We are trying to run PID on our shooter this year to ensure that we are always shooting at a specified RPM. We have tried using the built-in PID on the SRX and the PID block in LabVIEW, but it doesn’t run correctly because the mag encoders are updating very slowly (2-4 times a second). We have tried using the “Set Status Rate” vi in LabVIEW to change the update rate to 5ms, and this doesn’t work. What are we doing wrong here?
I apologize if you already checked this, but is it possible that you may be mixing up the rate at which the Encoder updates its position to the Talon with the rate at which the driver station receives those updates? As far as I know, there aren’t any settings which would make the Talon or encoder update any slower. The Talon will always run closed-loop control at 1000 Hz and the magnetic encoders update fast enough to relay RPM in the thousands.
What symptoms were you seeing that seemed to indicate a 2 - 4 Hz update rate on the encoder data?
Would it be possible to verify that this is the sensor data and not the loop itself? This behavior is what you might expect if your P or I values are too high. You could disable control of the shooter and spin the wheel by hand to verify how fast the values update.
Here is a graph from our Talon - CTRE Magnetic Encoder - Flywheel setup that is showing velocity read by the driver station over time: imgur.com/uHDug0V. The update rate is a lot faster than what you guys seem to be seeing and I believe our setups are identical.
One possibility is that the velocity sample period or window size was changed from the default settings (100 ms period, 64 sample window). I believe that calling reset would set these back to normal, and, if not, they can be changed back through code or maybe the web dashboard.
We are using Java although that should not have any effect on Talon or encoder update rate. I still strongly recommend printing RPM while spinning your flywheel by hand with no loops running. A incorrectly tuned loop could very easily show large osculations in speed and appear unresponsive. If the speed update rate still seems low I recommend resetting the velocity position and window. A lab view example can be found in section 220.127.116.11 of http://www.ctr-electronics.com/downloads/pdf/Talon%20SRX%20Software%20Reference%20Manual.pdf. If neither of those produce solutions, you could re-flash the firmware entirely on the Talons, ensuring that all of the default settings are present. The Talons are designed to be plug-and-play with the CTRE Magnetic Encoders and will automatically report speed in RPM assuming they are connected correctly.
Beyond this, I am out of ideas for what could cause the symptoms you described above.