Hi. I would appreciate a little help with some code please.
I am using an 08M2 to control a water heater. I turn on the water heater by making pinC.4 high by simply momentarily pushing a push to make switch which is connected to 5V and pinC.4. This then makes pinC.0 go high which operates a relay to turn on the heater and it stays on for the time specified in the code below (60 x 60 seconds to give one hour).
The code below accomplishes this.
My problem is that I want to be able to turn off the heater by again momentarily pressing the switch to make pinC.4 high, if I change my mind about heating the water, during the period when the loop is performing.
I basically need to be able to exit the loop and get out of the PAUSE, which lasts for 60 seconds, and have the pinC.0 go low until the next high pinC.4. Once the 60 second pause starts I can’t get out of it.
I have looked at the EXIT command and INTERRUPT command but can’t get it to do what I want. I have searched the forum but can't get exactly what I need. Maybe it's not possible to get out of a pause once it's started!
The other solution I suppose is to reset by turning off the power supply to the 08M2 for a few moments,letting the capacitor discharge, but this entails using another switch.
The other option is to shorten the pause to say 6 seconds, interrupt the loop and increase the number of loops. If I then held the switch for more than 6 seconds I'd be finished the pause and could exit the loop. If possible I'd like to avoid this.
Thanks if you can help.
Regards
Dermot
'08M2
Start:
If pinC.4=1 then high C.0
endif
if pinC.4=0 then State1
for b1=1 to 60
pause 60000
next b1
low C.0
goto start
State1:
low C.0
goto Start
I am using an 08M2 to control a water heater. I turn on the water heater by making pinC.4 high by simply momentarily pushing a push to make switch which is connected to 5V and pinC.4. This then makes pinC.0 go high which operates a relay to turn on the heater and it stays on for the time specified in the code below (60 x 60 seconds to give one hour).
The code below accomplishes this.
My problem is that I want to be able to turn off the heater by again momentarily pressing the switch to make pinC.4 high, if I change my mind about heating the water, during the period when the loop is performing.
I basically need to be able to exit the loop and get out of the PAUSE, which lasts for 60 seconds, and have the pinC.0 go low until the next high pinC.4. Once the 60 second pause starts I can’t get out of it.
I have looked at the EXIT command and INTERRUPT command but can’t get it to do what I want. I have searched the forum but can't get exactly what I need. Maybe it's not possible to get out of a pause once it's started!
The other solution I suppose is to reset by turning off the power supply to the 08M2 for a few moments,letting the capacitor discharge, but this entails using another switch.
The other option is to shorten the pause to say 6 seconds, interrupt the loop and increase the number of loops. If I then held the switch for more than 6 seconds I'd be finished the pause and could exit the loop. If possible I'd like to avoid this.
Thanks if you can help.
Regards
Dermot
'08M2
Start:
If pinC.4=1 then high C.0
endif
if pinC.4=0 then State1
for b1=1 to 60
pause 60000
next b1
low C.0
goto start
State1:
low C.0
goto Start
Last edited: