I am working on a project, where I need to get reliable data from 4 incremental rotary encoders. The motors can spin at a maximum of 100 RPM, with 420 pulses per revolution. This makes a single encoder produce a square signal of around 700 Hz. Currently, the encoders are connected to the GPIO expander via I2C (400kHz), that fires an interrupt everytime one of the pins changes states (channel A and B x 4 = 8 pin changes). This works well for one motor, however, when I use multiple encoders, the frequency varies with time, as some motors rotate with a slightly different RPM at the same voltage.
I am using an ESP32 (DEVKIT-V1) microcontroller, and it is loaded with other tasks (I2C readings, PWM outputs, algorithm calculations, LCD control, etc.). Reading the data therefore produces innacurate results, as the processor misses ticks, when it is busy doing some other task.
My goal is to get the RPM of 4 motors to the ESP32 at around 10 Hz, so data can be used in the algorithm.
I currently see a few options:
- Try to find a multi-channel quadrature decoder IC that would communicate the number of ticks via I2C (not yet found).
- Include an additional dedicated microcontroller, which would obtain the data from the 4 encoders, and send the RPM values via I2C to the host processor in 10 Hz intervals. I am thinking about STM32's that include a quadrature encoder interface hardware.
What do you think would be the most practical and robust solution to get reliable RPM data from 4 encoders?
Thank you for your time.