Before you get too far, do a little experiment to ensure the pots read the same relative values as you lift the scissor. I have a feeling one may be off a bit in its variable resistance so let’s try to make some software to account for that. But you can adjust for cheap variable resistors not playing nice.
You should measure the pot value in robot C using the debugger windows. Either measure the scissor angle, or the height of the scissor at various points. The height is probably easier, but make sure it is what the robot would push it to, not pulling it by hand from the top because it’s not how your robot will act on its own.
Make sure the left/right sides look relatively similar in their expansion. If you just trust the pot’s are the same left to right all the way up, you may be trying to adjust to what is not reality for your scissor.
Are the start values different? Are the values in between or the end values different? These establish the “good” sets of values your program will try and adhere to. Deviation from left or right from the measured height is what we’ll adjust to. You may want to measure a few times at various heights to make sure it’s still the same. Ensure the pot is really locked down and won’t move. (saw that one in gateway on a scissor and wondered why the preset heights weren’t so “preset” so it migrated up. Tightening some screws helped a lot. It was not the pot going bad, it was it slipped a bit.)
Input these values to a spreadsheet and plot these values in Excel. (or open office if you don’t have Excel) In a perfect world, the lines will be the straight and on top of each other with the same values all the way up. If this is the case, then stop here and program left to equal right as the error to compensate against. If not, then you have some work to do to determine how far off left and right is. Your code assumes left and right follow the same values all the way up and down.
If the lines are different, you want to make a formula of what left side and right side think they should be at various heights. You can also adjust/swap the pots until you get something nice, linear, and the same left/right.
Use Excel’s linear regression functions to get the formula of each line. You could do it by hand if you are a glutton for punishment. (Tip: The scatter plot in excel gives you the right linear regression, not the line plot. Make sure you back test the function to see the error from measured to see if the function is good enough)
If your line is not straight, choose different interpolation types to see what fits best to the data. Now you have two functions you can use to say you’re at different heights from the two pots.
You can figure out the height based upon the left pot and the right pot based upon this handy function Excel gave you. Now you have an error to work with for your motors.
If you are going up, the lesser height should get that side motor moving more or get the other side to move less. If you’re going down, slow down the speedier motor to let the other catch up.
How you do that can be a trick. A PD algorithm would work well I think or a simple trim to throttle back on the too fast side by no more than 5% each go around.
That’s another discussion but the scale of a pot is 4096 while a motor’s full range is 256. You are using an error that can be way over the motor’s allowed range. you will want to put some factor against the error to not have wild gyrations of the motor. OK, the limited range of motion of the pot on the scissor will be less due to not going 270 degrees but you get what I mean, 4096 is way bigger than +127. Don’t send a really big number to the motor for what should be a fine adjustment.
Wait 20ms and loop again to see the new error and adjust the motors again. In your code, you are constantly looping around and anything less than 20ms is not going to affect the motor so you might as well wait.
If you plan to do this, you need to re-validate it over time as the pot may slip to give new start and end values. Once you figure it out, it takes 10 minutes to re-plot the data and get a new function.
Team 80M used this measurement based technique in Sack Attack to keep their arm along the floor at a set angle or in a carrying position. Two pots measured the main arm and the scoop position to get the ideal values in the state of carry vs floor. Buttons controlled the desired state and position and made it a one person driven robot.
Oh yeah, and once again, math (and engineering) rules! 