When I type PID.setSetPoint(), what value is it looking for me to input? Does it want counts per second, degrees per second, ect?
That depends on how you set up your PID loop. For our PID loop we are using RPM as the input and we get motor power out. It would also depend on what you are using your PID loop for.
You should have a set point you are trying to achieve.
The process variable (current measured value)
The PID values
Limits (This could be anything +/- 1, 0-1VDC, 0-5000RPM, 3500-5000RPM etc…)
Output would be a number somewhere in the range of your limits.
I am using my PID to maintain a certain RPM with input from an encoder (which would read counts per revolution) using 4x decoding at 120 cycles per revolution, so I have
pidShooter = new PIDController(Kp, Ki, Kd, encoder, motor);
now say I’m trying to maintain 1000 RPM, what do I put into PID.setSetPoint() to achieve that? If I am still missing something let me know.
Your set point should be 1000 as long as the input to the PID is in RPM and the process values is in RPM. If the input to the system is pulses then you are going to read pulses on the process variable and change the motor output.
You have two options here:
One: figure out how many pules it takes to get to 1000RPM and have that be your input. I your case 120 (counts in one revolution) * 1000 RPM = 120,000 pluses. This way you could read pulses into your PID and it would adjust. In this case 120,000 would be your input to the setpoint.
Two: convert pulses to RPM and feed this into your PID loop. I this case you you have the set point of 1000 and you would read RPM.
Either way will work.
Thank you for the help, hopefully things will go well when I get a chance to test this.