PID

Does anyone know how PID works and how to apply it to RobotC?

PID stands for Proportional Integral Derivative. We use it in our claw. It takes the angle of the claw, subtracts it from the angle that it is supposed to be at, then sets the difference as the power to the claw motors, that way, the further away the claw is from where it is supposed to be, the more power the motor receives. This link might help.

ok so how do I put this into effect.

There are already a lot threads covering this. Just use the search function.

What do you need help with? If i knew what exactly you were wanting, I would be able to provide more help, I might even program it for you.

I also wanted to know what can it be used for.

It can be used on a flywheel to keep it running at a certain speed, you can use it on your drive system to make sure you don’t stall your motors, etc. You can use it for pretty much anything that you need to keep in a certain position or at a certain position.

We use it for the position of our lifting arm, and keeping the position of our claws that aren’t tied together. We still just use a while loop for driving in autonomous.

ok so how would I do that.

clawangleleft and clawangleright are the potentiometers on each side of the claw. The code is such that the further away a claw arm is from its desired position, the more power it sends to the motor.

int clawset = 0
if(VexRT[Btn5U] == 1)
{
clawset = (clawset + 2)
}
if(VexRT[Btn5D] ==1)
{
clawset = (clawset - 2)
}
if((VexRT[Btn5U] == 0) && (VexRT[Btn5D] == 0)
{
}
while(true)
{
motor[clawArmReft] = ((0.3)*((clawset) - (sensorValue[clawangleleft])));
motor[clawArmRight] = ((0.3)*((clawset) - (sensorValue[clawangleright])));
}

That’s just proportional control… He asked about PID. However, since you are just learning how to implement it I would recommend starting with just P because it does the majority of the work anyways.

Let's Make a PID Loop Episode 1 -- Basic Setup - YouTube

That’ll link you to a great tutorial video that is a series that you should check out that teaches how to make a PID loop

Last year, my team focused very heavily on PID. We dug up an old manual by George Gillard of New Zealand and it proved to be extremely useful. Here is his website and a PDF of the guide. It is quite a read, but it’s everything you need to know and more.

[%between%](http://georgegillard.com/documents/2-introduction-to-pid-controllers)
introduction_to_pid_controllers_ed2(1).pdf (402 KB)