I know this has been asked many times before, but none of the answers I found are clear enough for me. How exactly do I program a PID loop to make sure our shooter is at the right rpm, compensating for variables such as battery voltage?
I know labview pretty well but PIDs look really complicated. We have a flywheel shooter with a US digital encoder. I would like to be able to input any rpm value I want (eg 1-8000 rpm) and have the motor automatically speed up or slow down to ~+/- 100 rpms of the requested speed.
Any help is greatly appreciated. ::safety::
You don’t have to program it; that’s already been done for you. There’s a PID vi in LabVIEW.
Your desired speed goes to the setpoint input. The encoder signal goes to the process variable input. The output goes to the motor.
You will have to “tune” (adjust) the P I and D gains to make it work right.
none of the answers I found are clear enough for me
Ask some specific targeted questions.
So what do I do from here? I am kind of a noob in complex data management.
It may be easier for you to use a CAN jaguar instead. CAN will do most of the PID work for you and there is an example already in labview for it. It’s actually quite simple. For PID calculations try using Ziegler–Nichols method. Just keep adjusting P until you get a set oscillation and then the rest is easy.
@Ether You can’t simply put the encoder into the PID process variable you have to find the speed of the motor using the encoder and put that into there. Correct? Unless I’m missing something.
You have to scale the process variable (the encoder signal) and/or the setpoint so they have the same range and offset.
If your process variable (encoder signal) has been scaled to represent RPM, then you have to scale your setpoint so it also is in RPM (and not, say, -/+1).
Or you can do it the other way. If your setpoint has been scaled so that it has the value +1 when you want MaxRPM, and it has the value -1 when you want -MaxRPM, then you should scale your encoder signal so that it outputs +1 when the device it is measuring is spinning at MaxRPM, and it outputs -1 when the device it is measuring is spinning at -MaxRPM.
From there, I would go to “Help” > “Find Examples…” and in the NI Example Finder search for “PID” and look for the General PID Simulator.vi (or any other one you would like to use)
In the block diagram of the example, I would copy the PID gain cluster and the bundle + chart with the PV Setpoint Output label, so your code might look something like below.
I like to include the graph so that the gains are easier to tune, as well as using the controls so you can adjust them while the code is running. (When you get the gains the way you want them, be sure to write them down and take out the controls and replace them with constants; they tend to reset themselves.)
Thanks guys! I’ll try to work off of that.