|Page 1 of 1|
|Author:||pgregory [ Mon Jan 12, 2015 8:42 pm ]|
|Post subject:||PID Control|
Hi guys im attempting to learn PID control for my robotics classroom. I was looking over some example code and was wondering if anyone can explain some of these statements to me or maybe to the whole code. I have been unable to find any teaching source for PID and at this point I have excelled my teacher so he is unable to teach me this.
The things i dont know are what these things stand for nLastPos, nPos, nNumbOfHits, nSensor, nWeight, ++nCycles.
I have no idea what the n in front of the statements mean aswell.
Here is the code that I am looking at
https://drive.google.com/file/d/0B7iyjv ... sp=sharing
|Author:||terbos [ Tue Jan 13, 2015 1:41 pm ]|
|Post subject:||Re: PID Control|
It is common in some styles of programming to prefix variable names with their type.
Thus, the 'n' prefix means this variable is a 'number'.
As for the other variables, I can guess at a couple of them, but the others aren't obvious when taken out of context. I can't follow the link you posted as it's blocked for me.
A PID control is designed to use sensors to adjust a robot in order to match a desired, or 'target', position or speed. To accomplish this task, the sensor is repeatedly sampled, and the reading is used to compute a correction, which is applied by turning a motor. Given that, I'd apply the following guesses to some of the variable names:
nSensor - is either the sensor number or the last raw value read from the sensor.
nPos - is probably the current position, derived from the last raw sensor value. This is where the sensor says the robot is right now.
nLastPos - is probably the last position. This is where the sensor says the robot was the last time it checked. Probably 1-20 milliseconds ago. This is used for the 'D' part of the PID calculation.
The others are unclear without context.
|Page 1 of 1||All times are UTC - 5 hours [ DST ]|
|Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group