PID programming help

We are reaching out to the CD community for with using the PID Eclipse C++ function for our bot. After spending the entire night with two students and two mentors we learned that the PID function has so many setups and sub functions that without any real examples we just don’t know what to code. So a lot of help would be greatly appreciated.

I can not post any of our code as it just doesn’t work but we will be using a Gyro as the normal input sensor but all we what back from the PID is a variable only as we will be using that variable in another part of our code that is not a motor function.

A sample of all the setup steps and a better explanation of what every thing does would be very helpful in understanding how a PID works.

Many thanks

*While you are waiting for responses, here are some links where you might find useful information:

http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/

https://decibel.ni.com/content/servlet/JiveServlet/download/14709-3-41047/[FRC%202012]%20PID%20Tutorial.pdf

http://www.controlguru.com/pages/table.html

http://www.inpharmix.com/jps/PID_Controller_For_Lego_Mindstorms_Robots.html

http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/

http://www.education.rec.ri.cmu.edu/previews/robot_c_products/teaching_rc_tetrix_preview/movement/improved_movement/documents/Movement_Improvedmovement.pdf

If you would give some details about what you are seeking to control with PID you will likely get more targeted answers here. For example, you mentioned the gyro. Are you trying to do field-centric control? Or are you trying the correct for drivetrain anomalies to make the bot travel in a straight line? etc.

Ether, thank you for all links. We will review the ones that we haven’t looked at yet.

The best application would be very close to your example of correcting a drivetrain to travel in a straight line but we can not have the PID directly feed the device hence the reason we just what the value from the PID. We have yet to find a way to just retrieve the PID correction value.

From a pure teaching point of view, it would be nice to see what the result would be with given input values.

What kind of drivetrain?

we can not have the PID directly feed the device

Can you explain why not? What device are you referring to?

See this thread. http://www.chiefdelphi.com/forums/showthread.php?t=114061&highlight=pidoutput

Given the very nature of the design “device” It would take a novel to explain.

To Ether and Ross,
Thank you for the links and information, it helped up to a point but we have found, like many others that our single very precious resource was being used up at an alarming rate. So we have chalk this one up to; yes failure is an option but lets learn from it and move forward. Perhaps after regional’s we might re-visit the task but a “101 Programming a PID function with examples” would sure help.

Just in case, the “precious resource” is TIME. Five weeks is just to short. We lose a week for exams ::ouch::

Post #12 http://www.chiefdelphi.com/forums/showthread.php?threadid=133100 also has a very nice to help understand what a PID does.

Look at the crab speed class in our code from last year. I think it does what you are looking for. Crates a generic class that he PIDController will write to that you can get with something else.