CANTalon SRX kPosition help

We have the SRXs setup with AM-2899 Absolute Encoders connected to the breakout board. They are configured as analogpot with ConfigPotentiometerTurns(360). This gives us a nice 360 degrees of values as we turn the encoder.

We can then set kPosition to 0-360 and it will move to that position. The problem is that if it is at 10 and we set it to 340, it moves 330 instead of crossing 0 to get to 340 (much shorter). I was surprised that it acted this way. Is there configuration to allow it to take the shortest path?

To my knowledge, that’s something you’re going to need to handle yourself. You should try using the AnalogEncoder sensor mode instead, which handles wraparound like you’re thinking.

Just remember that when you cross 0 the resulting position values will be negative, so in your example you’d want to command the SRX to move to -20 from 10 instead for the same effect.

Without looking up the code, remember that most potentiometers have a hard stop that will be destroyed if you move past it. This is probably coded in on purpose for exactly that reason. If you use it as an encoder it should fix the problem.