So our team has been trying to make to put in our driver’s code a way to keep the power of the claw just enough to hold the claw at its current potentiometer position
-if the claw starts moving higher then the value the power will decrease, which brings it back toward the value
-if the claw starts moving lower then the value the power increases, which brings it back toward the value
We kind of got it working but it keeps overshooting the value… is there any way to fix this?
Looks like you want some sort of feedback control, like PID. You’ll probably be just fine with the proportional controller (i.e. I and D constants set to 0). I always recommend this tutorial for getting started with PID: http://www.wescottdesign.com/articles/pid/pidWithoutAPhd.pdf
If you don’t want to do PID, try lowering the speed of the claw to something more manageable. So if you’re currently setting to 127 if you’re off target, then do something slower like 100 and go from there.
Furthermore, you might get better results if you divide the output of
analogRead
by 10. The potentiometer is precise, and you can afford to chop off the last digit
Finally, try adding a deadband, so you stop your claw if you’re within a few units of your goal.
I would post what you have. Edjubah gave you what you need, but if you need more help, then it would probably be easiest for us and best for you if we built on what you already have.
The concept is the same. Assuming you know how to use a while loop and set motor power, it should be fairly easy to extrapolate a p control loop from what Oedipus Vex posted above.
Neat name, by the way. Ever read Oedipus the King?
The only part of that code that is specific to robotc is that motor[port1] = power would be motor(1, power). If you need examples of how to do things in PROS, see the tutorials on the pros website. You can also look at the code for the Open Source Starstruck Robot. Looking at these resources should let you come back with a more specific question if you still need help.