Hello all,
I have been trying to program an 08M2 (4.A) to wait an interval of time then do a task. During my testing, I noticed that if I reset the TIME variable to zero (TIME=0), the first one second interval varies. It is always less than a second and the interval varies.
I use a "DO WHILE button is pressed" loop to set the TIME variable to zero and I update the time on an OLED display after every increment of the TIME variable (each second). I also have a "how many times through the main program loop" counter (W1). It takes 247 loops through the program for the TIME variable to change. However, when I press and release the button which should reset the timer to zero, the number of times through the program loop varies anywhere from 51 to 226 for the first increment of the timer. I have also used the DISABLETIME/ENABLETIME commands inside the reset loop but found no changes.
This leads me to believe that just because the TIME variable is set to zero, the internal timer is not reset to the start of its count.
Does anyone have any info on this?
Dave E
I have been trying to program an 08M2 (4.A) to wait an interval of time then do a task. During my testing, I noticed that if I reset the TIME variable to zero (TIME=0), the first one second interval varies. It is always less than a second and the interval varies.
I use a "DO WHILE button is pressed" loop to set the TIME variable to zero and I update the time on an OLED display after every increment of the TIME variable (each second). I also have a "how many times through the main program loop" counter (W1). It takes 247 loops through the program for the TIME variable to change. However, when I press and release the button which should reset the timer to zero, the number of times through the program loop varies anywhere from 51 to 226 for the first increment of the timer. I have also used the DISABLETIME/ENABLETIME commands inside the reset loop but found no changes.
This leads me to believe that just because the TIME variable is set to zero, the internal timer is not reset to the start of its count.
Does anyone have any info on this?
Dave E
Code:
#PICAXE 08M2
#NO_DATA
SETFREQ M4
SYMBOL SECONDS = B4 'W2
SYMBOL MINUTES = B5 'W2
SYMBOL HOURS = W3
SYMBOL TIME2 = W4
PAUSE 1000
SEROUT C.4, N2400_4, (254, 1)
PAUSE 100
SEROUT C.4, N2400_4, (254, 192, #HOURS, ":", #MINUTES, ":", #SECONDS)
TIME = 0
TIME2 = 0
MAIN:
DO
DO WHILE PINC.3 = 1 'RESET TIME/CLEAR SCREEN WHILE BUTTON IS PRESSED
TIME = 0
TIME2 = 0
SECONDS = 0
MINUTES = 0
HOURS = 0
W1 = 0
SEROUT C.4, N2400_4, (254, 1)
LOOP
TOGGLE C.1 'LED
INC W1 'COUNT NUMBER OF RUNS THROUGH PROGRAM
IF TIME = 1 THEN 'ONE SECOND HAS ELAPSED
TIME = 0
INC TIME2
SEROUT C.4, N2400_4, (254, 128, #TIME2, 254, 135, #W1)
W1 = 0
INC SECONDS
IF SECONDS = 60 THEN
SECONDS = 0
SEROUT C.4, N2400_4, (254, 192, #HOURS, ":", #MINUTES, ":0 ")
INC MINUTES
IF MINUTES = 60 THEN
INC HOURS
MINUTES = 0
SEROUT C.4, N2400_4, (254, 192, #HOURS, ":0 ", ":0 ")
ENDIF
ENDIF
SEROUT C.4, N2400_4, (254, 192, #HOURS, ":", #MINUTES, ":", #SECONDS)
ENDIF
LOOP