First off you need to make sure that motors and sensors are in phase with each other. In terms of the Talons, that means that when the LEDs are blinking green, that your encoder is going in a positive direction and when your LEDs are blinking red, your encoder is going in a negative direction.
None of this will work until you’ve gone through the entire Bring-Up Process that CTRE documents.
Once you have finished that, meaning you started from the beginning and didn’t skip any steps, then you are ready to start closed-loop control modes.
The next thing you need to understand is the physical mechanism between the encoder, and the actual thing you want to turn. For example, here’s how I would formulate the calculation to rotate my drive train wheel one time, in encoder ticks:
We use a 4 CIM motor setup, with ball shifting gear boxes. So, we actually have to account for two different stages from where our shaft encoder is plugged in, to actually spinning the wheels. The encoders plugged into that gearbox are Greyhill 63R-128. The 128 represents the number of cycles in one rotation.
The math lays out like this:
ticks per axle rotation * 3rd stage gear reduction * 1st stage gear reduction = encoder ticks per wheel rotation.
For our setup
128 cycles per rotation = 512 (4 edges per cycle with the quadrature encoder)
3rd stage gear reduction = 36/12 (ask your mechanical team about the gear reductions in the mechanism if you don’t know)
1st stage gear reduction = 64/20
Putting that all together = (512 * (36/12) * (64/20)) = 4915 ticks per wheel rotation.
To convert to a distance (however you measure, metric or imperial) we take 4915 / measurement.
In the case of a turret you may want to convert ticks to degrees or something, so 4915 / 360 would give you how many encoder ticks represent 1 degree of rotation.