This code is meant to pause for the amount set by a pot (from 1 to 60 seconds):
I tested with pollingInterval variable set at 10, 25 and 50ms.
An expected 60s pause took
10ms -2m 28s
25ms - 1m 35s
50ms - 1m 17s respectively.
There is not that much code executing but the poling interval has a big impact on accuracy.
I guess the only solution is increasing the pollingInterval to the maximum tolerable value.
From what I read the m2 elapsed time counter is also effected by pause commands right?
Help please.
I tested with pollingInterval variable set at 10, 25 and 50ms.
An expected 60s pause took
10ms -2m 28s
25ms - 1m 35s
50ms - 1m 17s respectively.
There is not that much code executing but the poling interval has a big impact on accuracy.
Code:
IntervalTiming:
symbol alarmTimer = w8
alarmTimer = 0
elapsedTime = 0
do
...
elapsedTime = 0
do
; motor off while pause for potTime amount
gosub DetermineSwitchPosition
if switchPosition <> 3 then MainLoop
Pause pollingInterval
elapsedTime = elapsedTime + pollingInterval
gosub DeterminePotTime
loop until elapsedTime >= potTime
goto IntervalTiming
DeterminePotTime:
; Return potTime as 1000ms to 60000ms
symbol MAX_SECONDS = 60
symbol MIN_SECONDS = 1
symbol POT_PIN = c.1
ReadAdc POT_PIN, potTime
potTime = MAX_SECONDS - MIN_SECONDS * potTime / 255 + MIN_SECONDS * 1000
return
DetermineSwitchPosition:
; Sets global 'switchPosition' variable
if swchPinTimed = 1 then
switchPosition = 3
else if swchPinCont = 1 then
switchPosition = 2
else
switchPosition = 1
endif
return
From what I read the m2 elapsed time counter is also effected by pause commands right?
Help please.
Last edited: