! Cavanaugh's HCS / 18 SEPT 93. ! CONFIG SC = SC1 CONFIG PL-LINK = 1 CONFIG IR-LINK = 0 CONFIG LCD-LINK = 1 CONFIG DIO-LINK = 0 CONFIG ADIO-LINK = 0 ! Indicates X10 modules to display. Display Modules = A,B ! INPUTS; PA0 to PB7; 16 inputs available. DEFINE Bed = Input(1) DEFINE Liv_Rm = Input(2) DEFINE Fam_Rm = Input(3) DEFINE Gar = Input(4) DEFINE Base = Input(5) DEFINE Doors = Input(6) DEFINE Gar_Dr = Input(7) DEFINE Away_Key = Input(8) DEFINE Home_Key = Input(9) DEFINE Display = Input(10) DEFINE DisplayReading = Input(11) DEFINE Guest_Mode = Input(12) DEFINE Restart = Input(13) DEFINE Silence_Horn = Input(14) DEFINE Var1 = Variable(1) DEFINE Var2 = Variable(2) DEFINE Var3 = Variable(3) DEFINE Var4 = Variable(4) DEFINE Var5 = Variable(5) DEFINE Var6 = Variable(6) DEFINE Var7 = Variable(7) DEFINE Var8 = Variable(8) DEFINE RawV = Variable(9) DEFINE RawVV = Variable(13) DEFINE DspTmr = Timer(1) DEFINE Tmr2 = Timer(2) ! Address of the X10 module. DEFINE Radio = Module(B1) ! OUTPUTS; PC0 to PC7; 8 outputs available DEFINE Horn = Output(1) ! Item numbers for the LOG. DEFINE Horn_Off = 0 DEFINE Moving = 1 ! DEFINE the normal and inverted states for ON and OFF. DEFINE OnN = ON DEFINE OffN = OFF DEFINE OnI = OFF DEFINE OffI = ON BEGIN ! Establish known conditions on start-up. IFA Reset THEN DspTmr=ON; ClearVariables; Timer(10)=OFF; Output(0)=OFF Output(5)=OFF; Output(7)=OFF END ! Update LCD display every ten seconds. IF DspTmr=10 THEN RawV = ADC(2) Variable(15) = ((RawV*18)+320) ! Display the temperature and time. LCD(0) = "Temperature= %P1\xDF F", Variable(15) LCD(0) = "Time is %B \n" ! Reset the display timer. DspTmr=ON END ! Reset the display timer. IFA DspTmr > 15 THEN DspTmr = ON END ! Monitor the time for the radio to turn ON. IFA Time=7:15:WK THEN Radio = ON END ! Turn off the radio. IFA Time = 7:28:WK THEN Radio = OFF END ! Start timer2 to allow timer to shut off alarm IF Gar_Dr=OFF THEN Tmr2 = ON END ! Monitor for intrusion of Liv, Fam Rm or Garage IF Liv_Rm=OFF OR Fam_Rm=OFF OR Gar=OFF THEN Var1 = ON END ! Monitor Garage door but allow 120 sec timer to shut off alarm IF Gar_Dr = OFF AND Tmr2 > 120 THEN Var2 = ON END ! Monitor Base, Doors and timed garage door IF Base=OFF OR Doors=OFF OR Var2=ON THEN Var3 = ON END ! Monitor house for AT HOME security IF Var1=ON OR Var3=ON THEN Var4 = ON END ! Monitor complete house for AWAY security IF Var3=ON OR Bed=ON THEN Var5 = ON END ! Var6 will monitor the house for AT HOME security IF Home_Key=ON AND Var4=ON THEN Var6 = ON END ! Var7 will monitor the house for AWAY security IF Away_Key=ON AND Var5=ON THEN Var7 = ON END ! Test code for motion detector. IF Bed = OFF THEN Output(0)=ON Timer(10)=ON END ! LOG when the alarm HORN was triggered IF Output(0) = ON THEN LOG(Moving) = 1 END ! LOG when the alarm HORN was shut off IF Output(0) = OFF THEN LOG(Horn_Off) = 0 END ! Timer to allow the HORN to shut off after 120 sec IFA Output(0)=ON AND TImer(10)>120 THEN Output(0) = OFF Timer(10) = OFF END ! Photo Sensor indicates dark out, turn on lites. IF ADC(0) > 100 THEN Timer(3) = ON END ! Timer3 will debounce the photo sensor before lites go on. IF Timer(3) > 300 THEN Output(2) = ON; Timer(3) = OFF END ! Photo Sensor indicates light out, turn off lights. IF ADC(1) < 75 THEN Timer(4) = ON END ! Timer4 will debounce the photo sensor before lites go off. IF Timer(4) > 300 THEN Output(2) = OFF; Timer(4) = OFF END