Keeping up with lots of interrupts (two encoders)
Posted: Sun Mar 19, 2017 2:59 pm
So I have a project for tracking two encoders and making their values available via WiFi to make it easy for people to locate object in the night sky with their telescope. Typical encoders used for this kind of application are between 1K and 10K CPR (clicks per revolution) which translates to 4K to 40K per revolution after quadrature decoding.
I'm currently using 2.5K CPR US Digital encoders: http://www.usdigital.com/products/encod ... y/shaft/S2
On my telescope, I use the 10K CPR version of the same encoder.
The problem is that I'm finding by using interrupts on all four pins, I'm missing events (on CHANGE, the old value == new value). I'm using a MCP1825S (with the recommended caps) to supply power to the ESP-12F and TXB0104 which I'm using to convert the 5V encoder signals to 3.3V for the ESP, so I'm pretty confident this isn't a problem with power which seems to be a common issue.
So I'm hoping to get some guidance.
First, is there anything I can do to improve the performance of my existing code? For example I know digitalRead() on the AVR chips is pretty slow, but sounds like it's much faster on the ESP8266. https://github.com/synfinatic/esp-dsc/b ... sp_dsc.ino
Another option is to stop using the Arduino environment and program directly in C using the ESP SDK. Not sure if that would provide better results?
Alternatively, I can use something like the LSI LS7366R chip to handle decoding of the encoders, but those are ~$5/ea and I'd need one for each encoder which would obviously dramatically increase costs (and those damned chips are not widely available at Digikey/Newark/etc!)
Or possibly, the internal pullup on the ESP GPIO pins are strong enough and I'm just seeing noise? Honestly, I don't think this is the case as dropping interrupts only seems to happen when I'm moving both encoders at the same time.
Any other ideas? Thanks!
I'm currently using 2.5K CPR US Digital encoders: http://www.usdigital.com/products/encod ... y/shaft/S2
On my telescope, I use the 10K CPR version of the same encoder.
The problem is that I'm finding by using interrupts on all four pins, I'm missing events (on CHANGE, the old value == new value). I'm using a MCP1825S (with the recommended caps) to supply power to the ESP-12F and TXB0104 which I'm using to convert the 5V encoder signals to 3.3V for the ESP, so I'm pretty confident this isn't a problem with power which seems to be a common issue.
So I'm hoping to get some guidance.
First, is there anything I can do to improve the performance of my existing code? For example I know digitalRead() on the AVR chips is pretty slow, but sounds like it's much faster on the ESP8266. https://github.com/synfinatic/esp-dsc/b ... sp_dsc.ino
Another option is to stop using the Arduino environment and program directly in C using the ESP SDK. Not sure if that would provide better results?
Alternatively, I can use something like the LSI LS7366R chip to handle decoding of the encoders, but those are ~$5/ea and I'd need one for each encoder which would obviously dramatically increase costs (and those damned chips are not widely available at Digikey/Newark/etc!)
Or possibly, the internal pullup on the ESP GPIO pins are strong enough and I'm just seeing noise? Honestly, I don't think this is the case as dropping interrupts only seems to happen when I'm moving both encoders at the same time.
Any other ideas? Thanks!