Timer with microsecond resolution
Timer with microsecond resolution
Can I use a timer with micro second resolution instead of milli second?
- pythoncoder
- Posts: 5059
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Timer with microsecond resolution
If you are hoping for a callback to run with anything approaching microsecond resolution you need to use a Pyboard or similar. Interrupts on ESP32 are soft IRQ's and are subject to latency which can run to milliseconds, especially on SPIRAM boards,
On a Pyboard latency is on the order of 15μs.
On a Pyboard latency is on the order of 15μs.
Peter Hinch
Re: Timer with microsecond resolution
Thanks, Peter. I think the best way is to have an Arduino as a pulse generator to drive my stepper motor. I can communicate with Arduino and ESP32 via SPI. In that way, I will have hardware interrupt on the Arduino with minimum C++ code and have all control logic on ESP with the freedom of Python.
- OlivierLenoir
- Posts: 57
- Joined: Fri Dec 13, 2019 7:10 pm
- Location: Picardie, FR
Re: Timer with microsecond resolution
If your looking for µs, you can use the RMT.
I've been using it in MicroPython-Multiaxis project. Discussion in this forum Multiaxis stepper motors using RMT.
I've been using it in MicroPython-Multiaxis project. Discussion in this forum Multiaxis stepper motors using RMT.
Olivier Lenoir
https://gitlab.com/olivier.len02
https://gitlab.com/olivier.len02
-
- Posts: 6
- Joined: Wed Nov 18, 2020 1:46 pm
Re: Timer with microsecond resolution
This thread makes me sad. I've been working on a design with three serial UARTs @ 57.6Kbps, 62.5 Kbps, and 202 Kbps speeds and ultra low latency / jitter requirement for the 62.5/202Kbps UARTS, using ESP32-S as the MCU running Micropython.
Is this even doable with the ESP-32 given these soft interrupt scheduling issues? I am reading other conflicting threads about what options there may be to get down to microsecond level granularity, is writing an RMT serial driver the only option here?
Does loboris fork solve any of this? Is loboris supported any longer? How do combustion engines even work?
Is this even doable with the ESP-32 given these soft interrupt scheduling issues? I am reading other conflicting threads about what options there may be to get down to microsecond level granularity, is writing an RMT serial driver the only option here?
Does loboris fork solve any of this? Is loboris supported any longer? How do combustion engines even work?
- pythoncoder
- Posts: 5059
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Timer with microsecond resolution
As I understand it the Loboris fork was abandoned long ago.
RMT output is well supported in the official firmware. I have used it to good effect. RMT input would be a great addition.
I could explain internal combustion engines but this is neither the time or place
RMT output is well supported in the official firmware. I have used it to good effect. RMT input would be a great addition.
I could explain internal combustion engines but this is neither the time or place

Peter Hinch
-
- Posts: 6
- Joined: Wed Nov 18, 2020 1:46 pm
Re: Timer with microsecond resolution
But RMT is write-only and beta status currently, correct?
-
- Posts: 6
- Joined: Wed Nov 18, 2020 1:46 pm
Re: Timer with microsecond resolution
So is ESP8266 an option here? From what I understand it is not plagued with soft IRQ issues as ESP32-S?
Re: Timer with microsecond resolution
For time critic operations native code can be used with microPython;
https://docs.micropython.org/en/latest/ ... atmod.html
I started to test RMT. I plan to combine RMT and timer interrupts. I have to know the position of the stepper with 1 mm precision while it is moving. When I buffer all pulses to RMT it will not be possible.
https://docs.micropython.org/en/latest/ ... atmod.html
I started to test RMT. I plan to combine RMT and timer interrupts. I have to know the position of the stepper with 1 mm precision while it is moving. When I buffer all pulses to RMT it will not be possible.