How does timer encoder mode work?
Re: How does timer encoder mode work?
Not sure if you're using the timers to interface to a Rotary Encoder but, if so, I've found Spotlight Kid's Encoder library works great...
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: How does timer encoder mode work?
[quote="evidlo"]I modified the code as pythoncoder said and tested successfully with a quadrature encoder...[/url]
If you've no objection I'll update the original to reflect these changes which should provide portability to any MicroPython platform.
If you've no objection I'll update the original to reflect these changes which should provide portability to any MicroPython platform.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: How does timer encoder mode work?
That's fine.pythoncoder wrote:If you've no objection I'll update the original to reflect these changes which should provide portability to any MicroPython platform.
I've also discovered an issue. It seems the callback routine is around 800μs, which is a bit too slow for my application and is causing me to lose counts.
Here is the scope view of one of my magnetic encoder pins:
http://i.imgur.com/vB9ofHb.png
Also, I've seen other people use code tags, but they don't seem to work for me. Is there some way to turn BBcode on?
Last edited by evidlo on Sat Jul 08, 2017 10:09 pm, edited 1 time in total.
Re: How does timer encoder mode work?
Callback function here takes also close to 800μs and I'm seeing similar results.mattyt wrote:Not sure if you're using the timers to interface to a Rotary Encoder but, if so, I've found Spotlight Kid's Encoder library works great...
Last edited by evidlo on Sat Jul 08, 2017 10:09 pm, edited 1 time in total.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: How does timer encoder mode work?
I think the problem you're hitting here is the interrupt latency of the ESP8266 which is frankly appalling. See https://github.com/micropython/micropython/issues/2972.
This will limit the performance of any solution as far as I can see.
[EDIT]
I've posted your modification here https://github.com/peterhinch/micropyth ... ortable.py. I made one change to ensure that setting the position and reading it back are mutually consistent. I also removed my reset method as this is made redundant by the position setter.
This will limit the performance of any solution as far as I can see.
[EDIT]
I've posted your modification here https://github.com/peterhinch/micropyth ... ortable.py. I made one change to ensure that setting the position and reading it back are mutually consistent. I also removed my reset method as this is made redundant by the position setter.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: How does timer encoder mode work?
Does this still apply to the ESP32?I think the problem you're hitting here is the interrupt latency of the ESP8266 which is frankly appalling.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: How does timer encoder mode work?
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.