Hi there,
My setup includes the following components:
- 1 Raspberry Pi Zero W
- 2 Pololu Micro Metal Gearmotor #3056
- 1 Pololu DRV8833 Dual Motor Driver Carrier #2130
- 2 Pololu Magnetic Encoders #4761
I’m able to successfully run both motors in both directions, but I’m struggling to track the ticks on the encoder. I’m reading in ticks using both sensors on each encoder and dividing the total tick count by 12 (CPR) x 298 (gear ratio) to compute 1 revolution. However, when I tell a motor to cycle 1 revolution (3576 ticks with my setup), it moves the motor about 1.5 revolutions.
I think my code on the Pi is missing ticks as they go by, making it take longer for the code to count the ticks required for 1 revolution. From what I can find on the internet this error seems to be due to the fact that the Pi is occupying itself with other tasks besides counting the ticks leading it to miss some while it completes other tasks. As was mentioned on this forum, the Pi doesn’t have a “real-time operating system”.
It seems that one option may be to try to get around this the software way with some interrupt handling, but I’ve struggled to implement this. Another option it seems is to have another piece of hardware dedicated to counting the encoder ticks so that no ticks are missed, such as this.
Does Pololu offer a piece of hardware like this? Ideally it would be smaller than the Raspberry Pi Zero W (i.e. length < 60 mm). Do you have any other suggestions?