Encoder Information Unknown

Hello,

I’m the lead programmer for FRC team 3482 and we’ve been having some trouble using the am-2816a encoder from your website. We have successfully hooked it up and it appears to function correctly but we have had some trouble using it. The goal is to have PID absolute position control but we haven’t found the settings required. Primarily, we believe we need a codes/counts per revolution number for the encoder but its unclear if that’s the same as the pulses per revolution number listed on the product page. Currently, we just have the encoder hooked up to the roboRIO directly but may try hooking it straight into a talon srx (so we can use code that is confirmed to work on the ctr encoders – https://github.com/CrossTheRoadElec/FRC-Examples/blob/master/JAVA_PositionClosedLoop/src/org/usfirst/frc/team469/robot/Robot.java). Could you clarify what the codes/counts per revolution is and if available provide some sample code for closed loop position control?

Thanks,
Corey Mason

*The am-2816a is listed as 7 “Pulses Per Revolution”. Since 7 is an odd number, that must mean 7 cycles per rev, which is 7 rising (or falling) edges per rev per channel, which is 14 rising+falling edges per rev per channel, which is 28 quadrature edges per rev.

So if you decode it at 1x you’ll get 7 “counts” per rev, if you decode it at 2x you’ll get 14 “counts” per rev, and if you decode it at 4x you’ll get 28 “counts” per rev.

Hi guys,
I am another programmer from the team who asked this question, We have been using the ratio suggested by Ether (7*50 – 50 is the gear ratio), and the PID with a value of P=1.0 (we know this isn’t a great value) and I and D equal to 0. The PID corrects the position very slowly for some reason and we don’t know why. When we were using PID for a VEX Integrated CTR Encoder with which we didn’t need to use the codes per revolution (since it was preset, but it was somewhere around 4096 native units), the motor would correct very quickly with just a P=.3. Are we doing something wrong and should the codes per revolution be different?
Thanks,
Rohin

I am coaching a rookie team and still figuring all this out myself, but I did just successfully program that encoder yesterday.

We have that encoder on the back end of a motor with a 71:1 gear reduction. So with 7 pulses per rev x 71 we get 497 Codes per Rev. Multiplied times 4 for Quadrature is 1988, which I actually verified was the output from one rotation by reading System.out.println(talon.getEncPosition());

So ultimately I used the 497 as the Codes per Rev, but when I used the talon’s PID set function for distance, I had to do it a slightly different way:
If I wanted one-half rotation (which is 497 * 1/2 * 4 = 994), then the line of code I would use was
talon.set(994/1998.0)

For some reason, it uses position in terms of rotation as its metric for determining how far to go. Maybe this is normal or maybe there is a way to change that part of it – we are still learning.

Anyway, I hope that helped!