SparkyDave
Member
Hi All,
I'm not at all close to being a great coder and I'm stuck where I have a few problems with what I thought would be an easy program to write. I want to create a Spa controller where:
-The Controller has 3 buttons, PUMP, BLOWER, LIGHT
-The pump has 2 speeds
-The blower will only turn ON if the pump is running
-The light can be turned ON or OFF at any time
-When not in use, the spa cycles ON for 15mins, then OFF for 45mins (auto cycle)
-If the PUMP button is pressed while the spa is OFF, the pump is to turn ON at low speed
-If the PUMP button is pressed while the spa is running on low speed, it will go to high speed
-If the spa is running for 1 hour, the spa turns OFF (back to its auto cycle)
I have used an interrupt for the PUMP button so it can force the spa ON at any time and also have the light switching working ok, but I seem to have issues with the blower and also the use of SYMBOLS. What is the best way to use the status of an output in an IF statement? (ie: IF an input AND an output are high, then...)
Any help would be greatly appreciated.
I'm not at all close to being a great coder and I'm stuck where I have a few problems with what I thought would be an easy program to write. I want to create a Spa controller where:
-The Controller has 3 buttons, PUMP, BLOWER, LIGHT
-The pump has 2 speeds
-The blower will only turn ON if the pump is running
-The light can be turned ON or OFF at any time
-When not in use, the spa cycles ON for 15mins, then OFF for 45mins (auto cycle)
-If the PUMP button is pressed while the spa is OFF, the pump is to turn ON at low speed
-If the PUMP button is pressed while the spa is running on low speed, it will go to high speed
-If the spa is running for 1 hour, the spa turns OFF (back to its auto cycle)
I have used an interrupt for the PUMP button so it can force the spa ON at any time and also have the light switching working ok, but I seem to have issues with the blower and also the use of SYMBOLS. What is the best way to use the status of an output in an IF statement? (ie: IF an input AND an output are high, then...)
Code:
input C.0
input C.1
input C.2
output B.1
output B.2
output B.3
output B.4
symbol LIGHTBUTTON = C.0
symbol BLOWERBUTTON = C.1
symbol PUMPBUTTON = C.2
symbol LIGHTON = B.1
symbol BLOWERON = B.2
symbol PUMPLOW = B.3
symbol PUMPHIGH = B.4
main:
let W0 = time + 5 ;normally +900 (15mins), changed for testing
let W1 = time + 10 ;normally +2700 (45mins), changed for testing
let W2 = time + 20 ;normally +3600 (60mins), changed for testing
setint %0000100,%0000100
cycleon:
setint %0000100,%0000100
disabletime
time = 0
enabletime
high PUMPLOW ;turn pump on at low speed
do
if pinC.0 = 1 then gosub light ;turn light on if light button is pressed
if time > W0 then ;after 15mins turn pump off
goto cycleoff
end if
loop
cycleoff:
setint %0000100,%0000100
disabletime
time = 0
enabletime
low PUMPHIGH
low PUMPLOW
do
if pinC.0 = 1 then gosub light ;turn light on if light button is pressed
if time > W1 then ;wait 45mins with pump off before returning to pump on cycle
goto cycleon
end if
loop
interrupt: ;do following if pump button is pressed
disabletime
time = 0
enabletime
high PUMPLOW
high PUMPHIGH
do if pinC.0 = 1 then gosub light ;turn light on is light button is pressed
if pinC.1 = 1 then gosub blower ;turn blower on if blower button is pressed
if pinC.2 = 1 then goto cycleoff
if time > W2 then
goto cycleoff ;run pump on high speed for 60mins
end if
loop
goto cycleon
blower:
;if pinC.1 = 1 and BLOWERON = 0 and PUMPHIGH = 1 (I actually wanted to have this check if 1 input was high and also 2 outputs high)
;then high BLOWER0N
;if BLOWERBUTTON = 1 and BLOWERON = 1 (I actually wanted to have this check if 1 input was high and also 1 output high)
;then low BLOWERON
if pinC.1 = 1 then
toggle B.2
end if
return
light:
if pinC.0 = 1 then
toggle LIGHTON
end if
return