How to configure limit switches on a TalonSRX

Hi, I’m trying to configure a hardware limit switch using the configForwardLimitSwitchSource(); and configReverseLimitSwitchSource(); on a TalonSRX motor controller. What parameters should I put into these methods since the ones I got from Phoenix Tuner didn’t work?

Hello, if you are trying to run a command depending on the limit switch’s status, you can also connect the limit switch to the roboRIO and read the value from limit switch as an input then you can run the command with a simple if-else statement.

1 Like

I believe those methods tell the TalonSRX where the Limit switches are connected and needed if you plan NOT to wire them to the Data Port of the TalonSRX but to a remote TalonSRX or CANifier. https://github.com/CrossTheRoadElec/Phoenix-api/blob/master/src/main/java/com/ctre/phoenix/motorcontrol/LimitSwitchSource.java

What are your intentions?
Do you wish to switch them from normally open to normally closed?
Use a switch to zero an encoder? _talon.configClearPositionOnLimitR(true, Constants.kTimeoutMs);
Monitor the switch in your Code? _talon.getSensorCollection().isFwdLimitSwitchClosed(); _talon.getSensorCollection().isRevLimitSwitchClosed();

This doesn’t yet answer your question but points out that the method you asked about has many Overloads and parameter input patterns and possibilities here are the Java Docs:

http://www.ctr-electronics.com/downloads/api/java/html/classcom_1_1ctre_1_1phoenix_1_1motorcontrol_1_1can_1_1_base_motor_controller.html#a3a4684c9d978c3cae441cdcf165f520c

The Phoenix Documentation on Github includes examples for remote and non remote limit switches.