;Grey water controller MK2 symbol PUMP=0 ; name output 0 as the PUMP symbol ERROR_LED=1 ; name the output 1 as the error (fault) LED ;high waterfloat switch = input 3, low water float switch = input 4 let dirs=%0000111 let pins=%0000000 ;ensure all outputs low ;float switches are inverse logic, a 0 means it is turned on main_loop: if input3=0 and input4=0 then debounce ;high water float mark if input4=0 then inc_timer ;low water float mark goto main_loop inc_timer: let w0=w0+1 if w0=36000 then start_pump ;if water is in the tank for 10 hours, start pump pause 1000 ;pause 1 second goto main_loop debounce: pause 500 if input3=1 then main_loop ;check if the float is still high start_pump: high PUMP ;turn on pump relay pump_loop: if input4=1 then stop_pump ;check to see if low water if w1=3600 then pump_error ;error if pumps operates continuously for more than 60 minutes let w1=w1+1 pause 1000 goto pump_loop stop_pump: low PUMP ;stop pump let w0=0 ;reset stale water counter let w1=0 ;reset error counter goto main_loop pump_error: low PUMP ;stop the pump error_loop: if input4=1 then exit_loop ;stay errored until tank empty high ERROR_LED pause 500 low ERROR_LED pause 500 goto error_loop exit_loop: let w0=0 ;reset counters let w1=0 low ERROR_LED ;reset error LED goto main_loop