Wrong or incorrect CPR count on motors

I recently purchased these motors. They work perfectly fine except for the fact that the CPR is wrong on both of the ones I bought. I’m not sure if it’s because I was shipped the wrong motors or my code has a problem. I made a post on the Arduino forum in an attempt to find the solution but was referred here. To see my code check out that post.

Thanks,
Ian

It is very unlikely you were shipped the wrong gear ratio, but you should be able to confirm by looking at the engraving on your gearbox as shown here (GB37-70 specifies the 70:1 gearbox).

How far off is your result? You should get 4480 counts per rotation of the output shaft of the gearbox. I have not looked through your code thoroughly, but it looks like you are only setting your interrupts up to catch rising edges instead of all transitions (rising and falling) and only looking at one channel of the encoder. Please note that to get 64 CPR you need to count the rising and falling edge of both encoder signals, so I suspect you might be getting about quarter of that.

You might try taking jremington’s advice and use Arduino’s encoder library. As he mentioned, it is already known to be working and reliable so it would be a good way to test the hardware even if you want to use your own implementation after you confirm it’s all working.

Brandon

I am only counting the rising edge of one of the encoders. So would the subsequent equation equal 16*70? due to it being one fourth of the 64 CPR? Currently, I’m getting about 4.3 revolutions for 4480 ticks

As I pointed out in your thread on the Arduino forum, that counts only 1/4 of the edges, so at best you get 1/4 of the encoder resolution. There are other problems with the code that may explain missing or extra pulses that further confuse the issue.

Try a proven encoder library!

1 Like