granularity of TimerSet_ms differs by 10%

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
_Cyber_
Normal user
Posts: 115
Joined: 20 Oct 2019, 09:46

granularity of TimerSet_ms differs by 10%

#1 Post by _Cyber_ » 04 Feb 2021, 17:20

Hi,

I am using ESP_Easy_mega_20210114_normal_ESP32_4M316k on a ESP32.

in the following rule I start the event "ControlSZ=0".
It pulses two GPIOs with LongPulse for 28 seconds.
In parallel I start a timer (already with TimerSet_ms as the difference without _ms was bigger), set a variable to 28 and let the timer decrease every second 1 from the VAR#20.

the outcome is that the Pulse of the GPIOs ends and the counter is running nearly 3 seconds longer. :shock:

below also the complete log, following timestamps:
181338027 trigger the event
181339290 Pulse first GPIO
181339295 Pulse second GPIO
181339305 Start timer_ms (VAR#20 already set to 28 before)
181340307 enter the timer-part in rules
181340353 reset the timer to 1000msec (already on most top in the event rule)
181341762 enter the timer-part in rules
181341808 reset the timer to 1000msec
....

a parallel running Rules#Timer=8,1 which is set to 28 Seconds is running out in time and overtakes the periodically reset timer by over 3 seconds:
181339031: ACT : TimerSet,8,28+2
181367032: EVENT: Rules#Timer=8,1
Difference: 28001 (oh, it looks like the addition there does not work - have to rework this)

I have NOT checked SendToHTTP wait for ack

I know, jitter may influence things - but can I do something against it - or to make it more exactly?
Or, as the GPIOPulse is working exactly, is there a way to read in rules the seconds passed from the pulse?

Any ideas? :)

Thanks!

Best regards
Alois


I compared and calculated the differences between the timestamps:

Code: Select all

Timestamp       Diff
181339305			 ACT 	 TimerSet_ms,7,1000
181340307	1002		 EVENT	 Rules#Timer=7,1
181340353	46		 ACT 	 TimerSet_ms,7,1000
181341762	1409		 EVENT	 Rules#Timer=7,1
181341808	46		 ACT 	 TimerSet_ms,7,1000
181342811	1003		 EVENT	 Rules#Timer=7,1
181342857	46		 ACT 	 TimerSet_ms,7,1000
181343992	1135		 EVENT	 Rules#Timer=7,1
181344037	45		 ACT 	 TimerSet_ms,7,1000
181345040	1003		 EVENT	 Rules#Timer=7,1
181345085	45		 ACT 	 TimerSet_ms,7,1000
181346087	1002		 EVENT	 Rules#Timer=7,1
181346131	44		 ACT 	 TimerSet_ms,7,1000
181347133	1002		 EVENT	 Rules#Timer=7,1
181347179	46		 ACT 	 TimerSet_ms,7,1000
181348184	1005		 EVENT	 Rules#Timer=7,1
181348228	44		 ACT 	 TimerSet_ms,7,1000
181349231	1003		 EVENT	 Rules#Timer=7,1
181349275	44		 ACT 	 TimerSet_ms,7,1000
181350278	1003		 EVENT	 Rules#Timer=7,1
181350324	46		 ACT 	 TimerSet_ms,7,1000
181351326	1002		 EVENT	 Rules#Timer=7,1
181351403	77		 ACT 	 TimerSet_ms,7,1000
181352405	1002		 EVENT	 Rules#Timer=7,1
181352449	44		 ACT 	 TimerSet_ms,7,1000
181353453	1004		 EVENT	 Rules#Timer=7,1
181353498	45		 ACT 	 TimerSet_ms,7,1000
181354675	1177		 EVENT	 Rules#Timer=7,1
181354719	44		 ACT 	 TimerSet_ms,7,1000
181355722	1003		 EVENT	 Rules#Timer=7,1
181355768	46		 ACT 	 TimerSet_ms,7,1000
181356773	1005		 EVENT	 Rules#Timer=7,1
181356818	45		 ACT 	 TimerSet_ms,7,1000
181357820	1002		 EVENT	 Rules#Timer=7,1
181357864	44		 ACT 	 TimerSet_ms,7,1000
181358866	1002		 EVENT	 Rules#Timer=7,1
181358911	45		 ACT 	 TimerSet_ms,7,1000
181359956	1045		 EVENT	 Rules#Timer=7,1
181360000	44		 ACT 	 TimerSet_ms,7,1000
181361009	1009		 EVENT	 Rules#Timer=7,1
181361053	44		 ACT 	 TimerSet_ms,7,1000
181362058	1005		 EVENT	 Rules#Timer=7,1
181362102	44		 ACT 	 TimerSet_ms,7,1000
181363107	1005		 EVENT	 Rules#Timer=7,1
181363151	44		 ACT 	 TimerSet_ms,7,1000
181364153	1002		 EVENT	 Rules#Timer=7,1
181364197	44		 ACT 	 TimerSet_ms,7,1000
181365200	1003		 EVENT	 Rules#Timer=7,1
181365243	43		 ACT 	 TimerSet_ms,7,1000
181366246	1003		 EVENT	 Rules#Timer=7,1
181366290	44		 ACT 	 TimerSet_ms,7,1000
181367657	1367		 EVENT	 Rules#Timer=7,1
181367700	43		 ACT 	 TimerSet_ms,7,1000
181368896	1196		 EVENT	 Rules#Timer=7,1
181368940	44		 ACT 	 TimerSet_ms,7,1000
181370211	1271		 EVENT	 Rules#Timer=7,1
181370257	46		 ACT 	 TimerSet_ms,7,1000
181371485	1228		 EVENT	 Rules#Timer=7,1
181371529	44		 ACT 	 TimerSet_ms,7,1000
181373184	1655		 EVENT	 Rules#Timer=7,1
here is the part of the rules:

Code: Select all

on Rules#Timer=8 do
 if [Z1#M] = 0 and [Z2#M] = 0 and [Z3#M] = 0 and [SZ#M] = 0
  logentry,"No Movement, Power off"
  gpio,2,1
  TaskValueSet,5,1,-1
 else
  logentry,"Power still needed (SZ#M=[SZ#M] Z1#M=[Z1#M] Z2#M=[Z2#M] Z3#M=[Z3#M])"
  TimerSet,8,1
 endif
endon

on Rules#Timer=7 do
 //[VAR#20] second countdown; [VAR#21] direction; [VAR#22] shutter percent
 if [VAR#20] >= 0
  TimerSet_ms,7,1000
  Let,20,[VAR#20]-1
  Let,22,[SZ#S]+(100/28)*[VAR#21]
  if [VAR#22] < 0 or [VAR#22] > 100
   if [VAR#22] < 0
    TaskValueSet,1,1,0
   else
    TaskValueSet,1,1,100
   endif
  else
   TaskValueSet,1,1,[VAR#22]
  endif
 else
  TaskValueSet,1,2,0
  Let,20,0
  Let,21,0
  Let,22,[SZ#S]
 endif
 SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=%sysname%&SZ=[SZ#M];[SZ#S];
 //TaskValueSet,1,2,0
 //asyncevent,updatephp
endon

on ControlSZ do
 //control?cmd=event,ControlSZ=0
 Let,13,%eventvalue%
 if [VAR#13] > 0 and [VAR#13] < 100
  //open/close percent
  Let,10,(28/100)*[VAR#13]
  Let,11,(28/100)*[SZ#S]
  if [VAR#11] > [VAR#10]
   // open a bit
   Let,12,[VAR#11]-[VAR#10]
   logentry,SZ_o_secs=[VAR#12]
   gpio,2,0
   TimerSet,8,[VAR#12]+2
   delay,250
   LongPulse,4,0,[VAR#12]
   LongPulse,16,0,[VAR#12]
   //TimerSet,7,[VAR#12]
   Let,20,[VAR#12]
   Let,21,-1
   TimerSet_ms,7,1000
   TaskValueSet,1,2,1
  endif
  if [VAR#11] < [VAR#10]
   //close a bit
   Let,12,[VAR#10]-[VAR#11]
   logentry,SZ_c_secs=[VAR#12]
   gpio,2,0
   TimerSet,8,[VAR#12]+2
   delay,250
   LongPulse,4,0,[VAR#12]
   gpio,16,1
   //TimerSet,7,[VAR#12]
   Let,20,[VAR#12]
   Let,21,1
   TimerSet_ms,7,1000
   TaskValueSet,1,2,1
  endif
 else
  if [VAR#13] = 0
   logentry,SZ_o_comp
   gpio,2,0
   TimerSet,8,28+2
   delay,250
   LongPulse,4,0,28
   LongPulse,16,0,28
   //TimerSet,7,28
   Let,20,28
   Let,21,-1
   TimerSet_ms,7,1000
   TaskValueSet,1,2,1
  endif
  if [VAR#13] = 100
   logentry,SZ_c_comp
   gpio,2,0
   TimerSet,8,28+2
   delay,250
   LongPulse,4,0,28
   gpio,16,1
   //TimerSet,7,28
   Let,20,28
   Let,21,1
   TimerSet_ms,7,1000
   TaskValueSet,1,2,1
  endif
  if [VAR#13] = 101
   logentry,SZ_stop
   LongPulse,4,0,0
   LongPulse,16,0,0
   Let,20,0
  endif
  if [VAR#13] = 102
   //special state
  endif
  if [VAR#13] = 103
   //special state
  endif
 endif
 //TaskValueSet,1,1,[VAR#13]
endon
here the complete log:

Code: Select all

181320433: Dummy: value 1: -1
181320498: EVENT: Boot#All=-1
181324027: Dummy: value 1: 100.00
181324029: Dummy: value 2: 0
181324053: EVENT: SZ#All=100.00,0
181325982: WD : Uptime 3022 ConnectFailures 0 FreeMem 200848 WiFiStatus WL_CONNECTED ESPeasy internal wifi status: Conn. IP Init
181329413: Dummy: value 1: 0.00
181329415: Dummy: value 2: 0.00
181329416: Dummy: value 3: 0.00
181329418: Dummy: value 4: 0
181329496: EVENT: Z2#All=0.00,0.00,0.00,0
181337838: EVENT: Clock#Time=Thu,16:33
181337863: ACT : asyncevent,updatephp
181338027: HTTP: event,ControlSZ=0
181338324: EVENT: updatephp
181338458: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&ipv4=192.168.10.233&uptime=3022&load=22.35&f
181338883: EVENT: controlsz=0
181338936: ACT : Let,13,0
181339023: ACT : logentry,SZ_o_comp
181339025: SZ_o_comp
181339027: ACT : gpio,2,0
181339029: GPIO : port#2: set to 0
181339031: ACT : TimerSet,8,28+2
181339034: ACT : delay,250
181339287: ACT : LongPulse,4,0,28
181339290: GPIO : port 4. Pulse set for 28000 ms
181339292: ACT : LongPulse,16,0,28
181339295: GPIO : port 16. Pulse set for 28000 ms
181339297: ACT : Let,20,28
181339301: ACT : Let,21,-1
181339305: ACT : TimerSet_ms,7,1000
181339309: ACT : TaskValueSet,1,2,1
181340307: EVENT: Rules#Timer=7,1
181340353: ACT : TimerSet_ms,7,1000
181340358: ACT : Let,20,28-1
181340394: ACT : Let,22,100.00+(100/28)*-1
181340412: ACT : TaskValueSet,1,1,96.4285714285714
181340492: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;96.43;
181341247: Dummy: value 1: 0.00
181341248: Dummy: value 2: 0.00
181341250: Dummy: value 3: 0.00
181341251: Dummy: value 4: 0
181341263: EVENT: Z3#All=0.00,0.00,0.00,0
181341762: EVENT: Rules#Timer=7,1
181341808: ACT : TimerSet_ms,7,1000
181341813: ACT : Let,20,27-1
181341849: ACT : Let,22,96.43+(100/28)*-1
181341867: ACT : TaskValueSet,1,1,92.8585717337472
181341947: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;92.86;
181342811: EVENT: Rules#Timer=7,1
181342857: ACT : TimerSet_ms,7,1000
181342862: ACT : Let,20,26-1
181342899: ACT : Let,22,92.86+(100/28)*-1
181342917: ACT : TaskValueSet,1,1,89.288572038923
181342997: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;89.29;
181343422: Dummy: value 1: 0.00
181343424: Dummy: value 2: 0.00
181343425: Dummy: value 3: 0.00
181343427: Dummy: value 4: 0
181343511: EVENT: Z1#All=0.00,0.00,0.00,0
181343992: EVENT: Rules#Timer=7,1
181344037: ACT : TimerSet_ms,7,1000
181344042: ACT : Let,20,25-1
181344079: ACT : Let,22,89.29+(100/28)*-1
181344097: ACT : TaskValueSet,1,1,85.7185723440988
181344177: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;85.72;
181345040: EVENT: Rules#Timer=7,1
181345085: ACT : TimerSet_ms,7,1000
181345090: ACT : Let,20,24-1
181345126: ACT : Let,22,85.72+(100/28)*-1
181345144: ACT : TaskValueSet,1,1,82.1485726492746
181345224: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;82.15;
181346087: EVENT: Rules#Timer=7,1
181346131: ACT : TimerSet_ms,7,1000
181346136: ACT : Let,20,23-1
181346173: ACT : Let,22,82.15+(100/28)*-1
181346190: ACT : TaskValueSet,1,1,78.5785729544503
181346298: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;78.58;
181347133: EVENT: Rules#Timer=7,1
181347179: ACT : TimerSet_ms,7,1000
181347184: ACT : Let,20,22-1
181347221: ACT : Let,22,78.58+(100/28)*-1
181347239: ACT : TaskValueSet,1,1,75.0085732596261
181347319: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;75.01;
181348184: EVENT: Rules#Timer=7,1
181348228: ACT : TimerSet_ms,7,1000
181348233: ACT : Let,20,21-1
181348269: ACT : Let,22,75.01+(100/28)*-1
181348286: ACT : TaskValueSet,1,1,71.4385735648019
181348366: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;71.44;
181349231: EVENT: Rules#Timer=7,1
181349275: ACT : TimerSet_ms,7,1000
181349280: ACT : Let,20,20-1
181349316: ACT : Let,22,71.44+(100/28)*-1
181349333: ACT : TaskValueSet,1,1,67.8685738699777
181349413: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;67.87;
181350278: EVENT: Rules#Timer=7,1
181350324: ACT : TimerSet_ms,7,1000
181350330: ACT : Let,20,19-1
181350366: ACT : Let,22,67.87+(100/28)*-1
181350384: ACT : TaskValueSet,1,1,64.2985741751535
181350464: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;64.30;
181351326: EVENT: Rules#Timer=7,1
181351403: ACT : TimerSet_ms,7,1000
181351408: ACT : Let,20,18-1
181351444: ACT : Let,22,64.30+(100/28)*-1
181351462: ACT : TaskValueSet,1,1,60.7285744803292
181351542: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;60.73;
181352405: EVENT: Rules#Timer=7,1
181352449: ACT : TimerSet_ms,7,1000
181352454: ACT : Let,20,17-1
181352491: ACT : Let,22,60.73+(100/28)*-1
181352508: ACT : TaskValueSet,1,1,57.1585709708078
181352588: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;57.16;
181353453: EVENT: Rules#Timer=7,1
181353498: ACT : TimerSet_ms,7,1000
181353503: ACT : Let,20,16-1
181353539: ACT : Let,22,57.16+(100/28)*-1
181353557: ACT : TaskValueSet,1,1,53.5885712759835
181353637: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;53.59;
181354107: Dummy: value 1: 53.59
181354109: Dummy: value 2: 1
181354193: EVENT: SZ#All=53.59,1
181354675: EVENT: Rules#Timer=7,1
181354719: ACT : TimerSet_ms,7,1000
181354725: ACT : Let,20,15-1
181354732: ACT : Let,22,53.59+(100/28)*-1
181354749: ACT : TaskValueSet,1,1,50.0185715811593
181354772: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;50.02;
181355722: EVENT: Rules#Timer=7,1
181355768: ACT : TimerSet_ms,7,1000
181355773: ACT : Let,20,14-1
181355781: ACT : Let,22,50.02+(100/28)*-1
181355798: ACT : TaskValueSet,1,1,46.4485718863351
181355821: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;46.45;
181356240: WD : Uptime 3023 ConnectFailures 0 FreeMem 200616 WiFiStatus WL_CONNECTED ESPeasy internal wifi status: Conn. IP Init
181356773: EVENT: Rules#Timer=7,1
181356818: ACT : TimerSet_ms,7,1000
181356823: ACT : Let,20,13-1
181356831: ACT : Let,22,46.45+(100/28)*-1
181356848: ACT : TaskValueSet,1,1,42.8785721915109
181356872: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;42.88;
181357820: EVENT: Rules#Timer=7,1
181357864: ACT : TimerSet_ms,7,1000
181357869: ACT : Let,20,12-1
181357876: ACT : Let,22,42.88+(100/28)*-1
181357894: ACT : TaskValueSet,1,1,39.3085724966867
181357916: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;39.31;
181358866: EVENT: Rules#Timer=7,1
181358911: ACT : TimerSet_ms,7,1000
181358916: ACT : Let,20,11-1
181358923: ACT : Let,22,39.31+(100/28)*-1
181358940: ACT : TaskValueSet,1,1,35.7385728018624
181358962: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;35.74;
181359413: Dummy: value 1: 0.00
181359414: Dummy: value 2: 0.00
181359416: Dummy: value 3: 0.00
181359417: Dummy: value 4: 0
181359473: EVENT: Z2#All=0.00,0.00,0.00,0
181359956: EVENT: Rules#Timer=7,1
181360000: ACT : TimerSet_ms,7,1000
181360005: ACT : Let,20,10-1
181360041: ACT : Let,22,35.74+(100/28)*-1
181360058: ACT : TaskValueSet,1,1,32.1685731070382
181360138: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;32.17;
181361009: EVENT: Rules#Timer=7,1
181361053: ACT : TimerSet_ms,7,1000
181361059: ACT : Let,20,9-1
181361095: ACT : Let,22,32.17+(100/28)*-1
181361112: ACT : TaskValueSet,1,1,28.5985695975167
181361192: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;28.60;
181362058: EVENT: Rules#Timer=7,1
181362102: ACT : TimerSet_ms,7,1000
181362107: ACT : Let,20,8-1
181362143: ACT : Let,22,28.60+(100/28)*-1
181362160: ACT : TaskValueSet,1,1,25.0285718100412
181362240: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;25.03;
181363107: EVENT: Rules#Timer=7,1
181363151: ACT : TimerSet_ms,7,1000
181363156: ACT : Let,20,7-1
181363192: ACT : Let,22,25.03+(100/28)*-1
181363209: ACT : TaskValueSet,1,1,21.4585721152169
181363289: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;21.46;
181364153: EVENT: Rules#Timer=7,1
181364197: ACT : TimerSet_ms,7,1000
181364202: ACT : Let,20,6-1
181364239: ACT : Let,22,21.46+(100/28)*-1
181364256: ACT : TaskValueSet,1,1,17.8885705130441
181364336: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;17.89;
181365200: EVENT: Rules#Timer=7,1
181365243: ACT : TimerSet_ms,7,1000
181365248: ACT : Let,20,5-1
181365286: ACT : Let,22,17.89+(100/28)*-1
181365338: ACT : TaskValueSet,1,1,14.3185708182199
181365418: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;14.32;
181366246: EVENT: Rules#Timer=7,1
181366290: ACT : TimerSet_ms,7,1000
181366295: ACT : Let,20,4-1
181366331: ACT : Let,22,14.32+(100/28)*-1
181366348: ACT : TaskValueSet,1,1,10.7485711233956
181366428: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;10.75;
181367032: EVENT: Rules#Timer=8,1
181367234: ACT : logentry,'Power still needed (SZ#M=1 Z1#M=0 Z2#M=0 Z3#M=0)'
181367237: Power still needed (SZ#M=1 Z1#M=0 Z2#M=0 Z3#M=0)
181367239: ACT : TimerSet,8,1
181367657: EVENT: Rules#Timer=7,1
181367700: ACT : TimerSet_ms,7,1000
181367705: ACT : Let,20,3-1
181367743: ACT : Let,22,10.75+(100/28)*-1
181367790: ACT : TaskValueSet,1,1,7.17857142857143
181367870: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;7.18;
181368283: EVENT: Rules#Timer=8,1
181368485: ACT : logentry,'Power still needed (SZ#M=1 Z1#M=0 Z2#M=0 Z3#M=0)'
181368488: Power still needed (SZ#M=1 Z1#M=0 Z2#M=0 Z3#M=0)
181368490: ACT : TimerSet,8,1
181368896: EVENT: Rules#Timer=7,1
181368940: ACT : TimerSet_ms,7,1000
181368946: ACT : Let,20,2-1
181368982: ACT : Let,22,7.18+(100/28)*-1
181369033: ACT : TaskValueSet,1,1,3.60857125691005
181369113: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;3.61;
181369527: EVENT: Rules#Timer=8,1
181369732: ACT : logentry,'Power still needed (SZ#M=1 Z1#M=0 Z2#M=0 Z3#M=0)'
181369735: Power still needed (SZ#M=1 Z1#M=0 Z2#M=0 Z3#M=0)
181369737: ACT : TimerSet,8,1
181370211: EVENT: Rules#Timer=7,1
181370257: ACT : TimerSet_ms,7,1000
181370262: ACT : Let,20,1-1
181370298: ACT : Let,22,3.61+(100/28)*-1
181370316: ACT : TaskValueSet,1,1,0.03857132366725
181370396: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;0.04;
181370813: EVENT: Rules#Timer=8,1
181371015: ACT : logentry,'Power still needed (SZ#M=1 Z1#M=0 Z2#M=0 Z3#M=0)'
181371018: Power still needed (SZ#M=1 Z1#M=0 Z2#M=0 Z3#M=0)
181371020: ACT : TimerSet,8,1
181371474: Dummy: value 1: 0.00
181371476: Dummy: value 2: 0.00
181371477: Dummy: value 3: 0.00
181371479: Dummy: value 4: 0
181371485: EVENT: Rules#Timer=7,1
181371529: ACT : TimerSet_ms,7,1000
181371534: ACT : Let,20,0-1
181371570: ACT : Let,22,0.04+(100/28)*-1
181371582: ACT : TaskValueSet,1,1,0
181371668: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=1;0.00;
181372093: EVENT: Z3#All=0.00,0.00,0.00,0
181372547: EVENT: Rules#Timer=8,1
181372771: ACT : logentry,'Power still needed (SZ#M=1 Z1#M=0 Z2#M=0 Z3#M=0)'
181372774: Power still needed (SZ#M=1 Z1#M=0 Z2#M=0 Z3#M=0)
181372776: ACT : TimerSet,8,1
181373184: EVENT: Rules#Timer=7,1
181373277: ACT : TaskValueSet,1,2,0
181373282: ACT : Let,20,0
181373286: ACT : Let,21,0
181373321: ACT : Let,22,0.00
181373362: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&SZ=0;0.00;
181373781: Dummy: value 1: 0.00
181373783: Dummy: value 2: 0.00
181373784: Dummy: value 3: 0.00
181373786: Dummy: value 4: 0
181373797: EVENT: Z1#All=0.00,0.00,0.00,0
181374295: EVENT: Rules#Timer=8,1
181374398: ACT : logentry,'No Movement, Power off'
181374400: No Movement, Power off
181374402: ACT : gpio,2,1
181374404: GPIO : port#2: set to 1
181374406: ACT : TaskValueSet,5,1,-1
181380434: Dummy: value 1: -1
181380500: EVENT: Boot#All=-1
181384027: Dummy: value 1: 0.00
181384028: Dummy: value 2: 0
181384065: EVENT: SZ#All=0.00,0
181385984: WD : Uptime 3023 ConnectFailures 0 FreeMem 200816 WiFiStatus WL_CONNECTED ESPeasy internal wifi status: Conn. IP Init
181389414: Dummy: value 1: 0.00
181389415: Dummy: value 2: 0.00
181389417: Dummy: value 3: 0.00
181389418: Dummy: value 4: 0
181389447: EVENT: Z2#All=0.00,0.00,0.00,0
181397840: EVENT: Clock#Time=Thu,16:34
181397865: ACT : asyncevent,updatephp
181398302: EVENT: updatephp
181398436: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=RollladenManager&ipv4=192.168.10.233&uptime=3023&load=57.84&f

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: granularity of TimerSet_ms differs by 10%

#2 Post by TD-er » 04 Feb 2021, 18:03

To create repeating timers with at least a repeating interval (jitter is still possible) I created the looptimer
See: https://espeasy.readthedocs.io/en/lates ... oop-timers

Is that usable for your project?
The timer is scheduled based on the last timer + interval, so there should be no drift in the scheduled interval.
Still there can be some jitter in the moment the timer is handled as rules processing can be delayed by blocking code.
I don't think you should try to process several events a second as the rules processing may take some time.
I would really be surprised if you manage to process over 5 events a second.

_Cyber_
Normal user
Posts: 115
Joined: 20 Oct 2019, 09:46

Re: granularity of TimerSet_ms differs by 10%

#3 Post by _Cyber_ » 04 Feb 2021, 18:25

Thanks, will try looptimer. Looks like it is an alternative.

Best regards
Alois

_Cyber_
Normal user
Posts: 115
Joined: 20 Oct 2019, 09:46

Re: granularity of TimerSet_ms differs by 10%

#4 Post by _Cyber_ » 06 Feb 2021, 15:27

:!: awesome :!:

with looptimer the difference between the 28seconds (not ms) timer and the looptimer,1000,28 is ... 1ms. :D

the timerpart of the rules is now also shorter with looptimer:

Code: Select all

on Rules#Timer=7 do
 //[VAR#20] seconds requested; [VAR#21] direction; [VAR#22] shutter percent
 logentry,%eventvalue2%
 Let,22,[SZ#S]+(100/28)*[VAR#21]
 if %eventvalue2% = [VAR#20] or [VAR#20] = 0
  if %eventvalue2% != 0
   TimerSet_ms,7,0
  endif
  Let,20,0
  Let,21,0
  TaskValueSet,1,1,[INT#22]
  TaskValueSet,1,2,0
 else
  TaskValueSet,1,1,[VAR#22]
 endif
 SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=%sysname%&SZ=[SZ#M];[SZ#S];
endon
Two questions regarding: "I don't think you should try to process several events a second as the rules processing may take some time. I would really be surprised if you manage to process over 5 events a second."

Does this thinking fit to a ESP8266 or a ESP32?
With ESPEasy, does the ESP32 use both cores? By default (so if not set specificly) with Arduino it uses AFAIK the second core for Wifi stuff - is this also true with ESP32?

I have not checked "Enable RTOS Multitasking" - I do not know what it does, but I suspect it is maybe related. :-)

I have recognized the ESP32 has much more load printed on the main page as my ESP8266 - about 15% compared to 7% on nearly idling around. the shutter-project-ESP32 ist always over 21%, I could save already 10% by combining dummydevice events with "Single event with all values".

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: granularity of TimerSet_ms differs by 10%

#5 Post by TD-er » 07 Feb 2021, 00:31

Well those questions do look "simple to answer", but they aren't...

Currently we don't use the 2 cores of the ESP32 as data synchronization is a bit hard between them.
So therefore I disabled it for now and indeed it has to do with RTOS multitasking.
You can of course use locks to sync data between cores, but a lock is rather overkill as it affects both cores.
So a more simpler approach should be to use simple boolean like semaphores, but I ran into some issues which I could not solve very easily, so I left it for later in the hope the core libs would give some better examples later.

The load on ESPEasy is not as easy to explain as one may think.
I have written a scheduler for ESPEasy which also makes sure your loop timer is executed at the right time :)

For this scheduler, every loop() cycle it looks at the next thing to do and checks if its timer has already passed.
If it has, it will pop it from the queue and execute it. => Active loop
If the timer has not yet passed => idle loop.

2 counters are used to keep track of the number of usec is spent in active loop and in idle loop.
This ratio is the "load"

Now the catch...
During "idle loop" the background tasks are also processed.
These can take almost no time, but may also trigger some actions and may take some time to fetch all received WiFi data for example.
(the background tasks are also called every now and then even if there is an active loop ready to run to make sure background tasks are still dealt with)
This may lead to some skew in reported load.

So you can only compare loads on the same platform units.
A load of ESP8266 and ESP32 cannot be compared very well as background tasks may be relative high load for a faster ESP32 as they still take the same amount of time to process.

_Cyber_
Normal user
Posts: 115
Joined: 20 Oct 2019, 09:46

Re: granularity of TimerSet_ms differs by 10%

#6 Post by _Cyber_ » 08 Feb 2021, 06:38

thanks, got it. :-)

BR
Alois

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 51 guests