' ========================================================================= ' ' File....... PCL2.BS1 ' Purpose.... Lights controller for airport runway / beacon ' Authors..... Jon Williams, Parallax, Inc. jwilliams at parallax dot com ' Jared Watkins jared at watkins dot net ' ' Started.... 10 JUL 1994 ' Updated.... 12 OCT 2005 ' ' {$STAMP BS1} ' {$PBASIC 1.0} ' ' -----[ Program Description ]--------------------------------------------- ' http://www.uoguelph.ca/~antoon/circ/sensor4.htm ' http://store.qkits.com/moreinfo.cfm/QK126 (Change C2 to .1u and R3 to about 4.3k) ' ' The program accepts input from a darkness sensor and vox kit and outputs ' to one or more relays to control lighting for an airport. In darkness it will ' listen to a base radio speaker for 'clicks' of someone keying their mic. On hearing ' 7 clicks in a 10 second period it will activate the lights for about 15 minutes and will ' restart the lights timer if it picks up 7 more clicks while they are still on. ' There is another output for a beacon relay to turn on when it gets dark. ' ' -----[ Revision History ]------------------------------------------------ ' ' 07-10-94... Version 1.0 ' 07-11-94... Fine tuned timing loop constants ' 09-10-05... Reformatted to current standards (Elements of PBASIC Style) ' 10-12-05... Added beacon out, darkness check, made to listen for clicks while lighs are on ' -----[ I/O Definitions ]------------------------------------------------- SYMBOL StatusLED = 1 ' Indicates clicks and lights on state (out) SYMBOL Lights = 2 ' light relay control (out) SYMBOL Beacon = 3 ' Dedicated Beacon Circuit (out) SYMBOL DarkSensor = 6 ' Darkness Circuit Reads High When Dark(in) SYMBOL ClixIn = 7 ' vox circuit goes high on click (in) ' -----[ Constants ]------------------------------------------------------- SYMBOL TimerDelay = 755 ' tuned for 10 seconds SYMBOL LightClix = 7 ' 7 clicks for lights SYMBOL LightOn = 9000 ' tuned for 15 min (in tenths of a second) ' -----[ Variables ]------------------------------------------------------- SYMBOL numClix = B0 ' clicks counter SYMBOL work = B1 ' button workspace SYMBOL timer = W1 ' time delay counter SYMBOL tmrDelay = W2 ' New Lights on counter ' -----[ EEPROM Data ]----------------------------------------------------- ' -----[ Initialization ]-------------------------------------------------- '76543210 - Pins Reset: DIRS = %00111111 ' port setup PINS = %00000000 ' outputs off tmrDelay = 0 ' -----[ Program Code ]---------------------------------------------------- Startup: ' Stay in this loop while it's daylight LOW Beacon LOW Lights HIGH StatusLED PAUSE 1000 LOW StatusLED IF PIN6 = 0 THEN Startup Main: work = 0 ' clear button workspace HIGH Beacon IF PIN6 = 0 THEN Startup ' If it's daylight stop looking for clicks ' DEBUG "Listening for Clicks", CR BUTTON ClixIn, 1, 255, 0, work, 0, Main ' wait for input FoundClick: numClix = 1 ' count first click DEBUG "Click Number: ", #numClix, CR timer = 0 ' reset timer Monitor: BUTTON ClixIn, 1, 255, 0, work, 0, Inc_T0 ' check input numClix = numClix + 1 ' update click count DEBUG "Click Number: ", #numClix, CR Inc_T0: PAUSE 10 ' 10 ms delay timer = timer + 1 ' update timer IF timer = TimerDelay THEN Check_Clix ' if timer done, check IF numClix = LightClix THEN Check_Clix ' early exit GOTO Monitor ' timer still active Check_Clix: DEBUG "Checking Click Count", CR IF numClix < LightClix THEN CheckLightsOn ' not enough check to see if already on.. if not start over HIGH Lights ' lights on HIGH StatusLED DEBUG "Lights On! ",#PIN2, CR tmrDelay = LightOn work = 0 numClix = 0 LightsOnState: PAUSE 100 BUTTON ClixIn, 1, 255, 0, work, 1, FoundClick ' Listen for Click tmrDelay = tmrDelay - 1 ' IF PIN6 = 0 THEN Startup ' If it's daylight stop looking for clicks ' DEBUG "Timer: ", #tmrDelay, CR IF tmrDelay > 0 THEN LightsOnState Expired: LOW Lights LOW StatusLED DEBUG "Lights Off!", CR GOTO Main CheckLightsOn: DEBUG "Checking Lights On", CR IF tmrDelay > 0 THEN LightsOnState GOTO Main ' -----[ Subroutines ]-----------------------------------------------------