# PROS "enough" loop

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

by 10. The potentiometer is precise, and you can afford to chop off the last digit

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.

Could you post a sample PID loop? It would help to have some sample code

potentiometer = current;
desired angle = target;

while(true)
{
error=target-current;
power = kp*error;
motor[port1] = power;
delay(20);
}

I need PROS code though…

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?

haha it was a joke from 2 years ago, and no, just Oedipus at Colonus and Antigone

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.

Can we still use rubber bands with a PID Loop?