A library for reading rotary encoders (ESP-8266 and Pyboard/stmhal)

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: A library for reading rotary encoders (ESP-8266 and Pyboard/stmhal)

Post by pythoncoder » Tue Nov 28, 2017 6:36 am

The ESP8266 RTOS is closed source and much has had to be learned by reverse engineering. There is little if any control over its resource use.

As I understand it the ESP32 RTOS runs on one core and MicroPython currently runs on the other. You'd think this would improve interrupt latency but, while it's better than the ESP8266 it's still poor compared to STM targets such as the Pyboard.
Peter Hinch
Index to my micropython libraries.

ris8_allo_zen0
Posts: 6
Joined: Sun Mar 11, 2018 4:55 pm

Re: A library for reading rotary encoders (ESP-8266 and Pyboard/stmhal)

Post by ris8_allo_zen0 » Wed Mar 21, 2018 7:52 am

OutoftheBOTS_ wrote:
Fri Nov 24, 2017 8:50 pm
I am using a quadrature motor encoder, it is a magnetic encoder with 11 pairs of poles poles attached to a motor and the motor has a 31:1 gear box so I get a very resolution per rotation. I have tried both writing my own routines and using the great 1 written by spotlightkid. I have found them to work perfectly for freq with less than about 900 signals per second but at any higher speeds it starts to miss ticks.

Have others found this problem??
Yes I have. I too have a geared motor with encoder, albeit with an optical one. It works good when moved manually (I have a video, see https://www.instagram.com/p/BgfziFQlPxp), but when running it misses steps big time.
In the past I managed to read encoder positions at higher speeds with the Arduino platform (both on ESP8266 and with an Arduino Micro). I'm thinking about having the best of both worlds by writing a native Micropython module to read the encoder position. I'm not fully committed though; I may opt for a two-microcontroller solution (esp8266 + arduino micro).

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: A library for reading rotary encoders (ESP-8266 and Pyboard/stmhal)

Post by OutoftheBOTS_ » Wed Mar 21, 2018 8:51 am

In the end I have been using an external counter chip LS7366R as it frees up the MCU with the overheads of counting the encoders especially as my robot has 2 motors with encoders, each encoder has 11 poles with a 31:1 gear box with 4 signals per pole makes 1364 signals to count per revolution per motor. With 2 motors having top speeds (not really used at top speed though) of 240RPM means over 10,000 signals per second.

The counter chips not only removed the overheads they also freed up some GPIO pins as already has a SPI bus in use for the TFT so just need a CS pin for each encoder chip I want to add instead of the 2 encoder pins for each encoder

Post Reply