Page scanner
The following example was donated by Mike Gill.
A schematic is not available but here is some additional info from the author:
No Schematic, it just connects via the serial port and gives appropriate codes to a
purpose built UHF transmitter. Typically
pager code followed by bleep code, then message string or variable. The transmitters are
built by Scope/ MB Electronics and
no doubt others in different countries.
Download file in .BAS file
' 32 Way Scanner and Potsag Pager
Interface MKG 08/06/98 Bascom 8052 Compiler for 89S8252
' Reads PCF8574s on I2C Bus. Inputs to these are active
LOW via Opto Couplers
' Inputs are latched until cancelled at source. Change
Ports and remove Watchdod if other CPU used
' Should be easy to alter if you require momentery inputs,
Scan routine is fast enough.
' Configure for what Serial O/P you need, i.e Moving Message
display/Terminal.
StartUp:
Config WatchDog = 2048
Start WatchDog
Config SCL = P2.0 ' I2C Bus Pin Assignments
Config SDA = P2.1
Config Lcd = 16 * 2
WaitMs 50 ' Allow Display time to Initialise
$Baud = 300 ' Output to paging TX
$Crystal = 12000000
Cursor OFF
Cls
Lcd "B M Electronics" ' Start Up Message, What you like
Dim Check As Bit ' Check for Call
Dim DelayTime As Byte ' Used in Loop for Time Between Calls
Dim AlarmBlips As Byte ' Counter for No of Bleeps on
Sounders
Dim I2cAddress As Byte ' Address to Read
Dim I2cRead As Byte ' Data from PCF8574
Dim I2cStage As Byte ' Individual PCF8574 Location
Dim RealNo As Byte ' Actual Position Number
Dim Result As Byte ' Result of Input Present Test
Dim Message As String * 16 ' Displayed Pager/Lcd Message
StatusLed Alias P0.0 ' Inverted 1=OFF 0=ON
Sounder Alias P2.2 ' True 1=ON 0=OFF
BackLight Alias P2.3 ' True
Relay Alias P2.4 ' True
Sounder = 0 ' Sounder
OFF
Relay = 0 ' Relay OFF
(If Used)
BackLight = 0 ' Back
Light OFF
Check = 0 ' Reset
Call Check Bit for Immediate Page
StatusLed = 1 ' OFF
MainLoop:
Gosub ScanInputs
Reset WatchDog
StatusLed = 0 ' Status Led ON
WaitMs 10 ' Led Flash Time (Once Per Scan of 32
Points)
StatusLed = 1 ' Status Led OFF - Disable if faster
scan needed
WaitMs 150
If Check = 1 Then : Gosub DelayIt : Goto StartUp : End If
Goto MainLoop
End
ScanInputs: ' Reads all
PCF8574 Inputs in Sequence
For I2cAddress = 64 To 70 Step 2 ' Select 1 of 4 ICs In Turn
If I2cAddress = 64 Then : I2cStage = 0 : End If ' 1st 4 codes for PCF8574
If I2cAddress = 66 Then : I2cStage = 8 : End If
If I2cAddress = 68 Then : I2cStage = 16 : End If
If I2cAddress = 70 Then : I2cStage = 24 : End If
I2cReceive , I2cAddress , I2cRead
Result = I2cRead And 1 : If Result = 0 Then : RealNo = 0 + I2cStage : Gosub Display : End If
Result = I2cRead And 2 : If Result = 0 Then : RealNo = 1 + I2cStage : Gosub Display : End If
Result = I2cRead And 4 : If Result = 0 Then : RealNo = 2 + I2cStage : Gosub Display : End If
Result = I2cRead And 8 : If Result = 0 Then : RealNo = 3 + I2cStage : Gosub Display : End If
Result = I2cRead And 16 : If Result = 0 Then : RealNo = 4 + I2cStage : Gosub Display : End If
Result = I2cRead And 32 : If Result = 0 Then : RealNo = 5 + I2cStage : Gosub Display : End If
Result = I2cRead And 64 : If Result = 0 Then : RealNo = 6 + I2cStage : Gosub Display : End If
Result = I2cRead And 128 : If Result = 0 Then : RealNo = 7 + I2cStage : Gosub Display : End If
Next I2cAddress
Return
End
Display:
Reset WatchDog
BackLight = 1 ' Display Back Light ON
Check = 1 ' Enables Loop Delay Counter
StatusLed = 0 ' Flashes Led
Message = LookupStr(RealNo , List)
Cls
Lcd "Number Calling.." ' Print to Lcd
Lowerline
Lcd Message ' Alarm message to Lcd
Reset WatchDog
Print "L0012000A" ; Message ' TX Message to Pagers Or other serial 'device
Gosub Alarm
Return
End
Alarm:
For AlarmBlips = 0 to 5 ' Modify for faster scan
Reset WatchDog
Sounder = 1 ' Alarm ON
Wait 1
Reset WatchDog
Sounder = 0 ' Alarm OFF
Wait 1
Next AlarmBlips
Return
End
DelayIt: ' Routine needed
instead of simple Wait
For DelayTime = 0 To 45 ' To allow WatchDog to Reset
periodically
Reset WatchDog
Wait 1
Next DelayTime ' Remove this routine for fast scan
Return
End
List:
Data "One " , "Two " , "Three " , "Four " ' Change these for whatever
Data "Five " , "Six " , "Seven " , "Eight "
Data "Nine " , "Ten " , "Eleven " , "Twelve "
Data "Thirteen " , "Fourteen " , "Fifteen " , "Sixteen "
Data "Seventeen " , "Eighteen " , "Nineteen " , "Twenty "
Data "Twenty One " , "Twenty Two " , "Twenty Three " , "Twenty Four "
Data "Twenty Five " , "Twenty Six " , "Twenty Seven " , "Twenty Eight "
Data "Twenty Nine " , "Thirty " , "Thirty One " , "Thirty Two "
End
|