Maximum possible machine.Timer period

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
neurino
Posts: 14
Joined: Mon Aug 06, 2018 8:23 am

Maximum possible machine.Timer period

Post by neurino » Wed Aug 08, 2018 8:22 am

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 :D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:

neurino
Posts: 14
Joined: Mon Aug 06, 2018 8:23 am

Re: Maximum possible machine.Timer period

Post by neurino » Thu Aug 30, 2018 10:54 am

Bump!

So no one's interested in a working Timer on spans bigger than 1 minute? :)

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: Maximum possible machine.Timer period

Post by jickster » Thu Aug 30, 2018 6:42 pm

neurino wrote:Bump!

So no one's interested in a working Timer on spans bigger than 1 minute? :)
What hardware are you using?



Sent from my iPhone using Tapatalk Pro


jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: Maximum possible machine.Timer period

Post by jickster » Thu Aug 30, 2018 9:12 pm

neurino wrote:
Wed Aug 08, 2018 8:22 am
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 :D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:
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.

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).

neurino
Posts: 14
Joined: Mon Aug 06, 2018 8:23 am

Re: Maximum possible machine.Timer period

Post by neurino » Mon Sep 03, 2018 4:15 pm

jickster wrote:
Thu Aug 30, 2018 9:12 pm
neurino wrote:
Wed Aug 08, 2018 8:22 am
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 :D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:
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.

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).
It's somewhere between 120000 (gets called) and 480000 (NOT called).

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)

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: Maximum possible machine.Timer period

Post by jickster » Mon Sep 03, 2018 10:20 pm

neurino wrote:
Mon Sep 03, 2018 4:15 pm
jickster wrote:
Thu Aug 30, 2018 9:12 pm
neurino wrote:
Wed Aug 08, 2018 8:22 am
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 :D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:
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.

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).
It's somewhere between 120000 (gets called) and 480000 (NOT called).

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)
Those numbers don't stand out to me.
I think something else is going on.

Do you have access to a C-debugger?

neurino
Posts: 14
Joined: Mon Aug 06, 2018 8:23 am

Re: Maximum possible machine.Timer period

Post by neurino » Tue Sep 04, 2018 3:30 pm

jickster wrote:
Mon Sep 03, 2018 10:20 pm

Those numbers don't stand out to me.
I think something else is going on.

Do you have access to a C-debugger?
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)
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.

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: Maximum possible machine.Timer period

Post by jickster » Tue Sep 04, 2018 3:43 pm

neurino wrote:
jickster wrote:
Mon Sep 03, 2018 10:20 pm

Those numbers don't stand out to me.
I think something else is going on.

Do you have access to a C-debugger?
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)
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.
Why are you using .schedule?


Sent from my iPhone using Tapatalk Pro

neurino
Posts: 14
Joined: Mon Aug 06, 2018 8:23 am

Re: Maximum possible machine.Timer period

Post by neurino » Tue Sep 04, 2018 4:17 pm

jickster wrote:
Tue Sep 04, 2018 3:43 pm
Why are you using .schedule?
Simply because I read it here: https://docs.micropython.org/en/latest/ ... rules.html
* Avoid memory allocation: no appending to lists or insertion into dictionaries, no floating point.
* Consider using micropython.schedule to work around the above constraint.
etc

Post Reply