Our students are currently trying to reprogram last years robot with Command based programming. Last year we used a homemade PID function to controller our arm instead of wpi’s PIDController.
We are now trying to use PIDController with the arm; one potentiometer is the input. When we set the set point to a known location and enable the PID, the pid outputs -1 100% of the time, when we move the arm across the known point the pid output never changes. Below is how we have the ReturnPIDInput defined.
We have had success with controlling the Shooter with a PID but we cannot get the arm to work.
Is it possible the PIDController is trying to read a voltage too quickly from the pot and we are recieving a NULL value back?
When we read directly armPot->GetAverageVoltage(); we get expected values that range from 0 - 3.
However we believe the PIDController is not receiving that value.
We are using PID values from our previous PID loop, but we are not even trying to power the motors in this debug stage.
If we manually move the arm across the setpoint we should at least expect a change from the output of the PID to go from a negitive number to a positive number or vise versa. We currently do not see that.
Thanks nightpool. Interesting results. When reading armPot->GetAverageVoltage() we receive values that range from 0-3. (armPot->GetAverageVoltage() is what we return as the input to the PID loop). However when we read armPot->PIDGet() we receive values from 300 to 600. When we change our set points to match what PIDGet is receiving the PID works as expected… Not sure what is going on here, but at least we have a solution.
I think the PIDController is getting integer counts ranging from 0-1024.
Interestingly, we’ve been using the HOT_PID controller for years, starting in 2010. Now, we are doing exactly the same thing this year, switching over to commands and WPI PIDController.
This was confusing to us as well when we switched over. Try reading armPot->GetAverageValue. That should give you the same value as the PIDGet function.
Just give it an integer value in the 0-1024 range instead of the 0-5V range, and you should be good.
Thanks Jeff, we’ll be sure to try the GetAverageValue function with setting the range differently. Glad HOTPID helped you throughout the years. We are sad to not use it anymore as well, but when PIDController works, it works great.
The hardware returns a value between 0 and 1023 for 0-5V. The library will return either the hardware value or the voltage and it’s important to be consistant in your units otherwise the output values will be way off.