Timers

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
JumpZero
Posts: 54
Joined: Mon Oct 30, 2017 5:54 am
Location: Arcachon - France

Timers

Post by JumpZero » Thu Nov 02, 2017 9:04 am

Hi!

On an ESP8266 is there a limit to the quantity of virtual timers I can use simultaneously?
The documentation is silent on this. I use 3 without problem with code like this:

Code: Select all

tim = Timer(-1)
tom = Timer(-1)
tam = Timer(-1)
but is there a limit?
Also what are advantages and disadvantages of virtual vs hardware timers?

Thks
--
Jmp0

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Timers

Post by pythoncoder » Fri Nov 03, 2017 7:55 am

As far as I know there is no limit to the number of virtual timers although RAM may prevent really large numbers. The main differences between a virtual timer and a hardware one are likely to be timing accuracy and latency in executing a callback. A hardware timer uses a hardware interrupt which should have very low latency; on platforms like the Pyboard it does. On the ESP8266 hardware interrupts have a maximum latency on the order of 600μs which is poor.

I don't know if anyone has actually made measurements to quantify the performance of virtual timers.

Unless your application requires accuracy better than a few ms my guess is that virtual timers will be fine.
Peter Hinch
Index to my micropython libraries.

JumpZero
Posts: 54
Joined: Mon Oct 30, 2017 5:54 am
Location: Arcachon - France

Re: Timers

Post by JumpZero » Fri Nov 10, 2017 7:37 am

Thanks for the explanation,
I'll carry on with virtual timers, for the projects I do now I don't need a lot of accuracy.
--
Jmp0

Post Reply