PDA

View Full Version : PAC Fan run on timer for heat lamps


Stu
29 Jan 08, 08:56 AM
Is the code I have here going in the right direction? It runs OK in PICED.
The idea is to run a fan on if the light has been on longer for 1 minute.

{If an Ensuite light goes ON then start Exhaust Fan after light(s) have been on for >10 seconds
On for longer than 1 minute then fan runs on for 2 minutes after last light goes off}

if ConditionStaysTrue(GetLightingState("Ensuite Light") or
GetLightingState("Esuite Heat 1 51B") or
GetLightingState("Ensuit Heat 2 51C")= ON, 10) then { 10 seconds }
begin { a light has gone on long enough to start fan }
Trigger2 := ON; {condition met, store result}
SetLightingState("Ensuite Fan", ON); { switch on fan }
StartTime := Time; { set start time }
end;

once (GetLightingState("Ensuite Light")= OFF) and
(GetLightingState("Esuite Heat 1 51B")= OFF) and
(GetLightingState("Ensuit Heat 2 51C")= OFF) and {if all lights are off}
(Trigger2 = ON) then {check if condition met}
begin { lights have gone off and were on long enough to start fan }

if Time - StartTime > 60 then { fan has been on for 60 seconds }
Delay(120); { 2 mins delay off for fan }
SetLightingState("Ensuite Fan", OFF); { switch off fan }
Trigger2 := OFF; {set condition OFF}
end;

Stu