CANTalon SetCurrentLimit doesn't work

Hello everyone,

I am using a Talon SRX motor controller with the CANTalon library, in C++. I am trying to set a current limit so my robot doesn’t destroy itself. :slight_smile: This is my configuration code:

CANTalon *talon = new CANTalon(0);
talon->SetFeedbackDevice(CANTalon::QuadEncoder); // Relative encoder input
talon->ConfigEncoderCodesPerRev(10240); // One rotation, after the 10:1 gearbox
talon->ConfigNominalOutputVoltage(0, 0);
talon->ConfigPeakOutputVoltage(2.5, -2.5);
talon->SetControlMode(CANSpeedController::kPosition); // Use integrated PID

Unfortunately, no matter what I set the CurrentLimit to, and despite my use of a low voltage, absolutely nothing changes. I can remove it altogether and the motor isn’t any more difficult to stop.

Has anyone had this issue before? What workarounds did you find? I’m following precisely the example code in the manual for the Talon SRX, and the manual says that it works in all positioning modes, so my use of kPosition and the PID shouldn’t be an issue. Right?

Have you measured the current going into the motor? Either with an external meter, or what the SRX or PDB can measure? I’d trust the external meter the most. At small currents, I know for sure the PDB measurements will get inaccurate (Don’t recall for SRX).

To cross-check the measurement, can you check also what voltage the SRX is sending to the motor?

Given an input voltage and a stalled motor, the theoretical current draw will be:

<stall current @ 12V> * <input voltage> / 12

Make sure the measured current & voltage are close-ish to this.

All this work is to answer the question - are you certain the motor is drawing more than the set current limit? I haven’t actually used this feature, but it’s in our to-do list in the off-season to do some validation on it in prep for drivetrain controls this season.

Have you updated your talons to the latest firmware? Talon version 2.20 is when they added the current limit.

In the Talon SRX Users manual, ConfigPeakOutputVoltage() is only used in the motion magic sections; it may not affect the kPosition mode.

However, setCurrentLimit() is claimed to affect all output modes (9.3). As you are enabling the current limit, the only possible sticking point I notice is that you’re using an integer value instead of a float for setCurrentLimit().

What type of motor are you using? Some motors really don’t pull that much at 12V, so at 2.5V their stall current is really low. This one for example: