We have a Talon SRX (to a CIM motor, with a quadrature encoder) - it’s attached via a pullup / breakout board to the encoder.
On our test robot board (no robot, just control system), it seems to behave as expected:
using control mode kSpeed - …
(pseudo-code):
if (button1) {
talon.Set(1000.0); //turn it on.
}
if (button2) {
talon.Set(0.0); //turn it off.
}
the talon starts and stops when commanded.
On our real bot, though, it won’t stop once started.
(we also tried putting it in voltage mode; in that case:)
(pseudo-code):
if (button1) {
talon.Set(1.0); //turn it on.
}
if (button2) {
talon.Set(0.0); //turn it off.
}
Which works fine.
Stumped!
Martin Haeberli
(de-)mentor, FRC 3045 Gear Gremlins (formerly SWAT)
If you read the software reference manual, you’ll see a section on how to set up speed PID control on the Talons. Based on the first step of that section, your encoder and Talon outputs are probably opposite directions. So try either:
talon.reverseOutput(true);
or
talon.reverseSensor(true);
Either of those should fix it. If it fixes it but the motor is the wrong direction, you can switch which one you are using. If for some reason it still doesn’t work after that, you might want to check the roboRIO webpage and make sure you are getting encoder feedback on that Talon. Also, make sure you have the correct feedback device selected, PID parameters, etc.
It appears (and we’ll have to double check) that the PID does control to the target speed and direction. That is Set(1000) makes it go 1000 RPM in one direction; Set(-1000) at the start would go the opposite direction; but in this set of circumstances, Set(0) doesn’t stop it.
What does work, which is a horrible hack, is to switch to Voltage mode, Set(0), then set back to PID mode.
Thanks,
Martin Haeberli
(de-)mentor, FRC 3045 Gear Gremlins (formerly “SWAT”)