Ctre Falcon 500 built in more encoder

Does anyone have working example code to pull data from the built in encoder.

There’s some bits of code in the docs, but not a complete example.

As a learning exercise, could you describe what you’ve tried and how it wasn’t working? Perhaps we could help you troubleshoot that. If you haven’t tried yet, I definitely recommend giving that a go first.

To get you started, you likely have a WPI_TalonFX object, so what methods do you see in the docs that might get you what you need? (hint: you may need to look at the parent class, TalonFX)

1 Like

I know how to access the encoder values but converting them to meters for RamseteController has been a pain. I am using PathPlanner. The test path is 1.69 m long but the values come up as ~3 meters.
Here is my conversion method:

public double encoderTicksToMeters(double currentEncoderValue, double encoderFullRev, double gearRatio, double wheelCircumferenceInInches) {
    return (currentEncoderValue * Units.inchesToMeters(wheelCircumferenceInInches)) / (encoderFullRev * gearRatio);

Any suggestions?

Not sure how you have written your gear ratio and encoderFullRev in code, but I did it like this:


first, get the motor revolutions by dividing the encoder counts by the “Counts Per Revolution” of the encoder, then get wheel rotations by dividing by the gearbox ratio, then multiply by the meters per wheel rotation (wheel circumference) to get how far the robot has traveled.

I’m not sure if this is actually different from your math, I’m having a hard time figuring out the steps in your code. The other things I can think of are, double check your constants, and also incorrect pid/feedforward gains can cause the robot to overshoot - but you’d probably realize if the robot was going 3 meters instead of 1.69.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.