| Motivation/Problem:
This project started out as a very innocent question on the HomeVision
eGroups email list, "How do I control a keypad from HomeVision?"
As it turns out, one of the users has a hearing impairment and he
uses this RadioShack Wireless Personal Pager as a home messaging
system. The unit supports up to 1000 pagers and operates with a
very simple interface. You punch in a 3-digit pager ID followed
by 1 digit message code and hit the PAGE key. You can page all pagers
or a subset of pagers as well. The pagers are small and can be worn
on the belt. They can either beep or vibrate.
The only problem is, the base unit has to be operated manually--there's
no interface for any sort of automation. So the question was reasonable
and a fun challenge. With this interface, you can have up to 10
different events to automatically signal you including telephone,
door bell, call button (x10 works), front gate open, alarms, etc.
Reverse Engineering:
Before I started to design this project, I reverse-engineered how
the keypad (and most of the pager base unit) works. It uses a PIC
microcontroller and an EEPROM chip for a two-chip, very elegant
solution. The one thing to note is the CLR key. It doesn't get scanned
like the rest of the keys. In fact, it's a simply pushbutton switch
which resets the CPU every time you press it--talk about an idiot-proof
design!
When I annotated the wiring, I used the PIC pin names. Port RC is
configured as an output port, used for scanning both the keypad
and the LED display simultaneously. Each keypad row is isolated
from the display with a series diode (so the display doesn't blank
out when you press a key. The RB ports read the column signals from
the keypad. Only two are needed even though there are 3 columns
because of the clever way they use different row lines (8 total
instead of 4).
Once this was figured out, I simply drew a table and created the
logic equations to activate the switches from that (see the PAL
source below). |
| HomeVision
Interface to the Radio Shack Personal Pager
title HVPAGER
pattern hvpager
revision A
author Erich Whitney
company HomeBrew Engineering
date 09/15/00
chip hvpager gal16v8
; pin 1 2 3 4 5 6 7 8 9 10
ck hv0 hv1 hv2 hv3 u1 u2 u3 u4 gnd
; pin 11 12 13 14 15 16 17 18 19 20
/oe C B A ROW2 ROW1 ROW3 ROW4 AUX vcc
equations
;
; Decode HV inputs into the control lines for the analog muxes
;
; ROW SELECT
; HV INPUT CODE KEY RB RC 1 2 3 4 5 A B C
; ------------- ------- --- --- - - - - - - - -
; 0 0000 no key - - 0 0 0 0 0 0 0 0
; 1 0001 1 3 3 1 1
; 2 0010 2 4 3 1 1
; 3 0011 3 4 7 1 1
; 4 0100 4 3 2 1 1
; 5 0101 5 4 2 1 1
; 6 0110 6 4 6 1 1
; 7 0111 7 3 1 1 1
; 8 1000 8 4 1 1 1
; 9 1001 9 4 5 1 1
; 10 1010 0 4 0 1 1
; 11 1011 ALL 3 0 1 1
; 12 1100 * 4 4 1 1
; 13 1101 PAGE 3 4 1 1
; 14 1110 CLR - - 1 1
; 15 1111 no key - - 0 0 0 0 0 0 0 0
;
; The "row" outputs are inverted and go to the INHIBIT
pin of each CD4053
; CMOS switch. A 1 inhibits the switches from operating, 0 enables
them.
;
/ROW1 = /hv3 * /hv2 * /hv1 * hv0
+ /hv3 * /hv2 * hv1;
/ROW2 = /hv3 * hv2 * /hv1
+ /hv3 * hv2 * hv1 * /hv0;
/ROW3 = /hv3 * hv2 * hv1 * hv0
+ hv3 * /hv2 * /hv1;
/ROW4 = hv3 * /hv2 * hv1
+ hv3 * hv2 * /hv1 * /hv0;
/AUX = hv3 * hv2 * /hv1 * hv0
+ hv3 * hv2 * hv1 * /hv0;
;
; These are the switch select inputs to the CMOS switches
; A 1 is ON and a 0 is OFF
;
A = /hv3 * /hv2 * /hv1 * hv0
+ /hv3 * hv2 * /hv1 * /hv0
+ /hv3 * hv2 * hv1 * hv0
+ hv3 * /hv2 * hv1 * hv0;
B = /hv3 * /hv2 * hv1 * /hv0
+ /hv3 * hv2 * /hv1 * hv0
+ hv3 * /hv2 * /hv1 * /hv0
+ hv3 * /hv2 * hv1 * /hv0
+ hv3 * hv2 * /hv1 * hv0;
C = /hv3 * /hv2 * hv1 * hv0
+ /hv3 * hv2 * hv1 * /hv0
+ hv3 * /hv2 * /hv1 * hv0
+ hv3 * hv2 * /hv1 * /hv0
+ hv3 * hv2 * hv1 * /hv0;
|
|
This solution is a simple
logic interface to the Radio Shack Wireless Personal Pager. It has
a 4-bit input which provides digital control of the keypad. Here's
the schematic
created using IVEX WinDraft.
The PLAN-II PAL program I used to program the GAL16V8 PAL is on
the left. If you have a PAL programmer, you can compile this file
using free PLAN-II software from National Semiconductor's web site.
Here's the table of input combinations and their meaning:
| Key |
Bit 3 |
Bit 2 |
Bit 1 |
Bit 0 |
HomeVision Port A Value |
| no key |
0 |
0 |
0 |
0 |
0 |
| 1 |
0 |
0 |
0 |
1 |
1 |
| 2 |
0 |
0 |
1 |
0 |
2 |
| 3 |
0 |
0 |
1 |
1 |
3 |
| 4 |
0 |
1 |
0 |
0 |
4 |
| 5 |
0 |
1 |
0 |
1 |
5 |
| 6 |
0 |
1 |
1 |
0 |
6 |
| 7 |
0 |
1 |
1 |
1 |
7 |
| 8 |
1 |
0 |
0 |
0 |
8 |
| 9 |
1 |
0 |
0 |
1 |
9 |
| 0 |
1 |
0 |
1 |
0 |
10 |
| ALL |
1 |
0 |
1 |
1 |
11 |
| * |
1 |
1 |
0 |
0 |
12 |
| PAGE |
1 |
1 |
0 |
1 |
13 |
| CLR |
1 |
1 |
1 |
0 |
14 |
| no key |
1 |
1 |
1 |
1 |
15 |
It is recommended that you connect Bit 0 to HomeVision port A0, Bit
1 to A1, Bit 2 to A2, and Bit 3 to A3. In your schedule, when you
want to "press a key" you simply write one of the above
values, wait for a short period of time, then write either "1111"
or "0000" to effectively "lift up on the key".
Theory of Operation
This circuit works by using a CMOS analog switch to simulate the user
pressing the keys on the keypad. Keypads like this are designed in
a matrix configuration, rows and columns forming the keypad. The microprocessor
enables one row at a time by sending a '1' to one side of all the
keys on that row. The other side of all the switches in a column are
wired together to an input on the microprocessor. When you press a
key, it shorts the intersection of the row and column and the processor
detects this keypress as a pulse on the column input during the time
when the row is energised.
Here we use the CD4053 triple multiplexer (or switch) to provide the
switches. The CD4053 has an inhibit input which when '1' disables
all the switches in the device. Additionally, the CD4053 has one select
bit for each switch which will select either the '1' or '0' position
of the switch. In this circuit we only need SPST operation, so one
side of each switch is left open.
To control all the switches, we use a GAL16V8 PAL (programmable array
logic) device. This allows us to completely decode all the necessary
control signals in a single chip (and easily debug it when we get
it wrong). The PAL controls the Inhibit input of each CD4053. The
individual switch controls can be wired together and controlled in
concert. The inputs to the PAL are simply the 4-bit code from HomeVision.
The table above shows the input combinations chosen and the corresponding
keypresses. |
'
' HomeVision Pager Interface
'
' Basic Stamp Control Program
' by Erich Whitney
' HomeBrew Engineering
'
'
' Define constants
'
ROW1 CON 12
ROW2 CON 11
ROW3 CON 13
ROW4 CON 14
ROW5 CON 15
SELA CON 10
SELB CON 9
SELC CON 8
GOOD CON 7
BAD CON 6
RST_PORT CON %11111000
STRSZ CON 6
'
' Declare Variables
'
serData var byte(STRSZ) ' string of characters from HV
serByte var byte ' process each character
result var byte ' lookup result
i var nib ' loop variable
'
' Initialize variables and output ports
'
serData(STRSZ-1) = 0
' protect string from overrunning
OUTPUT SELC ' C
OUTPUT SELB ' B
OUTPUT SELA ' A
OUTPUT ROW2 ' ROW2
OUTPUT ROW1 ' ROW1
OUTPUT ROW3 ' ROW3
OUTPUT ROW4 ' ROW4
OUTPUT ROW5 ' ROW5
OUTPUT GOOD ' Good LED
OUTPUT BAD ' Bad LED
OUTH = RST_PORT
HIGH GOOD
HIGH BAD
'
' Main program loop
'
' Get a string from the serial port, no more than 5 characters
' long but optionally terminated with CR
'
' Foreach valid character in string
' Get the index of the character matched
' Branch to a routine to press that character
'
' Go back to the top
'
main:
debug cr,"CMD> "
SERIN 16, 16468, [STR serData\STRSZ-1\13]
FOR i = 0 TO STRSZ-2
serByte = serData(i)
IF serByte = 0 THEN again
result = "-" ' set result to a bogus key
LOOKDOWN serByte,["0123456789A*PC"], result BRANCH result,[l0,l1,l2,l3,l4,l5,l6,l7,l8,l9,la,ls,lp,lc]
'
' If we end up here, the character entered was not
' one in the above list so we indicate an error
' with the LED
'
LOW BAD ' Turn on BAD LED
PAUSE 250
HIGH BAD ' Turn off BAD LED
again:
NEXT GOTO main
'
' Process each valid key
'
' Each keypress needs to select A, B, or C
' and then enable the correct switch chip (row)
'
l0:
HIGH SELB
LOW ROW4
GOTO key
l1:
HIGH SELA
LOW ROW1
GOTO key
l2:
HIGH SELB
LOW ROW1
GOTO key
l3:
HIGH SELC
LOW ROW1
GOTO key
l4:
HIGH SELA
LOW ROW2
GOTO key
l5:
HIGH SELB
LOW ROW2
GOTO key
l6:
HIGH SELC
LOW ROW2
GOTO key
l7:
HIGH SELA
LOW ROW3
GOTO key
l8:
HIGH SELB
LOW ROW3
GOTO key
l9:
HIGH SELC
LOW ROW3
GOTO key
la:
HIGH SELA
LOW ROW4
GOTO key
ls:
HIGH SELC
LOW ROW4
GOTO key
lp:
HIGH SELB
LOW ROW5
GOTO key
lc:
HIGH SELC
LOW ROW5
GOTO key
'
' Go here after pressing a key to complete the cycle
' and release the key
'
key:
LOW GOOD
' Turn on GOOD LED
PAUSE 250 ' hold key down for 1/4 second
OUTH = RST_PORT ' reset all outputs
PAUSE 250 ' wait 1/4 second before next key
HIGH GOOD ' Turn off GOOD LED
GOTO again |
|
Here is the schematic
based on using the Parallax Basic Stamp II OEM module (BS2-OEM).
This module replaces the
GAL16V8 above and uses programmable I/O ports to control the CD4053
switches used in the original design. Next, it's just a matter of
programming. The BS2-OEM module has a built-in 9pin serial
port which you can plug into your PC for programming and into HomeVision
for operation.
As a general project, this is a really great example. The BS2-OEM
module kit is only $39 from Parallax and the remaining components
are pennies. Using a general-purpose programmable processor for
this type of interface greatly reduces the cost and development
time in designing such a project.
The Basic Stamp 2 BASIC
program is on the left. To operate the pager, you send ASCII characters
to the Basic Stamp and it will wiggle the wires to control the CMOS
switches for you. The program assumes 9600 baud, 8 bits, no parity.
Below is a table of the characters it understands. You can send
single characters followed by a carriage return or a string of 5
characters for one page command.
Examples:
C<return> Sends the CLR command
0015P Sends a 5 to pager 001, note return key not needed here
AAA2P Sends a 2 to all pagers
NOTE: This IS case sensitive. The GREEN LED will blink for each
valid character recieved. The RED LED will blink for each invalid
character received.
| Key |
ASCII Character to send |
| 1 |
1 |
| 2 |
2 |
| 3 |
3 |
| 4 |
4 |
| 5 |
5 |
| 6 |
6 |
| 7 |
7 |
| 8 |
8 |
| 9 |
9 |
| 0 |
0 |
| ALL |
A |
| * |
* |
| PAGE |
P |
| CLR |
C |
|