Java Falcon500 integrated Encoder .setDistancePerPulse() issue

Hi our FRC team is working on building a MK3 swerve drive robot. We have programmed everything we need to get the swerve working we believe but we haven’t had a chance to test the code yet. The problem we are facing is that we are not able to .setDistancePerPulse() or get the rate for out integrated TalonFX encoders on our Falcon500 which are wired through CAN. We also have SRX Mag Encoder declared as CANCoder and are wondering what the get() equivalent for them would be from Encoder(). Thanks for any help in advance.

I saw that you liked my post here. I think your issue is the same. The WPILib Encoder class has .setDistancePerPulse(). It sounds like you are using a CANCoder which is a CTRE product and uses the CTRE library. Here is the documentation on using the CANCoder in code. As I mentioned in the post linked above CTRE does not have an equivalent function to .setDistancePerPulse() you should just multiply by the distance per native unit.

If you actually mean CANEncoder like you wrote the only CANEncoder I know of is using REV’s library which is totally different.

Yea I meant CANCoder not CANEncoder, we will definitely try the way you mentioned in your post. Thanks for the help!

Hi, I have questions as well. We are using Falcon 500 motors in our swerve drive, and we need to use the encoders built in them which I believe are the Talons. To declare these encoders would we say they are TalonFX’s, that’s what we are doing now. Also, our swerve modules are daisy-chained via CAN wires, so I’m wondering when initializing these talon encoders what port we would reference for each?

Falcon500 have the TalonFX as a built in motor controller.

See this CTRE document on using the Falcon500 encoders.

I don’t fully understand what you mean by what port you would reference. As you can see in the document above you can use Phoenix Tuner to determine each Falcons CAN id. Then you will just use the onboard sensor. Here is a CTRE Example of using the onboard sensor to get position (and do a position closed loop).

1 Like

Just to clarify - by default, CANcoder uses degrees and degrees per second.
However you can change this by modifying the coefficient and timebase configurations.

The only time you need to use native units for CANcoder is when it’s used as a remote sensor for a motor controller.

It’s correct that the integrated encoder in the Talon FX does always use native units and cannot currently be scaled.


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