Timer accuracy in rules

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Gardener
New user
Posts: 2
Joined: 17 Mar 2019, 21:45

Timer accuracy in rules

#1 Post by Gardener » 17 Mar 2019, 22:34

Timer accuracy in rules
I want to use timers in the rules and have high accuracy. I try to create a rule and compare with a stopwatch, I get a cycle time of about 1.98 seconds. This is a very bad result. Is it possible to get the best result?
I tried it on the assembly ESPEasy_mega-20190311

Code: Select all

On System#Boot do    //When the ESP boots, do
   timerSet,1,1      //Set Timer 1 for the next event in 10 seconds
 endon
On Rules#Timer=1 do
   //repeat after 1 seconds
   timerSet,1,1
   taskvalueset 2,1,[Counter1#Var1]+1
endon

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Timer accuracy in rules

#2 Post by grovkillen » 18 Mar 2019, 05:56

I would say that, no, you cannot trust the timer to be 100% since it depends on your setup. The ESP is a single threaded unit and we don't want anything to be blocking = timers may not be spot on millisecond.

If you need 100% accuracy you must use delay but that will make the unit unresponsive.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Gardener
New user
Posts: 2
Joined: 17 Mar 2019, 21:45

Re: Timer accuracy in rules

#3 Post by Gardener » 18 Mar 2019, 11:09

Thank. I expected that the accuracy of the timer would not be 100%, but I did not expect the error to be more than 90%.
Using delay for 100% accuracy is not a good idea when you need to complete a task every time interval.
I did another experiment with a timer of 5 seconds and I got a result of 6 seconds. I see that the timer has good accuracy, but always adds 1 second.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Timer accuracy in rules

#4 Post by grovkillen » 18 Mar 2019, 11:36

Makes sense. The offset will be 0..1 seconds depending on where on the loop the timer get activated. If you need better accuracy than that you need to use something other than ESP Easy...
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests