Maximum possible machine.Timer period
Maximum possible machine.Timer period
Hello,
I'm new to the forum, thanks for such a beautiful development platform!
What is the maximum period I can set for a Timer?
I set it carelessly to 6 hours — 1000 * 60 * 60 * 6 == 21600000 — and from server access logs it's seems it's not being called at all.
Here the code:
period = 21600000
timer = machine.Timer(-1)
timer.init(period=period,
callback=lambda timer:
micropython.schedule(timer_cb, timer),
mode=machine.Timer.PERIODIC)
It works with shorter intervals like 60000 (1min)
P.S.: no code formatting allowed to me? Well, luckily I can spam as many smiles as I want
I'm new to the forum, thanks for such a beautiful development platform!
What is the maximum period I can set for a Timer?
I set it carelessly to 6 hours — 1000 * 60 * 60 * 6 == 21600000 — and from server access logs it's seems it's not being called at all.
Here the code:
period = 21600000
timer = machine.Timer(-1)
timer.init(period=period,
callback=lambda timer:
micropython.schedule(timer_cb, timer),
mode=machine.Timer.PERIODIC)
It works with shorter intervals like 60000 (1min)
P.S.: no code formatting allowed to me? Well, luckily I can spam as many smiles as I want
Re: Maximum possible machine.Timer period
Bump!
So no one's interested in a working Timer on spans bigger than 1 minute?
So no one's interested in a working Timer on spans bigger than 1 minute?
Re: Maximum possible machine.Timer period
What hardware are you using?neurino wrote:Bump!
So no one's interested in a working Timer on spans bigger than 1 minute?
Sent from my iPhone using Tapatalk Pro
Re: Maximum possible machine.Timer period
I don't know why it's failing. You are able to set up to a maximum of UINT32 so a value of 21 million should be ok.neurino wrote: ↑Wed Aug 08, 2018 8:22 amHello,
I'm new to the forum, thanks for such a beautiful development platform!
What is the maximum period I can set for a Timer?
I set it carelessly to 6 hours — 1000 * 60 * 60 * 6 == 21600000 — and from server access logs it's seems it's not being called at all.
Here the code:
period = 21600000
timer = machine.Timer(-1)
timer.init(period=period,
callback=lambda timer:
micropython.schedule(timer_cb, timer),
mode=machine.Timer.PERIODIC)
It works with shorter intervals like 60000 (1min)
P.S.: no code formatting allowed to me? Well, luckily I can spam as many smiles as I want
Try setting the period to 65536. which is one bigger than a UINT16.
If that doesn't fail, keep increasing it until you reach the point it does fail.
Let me know (by quoting this post).
Re: Maximum possible machine.Timer period
It's somewhere between 120000 (gets called) and 480000 (NOT called).jickster wrote: ↑Thu Aug 30, 2018 9:12 pmI don't know why it's failing. You are able to set up to a maximum of UINT32 so a value of 21 million should be ok.neurino wrote: ↑Wed Aug 08, 2018 8:22 amHello,
I'm new to the forum, thanks for such a beautiful development platform!
What is the maximum period I can set for a Timer?
I set it carelessly to 6 hours — 1000 * 60 * 60 * 6 == 21600000 — and from server access logs it's seems it's not being called at all.
Here the code:
period = 21600000
timer = machine.Timer(-1)
timer.init(period=period,
callback=lambda timer:
micropython.schedule(timer_cb, timer),
mode=machine.Timer.PERIODIC)
It works with shorter intervals like 60000 (1min)
P.S.: no code formatting allowed to me? Well, luckily I can spam as many smiles as I want
Try setting the period to 65536. which is one bigger than a UINT16.
If that doesn't fail, keep increasing it until you reach the point it does fail.
Let me know (by quoting this post).
I hope I can avoid trying to find the exact threshold
Here the code:
Code: Select all
import machine
import micropython
def timer_cb(timer):
print('here', timer)
period = 480000
timer = machine.Timer(-1)
timer.init(period=period,
callback=lambda timer: micropython.schedule(timer_cb, timer),
mode=machine.Timer.PERIODIC)
Re: Maximum possible machine.Timer period
Those numbers don't stand out to me.neurino wrote: ↑Mon Sep 03, 2018 4:15 pmIt's somewhere between 120000 (gets called) and 480000 (NOT called).jickster wrote: ↑Thu Aug 30, 2018 9:12 pmI don't know why it's failing. You are able to set up to a maximum of UINT32 so a value of 21 million should be ok.neurino wrote: ↑Wed Aug 08, 2018 8:22 amHello,
I'm new to the forum, thanks for such a beautiful development platform!
What is the maximum period I can set for a Timer?
I set it carelessly to 6 hours — 1000 * 60 * 60 * 6 == 21600000 — and from server access logs it's seems it's not being called at all.
Here the code:
period = 21600000
timer = machine.Timer(-1)
timer.init(period=period,
callback=lambda timer:
micropython.schedule(timer_cb, timer),
mode=machine.Timer.PERIODIC)
It works with shorter intervals like 60000 (1min)
P.S.: no code formatting allowed to me? Well, luckily I can spam as many smiles as I want
Try setting the period to 65536. which is one bigger than a UINT16.
If that doesn't fail, keep increasing it until you reach the point it does fail.
Let me know (by quoting this post).
I hope I can avoid trying to find the exact threshold
Here the code:
Code: Select all
import machine import micropython def timer_cb(timer): print('here', timer) period = 480000 timer = machine.Timer(-1) timer.init(period=period, callback=lambda timer: micropython.schedule(timer_cb, timer), mode=machine.Timer.PERIODIC)
I think something else is going on.
Do you have access to a C-debugger?
Re: Maximum possible machine.Timer period
Sorry, no debugger,
haven't anyone out there been able to reproduce the issue?
I mean someone with an ESP8266 ruing these few lines and seeing if he gets timer_cb called or not after 6 minutes (480000ms)
Code: Select all
import machine
import micropython
def timer_cb(timer):
print('here', timer)
period = 480000
timer = machine.Timer(-1)
timer.init(period=period,
callback=lambda timer: micropython.schedule(timer_cb, timer),
mode=machine.Timer.PERIODIC)
Re: Maximum possible machine.Timer period
Why are you using .schedule?neurino wrote:Sorry, no debugger,
haven't anyone out there been able to reproduce the issue?
I mean someone with an ESP8266 ruing these few lines and seeing if he gets timer_cb called or not after 6 minutes (480000ms)
On my side, I started relying on a DS3231 alarm to trigger my hourly job, however getting this fixed would really help in other projects.Code: Select all
import machine import micropython def timer_cb(timer): print('here', timer) period = 480000 timer = machine.Timer(-1) timer.init(period=period, callback=lambda timer: micropython.schedule(timer_cb, timer), mode=machine.Timer.PERIODIC)
Sent from my iPhone using Tapatalk Pro
Re: Maximum possible machine.Timer period
Simply because I read it here: https://docs.micropython.org/en/latest/ ... rules.html
etc* Avoid memory allocation: no appending to lists or insertion into dictionaries, no floating point.
* Consider using micropython.schedule to work around the above constraint.