More Problems with TalonSRX Posiition Control

Firstly we have read and gone through the CTRE documents for the TalonSRX and are still having issues. Specifically we are trying to set the position of an arm that is driven by a VexPro Versa Planetary gearbox into a CTRE Mag encoder with physical limit switches installed as well. Physically the system is working correctly with the limit switches stopping the arm correctly. According to the Web Dashboard, the motor and the sensor are in-phase and working correctly.

I know we are probably just missing some configuration setting for the TalonSRX, but we have spent multiple hours trying to check example code and going over documents but still can’t get it right.

The issue is with the closedLoopError. If it shows up correctly (on the SmartDashboard) then the position control works correctly. However, many times the ClosedLoopError is not correct and actually is not changing like we would expect. It is almost random.

This is why I thought it was some kind of missing configuration variable.

Our code is freely available on https://github.com/Team997Coders/BunnyBotElmer and the specific code is in the ArmJoint Subsystem and ArmToAngle Command.

(I could have included the code, but this way I won’t forget something)

If anyone can help us figure out what is missing, we would appreciate it.

Thank You!

Have you checked that all of your encoder wire connections are tight and you don’t have any broken wires? An intermittent break in an encoder cable could cause this sort of behavior - working fine sometimes, completely out to lunch another.

That sounds like an electrical or CAN bus issue. Check the CAN Bus utilization on the driver station, swap/test the encoder cable and, if possible, swap the encoder. I like the commit messages, by the way :stuck_out_tongue:

Wiring was out first thought, however…

1 - We can still move the arm so we know the CAN is connected and talking, just intermittent response on the closedLoopError

2 - We are sending the closedLoopError, the Encoder postition and the getPosition() information to the SmartDashboard and they are responding correctly. So the encoder cable should be connected.

We could be saturating the CAN bus, but we only have one TalonSRX, a PCM and the PDP on the Bus (besides the roboRio). I will have to check the utilization.

Thanks

Given the troubleshooting to date, are the values being correctly and consistently updated? If there’s some lag or jumpy updates it’s possible your CAN is overutilized (as discussed) or that you are getting some amount of error on the CAN bus that’s interfering. (Could be dodgy cabling, connector issue, CAN wire not twisted, etc). I don’t have access to our test elec board until Friday so I don’t recall if CAN errors show as “utilization” on the DS, someone else may be able to help there.