I'm trying to figure out a better way to turn on/off a light in my home. I setup a timer using PLC code to turn them on at 5pm and off at 10pm. The problem is my code will not allow me to manually turn the lights off for the entire hour at 5pm and on at 10pm.
Is there a better way to write the code so I can turn the light on/off durning those two hours? I could deal with just a minute of auto on/off, but I'm having trouble writing the code.
START
LOOP:
SET RAM3 CH
TSTEQ RAM3 17
CALLSUB LITEON
TSTEQ RAM3 22
CALLSUB LITEOFF
GOTO LOOP
END
RESETS:
TSTEQ IP8 0
SET RAM8 0
TSTEQ IP8 1
SET RAM8 1
RET
LITEON:
TSTEQ RAM8 0
GOTO LON
RET
LON:
SET OP7 1
DELAY 500
SET OP7 0
SET RAM8 1
RET
LITEOFF:
TSTEQ RAM8 1
GOTO LOFF
RET
LOFF:
SET OP8 1
DELAY 500
SET OP8 0
SET RAM8 0
RET
I use OP1 to let me know if the light is on or off. Keep on mind that this not all of my code. I have all of the boards variables in use.
Thanks
Is there a better way to write the code so I can turn the light on/off durning those two hours? I could deal with just a minute of auto on/off, but I'm having trouble writing the code.
START
LOOP:
SET RAM3 CH
TSTEQ RAM3 17
CALLSUB LITEON
TSTEQ RAM3 22
CALLSUB LITEOFF
GOTO LOOP
END
RESETS:
TSTEQ IP8 0
SET RAM8 0
TSTEQ IP8 1
SET RAM8 1
RET
LITEON:
TSTEQ RAM8 0
GOTO LON
RET
LON:
SET OP7 1
DELAY 500
SET OP7 0
SET RAM8 1
RET
LITEOFF:
TSTEQ RAM8 1
GOTO LOFF
RET
LOFF:
SET OP8 1
DELAY 500
SET OP8 0
SET RAM8 0
RET
I use OP1 to let me know if the light is on or off. Keep on mind that this not all of my code. I have all of the boards variables in use.
Thanks