CTRE Mag Encoder Relative vs Absolute for Position

I’ve heard that using the CTRE Mag Encoder in relative mode with limit switches is more accurate than using it with just absolute mode for position closed-loop, but I haven’t seen anything that really shows how inaccurate the absolute mode is. Does anyone have any specific numbers for this or knows if this is negligible for most FRC purposes?

Pretty sure both of them are effectively 4096 Counts per rotation. The PWM (absolute) is natively 4096, and the quadrature (relative) is 1024 * 4 = 4096. The benefit to quadrature/relative is that it works more reliably at higher rotation speeds. The answer to your question is pretty dependent on what you intend to use this for.

The use case is a wrist. I know last year, we used some multi-turn pots for some of our use cases where this wouldn’t have worked well (Pot on a wrist at the output shaft, that then turned a 2.33:1 geared wrist and a DART actuator that needed a 10-turn pot). This is more of an interest since I’ve heard this a lot, but couldn’t find anything significant to back it up and a backup plan if we need to design out limit switches on our wrist/intake.

For a wrist with presumably <360 degrees of rotation, I’d stick to the absolute mode. Just less of a headache, as you’ll immediately know the real-world position of the wrist. You won’t be moving fast enough that you’ll saturate the update rate of the PWM output from the absolute mode.

There’s a few considerations. The first is the resolution, here’s some example calculations comparing angular resolution (degrees) of different sensor types with different ways of reading them and mounting them. In order to have good control, your sensor needs to be able to have several times the resolution that you want to control to. So, if you want your mechanism +/- 1 degree, you should choose one of the options that is lower then 1 degree.

The TalonSRX a2d is 10 bit resolution while the RoboRIO is 12 bit, so you get more resolution.

Direct 2.33:1
RoboRIO 1 turn potentiometer 360/4096=0.088 N/A
RoboRIO 10 turn potentiometer 3600/4096=0.88 3600/4096/2.33=0.38
RoboRIO Quadrature 360/4096=0.088 360/4096/2.33=0.038
TalonSRX Absolute 360/4096=0.088 N/A
TalonSRX Quadrature 360/4096=0.088 360/4096/2.33=0.038
TalonSRX 1 turn potentiometer 360/1024=0.35 N/A
TalonSRX 10 turn potentiometer 3600/1024=3.5 3600/1024/2.33=1.5

The other thing to consider is for a limit switch, how quickly can you respond, which will control how accurately you can calibrate. The naive way is to poll in your main (20ms loop) but the mechanism can move a lot in 20ms, which adds error in your calibrations. There are other methods (interrupts) that add complexity. 971 uses the RoboRIOs DMA to look at the history of exactly when the limit switch tripped compared to the sensor position, but that’s several levels of complexity. I’m not sure if the SRX has something built in, or if you’re limited to polling. You can help this by having a hard stop that the mechanism is against when you calibrate.

0.088 degrees is plenty of resolution if you can mount the mag encoder to the wrist output directly, and that’s what I’d do for simplicity.

2 Likes

It should probably also be mentioned that potentiometers use an analog signal, whereas the TalonSRX encoders in absolute and quadrature modes have digital signals. Analog signals are much more sensitive to noise than digital signals. So even though they technically have the same resolution, the TalonSRX encoder will give a more precise measurement.