Zeroing CANCoders

Hi all,

I am working on programming a swerve drivetrain, and I seem to be having an issue with the orientation of the encoders. I am using 4 MK3 SDS Falcon swerve modules as well as 4 CANCoders. I have the CANCoders configured to report 0-360.

I am booting them to absolute position and am able to control the position of each module. My zeroing process is as follows:

  1. Turn each module so they are facing my desired zero.
  2. Take the angle of each CANCoder.
  3. Set the magnetOffset to the opposite of what each CANCoder reads.
  4. Reboot the robot.

This process is not working, and I am not sure why. Is there another way to zero the CANCoder? Print statements in my code make it appear as though the changing of the offset is working, but it does not appear to be.

Any advice is appreciated.

We manually grabbed the pulse width (not position) and zeroed in code last year. Pulse width was in increments of 250ns, where position is in increments of 1us. I believe the problem was that Talon SRXs don’t support zeroing remote sensors, and that may go for zeroing the sensor itself as well.

How did you grab the pulse width of a CANCoder? I’m also using Falcon 500s. Not to mention, I am using Python, but that should not be a limitation.

There should be a getPulseWidthRiseToFall method. Our 2020 code might be public on the 1072 github.

I think I might have found my issue. Thanks for the help anyway @asid61!