This is only a preview of the April 2004 issue of Silicon Chip. You can view 18 of the 96 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Items relevant to "Loudspeaker Level Meter For Home Theatre Systems":
Items relevant to "A Smart Mixture Display For Your Car":
Articles in this series:
Purchase a printed copy of this issue for $10.00. |
PC or PICAXE interface
for UHF remote control
For those wishing to experiment with home
automation or extensive remote control,
the popular PICAXE chips or a personal
computer can be interfaced with the 4-channel
transmitters and receivers from Oatley
Electronics, as featured in the June 2003 issue.
By JOHN HOLLIDAY
T
HE ORIGINAL Oatley Electronics
4-channel UHF transmitter board
had manual pushbuttons but these
can be omitted for computer control.
In fact, one transmitter can control
the four channels on up to 16 separate remote receivers – that’s up to 64
computer channels altogether!
This circuit concept uses the eight
data lines from a PICAXE18A or the
parallel printer port of any PC. Since
the PC situation is the more complex, I
will limit the article to describing how
to interface the parallel printer port of
a PC to the transmitter. I will assume
the reader is familiar with the article
in the June 2003 issue.
The circuit
The circuit uses a quad NAND
Schmitt trigger gate (74HC132) and
four PNP transistors (Q2-Q5) to replace
the four pushbuttons in the original
design. All lines from the computer’s
parallel port are connected via 470Ω
resistors and all have 22kΩ pull-down
resistors, to avoid damage to the NAND
package or to IC1.
Fig.1 shows how the four lowest
data lines (lower nibble) are used to
control the transmitter encoding pins
(1-4) of IC1. So instead of these pins
being permanently hard wired into a
fixed encoding pattern, they are now
under computer control. The remaining encoding pins of IC1, pins 5-8, are
left unconnected.
Because encoding pins 1-4 can be
either high or low, as determined by
D0-D3, up to 16 different combinations
are possible, so that the transmitter
can individually control up to 16
different receivers, each with its own
unique code.
Note that because the data lines can
only be high or low, the “open circuit”
condition of the transmitter security
encoding cannot be used in this circuit. This does result in less combinations being available but that does not
reduce the utility of the circuit.
Data on D0-D3 represents some
binary number, so if we output the
number 10 (1010 binary) using these
four data lines, this effectively encodes
transmitter pins 1-4 as LOW, HIGH,
Table 1: QBASIC Code
lowernibble = 12
'set variable “lowernibble” to required receiver code
channels = 14
'set variable “channels” to required channel combination
uppernibble = 16 * channels 'put channel combination into the upper nibble
outputdata = lowernibble + uppernibble 'combine the two nibbles
OUT 888,outputdata
'put the data on the data lines D0-D7 (LPT1)
Once you know what you are doing, the above lines can be condensed into one:
OUT 888,(12 +16*14)
www.siliconchip.com.au
The Oatley Electronics 4-channel UHF
transmitter board includes an SM5023
trinary encoder IC and a pre-built
UHF transmitter module (mounted on
the underside of the board).
LOW, HIGH. Therefore a receiver with
its corresponding decoding pins 1-4
hard-wired in the same pattern (LOW,
HIGH, LOW, HIGH) would accept
the transmission of data while other
receivers with different hard-wired
patterns would not.
From here on, I will identify a
receiver by the binary number (or
decimal equivalent) of the hard-wired
pattern of pins 1-4 on its decoding
chip, with pin 1 being the least significant bit. As with the transmitter,
pins 5-8 of the decoding chip are left
unconnected.
As noted above, the four pushbutton
switches on the transmitter (IC1) in the
original design have been replaced by
four BC558 transistors. Each transistor
and its associated 10kΩ base resistor
can be conveniently installed in the
four holes vacated by the pushbutton
switch. Each transistor is driven by a
NAND gate (74HC132) which in turn
is controlled by a data line from the
printer port. The four channels of the
transmitter are thus controlled by the
upper four data lines (upper nibble)
D4-D7.
If D4 is low, for example, the output
pin 3 on the 74HC132 is high and Q2
is therefore off. This corresponds to
channel A being off. If, on the other
hand, D4 is high, Q2 will be on, thus
turning channel A on. A similar situation holds for the other three channels
April 2004 75
Fig.1: the interface circuit uses a quad NAND Schmitt trigger (74HC132) and four PNP transistors (Q2-Q5) to replace
the four pushbuttons in the original design.
– they will be on if their data line is
high and off if their data line is low.
In a similar manner to the encoding
pins, the four channels can be turned
on in any combination by using the
appropriate binary number output on
data lines D4-D7. If, say, we output the
number 7 (0111 binary) to the upper
nibble, channels A, B and C would
be on, while channel D would be off.
As each individual channel is activated by its own data line, each channel can be thought of as the number
represented by that data line. So channel A alone is turned on by outputting
“1” (0001), B alone by “2” (0010), C
alone by “4” (0100) and D alone by “8”
(1000). That means that the channels
76 Silicon Chip
are individually represented by the
successive powers of 2.
If we wanted to turn on both B and
C but no other, we would output 6 (2
+ 4 = 0110). If we wanted all channels
on we would output 15 (1+2+4+8 =
1111), while outputting 0 would turn
all channels off. That is, to turn on a
combination of channels, we simply
add the numbers representing the
individual channels.
Software
Before exploring this issue, we
might now tackle the software problem of putting the correct data on the
correct data line. I will illustrate this
using QBASIC commands. First, de-
cide which receiver is to be addressed;
let us suppose it is the one coded 12.
This means the lower nibble needs to
be 12. Next, decide which channels
on receiver 12 need to be turned on;
channels B, C and D, say. This means
the upper nibble needs to be 14. The
printer port address is 888 (decimal).
The QBASIC code shown in Table 1
could be used.
One last word of warning. If you
write some software to control items in
the home, you need to think about the
consequences of what might happen if
some piece of equipment is turned on
when it is not supposed to be on. How
can this happen? Even if your software
is perfect, never allowing such terrible
www.siliconchip.com.au
things to happen while the software is
in control, the computer is not always
under software control. During the
boot up process (or an automatic reboot after a power supply failure), your
computer (including the printer ports)
is at the mercy of the BIOS, MSDOS
or perhaps Windows. The amount of
fiddling that can go on with the data
lines of the printer ports during the
boot up process is beyond belief.
With my computer, when booting
with MSDOS 6, no data lines on port
888 were set high, while with Windows 98, D3 was left high. This means
that the computer is quite safe to boot
using a QBASIC control program running under MSDOS. It is also safe to
operate under Windows 98, because
while D3 is high and could be a valid
www.siliconchip.com.au
receiver address, the upper nibble data
lines are always low, meaning no data
will be sent. This was the reason for
assigning the lower and upper nibbles
the way they were. You will have to
monitor the data lines of your own
system to see if there might be a safety
problem during the boot up process.
This is where the 74HC132 might
come in handy again. Instead of making pins 1, 4, 9 & 12 permanently
HIGH, they could instead be connected
to a control output which could be kept
LOW during the boot up process. The
control output would then be changed
to HIGH under software control.
Suitable control sources might be
found in the auxiliary output channel
890 or by using one of the data lines
D0-D7 which remain unaffected dur-
ing the boot up process.
As for using the PICAXE as a control
source, the 18A is ideal, having eight
dedicated output data lines. The 08
suffers from only having four output
pins. Here we could use two outputs
for addressing and two switching
channels. This would allow four receivers to be addressed but only two
channels on each could be switched.
The available outputs could also be
split in other combinations according
to your need.
So go ahead, the whole world of
home automation lies before you. SC
Footnote: further information on
parallel port interfacing and programming is available from www.lvr.com
and www.beyondlogic.org
April 2004 77
|