Us200002 PDF
Us200002 PDF
design by K. Schuster
PC interface for
Nintendo joystick
using the Nintendo 64 to run PC games
transmission time for each bit is 4µs in
both send and receive modes. A Low
bit is indicated by a 3-µs Low phase
followed by a 1-µs High phase, while
a High bit is indicated by a 1-µs Low
phase followed by a 3-µs High phase.
In order to delay the response to a
command, the last transferred bit of
the command can be held Low. If the
line is returned High at the end of the
command transmission, the response
should occur within 2 to 3 microsec-
onds. The response time is not fixed,
since the controller and the N64C2PC
IC operate asynchronously, each with
its own clock.
The first experimental circuit, with a
8051 clocked at 12 MHz (correspond-
ing to a 1 µs cycle time), was obviously
too slow to meet the critical timing
requirements of the Nintendo 64 con-
troller. Reliable communication was
only possible after the microprocessor
This circuit allows a Nintendo 64 con- stick module that works like a mouse. was replaced by an AT89C2051-24PC
troller to be connected to the PC game On demand, the controller unit reports with a 24-MHz clock. Regarding the
port (or a sound card), without requir- the status of the switches and the hardware, you can see that two clock
ing any additional drivers to be position of the joystick. Bidirectional sources are shown in Figure 1, in addi-
installed. The Nintendo 64 controller is communication takes place over a tion to the microcontroller and a pair of
a widely-used unit that combines high single line that has a High level in the current-limiting resistors. This is because
quality with a low price. With this rest state. This line is used both to send 24-MHz crystals are normally only avail-
approach, you can run PC games with commands to the controller and to able for series-resonant operation. Such
the comfortable Nintendo 64 controller receive the requested data from the ‘overtone’ crystals are not suitable for
instead of using the PC keyboard and controller. A command byte must be this application! If you cannot obtain a
mouse. sent before data can be received fundamental-frequency crystal, you
from the controller. If the line is free, as can use a self-contained 24-MHz oscil-
What the Nintendo 64 indicated by a persistent High level, lator (see the list of components).
controller offers… the command byte can be trans- Returning to the communications with
ferred. The controller responds to the the controller, the answer to the com-
In addition to a few membrane command $01 with the status infor- mand $01 is four bytes of controller sta-
switches, the controller contains a mation for all pushbuttons and the tus information, transmitted MSB first, as
precise analogue electro-optical joy- position of the analogue joystick. The shown in Table 1.
2k2
100µ 16V
tons simply make connections to earth. K1 4x 10k 100n 10µ
R1 5 4 3 2 16V
The PC game port, or a suitable sound 8 joyax
470Ω
card, simply polls the switch levels to 15
R2
20
joyay D1
see whether they are High or Low. 7
470Ω 1
14 RST
With the analogue joystick, the situation 6 joybx
R3 12
P1.0
470Ω
is a bit more complicated. The joystick 13
13
P1.1 P3.0
2
R4 14 IC1 3
contains two potentiometers (X and Y), 5 joyby
470Ω
P1.2 P3.1
15 6
P1.3 P3.2
whose resistances are around 100 kΩ, 12
R5 16 7
4 joyb2 P1.4 P3.3
connected to the supply voltage. 220Ω 17
P1.5 P3.4
8
11
Capacitors located on the card are 3 joyb1
R6 18
P1.6 P3.5
9
220Ω 19 AT89C2051
charged via these potentiometers. 10 P1.7
-24PC
R7 11
These capacitors determine the time 2 joya2
220Ω
P3.7
9 X1 X2 R9
constants of a pair of monostable mul- R8
joya1
10k
1 10 5 4
tivibrators. The positions of the poten- 220Ω
R10 = 2kΩ2
002007-1
1-700200
R11 = SIL-resistor array 4x10kΩ
R7
R2
R5
R4
R3
R1
R8
R6
002007-1
C5
Capacitors:
C1 = 10µF 16V radial
R11
C2
+ C2 = 100nF
IC1 C3,C4 = 27pF (*)
C5 = 100µF 16V radial
T
D1
Semiconductors:
XO1
R10
C1
F3
F4
006504-1)
Figure 2. The printed circuit board for the Nintendo-64/PC adapter. Miscellaneous:
K1 = 15-way sub-D plug fr board edge
mounting
X1 or XO1 = quartz crystal, 24MHz,
done this, the microcontroller sets the byte is read, precise bit synchronization fundametal resonance or 24MHz-
four potentiometer lines JOYAX/Y and is established, following which the Time- oscillator module (Seiko-Epson SG531P-
24MHz) (*)
JOYBX/Y Low and starts timers T0 and T1 out Mode of Timer 0 is again deacti-
for JOYAX/Y, since these are assigned to vated and the values that have just (*) = see text
the analogue joystick. The control cross been read in are interpreted in the rou-
or C button is assigned to JOYBX/Y. Ana- tine handlebuttons. This works accord-
logue values are also expected here, ing to the arrangement shown in
so the timing is handled by the routine Table 2. processor cycles, and the resulting
joybtiming, due to the lack of addi- Repeatedly pressing the L button data form the inputs for the next round,
tional timers in the microcontroller. With changes the advance rate of the con- which begins with the discharging of
the help of a few NOPs and nested trol cross up/down buttons or C button the capacitors.
loops, the game port receives what it in three steps.
expects here as well, and the JOYBX/Y Once the switch states have been eval- Playing around
lines are set high again after appropri- uated and their status has been passed
ate delays. The rate of advance in the on to the PC game port, the loop starts In order for the new joystick to be used
Y direction can be set to one of three from the beginning with the evaluation with the PC under Windows 95/98, it
different levels by simple ‘switch-on, of the analogue values that have been must be made known to the operating
switch-off’ logic. If the control cross or read in. The routine calctiming normal- system. You should find a joystick or
the C button is used during a game for izes and scales these values in terms of game controller icon under
forward or reverse motion, the L button
can be used to switch between ‘creep-
ing’, ‘walking’ and ‘running’. The duty
cycle range is thereby switched from its
default range of 58%–78% to either
48%–88% or 40%–97%.
After both software timers have timed
out, the program waits until the hard-
ware timers T0 and T1 have completed
their jobs and generated interrupts.
Once they have timed out, the JOYAX/Y
outputs are again set to High. Since the
program can easily get hung in the
subsequent time-critical portion, the
timer T0 interrupt is used as an ‘emer-
gency brake’ timeout in the routine Init-
tom. If the Nintendo 64 controller does
not respond within a predefined inter-
val, the program is restarted from the
beginning. The routine sendbyteA
sends the command $01 (Status Infor-
mation), and the following routine get-
bytes reads the four status bytes from
the Nintendo 64 controller. Bytes 1
through 4 land in registers R4 through
R7 for further processing. Before each Figure 3. How to prevent an incorrect connection.
running
Transmitter ra atrix elements
nge:
approximatel
Operating vo y 10 m
ltage: 12 V (tr
ansmitter and
receiver)
text display
controlled by a COP-8 microcontroller
100k
3
5
Resistors: KEYBOARD
IC3
2 DATA
16
R1 = 10Ω DIN 5 RESET
rear view 4
R2 = 100kΩ 1 IC1 L0
7
CLK 17
G0/INT JP1 ZSM560
8
R3 = 470Ω 18 L1
R4 = 1MΩ
GND
19
G1
G2
L2
9
*
10
L3
COP8782 11 9V
5 6 1 DATA 1 L4
Capacitors: G4/SO 12
KEYBOARD 3 4 3 GND 2 L5
C1,C2 = 33pF PS-2
G5/SK 13 D1
4 +5V 3 L6
C3 = 100nF rear view G6/SI
L7
14
1 2 5 CLK
TSUS
C4 = 220µF 16V 20 5201
G3/T10
IC2 R3 R1
G7/CKO CKI
Semiconductors:
470Ω
9V 7805 5V
10Ω
4 R4 5 15
D1 = TSUB8201 1M
T1 = ZTX603 T1
start bit 6 ms H, data bit "1" data bit "0" stop bit
6 ms L 2 ms H, 4 ms L 2 ms H, 1 ms L 2 ms H 990090 - 13
Figure 2. Timing diagram of the transmitter signal that modulates the 36-kHz carrier (this example is for the code 88 H).
100k
100Ω
T1 6
R10 IC27
100n
750Ω 16 17 5V
T2 RESET G0/INT
R2 R11 IC34
47Ω 750Ω ZSM560 IC33 2
T3 7
IC26
R3 R12 L0
8 14 1 8 3
47Ω 750Ω L1 L7 CS
T4 9 2 2 7 C5
R5 R13 L2 G5/SK SK X
10 1 3 6
47Ω 750Ω L3 G4/SO DI X 1
T5 11 3 10µ
4 5 TFMS5360
R6 R14 L4 G6/SI DO
12 COP8782C
47Ω 750Ω L5
T6 13
R1 R15 L6 93C66CB1
20
47Ω 750Ω G3/T10
T7 19 18
R7 R16 G2 G1 IC35
47Ω 750Ω G7/CKO CKI
7805 5V
R4 4 5 15
R8 B1
47Ω
1M
8x BC557
C6 C7
C1 C2
1A
X1
2000µ 2000µ
33p 10MHz 33p
5V 5V 5V 5V 5V
1 2 8 9 1 2 8 9 1 2 8 9 1 2 8 9 1 2 8 9
A B CLK CLR A B CLK CLR A B CLK CLR A B CLK CLR A B CLK CLR
14 14 14 14 14
IC21 IC22 IC23 IC24 IC25
74164 7 74164 7 74164 7 74164 7 74164 7
QA
QB
QC
QD
QE
QG
QH
QA
QB
QC
QD
QE
QG
QH
QA
QB
QC
QD
QE
QG
QH
QA
QB
QC
QD
QE
QG
QH
QA
QB
QC
QD
QE
QG
QH
QF
QF
QF
QF
QF
3 4 5 6 10 11 12 13 3 4 5 6 10 11 12 13 3 4 5 6 10 11 12 13 3 4 5 6 10 11 12 13 3 4 5 6 10 11 12 13
1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
I1 I2 I3 I4 I5 I6 I7 I8 I1 I2 I3 I4 I5 I6 I7 I8 I1 I2 I3 I4 I5 I6 I7 I8 I1 I2 I3 I4 I5 I6 I7 I8 I1 I2 I3 I4 I5 I6 I7 I8
10 10 10 10 10
IC28 IC29 IC30 IC31 IC32
ULN2803 9 ULN2803 9 ULN2803 9 ULN2803 9 ULN2803 9
O1 O2 O3 O4 O5 O6 O7 O8 O1 O2 O3 O4 O5 O6 O7 O8 O1 O2 O3 O4 O5 O6 O7 O8 O1 O2 O3 O4 O5 O6 O7 O8 O1 O2 O3 O4 O5 O6 O7 O8
18 17 16 15 14 13 12 11 18 17 16 15 14 13 12 11 18 17 16 15 14 13 12 11 18 17 16 15 14 13 12 11 18 17 16 15 14 13 12 11
Figure 3. Circuit diagram of the receiver and seven-position LED display matrix.
nity. One start bit, eight data bits, one resulting short ‘on’ times, prevent the
parity bit and one stop bit are transmit- transistor from becoming overheated.
ted. The microcontroller is clocked at The reset IC (IC3) ensures that the
the relatively high rate of 10 MHz. This microcontroller always starts up prop- pin L6
enables it to correctly decode the ser- erly. The current consumption of the
ial data stream from the keyboard, and transmitter, including the connected pin L5
to generate the 36 kHz carrier fre- keyboard, is around 110mA. Since it is pin L4
quency for the infrared diode, using used only infrequently, it can be pow-
only software. ered from a 9 V battery, although a pin L3
Figure 2 shows the timing diagram mains adapter can also be used.
of a sample character (with the code pin L2
88H) before modulation. The infrared The receiver pin L1
diode D1 is driven by the Darlington
transistor T1. In order to give the trans- The transmitted information is demodu- pin L0
mitter a wide range, the value of the lated by the infrared receiver IC4,
42h
41h
49h
49h
66h
byte generator
for testing DACs and digital controls
R1 8x 4k7 1
K2 K3
K1
2 3 4 5 6 7 8 9
1 10 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10 11
2 IC1
3 19
G3
4 K4
3EN1 3
5 1
3EN2 2
6
1
7
1 10
8
9 2 18 1 +VS 18
2 I1 O1
10 3 17 2 17
I2 O2
11 4 16 3 16
I3 O3
12 5 15 4 15
I4 O4
13 6 14 5 IC2 14
I5 O5
14 7 13 6
I6 ULN O6
13
15 8 12 7 2801A 12
I7 O7
16 9 11 8 11
I8 O8
17 VEE
18 74LS245 9
19 16 15 14 13 12 11 10 9
20 D1 D2 D3 D4 D5 D6 D7 D8
SW1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8
1
R2 8x 470Ω 002005 - 11
In the circuit diagram, Figure 1, SW1 is IC2. IC2 is a ULN2801A, which is an diodes are commoned together on pin
a 16-pin 8-way DIL switch and is fitted octal Darlington driver chip with open 10 of IC2 and should be connected to
into a 16 way DIL socket (more about collector outputs. The outputs of IC2 are the voltage supply of the load. This will
this later). The common side of the available on K3. ‘shunt’ any inductive kicks created by
switch is grounded and the switched Operation of SW1 will result in a TTL out- switching the load, back into the load’s
side is pulled up to +5V via a 4.7 kΩ SIL put on K2, or an open collector output power supply away from the circuit
resistor network (R1). This is then con- on K3. As can be seen from Table 1, itself.
nected to K1 (which is a doubled up the pin-out for K2 and K3 are virtually The circuit can be powered via pins 1
10-way SIL header or 20-way IDC the same with the exception of the (+5 V) and 2 (0 V) of K2 or K3 and pin
header), and from there to the inputs of extra terminal (pin 11) on K3. The 11 of K3 as required, depending upon
IC1, a 74LS245 which is configured as ULN2801A (IC2) incorporates internal the application.
a buffer. The outputs of IC1 are con- protection diodes for driving inductive The main circuit also includes a simple
nected to both K2 and the inputs of loads — like relays. These internal logic indicator. If the circuit to be mon-
1N4148 5
between pins 2 & 3 for +5 V operation, 16 6
and between pins 1 & 2 for an external 9 7
0
voltage source. CTR12 1
7 8
11 6 9
CT=0 2
5 10
Extensions 3
3 11
IC1 4
C2 2 12
5
With a simple extension, this circuit can CT 4 13
6
100n 74
be modified to include an external HCT 7
13 14
4k7
clock source, rather than manually.
The external clock source is connected
to the main board via a 20-way ribbon 002005 - 12
By F. Wohlrabe
PC keyboard encoding
Everything you ever wanted to know about
the signals from a PC keyboard…
In addition to the ready availability, low ideal complement to a microcontroller Key codes
cost and accustomed manner of use project. Of course, the manner in which The most widely-used type of keyboard
of a PC keyboard, connecting a PC the signal from the PC keyboard is con- is the MF2 model (‘multi-functional ver-
keyboard directly to a microcontroller structed has a few special features. sion 2’). It was originally developed by
system has the advantage that it Two lines are used for the serial data IBM for computers in the XT, AT and PS/2
makes valuable port pins available that transfer. One of these, labelled data, series. This model has become an
otherwise would be used for polling a transfers the data, while the second industry standard in the meantime, and
keyboard built from individual compo- one transfers the clock. The serial data almost all PCs are equipped with it. The
nents. A PC keyboard, by contrast, pro- transfer protocol, which is fairly com- keyboard itself contains a ‘keyboard
duces a serial signal, and is thus an plex, is explained below. controller’, which generates the key
Programming example 1 Pull the data line to earth. 8 The keyboard sends the code 34H.
In conclusion, the manner in which a 2 Send the command code F0H, syn- A practical application example of the
(microcontroller) system should address chronous to the clock. use of a PC keyboard with a microcon-
an AT keyboard can be illustrated with 3 The keyboard sends the code FAH troller system is “Text Running Line Dis-
a simple programming example. (ACK) as confirmation. play” elsewhere in this Supplement. In
When the 5-V supply voltage is 4 Pull the data line to earth. this example, a common or variety PC
switched on, +5 V is applied to the key- 5 Send the command code 03H, syn- keyboard is used for entering text to be
board. The keyboard controller in the chronous to the clock. displayed on an LED running-line dis-
keyboard then executes a self-test. If 6 The keyboard sends the code FAH play. Keyboard decoding is handled
this is completed successfully, the key- (ACK) as confirmation. by a COP-8 microcontroller, and the
board sends the byte AAH. data transfer to the running-line display
Now a key can be pressed, and the uses an infrared link. The photo at the
Next comes the selection of the scan key code from the scan code 3 set head of this article shows a small circuit
code set. In this example, scan code (see Table 1) will be received: board holding the keyboard decoder
set 3 is selected using the SCAN CODES and IR transmitter.
SELECT command, as follows: 7 Press ‘G’ on the keyboard. (002008-1)
2-metre band
converter
capture 144 MHz DX signals
If you have a gen-
eral coverage
shortwave receiver
available and
would like to
extend its fre-
quency range with
the two-metre
amateur radio
band, the present
design is for you.
Easy to build from
low-cost parts, the
converter should
make an excellent
entry-level project
for budding radio
enthusiasts. The
converter is also a
prefect companion
to the general-cov-
erage multi-mode SW The 2-metre radio amateur band is still m band is also the place to be for
the most popular band worldwide. It mobile and portable communication,
receiver described last extends from 144 to 146 MHz in most witness the presence of amateur-built
year in this magazine. European countries, and from 144 to and operated repeater stations in many
148 MHz is some other countries like countries and areas.
the U.S.A. and Australia. Traditionally, The lower part of the 2-metre
the band is associated with short-range band is reserved for narrow-band
communication over distances of up to modes like CW (Morse) and SSB (sin-
50 miles or so using narrow-band fre- gle-sideband). Mainly because of the
quency modulation (NBFM) and smaller bandwidth and resultant bet-
power levels up to about 50 watts. This ter signal-to-noise ratio for weak sig-
is also called ‘local traffic’ by some nals, these modes offer far greater
radio amateurs. Thanks to the rela- ranges than NBFM. The ‘sound’ of
tively short antenna lengths and gen- the band section between say
eral profusion of cheap Japanese high- 144.000 MHz and 144.400 MHz is
Design by G. Baars tech rigs and converted PMR kit, the 2- therefore not unlike that of a short-
150k
180k
9V0
9V2
Many beginners to the radio hobby
start will start out with a second-hand
* see text C3
BF494
10p
BF494 100mV t t
2k2
between 150 kHz and 30 MHz. The 27p 15p 40p 22p 22p
560Ω
E
100k
2k2
150k
56Ω
all-mode VHF transceiver, so
100n 100n 100n
why not add 2-metre band BF961
reception to the available short- G2
0µH56
7V8 C19
8V9
wave receiver? With some luck,
G1 9V
this has an NBFM mode, too, so R4 T5 1n
D C18
you can also listen to ‘local’ traf- 150k C13
2V9 50Ω
fic and get to know the hams in S
4p7 10p
T3 T4
your area. C12 0V BFR91
3V4
It should be noted that recep-
2V7
tion of DX (long-distance) sig-
*
L5 *
L6 10p
0V6
(3)
BFR91 BF961
nals in the 2-metre band C10 C11
0V7 L7
C14 R6 R8 C16
P1
requires a good directional 50Ω * C15 C17
47k
1k
(2)
antenna with a gain of at least 22p 22p 22p 1n 40p 22p
10 dB and low-loss coax cable to 1k
T1 H6
X1
and component mounting
H1
H2
L4
R1
L3 plan of the single-sided PCB.
C2 C4 T2 0
C1 C8 Three transistors are
mounted at the solder side!
L1
1-310000 R2 L2 R3 +9..12V
ROTKELE )C(
C6 C21
C9 C22
T C24 C25
C10 C20
C23
R7
R10
R11
T
R4 R5 R9 COMPONENTS LIST
L5 R6 C19
C13 T4 L8
C18 Resistors:
L7
C12 R1,R4,R10 = 150kΩ
T3 C15 C17 T5
R2,R9 = 2kΩ2
L6 000013-1
R3 = 180kΩ
R8 R5 = 560Ω
H3
H4 H5 H8
C14
C11 C16 P1 R6 = 47kΩ
R7 = 100kΩ
R8 = 1kΩ
R11 = 56Ω
P1 = 1kΩ preset H
Capacitors:
C1,C7,C8,C10,C11,C14 = 22pF
000013-1 trimmer
(C) ELEKTOR C2 = 27pF
C3,C6,C9,C12,C18 = 10pF
C4 = 15pF
C5,C16 = 40pF trimmer
C13 = 4pF7
C15,C19 = 1nF, raster 5mm
C17 = 22pF
C20,C22-C25 = 100nF ceramic
C21 = 10µF 63V radial
Inductors:
L1 = 0.22µH miniature choke
L2 = 0.33µH miniature choke
L3-L7 = 5 turns silver-plated wire,
dia. 0.8mm (SWG20), internal
diameter 4.5mm, length 10mm
Distance between coupled inductors:
1mm, tap at 2 turns from ground
side
L8 = 0.56µH miniature choke
Semiconductors:
T1,T2 = BF494
T3,T5 = BFR91
T4 = BF961
Miscellaneous:
X1 = quartz crystal 38.667MHz (3rd
overtone) (Mainline, tel. 0870
2410810)
PCB, order code 000013-1 (see
Readers Services page)
Case: e.g. Hammond 1590B
56×107×25 (inside dimensions)
and wind 5 turns of SWG20 (approx. circuit that works spot-on. Hammond. The converter RF input
0.8 mm dia.) silver-plated wire around To keep parasitic capacitance as and output may be BNC or SO239
it. Then stretch the turns evenly until small as possible, the BFR91 and BF961 style sockets, depending on what you
the coil has a length of about 10 mm. transistors are fitted at the solder side have available. The connections
Only on L5 you ‘tap’ the inductor at 2 of the board. This is indicated by their between the sockets and the relevant
turns from the side you want to con- dashed outlines on the component PCB pins should be made in coax
nect to ground (look at the component overlay. Look very carefully at the ori- cable, for example, RG174 or RG58.
overlay). The tap is made by means of a entation aids on these transistors to
small piece of bare wire. Make sure it make sure they are mounted the right AN ADJUSTMENT TOOL
does not short-circuit the adjacent way around. On the BFR91, the collec- We are sure that the simple RF probe
turns! Coupled inductors L5-L6 and tor is the longest pin; on the BF961, the shown in Figure 3 will pay dividends
L3-L4 should be spaced 1 mm apart. source has a small tab and the drain is in adjusting RF circuits. Build it and
Next, fit all the parts on to the the longest pin. you will wonder how you ever did
board, except transistors T3, T4 and T5. The completed board has to be fit- without it.
Remember, careful and accurate sol- ted in a metal case. For our prototype, The probe consists of an aluminium
dering work will be rewarded with a we used a small diecast case from pen case (a felt pen, cleaned out, of
1. Put the probe tip on the hot side of 145.2000 – 145.5875 MHz
C5 and adjust this trimmer for max- Simplex channels, FM, 12.5kHz raster.
imum reading on the voltmeter.
2. Connect the probe to about 1 turn 145.6000 – 145.7875 MHz
from the cold side of L3 and peak Repeater output frequencies (12.5 kHz, shift 600 kHz)
C7. You want the first peak starting
from fully meshed. If not, you tune 145.8000 – 146.0000 MHz
to fosc × 4 instead of fosc × 3. Satellite services
3. Connect the probe to 1 turn from
The MZ-R30 MD
recorder comes
with its own
cable-operated
remote control,
which is primar-
ily designed for
Walkman-ish operation. However, Brian Rather than starting straightaway with
the technical description of the project
Houghton’s own application for recording it may be interesting to tell you some of
the design history.
choral rehearsals needed to have a means of I found the website “The Minidisk
controlling the stop/start function from a loca- Community Pages” on http://www.amu-
lation.com/minidisc very helpful with
tion that made cable control impossible. Here’s information on how the Sony MZ-R30
remote functions are controlled by dif-
how Brian solved the problem — elegantly and ferent resistance values across a pair of
without breaking the bank. wires.
Initially a 173-MHz licence-free
“HomeCall “type transmitter and a
suitable receiver was obtained, and the
receiver mounted in a control box with
Design by Brian Houghton G4BCO some CMOS logic. This RF system
“pause”. The details of this remote con- 4 red Left Channel Mini
5 brn Common Socket
trol can be found on :
http://www.amulation.com/minidisc/mzr30_ 2
MD
remote_radio/index.html.
Several emails from people regard-
2 3
ing that design, were received and one XLR Free
990075 - 11
in particular from someone who Plug (Rear) 1 5 4
wanted some help with a college pro-
ject to build a full function IR remote
control within a budget of £50. This Figure 2. The remote pod
spurred the author to have a go. this magazine. can still be used if you function is shown in
Any button press give it a connector again. tabular form in the
DESIGN will place 0 volts on circuit diagram. Note
This design logically splits into two the selected diode(s) that pushbuttons S10
parts: to pull down the data inputs of the and S11 have to be pressed simultane-
encoder IC1. Any data input going low ously to transmit a RECORD com-
➧ The hand held transmitter contain- will ‘wake up’ the encoder chip, start mand. This is done to prevent inad-
ing the function select push button the 455 kHz oscillator and the encoded vertent selection of the RECORD
switches, encoder and infrared trans- data stream will be output from pin 17 mode.
mitter. (Dout) driving the two transistors and
subsequently the two infrared sender RECEIVER/DECODER
➧ The receiver/decoder containing the diodes. A low value series resistor UNIT
infrared receiver, decoder and resis- (2.2 Ω) enables the IR diodes to be dri- The Sony MZ-R30 requires a number
tance ladder selector analogue ven with high current pulses, although of specific resistance values to recog-
switches. the average current is only 10 mA per nize certain functions selected via its
transistor. The large electrolytic capaci- remote input socket: The resistance
The remote control connector on the tor C1 is essential to overcome the rel- values and associated functions are
Sony MD Walkman is unique and atively high internal resistance of the shown in Table 1. The code in the third
unfortunately is not obtainable as a two AA or AAA batteries. row is the decimal value of the 4-bit
spare item, and since the whole remote The relation between pushbutton data used by the IR encoder/decoders.
cable is £50 to purchase separately, it number, transmitted The use of type
was decided to perform minor surgery code and the associ- Figure 3. Circuit diagram 4016 analogue
on the existing cable. ated MD recorder of the hand held control. switches (IC3, IC5,
2Ω2
"0" Spare
The remote control pod was opened C1 C4
"1" Prev/Back
D26 D27
and the existing cable disconnected. A "2" Next/FWD
3V
100µ 100n
D26, D27 = LD271 "3" PAUSE
mini XLR 5-way socket was fitted to 16V T1 "4" STOP
R2
the free end of the old cable. This cable 10k "5" Volume –
is then suitable to connect the IR Con- R1
T2 "6" Volume +
trol Unit to the Sony Walkman. The 10k "7" MARK (Rec)
"8" MODE (Play)
modification is illustrated in Figure 1. 18 2x "9" RECORD
A new cable was made up using 5 1
A0 ADOUT
17 BC550 (in stop or pause)
2k2
R5
C1 C2
2k2
6
D3
2µ2 4µ7 IC3d 9
25V 16V
D1 8
6
T2
R4 8
5V 4k7 R18 R19
100Ω
5k6
4k7
C3 R20
4 100n
BC547
IC6c 10
JP2
18 R17
12
2k
1 17 TEST
A0 ADOUT
2
A1 X/Y 5 IC6d 9 11
3 14 9
A2 IC1 TE 9 6
4 8 R16
JP2
2k
A3 4
5 13 11 7
A4 HT12D D3 8 7
IC6b 3
6 12 12 4 6 8
A5 D2 IC2 6 5
7 11 13 2 5
A6 D1 1 IC5a 2
8 10 10 4028 4 R15
1
1k5
A7 D0 15 4 XLR-Socket
3 13
OSC2 OSC1 2 2
K2 3
2
9 15 16 14
R1 1 1
3 IC3c 10
56k 0 R14 R13
150Ω
1k5
12 1 4
5
5V
R2
IC6a 2 11
10k
R11 R12
13
56Ω
1k8
JP1
T1 1
R3
P1 CV
10k R7 R8
K3
27Ω
1k5
R9 16 C6 14 C7 14 C7 14
1k3
680Ω
1k3
4 11 4
990075 - 14
JP2
R8 R9 R7 R14
H1
H2
test
(Board section 990075a) R10 R17 R16 R15
T2
R11
R4
R21
R1 = 56kΩ
R20
D1
IC3
IC6
IC5
R6
IC2
R2,R3 = 10kΩ
R4,R20 = 4kΩ7
R5
R5,R6 = 2kΩ2 IC4
R7 = 27Ω C5 C4 T
0
+
C7 C6
R8,R13,R15 = 1kΩ5 R1 R2
P1
+
R9,R10 = 1kΩ3
R3
R11 = 56Ω IC1 T1 JP1
C2
C1
+
H3
H4
R12 = 1kΩ8
V2
C3 D2
R14 = 150Ω
R16,R17 = 2kΩ
R18 = 100Ω
R19 = 5kΩ6
R21 = 680Ω
P1 = 1kΩ preset H
Capacitors:
Semiconductors:
D1,D3 = low-current LED
D2 = 1N4001
T1,T2 = BC550
IC1 = HT12D (Holtek) (Maplin)
IC2 = 4028
IC3,IC5,IC6 = 4016
IC4 = LP2950-CZ5.0
Miscellaneous:
JP1 = SFH506-36 S11 S6 S7 S5 S4
H4
H1
D24
Transmitter
D14
D12
D15
D17
D19
D11
D13
R3
R4
990075b
D25
D18
D16
D26
C4
Resistors: C3
D2
ROTKELE )C(
R1,R2 = 10kΩ D3
+
R5 IC1 D9
R2
R3,R4 = 2Ω2
D27
D10
-
C2
T1
R5 = 10MΩ D4
X1
D23
b570099
T2
Capacitors:
D22
D21
D20
D6
D5
R1
D8
C2,C3 = 100pF
H2
H3
C4 = 100nF
S1
S10 S9 S8 S2 S3
Semiconductors:
D1-D25 = 1N4148
D26,D27 = LD271 or similar IR LED
T1,T2 = BC550
IC1 = HT12A (Holtek) (Maplin,
Farnell)
Miscellaneous:
990075b (C) ELEKTOR
CONSTRUCTION
The printed circuit board you will need
to build this project is shown in Fig-
ure 5. The first thing to do is separate
the receiver and transmitter sections
with a jigsaw.
To keep cost as low as possible,
these are single-sided circuit boards.
They contain a few wire links which
should be fitted before anything else.
The PCBs are easily stuffed using
the parts list and the component over-
lay. Be sure to fit all polarized compo-
nents the right way around, that is,
diodes, LEDs, transistors, electrolytic
capacitors and ICs. Although they are
neither expensive nor hard to get
(Maplin), the HT12 ICs are best fitted
in IC sockets.
The transmitter board has a number
of diodes fitted at the solder side of the
board. The IR sender diodes may be
fitted with reflector caps to boost their
directivity.
The author fitted his version of the
handheld control in a type HH1 plain
box from Maplin. This had enough
appears elsewhere in this issue. in the circuit diagram. Alternatively, space to incorporate a holder for two
A common analogue switch (IC3a) you may want to use a mini XLR chas- alkaline rechargeable AAA cells.
controlled from the IR decoder (VT) sis plug. The pinout is then as follows:
pin is used to gate the output, since the
4-bit data is latched by the decoder and Pin 1: audio left SETTING UP
always selects the last switch that was Pin 2: pin 1 of IC3a The only setting up required is to
used. The minimum selectable resis- Pin 3: preset P1 adjust the 1 kΩ preset to compensate
tance (function “Preview/Back”) is Pin 4: audio right for the resistance of the analogue
1000 Ω and to achieve this, a 1kΩ pre- Pin 5: audio common switches. This is done as follows:
set potentiometer, P1, is used to add
approximately 700Ω in series with the Alternatives to the IS1U60 include the a) Install jumper JP2. This links R20,
300Ω total resistance of the two ana- Siemens SFH505A and SFH506. Their the 4.7 kΩ resistor from the com-
logue switches. A bright LED, D1, is pin functions being different from the mon rail of the network, to 0 V.
also switched on at the same time to IS1U60, you have to pay attention to b) Connect a DMM on a suitable resis-
indicate correct operation. the way they are connected to the tance range to be able to measure
The resistance value associated with board. 7,050 Ω, across the output pins 2
a control code appears across JP2, the The output of the remote control and 3 on the XLR connector.
output of the circuit. A suggested con- receiver is wired to a suitable miniature c) Power up the receiver/decoder and
nection to a mini-DIN socket is shown socket which is then connected to the select code 4 “Stop” on the remote
hand held control.
d) Adjust preset P1 to give 7,050 Ω on
the DVM.
e) Remove power, pull JP2 and dis-
Table 1. MiniDisc Walkman remote control codes connect the DVM.
f) Connect the receiver/decoder to the
Function: Resistance: Code:
MZ-R30 and test all functions.
Preview/Back 1,000 Ω 1
Next/Forward 3,627 Ω 2 (990050-1)
Pause 5,156 Ω 3
Stop 7,050 Ω 4 Design editing: L. Lemmens
Volume (–) 8,400 Ω 5 Article editing: J. Buiting
Volume (+) 9,900 Ω 6
Mark 11,900 Ω 7
Mode 14,000 Ω 8
Record 19,500 Ω 9
Using a key-
board and
mouse to
operate the
innumerable
knobs and slid-
ers of a PC mix-
ing board can turn
playing around with a
sound synthesizer
into an agonizing
experience. With the
Almost every PC these days has a makes working with a software syn-
MIDI parameter box sound card. However, most PC users thesizer considerably easier. It utilises
it’s a different story! employ it only to reproduce operating the ability of a software synthesizer to
system sounds, music from audio CDs receive MIDI codes and to use these
and sound effects for games and pre- codes to drive certain controllers. The
sentations. They thus use only the hardware of the MIDI parameter box
standard features of the software for can thus be kept very simple. A micro-
the sound card, even though there are controller reads the positions of eight
outstanding programs available that standard potentiometers in turn, via an
allow even non-musicians to exploit 8-channel A/D converter. If one or more
the manifold features of modern of the potentiometer positions is
sound cards. These are sound synthe- changed, the microcontroller sends this
sizer programs. information in MIDI format to the
Such synthesizers are sometimes MIDI input of the sound card. The soft-
even included in the software pack- ware synthesizer translates the MIDI
ages that come with the better quality codes into new settings for the con-
sound cards. However, there are also troller in question.
separate programs, such as Generator
from Native Instruments or Rebirth LAYERS
from Propellerhead. These programs AND SUPER-LAYERS
simulate the functions and operations The somewhat nebulous term ‘layer ’
of a real synthesizer using a screen full often crops up in connection with
of sliders and knobs that are controlled MIDI. Layers are actually nothing more
by the mouse. They represent a sort of than groups of eight synthesizer func-
Gordian knot for anyone who wants to tions, which correspond to the eight
do more than adjust a single slider. potentiometers of the MIDI parameter
Design by T. Klose The circuit described in this article box using a sort of multiple allocation.
10Ω
10k
1k5
CV
R16
R15
R14
R13
P9
470Ω C14 K9
10k
10k
10k
10k
C10 C9
D1
100n
1k
R2
100n 10µ 14 K5
63V
20 INIT
4 6 VALUE
MCLR RB0
10 7
K3 SHDN RB1
15 17 8
DOUT RA0 IC2 RB2
1 IC1 16 18 9
CH0 SSTRB RA1 RB3
2 17 1 10
CH1 DIN RA2 RB4
3
CH2 CS
18 2 PIC16F84 RB5 11
RA3
R12
R11
R10
4 19 3 -10/P 12
R9
CH3 SCLK RA4 RB6
5 13
CH4 RB7
10k
10k
10k
10k
6 MAX186 K10
CH5 OSC1 OSC2
7 11
CH6 VREF 16 15 5
8 12 X1
CH7 REFADJ 5V
AGND VSS DGND 5V
C8 C7 C6 C5 C4 C3 C2 C1 13 9 14 C11 C12 C13 C15 C16 R8
1k5
100n 100n 10µ 33p 10MHz 33p
63V
8x 100n R7 R6 R5
220Ω
220Ω
IC3
10k
D3
K6 D2 T1
12V 1N4001 7805 5V
S9 ... S12
K9
K7 *
1 8
K4 MIDI
2 DATA BC547B 15
C17 C18 C19 3 4 K1 1 2 3 4
7
8 14
10µ 100n 10µ
6
63V 63V
K2 3 5 13
MIDI CHANNEL
K5 * 2 5
K10 12
4
K3 K6 1 4
11
3
P1...P8 = 8x 47k 10
2
+5V 9
1
P1 P2 P3 P4 P5 P6 P7 P8
S1 S2 S3 S4 S5 S6 S7 S8
* see text
* zie tekst
1 2 3 4 5 6 * siehe Text
CV CV CV CV CV CV CV CV
MEMORY RESET * voir texte
1 2 3 4 5 6 7 8 LAYER
990087 - 11
The parameter box has pushbutton number of Elektor projects, has an part of the AWE-64 package, for
switches that can select one of six lay- interface to the microcontroller (IC2). instance, but it cannot be ordered sep-
ers. The MIDI codes sent by each This interface carries the output data arately. You can either buy one for
potentiometer (or the controller) thus from the D/A converter (DOUT) and around £15 in a computer shop or copy
vary according to the layer that is the clock (SCLK), as well as the settings one of the numerous Elektor designs
selected. for the multiplexer (DIN). The con- (such as the MIDI interface in the 1995
The assignment of layers to specific verter is controlled via the SSRB and Summer Circuits issue). A less elegant
functions is not the same for all con- CS leads, synchronous to SCLK. option, but one that can conceivably be
trollers. Instead, controllers can be The microcontroller is a type used if no other MIDI devices are con-
divided into different groups. The var- PIC16F84 IC that is clocked at 10 MHz. nected, is to connect the MIDI para-
ious types of assignments are referred In addition to the potentiometer posi- meter box directly to the 15-pin joystick
to as super-layers. The MIDI parame- tions, it also reads the layer selection interface, which also has a MIDI input.
ter box knows the three most com- switches (S1–S6), the MIDI channel The 220Ω resistor in the data line pro-
monly used groups and adapts the switches ((S9–S12) and two other push- tects against short circuits if this alter-
MIDI codes to their specific needs. button switches, MEMO and RESET. native is used. This type of connection
Table 1 summarises the contents of the Table 2 describes the meanings and has one advantage, which is that the
six layers within the three super-layers. uses of all of the switches. operating power can be drawn from
MIDI communication with the the joystick port, so that D3, C17, C18
HARDWARE sound card takes place via port lead and IC3 are not needed.
The most important elements of the RB7. The MIDI signal can be visually This brings us to the power supply.
hardware, which have already been checked via the (blinking) LED D2. An external power supply is obligatory
mentioned, can easily be recognised in There is a good reason why two con- with ‘real’ MIDI interfaces, in order to
the schematic diagram shown in Fig- nection options are shown in the ensure the electrical isolation of the PC
ure 1. The eight potentiometers are drawing. Actually, the MIDI parameter and the MIDI equipment. Only capac-
connected to channels 0 through 7 of box should only be connected to the itors C17 through C19 and the voltage
the A/D converter IC1. The MAX186 sound card via a true, optically isolated regulator IC3 are needed to provide a
IC, which has already been used in a MIDI interface. Such an interface is sufficiently stable +5 V. Power can be
provided by a simple 12 V mains board that is the size of a pack of ciga- LEDs and the ICs, and don’t forget the
adapter. Diode D2 provides protection rettes, as shown in Figure 2. It is avail- wire bridge next to K5. After this you
against a reverse-polarity connection. able from Readers Services (order can prepare the control panel. The
number 990087-1). You shouldn’t expe- potentiometers and switches can be
AS SMALL AS POSSIBLE rience any problems mounting all the glued to the front panel in a reasonable
To make the construction of the MIDI components, which takes around half arrangement, such as that shown in
parameter box as convenient as possi- an hour. Pay attention to the orienta- Figure 3, and wired using flatcable.
ble, we have designed a printed circuit tion of the electrolytic capacitors, the You can also mount these components
Blinks after the power is switched on to indicate that one of the three
LED D1 Init Value super-layers must be selected using switches S1 – S3.
Illuminated when the initial value is set for the potentiometer that was last rotated.
Switches S1 – S4 MIDI-Channel These four binary-coded switches select the MIDI channel.
Potentiometers P1 – P8 Fader These potentiometers are used to set the MIDI values.
Pushbutton S7 Memo Save the last modified value in the current layer.
Pushbutton S8 Reset Overwrite the current value with the predefined initialization value.
H1
H2
R3
R4
Resistors: C10 X1 R1 K1
R1,R8 = 1kΩ5 C1
R8 4
R5 3
R2 = 1kΩ C9
R7
C2 IC2 2
R3 = 10Ω R6 1
C3
R4,R7,R9-R16 = 10kΩ C14
C4
R5,R6 = 220Ω
C11
K5
T1
P1-P8 = 47kΩ linear potentiometer C5
D3
IC1
C19
P9 = 470Ω preset Hi C6
C18
ROTKELE )C( 1-780099 +
R13
R14
R10
R15
R11
R16
R12
R9
C7 K2
Capacitors: C8 0
C12
C17
C1-C8,C10,C11,C12,C14,C18 = K3
H3
H4
Semiconductors:
D1,D2 = LED, high efficiency
D3 = 1N4001
T1 = BC547B 990087-1 (C) ELEKTOR
IC1 = MAX186BEPP
IC2 = PIC16F84-10/P (programmed,
order code 996521-1)
IC3 = 7805
Miscellaneous:
K1 = 4-way SIL connector
K2 = 2 PCB solder pins
K3,K6 = 10-way SIL connector
K4,K9 = 5-way SIL connector
K5,K10 = 6-way SIL connector
K7 = 15-way Sub-D plug, chassis
mount (see text) Figure 2. The MIDI para-
K8 = 5-way DIN socket, chassis monitor should dis- meter box can be build changed by S9–S12
mount, 180° (see text) play control codes. using this small printed (binary), and that
K11 = mains adaptor socket These will have values circuit board. changing the layer
S1-S8 = pushbutton, 1 make contact ranging from 0 to 127. works properly.
S9-S12 = on/off switch If this does not hap- When the layer is
X1 = 10MHz quartz crystal pen, thoroughly check the circuit con- changed, the last stored values for the
Enclosure, e.g. Teko 363 struction, the cabling and the settings potentiometers are always output via
(216x130x77mm) of the MIDI monitor. If this doesn’t the MIDI interface. The advantage of
PCB, order code 990087-1
help, you can curse Windows or the this is that the parameters of the syn-
sound card. thesizer or the sound card are reset to
However, if the MIDI monitor dis- their last stored values. If for example
plays the first MIDI events, then every- you change the volume in layer 3,
on a piece of prototyping board and thing is in order. Trimpot P9, by the change to a different layer and some
wire them point-to-point. Of course, way, can also be used for calibration to time later return to layer 3, the volume
you can also design a ‘real’ circuit adjust actual range of the MIDI values will be restored to its original level. If
board. You should dress the flat cables to 0 through 127. you want to avoid this, all you have to
such that the unit can later be built into Verify that the MIDI channel is do is to press the Memo button before
an enclosure.
TESTING
In order to thoroughly test the MIDI
parameter box, you absolutely need a
MIDI monitor with a MIDI-through
option for the PC, so that you can
observe the transmitted MIDI data on
the monitor and properly calibrate the
potentiometers. The text box contain
more information about suitable MIDI
monitors. After a visual inspection of
the soldering, connect the parts
together and cable the unit to the PC.
Then switch everything on and start
the MIDI monitor. All the stored values
in a virgin PIC are set to FFh, so they
must be set to valid MIDI protocol val-
ues by pressing the Reset button. Next
select super-layer 1 and layer 1 (the
default layer) by pressing S1 twice.
Now comes the moment of truth.
When the potentiometers are rotated,
LED D2 should flash and the MIDI
1 2 3 4 5 6 MEMORY RESET
990087 - F
Figure 3. A reasonable
arrangement for the changing the layer. In this case only the Text editing
control elements on values that have changed since the last (German original): R. Gerstendorf
the front panel. layer change are stored. Design editing: K. Walraven
(990087-1)
MIDI monitors
There is a whole series of MIDI monitors that can be used with a
PC. An outstandingly suitable program is MIDI-OX, for which a beta
version is available for free on the Internet at
www.members.xoom.com/_XOOM/MIDIOX/moxbeta.htm. After
installing and starting the program, you must first select the MIDI
devices, either via the menu Options/MIDI Devices or by clicking
on the dark blue button with the five-pin DIN connector (see Figure
A). On this PC, the MIDI input and output of the SoundBlaster SB16
are active.
The MIDI Port Activity window shown in Figure B appears if you
press the bright green DIN icon in the second group of buttons.
Each MIDI input and output gets its own row of ‘LEDs’, so that it is
clear which channel is active.
The content of the transmitted data appears in the Monitors Output
window. The first column shows the time when the MIDI message
occurred (as noted by MIDI-OX), and the second column indicates
the MIDI port via which the message arrived (in this case, Port 1 via
SB16 MIDI). The following byte, 0BFh, consists of two parts: a Con-
trol Change (indicated by the ‘B’) and the MIDI channel number
(indicated by the ‘F’, which corresponds to MIDI channel 16).
DATA1 shows the controller number (0 – 127 in this case) and
DATA2 shows the assigned value. Just as with DATA1, only the
lower seven bits are used, so that the values range from 0 to 127.
CHAN shows the MIDI channel once again. Note that MIDI officially
uses channel numbers 1 through 16, but many programs display 0
through 15. When a different super-layer is active or the layer is
changed, the messages displayed on the monitor also change.
If you want to learn more background information regarding MIDI,
you can find an adequate amount of literature on the Internet. One
example is Eddies Home – MIDI-RPN and NRPN
(http://members.delosnet.com.tlc/nrpn.htm).
MIDI-OX is especially well suited to checking equipment functions. If you want to go deeper into the matter, you can try easy-to-
use and powerful programs such as Generator from Native Instruments or Rebirth from Propellerhead. Free demo versions of both
programs are available. These can be used for only a very short time and have no save functions, but they are an outstanding
choice for just playing around with the MIDI parameter box.
Most of you, we are convinced, would is presented as a lively little ornament cuit, you may decide to use different
avow to being pretty seriously consisting of red LEDs arranged in the colour LEDs for one of the hearts. Yel-
involved in electronics, be it as a shape of a heart. Flashing all the time, low LEDs, for example, do a fine job.
hobby or professionally. Sometimes, the LEDs beg for attention. Very deco- However, in that case the series resis-
too, you may get the feeling that it’s all rative, we’d say, and highly suitable as a tors may have to be decreased to about
getting a bit too serious. Typically, our gift to someone close to your real heart. 820 Ω to compensate the higher voltage
readers are busy working on practical Do not expect the latest design tech- drop of yellow LEDs. If you do not
applications of published circuits, or nology from this kit. As indicated by change the resistors, the light intensity
tweaking the specs. They will rave on the circuit diagram, the circuit consists from yellow LEDs will be too low.
about distortion, signal/noise ratios, or of little more than a bistable multivi- We do not know if Velleman offers
memory capacity, painstakingly seek- brator built around two common or any kind of warranty on this circuit.
ing ways to achieve improvements no garden transistors, with seven rows of Reproducibility will not be a problem,
better than tenths of a decibel or a few four LEDs each in their collector lines. we reckon, but a guarantee that the
parts per million. LEDs LD1-LD12 form the inner heart, flashing sweetheart will succeed in
Riveting stuff, of course, but it and LD13-LD25, the outer heart. Both actually conquering a heart will be
makes you wonder sometimes if all hearts flash in alternate fashion to impossible to obtain! However, at a
this activity captures any of the sheer mimic the well-known pump action. price of just £4.99 it’s well worth the
fun that can be had from the noble art The high-efficiency LEDs operate effort.
of soldering. That is why we can not ‘sparsely’ using series resistors R1-R7. The Maplin order code for this kit is
resist voicing a clear “start having fun The result is a current consumption of VX75S.
again” note to those of you with a ten- just 8 mA, enabling a 9-V PP3 battery (000031-1)
dency of taking a high-brow look at to last for about 24 hours.
the hobby. Electronics, we feel, need If you want to personalise the cir- Text (Dutch original): S. van Rooij.
not always be useful, in fact there’s no
reason why it should not be amusing,
playful and without pretension. With
simple means, dozens of interesting LD4 LD5 LD9 LD16 LD17 LD21 LD28
projects can be built. So, why not build
an original doorbell, a running lights
unit or a flashing brooch? Just for the R1
LD6 LD10
R8 R9
LD15 LD18 LD22 LD27
1k2
33k
33k
fun of it.
Quite possibly, people around you
R3
may value simple gadgets more than LD3 LD7 LD14 LD19 LD23 LD26
E1
1k2
A L OV E LY F L A S H E R
LD1
R2
LD12
R4 R5 R6 R7
1k2
1k2
1k2
1k2
BASIC Stamp
programming course (6)
Part 6: introducing the FSM concept
By Dennis Clark quarters < 2
45 select = none
quarters = 2
Linear based servo controller subroutine FSM based servo controller subroutine
act: act:
for I = 1 to 10 if aDur > 0 then aDec
pulsout LEFT,750 aDur = 5
Pulsout RIGHT,750 pulsout LEFT,750
pause 20 pulsout RIGHT,750
next goto aDone
return aDec:
aDur = aDur - 1
aDone:
return
arrow points the direction). If a transi- operate correctly, a single pulse is not time taken by the left subroutine, we
tion line is labelled, that label is the very useful to a servo. now will take 5*750 µs + 3.75 ms =
result of the transition function and The code on the left looks very sim- 7.5 ms of processor time total (we are
defines the condition required for that ple and fast, but looks can be deceiv- taking 5 turns through it after the initial
change of state. An unlabelled line is a ing. The pulsout instructions are used pulse outputs remember?) to accom-
transition that will always occur as soon to output a pulse of the needed width plish the same purpose. If we only
as the function of that state is com- to turn the servos. Remember, this count a single 23 ms loop for each pass
pleted. The lines that loop back upon a pulse needs to be repeated every 20 to through the first subroutine, we will
state show iteration, or that the FSM 30 milliseconds (ms) in order for the have saved 15.5 ms of processor time,
remains in this state doing something servo to respond properly. Also, it which, at 4000 instructions per second
until a terminal condition is reached, at needs to have several repetitions of this amounts to 62 instructions that can be
which time a defined transition that is pulse for the motor to turn and keep executed elsewhere and give us the
labelled will occur. Here we see that our running. The pause instruction will exact same activity on our servo
soda machine FSM will remain in state cause the Stamp II to pause for 20 ms, motors. If we take into account the full
0 until two quarters have been given, at each of the pulses sent will be 2 230 ms time for the left loop we save
which point our FSM will transition to microseconds * 750, or 1.5 ms. So, each over 226 ms which is a whopping 904
state 1. Here we will wait, looking at pass through this for/next loop will take instructions!
buttons until a selection is made. When 3 ms + 20 ms = 23 ms at least, 10 times But why is this important? A robot
a selection is made, our FSM will then through the loop will take 230 ms! does not just wander aimless around
transition to state 2, 3 or 4 depending That is almost 1/4 of a second when in its environment, it usually has some
on the selection made. From these ter- nothing else can be done! task to accomplish. Whether it is
minal states, our FSM will immediately Now let’s look at the code on the searching for a fire to put out, trash to
transition back to state 0 after complet- right that implements a two-state FSM pick up or for another robot to attack,
ing. This is the general process of defi- to move the servos. You can see that it is doing something else more impor-
nition and representation for the FSMs our subroutine on the right does one of tant than just running its motors.
that we will be using to define our BoE- two operations at any given time. The When we use the motor driver routine
Bot behaviours. first operation is to output the pulses to on the left above, the robot is doing
Remembering where you are in the servos and set the aDur variable. absolutely nothing but concentrating
your subroutine is called saving state The second operation is to simply on running the motors for 230 ms.
and is essential if you are to pick up decrement the aDur variable. In either During this time it cannot look at a sen-
where you left off when last this sub- case, after the operation has been sor, pick up trash or put out a fire. If it
routine ran. Each state in our behav- accomplished we exit the subroutine. runs into something, it will just keep
iour FSM will be executed when its Each of these operations will be running into it until it is finished with
subroutine is called and will exit the defined as a state for the act behaviour. that loop and can then do something
subroutine when that state is com- We will get into more details on else. Each of the other behaviours that
pleted. Subsequent calls of that sub- how to describe and design state we implement in our robot will be
routine will execute the next correct machines for our robotic behaviours some activity that the robot will need
state that is defined. Why is this useful? using examples and programs that you to perform in a timely manner. It does
Let’s look at two code snippets in List- will write for your BoE-Bot in later us no good to detect an object to avoid
ing 9 that show why this can make instalments. after we have already run into it! Let’s
your whole program run faster. Both of Returning to our code samples, let’s assume that our robot is running the
these pieces of code operate the hobby figure the time spent in the subroutine following behaviours, listed in lowest
servos that make your BoE robot on the left now. Since the Stamp II exe- priority to highest priority, to achieve
move, don’t worry about understand- cutes about 4000 lines of code a second some objective:
ing them exactly, what this code does this means that each instruction will
will be fully explained in due course. take about 250 µs to execute. The pul- ➧ Go North until home is found
The one thing you must know is that a sout instructions will obviously take (chooses a direction to travel)
hobby servo requires that a pulse of 1.5 ms each to execute because that is ➧ Avoid hitting anything by using IR
1 ms (millisecond) to 2 ms must be sent the length of the pulse that is being proximity detection (if something is
to each servo every 20 to 30 ms or the sent. In state 1 it will take 3 ms for the a danger, choose another direction)
servo will not perform correctly. If you pulsout instructions + 750 µs for the ➧ If I hit something, back up and
send it too often (say every 7 ms) the other three instructions, which equals turn left (chooses yet another direc-
servo will jitter, if you send it too rarely 3.75 ms. In state two our second sub- tion to go)
(say every 50 ms) then the servo will routine will take about 750 µs of ➧ Stop and beep when I am home
stop. These pulses need to be repeated processor time each time it is executed. (choose no direction at all, just stop)
continuously, and regularly in order to Instead of the 230 ms of processor ➧ Select the highest priority direction
BASIC-537
a high-level language for the
80535/537
Amplifiers come in all sorts. Most of power output, their design is far from Be that as it may, the most obvious
the amplifier designs published in this simple. way of increasing power output is to
magazine are intended for domestic or A simple calculation shows that a raise the supply voltage of 12 V to a
studio use. As such, they are usually conventional amplifier operating from higher level by means of a converter.
powered by a 60–150 V supply, which 12 V (or maximum 14.4 V when the Such a converter, however, is not
may, moreover, be further divided into battery is fully charged) cannot pro- exactly cheap and is, moreover, a noto-
two balanced voltages. This makes vide a power output of much more rious source of noise and interference.
these amplifiers unsuitable for use in than 6 W. Use of a bridge arrangement In view of the extensive electronic cir-
motor vehicles. may push this up to some 20 watts, but cuits in modern motor vehicles, this lat-
Amplifiers that can operate from a that is just about the maximum possi- ter point is not to be underestimated.
12 V supply are quite different units, ble. Fortunately for the loudness-hun-
designed as they are for low-voltage Nowadays, many motorists, and gry, there is an alternative to a con-
supplies. If, moreover, they are more particularly the younger ones, verter. Some years ago, Philips intro-
required to provide a substantial want considerably more power than duced a special integrated output
6–20 watts. Loudness is their god, but amplifier chip, the TDA1560Q, that is
they unfortunately forget that this is an able to provide 30 watts into 8 Ω from
unforgiving god, leading them to early a 12 V power supply (without the use
Design by T. Giesberts deafness. of a converter). This output power is
100k
4k7
R3 C7 C8
rent drain in the standby mode is vir-
1k C5 tually negligible at only 200 µA.
D1 4700µ
C4
100n 4700µ
25V
Resistor R3 prevents a short-circuit
S1
25V current ensuing when S1 is being
10µ
63V 8 16 3 5 9 10 closed at the instant C4 is being dis-
charged.
VP1
VP2
standby DIAG C1– C1+
STAT
4
MODE
C1 LS+
1
+IN OUT+
7 ERROR INDICATION
R1
470n
IC1 The diagnostic output (pin 8) of the
1M
PGND1
PGND2
14
SGND
VREF used to drive an visible error indicator,
C2– C2+
D1, directly. During normal operation
17 15 13 6 12
C6
the diode should be out. Its lighting
C3
may be caused by one of four possible
10µ
63V
4700µ causes.
25V
1. The amplifier is being overdriven.
The internal circuit responsible for
000004 - 11 the indication is the ‘Dynamic Dis-
tortion Detector ’ (see Figure 1). In
Figure 2. The circuit of practice, this will be the case when
the amplifier is con- the distortion rises above 1.6 per
spicuous by its sim- cent at 1 kHz. The diode is, there-
plicity. Diode D1 is an fore, a kind of clipping indicator.
CIRCUIT error indicator.The value of input 2. There is a short-circuit between the
DESCRIPTION capacitors C1 and C2 is outputs or between one of the out-
The circuit diagram in relatively low, thanks to puts and the supply line. In the first
Figure 2 emphasizes how few external the high input impedance of the IC. case, the outputs are disabled,
components are needed to construct a Switched RC network R4-C4 at the whereupon the protection network
complete output amplifier (in fact, ‘mode select’ input (pin 4) serves to ascertains at short intervals of time
fewer than half the number in the Feb- switch the IC to ‘mute’ or ‘standby’. whether the short-circuit has been
ruary 1995 amplifier). For instance, the When the supply voltage is switched removed. The DIAG output is then
new device does not need compensa- on, the IC is first switched automati- disabled for 30 µs at 20 ms intervals.
tion networks to enhance the stability. cally to the ‘mute’ mode and to ‘on’ In the case of a short-circuit
Also, because of the absence of switch- only after a short delay. The time con- between one of the outputs to the
on phenomena, there is no need for a stant R4-C4 is a few tenths of a second supply line, the DIAG output
switch-on delay network. and this delay between the two states remains active.
There is, of course, still a need for is sufficient to obviate disturbing (and 3. The internal sensor measures a tem-
supply line decoupling capacitors. annoying) switch-on phenomena. perature of 145 °C, whereupon the
Capacitors C5 and Switch S1 enables
C6 are required for Figure 3. The compact the amplifier to be
Class-H operation, printed-circuit board switched to ‘standby’
about which more in for the amplifier is when the use of the
the box. available through the amplifier is not needed
Readers’ services COMPONENTS LIST
(towards the end of
Resistors:
this issue).
R1 = 1MΩ
R2 = 4kΩ7
R3 = 1kΩ
3 R4 = 100kΩ
S1
standby
H4
H1
R3
Capacitors:
LS+
C1,C2 = 470nF
C5
R1
C4
C2
C7 = 100nF, raster 5 mm
C1
+
Semiconductors:
D1 = high-efficiency-LED
C7
Miscellaneous:
S1 = single-pole on/off switch
0 C8
1-400000
H2
H3
000004-1
ROTKELE )C( (C) ELEKTOR
A COMPACT B OARD
The amplifier is best built on the single-
sided printed-circuit board shown in
Figure 3 (available through our Read-
ers’ services – see towards end of this
issue). As mentioned earlier, the board
is small for an output amplifier. In fact,
most of its surface is taken up by the
four car-type (spade) connectors via
which the power supply and the loud-
speakers are connected to the amplifier.
The small size of the board also cre-
ates a few difficulties. If, for instance, Class-H operation
the electrolytic capacitors are mounted
first, the fitting of the IC becomes A Class H amplifier is somewhat akin to a Class G amplifier, which is a power ampli-
pretty difficult. It is, therefore, advis- fier in which two Class B amplifiers with different supply voltages are combined. Small-
able to start with fitting the IC onto the amplitude signals are boosted by the one with the lower supply voltage, resulting in
heat sink (using plenty of heat con- much higher average efficiency for speech and music. When signals exceed the low-
ducting paste). voltage supply amplitude, the amplifier that operates from the higher supply voltage takes
Also, ensure that after the board has over, while the first one is switched off.
been placed in a suitable enclosure, its In a Class H amplifier the supply voltage is varied by an efficient Class S amplifier
or the arrangement in the present design so that it remains just above the minimum
solder (track) side remains readily
value required to prevent saturation. This configuration also achieves a much higher
accessible. After the board and heat
average efficiency for speech and music signals. (A Class S amplifier is a pulse-width-
sink have been secured in the case, sol-
modulated audio amplifier in which the active elements are switched by a control fre-
der the pins of the IC to the board.
quency several times higher than the signal frequency being amplified. This type of
Figure 4 shows a photograph of the
amplifier has an efficiency of some 90 per cent).
completed prototype as built up in our
design lab.
Make sure that when the board is
fitted in the case, the loudspeaker ter- D1 D2
minals are not (and cannot be) short- T5 T6
desoldering
a craft in its own right
We can assume that the
majority of our readers have
sufficiently mastered the
noble art of soldering. How-
ever, the art of unsoldering
already soldered compo-
nents, or desoldering, is
something else. Even rather
experienced solder artists
often prove to be extremely
clumsy in this area. They go
about it the wrong way, and
lacking both patience and
the right touch, they tend to
In short, even though using desol- no longer desired. Desoldering braid
mess around until they dering braid may appear to be the can be obtained in small rolls a few
have ruined not only the most primitive of the three options, our
experience in the Elektor lab is that it
metres long (see Figure 1).
Using desoldering braid is very easy.
component but also the yields the best results. Before you start, remember that solder
flows best when it is good and hot. You
printed circuit board. BRAIDED WIRE should thus not use too small a solder-
Desoldering braid or ‘Wick’ is actually a ing iron. If you have a temperature-
braided wire ribbon consisting of thin controlled soldering iron, set it to at
copper wires together with impreg- least 350 degrees. Now all you have to
PUMPING OR SUCKING? nated solder flux. The spaces between do is to make sure that the desoldering
The only good way to desolder is to the wires soak up the solder, so that it braid is hotter than the joint that is to
patiently remove all of the solder from is removed from the place where it is be desoldered, since the solder will
the points where the component is
attached to the circuit board. This can
be done using a special ‘solder-sucker’
soldering iron, a vacuum pump or des- 1
oldering braid.
Of these various options, the vac-
uum pump and the special soldering
iron may seem to be the most conve-
nient at first glance, but in practice this
is not so. The nozzles of these tools are
easily clogged, and the sucking action
is not always perfect. If you use a sep-
arate pump, you have to heat the sol-
der joint quite strongly, which is in
itself risky. Even then you have to
quickly switch between the soldering
iron and the pump, since otherwise the
solder will cool down and become
hard again.
By K. Walraven
FLUX
Once you have gained some experi-
ence in working with desoldering
braid, you will quickly realize that this
technique works well only if sufficient
flux is present. If there is not enough
flux, even liquid solder simply forms a
ball and will not soak into the braid.
Sometimes certain parts of the braid
do not have enough flux. This can be
caused, for example, by repeated flex-
ing of the braid at a particular location.
This fault can be remedied by
putting additional flux on the solder
joint that is to be removed. You can
buy flux paste in tubes for this pur-
pose. You can also use violinist’s rosin,
which is available in small tins, to
impregnate the braid. Since rosin is
hard, getting it into the braid is a bit 4
tricky. Set your soldering iron to a low
temperature (100 to 150 degrees); if
you do not have a regulated iron, you
will just have to be quick. Lay a small
piece of braid on the surface of the
rosin and warm the braid from the top
with the soldering iron (see Figure 4).
The rosin will melt and soak into the
braid. Hold the iron stationary and pull
the braid through underneath it.
You can also make your own desol-
dering braid in this manner. You can
use any piece of stranded wire (from a
bit of mains cable, for example) — just
remove the insulation and impregnate
it with flux. This is handy to know if
you run out of desoldering braid, or
simply find it too expensive.
(000006-1)
Figure 1. (************************************************************************)
P2.PAS (*** p2: Capture analogue values with the 537 Lite Board ***)
listing. (*** =================================================== ***)
(*** Version: 1.0, 12.10.99, 16:23 ***)
(*** Programmer: v.Bg. ***)
(************************************************************************)
program p2;
(* Various *)
i,zw: byte;
begin
(*** Clear screen ***)
write(chr($1a));
end.
HT12D HT12A
Application example LSIs for remote control system applications. They are
IR Remote Control for Sony MZ-R30 MiniDisc Walk- capable of encoding information which consists of N
man, Elektor Electronics February 2000. address bits and 12–N data bits. Each address/data
No.3 Creation Rd. II, Science-based Industrial Park, No.3 Creation Rd. II, Science-based Industrial Park,
Hsinchu, Taiwan, R.O.C. Fax: 886-3-563-1189. Hsinchu, Taiwan, R.O.C. Fax: 886-3-563-1189.
Internet: http://www.holtek.com.tw Internet: http://www.holtek.com.tw
Input pins for A0-A7 setting. These pins can be externally set to VSS
A0 – A7 I CMOS IN, pull-high
Input pins for A0-A11 setting. They can be externally set to VDD or left open
A0 – A11 I NMOS TRANSMISION GATE
or VSS Input pins for data D8-D11 setting and transmission enable, active
D8 – D11 I CMOS IN, pull-high
low. These pins can be externally set to VSS or left open
D8 – D11 O CMOS OUT Output data pins
DOUT O CMOS OUT Encoder data serial transmission output
DIN I CMOS IN Serial data input pin Latch/Momentary transmission format selection pin.
L/MB I CMOS IN pull-high
Latch: floating or VDD. Momentary: VSS
VT O CMOS OUT Valid transmission, active high
OSC1 I OSCILATOR 1 Oscillator input pin
OSC1 I OSCILLATOR Oscillator input pin OSC2 O OSCILLATOR 1 Oscillator output pin
OSC2 O OSCILLATOR Oscillator output pin X1 I OSCILLATOR 2 455 kHz resonator oscillator input
X2 O OSCILLATOR 2 455 kHz resonator oscillator output
VSS I — Negative power supply (GND)
VSS I — Negative power supply (GND)
VDD I — Positive power supply VDD I — Positive power supply
✃
HT12A HT12D
2/2000
Integrated circuits Integrated circuits
Special Function Special Function
DATASHEET 2/2000 DATASHEET 2/2000
Elektor Electronics
HT12A Block Diagram HT12D Block Diagram
input can be set to one of the two logic states. The completes its final cycle and then stops as shown in General Description Functional description
programmed addresses/data are transmitted together the transmission timing diagram. The HT12D decoder is a CMOS LSIs for remote con- Operation
with the header bits via an RF or an infrared trans- trol system applications. It is paired with Holtek’s The HT12D decoder receives data that are transmitted
mission medium upon receipt of a trigger signal. The Information word 212 series of encoders. For proper operation, a pair by an encoder and interpret the first N bits of code
capability to select a DATA trigger on the HT12A fur- If L/MB=1 the device is in the latch mode (for use of encoder/decoder with the same number of period as addresses and the last 12–N bits as data,
ther enhances the application flexibility of the 212 with the latch type of data decoders). When the addresses and data format should be chosen. The where N is the address code number. A signal on the
series of encoders. The HT12A provides a 38kHz transmission enable is removed during a transmis- decoders receive serial addresses and data from a DIN pin activates the oscillator which in turn decodes
carrier for infrared systems. sion, the DOUT pin outputs a complete word and programmed 212 series of encoders that are trans- the incoming address and data. The decoders will then
then stops. On the other hand, if L/MB=0 the device mitted by a carrier using an RF or an IR transmis- check the received address three times continuously. If
Functional description is in the momentary mode (for use with the momen- sion medium. They compare the serial input data the received address codes all match the contents of
Operation tary type of data decoders). When the transmission three times continuously with their local addresses. the decoder’s local address, the 12–N bits of data are
The HT12A encoder begins a 4-word transmission enable is removed during a transmission, the DOUT If no error or unmatched codes are found, the input decoded to activate the output pins and the VT pin is
cycle upon receipt of a transmission enable (D8-D11, outputs a complete word and then adds 7 words all data codes are decoded and then transferred to the set high to indicate a valid transmission. This will last
active low). This cycle will repeat itself as long as the with the ‘1’ data code. output pins. The VT pin also goes high to indicate a unless the address code is incorrect or no signal is
transmission enable (D8-D11) is held low. Once the valid transmission. received. The output of the VT pin is high only when
transmission enable returns high the encoder output The HT12D decoder is capable of decoding informa- the transmission is valid. Otherwise it is always low.
tion consisting of N bits of address and 12–N bits of
data. The HT12D is arranged to provide 8 address Output type
bits and 4 data bits. The HT12D provides 4 latch type data pins whose
data remain unchanged until new data are received.
54
Transmission timing for HT12A (L/MB = VSS) Decoder timing for HT12D
✃