Using LabVIEW I can use a auto PID where it fixes the PID as it is being ran. Can I do this with C++ and how do I use a C++ PID loop. I have used a PID loop before in LabVIEW but I can’t understand how to do it on c++ using the wpiLIB. If you can provide simple code to help or give a website other than wpiLIB that would be appreciated. Thanks!
I know you said site that is not WPILib but it actually has some useful info
http://wpilib.screenstepslive.com/s/4485/m/13810/l/241879-operating-the-robot-with-feedback-from-sensors-pid-control?id=241879-operating-the-robot-with-feedback-from-sensors-pid-control
Make sure you’ve read this. It has extensive information and example code
Thank you . For some reason after 20 mintues of googling that page didn’t show up for me.
I’m curious what you mean by this. Would you please explain?
This code isn’t as smooth as a perfectly tuned PID but we couldnt use that because the thing we used the PID rotated vertically on a shaft so the PID needed to constantly update because based on the angle of our shooter gravity would effect it differently.
Hi Noah,
Normally I wouldn’t post (relatively) untested code, but if simple is what you want the attached may work for your needs. I just tossed this together the other day (I intend to make this a development task for some of our software kids, if you’re on Team 230 stop looking!). BTW, we use the simple robot class with C++ and do our own loops, just seems to be easier that way.
Cheers,
Steve.
P.S. Don’t tell MamaSpoldi I’m posting code, I’ll get in trouble:ahh:
pid.c (972 Bytes)
pid.h (300 Bytes)
example.c (453 Bytes)
pid.c (972 Bytes)
pid.h (300 Bytes)
example.c (453 Bytes)
No worries. I am always happy to post our code whenever it is needed by someone. Besides, as you mentioned, that is your code, not code developed by our students. Either way it is always good to share!
Save