ESP-DSC Works Not Well!

So yesterday I was all happy that I got my prototype ESP-DSC working. This ended up being short lived as I realized this morning that while it does technically work, the ESP8266 can’t keep up with two medium resolution (2,500 CPR) encoders.

Ironically, I found out that the code was too slow when I started to optimize the code and I realized that the code I has was very very conservative. My original optimization was to speed it up, but maintain that conservative ethos. I figured while I was editing the code, I might as well also add a test to see if the ESP-12F was dropping interrupts…

It turns out that it can keep up with one encoder just fine, but when both encoders are moving at medium to fast speeds, the ESP8266 can’t fire off the interrupt handlers fast enough to keep up. It could just be a case of two interrupts happening at exactly the same time or just simple overload. I’ve spent a fair bit of time optimizing the code even more, but tests show that it’s not enough. I’m pretty sure if I forced myself to always move the scope slowly with these encoders it would work, but if I ever moved it too fast it would become less accurate over time.

To make matters worse, my telescope uses 10,000 CPR encoders so I’m going to generate 4 times the amount of interrupts for any given movement of my scope. That will clearly not work in the real world.

So right now I seem to have a few choices:

  1. Rewrite my code in C using the native SDK. May not actually improve performance any and would be a PITA to do.
  2. Use something like the LSI LS7366R-S encoder counter to handle decoding the encoders. Downside is they’re about $5/ea and aren’t carried by places like Digikey/Newark and require additional components (crystal, capacitors, resistors).
  3. The even more expensive HCTL-2022 which costs about $10/ea, is a large PDIP chip, but is available via Digikey/Newark
  4. Redesign the board to be more like the Teensy-DSC and only use the ESP-12 for WiFi duty and use a Teensy 3.2 or LC for the encoders for $12-20.
  5. Use AtTiny84 as high speed counters like this guy? Would have to program them in AVRStudio though. Less then $1/ea though.

I’m really surprised that the options for a quadrature decoder chip are so limited- you would think with robotics/PLC’s, this would be common. I guess most of these are low RPM situations or people use use a small FPGA/CPLD?

Based on the experience of that on guy on the Arduino forums, I’m somewhat tempted to do it via the AtTiny84 as that would be the most cost effective (although it would require programming them via ICSP). The next best option is the LSI LS7366R-S, but that is 5x more expensive and less available.

Leave a Reply

Your email address will not be published. Required fields are marked *