0% found this document useful (0 votes)
153 views

Us200002 PDF

This circuit allows a Nintendo 64 controller to connect to a PC game port or sound card without additional drivers. It uses a microcontroller to translate signals from the Nintendo 64 controller into a format understood by the PC. The microcontroller communicates with the controller over a single data line using a protocol with predefined commands and responses to retrieve button and joystick status information. Precise timing is required due to the asynchronous nature of communication between the microcontroller and controller.

Uploaded by

polikarpa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
153 views

Us200002 PDF

This circuit allows a Nintendo 64 controller to connect to a PC game port or sound card without additional drivers. It uses a microcontroller to translate signals from the Nintendo 64 controller into a format understood by the PC. The microcontroller communicates with the controller over a single data line using a protocol with predefined commands and responses to retrieve button and joystick status information. Precise timing is required due to the asynchronous nature of communication between the microcontroller and controller.

Uploaded by

polikarpa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

Awkward keyboard commands and uncomfortable

mouse control can spoil even the most attractive PC


game. The ideal solution would be simple operation,
as offered by the Nintendo 64, combined with the pro-
cessing power of a PC. This article describes how to
connect a Nintendo 64 controller to the PC game port.

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.

2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS


…is not what the game port 5V
expects 1
R11
A simple PC game port does not need C5 R10
C1
any active circuitry. The two pushbut- C2

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Ω

tiometers can thus be derived from the


5V
lengths of the pulses produced by the * X1
monostables. All analogue elements XO1 8
front view
are addressed or polled at the same * see text
24MHz
time. A normal PC game port provides 1
EN
5 C4 C3

connections for two joysticks, which OSC


27p 27p
means that it has four ‘digital’ and four 4 24MHz
‘analogue’ inputs. Sometimes only one
002007 - 11
joystick can be connected, but this is
very rare.
Figure 1. A microcontroller, a pair of resistors and an oscillator are all you need for the
adapter circuit.
Two worlds join together
It is not difficult to see that these two
worlds do not really fit with each other. be satisfied without a lot of compli- Details — the program
Requesting and interpreting the status cated circuitry? Handling the push- The software, including the source
data from the Nintendo 64 controller buttons is relatively easy; the relevant code, is available from the Elektor Elec-
should not be difficult, but how can bits from the Nintendo 64 controller tronics web site (www.elektor-electron-
the expectations of the PC game port can simply be periodically output on ics.co.uk). If you cannot program the
the microcontroller leads. However, microcontroller yourself, you can obtain
what should be done with the digital a ready-programmed device from our
values for the analogue joystick? Here Readers Services under order code
Table 1. Nintendo 64 we can use a trick: the interface 006504-1.
microcontroller waits for a short Low The main loop of the program starts
serial status information level on one of the potentiometer after the stack and the two timers have
lines, which goes along with the cyclic been initialized, the timers have been
Byte 1
Bit 7 button A charging of the capacitors of the PC started and their interrupts have been
Bit 6 button B game port card. Following this, the enabled. First, the timing for the ana-
Bit 5 button Z microcontroller holds all of the poten- logue joystick modules A and B (B is the
Bit 4 start button tiometer lines Low, to prevent any fur- control cross or C button) are estab-
Bit 3 control cross up ther charging of the capacitors, and lished by the routines prepajoyt and
Bit 2 control cross down starts its timer. Each of the poten- prepbjoyt, respectively. Timers T0 and
Bit 1 control cross left tiometer lines is subsequently allowed T1 are responsible for the timing of joy-
Bit 0 control cross right to go High at a time that depends on stick A, with T0 used for the X axis and
the data received from the Nintendo T1 for the Y axis. Timer T0 also manages
Byte 2
Bit 7 unknown, always 0
64 controller. The corresponding the Timeout Mode, which prevents the
Bit 6 unknown, always 0 capacitors are charged briefly via the program from getting stuck in a polling
Bit 5 button L microcontroller outputs, and the asso- loop if the Nintendo 64 controller is
Bit 4 button R ciated monostables report what they unexpectedly disconnected or there is
Bit 3 button C up assume to be the potentiometer posi- an intermittent contact. In such a situa-
Bit 2 button C down tions. If you observe the relevant out- tion, it would otherwise not be possible
Bit 1 button C left puts of the AT89C2051 with an oscillo- to initialize the Nintendo 64 controller
Bit 0 button C right scope, you will see pulse-width modu- once it was reconnected without first
lated signals with a period of around manually resetting the microcontroller.
Byte 3
840µs and a duty cycle of 50% to The entire program is synchronized with
analogue stick x
90%, depending on the potentiome- the slowest and least-flexible element,
Byte 4 ter position. When the potentiometer is the PC game port. The instruction jnb
analogue stick y at the midrange position, the duty JPYAX,* waits for the capacitors to be
cycle is 70%. discharged. Once the game port has

PC TOPICS —————————————— Elektor Electronics EXTRA 3 - 2/2000


COMPONENTS LIST
Resistors:
R1-R4 = 470Ω
R5-R8 = 220Ω
R9 = 10kΩ
K1

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

D1 = LED, low current


R9
X1

F3

F4

IC1 = AT89C2051-24PC (order code


C4
C3

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.

4 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS


Settings/Control Panel. If you do not, the Table 2. Arrangement of the Nintendo-64/PC game
necessary software must first be
installed. After this, the best approach port signals
is to configure a new joystick with four N64 Controller PC Gameport Line
axes and four pushbuttons. During the
subsequent calibration, make sure that button A Joy A button 1 JOYAB1
the up/down buttons of the control button B Joy A button 2 JOYAB2
cross, or the C button, have been set to button Z Joy B button 1 JOYBB1
button Start/R Joy B button 2 JOYBB2
the highest speed using the L button
analogue X-axis Joy A analogue x JOYAAX
(recognizable by the largest displace- analogue Y-axis Joy A analogue y JOYAAY
ment on the screen). The settings can K/C left/right Joy B analogue x JOYBAX
be saved with the name ‘N64’, for K/C up/down Joy B analogue y JOYBAY
example. This name may be needed
later to configure certain games. Older K=control cross, C=buttons
(DOS) games only require calibration.
Some games (such as Unreal) offer an
extensive range of joystick settings, Table 3. Two typical joystick configuration files
which you will have to carefully study
and try out. In some cases, such as with
Half-Life, you will need a small joystick // name joystick.cfg
configuration file that contains the con- // analog turn and look version
//
figuration data. The game looks for this
// x analog turn left/right
file in a particular folder when it is // y analog look up/down
started (for example, // C move left/right
c:\Sierra\HalfLife\valve). You can usually // C move forward/backward
find tips in the ReadMe files of the // configure in game: A alternate fire, B duck, Z fire, R/Start jump
games as well. Table 3 shows two typi- //
joyname ”N64”
cal configuration files. joyadvanced 1
joyadvaxisx 4
Construction hints joyadvaxisy 2
joyadvaxisz 1
Constructing the circuit, using the joyadvaxisr 3
joyadvaxisu 0
printed circuit board shown in Figure 2, joyadvaxisv 0
should not present any difficulties. This joyforwardsensitivity -1.0
PCB is unfortunately not available joysidesensitivity 1.0
ready-made through our Readers Ser- joypitchsensitivity -1.0
vices. Mount the microcontroller in a joyyawsensitivity -1.0
joyforwardthreshold 0.1
good-quality socket. The choice
joysidethreshold 0.1
between a quartz crystal and an oscil- joypitchthreshold 0.1
lator module has already been dis- joyyawthreshold 0.1
cussed. If an oscillator module is used, joyadvancedupdate
omit capacitors C3 and C4 (and of
course X1). Difficulties may arise with
Alternative version:
the (various) controller plugs, since
matching sockets are hard to come by. // name joystick.cfg
There are three possible solutions: (a) // analog turn and move version
cannibalize an old Nintendo 64 con- //
sole, (b) cut off the plug and make up // x analog turn left/right
// y analog move forward/backward
an adapter cable with a three-way DIN
// C look up/down
or Mini-XLR plug (with a mating con- // C move left/right
nector on the end of the cable), or (c) // configure in game: A jump, B alternate fire, Z fire, R/Start duck
improvise a solution using 1.3-mm //
diameter solder pins to which short joyname ”N64”
lengths of wire are soldered, which in joyadvanced 1
joyadvaxisx 4
turn can be soldered to the inputs of joyadvaxisy 1
the AT89C2051 (see Figure 3). To pro- joyadvaxisz 2
tect against a reverse-polarity connec- joyadvaxisr 3
tion, you should solder the pins to a joyadvaxisu 0
piece of prototyping board with a hole joyadvaxisv 0
joyforwardsensitivity -1.0
spacing of 3.75 mm, and then use an joysidesensitivity 1.0
additional part (for example, a piece joypitchsensitivity 1.0
of 3/4-inch plastic pipe, as shown) to joyyawsensitivity -1.0
prevent the plug from being con- joyforwardthreshold 0.1
nected incorrectly. joysidethreshold 0.1
joypitchthreshold 0.1
(002007)
joyyawthreshold 0.1
joyadvancedupdate

PC TOPICS —————————————— Elektor Electronics EXTRA 5 - 2/2000


It’s hard to keep track of how many running text dis-
plays you run across nowadays. You can find them
used as decorations in shop windows, as program-
mable signboards and as simple eye-catchers. If you
buy one ready-made, however, it’s fairly expensive,
and they are usually too complex for DIY construc-
tion. The running text display project in this article
combines a simple and inexpensive design with
repeatable construction and ease of use.
Technical sp
ecifications
Stored text:
Design by K. Wohlrabe 508 characte
rs maximum
Displayed text
:
6 characters
using 5 x 7 m visible

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

The objective of the running text display


project was to develop a simple, inex-
pensive design that would not be too
difficult to build and would be easy to
use. We intentionally decided not to
make the display as large as possible
or to implement a lot of different dis-
play modes, since these would require
a powerful microcontroller or a single-
board computer. The result is a circuit
that is controlled by an inexpensive
National Semiconductor microcon-
troller with 4 kB of ROM, and which can
be built using readily obtainable com-
ponents.
Conventional running text displays
normally have keyboards that are
directly cabled to the display units.
These keyboards are usually not laid
out the same as standard keyboards,
so programming is awkward and time
consuming. The keyboard matrix also
requires a relatively large printed circuit
board with expensive keys, which
makes it unsuitable for a DIY project.
The basic idea of this project is to use a
standard PC keyboard with an infrared
data link to the display unit. The running
text can then be conveniently pro-
grammed, with all the advantages of
using a standardised PC keyboard —
and this can be done up to 10 metres
away from the display.
The transmitter, with its attached key-
board, can also be employed as a
general-purpose unit for other (future)
projects, in order to simplify the con-

6 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS


5V
COMPONENTS LIST
K1
(transmitter) R2
+5V
6

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

IC1 = COP8782 (order code 996527-1)


C3 C4 C1 C2
IC2 = 7805
X1 ZTX603
IC3 = ZSM560 100n 220µ 33p 10MHz 33p
16V

Miscellaneous: * see text 990090 - 12

K1 = 5-way DIN socket 180° or PS2-


socket
X1 = 10MHz quartz crystal Figure 1. The input data transmitter contains only a COP-8 microcontroller and an
infrared transmitter module.

struction and operation of the equip-


ment. Only one port pin of the micro-
controller on the receiver side is
needed for decoding the information The microcontroller
from up to 128 keys. The same type of microcontroller is used in the transmitter and the receiver. The specifica-
tions of this National Semiconductor IC make it an outstanding choice for this project:
The transmitter ➧ 4096 x 8 OTP EPROM
➧ 128 bytes of RAM
The microcontroller in the transmitter ➧ 1 µs cycle time at 10 MHz
unit, whose schematic diagram is ➧ 16-bit timer with the following operating modes:
shown in Figure 1, receives the serial ➧ auto reload
digital signals from the PC keyboard
➧ external event counter
and converts them into a protocol that
➧ timer with capture function
is sent to the display unit via infrared
➧ 16 I/O leads, of which 14 can individually be programmed as inputs or outputs
light. The decoding of PC keyboard sig-
•➧ selectable pin configuration: tri-state, push-pull or pull-up
nals is described in another article,
➧ Microwire interface
elsewhere in this issue. The microcon-
➧ interrupt sources: external with selectable edge, timer or software
troller in the transmitter unit selects scan
code set 3 after it has been reset, The COP8782 microcontroller now has a successor, with the type designation COP8SAC7.
switches on the Scroll LED of the key- This has improved characteristics, but it is essentially pin-compatible and functionally com-
board as an indication that it is active, patible with the older version. There is a starter kit available, which unfortunately does not
suppresses the Break code for the allow real-time emulation, but which does allow OTP devices to be programmed. It also pro-
upper-case (shifted) keys and transfers vides comprehensive insight into the possibilities of this inexpensive and technically inter-
esting microcontroller family. For somewhat more demanding projects that require the real-
key codes to the display unit. The data
time behaviour of the microcontroller to be tested, you have no other choice than to buy
transfer employs a modulated 36 kHz an emulator if you do not want your projects to turn into endless trial-and-error sessions.
carrier, in order to provide noise immu-

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).

PC TOPICS —————————————— Elektor Electronics EXTRA 7 - 2/2000


5V 5V 5V
R17
R9 C4

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

IC14 13 3 4 10 6 IC15 13 3 4 10 6 IC16 13 3 4 10 6 IC17 13 3 4 10 6 IC18 13 3 4 10 6 IC19 13 3 4 10 6 IC20 13 3 4 10 6


2 2 2 2 2 2 2
7 7 7 7 7 7 7
1 1 1 1 1 1 1
5 5 5 5 5 5 5
8 8 8 8 8 8 8
14 14 14 14 14 14 14
9 9 9 9 9 9 9

MATRIX 3 MATRIX 3 MATRIX 3 MATRIX 3 MATRIX 3 MATRIX 3 MATRIX 3 990090 - 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

current-limiting resistor R1 is intentionally shown in Figure 3. This very sensitive IC,


990090 - 14
chosen to be on the low side, and a which is specially tuned to work at the
high-efficiency LED is used. However, in 36 kHz carrier frequency, contains a
principle any type of infrared LED can photodiode, an amplifier stage, a filter
be used. and a demodulator. Resistor R17 and Figure 4. How the numeral ‘3’ is represent-
The short data packets, and the capacitor C5 form a supplementary ed on a 5 x 7 matrix display element.

8 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS


COMPONENTS LIST Each display cycle starts with a high power source, or a small 12-V sealed
(receiver) level on the data input of the first shift lead-acid battery (or a car battery)
register (IC21). This high level lasts for can be used if the display must be
Resistors: one clock period. The five cascaded independent of the mains.
R1-R7 = 47Ω shift registers are clocked simultane-
R8 = 1MΩ ously every 400 µs under interrupt con- Operation
R9 = 100kΩ trol, so that the active column moves
R10-R16 = 750Ω stepwise from QA of IC21 through to QH When the power is switched on, the
R17 = 100Ω of IC25. IC28 through IC32 are simple running text that was last entered is
driver ICs, which provide sufficient cur- automatically displayed. If no text has
Capacitors: rent for the matrices. Every column of yet been programmed, ‘ELEKTOR’
C1,C2 = 33pF
the matrix is assigned to a RAM location appears on the display. Connect the
C4 = 100nF
in the microcontroller. The information transmitter to a PC keyboard and then
C5 = 10µF 16V
to be displayed appears for 400µs on apply power to it. If the transmitter is
C6 = 2000µF 25V (or 2200µF 25V)
the microcontroller outputs L0 through working properly, the Scroll LED should
C7 = 2000µF 16 V (or 2200µF 16V) L6, according to which column is being be illuminated on the keyboard. Press
Semiconductors:
driven. Transistors T1 through T7 are the F2 key to clear the display and
B1 = bridge rectifier B80C1000 (80V piv, used here as drivers. Due to the use of cause a cursor to appear. You can
1A) multiplexing, the LEDs must be driven at now enter the desired text. Press the
T1-T7 = BC557 higher than usual current levels in order Shift key briefly to switch between
IC14-IC20 = see text to make them bright enough to be lower-case and upper-case charac-
IC21-IC25 = 74164 seen in daylight. To obtain sufficient ters. This will cause the appearance of
IC26 = COP8782C brightness, you should use matrix dis- the cursor to change. Incorrectly
(order code 996527-2)
plays with an optical efficiency of at entered characters can be deleted
IC27 = ZSM560
IC28-IC32 = ULN2803 (Sprague)
least 3 mcd at 20 mA. using the Backspace key, up to the first
IC33 = 93C66CB1 (ST-Microelectronics) The information for the running text character entered. It is not possible to
IC34 = TFMS5360 display is stored in a non-volatile 512- erase previously entered characters; if
IC35 = 7805 byte serial EEPROM (IC33). In order to this is necessary, press the Esc key to
allow the data to be quickly recalled, end the current entry session and then
Miscellaneous: the EEPROM is addressed via the press F2 to start anew. Press Enter when
Mains adaptor socket Microwire interface of the microcon- you have finished entering the text.
Small heatsink for IC35
troller at a clock frequency of 500kHz. After this, the running text display will
X1 = 10MHz quartz crystal
The PC keyboard delivers the scan start automatically.
Disk. source code file, order code
996032-1 code of each key via the infrared inter- After each text display cycle, the
face, for example the code 26H for the time of day is automatically displayed
numeral ‘3’. In order to display this for about 15 seconds. The time can be
numeral on a 5×7 matrix, as shown in set using the F1 key. If you do not want
Figure 4, the scan code is converted this alternating display mode, you can
using a look-up table, which in this use the F3 and F4 keys to select a dif-
low-pass filter, which guarantees error- case yields the values 42H, 41H, 49H, ferent mode. The meanings of the key-
free reception. The microcontroller 59H and 66H. These are applied to board keys are explained in the ‘Key-
(IC26) samples the signal every 400 µs. each column in turn to display a ‘3’. board Input’ box. Since the microcon-
Any transient interference that might be IC36 is a ZSM560, which produces the troller does not have a real-time clock
present is suppressed by a special soft- power-on reset pulse for the microcon- with a separate 32-kHz crystal, the
ware algorithm, which evaluates the troller. The same type of IC is used in the clock keeps relatively poor time, due to
lengths of both the pulses and the inter- transmitter circuit. the high clock frequency and the tol-
vening gaps and compares them to The current consumption of the erance of the crystal. A small trimmer
reference values. Finally, the software receiver is around 25 mA when all dis- capacitor in place of C1 can help to
computes the parity of the received plays are dark, and around 100 mA improve the situation.
data and compares this to the state of (average) to 200 mA (peak) when the (990090-1)
the received parity bit. display is operating. Here the use of a
LED matrix display devices with a small battery is not such a good idea. Design editing: K. Walraven
5×7 matrix are used for representing A 12-V mains adaptor is a suitable
the characters. Although a LED matrix
display costs marginally more than a
set of 35 separate LEDs, it is significantly
easier to handle. Since not all of the Keyboard input
matrix diodes can be driven at the
Esc: Cancel input
same time, they must be switched on
F1: Enter the time of day
sequentially using a multiplexing
F2: Enter the running text
process, which is not noticeable to the
user. Seven LEDs at most in one matrix F3: Running text only (on/off)
column, are illuminated at any one F4: Time of day only (on/off)
time. Since the eye cannot respond as Shift: Switch between upper and lower case
fast as the individual segments are Return: End the entry session and start the running text display
switched on and off, it sees an image Delete: Erase the character in the input window
consisting of 245 points (7×35).

PC TOPICS —————————————— Elektor Electronics EXTRA 9 - 2/2000


This design was originally ‘knocked together’ to test
out a prototype DAC circuit to allow the digital codes
to be entered manually. The circuit was later modi-
fied to test an opto-isolated low side switch which
required an open collector transistor driver. The final
circuit combines the virtues of both designs.

Hardware design: Adrian Grace

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

Figure 1. Circuit diagram of the byte generator.

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-

10 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS


itored is connected to K1, a series of
K5
eight LEDs connected to the open-col- 1
lector outputs of IC2 shows the circuit’s 2
status. Connector K4 allows the LED C1 D9 3

supply voltage to be selected. A link 100n


4

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

clock source — see Figure 2. CLOCK 4040 8


12 15
10 14 16
If the 8-way switch is removed (or + 9
15 17
10
ensured that all switches are open) and 1 18
11
a daughter board is plugged into K1, R1
19

the main circuit can be driven by a 8 20

4k7
clock source, rather than manually.
The external clock source is connected
to the main board via a 20-way ribbon 002005 - 12

cable. I found it easier to use a 20-way


IDC ribbon cable connection (2 × 10)
Figure 2. Optional clock extension circuit for connecting to K1 of the byte generator circuit.
even though the 10 signal lines are
doubled-up, than attempt to use a 10
way crimp connector version (1 × 10).
The cable is terminated at the clock COMPONENTS LIST COMPONENTS LIST
source board by a 20-way transition, Clock divider extension
and at the main board end in a stan- Resistors:
dard 20-way IDC connector. R1 = 8 × 4K7Ω SIL resistor pack Resistor:
The clock source itself is based around R2 = 8 × 470Ω SIL resistor pack R1 = 4k7Ω
IC1, a 74HCT4040. This is a +5 V TTL
Integrated Circuits: Capacitor:
output version of the standard CMOS C1 = 100nF
IC1 = 74LS245 or 74HCT245
4040 chip. Eight sequential outputs, Q0 IC2 = ULN2801A
through Q7 (CT0 through CT7) are fed Semiconductor:
to the ribbon cable connection whilst Miscellaneous: D9 = 1N4148
Q8 through Q11 (CT8 through CT11) are D1-D8 = 5 mm ↔ 2mm wide LED, high
not connected. IC1 is reset on power- efficiency Integrated Circuit:
K1 = 20 way IDC connector IC1 = 74HCT4040
up via R1-C1, and D9 discharges C1
on power down. K2 = 10 way SIL pin header
K3 = 11 way SIL pin header Miscellaneous:
The (TTL-level) clock source is con- K4 = 20 way DIL transition
K4 = 3 way SIL connector with jumper
nected to GND and CLOCK. Depend- 16 way turned pin DIL socket K5 = 20 way IDC
ing on the frequency required, con- 20 way ribbon cable
necting a length of wire to CLOCK may
be used as a simple clock source by
relying on mains pick-up.
(002005-1)

Article editing: Jan Buiting

Table 1. Connector pin functions

K1 pin # Function K2 pin # Function K3 pin # Function


1,2 +5V 1 +5V 1 +5V
3,4 DI-1 2 0V 2 0V
5,6 DI-2 3 D0-1 3 D0-1
7,8 DI-3 4 D0-2 4 D0-2
9,10 DI-4 5 D0-3 5 D0-3
11,12 DI-5 6 D0-4 6 D0-4
13,14 DI-6 7 D0-5 7 D0-5
15,16 DI-7 8 D0-6 8 D0-6
17,18 DI-8 9 D0-7 9 D0-7
19,20 0V 10 D0-8 10 D0-8
11 V+

PC TOPICS ————————————— Elektor Electronics EXTRA 11 - 2/2000


…and couldn’t find anywhere, you will find in this Elektor arti-
cle (and where else would you find it?). It’s a natural idea to
use a PC keyboard for developing microcomputer applica-
tions, for example, in order to send commands or respond to
specific actions. Why go to the trouble of building your own
keyboard when you can use a ready-made (and inexpen-
sive) PC keyboard? The only problem is that you first have to
know exactly what signals a PC keyboard supplies.

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

12 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS


codes and provides for communication keyboard keyboard
with the keyboard interface of the PC. DIN 5 PS-2
The keyboard controller is usually a CLK
6 5
mask-programmed microcontroller.
Data are sent and received according CLK
1 3 4 3
+5V GND
to the IBM protocol. Commands can
4 5
be used to control the LEDs, specify the 2 2 1
GND +5V
delay and rate for key repetition, and DATA
DATA
select the scan code set. The MF2 key- 002008 - 11
board has three different scan code
sets. Set 1 is used by XT/PC and PS/2-30
Figure 1. Pin assignments of the standard PC keyboard connectors (viewed from the front).
compatible computers, while set 2 is
used by AT computers and all other
PS/2-compatible computers. Set 3 sup-
ports workstations and terminal emula- (the PC). The keyboard responds by data line is at earth level. Communi-
tion on the PC. Country-specific key- sending the clock signal, and it expects cations can be blocked by holding the
board drivers in the operating system the data to be sent synchronized to the clock line Low. In this case, the key-
translate each key press into the clock signal. After the data transfer, the board holds the data to be sent in an
desired character. data line must exhibit a High level, internal buffer. The keyboard can send
When a key is pressed, the keyboard which acts as the stop bit. The key- data only if both the clock and data
produces a Make code. This code cor- board will continue to send the clock lines are at a High level. It then sets the
responds to the scan code for that key. until this condition is satisfied. Following data line Low (for the start bit) and
The repeat function causes the Make this, the command FEH is sent to request generates the clock signal. The data
code to be continuously repeated if a new data packet. Data are are valid on the falling edge of the
the key is held down long enough. The accepted on the rising edge of the clock signal and change after the ris-
delay time and repetition rate of the clock signal. After the stop bit has been ing edge.
repeat function are programmable. detected, the keyboard controller
When a key is released, the keyboard holds the data line Low for the duration In order to implement a MF2 keyboard
produces a Break code. However, if of one bit period. The keyboard connection in a microcomputer sys-
scan code set 3 is selected, no Break answers every command that it tem, you will also need to know certain
code is generated and the repeat receives, within at most 20 ms, by send- information regarding the most impor-
function is disabled. After a reset, the ing the byte FAH (ACK), except for the tant commands and return codes for
keyboard selects scan code set 2 as a ECHO and RESET commands. an AT keyboard. These are described in
default. The keyboard sends data in the AT for- the following section. The key codes,
mat to an external device using the fol- which are the codes that the keyboard
You should bear in mind that a PC/XT lowing process. produces according to the selected
keyboard cannot be programmed, Before sending data, the keyboard scan-code set when keys are pressed,
since its internal controller cannot controller first tests whether the clock or are listed in Table 1.
accept data. Only with the introduction
of the AT computer did the keyboard
become more user-friendly, since the
behaviour of an AT keyboard can be
adapted to the needs of the user via
keyboard clock 1 2 3 4 5 6 7 8 9 10 11
software. The following information
relates to a keyboard that is set to oper-
Start
ate in the AT mode. keyboard data Bit LSB MSB Parity Stop
Bit

Sending and receiving external data


Start
Bit LSB MSB Parity Stop
Bit

Figure 1 shows the pin assignments of keyboard pulling low 002008 - 12


the two commonly-used keyboard
plugs (the 5-pin DIN plug and the 6-pin
Figure 2. Timing diagram for serial data transfers between the keyboard and a PC.
PS/2 plug). The keyboard is powered
with 5 V from the PC. Its maximum cur-
rent consumption is around 200 mA.
In general, the clock rate is set by the The most important commands
keyboard. It lies in the range of 10 to
16.7 kHz. Data are sent using a start bit SET/RESET MODE INDICATORS → code EDH
(always 0), eight data bits with bit 0 first, This two-byte command controls the behaviour of the LEDs.
an odd-parity bit and a stop bit (always Command: EDH
1). Figure 2 shows the data transfer tim- Command: 0000 0xxx
ing diagram. Bit 0: Scroll lock
If an external device or system (which Bit 1: Num lock
is normally a PC) wants to send data to Bit 2: Caps lock
the keyboard, the keyboard recognizes 1 = LED on, 0 = LED off
this by the fact that the data line is
pulled to earth by the external device

PC TOPICS ————————————— Elektor Electronics EXTRA 13 - 2/2000


ECHO → code EEH SET ALL KEYS → codes F7H, F8H, F9H, FAH
The keyboard answers this command with EEH. It can be These commands assign attributes to the keys, as follows:
used to confirm the presence of a keyboard. • F7H: all keys have the repeat function
• F8H: all keys produce Make and Break codes
SCAN CODES SELECT → code F0H • F9H: all keys produce only a Make code
This two-byte command selects the scan code set. Scan • FAH: all keys have the repeat function and produce
code set 2 is selected by default after a reset. However, Make and Break codes
scan code set 3 recommends itself for microcontroller
applications, due to its simplicity. With scan code set 3, no RESET → code FFH
Break code is sent for almost all keys and the repeat func- This command restores all keyboard settings to their default
tion is disabled. values.
Command: FOH
Command: 0000 00xx
01 = scan code set 1
10 = scan code set 2
11 = scan code set 3

READING ID CODE → code F2H The most important return codes


In response to this command, the keyboard sends three
bytes which contain a manufacturer-specific code. BAT COMPLETION → code AAH
1st byte = FAH (ACK) This byte is sent to the external system after the supply volt-
2nd byte = xxxx xxxx age has been applied or a reset command (FFH) has been
3rd byte = xxxx xxxx recognized. In indicates correct execution of the keyboard
self-test.
SET TYPEMATIC RATE/DELAY → code F3H
This two-byte command controls the key repeat rate and RESEND NAK → code FEH
the delay for starting key repetition. This byte is sent in response to a data transfer error.
Command: F3H
Command: 0xxx xxxx ACK → code FAH
Bits 5 and 6 control the delay, which ranges from 150 ms to This byte is sent to the external device in response to each
1 s. received command.
Bit 6 Bit 5 Delay (± 20%)
0 0 150 ms OVERRUN → code 00H/FFH
0 1 500 ms All key presses are stored internally in the keyboard until
1 0 750 ms their codes can be serially transferred to the external
1 1 1s device. If the storage buffer overflows, the byte 00H is sent
Bits 0 through 4 control the repetition rate, which ranges for scan code sets 2 and 3, while the byte FFH is sent for
from 2 to 30 Hz. In the following table, only three values are scan code set 1.
shown as examples.
Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Frequency (± 20%) BREAK CODE PREFIX → code F0H
0 0 0 0 0 30 Hz With scan code set 2, the byte F0H is sent before the Break
0 1 1 1 1 8 Hz code.
1 1 1 1 1 2 Hz

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)

14 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS


Table 1.
The key codes produced when keys are pressed, for each of the three scan code sets.
Symbol Scan code set 1 Scan code set 2 Scan code set 3 Symbol Scan code set 1 Scan code set 2 Scan code set 3
Make Break Make Break Code Type Make Break Make Break Code Type
^ 29 A9 0E F0-0E 0E T Num 45 C5 77 F0-77 76 M
1 02 82 16 F0-16 16 T 7 Nb 47 C7 6C F0-6C 6C M
2 03 83 1E F0-1E 1E T 4 Nb 4B CB 6B F0-6B 6B M
3 04 84 26 F0-26 26 T 1 Nb 4F CF 69 F0-69 69 M
4 05 85 25 F0-25 25 T / Nb E0-35 E0-B5 E0-4A E0-F0-4A 77 M
5 06 86 2E F0-2E 2E T 8 Nb 48 C8 75 F0-75 75 M
6 07 87 36 F0-36 36 T 5 Nb 4C CC 73 F0-73 73 M
7 08 88 3D F0-3D 3D T 2 Nb 50 D0 72 F0-72 72 M
8 09 89 3E F0-3E 3E T 0 Nb 52 D2 70 F0-70 70 M
9 0A 8A 46 F0-46 46 T * Nb 37 B7 7C F0-7C 7E M
0 0B 8B 45 F0-45 45 T 9 Nb 49 C9 7D F0-7D 7D M
ß 0C 8C 4E F0-4E 4E T 6 Nb 4D CD 74 F0-74 74 M
‘ 0D 8D 55 F0-55 55 T 3 Nb 51 D1 7A F0-7A 7A M
← Back 0E 8E 66 F0-66 66 T Del Nb 53 D3 71 F0-71 71 M
|← →| Tab 0F 8F 0D F0-0D 0D T - Nb 4A CA 7B F0-7B 84 M
Q 10 90 15 F0-15 15 T + Nb 4E CE 79 F0-79 7C M
W 11 91 1D F0-1D 1D T Enter E0-1C E0-9C E0-5A E0-F0-5A 79 T
E 12 92 24 F0-24 24 T Esc 01 01 76 F0-76 08 M
R 13 93 2D F0-2D 2D T F1 3B BB 05 F0-05 07 M
T 14 94 2C F0-2C 2C T F2 3C BC 06 F0-06 0F M
Z 15 95 35 F0-35 35 T F3 3D BD 04 F0-04 17 M
U 16 96 3C F0-3C 3C T F4 3E BE 0C F0-0C 1F M
I 17 97 43 F0-43 43 T F5 3F BF 03 F0-03 27 M
O 18 98 44 F0-44 44 T F6 40 C0 0B F0-0B 2F M
P 19 99 4D F0-4D 4D T F7 41 C1 83 F0-83 37 M
Ü 1A 9A 54 F0-54 54 T F8 42 C2 0A F0-0A 3F M
+ 1B 9B 5B F0-5B 5B T F9 43 C3 01 F0-01 47 M
CapsLock 3A BA 58 F0-58 14 M,B F10 44 C4 09 F0-09 AF M
A 1E 9E 1C F0-1C 1C T F11 57 D7 78 F0-78 56 M
S 1F 9F 1B F0-1B 1B T F12 58 D8 07 F0-07 5E M
D 20 A0 23 F0-23 23 T E0-2A-E0- E0-B7-E0- E0-12-E0- E0-F0-7C-
PrtSc 57 M
F 21 A1 2B F0-2B 2B T 37 AA 7C E0-F0-12
G 22 A2 34 F0-34 34 T Scroll Lock 46 C6 7E F0-7E 5F M
H 23 A3 33 F0-33 33 T E1-12-77-
E1-1D-45- no no
J 24 A4 3B F0-3B 3B T Pause E1-F0-14-F0- 62 M
E1-9D-C5 break code break code
77
K 25 A5 42 F0-42 42 T
Insert E0-52 E0-D2 E0-70 E0-F0-70 67 M
L 26 A6 4B F0-4B 4B T
Del E0-53 E0-D3 E0-71 E0-F0-71 64 T
Ö 27 A7 4C F0-4C 4C T
← E0-4B E0-CB E0-6B E0-F0-6B 61 T
Ä 28 A8 52 F0-52 52 T
Home E0-47 E0-C7 E0-6C E0-F0-6C 6E M
# 2B AB 5D F0-5D 53 T
End E0-4F E0-CF E0-69 E0-F0-69 65 M
Return 1C 9C 5A F0-5A 5A T
↑ E0-48 E0-C8 E0-75 E0-F0-75 63 T
Shift l. 2A AA 12 F0-12 12 M,B
↓ E0-50 E0-D0 E0-72 E0-F0-72 60 T
< 56 D6 61 F0-61 13 T
PgUp E0-49 E0-C9 E0-7D E0-F0-7D 6F M
Y 2C AC 1A F0-1A 1A T
PgDn E0-51 E0-D1 E0-7A E0-F0-7A 6D M
X 2D AD 22 F0-22 22 T
→ E0-4D E0-CD E0-74 E0-F0-74 6A T
C 2E AE 21 F0-21 21 T
V 2F AF 2A F0-2A 2A T Nb = numeric block
B 30 B0 32 F0-32 32 T M = Make code when key pressed
B = Break code when key released
N 31 B1 31 F0-31 31 T
T = Typematic repeat function with delay & make
M 32 B2 3A F0-3A 3A T
, 33 B3 41 F0-41 41 T
. 34 B4 49 F0-49 49 T
- 35 B5 4A F0-4A 4A T
Shift r. 36 B6 59 F0-59 59 M,B
Ctrl l. 1D 9D 14 F0-14 11 M,B
Alt l. 38 B8 11 F0-11 19 M,B
Space 39 B9 29 F0-29 29 T

PC TOPICS ————————————— Elektor Electronics EXTRA 15 - 2/2000


. B ox
P.O 90
1 We can only answer questions or remarks of general interest to our readers, concerning projects not older than
two years and published in Elektor Electronics. In view of the amount of post received, it is not possible to
answer all letters, and we are unable to respond to individual wishes and requests for modifications to, or addi-
tional information about, Elektor Electronics projects.

the Encyclopaedia received over distances of


Britannica, Marconi’s entry up to 700 miles by day, but
reads ‘Italian physicist and at up to 2000 miles by
inventor of successful sys- night. This discovery
When Electronics was tem of radio telegraphy. prompted Oliver Heaviside,
Young (9) Received Nobel Prize for an English physicist, and
Dear Editor — in the Novem- Physics in 1909’. Similarly, Arthur Edwin Kennelly, an
ber 1999 issue of Elektor the Chambers Dictionary of American electrical engi-
above interesting series has a Scientists lists Marconi as neer, independently and
brief note on Guglielmo Mar-
‘Marconi, (Marquis), simultaneously to publish
coni that is misleading.
Marconi’s early experiments Guglielmo, 1874-1937, their prediction of the exis-
were carried out in Italy not Italian physicist and engi- tence of an electrically
England. He established that neer, pioneer of radioteleg- conductive layer in the
communication using electro- raphy’. In line with these upper atmosphere that
magnetic waves was possible two renowned publica- allows radio waves to fol-
at the age of 20 experimenting tions, I, too, have called low the earth’s curvature
at his parent’s estate near Marconi a physicist.” instead of travelling in a
Bologna. He moved to England ”Owing to the shortness of straight line as predicted
as the Italian government the article, I could not by a number of mathemati-
showed no interest in his include the fact that cians. The predictions of
invention and his English moth- Marconi had started his Heaviside and Kennelly
er felt he would be more likely
experiments in Italy. (shared) of the Nobel Prize for were demonstrated in
to achieve success in her
However, his main experiments Physics in 1909.” 1925 by Sir Edward Victor
mother country. At the time,
this country was a leading mar- were carried out in England. ”It is a debatable point whether Appleton, an English physicist
itime nation and there was no While still a physics student at or not Marconi or his fellow who, in 1947, was awarded the
means of communicating with Leghorn technical school, physicists and engineers knew Nobel Prize for Physics for his
ships once they were out of Marconi in 1894 demonstrated about the ionosphere. Michael contribution in the exploration of
sight of land. the possibility of sending wire- Faraday’s experiments in the the ionosphere”.
It was in England that Marconi less signals over a distance of a 1840s and 1850s demonstrated ”Today, we know that the ionos-
filed his patent applications, distance of some 150 metres at a clear connection between phere is a region of the earth’s
supported by the chief engineer his father’s estate near Bologna. magnetism and electricity. atmosphere at a height of 30-
of the Post office, Sir William However, since he found nobody 300 miles where short-wave
Faraday’s friend and colleague,
Preece. in Italy interested in his experi- radiation from the sun partly ion-
To call Marconi a ‘physicist’ is James Clark Maxwell, confirmed
ments, he and his Irish mother and explained Faraday’s experi- izes gas molecules and atoms,
a gross insult. If he had been a
travelled to England a year later. mental results by a mathematical leaving them positively charged.
physicist, he would be unlike-
ly to have achieved transat- There, in 1896, he demonstrated theory. Maxwell’s calculations The ionized layers reflect short-
lantic communication. The a transmission of wireless sig- showed that magnetic and elec- wavelength radiowaves, which
physicists of the day held the nals over a distance of three tric fields affect each other, and makes long-distance radio com-
view that electromagnetic miles between Flatholm Island in that light is a form of electro- munication possible. The ionos-
waves travelled in straight lines the Bristol Channel and Penarth. magnetic waves. Some tradition- phere is layered according to the
and were absorbed by land and He filed his first patent applica- al physicists adhered to the concentration of free electrons,
water. The curvature of the tion for wireless telegraphy at the belief that light was a mechanical called D and E layers (also called
ear th created a 50 mile high London Patent Office on 2nd phenomenon.” the Heaviside or Kennelly layers,
mountain of water across the June 1896. In 1897, he transmit- ”The conflict caused by depending on which side of the
Atlantic Ocean so no waves ted wireless signals over a dis- Atlantic the term is used), which
Maxwell’s hypothesis that elec-
coild possibly reach the New tance of eight miles across the result from molecular ionization,
World. Marconi with no formal tromagnetic waves are propagat-
Bristol Channel. This experiment ed at the speed of light lasted for and the upper layer, termed F
education ignored the ‘experts’
drew the attention of Sir William many years, until in 1888 layer or Appleton layer, which
and was successful. Neither
the physicists nor Marconi Preece, the chief engineer of the Heinrich Hertz, Professor at the results from atomic ionization.
knew about the existence of the post office, as well as of the Technical College in Karlsruhe, The thicknesses of the layers
ionosphere which convenient- Press. In 1899, he transmitted finally closed the debate on the vary with latitude, season, time
ly reflected his waves from Morse code across the English wave character of light. He of day, and solar activity”.
Poldhu to St. Johns. Channel, which attracted atten- demonstrated that the electric ”Since much of the research into
Beware of experts! tion from the Admiralty, resulting sparks produced by him caused propagation was going on and
Guy Selby-Lowndes in the installation of radio wire- electrical vibrations which were published while Marconi, Braun,
less equipment on Royal Naval propagated into space at the Slaby, and Arco, were conduct-
Our contributor replies as fol- ships. In 1901, he transmitted ing their experiments in England
speed of light.”
lows. across the Atlantic from Cornwall and Germany, it is extremely like-
”During a cross-Atlantic trip,
”Interpretation of certain aspects to Newfoundland. His pioneering ly that they read about it.”
Marconi had already noticed that
of history can be contentious. In work was rewarded by the award telegraph messages could be

Elektor Electronics 2/2000 11


RADIO, TELEVISION & VIDEO

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-

Elektor Electronics 2/2000


16
wave band like 10 metres (28 MHz). BF494
9V
L1 L3 L4
Provided you use a good directional
antenna (like a yagi) you should be
1 C20 C21 C22
* *
100n 10µ 100n
able to pick up the CW idents of low- 63V
0µH22
power beacons as well as CW and C9

SSB signals from stations far beyond C B R1


L2
R3
10p
the range of NBFM. E

150k

180k
9V0

WHY A CONVERTER? * zie tekst


6V0 T1
0µH33 C6
T2

9V2
Many beginners to the radio hobby
start will start out with a second-hand
* see text C3
BF494
10p
BF494 100mV t t

shortwave receiver. This will typically * siehe Text C1 X1


10p 0V7

be a general-coverage type for * voir texte 22p


C2
R2
7V3
C4
C5 C7 C8
CW/USB/LSB/AM/RTTY reception

2k2
between 150 kHz and 30 MHz. The 27p 15p 40p 22p 22p

Yaesu FRG-7 is an excellent example of


X1 = 38.667MHz
such a receiver, and although its design 9V
is 25 years old, it is still in popular
BFR91 +9...12V
demand in the radio amateur trade. B C
The same beginners will also lack the 20mA
L8
funds (and a licence) to buy an C23
R5 R7 R9
C24
R10 R11
C25

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

the receiver (or converter)


000013 - 11
input. Whatever low-noise pre-
amplifier you may have in Figure 1. Circuit dia-
mind, experience shows that it gram of the 2-to-10-m
is beaten hands down by a inductively coupled converter. frequencies at 116–28
good antenna in an elevated (via L4) to the mixer. = 88 MHz and at the
position. same time match the
Following a well-established Mixer transistor to the cable impedance of
tradition in ham radio, the pre- The mixer in the converter is a type 50 Ω. The amplified signal is capaci-
sent converter mixes the 2- BF961 dual-gate MOSFET, T4. The local tively coupled to gate 1 of the mixer
metre band signals down to the oscillator signal is applied to gate 2 (G2) via C13.
10-metre band (28.0-29.7 MHz). and the RF input signal, to gate 1 (G1).
Note that G2 is held at a fixed potential Output stage
HOW IT WORKS of about 2.9 V by R6-R7, while G1 is dc- The main function of the driver stage
The circuit diagram of the 2- wise at ground potential. This is the around T5 is to provide a good match
metre band converter is given traditional configuration, with the G2 to the receiver input (50 Ω). The gain of
in Figure 1. As you can see it resistors determining the conversion this stage is made adjustable with pre-
employs only five active com- gain. The mixer products are available set P1 to ensure that no overdriving
ponents, and these are all of the at the drain of the BF961. These prod- occurs with sensitive shortwave
common or garden variety. ucts are, in principle: 144+116 = receivers.
The design consists of four sections, 260 MHz, 144–116 = 28 MHz and the
a local oscillator, a mixer, an input LO signal residue at 116 MHz. The The converter is powered by a regu-
stage, and an output stage which will combination L8/C16/C17 is tuned to lated and well decoupled supply with
be discussed separately below. 28.8 MHz and serves to suppress the an output of between 9 and 12 volts.
116 MHz LO component — given the Current consumption will be of the
Local oscillator (LO) frequency difference between these order of 20 mA.
Transistor T1 and quartz crystal X1 are components sufficient suppression is
configured as an oscillator with an out- not hard to achieve. CONSTRUCTION
put frequency of 38.667 MHz. The crys- The converter is built on a single-sided
tal operates in third-overtone mode. Input stage printed circuit board of which the
Trimmer C1 is available to net the oscil- The signal from the 2-metre antenna design is shown in Figure 2. This board
lator. The oscillator output signal is fed is inductively coupled to the base of is available ready-made through the
to frequency tripler T2 whose collector T3, a low-noise VHF/UHF transistor Elektor Electronics Readers Services.
circuit is tuned to 116 MHz by L3 in type BFR91. The input inductor pair Before you start soldering away we
combination with trimmer C7. The L5-L6 is accurately tuned to 144 MHz recommend you make inductors L3-
local oscillator signal has a level of by trimmers C10 and C11. The input L7. This is not at all difficult. Take a pen
about 100 mV peak to peak and is bandfilter serves to suppress image or a drill bit with a diameter of 4.5 mm

Elektor Electronics 2/2000 17


C3 C5 C7 Figure 2. Copper track layout
H7

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

18 Elektor Electronics 2/2000


amateur). Peak C10, C11 and C14
for best reception. Reduce the input
3 signal as required to ensure you can
to
2x
multimeter always find a peak.
BAT82 10n 7. Adjust C1 so that the frequency
6p8
readout on the receiver matches the
signal frequency, for example,
144.800 MHz = 28.800 MHz.
8. Remove the input signal and adjust
P1 so that the S meter on the
3mm large felt pen
welding wire receiver just starts to deflect.
BAT82 9. Tune to a weak signal in the 2-m
10n
to band and carefully adjust C10, C11
6p8 multimeter and C14 for highest S-meter indica-
BAT82
tion.
000013 - 12
That concludes the adjustment of the
Figure 3. Build this converter.
simple RF probe and
course) in which a small adjusting the con- the cold side of L4 and WEATHER-SATELLITE
diode detector is verter will be a breeze. peak C8. Use the first BAND
housed. The end of the peak starting from fully By changing the LO injection fre-
copper or welding wire meshed. If not, you quency to 109 MHz, it should be possi-
is carefully filed down to give a sharp tune to fosc × 4 instead of fosc × 3. ble to use the converter for reception of
tip. The choice of diode is not critical. 4. Set C10, C11 and C14 to half mesh. low-orbiting weather satellites in the
While SHF diodes like the 1S99 will 5. Tune the receiver to 28.800 MHz 137 MHz band. A quartz crystal of
enable measurements well into the and adjust C16 for maximum noise. 36.333 MHz (again, 3rd overtone) is
GHz range, the run-of-the-mill BAT82 6. Ensure that a relatively strong input then required, as well as readjustment
will be fine for VHF circuits like the signal is available on a frequency of all trimmers for the slightly lower
present converter. between 144.800 and 145.000 MHz frequencies.
The probe is only intended to give (RF generator or ask a local radio (000013-1)
relative indications, providing an easy
means to ‘peak’ inductors on their res-
onance frequency. It will only lightly
load the tuned circuit and does not
require a ground connection. The out- Band plan for 144 –146 MHz
put voltage is fed to the inputs of a
voltmeter — preferably analogue so (IARU recommendation)
you can see the ‘trend’. In this case,
needle movement on an antique mov- 144.000 – 144.500 MHz
ing-coil meter is rather more useful Reserved for DX traffic. Some important sub-bands:
than rolling digits on a DVM. 144.000 – 144.025: EME (earth-moon-earth or ‘moonbounce’)
144.050: CW calling
ADJUSTMENT 144.100: Meteor scatter in CW
Start by setting all trimmers on the 144.150: CW DX
board to full mesh, except C1, which is 144.300: SSB calling
set to mid-travel. Connect the con- 144.400 – 144.490: Beacons
verter to the receiver and switch on 144.490 – 144.500: Beacon guard band, no transmissions
the power supply. Set P1 to the centre
of its travel. Measure the current con- 144.500 – 144.800 MHz
sumption. If it as expected, proceed All modes, including
with the adjustment procedure
144.500 SSTV calling
described below. “Hot” means carry-
144.600 RTTY calling
ing RF, “Cold” means not carrying RF,
144.700: FAX calling
i.e., ground or positive supply. “Peak” 144.750: ATV calling
means adjust for maximum reading
on the voltmeter connected to the 144.800 – 144.990 MHz
probe, or for maximum S-meter read-
ing on the receiver. In case of the Digital modes (Packet Radio)
probe, the absolute value you measure
145.0000 – 145.1875 MHz
is irrelevant, it’s the peak you should
be looking for. Repeater input frequencies (12.5 kHz raster, shift 600 kHz)

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

Elektor Electronics 2/2000 19


AUDIO & HI-FI

infrared remote control


for Sony MZ-R30 MiniDisc Walkman
a useful add-on for a popular player

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

Elektor Electronics 2/2000


22
Figure 1. Modification to
the remote control cable 1
supplied with the Sony 3 2

MD MiniDisc walkman. XLR Free


4 5 1 Socket (Rear)

works well up to 100ft, but is slow to Remote Pod connections:


respond (5 seconds) and only allows 1 wht Right Channel 4 1
2 yel Ctl Pin 4
for the one function, in this case 3 gry Ctl Pin 2
3 2 5

“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,

REMOTE CABLE R3 R4 CODE FUNCTION


MODIFICATIONS 3 Bt1
2Ω2

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)

fairly thin wires, stripped from some 2


A1
3 14
multicore cable, and a length of 3 mm 4
A2 IC1 TE

heatshrink sleeving, with a mini XLR 5 5


A3
HT12A 13 D1 D5 D8 D11 D13 D15 D17 D20
A4 AD11
pin plug at one end and the old remote 6
A5 AD10
12

control pod on the other. This enables 7


A6 AD9
11
8 10 D2 D6 D9 D12 D21 D24
normal cable remote functions to be A7 AD8

made via this ‘adapter cable’. The con- OSC2 OSC1


9 15 16
struction is illustrated in Figure 2. R5 D3 D7 D14 D18 D22 D25
10M
S11
HAND HELD D4 D10 D16 D19 D23
TRANSMITTER
C2 C3 "Shift"
The circuit diagram of the hand held X1
S1 S2 S3 S4 S5 S6 S7 S8 S9 S10
control box is given in Figure 3. The 100p 455kHz 100p

key component is a Holtek HT12A


"0" "1" "2" "3" "4" "5" "6" "7" "8" "9"
remote control encoder chip. The (con-
densed) datasheets of this interesting D1 ... D25 = 1N4148 990075 - 13
and versatile chip appear elsewhere in

Elektor Electronics 2/2000 23


IC3a 1
LP2950CZ5.0
D2 13
1N4001 IC4 5V
R6 2
IC5d 9

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

BC550 5V IC3, IC5, IC6 = 4016


1k

R9 16 C6 14 C7 14 C7 14
1k3

SFH505A SFH506 IC2 IC3 IC5 IC6


IS1U60 IC5b 3 IC5c 10 IC3b 3 8 100n 7 100n 7 100n 7
R21
R10
5 12 5

680Ω
1k3

4 11 4
990075 - 14

Figure 4. Circuit dia-


gram of the remote con-
trol receiver/decoder.

24 Elektor Electronics 2/2000


IC6) in conjunction with a resistor net- decoder IC which latches the original appropriate point on a resistor ladder
work (R7-R20) offers a simple and 4 bits of data. This data is then pre- to be used by the MZ-R30 for the
cheap method of selecting the required sented to a BCD/Decimal decoder selected function. The condensed
resistance value. (IC2, 4028) which selects one of nine datasheet of the HT12D IR decoder
A Sharp IS1U60 IR receiver IC a n a l o g u e
detects the IR carrier and its output is switches. These Figure 5. PCB copper track layouts and component over-
inverted by T1 and fed to the HT12D in turn select the lays. Cut the board to separate the transmitter (below)
and receiver (top) section.

COMPONENTS LIST 990075a R12


5

JP2
R8 R9 R7 R14

H1
H2

Receiver/decoder R18 R19 R13

test
(Board section 990075a) R10 R17 R16 R15
T2

R11
R4

ROTKELE )C( a570099


D3
Resistors:

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:

990075a (C) ELEKTOR


C1 = 2µF2 25V radial
C2 = 4µF7 16V radial
C3-C7 = 100nF

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

(Board section 990075b)


C1

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

C1 = 100µF 16V radial


D1
D7

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

S1-S11 = pushbutton, PCB mount,


Multimec or D6-R-RD
BT1 = 2 off AA or AAA penlight
battery
X1 = ceramic resonator, 455kHz
(e.g., SB455E) (Mainline, 0870 241
0810)

Elektor Electronics 2/2000 25


remote control input of the MD30-RZ
via a short cable.
The function of the test jumper, JP2,
is discussed further on.
The receiver/decoder may be pow-
ered by just about any wall adaptor
capable of supplying 8-12 V DC at
about 100 mA.

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

26 Elektor Electronics 2/2000


GENERAL INTEREST

parameter box for


MIDI software
convenient software synthesizer operation

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.

Elektor Electronics 2/2000


28
5V
K4
1 R3 R4 R1

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

Figure 1. The microcontroller reads the


status of the switches and of each of
the eight potentiometers in turn.

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

Elektor Electronics 2/2000 29


Table 1. Contents of the six layers within the three super-layers.
Layer P1 P2 P3 P4 P5 P6 P7 P8
super-layer 1 (AWE, EMU8000 and EMU10k-1 synthesizers)
layer 1 Controller 10 – 17
layer 2 Controller 18 – 1F
layer 3 volume pan expression modulation LP cutoff LP reson. chorus reverb
layer 4 LFO1 delay LFO1 freq. LFO1 pitch LFO1 vol. LFO2 delay LFO2 freq. LFO2 pitch LFO2 vol.
layer 5 env1 delay env1 attack env1 hold env1 decay env1 sustain env1 release env1 pitch env1 cutoff
layer 6 env2 delay env2 attack env2 hold env2 decay env2 sustain env2 release -, -
super-layer 2 (XG synthesizer)
layer 1 Controller 10 – 17
layer 2 Controller 18 – 1F
layer 3 volume pan expression modulation portamento reverb chorus variation
layer 4 attack decay release vib. delay vib. rate vib. depth cutoff resonance
layer 5 pitch init pitch attack pitch rel. p.r. time vel. lim. L vel. lim. H -, -
amplitude LFO PMOD FMOD D
layer 6 pitch ben. filter ben. ben. ben. AMOD
ben.

super-layer 3 (software synthesizer)


layer 1 Controller 00 – 07
layer 2 Controller 08 – 0F
layer 3 Controller 10 – 17
layer 4 Controller 18 – 1F
layer 5 Controller 20 – 27
layer 6 Controller 28 – 2F

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

Table 2. Meanings and uses of all switches.


Component Designation Meaning
Message Blinks when a MIDI message is sent via the MIDO OUT port.
LED D2 MIDI Message
Also blinks when a potentiometer is set exactly between two quantization levels.

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.

Pushbuttons S1 – S6 Layer These switches select layers 1 through 6.

Pushbutton S7 Memo Save the last modified value in the current layer.
Pushbutton S8 Reset Overwrite the current value with the predefined initialization value.

30 Elektor Electronics 2/2000


C15 C16 D1 D2
COMPONENTS LIST P9
R2
2

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

100nF 990087-1 C13 K4 IC3


C9,C13,C17,C19 = 10µF 63V radial
C15,C16 = 33pF

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

Elektor Electronics 2/2000 31


3

0 127 0 127 0 127 0 127


1 3 5 7

0 127 0 127 0 127 0 127


2 4 6 8
MRPC MIDI INIT
DATA VALUE
MIDI REMOTE PARAMETER CONTROL
CHANNEL LAYER
-

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.

32 Elektor Electronics 2/2000


KIT DESCRIPTION

flashing LED sweetheart


an original Valentine present
A small effort and an even smaller outlay is
required to throw an electronic gadget together
that’s sure to make a great gift for Valentine’s Day.
Belgium-based Velleman are suppliers of kits that
enable this type of circuit to be built by the
masses. We decided to try out one of their kits.

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

the latest high-spec complex devices,


probably because to them the latter will
9V LD2 LD8 LD11 LD13 LD20 LD24 LD25
forever remain big electronic mysteries.

A L OV E LY F L A S H E R
LD1
R2
LD12
R4 R5 R6 R7

Most Summer Circuits and December


1k2

1k2

1k2

1k2

1k2

issues of Elektor Electronics contain at C1 C2


least a few ‘playful’ electronic circuits.
Some kit suppliers go one step further, 22µ 22µ
T1 T2
having discovered a market for such
products.
In the recent Maplin catalogue, we
BC547B BC547B
came across a Flashing LED Sweet- 000031 - 11
heart from kit supplier Velleman. This

Elektor Electronics 2/2000 33


electronics on-line
on line
Nick’s hardware area
InfoDesk on electronics
Electronics enthusiasts spend a
lot of time just looking for all sorts
of data: resistor colour codes,
schematics for various applica-
tions, connector pinouts or per-
haps a description of DIY circuit
board etching. Well, Nick’s web-
site has it all nicely bundled.
Practical and useful!

Nick’s real name (we are informed) is Nicola Asuni and he


lives on Sardinia. The website he built contains data that
every electronics enthusiast or professional may need for
everyday work. Starting from the homepage:
(http://www.nickhardware.da.ru) you may choose between var-
ious departments (some of which having their own address):
• Circuits (www.circuits.da.ru)
This is a collection of small circuit diagrams for miscellaneous
applications, subdivided into these subjects: infrared, tele-
phone, sound, Smartcard and filters. The last subject is cov-
ered in great depth.
• Pinouts (www.pinouts.da.ru)
We reckon Nick has one of the largest overviews of connector
pinout (i.e., connection data) on the entire Internet. Even if
there are more massive sites, Nick’s list is pretty impressive to
say the least. A true galaxy of extremely common but also odd-
ball connectors, cable links and adaptors may be found here.
• Guides
This department contains a number of manuals covering sev-
eral aspects of home-brew electronics such as DIY circuit
board etching, a course in soldering, SI and derived units,
tables, passive component colour codes and a piece on elec-
trical safety.
• News
A section covering the latest in electronics, but heavily com-
puter-inclined. This page is frequently updated.
• Links
This section presents a list of other websites with useful infor-
mation. The list is divided in computer/electronics links and
links to various design standards.

On Nick’s website you may also find lots of software down-


loads including C++ programs and program manuals writ-
ten by Nick himself.
A search engine is available on the on this website if you are
after information on a certain subject.
As an aside, Nick is an active athlete and he is even a
member of the Italian sprinters’ team. Thic subject, too, is cov- a hobbyist. This address certainly deserves a prominent place
ered in some depth on his website. in your Favourites folder!
Nick’s hardware area is a valuable asset for everyone (005013-1)
actively involved in electronics, both professionally and/or as Text (Dutch original): H. Baggen

Elektor Electronics 2/2000 35


MICROPROCESSORS

BASIC Stamp
programming course (6)
Part 6: introducing the FSM concept
By Dennis Clark quarters < 2
45 select = none
quarters = 2

The Parallax Boe-Bot, or Board of Edu- 0 1


cation Robot is a simple robot made Get two Get selection
from a Parallax Board of Education quarters select = Fanta
(BoE) mounted on an aluminium
frame to which two Futaba hobby ser-
vos are mounted. These servos have select = Coke select = Barq's
been modified to provide continuous
motion and have several speeds at 4
2
which they will turn.
Deliver Coke
The BoE has a small prototyping Deliver Fanta
area on which several experiments can
be done. In order to realize the fasci-
nating potential the BoE-Bot has to 3
demonstrate robotic behaviours, you Deliver Barq's
will need to know how to program it!
In this and the following instalments I
will explain how to
make the robot move Figure 21. Finite State 990050 - 6 - 11
randomly, or pur- Machine design for a
posely, how to seek out soda machine.
or avoid bright light
and how to avoid
objects. I will also explain how to pro- routines that will be called many times ple, we will create a pretty stupid
gram your BoE-Bot in such a manner before their function is complete. In machine with these abilities:
that all of these functions seem to be order to do that, you will need to keep ➧ takes only quarters
operating at the same time. track of where you are in your subrou- ➧ needs two quarters to get a soda
Further, I will show you can get tine so that you know where to start ➧ will not give you your money back
behaviours from your robot that you up again when you return. One very ➧ does not give change, nor return
didn’t even program in to it! good way to do this is called the Finite money that isn’t a quarter
State Machine or FSM for short. Because ➧ has Coke, Barq’s Root Beer and Fanta
LINEAR EXECUTION VS. there are only a few different actions Orange soda
CONCURRENT EXECU- you want your subroutine to execute, ➧ has an infinite amount of soda and
TION AND THE FINITE and it does actually complete its job at never runs out
STATE MACHINE some point, it is a finite list. There are
In a program, each statement is exe- several forms of FSMs, this type of As you can see, we have eliminated all
cuted in sequential order, the next FSM is a hybrid we will use specifically of the exceptions or error conditions that
statement cannot start until the last one for robotic programming. This behav- a normal soda machine could see in
is done. When there is only one thread iour FSM is a type of a state machine order to simplify this explanation — it’s
of logic running, this means that the that returns no outputs, it merely artificial for a reason; we’re not design-
program proceeds in a linear fashion, changes state based on input and the ing soda machines. However, do pay
from start to finish. Concurrent execu- current state. Each activity that the attention to exceptions and error condi-
tion is when there is more than one FSM engages in, is a state, unique in tions when you are designing your
thread of logic running at what operation and distinct from all other own FSMs! Figure 21 shows a graphical
appears to be the same time. ”How do states by its definition. rendering of our soda machine FSM.
I do that?”, you may ask. In the Paral- If this is difficult to understand, lets The underlined numbers in each of the
lax Basic Stamp II processor you can do use a sort of real world application to circles are the state number for that
this by using independent sections of explain FSMs, the soda machine. In state. A line with an arrow denotes a
code, called modules or in our case, sub- order to keep our soda machine sim- transition from one state to another (the

Elektor Electronics 2/2000


36
Listing 9. Linear vs FSM programming

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

Elektor Electronics 2/2000 37


to go and call act to implement it motors instead of wasting that time time to its environment. In the case of
with a pause instruction! In effect, this the act subroutine above, this results in
Many of these behaviours will tell the makes it look like everything is hap- a smoother motor response and
motors to perform some action; back- pening at the same time instead of one quicker reaction to obstacles and objec-
ing up, turning left, whatever. Each of thing after the other. If we were to use tives.
these behaviours will need to refer to a linear programming model instead of Before using the Finite State
sensors in order to perform their Finite State Machines to implement all Machine method of behaviour imple-
actions. Each of these behaviours of our behaviours and actions then we mentation I would notice that my
(using the system I am suggesting) will would not be able to look at the com- robot would appear to hesitate longer
be Finite State Machines implemented pass or check for an obstructing object and longer as I added more and more
in subroutines that will be called from until all 230 ms in the code snippet on complex behaviours. This FSM method
within some main code loop (you will the left had completed. In that time our will all but eliminate this hesitation. It
see some of these behaviours defined robot might miss seeing the chair in is more complex to design and code
later on). In the motor driver routine front of it and collide with it before it than linear programming, but the
act shown as the right side code snip- gets a chance to change direction. results, I feel, merit the complexity. Try
pet there is a variable aDur defined. There is nothing special about the programming your robots both linearly
When the act FSM is first called aDur is number 5 chosen for aDur either, I used and using FSMs, I think you will agree
set to 5. This means that the pulsout that number as a suggested starting that using Finite State Machines
instructions will be executed once, then point. In reality this number is chosen improves your robot’s abilities and
the next 5 times the act subroutine is by trial-and-error to achieve the allows us to get as much out of our
called it will do nothing but decrement smoothest timing. I started with this Stamp II as we can! Eventually a set of
aDur and exit. This means that it will number in my own robot and as I behaviours may become so complex
spend as little time in the subroutine as added behaviours I reduced it. For that even using FSMs will not prevent
possible. Why is this useful? It is useful example, with four behaviours active I some hesitation, but we can do much
because act only needs to send those have my act routine set aDur to only 2. more using FSMs as our programming
pulsout actions once every 20 to 30 ms. When we implement all of our model rather than linear programming
Our robot can be looking at sensors behaviours as FSMs this has the effect before that happens.
and selecting the next motor action of interleaving the code that needs to (990050-6)
while it is waiting to send that next be executed in each subroutine so that
series of pulses out. In this way, we use no one behaviour needs to wait until Next month we will continue with a method
the time it takes to read sensors and the prior behaviour completes in order called Subsumptive Programming which will
make decisions in those other four sub- to do at least some of the work that help us develop a step-by-step plan to implement
routines as the delay we must take needs to be done in its own routine. robotic behaviour.
between pulses we send to the servo This improves our robot’s response

38 Elektor Electronics 2/2000


MICROPROCESSORS

BASIC-537
a high-level language for the
80535/537

The most commonly


used dialect of
BASIC for microcon-
trollers, Intel’s
8052AH-BASIC, can-
not be used as is
with the new 8051
derivatives. This arti-
cle presents a modi-
fied version of the
interpreter that also
supports the
80535/537 microcon-
trollers. These have
been used in recent
Elektor projects,
such as the 80C537
Single-Board Com-
puter and the 537
‘Lite’ computer. The Intel BASIC-52 interpreter was tion of the original IC.
originally provided in the form of a However, anyone who has tried to
mask-programmed microcontroller use a BASIC-52 interpreter in EPROM
with the type designation 8052AH- in an 80535 or 80537 system has experi-
BASIC. The interpreter automatically enced a bitter disappointment. The ini-
recognises the amount of available tialisation routine for the serial interface
RAM and the baud rate of the con- uses properties of the 8052 that have
nected terminal when the system starts not been passed on to the 80535 in
up. There are also Autostart functions exactly the same form. The culprit is
that allow a program to be run auto- Timer 2, which is not compatible with
matically on start-up. It is even possi- the 8052.
ble to program an EPROM in the sys- The new processors can however be
tem, as long as you use the original used if the reset routine is modified.
Intel IC. The 8052-BASIC interpreter has provi-
The 8052AH-BASIC IC is no longer sions for a custom reset routine and for
produced. However, the program has adding new user-developed instruc-
been released for public use, so it can tions. We could thus write modifica-
now be used legally in an EPROM. If tions that work with the new micro-
you combine this with an 80C32 micro- controllers. In particular, the modified
processor, you have a low-power interpreter supports the Elektor 80537
BASIC system. The only thing that you Single Board Computer as well as the
Design by B. Kainka lose is the EPROM programming func- new 537 ‘Lite’ computer.

Elektor Electronics 2/2000


40
80C537 Single Board Computer This is a combined terminal emulation that is already in the microcontroller
➧ IC2 holds the BASIC-537 and editor program that is specially are not overwritten by new lines
designed for the BASIC-535 interpreter. unless the new lines have the same line
EPROM
The diskette also holds an instruction numbers. This means that you can
➧ IC4 holds a 32-kB RAM summary file (BASIC52.HLP), an ini- stock a collection of subroutines that
➧ IC5 and IC5 remain unused tialisation file (SBASIC.INI), the binary can be downloaded as needed. In
➧ all 6 jumpers of J1A are con- file of the EPROM contents order to start from scratch, enter NEW
nected to J1C (stand-alone (BASIC537.BIN) and sample programs before downloading a program.
mode) with the extension BAS. You can load a program via the
File/Open menu. First you should use
Program/Break to stop any program that
537-Light computer THE PROGRAM EDITOR is already running, and then use Pro-
➧ J7:1—2 (12 MHz) When BASIC.EXE is first started, it is gram/New to delete it. The text of the
➧ J1A– J1C: 1—2 (stand-alone set up to use COM2. A different port program will appear in a new editor
operation) can be selected via the Options/RS232 window, and in the terminal window
➧ switch S1: RUN menu. The selection is saved in the file as well if the interpreter was ready.
SBASIC.INI when you quit the pro- Several editor windows may be open
gram. simultaneously, which allows program
Table 1. 80537 com- When the microcontroller board is sections to be copied back and forth.
puter board settings switched on, the BASIC-537 interpreter
sends its start-up message. You can INSTRUCTION SUMMARY
then enter the first program and run it. The most important instructions and
The sample program Test1.bas outputs functions of BASIC-537 are listed in
data to port P1 and uses the original Table 2. Numerous special functions
The modified interpreter, which we call BASIC-52 instruction PORT1: have been adapted to the environment
BASIC-537, has the following features: of the microcontroller. Some of the
10 REM Port outputs original BASIC-52 instructions cannot
9600 baud data transfer rate 20 FOR N=0 TO 255 be used with the extended version and
with a 12 MHz clock 30 PORT1=N are not shown. Four new instructions
32kB RAM 40 FOR I=1 TO 200 : NEXT I have been specially added for the
6 new instructions 50 NEXT N 80537.
direct A/D converter polling 60 GOTO 20 The measurement range of the
LCD support (address FFCOh) RUN twelve possible analogue inputs is 0 to
Autostart function +5 V, but this can be modified within
BASIC.EXE has two text windows. A wide limits using the instruction
The BASIC-537 interpreter occupies text editor with many editing functions DAPR, which writes a parameter byte
the EPROM memory region from runs in the upper window. The lower to the processor register with the same
0000h to 403Fh, and also requires 32 kB window displays all the characters name. A one-byte control parameter
of RAM starting at address 0000h. A received from the microcontroller. can be specified for each measurement.
few jumper settings must be changed Every time that <Return> is pressed Its two 4-bit nibbles set the upper and
on the 80537 boards, as shown in in the editor, the complete line is sent lower limits of the range. Bits 0–3 set
Table 1, to ensure that the address to the microcontroller. the lower limit in units of (5 V/16), and
regions are properly configured. The echoed characters appear in the bits 4–7 set the upper limit in the same
In principle, any available terminal terminal window. You can edit each way. These two reference voltages
emulator program running at 9600 line as much as you wish before it is must have a minimum separation of
baud can be used with the BASIC-537 transferred. This also applies to lines 1.25 V. For example, a parameter value
interpreter. After the system is that appear earlier on in the text and of 84h sets the measurement range to
switched on, the interpreter announces that you want to modify after the fact. 1.25–2.5 V. The value 00h is an excep-
itself with the following start-up mes- In the terminal window, you can see tion; it sets the range to 0–5 V.
sage: whether each line has been accepted or The instructions SFR and WrSFR
has caused an error message to be allow all of the special hardware func-
MCS-51(tm) BASIC V1.1 / ES537 returned. Alternatively, you can acti- tions of the 80C537 to be used. They
READY vate the terminal window and use it provide access to both serial ports, the
> for entering text, which will be trans- timer, all supplementary ports and so
ferred a character at a time. on. Providing free access to all special-
You can now enter lines of BASIC code The program’s special functions can function registers presents a special
in the usual manner. Each character is be called up using the Program menu. challenge to an interpreter, since all
sent back to the terminal via the serial These are the RUN, LIST, BREAK, 8051 derivative ICs allow only direct
interface. Each time a Return character CONTINUE and NEW instructions for addressing (via an instruction such as
is received, the interpreter converts the the interpreter in the microcontroller, mov 90h, A). The SFR address thus
complete line into its internal token and CLS, which clears the terminal cannot be passed via another register.
format and stores the tokens in the window. You can use LIST to fetch a A compiler has no problem with this,
RAM. The program can be started by finished program and display it in the since it hard codes the address, but an
typing RUN, and it can be interrupted editor window, and then to save it to interpreter must be able to pass the
at any time by pressing Ctrl-C. Typing disk. address. This difficulty is probably the
LIST sends the complete program list- Naturally, instructions such as NEW, reason why the original BASIC-52
ing to the terminal, and typing NEW LIST, RUN and so on can be entered interpreter allowed free access to the
clears the memory. directly from the keyboard, the same as internal RAM, the external RAM and
Instead of a simple terminal emula- program lines. For testing, direct even the program region, but not to
tor, you can also use the Windows pro- queries such as PRINT PORT1 can be the special function registers. Since a
gram BASIC.EXE, which is found on used. A special feature of the overall 32-kB EPROM has enough room for
the same diskette as the interpreter. system is that code lines of a program the necessary extensions, an indirect

Elektor Electronics 2/2000 41


Instructions approach can be used. There are two
RUN Ctrl-C CONT LIST NEW small subroutines for reading and writ-
ing every address in the range from
Operators 128 to 255. When the interpreter
+ - / * = > >= < <= <> .AND. .OR. .XOR. ABS() NOT() INT() SGN() encounters an SFR or WrSFR instruc-
SQR() RND LOG() EXP() SIN() COS() TAN() ATN() tion, it calculates a jump address that
leads to the proper subroutine. The
Statements extended interpreter is thus prepared
for microcontrollers that haven’t even
CALL DATA READ RESTORE DIM DO-WHILE DO-UNTIL END FOR-TO-
been invented yet.
STEP NEXT GOSUB ON-GOTO ON-GOSUB IF-THEN-ELSE INPUT LET
The text file Sample Programs, which
ONERR PRINT REM STOP
is also located on the diskette, contains
programs that illustrate the use of the
Extended BASIC-537 Statements
specific instructions of the interpreter.
ONEX1 subroutine call following Interrupt 1
ONTIME timer interrupt call LCD CONTROL
RETI end of an interrupt subroutine BASIC-52 allows serial interface out-
PH0., PH1. output a hexadecimal number with/without leading zeros puts to be redirected to a different out-
PUSH, POP move data to/from the argument stack put routine. This capability is used in
STRING reserve memory for a text string the BASIC-537 interpreter to drive a
IDLE wait for interrupt liquid-crystal display. The display is
largely addressed using normal
Special function operators and system variables instructions. Only the instruction for
CBY() DBY() XBY() GET IE IP PCON T2CON TCON TIME TIMER0 TIMER2 initialising the LCD (LCDINIT) and the
PI XTAL MTOP LEN FREE instruction for setting the character
location (CURSOR) have been added.
80C537 I/O handling The new 537 ‘Lite’ computer (Janu-
AD (channel) [read-only] C = AD (0) analogue input (0 – 5V) at the ary 2000) has an interface for an LCD
AD0 input module. This is located in the address
C = AD (11) analogue input (0 – 5V) at the space starting with address FFCOh.
AD11 input The display is initialised using the new
DAPR [write-only] DAPR = 128 switch the measurement instruction LCDINIT. After this, there
range to 2.5 V are several ways to output characters
SFR [read-only] print SFR (90H) reading special function reg-
isters
WrSFR [write-only] WrSFR 90H,255 writing special function regis- Table 2. Summary of
ters BASIC-537 instructions

42 Elektor Electronics 2/2000


to the display. The desired character so on than the 80537. tion of the extended BASIC interpreter
position can be specified using the Intel’s BASIC-52 interpreter expects makes its presence known. This can be
CURSOR instruction. The PRINT@ to find data RAM starting at address seen if a reset is executed while power
instruction writes directly to the dis- 0000h. The new initialisation routine is still applied. In this case the program
play. A sample program is available on does not change this. However, the that is already present starts immedi-
the diskette or from the Elektor web- 80535 Single Board Computer divides ately after the reset. This is a quite use-
site. its 32 kB of RAM between the address ful feature during program develop-
A program can send its outputs to ranges 4000h–7FFFh and ment. Instead of entering Break and
the terminal emulator using PRINT, or C000h–FFFFh. Special logic allows the then Run, you can simply press the
to the LCD using PRINT@, as desired. RAM in these regions to be used to Reset button.
All output data can be formatted with store program code as well as data. An additional difference can be seen
the USING instruction. However, the The necessary changes are quite in the fact that it is possible to use a liq-
line feed function has no effect on the simple. Remove IC2 (a quad NAND IC, uid crystal display. The ’535 computer
LCD. This means that the CURSOR type 74HC00) from its socket and does not have any decoding logic for
instruction should be used as much as replace it with three small wire bridges, the LCD, so you will have to either
possible to specify the desired location as follows: build some extra circuitry or else con-
of the output data. Various types of nect the LCD to a port and use the 4-
LCDs can be used, with one, two or pin 3 to pin 4 (OE direct to RD) bit mode. The display can be driven by
four lines. The sample program pin 11 to pin 12 (CE direct to A14) a somewhat complicated BASIC rou-
LCD.BAS shows the character position pin 7 to pin 8 (CS direct to tine.
corresponding to the start of each line. ground) All of the supplementary ports of
Another option is use the instruc- the 80535 can be addressed not only
tion UO 1 to redirect the entire out- In this configuration there is 16 kB of via their SFR addresses but also
put to the LCD. The instruction RAM available to the system, starting directly. The instructions P3, P4 and P5
UO 0 switches the output back to at address 0000h. The normal BASIC- can be used for output only. An output
the terminal 537 interpreter can work with this. Of value can be directly assigned to a port
course, you must tell the interpreter (e.g. P4 = 255). Reading input data
AUTOSTART that only 16 kB of RAM is available, by from the ports with the InP3, InP4,
The original BASIC-52 tests the entire entering: InP5 and InP6 instructions is unfortu-
RAM after start-up, clears it and then nately not as convenient, since this
starts any program that it recognises in MTOP = 16383 must be done via the result stack. Port
the external EPROM. Both of the Elek- states that have been read can be
tor 80C537 computers have battery- This line should also be placed at the fetched and put into a variable using
backed RAM, so that the program that beginning of every program, since the the POP instruction:
was last run before the computer was interpreter initialises itself to 32 kB of
switched off remains present in the RAM after a restart. Since all variables InP4 : POP A : PRINT A
RAM. The BASIC initialisation routine are stored just below the upper RAM
has therefore been modified to auto- boundary, the interpreter will function The direct port instructions also work
matically start a program that is correctly only if it has accurate infor- with the 80C537, but only up to port
already in the RAM. mation about the amount of available P6. BASIC-52 allows only a limited
All that you have to do is to load a RAM. number of new keywords. It is thus
program into the computer’s memory. If you would rather be able to use the not possible to give every new function
After this you can disconnect the serial full 32 kB of RAM, you must make two its own name. This means that we
cable to the PC and let the computer further modifications, as follows: have to continue programming the
work on its own. Each time the com- special hardware of the microcontroller
puter is started up, the program is run Bend pin 1 of the RAM IC (A14) so that via register addresses. With read oper-
anew, at least as long as the lithium it does not stick into the socket, and ations in particular, the use of register
battery provides enough power to then connect it directly to address addresses (e.g. Print SFR(0E8h)) is often
maintain the contents of the RAM. If at line A14 (for example, at pin 12 of the more elegant than the use of direct
any time you don’t want the system to socket for IC2). port instructions.
automatically run a program when it Bend pin 20 of the RAM IC (CE) so that It is relatively easy to write some
starts up, all you have to do is to send it also does not stick into the socket, reset routines and supplementary
it a NEW instruction. and then connect it directly to instructions yourself, since the BASIC-
address line A15, which is on pin 1 of 52 interpreter already has suitable
the same socket. interfaces. You can find more detailed
WE HAVEN’T information in the relevant literature.
FORGOTTEN THE Now the system will see the full 32 kB (000018-1)
80535! of RAM in one continuous block, start-
Now we come to the widely used ing at address 0000h. With this modifi- You can find additional information and
80535 systems, such as the Elektor cation, it is not necessary to specify the sample programs for 80535 and 80537
80535 Single Board Computer. The amount of available memory with microcontrollers, and a DOS terminal
new interpreter can also be used with MTOP. emulator for BASIC-52, at the author’s
this system, if you first carry out a few The 80535 Single Board Computer homepage on the Internet:
modifications. does not have battery-backed RAM. http://home.t-online.de/home/B.Kainka
The system must run at 12 MHz, in However, it is possible to use a ‘zero-
order to yield a data transfer rate of power ’ RAM, which has a built-in Project Software
9600 baud. Everything else works as backup battery. If such a RAM is used, Diskette, order code 996029-1.
well, as long as you take the available this computer behaves the same way (terminal emulator, help file and sample
processor hardware into account. The as the new 80537 computer. With a programs)
A/D converter has only eight channels, zero-power RAM you can have a pro-
but is otherwise compatible. Naturally, gram start automatically. Even without EPROM, order code 996532-1.
the 80535 has fewer timers, ports and this luxury, though, the Autostart func- (BASIC-537 interpreter)

Elektor Electronics 2/2000 43


AUDIO & HI-FI

designed for in-car use


one-IC audio power amplifier
50+ watts from a 12 V battery

The integrated output amplifier


described in this article consists
of little more than one integrated
circuit. It is intended especially for
use in motor vehicles and other battery-
operated applications. Although it appears
simple and hardly worth looking at, the amplifier
can produce an appreciable audio power output.

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

Elektor Electronics 2/2000


44
1

Figure 1.Block diagram of the innards of the TDA1562Q. A


obtained by operating the amplifier in number of protection networks make the amplifier virtu-
Class H (see box elsewhere in this arti- ally foolproof.
cle).
An amplifier based on the Philips
device was described in the February
1995 issue of this magazine. Class H output amplifier, the device exceeded, the drive to the output tran-
Philips designers have further contains several protection circuits. sistors is reduced.
improved a number of properties of One of these protects the IC against an There is also a protection circuit
the IC, among which the power out- excessive output current and against against overvoltage and one against
put. According to the Philips data short-circuits. too low load impedances. When the
sheet, the improved device, the The temperature protection circuit load impedance drops below a prede-
TDA1562Q, can deliver 70 watts into works in two steps. When the first termined critical level, operation is
4 ohms, but that is at the cost of the dis- threshold temperature is exceeded, the switched from Class H to Class B. A
tortion, which at 10 per cent is rather device switches from Class H to Class B load impedance smaller than 0.5 Ω is
too high, even for in a car. operation. There is then no question of seen as a short-circuit, which causes
The prototype of the design increased supply voltage. When the the device to be switched off alto-
described in this article provides second threshold temperature is gether.
54 watts into 4 ohms at 1 per cent dis-
tortion. Since the number of requisite
external components is smaller than in
the case of the earlier device, the
printed-circuit board is even more Brief technical data
compact than that for the February
1995 amplifier. Properties
High power output through Class-H operation
THE TDA1562TQ Low power dissipation during reproduction of music signals
The internal circuitry of the new device Proof against short-circuits
is very similar to that of its predecessor. Protection against excessive temperatures
Since, however, not everybody can be Standby switch
assumed to be au fait with the February No power-on or power-off clicks
1995 article, the circuitry is described Visible error indication
anew.
The block schematic of the device is
Measurement results (at Ub=14.4 V)
shown in Figure 1. Particular attention
is drawn to the boxes marked ‘lift sup- Supply voltage 8–18 V
ply’, which are necessary in a Class H Sensitivity 760 mV r.m.s.
system (see box). Input impedance 70 kΩ
The IC evaluates the input signal Power output 54 W r.m.s. into 4 Ω (f=1 kHz; THD+N=1%)
and estimates the consequent drive of Harmonic distortion (THD+N) at 1 W into 4 Ω: 0.046% (1 kHz)
the output transistors. When these 0.29% (20 kHz)
transistors tend to go into saturation, at 35 W into 4 Ω: 0.12% (1 kHz)
the supply voltage is raised briefly by 0.7% (20 kHz)
switching the capacitors connected to Signal-to-noise ratio (with 1 W into 4 Ω) 88 dBA
pins 3 and 5, and 13 and 15, in series Power bandwidth 7.5 Hz – 185 kHz (at 25 W into 4 Ω)
with the supply voltage. Quiescent current about 135 mA (‘on’)
Apart from the input amplifier and

Elektor Electronics 2/2000 45


12V for a period of time. When that time
has elapsed, the amplifier is quickly
2 R4 R2
reverted to normal operation. The cur-

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

TDA1562Q is one of the few facets of


C2 TDA1562
2 11
LS– the device that is completely new. As
–IN OUT–
470n
shown in the diagram, it can now be

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

C3,C4 = 10µF 63V radial


D1

C2

C5,C6,C8 = 4700µF 25V radial


(18mm max. dia., raster 7.5 mm)
R2
R4

C7 = 100nF, raster 5 mm
C1
+

Semiconductors:
D1 = high-efficiency-LED
C7

IC1 = TDA1562Q (Philips)

Miscellaneous:
S1 = single-pole on/off switch
0 C8

Four spade connectors, PCB mount


IC1

Heatsink for IC1 (Rth<2.5 K/W)


000004-1
C6

PCB, order code 000004-1 (see


C3

Readers Services pages)


LS-

1-400000
H2

H3

000004-1
ROTKELE )C( (C) ELEKTOR

46 Elektor Electronics 2/2000


Figure 4.There cannot
be many 50 W output
amplifiers that are this
4
small.

relevant protection circuit is


enabled.
4. The IC is in the power-up state.
When it is switched to the ‘on’ state,
the diode goes out. If, however, the
output impedance is not to specifi-
cation during power-up, the diode
remains lit.

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

circuited to earth. Although the IC is C1


LIFT/ LIFT/
C2
V3 V4
protected against much abuse and mis- RECHARGE
CONTROL
RECHARGE
CONTROL
use, it is always better not to tempt T1 T7 T8 T3 E1
providence.
In most cases, two amplifier mod-
ules will be fitted in one enclosure: one V1 R1 V2

for the left-hand channel and the other T2 T4

for the right-hand channel.


Constructors who find 2×54 watts
insufficient may consider driving the 950024 - 12

front and rear speakers in the vehicle


by separate amplifiers. This would take In the present amplifier, Class H operation is achieved by the use of two switched
the total number of modules required capacitors, C1 and C2. These are charged to the battery voltage and switched into
to eight, and these deliver some series with the 12 V supply line during brief drive peaks.
400 watts of audio power into the vehi- In the diagram, transistors T1–T4 are part of the ‘normal’ amplifier, while T5–T8 and
cle. A case of minding the windows! C1 and C2 are added for Class H operation. At small-signal amplitudes, T7 and T8
[000004-1] are on and C1 and C2 are charged to the battery voltage via diodes D1 and D2. When
the signal amplitude tends to drive T1 or T3 into saturation, the internal sensor
Text (Dutch original): S. van Rooij (lift/recharge control) detects this and causes T7 and T8 to be cut off and T5 and T6
to be switched on. When that happens C1 and C2 are in series with the supply line;
diodes D1 and D2 prevent their being discharged into the battery.
When the input signal amplitude drops, the capacitors are linked to earth again by
T7 and T8, whereupon their charge is topped up.

Elektor Electronics 2/2000 47


GENERAL INTEREST

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

Elektor Electronics 2/2000


48
flow to the hottest point.
Proceed as follows: 2
➧ First place a clean piece of desolder-
ing braid on the solder joint that you
want to remove, and then place the
tip of the soldering iron on top of the
braid.
➧ Now press quite firmly with the sol-
dering iron, to make good thermal
contact (see Figure 2). The solder will
be drawn into the braid.
➧ As soon as the braid is saturated, it
will not absorb any more solder. You
can easily see how saturated it is
from its colour. It is initially copper-
coloured, but becomes increasingly
silver-coloured as it absorbs more
and more solder (see Figure 3).

In order to fully clean the solder from


a joint, you sometimes have to work in
two steps. In the first step you remove
most of the solder. After this, you can
slowly draw the braid along under the
soldering iron, while holding the sol-
dering iron stationary (this takes a bit 3
of practice). Following this, you can
remove the last remains of the solder
with a fresh, unused piece of desolder-
ing braid.

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)

Elektor Electronics 2/2000 49


MICROPROCESSORS

537 ‘Lite’ computer (2)


part 2: programming and practical use
Having built the board and successfully run the reset, after which the program runs in
the RAM area. The RAM component
first communication tests, you are ready to start then acts as an EPROM program stor-
programming the 537 core system. In doing so, age device, obviating the need to pro-
gram your own EPROM to be able to
some rather special points should be observed employ the system in stand-alone
mode running the final version of the
which are discussed in this article. What’s program. The RAM component acts as
more, we show you how the board may be a shared program and data memory.
An essential component in this mode is
used in practice by adding extensions and the backup battery, because, as you will
components. no doubt be aware, a RAM chip is a
‘volatile’ device which means that it
loses its contents when the supply volt-
age disappears.
Design by Prof. B. vom Berg When the Monitor EPROM is used
and P. Groppe (mode 2) the serial interface SS0 is auto-
matically configured for 9,600 baud,
one stop bit and no parity (9600, N, 8,
1), which should enable flawless com-
munication with the host PC. However,
MODES OF THE EPROM contains the monitor pro- if the program is to run in Stand Alone
537 ‘LITE’ COMPUTER gram, while the RAM chip acts as a or Run mode, this serial interface ini-
The fact that it can be used in three dif- combined program and data storage tialisation is sadly missing. Unfortu-
ferent modes adds considerably to the device. In this mode, jumper J7 has to nately, you have to provide and embed
power and versatility of the the 537 be set to the 12 MHz crystal position. If the necessary routine for SS0 yourself
Lite board. The modes are Stand not, the communications data speed is to make sure the communication with
Alone, Program Download and Run. not properly set up. However, once the the PC operates as it should.
Table 1 shows how to set jumpers and program has been downloaded, J7
switches to select between these may be changed at any time, if only to PROGRAMMING
modes. ensure that the program runs about Before you can start programming
33% faster after a reset. Do remember, away, you have to know some elemen-
Stand Alone mode is typically used for however, that the higher clock speed tary facts about the memory configura-
the final application of the board, also results in time-dependent routines tion of the 537 Lite board. After all, pro-
when a program has been fully tested being executed faster. grams and user data are both stored in
and is known to work error-free in the The EPROM-resident monitor pro- RAM component IC7. This shared
target system. After a reset, the user gram allows simple direct entry of memory space extends from 0000H
program is immediately executed from assembler commands as well as com- through 7FFFH, so its size is 32 kBytes.
EPROM. fortable debugging at assembly-code In the programming environment
level. You may enter help to call up an (8051 Compiler or Interpreter) you
In Program Download mode, a termi- overview of all available functions. have to indicate exactly which ranges
nal program is used to download the are reserved for the program and
program (developed on a host PC) to In Run mode the previously down- which ones for the data. If you fail to
the 537 Lite board. The program then loaded user application program may do this, memory contention may occur
has to be started from be executed straight and program(s) and data may actually
the host PC. The Table 1. Jumper- and away by means of a destroy each other!
switch settings of the
three modes

Mode Jumper Switch EPROM RAM


J1A,J1B,J1C S1 IC2 IC7
Stand-alone 1-2 don’t care user program* Data*
Program download 1-2 LOAD RAM Monitor user program and data*
Run 2-3 RUN not active user program and data

*: 32 kByte device, address range 0-7FFFH

Elektor Electronics 2/2000


50
You should also be aware that the 7FFF End of RAM range (fixed): 32 kByte
EPROM-resident Monitor program, Size: 256 bytes
whose functions include control over 7F00 Fixed start address of memory range for Monitor program
the program download operation, also
requires a small scratch area in RAM.
Obviously, this area may not be over- 7EFF End of data memory range (fixed)
written by the program code or user Size: 7.75 kBytes
data! The monitor scratch area is 6000 Start of data memory range (variable)
defined as 7F00H through 7FFFH in
RAM. 5FFF End of program code range
Size 24.0 kBytes
All this has the following implica- 0000 Start of program code memory range (variable)
tions if you want to start writing pro-
grams:
Table 2. RAM memory map

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;

(*** Definition of Variables *******************************************)


const
(* For A/D converter *)
adcon0 = $d8;
addat = $d9;
dapr = $da;
busy = $dc;
var
(* A/D converter *)
adu:byte;

(* Various *)
i,zw: byte;

(*** Suroutine Collection *********************************************)

(*** Main program ******************************************************)

begin
(*** Clear screen ***)
write(chr($1a));

(*** Intro text ***)


writeln('Program p2: Capture analogue values using 537 Lite Board');
writeln('========================================================');
writeln;
writeln(' now capturing measurement values .....');
writeln;

(*** Main loop ***)


repeat (* Start of endless loop *)

(* Capture and display measurement values *)


for i:=0 to 2 do (* Convert 3 measurement values *)
begin
adu:=reg(adcon0); (* Read adcon *)
adu:=adu and %11000000; (* single conversion, internal start *)
adu:=adu or i; (* Channel selection *)
writereg(adu,adcon0); (* Copy value into SFR *)
writereg(0,dapr); (* Start conversion *)
repeat until (bit(busy)=false); (* Wait for done *)
zw:=reg(addat); (* Read converted value *)
write('Input AN',i,': ',zw); (* Put on display *)
writeln(' = ',(zw*5)/256,' V');(* Convert into Volt and display *)
end;
writeln; (* Supply empty line *)

(* Wait: approx. 1000 ms until next measurement *)


wait_25ms(40);

until false; (* Exit from endless loop *)

end.

Elektor Electronics 2/2000 51


Program p2: Capture analogue values using 537 Lite Board EPROM. Consequently there’s no
===================================================== need to have an EPROM programmer
and/or UV eraser available.
now capturing measurement values .....
PRACTICAL
Input AN0: 118 = 2.3046875e0 V APPLICATIONS
Of course, the 537 core should not lie
idle among half a dozen or so other
Input AN1: 122 = 2.3828125e0 V
microcontroller boards in one of your
Input AN2: 118 = 2.3046875e0 V drawers. We strongly suggest you actu-
ally use the board by giving it a practi-
Input AN0: 66 = 1.2890625e0 V cal application. A good example is that
Input AN1: 56 = 1.0937500e0 V of a CAN bus system host as described
Input AN2: 29 = 5.6640625e-1 V in last month’s issue of this magazine.
Other experimental circuits and appli-
Input AN0: 75 = 1.4648437e0 V cations include peripheral devices with
Input AN1: 91 = 1.7773437e0 V serial control (3-channel D-A converter,
Input AN2: 109 = 2.1289062e0 V temperature sensor, LED display, etc.),
keypad/keyboard interfaces, voice pro-
Input AN0: 107 = 2.0898437e0 V duction, digital and analogue I/O
Input AN1: 112 = 2.1875000e0 V cards, IrDA, radio and fibre-optic com-
Input AN2: 111 = 2.1679687e0 V munication systems. Many such pro-
jects may be found in existing litera-
ture, or will be published shortly.
Figure 2. Measure- Even if space is at a premium in this
ment results produced magazine, an example should be
by P2.PAS on the PC included that illustrates the use of the
display. 537 Lite computer in combination with
➧ The total RAM range BASIC52, PL/M51 or the DOS version of Pascal51. This inte-
available for program Pascal51. BASIC52 and grated programming environment also
and data extends from 0000H Pascal51 in particular allow very fast runs in a Windows 95/98 DOS box.
through 7EFFH, so its size is and powerful results to be obtained. Having launched the editor
32,512 bytes. Whatever programming language is nilied.exe you first have to set up the
used, the final product of your pro- desired memory model. This is done in
➧ The program memory range always gramming efforts, a block of object the menu Options|NiliPascal Parame-
starts at address 0000H, and is imme- code, should be either an Intel-Hex ters (Figure 1). The minimum settings
diately followed by the data memory file, a file with the extension .hex or are the definitions of data and program
range. an ASCII file containing BASIC memory start addresses, the microcon-
tokens. troller clock frequency and the baud
➧ The data memory range may not rate of the communication between the
reach into the monitor memory ➧ The object code file is downloaded to PC and the 537 Lite board. Your per-
range. The memory division is illus- the 537 board via one of the available sonal preferences and settings are
trated in Table 2. RS232 interfaces on the PC. saved and the menu is closed.
At this point you may enter a pro-
At this point, an example may help to ➧ Test the program in combination gram or load an available piece of code,
show what considerations play a role with the target system hardware. for example, one of the examples
in practical programming. found on the project diskette, 976008-
➧ Once all errors have been sorted out 1. The example program p2.pas cap-
Let’s assume that a program with a size and the program works as it should, tures input voltages on the first three
of about 20 kBytes and requiring about there are two possibilities to accom- inputs AN0, AN1 and AN2 of the 537’s
5 kBytes of data memory is not quite modate the final version of the soft- on-chip A-D converter. The sampling
finished and therefore requires some ware in the system. rate is one per second. You may apply
additional memory locations. The com- – The first option is to program an different voltages in the range 0-5 V to
piler/interpreter should be ‘informed’ EPROM and install it instead of the pins 3, 4, 5 and 15 of connector K3 and
that the program code range starts at Monitor EPROM. The system then check the associated conversion results
0000H, and the data range, at 6000H. runs in Stand Alone mode on the display.
Consequently the program space has a (mode 1), so that 32 kBytes of The program p2.pas should be com-
size of 24,576 bytes (24 kBytes), while data/program memory is available. piled without errors after pressing
the data memory measures 7,936 bytes Shift-F9. Next, you quit the program
(7.75 kBytes). – The second option is to switch S1 editor by typing Alt-x which takes you
When the program is developed to RUN (mode 3) after the program back to the DOS level. The next step is
further, you should take care that the download operation, prompting to download the object code to the 537
program code does not cross the the program to execute from RAM. Lite board and run it! Figure 2 shows
5FFFH border, and the data, the 7EFFH When a backup battery is used, the what you should see on your display.
border. If that happens, the two mem- RAM contents is not lost when the (990054-2)
ory blocks will corrupt one another. battery voltage is switched off. A
Programming the 537 Lite board Lithium battery should have Design editing: K. Walraven
takes four steps: enough energy for several years of Text editing
problem-free use. (German original): R. Gerstendorf
➧ The user program is written in a pop-
ular and widely used programming The advantage of the second option
language like Assembler51, C51, is that you do not have to burn an

52 Elektor Electronics 2/2000


Elektor Electronics

HT12D HT12A

Integrated circuits Integrated circuits


Special Function Special Function
DATASHEET 2/2000 DATASHEET 2/2000

HT12D ➧ Built-in oscillator needs only 5% resistor HT12A Application example


212 Series of Decoders ➧ Valid transmission indicator 212 Series of Encoders IR Remote Control for Sony MZ-R30 MiniDisc Walk-
➧ Easy interface with an RF or an infrared transmis- man, Elektor Electronics February 2000.
Manufacturer sion medium Manufacturer
Holtek Semiconductor Inc., ➧ Minimal external components Holtek Semiconductor Inc., General Description
The 212 encoders type HT12A and HT12E are CMOS
2/2000

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

Features (HT12D only) Features (HT12A only)


➧ Operating voltage: 2.4V-12V ➧ Operating voltage 2.4V- 5V
➧ Low power and high noise immunity CMOS tech- ➧ Low power and high noise immunity CMOS tech-
nology nology
➧ Low standby current ➧ Low standby current: 0.1µA (typ.) at VDD =5V
➧ Capable of decoding 12 bits of information ➧ 38kHz carrier for infrared transmission medium
➧ Pair with Holtek’s 212 series of encoders ➧ Minimum transmission: one word
➧ Binary address setting ➧ Built-in oscillator needs only 5% resistor
➧ Received codes are checked 3 times ➧ Data code has positive polarity
➧ Address/Data number combination ➧ Minimal external components
➧ 8 address bits and 4 data bits Pin Assignment ➧ 18-pin DIP or 20-pin SOP package available Pin Assignment

Pin Descriptions Pin Descriptions (HT12A only)

Pin Name I/O Internal Connection Description


Pin Name I/O Internal Connection Description
53

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy