This project uses the Parallax Basic Stamp II (BS2-IC). The source code and schematic that follow forms a Status Monitor system that will send a page to an alpha or numeric pager containing the unique unit number and status of 4 discrete inputs. These inputs can be connected to anything that can provide a dry contact closure, a switch or an open collector output. The code is designed to send a pager whenever the state of any of the inputs changes from hi to lo or from lo to hi. This version of the software is designed to monitor 4 separate status inputs for two different users.
' statmon2.bs2
' dtmf pager status dialer
' 12/21/97 ADK
' if any of the 4 inputs changes state then a page is initiated
' the unit number and the status of the 4 inputs is sent to
' an alpha or numeric pager and represented as a 0 or 1 separated
' a dash symbol such as: +-------------+ 1 = open or high
' | 01-1-1-1-1 | 0 = closed or low
' +-------------+
' This version has 4 separate inputs for two different pagers.
'
' BS2-IC Pinout and Function
'
' Pin Name Function
' --- ---- --------
' 1 TX Serial Output -+
' 2 RX Serial input -+- Serial Port Programming Connections
' 3 ATN Active-High Reset -+
' 4 GND Serial Ground -+
' 5 P0 Status Input #1, Unit #1
' 6 P1 Status Input #2, Unit #1
' 7 P2 Status Input #3, Unit #1
' 8 P3 Status Input #4, Unit #1
' 9 P4 Status Input #1, Unit #2
' 10 P5 Status Input #2, Unit #2
' 11 P6 Status Input #3, Unit #2
' 12 P7 Status Input #4, Unit #2
' 13 P8 Line Relay Control
' 14 P9 DTMF Tones Output
' 15 P10 Unit #1 Dialing Status, high for duration of dialing
' 16 P11 Unit #2 Dialing Status, high for duration of dialing
' 17 P12 Unit #1 & #2 Status Change Pulse
' 18 P13 unused
' 19 P14 unused
' 20 P15 unused
' 21 +5V +5V Supply
' 22 RES Active Low Reset
' 23 GND System Ground ---+- Power Connections
' 24 PWR Regulator input ---+
'
'-------------------------- Program Starts Here --------------------------
PREV0 VAR BIT
PREV1 VAR BIT
PREV2 VAR BIT
PREV3 VAR BIT
PREV4 VAR BIT
PREV5 VAR BIT
PREV6 VAR BIT
PREV7 VAR BIT
STAT0 VAR BIT
STAT1 VAR BIT
STAT2 VAR BIT
STAT3 VAR BIT
STAT4 VAR BIT
STAT5 VAR BIT
STAT6 VAR BIT
STAT7 VAR BIT
input 0
input 1
input 2
input 3
input 4
input 5
input 6
input 7
output 8
output 9
output 10
output 11
output 12
STAT0 = IN0 'read inputs
STAT1 = IN1
STAT2 = IN2
STAT3 = IN3
STAT4 = IN4 'read inputs
STAT5 = IN5
STAT6 = IN6
STAT7 = IN7
PREV0 = STAT0 'make stat & previous the same so that the unit will
PREV1 = STAT1 'not page upon restart or power-up
PREV2 = STAT2
PREV3 = STAT3
PREV4 = STAT4 'make stat & previous the same so that the unit will
PREV5 = STAT5 'not page upon restart or power-up
PREV6 = STAT6
PREV7 = STAT7
start:
PREV0 = STAT0 ' make last value of STAT equal to the PREV
PREV1 = STAT1 ' first unit section
PREV2 = STAT2
PREV3 = STAT3
PREV4 = STAT4 ' make last value of STAT equal to the PREV
PREV5 = STAT5 ' second unit section
PREV6 = STAT6
PREV7 = STAT7
STAT0 = IN0 ' read inputs for current condition
STAT1 = IN1 ' first unit section
STAT2 = IN2
STAT3 = IN3
STAT4 = IN4 ' read inputs for current condition
STAT5 = IN5 ' second unit section
STAT6 = IN6
STAT7 = IN7
DEBUG bin stat0,bin stat1,bin stat2,bin stat3,bin stat4,bin stat5,bin stat6,bin stat7,10,13
if STAT0 <> PREV0 then pageme ' if current and previous are not
if STAT1 <> PREV1 then pageme ' the same then send a page
if STAT2 <> PREV2 then pageme ' with the new conditions
if STAT3 <> PREV3 then pageme
start2:
if STAT4 <> PREV4 then pageme2
if STAT5 <> PREV5 then pageme2
if STAT6 <> PREV6 then pageme2
if STAT7 <> PREV7 then pageme2
goto start ' loop
pageme: ' begin paging section for unit 1
pause 200
debug "Output to Pager:01-",BIN STAT0,"-",bin STAT1,"-",bin STAT2,"-",bin STAT3,10,13
pulsout 12,65535
out10 = 0 ' turn on status led
out8 = 0 ' pull in line seize relay
pause 800
dtmfout 9,[1,2,3,4,5,6,7] ' replace the 1,2,3,4,5,6,7 with the actual
pause 15000 ' pager telephone number for unit #1
dtmfout 9,[0,1,10,BIN STAT0,10,BIN STAT1,10,BIN STAT2,10,BIN STAT3,11]
pause 800
out8 = 1 ' drop line seize relay
out10 = 1 ' turn off status led
goto start2 ' end paging section & go back to the input loop
pageme2: ' begin paging section for unit 2
pause 200
debug "Output to Pager:02-",bin stat4,"-",bin stat5,"-",bin stat6,"-",bin stat7,10,13
pulsout 12,65535
out11 = 0 ' turn on status led
out8 = 0 ' pull in line seize relay
pause 800
dtmfout 9,[1,2,3,4,5,6,7] ' replace the 1,2,3,4,5,6,7 with the actual
pause 15000 ' pager telephone number for unit #2
dtmfout 9,[0,1,10,BIN STAT0,10,BIN STAT1,10,BIN STAT2,10,BIN STAT3,11]
pause 800
out8 = 1 ' drop line seize relay
OUT11 = 0 ' turn off status led
goto start ' end paging section & go back to the input loop
stop
'
'-------------------------- Program Ends Here --------------------------