I am new to Picaxe and micro-controllers, but I decided to dive into this project. I am programming an 08M to monitor hours of on time for a machine. After 6 months of on time I need the 08M to blink a light and turn on a relay. I have tested my circuit with smaller time values and it does most of what it is supposed to do. I am using "write" commands so the 08M can remember its time count should the power be turned off, but that is not working. It's important that the 08M remember the amount of on time and not reset if power is interrupted. I don't know what I am doing wrong.
Code:
symbol light = 1 `rename output 1 'light'
symbol relay = 2 `rename output 2 'relay'
symbol minutes = b0 `rename variable b0 'minutes'
symbol start = b13 `rename variable b13 'start'
symbol hours = b12 `rename variable b12 'hours'
symbol days = b11 `rename variable b11 'days'
main:
low 0,1,2,4
if days = 180 then shutdown
read minutes,start `read value of start into minutes
minute:
for minutes = start to 59 `count to 60 minutes
wait 60 `wait 1 minute
write minutes,minutes `save the minutes value
debug b1
next minutes
let hours = hours + 1 `increment hours + 1
write hours,hours `save hours value
if hours = 24 then `check hour count
let days = days + 1 `increment days
let hours = 0 `reset hours
endif
let start = 0 `reset minutes start
write days,days `save days value
if days = 180 then shutdown `if 180 days then goto shutdown
goto minute
shutdown:
high relay `make relay out high
goto flash
flash:
if pin3 = 1 then
let days = 0
goto minute `reset
endif
high light `turn on light
pause 500 `wait for 0.5 seconds
low light `turn off light
pause 500 `wait for 0.5 seconds
goto flash `repeat
Last edited: