as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA...

50

Transcript of as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA...

Page 1: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable
Page 2: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

This circuit allows a Nintendo 64 con-troller to be connected to the PC gameport (or a sound card), without requir-ing any additional drivers to beinstalled. The Nintendo 64 controller isa widely-used unit that combines highquality with a low price. With thisapproach, you can run PC games withthe comfortable Nintendo 64 controllerinstead of using the PC keyboard andmouse.

What the Nintendo 64 controller offers…

In addition to a few membraneswitches, the controller contains aprecise analogue electro-optical joy-

stick module that works like a mouse.On demand, the controller unit reportsthe status of the switches and theposition of the joystick. Bidirectionalcommunication takes place over asingle line that has a High level in therest state. This line is used both to sendcommands to the controller and toreceive the requested data from thecontroller. A command byte must besent before data can be receivedfrom the controller. If the line is free, asindicated by a persistent High level,the command byte can be trans-ferred. The controller responds to thecommand $01 with the status infor-mation for all pushbuttons and theposition of the analogue joystick. The

transmission time for each bit is 4µs inboth send and receive modes. A Lowbit is indicated by a 3-µs Low phasefollowed by a 1-µs High phase, whilea High bit is indicated by a 1-µs Lowphase followed by a 3-µs High phase.In order to delay the response to acommand, the last transferred bit ofthe command can be held Low. If theline is returned High at the end of thecommand transmission, the responseshould occur within 2 to 3 microsec-onds. The response time is not fixed,since the controller and the N64C2PCIC operate asynchronously, each withits own clock.The first experimental circuit, with a8051 clocked at 12 MHz (correspond-ing to a 1 µs cycle time), was obviouslytoo slow to meet the critical timingrequirements of the Nintendo 64 con-troller. Reliable communication wasonly possible after the microprocessorwas replaced by an AT89C2051-24PCwith a 24-MHz clock. Regarding thehardware, you can see that two clocksources are shown in Figure 1, in addi-tion to the microcontroller and a pair ofcurrent-limiting resistors. This is because24-MHz crystals are normally only avail-able for series-resonant operation. Such‘overtone’ crystals are not suitable forthis application! If you cannot obtain afundamental-frequency crystal, youcan use a self-contained 24-MHz oscil-lator (see the list of components).Returning to the communications withthe controller, the answer to the com-mand $01 is four bytes of controller sta-tus information, transmitted MSB first, asshown in Table 1.

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

Awkward keyboard commands and uncomfortablemouse control can spoil even the most attractive PCgame. 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 toconnect a Nintendo 64 controller to the PC game port.

design by K. Schuster

PC interface forNintendo joystickusing the Nintendo 64 to run PC games

Page 3: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

…is not what the game portexpectsA simple PC game port does not needany active circuitry. The two pushbut-tons simply make connections to earth.The PC game port, or a suitable soundcard, simply polls the switch levels tosee whether they are High or Low.With the analogue joystick, the situationis a bit more complicated. The joystickcontains two potentiometers (X and Y),whose resistances are around 100 kΩ,connected to the supply voltage.Capacitors located on the card arecharged via these potentiometers.These capacitors determine the timeconstants of a pair of monostable mul-tivibrators. The positions of the poten-tiometers can thus be derived from thelengths of the pulses produced by themonostables. All analogue elementsare addressed or polled at the sametime. A normal PC game port providesconnections for two joysticks, whichmeans that it has four ‘digital’ and four‘analogue’ inputs. Sometimes only onejoystick can be connected, but this isvery rare.

Two worlds join together

It is not difficult to see that these twoworlds do not really fit with each other.Requesting and interpreting the statusdata from the Nintendo 64 controllershould not be difficult, but how canthe expectations of the PC game port

be satisfied without a lot of compli-cated circuitry? Handling the push-buttons is relatively easy; the relevantbits from the Nintendo 64 controllercan simply be periodically output onthe microcontroller leads. However,what should be done with the digitalvalues for the analogue joystick? Herewe can use a trick: the interfacemicrocontroller waits for a short Lowlevel on one of the potentiometerlines, which goes along with the cycliccharging of the capacitors of the PCgame port card. Following this, themicrocontroller holds all of the poten-tiometer lines Low, to prevent any fur-ther charging of the capacitors, andstarts its timer. Each of the poten-tiometer lines is subsequently allowedto go High at a time that depends onthe data received from the Nintendo64 controller. The correspondingcapacitors are charged briefly via themicrocontroller outputs, and the asso-ciated monostables report what theyassume to be the potentiometer posi-tions. If you observe the relevant out-puts of the AT89C2051 with an oscillo-scope, you will see pulse-width modu-lated signals with a period of around840µs and a duty cycle of 50% to90%, depending on the potentiome-ter position. When the potentiometer isat the midrange position, the dutycycle is 70%.

Details — the programThe software, including the sourcecode, is available from the Elektor Elec-tronics web site (www.elektor-electron-ics.co.uk). If you cannot program themicrocontroller yourself, you can obtaina ready-programmed device from ourReaders Services under order code006504-1.The main loop of the program startsafter the stack and the two timers havebeen initialized, the timers have beenstarted and their interrupts have beenenabled. First, the timing for the ana-logue joystick modules A and B (B is thecontrol cross or C button) are estab-lished by the routines prepajoyt andprepbjoyt, respectively. Timers T0 andT1 are responsible for the timing of joy-stick A, with T0 used for the X axis andT1 for the Y axis. Timer T0 also managesthe Timeout Mode, which prevents theprogram from getting stuck in a pollingloop if the Nintendo 64 controller isunexpectedly disconnected or there isan intermittent contact. In such a situa-tion, it would otherwise not be possibleto initialize the Nintendo 64 controlleronce it was reconnected without firstmanually resetting the microcontroller.The entire program is synchronized withthe slowest and least-flexible element,the PC game port. The instruction jnbJPYAX,* waits for the capacitors to bedischarged. Once the game port has

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

K1

10

11

12

13

14

15

1

2

3

4

5

6

7

8

9

AT89C2051-24PC

P3.2

P3.3

P1.0

P1.1 P3.0

P3.1

P3.4

P3.5

IC1P1.2

P1.3

P1.4

P1.5

P1.6

P1.7

P3.7

RST

X1 X2

20

10

12

13

14

15

16

17

18

19

11

5 4

2

3

1

6

7

8

9

R11

4x 10k

1

5 4 3 2

R8

220Ω

R7

220Ω

R6

220Ω

R5

220Ω

R4

470Ω

R3

470Ω

R2

470Ω

R1

470Ω

C5

100µ 16V

X1

24MHzC4

27p

C3

27p

C2

100n

joyax

joyay

joybx

joyby

joyb2

joyb1

joya2

joya1

C1

10µ16V

R9

10

k

R10

2k

2

D1

XO1

EN1 5

4

8

OSC

24MHz

5V*see text*

002007 - 11

5V

front view

Figure 1. A microcontroller, a pair of resistors and an oscillator are all you need for theadapter circuit.

Table 1. Nintendo 64serial status information

Byte 1Bit 7 button ABit 6 button BBit 5 button ZBit 4 start buttonBit 3 control cross upBit 2 control cross downBit 1 control cross leftBit 0 control cross right

Byte 2Bit 7 unknown, always 0Bit 6 unknown, always 0Bit 5 button LBit 4 button RBit 3 button C upBit 2 button C downBit 1 button C leftBit 0 button C right

Byte 3analogue stick x

Byte 4analogue stick y

Page 4: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

done this, the microcontroller sets thefour potentiometer lines JOYAX/Y andJOYBX/Y Low and starts timers T0 and T1for JOYAX/Y, since these are assigned tothe analogue joystick. The control crossor C button is assigned to JOYBX/Y. Ana-logue values are also expected here,so the timing is handled by the routinejoybtiming, due to the lack of addi-tional timers in the microcontroller. Withthe help of a few NOPs and nestedloops, the game port receives what itexpects here as well, and the JOYBX/Ylines are set high again after appropri-ate delays. The rate of advance in theY direction can be set to one of threedifferent levels by simple ‘switch-on,switch-off’ logic. If the control cross orthe C button is used during a game forforward or reverse motion, the L buttoncan be used to switch between ‘creep-ing’, ‘walking’ and ‘running’. The dutycycle range is thereby switched from itsdefault range of 58%–78% to either48%–88% or 40%–97%.After both software timers have timedout, the program waits until the hard-ware timers T0 and T1 have completedtheir jobs and generated interrupts.Once they have timed out, the JOYAX/Youtputs are again set to High. Since theprogram can easily get hung in thesubsequent time-critical portion, thetimer T0 interrupt is used as an ‘emer-gency brake’ timeout in the routine Init-tom. If the Nintendo 64 controller doesnot respond within a predefined inter-val, the program is restarted from thebeginning. The routine sendbyteAsends the command $01 (Status Infor-mation), and the following routine get-bytes reads the four status bytes fromthe Nintendo 64 controller. Bytes 1through 4 land in registers R4 throughR7 for further processing. Before each

byte is read, precise bit synchronizationis established, following which the Time-out Mode of Timer 0 is again deacti-vated and the values that have justbeen read in are interpreted in the rou-tine handlebuttons. This works accord-ing to the arrangement shown inTable 2.Repeatedly pressing the L buttonchanges the advance rate of the con-trol cross up/down buttons or C buttonin three steps.Once the switch states have been eval-uated and their status has been passedon to the PC game port, the loop startsfrom the beginning with the evaluationof the analogue values that have beenread in. The routine calctiming normal-izes and scales these values in terms of

processor cycles, and the resultingdata form the inputs for the next round,which begins with the discharging ofthe capacitors.

Playing around

In order for the new joystick to be usedwith the PC under Windows 95/98, itmust be made known to the operatingsystem. You should find a joystick orgame controller icon under

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

002007-1

C1

C2

C3 C4

C5

D1

F3F4

IC1

K1

R1

R2

R3

R4

R5

R6

R7

R8

R9

R10

R11

X1 XO

1

T

+0

02

00

7-1

00

20

07

-1

Figure 2. The printed circuit board for the Nintendo-64/PC adapter.

COMPONENTS LIST

Resistors:R1-R4 = 470ΩR5-R8 = 220ΩR9 = 10kΩR10 = 2kΩ2R11 = SIL-resistor array 4x10kΩ

Capacitors:C1 = 10µF 16V radialC2 = 100nFC3,C4 = 27pF (*)C5 = 100µF 16V radial

Semiconductors:D1 = LED, low currentIC1 = AT89C2051-24PC (order code006504-1)

Miscellaneous:K1 = 15-way sub-D plug fr board edgemountingX1 or XO1 = quartz crystal, 24MHz,fundametal resonance or 24MHz-oscillator module (Seiko-Epson SG531P-24MHz) (*)

(*) = see text

Figure 3. How to prevent an incorrect connection.

Page 5: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

Settings/Control Panel. If you do not, thenecessary software must first beinstalled. After this, the best approachis to configure a new joystick with fouraxes and four pushbuttons. During thesubsequent calibration, make sure thatthe up/down buttons of the controlcross, or the C button, have been set tothe highest speed using the L button(recognizable by the largest displace-ment on the screen). The settings canbe saved with the name ‘N64’, forexample. This name may be neededlater to configure certain games. Older(DOS) games only require calibration.Some games (such as Unreal) offer anextensive range of joystick settings,which you will have to carefully studyand try out. In some cases, such as withHalf-Life, you will need a small joystickconfiguration file that contains the con-figuration data. The game looks for thisfile in a particular folder when it isstarted (for example,c:\Sierra\HalfLife\valve). You can usuallyfind tips in the ReadMe files of thegames as well. Table 3 shows two typi-cal configuration files.

Construction hints

Constructing the circuit, using theprinted circuit board shown in Figure 2,should not present any difficulties. ThisPCB is unfortunately not availableready-made through our Readers Ser-vices. Mount the microcontroller in agood-quality socket. The choicebetween a quartz crystal and an oscil-lator module has already been dis-cussed. If an oscillator module is used,omit capacitors C3 and C4 (and ofcourse X1). Difficulties may arise withthe (various) controller plugs, sincematching sockets are hard to come by.There are three possible solutions: (a)cannibalize an old Nintendo 64 con-sole, (b) cut off the plug and make upan adapter cable with a three-way DINor Mini-XLR plug (with a mating con-nector on the end of the cable), or (c)improvise a solution using 1.3-mmdiameter solder pins to which shortlengths of wire are soldered, which inturn can be soldered to the inputs ofthe AT89C2051 (see Figure 3). To pro-tect against a reverse-polarity connec-tion, you should solder the pins to apiece of prototyping board with a holespacing of 3.75 mm, and then use anadditional part (for example, a pieceof 3/4-inch plastic pipe, as shown) toprevent the plug from being con-nected incorrectly.

(002007)

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

Table 2. Arrangement of the Nintendo-64/PC gameport signals

N64 Controller PC Gameport Line

button A Joy A button 1 JOYAB1button B Joy A button 2 JOYAB2button Z Joy B button 1 JOYBB1

button Start/R Joy B button 2 JOYBB2analogue X-axis Joy A analogue x JOYAAXanalogue Y-axis Joy A analogue y JOYAAY

K/C left/right Joy B analogue x JOYBAXK/C up/down Joy B analogue y JOYBAY

K=control cross, C=buttons

Table 3. Two typical joystick configuration files

// name joystick.cfg// analog turn and look version//// x analog turn left/right// y analog look up/down// C move left/right// C move forward/backward// configure in game: A alternate fire, B duck, Z fire, R/Start jump//joyname ”N64”joyadvanced 1joyadvaxisx 4joyadvaxisy 2joyadvaxisz 1joyadvaxisr 3joyadvaxisu 0joyadvaxisv 0joyforwardsensitivity -1.0joysidesensitivity 1.0joypitchsensitivity -1.0joyyawsensitivity -1.0joyforwardthreshold 0.1joysidethreshold 0.1joypitchthreshold 0.1joyyawthreshold 0.1joyadvancedupdate

Alternative version:

// name joystick.cfg// analog turn and move version//// x analog turn left/right// y analog move forward/backward// C look up/down// C move left/right// configure in game: A jump, B alternate fire, Z fire, R/Start duck//joyname ”N64”joyadvanced 1joyadvaxisx 4joyadvaxisy 1joyadvaxisz 2joyadvaxisr 3joyadvaxisu 0joyadvaxisv 0joyforwardsensitivity -1.0joysidesensitivity 1.0joypitchsensitivity 1.0joyyawsensitivity -1.0joyforwardthreshold 0.1joysidethreshold 0.1joypitchthreshold 0.1joyyawthreshold 0.1joyadvancedupdate

Page 6: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

The objective of the running text displayproject was to develop a simple, inex-pensive design that would not be toodifficult to build and would be easy touse. We intentionally decided not tomake the display as large as possibleor to implement a lot of different dis-play modes, since these would requirea powerful microcontroller or a single-board computer. The result is a circuitthat is controlled by an inexpensiveNational Semiconductor microcon-troller with 4 kB of ROM, and which canbe built using readily obtainable com-ponents.

Conventional running text displaysnormally have keyboards that aredirectly cabled to the display units.These keyboards are usually not laidout the same as standard keyboards,so programming is awkward and timeconsuming. The keyboard matrix alsorequires a relatively large printed circuitboard with expensive keys, whichmakes it unsuitable for a DIY project.The basic idea of this project is to use astandard PC keyboard with an infrareddata link to the display unit. The runningtext can then be conveniently pro-grammed, with all the advantages ofusing a standardised PC keyboard —and this can be done up to 10 metresaway from the display.

The transmitter, with its attached key-board, can also be employed as ageneral-purpose unit for other (future)projects, in order to simplify the con-

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

It’s hard to keep track of how many running text dis-plays you run across nowadays. You can find themused as decorations in shop windows, as program-mable signboards and as simple eye-catchers. If youbuy 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 articlecombines a simple and inexpensive design withrepeatable construction and ease of use.

Design by K. Wohlrabe

runningtext displaycontrolled by a COP-8 microcontroller

Technical specificationsStored text: 508 characters maximumDisplayed text:

6 characters visibleusing 5 x 7 matrix elementsTransmitter range: approximately 10 mOperating voltage: 12 V (transmitter and receiver)

Page 7: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

struction and operation of the equip-ment. Only one port pin of the micro-controller on the receiver side isneeded for decoding the informationfrom up to 128 keys.

The transmitter

The microcontroller in the transmitterunit, whose schematic diagram isshown in Figure 1, receives the serialdigital signals from the PC keyboardand converts them into a protocol thatis sent to the display unit via infraredlight. The decoding of PC keyboard sig-nals is described in another article,elsewhere in this issue. The microcon-troller in the transmitter unit selects scancode set 3 after it has been reset,switches on the Scroll LED of the key-board as an indication that it is active,suppresses the Break code for theupper-case (shifted) keys and transferskey codes to the display unit. The datatransfer employs a modulated 36 kHzcarrier, in order to provide noise immu-

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

R4

1M

X1

10MHz

C1

33p

C2

33p

C4

220µ16V

7805

IC2

5V

R2

10

0k

R1

10Ω

R3

47

T1

ZTX603

D1

TSUS5201

IC3

ZSM560

DATA

5V

9V

9V

C3

100n

990090 - 12

2

3

1

5

4

K1

CLK

GND

+5V

43

1 2

65

DIN 5

1 DATA

3 GND

4 +5V

5 CLK

PS-2

COP8782

G7/CKO

G3/T10

G0/INT

RESET

G5/SK

G4/SO

G6/SI

IC1

CKI

19

L0

L714

15

L1

L2

L310

L411

L613

16

20

G118

G2

17

L512

6

7

54

8

9

2

1

3

JP1

*

see text*

rear view

rear view

KEYBOARD

KEYBOARD

990090 - 13

start bit 6 ms H,6 ms L

data bit "1"2 ms H, 4 ms L

data bit "0"2 ms H, 1 ms L

stop bit2 ms H

Figure 1. The input data transmitter contains only a COP-8 microcontroller and aninfrared transmitter module.

Figure 2. Timing diagram of the transmitter signal that modulates the 36-kHz carrier (this example is for the code 88H).

The microcontrollerThe 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:

4096 x 8 OTP EPROM 128 bytes of RAM 1 µs cycle time at 10 MHz 16-bit timer with the following operating modes: auto reload external event counter timer with capture function 16 I/O leads, of which 14 can individually be programmed as inputs or outputs• selectable pin configuration: tri-state, push-pull or pull-up Microwire interface interrupt sources: external with selectable edge, timer or software

The COP8782 microcontroller now has a successor, with the type designation COP8SAC7.This has improved characteristics, but it is essentially pin-compatible and functionally com-patible with the older version. There is a starter kit available, which unfortunately does notallow real-time emulation, but which does allow OTP devices to be programmed. It also pro-vides comprehensive insight into the possibilities of this inexpensive and technically inter-esting microcontroller family. For somewhat more demanding projects that require the real-time behaviour of the microcontroller to be tested, you have no other choice than to buyan emulator if you do not want your projects to turn into endless trial-and-error sessions.

COMPONENTS LIST(transmitter)

Resistors:

R1 = 10Ω

R2 = 100kΩ

R3 = 470Ω

R4 = 1MΩ

Capacitors:C1,C2 = 33pFC3 = 100nF

C4 = 220µF 16V

Semiconductors:D1 = TSUB8201T1 = ZTX603IC1 = COP8782 (order code 996527-1)IC2 = 7805IC3 = ZSM560

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

socketX1 = 10MHz quartz crystal

Page 8: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

nity. One start bit, eight data bits, oneparity bit and one stop bit are transmit-ted. The microcontroller is clocked atthe relatively high rate of 10 MHz. Thisenables it to correctly decode the ser-ial data stream from the keyboard, andto generate the 36 kHz carrier fre-quency for the infrared diode, usingonly software.

Figure 2 shows the timing diagramof a sample character (with the code88H) before modulation. The infrareddiode D1 is driven by the Darlingtontransistor T1. In order to give the trans-mitter a wide range, the value of thecurrent-limiting resistor R1 is intentionallychosen to be on the low side, and ahigh-efficiency LED is used. However, inprinciple any type of infrared LED canbe used.

The short data packets, and the

resulting short ‘on’ times, prevent thetransistor from becoming overheated.The reset IC (IC3) ensures that themicrocontroller always starts up prop-erly. The current consumption of thetransmitter, including the connectedkeyboard, is around 110mA. Since it isused only infrequently, it can be pow-ered from a 9 V battery, although amains adapter can also be used.

The receiver

The transmitted information is demodu-lated by the infrared receiver IC4,shown in Figure 3. This very sensitive IC,which is specially tuned to work at the36 kHz carrier frequency, contains aphotodiode, an amplifier stage, a filterand a demodulator. Resistor R17 andcapacitor C5 form a supplementary

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

TFMS5360

IC342

3

1

MATRIX 3

IC14

14

1013

2

7

1

5

8

9

643

MATRIX 3

IC20

14

1013

2

7

1

5

8

9

643

MATRIX 3

IC17

14

1013

2

7

1

5

8

9

643

MATRIX 3

IC16

14

1013

2

7

1

5

8

9

643

MATRIX 3

IC15

14

1013

2

7

1

5

8

9

643

MATRIX 3

IC19

14

1013

2

7

1

5

8

9

643

MATRIX 3

IC18

14

1013

2

7

1

5

8

9

643

74164IC21

CLK CLR

121110 13

QA

QB

QC

QD

QE

QF

QG

QH

14

1

6543

2

A B

8 9

7 74164IC22

CLK CLR

121110 13

QA

QB

QC

QD

QE

QF

QG

QH

14

1

6543

2

A B

8 9

7 74164IC23

CLK CLR

121110 13Q

A

QB

QC

QD

QE

QF

QG

QH

14

1

6543

2

A B

8 9

7 74164IC24

CLK CLR

121110 13

QA

QB

QC

QD

QE

QF

QG

QH

14

1

6543

2

A B

8 9

7 74164IC25

CLK CLR

121110 13

QA

QB

QC

QD

QE

QF

QG

QH

14

1

6543

2

A B

8 9

7

93C66CB1

IC33

DO

DI

CS

SK

X

X2

1

4

8

5

3 6

7

R8

1M

X1

10MHz

C1

33p

C2

33p

T1R10

750Ω

R2

47Ω

T2R11

750Ω

R3

47Ω

T3R12

750Ω

R5

47Ω

T4R13

750Ω

R6

47Ω

T5R14

750Ω

R1

47Ω

T6R15

750Ω

R7

47Ω

T7R16

750Ω

R4

47Ω

R9

10

0k

R17

10

C4

100n

C5

10µ

B1

C6

2000µ

C7

2000µ

8x BC557

5V5V5V

5V

5V

5V5V5V5V5V

990090 - 11

1A

IC35

7805

IC27

ZSM560

COP8782C

G7/CKO

G3/T10

G0/INTRESET

G5/SK

G4/SO

G6/SI

IC26

CKI

19

L0

L714

15

L1

L2

L310

L411

L613

16

20

G118

G2

17

L512

6

7

54

8

9 2

1

3

ULN2803

IC28

1112131415161718

I1 I2 I3 I4 I5 I6 I7 I8

O1 O2 O3 O4 O5 O6 O7 O8

10

1 2 3 6 7 84 5

9 ULN2803

IC29

1112131415161718

I1 I2 I3 I4 I5 I6 I7 I8

O1 O2 O3 O4 O5 O6 O7 O8

10

1 2 3 6 7 84 5

9 ULN2803

IC30

1112131415161718

I1 I2 I3 I4 I5 I6 I7 I8

O1 O2 O3 O4 O5 O6 O7 O8

10

1 2 3 6 7 84 5

9 ULN2803

IC31

1112131415161718

I1 I2 I3 I4 I5 I6 I7 I8

O1 O2 O3 O4 O5 O6 O7 O8

10

1 2 3 6 7 84 5

9 ULN2803

IC32

1112131415161718

I1 I2 I3 I4 I5 I6 I7 I8

O1 O2 O3 O4 O5 O6 O7 O8

10

1 2 3 6 7 84 5

9

Figure 3. Circuit diagram of the receiver and seven-position LED display matrix.

pin L6

pin L5

pin L4

pin L3

pin L2

pin L1

pin L0

42h

41h

49h

49h

66h

990090 - 14

Figure 4. How the numeral ‘3’ is represent-ed on a 5 x 7 matrix display element.

Page 9: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

low-pass filter, which guarantees error-free reception. The microcontroller(IC26) samples the signal every 400 µs.Any transient interference that might bepresent is suppressed by a special soft-ware algorithm, which evaluates thelengths of both the pulses and the inter-vening gaps and compares them toreference values. Finally, the softwarecomputes the parity of the receiveddata and compares this to the state ofthe received parity bit.

LED matrix display devices with a5×7 matrix are used for representingthe characters. Although a LED matrixdisplay costs marginally more than aset of 35 separate LEDs, it is significantlyeasier to handle. Since not all of thematrix diodes can be driven at thesame time, they must be switched onsequentially using a multiplexingprocess, which is not noticeable to theuser. Seven LEDs at most in one matrixcolumn, are illuminated at any onetime. Since the eye cannot respond asfast as the individual segments areswitched on and off, it sees an imageconsisting of 245 points (7×35).

Each display cycle starts with a highlevel on the data input of the first shiftregister (IC21). This high level lasts forone clock period. The five cascadedshift registers are clocked simultane-ously every 400 µs under interrupt con-trol, so that the active column movesstepwise from QA of IC21 through to QHof IC25. IC28 through IC32 are simpledriver ICs, which provide sufficient cur-rent for the matrices. Every column ofthe matrix is assigned to a RAM locationin the microcontroller. The informationto be displayed appears for 400µs onthe microcontroller outputs L0 throughL6, according to which column is beingdriven. Transistors T1 through T7 areused here as drivers. Due to the use ofmultiplexing, the LEDs must be driven athigher than usual current levels in orderto make them bright enough to beseen in daylight. To obtain sufficientbrightness, you should use matrix dis-plays with an optical efficiency of atleast 3 mcd at 20 mA.

The information for the running textdisplay is stored in a non-volatile 512-byte serial EEPROM (IC33). In order toallow the data to be quickly recalled,the EEPROM is addressed via theMicrowire interface of the microcon-troller at a clock frequency of 500kHz.The PC keyboard delivers the scancode of each key via the infrared inter-face, for example the code 26H for thenumeral ‘3’. In order to display thisnumeral on a 5×7 matrix, as shown inFigure 4, the scan code is convertedusing a look-up table, which in thiscase yields the values 42H, 41H, 49H,59H and 66H. These are applied toeach column in turn to display a ‘3’.IC36 is a ZSM560, which produces thepower-on reset pulse for the microcon-troller. The same type of IC is used in thetransmitter circuit.

The current consumption of thereceiver is around 25 mA when all dis-plays are dark, and around 100 mA(average) to 200 mA (peak) when thedisplay is operating. Here the use of asmall battery is not such a good idea.A 12-V mains adaptor is a suitable

power source, or a small 12-V sealedlead-acid battery (or a car battery)can be used if the display must beindependent of the mains.

Operation

When the power is switched on, therunning text that was last entered isautomatically displayed. If no text hasyet been programmed, ‘ELEKTOR’appears on the display. Connect thetransmitter to a PC keyboard and thenapply power to it. If the transmitter isworking properly, the Scroll LED shouldbe illuminated on the keyboard. Pressthe F2 key to clear the display andcause a cursor to appear. You cannow enter the desired text. Press theShift key briefly to switch betweenlower-case and upper-case charac-ters. This will cause the appearance ofthe cursor to change. Incorrectlyentered characters can be deletedusing the Backspace key, up to the firstcharacter entered. It is not possible toerase previously entered characters; ifthis is necessary, press the Esc key toend the current entry session and thenpress F2 to start anew. Press Enter whenyou have finished entering the text.After this, the running text display willstart automatically.

After each text display cycle, thetime of day is automatically displayedfor about 15 seconds. The time can beset using the F1 key. If you do not wantthis alternating display mode, you canuse the F3 and F4 keys to select a dif-ferent mode. The meanings of the key-board keys are explained in the ‘Key-board Input’ box. Since the microcon-troller does not have a real-time clockwith a separate 32-kHz crystal, theclock keeps relatively poor time, due tothe high clock frequency and the tol-erance of the crystal. A small trimmercapacitor in place of C1 can help toimprove the situation.

(990090-1)

Design editing: K. Walraven

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

Keyboard inputEsc: Cancel input

F1: Enter the time of day

F2: Enter the running text

F3: Running text only (on/off)

F4: Time of day only (on/off)

Shift: Switch between upper and lower case

Return: End the entry session and start the running text display

Delete: Erase the character in the input window

COMPONENTS LIST(receiver)

Resistors:

R1-R7 = 47Ω

R8 = 1MΩ

R9 = 100kΩ

R10-R16 = 750Ω

R17 = 100Ω

Capacitors:C1,C2 = 33pFC4 = 100nF

C5 = 10µF 16VC6 = 2000µF 25V (or 2200µF 25V)C7 = 2000µF 16 V (or 2200µF 16V)

Semiconductors:B1 = bridge rectifier B80C1000 (80V piv,

1A)T1-T7 = BC557IC14-IC20 = see textIC21-IC25 = 74164IC26 = COP8782C

(order code 996527-2)IC27 = ZSM560IC28-IC32 = ULN2803 (Sprague)IC33 = 93C66CB1 (ST-Microelectronics)IC34 = TFMS5360IC35 = 7805

Miscellaneous:Mains adaptor socketSmall heatsink for IC35X1 = 10MHz quartz crystalDisk. source code file, order code

996032-1

Page 10: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

In the circuit diagram, Figure 1, SW1 isa 16-pin 8-way DIL switch and is fittedinto a 16 way DIL socket (more aboutthis later). The common side of theswitch is grounded and the switchedside is pulled up to +5V via a 4.7 kΩ SILresistor network (R1). This is then con-nected to K1 (which is a doubled up10-way SIL header or 20-way IDCheader), and from there to the inputs ofIC1, a 74LS245 which is configured asa buffer. The outputs of IC1 are con-nected to both K2 and the inputs of

IC2. IC2 is a ULN2801A, which is anoctal Darlington driver chip with opencollector outputs. The outputs of IC2 areavailable on K3.Operation of SW1 will result in a TTL out-put on K2, or an open collector outputon K3. As can be seen from Table 1,the pin-out for K2 and K3 are virtuallythe same with the exception of theextra terminal (pin 11) on K3. TheULN2801A (IC2) incorporates internalprotection diodes for driving inductiveloads — like relays. These internal

diodes are commoned together on pin10 of IC2 and should be connected tothe voltage supply of the load. This will‘shunt’ any inductive kicks created byswitching the load, back into the load’spower supply away from the circuititself.The circuit can be powered via pins 1(+5 V) and 2 (0 V) of K2 or K3 and pin11 of K3 as required, depending uponthe application.The main circuit also includes a simplelogic indicator. If the circuit to be mon-

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

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

Hardware design: Adrian Grace

74LS245

IC1

3EN2

3EN1

11

12

13

14

15

16

17

18

19G3

2

3

4

7

8

9

5

6

1

1

2

2801A

IC2

VEE

+VS

ULN

11

12

13

14

15

16

17

18I1

I2

I3

I4

I5

I6

I7

I8

O1

O2

O3

O4

O5

O6

O7

O8

10

1

2

3

6

7

8

4

5

9

12345678

K2

910

K3

10 111 2 3 4 5 6 7 8 9

D1 D2 D3 D4 D5 D6 D7 D8

K1

10

11

12

13

14

15

16

17

18

19

20

1

2

3

4

5

6

7

8

9

R1 8x 4k7 1

2 3 4 5 6 7 8 9

SW1

K4

1

2

3

R2 8x 470Ω

1

2 3 4 5 6 7 8 9

16 15 14 13 12 11 10 9

1 2 3 4 5 6 7 8

002005 - 11

byte generatorfor testing DACs and digital controls

Figure 1. Circuit diagram of the byte generator.

Page 11: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

itored is connected to K1, a series ofeight LEDs connected to the open-col-lector outputs of IC2 shows the circuit’sstatus. Connector K4 allows the LEDsupply voltage to be selected. A linkbetween pins 2 & 3 for +5 V operation,and between pins 1 & 2 for an externalvoltage source.

Extensions

With a simple extension, this circuit canbe modified to include an externalclock source — see Figure 2.If the 8-way switch is removed (orensured that all switches are open) anda daughter board is plugged into K1,the main circuit can be driven by aclock source, rather than manually.The external clock source is connectedto the main board via a 20-way ribboncable. I found it easier to use a 20-wayIDC ribbon cable connection (2 × 10)even though the 10 signal lines aredoubled-up, than attempt to use a 10way crimp connector version (1 × 10).The cable is terminated at the clocksource board by a 20-way transition,and at the main board end in a stan-dard 20-way IDC connector.The clock source itself is based aroundIC1, a 74HCT4040. This is a +5 V TTLoutput version of the standard CMOS4040 chip. Eight sequential outputs, Q0through Q7 (CT0 through CT7) are fedto the ribbon cable connection whilstQ8 through Q11 (CT8 through CT11) arenot connected. IC1 is reset on power-up via R1-C1, and D9 discharges C1on power down.The (TTL-level) clock source is con-nected to GND and CLOCK. Depend-ing on the frequency required, con-necting a length of wire to CLOCK maybe used as a simple clock source byrelying on mains pick-up.

(002005-1)

Article editing: Jan Buiting

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

Table 1. Connector pin functions

K1 pin # Function K2 pin # Function K3 pin # Function1,2 + 5 V 1 + 5 V 1 + 5 V3,4 DI-1 2 0 V 2 0 V5,6 DI-2 3 D0-1 3 D0-17,8 DI-3 4 D0-2 4 D0-29,10 DI-4 5 D0-3 5 D0-311,12 DI-5 6 D0-4 6 D0-413,14 DI-6 7 D0-5 7 D0-515,16 DI-7 8 D0-6 8 D0-617,18 DI-8 9 D0-7 9 D0-719,20 0 V 10 D0-8 10 D0-8

11 V+

CTR12

IC1

CT=0

4040HCT

10

11

13

15

14

12

11

10

CT74

16

4

2

3

5

6

7

9

1

+ 9

8

7

6

5

4

3

2

1

0

8

K5

10

11

12

13

14

15

16

17

18

19

20

1

2

3

4

5

6

7

8

9

C2

100n

C1

100n

D9

1N4148

R1

4k

7

CLOCK

002005 - 12

Figure 2. Optional clock extension circuit for connecting to K1 of the byte generator circuit.

COMPONENTS LIST

Resistors:R1 = 8 × 4K7Ω SIL resistor packR2 = 8 × 470Ω SIL resistor pack

Integrated Circuits:IC1 = 74LS245 or 74HCT245IC2 = ULN2801A

Miscellaneous:D1-D8 = 5 mm ↔ 2mm wide LED, highefficiencyK1 = 20 way IDC connector K2 = 10 way SIL pin headerK3 = 11 way SIL pin headerK4 = 3 way SIL connector with jumper16 way turned pin DIL socket

COMPONENTS LISTClock divider extension

Resistor:R1 = 4k7Ω

Capacitor:C1 = 100nF

Semiconductor:D9 = 1N4148

Integrated Circuit:IC1 = 74HCT4040

Miscellaneous:K4 = 20 way DIL transitionK5 = 20 way IDC20 way ribbon cable

Page 12: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

In addition to the ready availability, lowcost and accustomed manner of useof a PC keyboard, connecting a PCkeyboard directly to a microcontrollersystem has the advantage that itmakes valuable port pins available thatotherwise would be used for polling akeyboard built from individual compo-nents. A PC keyboard, by contrast, pro-duces a serial signal, and is thus an

ideal complement to a microcontrollerproject. Of course, the manner in whichthe signal from the PC keyboard is con-structed has a few special features.Two lines are used for the serial datatransfer. One of these, labelled data,transfers the data, while the secondone transfers the clock. The serial datatransfer protocol, which is fairly com-plex, is explained below.

Key codesThe most widely-used type of keyboardis the MF2 model (‘multi-functional ver-sion 2’). It was originally developed byIBM for computers in the XT, AT and PS/2series. This model has become anindustry standard in the meantime, andalmost all PCs are equipped with it. Thekeyboard itself contains a ‘keyboardcontroller’, which generates the key

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

…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 touse a PC keyboard for developing microcomputer applica-tions, for example, in order to send commands or respond tospecific actions. Why go to the trouble of building your ownkeyboard when you can use a ready-made (and inexpen-sive) PC keyboard? The only problem is that you first have toknow exactly what signals a PC keyboard supplies.

By F. Wohlrabe

PC keyboard encodingEverything you ever wanted to know aboutthe signals from a PC keyboard…

Page 13: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

codes and provides for communicationwith the keyboard interface of the PC.The keyboard controller is usually amask-programmed microcontroller.Data are sent and received accordingto the IBM protocol. Commands canbe used to control the LEDs, specify thedelay and rate for key repetition, andselect the scan code set. The MF2 key-board has three different scan codesets. Set 1 is used by XT/PC and PS/2-30compatible computers, while set 2 isused by AT computers and all otherPS/2-compatible computers. Set 3 sup-ports workstations and terminal emula-tion on the PC. Country-specific key-board drivers in the operating systemtranslate each key press into thedesired character.When a key is pressed, the keyboardproduces a Make code. This code cor-responds to the scan code for that key.The repeat function causes the Makecode to be continuously repeated ifthe key is held down long enough. Thedelay time and repetition rate of therepeat function are programmable.When a key is released, the keyboardproduces a Break code. However, ifscan code set 3 is selected, no Breakcode is generated and the repeatfunction is disabled. After a reset, thekeyboard selects scan code set 2 as adefault.

You should bear in mind that a PC/XTkeyboard cannot be programmed,since its internal controller cannotaccept data. Only with the introductionof the AT computer did the keyboardbecome more user-friendly, since thebehaviour of an AT keyboard can beadapted to the needs of the user viasoftware. The following informationrelates to a keyboard that is set to oper-ate in the AT mode.

Sending and receiving

Figure 1 shows the pin assignments ofthe two commonly-used keyboardplugs (the 5-pin DIN plug and the 6-pinPS/2 plug). The keyboard is poweredwith 5 V from the PC. Its maximum cur-rent consumption is around 200 mA.In general, the clock rate is set by thekeyboard. It lies in the range of 10 to16.7 kHz. Data are sent using a start bit(always 0), eight data bits with bit 0 first,an odd-parity bit and a stop bit (always1). Figure 2 shows the data transfer tim-ing diagram.If an external device or system (whichis normally a PC) wants to send data tothe keyboard, the keyboard recognizesthis by the fact that the data line ispulled to earth by the external device

(the PC). The keyboard responds bysending the clock signal, and it expectsthe data to be sent synchronized to theclock signal. After the data transfer, thedata line must exhibit a High level,which acts as the stop bit. The key-board will continue to send the clockuntil this condition is satisfied. Followingthis, the command FEH is sent to requesta new data packet. Data areaccepted on the rising edge of theclock signal. After the stop bit has beendetected, the keyboard controllerholds the data line Low for the durationof one bit period. The keyboardanswers every command that itreceives, within at most 20 ms, by send-ing the byte FAH (ACK), except for theECHO and RESET commands.The keyboard sends data in the AT for-mat to an external device using the fol-lowing process.Before sending data, the keyboardcontroller first tests whether the clock or

data line is at earth level. Communi-cations can be blocked by holding theclock line Low. In this case, the key-board holds the data to be sent in aninternal buffer. The keyboard can senddata only if both the clock and datalines are at a High level. It then sets thedata line Low (for the start bit) andgenerates the clock signal. The dataare valid on the falling edge of theclock signal and change after the ris-ing edge.

In order to implement a MF2 keyboardconnection in a microcomputer sys-tem, you will also need to know certaininformation regarding the most impor-tant commands and return codes foran AT keyboard. These are described inthe following section. The key codes,which are the codes that the keyboardproduces according to the selectedscan-code set when keys are pressed,are listed in Table 1.

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

DATA

CLK

GND +5V

DIN 5

DATA

GND+5V

CLK

PS-2

4 3

12

6 5

2

31

54

002008 - 11

keyboard keyboard

1keyboard clock

keyboard data

external data

2 3 4 5 6 7 8 9 10 11

StartBit Stop

BitLSB MSB Parity

StartBit LSB MSB Parity Stop

Bit

keyboard pulling low 002008 - 12

Figure 1. Pin assignments of the standard PC keyboard connectors (viewed from the front).

Figure 2. Timing diagram for serial data transfers between the keyboard and a PC.

The most important commandsSET/RESET MODE INDICATORS → code EDHThis two-byte command controls the behaviour of the LEDs.Command: EDHCommand: 0000 0xxxBit 0: Scroll lockBit 1: Num lockBit 2: Caps lock1 = LED on, 0 = LED off

Page 14: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

Programming exampleIn conclusion, the manner in which a(microcontroller) system should addressan AT keyboard can be illustrated witha simple programming example.When the 5-V supply voltage isswitched on, +5 V is applied to the key-board. The keyboard controller in thekeyboard then executes a self-test. Ifthis is completed successfully, the key-board sends the byte AAH.

Next comes the selection of the scancode set. In this example, scan codeset 3 is selected using the SCAN CODESSELECT command, as follows:

1 Pull the data line to earth.2 Send the command code F0H, syn-chronous to the clock.3 The keyboard sends the code FAH(ACK) as confirmation.4 Pull the data line to earth.5 Send the command code 03H, syn-chronous to the clock.6 The keyboard sends the code FAH(ACK) as confirmation.

Now a key can be pressed, and thekey code from the scan code 3 set(see Table 1) will be received:

7 Press ‘G’ on the keyboard.

8 The keyboard sends the code 34H.A practical application example of theuse of a PC keyboard with a microcon-troller system is “Text Running Line Dis-play” elsewhere in this Supplement. Inthis example, a common or variety PCkeyboard is used for entering text to bedisplayed on an LED running-line dis-play. Keyboard decoding is handledby a COP-8 microcontroller, and thedata transfer to the running-line displayuses an infrared link. The photo at thehead of this article shows a small circuitboard holding the keyboard decoderand IR transmitter.

(002008-1)

ECHO → code EEHThe keyboard answers this command with EEH. It can beused to confirm the presence of a keyboard.

SCAN CODES SELECT → code F0HThis two-byte command selects the scan code set. Scancode set 2 is selected by default after a reset. However,scan code set 3 recommends itself for microcontrollerapplications, due to its simplicity. With scan code set 3, noBreak code is sent for almost all keys and the repeat func-tion is disabled.Command: FOHCommand: 0000 00xx01 = scan code set 110 = scan code set 211 = scan code set 3

READING ID CODE → code F2HIn response to this command, the keyboard sends threebytes which contain a manufacturer-specific code.1st byte = FAH (ACK)2nd byte = xxxx xxxx3rd byte = xxxx xxxx

SET TYPEMATIC RATE/DELAY → code F3HThis two-byte command controls the key repeat rate andthe delay for starting key repetition.Command: F3HCommand: 0xxx xxxxBits 5 and 6 control the delay, which ranges from 150 ms to1 s.Bit 6 Bit 5 Delay (± 20%)0 0 150 ms0 1 500 ms1 0 750 ms1 1 1 sBits 0 through 4 control the repetition rate, which rangesfrom 2 to 30 Hz. In the following table, only three values areshown as examples.Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Frequency (± 20%)0 0 0 0 0 30 Hz0 1 1 1 1 8 Hz1 1 1 1 1 2 Hz

SET ALL KEYS → codes F7H, F8H, F9H, FAHThese commands assign attributes to the keys, as follows:• F7H: all keys have the repeat function• F8H: all keys produce Make and Break codes• F9H: all keys produce only a Make code• FAH: all keys have the repeat function and produceMake and Break codes

RESET → code FFHThis command restores all keyboard settings to their defaultvalues.

The most important return codes

BAT COMPLETION → code AAHThis byte is sent to the external system after the supply volt-age has been applied or a reset command (FFH) has beenrecognized. In indicates correct execution of the keyboardself-test.

RESEND NAK → code FEHThis byte is sent in response to a data transfer error.

ACK → code FAHThis byte is sent to the external device in response to eachreceived command.

OVERRUN → code 00H/FFHAll key presses are stored internally in the keyboard untiltheir codes can be serially transferred to the externaldevice. If the storage buffer overflows, the byte 00H is sentfor scan code sets 2 and 3, while the byte FFH is sent forscan code set 1.

BREAK CODE PREFIX → code F0HWith scan code set 2, the byte F0H is sent before the Breakcode.

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

Page 15: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

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

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

Make Break Make Break Code Type

^ 29 A9 0E F0-0E 0E T

1 02 82 16 F0-16 16 T

2 03 83 1E F0-1E 1E T

3 04 84 26 F0-26 26 T

4 05 85 25 F0-25 25 T

5 06 86 2E F0-2E 2E T

6 07 87 36 F0-36 36 T

7 08 88 3D F0-3D 3D T

8 09 89 3E F0-3E 3E T

9 0A 8A 46 F0-46 46 T

0 0B 8B 45 F0-45 45 T

ß 0C 8C 4E F0-4E 4E T

‘ 0D 8D 55 F0-55 55 T

← Back 0E 8E 66 F0-66 66 T

|← →| Tab 0F 8F 0D F0-0D 0D T

Q 10 90 15 F0-15 15 T

W 11 91 1D F0-1D 1D T

E 12 92 24 F0-24 24 T

R 13 93 2D F0-2D 2D T

T 14 94 2C F0-2C 2C T

Z 15 95 35 F0-35 35 T

U 16 96 3C F0-3C 3C T

I 17 97 43 F0-43 43 T

O 18 98 44 F0-44 44 T

P 19 99 4D F0-4D 4D T

Ü 1A 9A 54 F0-54 54 T

+ 1B 9B 5B F0-5B 5B T

CapsLock 3A BA 58 F0-58 14 M,B

A 1E 9E 1C F0-1C 1C T

S 1F 9F 1B F0-1B 1B T

D 20 A0 23 F0-23 23 T

F 21 A1 2B F0-2B 2B T

G 22 A2 34 F0-34 34 T

H 23 A3 33 F0-33 33 T

J 24 A4 3B F0-3B 3B T

K 25 A5 42 F0-42 42 T

L 26 A6 4B F0-4B 4B T

Ö 27 A7 4C F0-4C 4C T

Ä 28 A8 52 F0-52 52 T

# 2B AB 5D F0-5D 53 T

Return 1C 9C 5A F0-5A 5A T

Shift l. 2A AA 12 F0-12 12 M,B

< 56 D6 61 F0-61 13 T

Y 2C AC 1A F0-1A 1A T

X 2D AD 22 F0-22 22 T

C 2E AE 21 F0-21 21 T

V 2F AF 2A F0-2A 2A T

B 30 B0 32 F0-32 32 T

N 31 B1 31 F0-31 31 T

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

Num 45 C5 77 F0-77 76 M

7 Nb 47 C7 6C F0-6C 6C M

4 Nb 4B CB 6B F0-6B 6B M

1 Nb 4F CF 69 F0-69 69 M

/ Nb E0-35 E0-B5 E0-4A E0-F0-4A 77 M

8 Nb 48 C8 75 F0-75 75 M

5 Nb 4C CC 73 F0-73 73 M

2 Nb 50 D0 72 F0-72 72 M

0 Nb 52 D2 70 F0-70 70 M

* Nb 37 B7 7C F0-7C 7E M

9 Nb 49 C9 7D F0-7D 7D M

6 Nb 4D CD 74 F0-74 74 M

3 Nb 51 D1 7A F0-7A 7A M

Del Nb 53 D3 71 F0-71 71 M

- Nb 4A CA 7B F0-7B 84 M

+ Nb 4E CE 79 F0-79 7C M

Enter E0-1C E0-9C E0-5A E0-F0-5A 79 T

Esc 01 01 76 F0-76 08 M

F1 3B BB 05 F0-05 07 M

F2 3C BC 06 F0-06 0F M

F3 3D BD 04 F0-04 17 M

F4 3E BE 0C F0-0C 1F M

F5 3F BF 03 F0-03 27 M

F6 40 C0 0B F0-0B 2F M

F7 41 C1 83 F0-83 37 M

F8 42 C2 0A F0-0A 3F M

F9 43 C3 01 F0-01 47 M

F10 44 C4 09 F0-09 AF M

F11 57 D7 78 F0-78 56 M

F12 58 D8 07 F0-07 5E M

PrtScE0-2A-E0-37

E0-B7-E0-AA

E0-12-E0-7C

E0-F0-7C-E0-F0-12

57 M

Scroll Lock 46 C6 7E F0-7E 5F M

PauseE1-1D-45-E1-9D-C5

nobreak code

E1-12-77-E1-F0-14-F0-77

nobreak code 62 M

Insert E0-52 E0-D2 E0-70 E0-F0-70 67 M

Del E0-53 E0-D3 E0-71 E0-F0-71 64 T

← E0-4B E0-CB E0-6B E0-F0-6B 61 T

Home E0-47 E0-C7 E0-6C E0-F0-6C 6E M

End E0-4F E0-CF E0-69 E0-F0-69 65 M

↑ E0-48 E0-C8 E0-75 E0-F0-75 63 T

↓ E0-50 E0-D0 E0-72 E0-F0-72 60 T

PgUp E0-49 E0-C9 E0-7D E0-F0-7D 6F M

PgDn E0-51 E0-D1 E0-7A E0-F0-7A 6D M

→ E0-4D E0-CD E0-74 E0-F0-74 6A T

Nb = numeric blockM = Make code when key pressedB = Break code when key releasedT = Typematic repeat function with delay & make

Symbol Scan code set 1 Scan code set 2 Scan code set 3

Make Break Make Break Code Type

Page 16: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

11Elektor Electronics 2/2000

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.

P.O. Box

190

When Electronics wasYoung (9)Dear Editor — in the Novem-ber 1999 issue of Elektor theabove interesting series has abrief note on Guglielmo Mar-coni that is misleading.Marconi’s early experimentswere carried out in Italy notEngland. He established thatcommunication using electro-magnetic waves was possibleat the age of 20 experimentingat his parent’s estate nearBologna. He moved to Englandas the Italian governmentshowed no interest in hisinvention and his English moth-er felt he would be more likelyto achieve success in hermother country. At the time,this country was a leading mar-itime nation and there was nomeans of communicating withships once they were out ofsight of land.It was in England that Marconifiled his patent applications,supported by the chief engineerof the Post office, Sir WilliamPreece.To call Marconi a ‘physicist’ isa gross insult. If he had been aphysicist, he would be unlike-ly to have achieved transat-lantic communication. Thephysicists of the day held theview that electromagneticwaves travelled in straight linesand were absorbed by land andwater. The curvature of theear th created a 50 mile highmountain of water across theAtlantic Ocean so no wavescoild possibly reach the NewWorld. Marconi with no formaleducation ignored the ‘experts’and was successful. Neitherthe physicists nor Marconiknew about the existence of theionosphere which convenient-ly reflected his waves fromPoldhu to St. Johns.Beware of exper ts!Guy Selby-Lowndes

Our contributor replies as fol-lows.”Interpretation of certain aspectsof history can be contentious. In

the EncyclopaediaBritannica, Marconi’s entryreads ‘Italian physicist andinventor of successful sys-tem of radio telegraphy.Received Nobel Prize forPhysics in 1909’. Similarly,Chambers Dictionary ofScientists lists Marconi as‘Marconi, (Marquis),Guglielmo, 1874-1937,Italian physicist and engi-neer, pioneer of radioteleg-raphy’. In line with thesetwo renowned publica-tions, I, too, have calledMarconi a physicist.””Owing to the shortness ofthe article, I could notinclude the fact thatMarconi had started hisexperiments in Italy.However, his main experimentswere carried out in England.While still a physics student atLeghorn technical school,Marconi in 1894 demonstratedthe possibility of sending wire-less signals over a distance of adistance of some 150 metres athis father’s estate near Bologna.However, since he found nobodyin Italy interested in his experi-ments, he and his Irish mothertravelled to England a year later.There, in 1896, he demonstrateda transmission of wireless sig-nals over a distance of threemiles between Flatholm Island inthe Bristol Channel and Penarth.He filed his first patent applica-tion for wireless telegraphy at theLondon Patent Office on 2ndJune 1896. In 1897, he transmit-ted wireless signals over a dis-tance of eight miles across theBristol Channel. This experimentdrew the attention of Sir WilliamPreece, the chief engineer of thepost office, as well as of thePress. In 1899, he transmittedMorse code across the EnglishChannel, which attracted atten-tion from the Admiralty, resultingin the installation of radio wire-less equipment on Royal Navalships. In 1901, he transmittedacross the Atlantic from Cornwallto Newfoundland. His pioneeringwork was rewarded by the award

(shared) of the Nobel Prize forPhysics in 1909.””It is a debatable point whetheror not Marconi or his fellowphysicists and engineers knewabout the ionosphere. MichaelFaraday’s experiments in the1840s and 1850s demonstrateda clear connection betweenmagnetism and electricity.Faraday’s friend and colleague,James Clark Maxwell, confirmedand explained Faraday’s experi-mental results by a mathematicaltheory. Maxwell’s calculationsshowed that magnetic and elec-tric fields affect each other, andthat light is a form of electro-magnetic waves. Some tradition-al physicists adhered to thebelief that light was a mechanicalphenomenon.””The conflict caused byMaxwell’s hypothesis that elec-tromagnetic waves are propagat-ed at the speed of light lasted formany years, until in 1888Heinrich Hertz, Professor at theTechnical College in Karlsruhe,finally closed the debate on thewave character of light. Hedemonstrated that the electricsparks produced by him causedelectrical vibrations which werepropagated into space at thespeed of light.””During a cross-Atlantic trip,Marconi had already noticed thattelegraph messages could be

received over distances ofup to 700 miles by day, butat up to 2000 miles bynight. This discoveryprompted Oliver Heaviside,an English physicist, andArthur Edwin Kennelly, anAmerican electrical engi-neer, independently andsimultaneously to publishtheir prediction of the exis-tence of an electricallyconductive layer in theupper atmosphere thatallows radio waves to fol-low the earth’s curvatureinstead of travelling in astraight line as predictedby a number of mathemati-cians. The predictions ofHeaviside and Kennellywere demonstrated in

1925 by Sir Edward VictorAppleton, an English physicistwho, in 1947, was awarded theNobel Prize for Physics for hiscontribution in the exploration ofthe ionosphere”.”Today, we know that the ionos-phere is a region of the earth’satmosphere at a height of 30-300 miles where short-waveradiation from the sun partly ion-izes gas molecules and atoms,leaving them positively charged.The ionized layers reflect short-wavelength radiowaves, whichmakes long-distance radio com-munication possible. The ionos-phere is layered according to theconcentration of free electrons,called D and E layers (also calledthe Heaviside or Kennelly layers,depending on which side of theAtlantic the term is used), whichresult from molecular ionization,and the upper layer, termed Flayer or Appleton layer, whichresults from atomic ionization.The thicknesses of the layersvary with latitude, season, timeof day, and solar activity”.”Since much of the research intopropagation was going on andpublished while Marconi, Braun,Slaby, and Arco, were conduct-ing their experiments in Englandand Germany, it is extremely like-ly that they read about it.”

Page 17: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

Elektor Electronics 2/2000

The 2-metre radio amateur band is stillthe most popular band worldwide. Itextends from 144 to 146 MHz in mostEuropean countries, and from 144 to148 MHz is some other countries likethe U.S.A. and Australia. Traditionally,the band is associated with short-rangecommunication over distances of up to50 miles or so using narrow-band fre-quency modulation (NBFM) andpower levels up to about 50 watts. Thisis also called ‘local traffic’ by someradio amateurs. Thanks to the rela-tively short antenna lengths and gen-eral profusion of cheap Japanese high-tech rigs and converted PMR kit, the 2-

m band is also the place to be formobile and portable communication,witness the presence of amateur-builtand operated repeater stations in manycountries and areas.

The lower part of the 2-metreband is reserved for narrow-bandmodes like CW (Morse) and SSB (sin-gle-sideband). Mainly because of thesmaller bandwidth and resultant bet-ter signal-to-noise ratio for weak sig-nals, these modes offer far greaterranges than NBFM. The ‘sound’ ofthe band section between say144.000 MHz and 144.400 MHz istherefore not unlike that of a short-

If you have a gen-eral coverage

shortwave receiveravailable andwould like to

extend its fre-quency range with

the two-metreamateur radio

band, the presentdesign is for you.

Easy to build fromlow-cost parts, the

converter shouldmake an excellententry-level projectfor budding radioenthusiasts. The

converter is also aprefect companionto the general-cov-

erage multi-mode SWreceiver described lastyear in this magazine.

16

Design by G. Baars

2-metre bandconverter

capture 144 MHz DX signals

RADIO, TELEVISION & VIDEO

Page 18: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

wave band like 10 metres (28 MHz).Provided you use a good directionalantenna (like a yagi) you should beable to pick up the CW idents of low-power beacons as well as CW andSSB signals from stations far beyondthe range of NBFM.

W H Y A C O N V E R T E R ?Many beginners to the radio hobbystart will start out with a second-handshortwave receiver. This will typicallybe a general-coverage type forCW/USB/LSB/AM/RTTY receptionbetween 150 kHz and 30 MHz. TheYaesu FRG-7 is an excellent example ofsuch a receiver, and although its designis 25 years old, it is still in populardemand in the radio amateur trade.The same beginners will also lack the

funds (and a licence) to buy anall-mode VHF transceiver, sowhy not add 2-metre bandreception to the available short-wave receiver? With some luck,this has an NBFM mode, too, soyou can also listen to ‘local’ traf-fic and get to know the hams inyour area.

It should be noted that recep-tion of DX (long-distance) sig-nals in the 2-metre bandrequires a good directionalantenna with a gain of at least10 dB and low-loss coax cable tothe receiver (or converter)input. Whatever low-noise pre-amplifier you may have inmind, experience shows that itis beaten hands down by agood antenna in an elevatedposition.

Following a well-establishedtradition in ham radio, the pre-sent converter mixes the 2-metre band signals down to the10-metre band (28.0-29.7 MHz).

H O W I T W O R K SThe circuit diagram of the 2-metre band converter is givenin Figure 1. As you can see itemploys only five active com-ponents, and these are all of thecommon or garden variety.

The design consists of four sections,a local oscillator, a mixer, an inputstage, and an output stage which willbe discussed separately below.

Local oscillator (LO)Transistor T1 and quartz crystal X1 areconfigured as an oscillator with an out-put frequency of 38.667 MHz. The crys-tal operates in third-overtone mode.Trimmer C1 is available to net the oscil-lator. The oscillator output signal is fedto frequency tripler T2 whose collectorcircuit is tuned to 116 MHz by L3 incombination with trimmer C7. Thelocal oscillator signal has a level ofabout 100 mV peak to peak and is

inductively coupled(via L4) to the mixer.

MixerThe mixer in the converter is a typeBF961 dual-gate MOSFET, T4. The localoscillator signal is applied to gate 2 (G2)and the RF input signal, to gate 1 (G1).Note that G2 is held at a fixed potentialof about 2.9 V by R6-R7, while G1 is dc-wise at ground potential. This is thetraditional configuration, with the G2resistors determining the conversiongain. The mixer products are availableat the drain of the BF961. These prod-ucts are, in principle: 144+116 =260 MHz, 144–116 = 28 MHz and theLO signal residue at 116 MHz. Thecombination L8/C16/C17 is tuned to28.8 MHz and serves to suppress the116 MHz LO component — given thefrequency difference between thesecomponents sufficient suppression isnot hard to achieve.

Input stageThe signal from the 2-metre antennais inductively coupled to the base ofT3, a low-noise VHF/UHF transistortype BFR91. The input inductor pairL5-L6 is accurately tuned to 144 MHzby trimmers C10 and C11. The inputbandfilter serves to suppress image

frequencies at 116–28= 88 MHz and at thesame time match the

transistor to the cable impedance of50 Ω. The amplified signal is capaci-tively coupled to gate 1 of the mixervia C13.

Output stageThe main function of the driver stagearound T5 is to provide a good matchto the receiver input (50 Ω). The gain ofthis stage is made adjustable with pre-set P1 to ensure that no overdrivingoccurs with sensitive shortwavereceivers.

The converter is powered by a regu-lated and well decoupled supply withan output of between 9 and 12 volts.Current consumption will be of theorder of 20 mA.

C O N S T R U C T I O NThe converter is built on a single-sidedprinted circuit board of which thedesign is shown in Figure 2. This boardis available ready-made through theElektor Electronics Readers Services.

Before you start soldering away werecommend you make inductors L3-L7. This is not at all difficult. Take a penor a drill bit with a diameter of 4.5 mm

17Elektor Electronics 2/2000

T1

BF494

T2

BF494

T3

BFR91

T5

BFR91T4

BF961

R1

15

0k

R3

18

0k

R2

2k

2

R41

50

k

R7

10

0k

R6

47

k

R8

1k

R5

56

R11

56Ω

R10

15

0k

R9

2k

2

1k

P1

C3

10p

C2

27p

C20

100n

C22

100n

C4

15p

C13

4p7

C15

1n

C17

22p

C23

100n

C24

100n

C25

100n

C1

22p C5

40p

C7

22p

C8

22p

C11

22p

C10

22p

C14

22p

C16

40p

X1

X1 = 38.667MHz

C21

10µ63V

C9

10p

C12

10p

C6

10p

C18

10p

C19

1n

L1

0µH22

L2

0µH33

L3 L4

L5 L6

L7

L8

0µH56

+9...12V

* *

*

*

000013 - 11

9V

9VBF494

BCE

BF961

G2

G1

D

S

*(3)

(2)

BFR91B C

E

zie tekst*see text*siehe Text*voir texte*

6V0

9V0

7V3

0V7

9V

2

100mV

0V7

7V8

0V

2V9

0V6

9V

3V4

8V

92

V7

50Ω

20mA

t t

50Ω

1

Figure 1. Circuit dia-gram of the 2-to-10-mconverter.

Page 19: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

and wind 5 turns of SWG20 (approx.0.8 mm dia.) silver-plated wire aroundit. Then stretch the turns evenly untilthe coil has a length of about 10 mm.Only on L5 you ‘tap’ the inductor at 2turns from the side you want to con-nect to ground (look at the componentoverlay). The tap is made by means of asmall piece of bare wire. Make sure itdoes not short-circuit the adjacentturns! Coupled inductors L5-L6 andL3-L4 should be spaced 1 mm apart.

Next, fit all the parts on to theboard, except transistors T3, T4 and T5.Remember, careful and accurate sol-dering work will be rewarded with a

circuit that works spot-on.To keep parasitic capacitance as

small as possible, the BFR91 and BF961transistors are fitted at the solder sideof the board. This is indicated by theirdashed outlines on the componentoverlay. Look very carefully at the ori-entation aids on these transistors tomake sure they are mounted the rightway around. On the BFR91, the collec-tor is the longest pin; on the BF961, thesource has a small tab and the drain isthe longest pin.

The completed board has to be fit-ted in a metal case. For our prototype,we used a small diecast case from

Hammond. The converter RF inputand output may be BNC or SO239style sockets, depending on what youhave available. The connectionsbetween the sockets and the relevantPCB pins should be made in coaxcable, for example, RG174 or RG58.

A N A D J U S T M E N T T O O LWe are sure that the simple RF probeshown in Figure 3 will pay dividendsin adjusting RF circuits. Build it andyou will wonder how you ever didwithout it.

The probe consists of an aluminiumpen case (a felt pen, cleaned out, of

18 Elektor Electronics 2/2000

000013-1(C) ELEKTOR

C1C2

C3

C4

C5

C6

C7

C8

C9C10

C11

C12

C13

C14

C15

C16

C17

C18

C19

C20

C21C22

C23C24 C25

H1 H2

H3H4 H5

H6H7

H8

L1

L2

L3L4

L5

L6

L7

L8

P1

R1

R2 R3

R4 R5 R6

R7

R8

R9 R10

R11

T1

T2

X1

000013-1

+9..12V

0

T

T

T3

T4

T5

000013-1(C) ELEKTOR

Figure 2. Copper track layoutand component mountingplan of the single-sided PCB.Three transistors aremounted at the solder side!

COMPONENTS LIST

Resistors:R1,R4,R10 = 150kΩR2,R9 = 2kΩ2R3 = 180kΩR5 = 560ΩR6 = 47kΩR7 = 100kΩR8 = 1kΩR11 = 56ΩP1 = 1kΩ preset H

Capacitors:C1,C7,C8,C10,C11,C14 = 22pF

trimmerC2 = 27pFC3,C6,C9,C12,C18 = 10pFC4 = 15pFC5,C16 = 40pF trimmerC13 = 4pF7C15,C19 = 1nF, raster 5mmC17 = 22pFC20,C22-C25 = 100nF ceramicC21 = 10µF 63V radial

Inductors:L1 = 0.22µH miniature chokeL2 = 0.33µH miniature chokeL3-L7 = 5 turns silver-plated wire,

dia. 0.8mm (SWG20), internaldiameter 4.5mm, length 10mm

Distance between coupled inductors:1mm, tap at 2 turns from groundside

L8 = 0.56µH miniature choke

Semiconductors:T1,T2 = BF494T3,T5 = BFR91T4 = BF961

Miscellaneous:X1 = quartz crystal 38.667MHz (3rd

overtone) (Mainline, tel. 08702410810)

PCB, order code 000013-1 (seeReaders Services page)

Case: e.g. Hammond 1590B56×107×25 (inside dimensions)

Page 20: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

course) in which a smalldiode detector ishoused. The end of thecopper or welding wireis carefully filed down to give a sharptip. The choice of diode is not critical.While SHF diodes like the 1S99 willenable measurements well into theGHz range, the run-of-the-mill BAT82will be fine for VHF circuits like thepresent converter.

The probe is only intended to giverelative indications, providing an easymeans to ‘peak’ inductors on their res-onance frequency. It will only lightlyload the tuned circuit and does notrequire a ground connection. The out-put voltage is fed to the inputs of avoltmeter — preferably analogue soyou can see the ‘trend’. In this case,needle movement on an antique mov-ing-coil meter is rather more usefulthan rolling digits on a DVM.

A D J U S T M E N TStart by setting all trimmers on theboard to full mesh, except C1, which isset to mid-travel. Connect the con-verter to the receiver and switch onthe power supply. Set P1 to the centreof its travel. Measure the current con-sumption. If it as expected, proceedwith the adjustment proceduredescribed below. “Hot” means carry-ing RF, “Cold” means not carrying RF,i.e., ground or positive supply. “Peak”means adjust for maximum readingon the voltmeter connected to theprobe, or for maximum S-meter read-ing on the receiver. In case of theprobe, the absolute value you measureis irrelevant, it’s the peak you shouldbe looking for.

1. Put the probe tip on the hot side ofC5 and adjust this trimmer for max-imum reading on the voltmeter.

2. Connect the probe to about 1 turnfrom the cold side of L3 and peakC7. You want the first peak startingfrom fully meshed. If not, you tuneto fosc × 4 instead of fosc × 3.

3. Connect the probe to 1 turn from

the cold side of L4 andpeak C8. Use the firstpeak starting from fullymeshed. If not, you

tune to fosc × 4 instead of fosc × 3.4. Set C10, C11 and C14 to half mesh.5. Tune the receiver to 28.800 MHz

and adjust C16 for maximum noise.6. Ensure that a relatively strong input

signal is available on a frequencybetween 144.800 and 145.000 MHz(RF generator or ask a local radio

amateur). Peak C10, C11 and C14for best reception. Reduce the inputsignal as required to ensure you canalways find a peak.

7. Adjust C1 so that the frequencyreadout on the receiver matches thesignal frequency, for example,144.800 MHz = 28.800 MHz.

8. Remove the input signal and adjustP1 so that the S meter on thereceiver just starts to deflect.

9. Tune to a weak signal in the 2-mband and carefully adjust C10, C11and C14 for highest S-meter indica-tion.

That concludes the adjustment of theconverter.

W E A T H E R - S A T E L L I T EB A N DBy changing the LO injection fre-quency to 109 MHz, it should be possi-ble to use the converter for reception oflow-orbiting weather satellites in the137 MHz band. A quartz crystal of36.333 MHz (again, 3rd overtone) isthen required, as well as readjustmentof all trimmers for the slightly lowerfrequencies.

(000013-1)

19Elektor Electronics 2/2000

Figure 3. Build thissimple RF probe andadjusting the con-verter will be a breeze.

Band plan for 144–146 MHz(IARU recommendation)144.000 – 144.500 MHzReserved for DX traffic. Some important sub-bands:144.000 – 144.025: EME (earth-moon-earth or ‘moonbounce’)144.050: CW calling144.100: Meteor scatter in CW144.150: CW DX144.300: SSB calling144.400 – 144.490: Beacons144.490 – 144.500: Beacon guard band, no transmissions

144.500 – 144.800 MHzAll modes, including144.500 SSTV calling144.600 RTTY calling144.700:FAX calling144.750:ATV calling

144.800 – 144.990 MHzDigital modes (Packet Radio)

145.0000 – 145.1875 MHzRepeater input frequencies (12.5 kHz raster, shift 600 kHz)

145.2000 – 145.5875 MHzSimplex channels, FM, 12.5kHz raster.

145.6000 – 145.7875 MHzRepeater output frequencies (12.5 kHz, shift 600 kHz)

145.8000 – 146.0000 MHzSatellite services

6p8

6p8

10nBAT82

tomultimeter

tomultimeter

2x

10n

000013 - 12

BAT82

BAT82

large felt pen3mmwelding wire

3

Page 21: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

Elektor Electronics 2/2000

Rather than starting straightaway withthe technical description of the projectit may be interesting to tell you some ofthe design history.

I found the website “The MinidiskCommunity Pages” on http://www.amu-lation.com/minidisc very helpful withinformation on how the Sony MZ-R30remote functions are controlled by dif-ferent resistance values across a pair ofwires.

Initially a 173-MHz licence-free“HomeCall “type transmitter and asuitable receiver was obtained, and thereceiver mounted in a control box withsome CMOS logic. This RF system

The MZ-R30 MDrecorder comes

with its owncable-operatedremote control,

which is primar-ily designed for

Walkman-ish operation. However, BrianHoughton’s own application for recording

choral rehearsals needed to have a means ofcontrolling the stop/start function from a loca-

tion that made cable control impossible. Here’show Brian solved the problem — elegantly and

without breaking the bank.

22

Design by Brian Houghton G4BCO

AUDIO & HI-FI

a useful add-on for a popular player

infrared remote controlfor Sony MZ-R30 MiniDisc Walkman

Page 22: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

works well up to 100ft, but is slow torespond (5 seconds) and only allowsfor the one function, in this case“pause”. The details of this remote con-trol can be found on :http://www.amulation.com/minidisc/mzr30_remote_radio/index.html.

Several emails from people regard-ing that design, were received and onein particular from someone whowanted some help with a college pro-ject to build a full function IR remotecontrol within a budget of £50. Thisspurred the author to have a go.

D E S I G NThis design logically splits into twoparts:

The hand held transmitter contain-ing the function select push buttonswitches, encoder and infrared trans-mitter.

The receiver/decoder containing theinfrared receiver, decoder and resis-tance ladder selector analogueswitches.

The remote control connector on theSony MD Walkman is unique andunfortunately is not obtainable as aspare item, and since the whole remotecable is £50 to purchase separately, itwas decided to perform minor surgeryon the existing cable.

R E M O T E C A B L EM O D I F I C A T I O N SThe remote control pod was openedand the existing cable disconnected. Amini XLR 5-way socket was fitted tothe free end of the old cable. This cableis then suitable to connect the IR Con-trol Unit to the Sony Walkman. Themodification is illustrated in Figure 1.

A new cable was made up using 5fairly thin wires, stripped from somemulticore cable, and a length of 3 mmheatshrink sleeving, with a mini XLR 5pin plug at one end and the old remotecontrol pod on the other. This enablesnormal cable remote functions to bemade via this ‘adapter cable’. The con-struction is illustrated in Figure 2.

H A N D H E L DT R A N S M I T T E RThe circuit diagram of the hand heldcontrol box is given in Figure 3. Thekey component is a Holtek HT12Aremote control encoder chip. The (con-densed) datasheets of this interestingand versatile chip appear elsewhere in

this magazine.Any button press

will place 0 volts onthe selected diode(s)to pull down the data inputs of theencoder IC1. Any data input going lowwill ‘wake up’ the encoder chip, startthe 455 kHz oscillator and the encodeddata stream will be output from pin 17(Dout) driving the two transistors andsubsequently the two infrared senderdiodes. A low value series resistor(2.2 Ω) enables the IR diodes to be dri-ven with high current pulses, althoughthe average current is only 10 mA pertransistor. The large electrolytic capaci-tor C1 is essential to overcome the rel-atively high internal resistance of thetwo AA or AAA batteries.

The relation between pushbuttonnumber, transmittedcode and the associ-ated MD recorder

function is shown intabular form in thecircuit diagram. Notethat pushbuttons S10

and S11 have to be pressed simultane-ously to transmit a RECORD com-mand. This is done to prevent inad-vertent selection of the RECORDmode.

R E C E I V E R / D E C O D E RU N I TThe Sony MZ-R30 requires a numberof specific resistance values to recog-nize certain functions selected via itsremote input socket: The resistancevalues and associated functions areshown in Table 1. The code in the thirdrow is the decimal value of the 4-bitdata used by the IR encoder/decoders.

The use of type4016 analogueswitches (IC3, IC5,

23Elektor Electronics 2/2000

3 2

54 1

XLR FreeSocket (Rear)

2 3

51 4

XLR FreePlug (Rear)

MD

Remote Pod connections:1 wht Right Channel

990075 - 11

2 yel Ctl Pin 43 gry Ctl Pin 24 red Left Channel 5 brn Common

4 1

53 2

MiniSocket

1Figure 1. Modification tothe remote control cablesupplied with the SonyMD MiniDisc walkman.

R5

10M

X1

455kHz

C2

100p

C3

100p

R1

10k

R2

10k

R3

2

R4

2

D26 D27

T1

T2

BC550

C4

100n

D4

D3

D2

D1

S1 S2

D7

D6

D5

S3

D10

D9

D8

S4

D12

D11

S5

D16

D14

D13

S6

D18

D15

S7

D19

D17

S8

D20

S9

D23

D22

D21

S11

D25

D24

S10

Bt1

3V

C1

100µ16V

"0" "1" "2" "3" "4" "5" "6" "7" "8" "9"

"Shift"

2x

"0""1""2""3""4""5""6""7""8""9"

Spare

Prev/Back

PAUSE

STOP

Volume –

Volume +

MARK (Rec)

MODE (Play)

RECORD(in stop or pause)

CODE FUNCTION

Next/FWD

990075 - 13

HT12A

ADOUT

IC1

AD11

AD10

OSC2 OSC1

AD9

AD8

17

18

13

15 16

12

11

10

14TE

A0

A1

A2

A3

A4

A5

A6

A7

9

8

7

6

5

1

2

3

4

D1 ... D25 = 1N4148

D26, D27 = LD271

Figure 2. The remote podcan still be used if yougive it a connector again.

Figure 3. Circuit diagramof the hand held control.

2

3

Page 23: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

24 Elektor Electronics 2/2000

HT12D

ADOUT

IC1

OSC2 OSC1

D3

D2

D1

D0

17

18

13

15 16

12

11

10

14TE

A0

A1

A2

A3

A4

A5

A6

A7

9

8

7

6

5

1

2

3

4

4028

IC2

X/Y

14

11

12

13

1015

8

3

2

6

7

4

5

9

1

0

1

2

3

4

5

6

7

8

9

1

4

2

R1

56k

R3

10k

R4

4k7

R5

2k

2

R2

10

k

R7

27Ω

R8

1k

5

R9

1k

3

R10

1k

3

R11

56Ω

R12

1k

8

R14

15

R13

1k

5

R15

1k

5

R16

2k

R17

2k

R18

10

R19

5k

6 R20

4k

7

R21

68

1k

P1

IC3b

5

3

4

IC6a

13

2

1

IC3c

12

10

11

IC5a

13

2

1

IC6b

5

3

4

IC6d

6

9

8

IC6c

12

10

11

IC3d

6

9

8

IC5d

6

9

8

IC3a

13

1

2

JP2

JP2

T2

BC547

T1

BC550

D1

JP1

C3

100n

LP2950CZ5.0

IC4

C2

4µ716V

C1

2µ225V

R6

2k

2D3

K3

D21N4001

IC5b

5

3

4

IC5c

12

10

11

IC3

14

7

IC5

14

7

IC6

14

7

C7

100n

C6

100nIC2

16

8

C7

100n

TEST

SFH506SFH505A

IS1U60

5V

5V

5V

990075 - 14

5V IC3, IC5, IC6 = 4016

CV

K232

1 45

XLR-Socket

4

Figure 4. Circuit dia-gram of the remote con-trol receiver/decoder.

Page 24: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

IC6) in conjunction with a resistor net-work (R7-R20) offers a simple andcheap method of selecting the requiredresistance value.

A Sharp IS1U60 IR receiver ICdetects the IR carrier and its output isinverted by T1 and fed to the HT12D

25Elektor Electronics 2/2000

(C) ELEKTOR

990075a

C1C2

C3

C4C5C6C7

D1

D2

D3

H1 H2

H3H4

IC1

IC2IC

3

IC4

IC5

IC6

JP1

JP2

P1 R1 R2

R3R

4

R5

R6

R7R8 R9

R10

R11

R12

R13R14

R15R16R17R18 R19

R20R

21

T1

T2

V2

0+

tes

t

+ T

990075a

+

(C) E

LEK

TOR

9900

75a

5

(C) ELEKTOR

990075b

C1

C2

C3

C4

D1

D2D3

D4

D5

D6 D

7

D8

D9D10

D11

D12

D13

D14

D15

D16

D17

D18

D19

D20

D21

D22

D23

D24 D

25 D26

D27

H1

H2H3

H4

IC1

R1

R2

R3

R4

R5

S1S2 S3

S4S5S6 S7

S8S9S10

S11

T1

T2

X1

+-

990075b

(C) E

LEK

TOR

9900

75b

COMPONENTS LIST

Receiver/decoder(Board section 990075a)

Resistors:R1 = 56kΩR2,R3 = 10kΩR4,R20 = 4kΩ7R5,R6 = 2kΩ2R7 = 27ΩR8,R13,R15 = 1kΩ5R9,R10 = 1kΩ3R11 = 56ΩR12 = 1kΩ8R14 = 150ΩR16,R17 = 2kΩR18 = 100ΩR19 = 5kΩ6R21 = 680ΩP1 = 1kΩ preset H

Capacitors:C1 = 2µF2 25V radialC2 = 4µF7 16V radialC3-C7 = 100nF

Semiconductors:D1,D3 = low-current LEDD2 = 1N4001T1,T2 = BC550IC1 = HT12D (Holtek) (Maplin)IC2 = 4028IC3,IC5,IC6 = 4016IC4 = LP2950-CZ5.0

Miscellaneous:JP1 = SFH506-36

Transmitter(Board section 990075b)

Resistors:R1,R2 = 10kΩR3,R4 = 2Ω2R5 = 10MΩ

Capacitors:C1 = 100µF 16V radialC2,C3 = 100pFC4 = 100nF

Semiconductors:D1-D25 = 1N4148D26,D27 = LD271 or similar IR LEDT1,T2 = BC550IC1 = HT12A (Holtek) (Maplin,

Farnell)

Miscellaneous:S1-S11 = pushbutton, PCB mount,

Multimec or D6-R-RDBT1 = 2 off AA or AAA penlight

batteryX1 = ceramic resonator, 455kHz

(e.g., SB455E) (Mainline, 0870 2410810)

decoder IC which latches the original4 bits of data. This data is then pre-sented to a BCD/Decimal decoder(IC2, 4028) which selects one of ninea n a l o g u eswitches. Thesein turn select the

appropriate point on a resistor ladderto be used by the MZ-R30 for theselected function. The condenseddatasheet of the HT12D IR decoder

Figure 5. PCB copper track layouts and component over-lays. Cut the board to separate the transmitter (below)and receiver (top) section.

Page 25: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

appears elsewhere in this issue.A common analogue switch (IC3a)

controlled from the IR decoder (VT)pin is used to gate the output, since the4-bit data is latched by the decoder andalways selects the last switch that wasused. The minimum selectable resis-tance (function “Preview/Back”) is1000 Ω and to achieve this, a 1kΩ pre-set potentiometer, P1, is used to addapproximately 700Ω in series with the300Ω total resistance of the two ana-logue switches. A bright LED, D1, isalso switched on at the same time toindicate correct operation.

The resistance value associated witha control code appears across JP2, theoutput of the circuit. A suggested con-nection to a mini-DIN socket is shown

in the circuit diagram. Alternatively,you may want to use a mini XLR chas-sis plug. The pinout is then as follows:

Pin 1: audio leftPin 2: pin 1 of IC3aPin 3: preset P1Pin 4: audio rightPin 5: audio common

Alternatives to the IS1U60 include theSiemens SFH505A and SFH506. Theirpin functions being different from theIS1U60, you have to pay attention tothe way they are connected to theboard.

The output of the remote controlreceiver is wired to a suitable miniaturesocket which is then connected to the

remote control input of the MD30-RZvia 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 adaptorcapable of supplying 8-12 V DC atabout 100 mA.

C O N S T R U C T I O NThe printed circuit board you will needto build this project is shown in Fig-ure 5. The first thing to do is separatethe receiver and transmitter sectionswith a jigsaw.

To keep cost as low as possible,these are single-sided circuit boards.They contain a few wire links whichshould be fitted before anything else.

The PCBs are easily stuffed usingthe parts list and the component over-lay. Be sure to fit all polarized compo-nents the right way around, that is,diodes, LEDs, transistors, electrolyticcapacitors and ICs. Although they areneither expensive nor hard to get(Maplin), the HT12 ICs are best fittedin IC sockets.

The transmitter board has a numberof diodes fitted at the solder side of theboard. The IR sender diodes may befitted with reflector caps to boost theirdirectivity.

The author fitted his version of thehandheld control in a type HH1 plainbox from Maplin. This had enoughspace to incorporate a holder for twoalkaline rechargeable AAA cells.

S E T T I N G U PThe only setting up required is toadjust the 1 kΩ preset to compensatefor the resistance of the analogueswitches. This is done as follows:

a) Install jumper JP2. This links R20,the 4.7 kΩ resistor from the com-mon rail of the network, to 0 V.

b) Connect a DMM on a suitable resis-tance range to be able to measure7,050 Ω, across the output pins 2and 3 on the XLR connector.

c) Power up the receiver/decoder andselect code 4 “Stop” on the remotehand held control.

d) Adjust preset P1 to give 7,050 Ω onthe DVM.

e) Remove power, pull JP2 and dis-connect the DVM.

f) Connect the receiver/decoder to theMZ-R30 and test all functions.

(990050-1)

Design editing: L. LemmensArticle editing: J. Buiting

26 Elektor Electronics 2/2000

Table 1. MiniDisc Walkman remote control codes

Function: Resistance: Code:

Preview/Back 1,000 Ω 1Next/Forward 3,627 Ω 2Pause 5,156 Ω 3Stop 7,050 Ω 4Volume (–) 8,400 Ω 5Volume (+) 9,900 Ω 6Mark 11,900 Ω 7Mode 14,000 Ω 8Record 19,500 Ω 9

Page 26: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

Elektor Electronics 2/2000

Almost every PC these days has asound card. However, most PC usersemploy it only to reproduce operatingsystem sounds, music from audio CDsand sound effects for games and pre-sentations. They thus use only thestandard features of the software forthe sound card, even though there areoutstanding programs available thatallow even non-musicians to exploitthe manifold features of modernsound cards. These are sound synthe-sizer programs.

Such synthesizers are sometimeseven included in the software pack-ages that come with the better qualitysound cards. However, there are alsoseparate programs, such as Generatorfrom Native Instruments or Rebirthfrom Propellerhead. These programssimulate the functions and operationsof a real synthesizer using a screen fullof sliders and knobs that are controlledby the mouse. They represent a sort ofGordian knot for anyone who wants todo more than adjust a single slider.

The circuit described in this article

makes working with a software syn-thesizer considerably easier. It utilisesthe ability of a software synthesizer toreceive MIDI codes and to use thesecodes to drive certain controllers. Thehardware of the MIDI parameter boxcan thus be kept very simple. A micro-controller reads the positions of eightstandard potentiometers in turn, via an8-channel A/D converter. If one or moreof the potentiometer positions ischanged, the microcontroller sends thisinformation in MIDI format to theMIDI input of the sound card. The soft-ware synthesizer translates the MIDIcodes into new settings for the con-troller in question.

L A Y E R SA N D S U P E R - L A Y E R SThe somewhat nebulous term ‘layer’often crops up in connection withMIDI. Layers are actually nothing morethan groups of eight synthesizer func-tions, which correspond to the eightpotentiometers of the MIDI parameterbox using a sort of multiple allocation.

Using a key-board and

mouse tooperate theinnumerable

knobs and slid-ers of a PC mix-

ing board can turnplaying around with a

sound synthesizerinto an agonizing

experience. With theMIDI parameter boxit’s a different story!

28

Design by T. Klose

convenient software synthesizer operation

GENERAL INTEREST

parameter box forMIDI software

Page 27: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

The parameter box has pushbuttonswitches that can select one of six lay-ers. The MIDI codes sent by eachpotentiometer (or the controller) thusvary according to the layer that isselected.

The assignment of layers to specificfunctions is not the same for all con-trollers. Instead, controllers can bedivided into different groups. The var-ious types of assignments are referredto as super-layers. The MIDI parame-ter box knows the three most com-monly used groups and adapts theMIDI codes to their specific needs.Table 1 summarises the contents of thesix layers within the three super-layers.

H A R D W A R EThe most important elements of thehardware, which have already beenmentioned, can easily be recognised inthe schematic diagram shown in Fig-ure 1. The eight potentiometers areconnected to channels 0 through 7 ofthe A/D converter IC1. The MAX186IC, which has already been used in a

number of Elektor projects, has aninterface to the microcontroller (IC2).This interface carries the output datafrom the D/A converter (DOUT) andthe clock (SCLK), as well as the settingsfor the multiplexer (DIN). The con-verter is controlled via the SSRB andCS leads, synchronous to SCLK.

The microcontroller is a typePIC16F84 IC that is clocked at 10 MHz.In addition to the potentiometer posi-tions, it also reads the layer selectionswitches (S1–S6), the MIDI channelswitches ((S9–S12) and two other push-button switches, MEMO and RESET.Table 2 describes the meanings anduses of all of the switches.

MIDI communication with thesound card takes place via port leadRB7. The MIDI signal can be visuallychecked via the (blinking) LED D2.There is a good reason why two con-nection options are shown in thedrawing. Actually, the MIDI parameterbox should only be connected to thesound card via a true, optically isolatedMIDI interface. Such an interface is

part of the AWE-64 package, forinstance, but it cannot be ordered sep-arately. You can either buy one foraround £15 in a computer shop or copyone of the numerous Elektor designs(such as the MIDI interface in the 1995Summer Circuits issue). A less elegantoption, but one that can conceivably beused if no other MIDI devices are con-nected, is to connect the MIDI para-meter box directly to the 15-pin joystickinterface, which also has a MIDI input.The 220Ω resistor in the data line pro-tects against short circuits if this alter-native is used. This type of connectionhas one advantage, which is that theoperating power can be drawn fromthe joystick port, so that D3, C17, C18and IC3 are not needed.

This brings us to the power supply.An external power supply is obligatorywith ‘real’ MIDI interfaces, in order toensure the electrical isolation of the PCand the MIDI equipment. Only capac-itors C17 through C19 and the voltageregulator IC3 are needed to provide asufficiently stable +5 V. Power can be

29Elektor Electronics 2/2000

PIC16F84

OSC2

IC2

OSC1

MCLR

RA4

RA0

RA1

RA2

RA3

RB0

RB1

RB2

RB3

RB4

RB5

RB6

RB7

17

18

13

12

11

10

16 15

14

1

3

9

8

7

6

2

4

5

MAX186

REFADJ

SSTRBIC1

DGNDAGND

DOUT

SCLK

SHDN

VREF

VSS

CH0

CH1

CH2

CH3

CH4

CH5

CH6

CH7

DIN

20

13 14

17

15

19

16

18CS

10

11

12

9

1

2

3

4

5

6

7

8

C15

33p

C16

33p

X1

10MHz

R3

10Ω

C10

100n

C9

10µ63V

C13

10µ63V

C17

10µ63V

C19

10µ63V

C14

100n

C18

100n

C11

100n

C12

100n

K3

C8

K5

R4

10

k

K4

R1

1k

5

7805

IC3

D1R21k

470Ω

P9

R15

10

kR

141

0k

R13

10

k

R16

10

kR

111

0k

R10

10

kR

91

0k

R12

10

k

D31N4001

8x 100n

C7 C6 C5 C4 C3 C2 C1

R6

22

R8

1k

5

D2

R7

10

k

T1

BC547BK1

R5

22

2

3

1

5

4

K2

K7

10

11

12

13

14

15

1

2

3

4

5

6

7

8

9

K6

P1 P2 P3 P4 P5 P6 P7 P8

K9

K10

S9 ... S12

3

S1 S2 S3 S4 S5 S6 S7 S8

1

2

4

8

5V

5V5V

5V

INITVALUE

MIDIDATA

MIDI CHANNEL

1

1 2 3 4 5 6 7 8

CV CV CV CV CV CV CV CV2 3 4 5 6

LAYER

MEMORY RESET

+5V

P1...P8 = 8x 47k

-10/P

K10

K9

K6

K5

K3

*

*

see text*zie tekst*siehe Text*voir texte*

990087 - 11

12V

CV

1 2 3 4

K4

1

Figure 1. The microcontroller reads thestatus of the switches and of each ofthe eight potentiometers in turn.

Page 28: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

provided by a simple 12 V mainsadapter. Diode D2 provides protectionagainst a reverse-polarity connection.

A S S M A L L A S P O S S I B L ETo make the construction of the MIDIparameter box as convenient as possi-ble, we have designed a printed circuit

board that is the size of a pack of ciga-rettes, as shown in Figure 2. It is avail-able from Readers Services (ordernumber 990087-1). You shouldn’t expe-rience any problems mounting all thecomponents, which takes around halfan hour. Pay attention to the orienta-tion of the electrolytic capacitors, the

LEDs and the ICs, and don’t forget thewire bridge next to K5. After this youcan prepare the control panel. Thepotentiometers and switches can beglued to the front panel in a reasonablearrangement, such as that shown inFigure 3, and wired using flatcable.You can also mount these components

30 Elektor Electronics 2/2000

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

layer 6 pitch ben. filter ben.amplitude

ben.LFO PMOD

ben.FMOD D

ben. AMOD

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

Table 2. Meanings and uses of all switches.

Component Designation Meaning

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

LED D1 Init ValueBlinks after the power is switched on to indicate that one of the three 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.

Page 29: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

on a piece of prototyping board andwire them point-to-point. Of course,you can also design a ‘real’ circuitboard. You should dress the flat cablessuch that the unit can later be built intoan enclosure.

T E S T I N GIn order to thoroughly test the MIDIparameter box, you absolutely need aMIDI monitor with a MIDI-throughoption for the PC, so that you canobserve the transmitted MIDI data onthe monitor and properly calibrate thepotentiometers. The text box containmore information about suitable MIDImonitors. After a visual inspection ofthe soldering, connect the partstogether and cable the unit to the PC.Then switch everything on and startthe MIDI monitor. All the stored valuesin a virgin PIC are set to FFh, so theymust be set to valid MIDI protocol val-ues by pressing the Reset button. Nextselect super-layer 1 and layer 1 (thedefault layer) by pressing S1 twice.

Now comes the moment of truth.When the potentiometers are rotated,LED D2 should flash and the MIDI

monitor should dis-play control codes.These will have valuesranging from 0 to 127.

If this does not hap-pen, thoroughly check the circuit con-struction, the cabling and the settingsof the MIDI monitor. If this doesn’thelp, you can curse Windows or thesound card.

However, if the MIDI monitor dis-plays the first MIDI events, then every-thing is in order. Trimpot P9, by theway, can also be used for calibration toadjust actual range of the MIDI valuesto 0 through 127.

Verify that the MIDI channel is

changed by S9–S12(binary), and thatchanging the layerworks properly.When the layer is

changed, the last stored values for thepotentiometers are always output viathe MIDI interface. The advantage ofthis is that the parameters of the syn-thesizer or the sound card are reset totheir last stored values. If for exampleyou change the volume in layer 3,change to a different layer and sometime later return to layer 3, the volumewill be restored to its original level. Ifyou want to avoid this, all you have todo is to press the Memo button before

31Elektor Electronics 2/2000

990087-1(C) ELEKTOR

C1

C2

C3

C4

C5

C6

C7

C8

C9

C10

C11

C12

C13

C14

C15 C16

C17

C18C

19

D1 D2

D3

H1 H2

H3H4

IC1

IC2

IC3

K1

K2

K3K4

K5

P9

R1

R2R3 R

4

R5

R6R7

R8

R9

R10

R11

R12

R13

R14

R15

R16

T1

X1

3

1

990087-1

2

4

+

0

990087-1(C) ELEKTOR

2

Figure 2. The MIDI para-meter box can be buildusing this small printedcircuit board.

COMPONENTS LIST

Resistors:R1,R8 = 1kΩ5R2 = 1kΩR3 = 10ΩR4,R7,R9-R16 = 10kΩR5,R6 = 220ΩP1-P8 = 47kΩ linear potentiometerP9 = 470Ω preset Hi

Capacitors:C1-C8,C10,C11,C12,C14,C18 =

100nFC9,C13,C17,C19 = 10µF 63V radialC15,C16 = 33pF

Semiconductors:D1,D2 = LED, high efficiencyD3 = 1N4001T1 = BC547BIC1 = MAX186BEPPIC2 = PIC16F84-10/P (programmed,

order code 996521-1)IC3 = 7805

Miscellaneous:K1 = 4-way SIL connectorK2 = 2 PCB solder pinsK3,K6 = 10-way SIL connectorK4,K9 = 5-way SIL connectorK5,K10 = 6-way SIL connectorK7 = 15-way Sub-D plug, chassis

mount (see text)K8 = 5-way DIN socket, chassis

mount, 180° (see text)K11 = mains adaptor socketS1-S8 = pushbutton, 1 make contactS9-S12 = on/off switchX1 = 10MHz quartz crystalEnclosure, e.g. Teko 363

(216x130x77mm)PCB, order code 990087-1

Page 30: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

changing the layer. In this case only thevalues that have changed since the lastlayer change are stored.

(990087-1)

Text editing (German original): R. Gerstendorf

Design editing: K. Walraven

32 Elektor Electronics 2/2000

M R P CMIDI REMOTE PARAMETER CONTROL

0 1273

0 1275

0 1277

0 1271

2

LAYER

MEMORY1

MIDIDATA

INITVALUE

RESET2 3 4 5 6

CHANNEL

0 1274

0 0 01276

1278

127

990087 - F

+

-

MIDI monitorsThere is a whole series of MIDI monitors that can be used with aPC. An outstandingly suitable program is MIDI-OX, for which a betaversion is available for free on the Internet atwww.members.xoom.com/_XOOM/MIDIOX/moxbeta.htm. Afterinstalling and starting the program, you must first select the MIDIdevices, either via the menu Options/MIDI Devices or by clickingon the dark blue button with the five-pin DIN connector (see FigureA). On this PC, the MIDI input and output of the SoundBlaster SB16are active.The MIDI Port Activity window shown in Figure B appears if youpress 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 isclear which channel is active.The content of the transmitted data appears in the Monitors Outputwindow. The first column shows the time when the MIDI messageoccurred (as noted by MIDI-OX), and the second column indicatesthe MIDI port via which the message arrived (in this case, Port 1 viaSB16 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) andDATA2 shows the assigned value. Just as with DATA1, only thelower seven bits are used, so that the values range from 0 to 127.CHAN shows the MIDI channel once again. Note that MIDI officiallyuses channel numbers 1 through 16, but many programs display 0through 15. When a different super-layer is active or the layer ischanged, 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. Oneexample 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 bothprograms are available. These can be used for only a very short time and have no save functions, but they are an outstandingchoice for just playing around with the MIDI parameter box.

Figure 3. A reasonablearrangement for thecontrol elements onthe front panel.

3

Page 31: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

33Elektor Electronics 2/2000

is presented as a lively little ornamentconsisting of red LEDs arranged in theshape of a heart. Flashing all the time,the LEDs beg for attention. Very deco-rative, we’d say, and highly suitable as agift to someone close to your real heart.

Do not expect the latest design tech-nology from this kit. As indicated bythe circuit diagram, the circuit consistsof little more than a bistable multivi-brator built around two common orgarden transistors, with seven rows offour LEDs each in their collector lines.LEDs LD1-LD12 form the inner heart,and LD13-LD25, the outer heart. Bothhearts flash in alternate fashion tomimic the well-known pump action.

The high-efficiency LEDs operate‘sparsely’ using series resistors R1-R7.The result is a current consumption ofjust 8 mA, enabling a 9-V PP3 batteryto last for about 24 hours.

If you want to personalise the cir-

cuit, you may decide to use differentcolour LEDs for one of the hearts. Yel-low LEDs, for example, do a fine job.However, in that case the series resis-tors may have to be decreased to about820 Ω to compensate the higher voltagedrop of yellow LEDs. If you do notchange the resistors, the light intensityfrom yellow LEDs will be too low.

We do not know if Velleman offersany kind of warranty on this circuit.Reproducibility will not be a problem,we reckon, but a guarantee that theflashing sweetheart will succeed inactually conquering a heart will beimpossible to obtain! However, at aprice of just £4.99 it’s well worth theeffort.

The Maplin order code for this kit isVX75S.

(000031-1)

Text (Dutch original): S. van Rooij.

A small effort and an even smaller outlay isrequired to throw an electronic gadget togetherthat’s sure to make a great gift for Valentine’s Day.Belgium-based Velleman are suppliers of kits thatenable this type of circuit to be built by themasses. We decided to try out one of their kits.

an original Valentine present

KIT DESCRIPTION

Most of you, we are convinced, wouldavow to being pretty seriouslyinvolved in electronics, be it as ahobby or professionally. Sometimes,too, you may get the feeling that it’s allgetting a bit too serious. Typically, ourreaders are busy working on practicalapplications of published circuits, ortweaking the specs. They will rave onabout distortion, signal/noise ratios, ormemory capacity, painstakingly seek-ing ways to achieve improvements nobetter than tenths of a decibel or a fewparts per million.

Riveting stuff, of course, but itmakes you wonder sometimes if allthis activity captures any of the sheerfun that can be had from the noble artof soldering. That is why we can notresist voicing a clear “start having funagain” note to those of you with a ten-dency of taking a high-brow look atthe hobby. Electronics, we feel, neednot always be useful, in fact there’s noreason why it should not be amusing,playful and without pretension. Withsimple means, dozens of interestingprojects can be built. So, why not buildan original doorbell, a running lightsunit or a flashing brooch? Just for thefun of it.

Quite possibly, people around youmay value simple gadgets more thanthe latest high-spec complex devices,probably because to them the latter willforever remain big electronic mysteries.

A L O V E L Y F L A S H E RMost Summer Circuits and Decemberissues of Elektor Electronics contain atleast a few ‘playful’ electronic circuits.Some kit suppliers go one step further,having discovered a market for suchproducts.

In the recent Maplin catalogue, wecame across a Flashing LED Sweet-heart from kit supplier Velleman. This

T2

BC547B

T1

BC547B

R8

33

k

R9

33

k

C1

22µ

C2

22µ

LD12

LD11

R3

1k

2

LD10

LD9

LD8

LD7

R2

1k

2

LD6

LD5

LD1

LD2

R1

1k

2

LD3

LD4

LD13

LD14

R4

1k

2

LD15

LD16

LD20

LD19

R5

1k

2

LD18

LD17

LD24

LD23

R6

1k

2

LD22

LD21

LD25

LD26

R7

1k

2

LD27

LD28

E1

9V

000031 - 11

flashing LED sweetheart

Page 32: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

35Elektor Electronics 2/2000

Nick’s real name (we are informed) is Nicola Asuni and helives on Sardinia. The website he built contains data thatevery electronics enthusiast or professional may need foreveryday 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 miscellaneousapplications, 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 connectorpinout (i.e., connection data) on the entire Internet. Even ifthere are more massive sites, Nick’s list is pretty impressive tosay the least. A true galaxy of extremely common but also odd-ball connectors, cable links and adaptors may be found here.• GuidesThis department contains a number of manuals covering sev-eral aspects of home-brew electronics such as DIY circuitboard etching, a course in soldering, SI and derived units,tables, passive component colour codes and a piece on elec-trical safety.• NewsA section covering the latest in electronics, but heavily com-puter-inclined. This page is frequently updated.• LinksThis section presents a list of other websites with useful infor-mation. The list is divided in computer/electronics links andlinks 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 areafter information on a certain subject.

As an aside, Nick is an active athlete and he is even amember of the Italian sprinters’ team. Thic subject, too, is cov-ered in some depth on his website.

Nick’s hardware area is a valuable asset for everyoneactively involved in electronics, both professionally and/or as

Electronics enthusiasts spend alot 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 circuitboard etching. Well, Nick’s web-

site has it all nicely bundled. Practical and useful!

Nick’s hardware areaInfoDesk on electronics

a hobbyist. This address certainly deserves a prominent placein your Favourites folder!

(005013-1)

Text (Dutch original): H. Baggen

electronics on lineelectronics on-line

Page 33: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

Elektor Electronics 2/2000

routines that will be called many timesbefore their function is complete. Inorder to do that, you will need to keeptrack of where you are in your subrou-tine so that you know where to startup again when you return. One verygood way to do this is called the FiniteState Machine or FSM for short. Becausethere are only a few different actionsyou want your subroutine to execute,and it does actually complete its job atsome point, it is a finite list. There areseveral forms of FSMs, this type ofFSM is a hybrid we will use specificallyfor robotic programming. This behav-iour FSM is a type of a state machinethat returns no outputs, it merelychanges state based on input and thecurrent state. Each activity that theFSM engages in, is a state, unique inoperation and distinct from all otherstates by its definition.

If this is difficult to understand, letsuse a sort of real world application toexplain FSMs, the soda machine. Inorder to keep our soda machine sim-

ple, we will create a pretty stupidmachine with these abilities: takes only quarters needs two quarters to get a soda will not give you your money back does not give change, nor return

money that isn’t a quarter has Coke, Barq’s Root Beer and Fanta

Orange soda has an infinite amount of soda and

never runs out

As you can see, we have eliminated allof the exceptions or error conditions thata normal soda machine could see inorder to simplify this explanation — it’sartificial for a reason; we’re not design-ing soda machines. However, do payattention to exceptions and error condi-tions when you are designing yourown FSMs! Figure 21 shows a graphicalrendering of our soda machine FSM.The underlined numbers in each of thecircles are the state number for thatstate. A line with an arrow denotes atransition from one state to another (the

36

Part 6: introducing the FSM concept

MICROPROCESSORS

BASIC Stamp programming course (6)

By Dennis Clark

The Parallax Boe-Bot, or Board of Edu-cation Robot is a simple robot madefrom a Parallax Board of Education(BoE) mounted on an aluminiumframe to which two Futaba hobby ser-vos are mounted. These servos havebeen modified to provide continuousmotion and have several speeds atwhich they will turn.

The BoE has a small prototypingarea on which several experiments canbe done. In order to realize the fasci-nating potential the BoE-Bot has todemonstrate robotic behaviours, youwill need to know how to program it!In this and the following instalments Iwill explain how tomake the robot moverandomly, or pur-posely, how to seek outor avoid bright lightand how to avoidobjects. I will also explain how to pro-gram your BoE-Bot in such a mannerthat all of these functions seem to beoperating at the same time.

Further, I will show you can getbehaviours from your robot that youdidn’t even program in to it!

L I N E A R E X E C U T I O N V S .C O N C U R R E N T E X E C U -T I O N A N D T H E F I N I T ES T A T E M A C H I N EIn a program, each statement is exe-cuted in sequential order, the nextstatement cannot start until the last oneis done. When there is only one threadof logic running, this means that theprogram proceeds in a linear fashion,from start to finish. Concurrent execu-tion is when there is more than onethread of logic running at whatappears to be the same time. ”How doI do that?”, you may ask. In the Paral-lax Basic Stamp II processor you can dothis by using independent sections ofcode, called modules or in our case, sub-

0 1

2

3

4

Get twoquarters

quarters = 2

select = none

select = Fanta

select = Barq's

990050 - 6 - 11

select = Coke

quarters < 2

Get selection

Deliver Fanta

Deliver Barq's

Deliver Coke

45

Figure 21. Finite StateMachine design for asoda machine.

Page 34: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

arrow points the direction). If a transi-tion line is labelled, that label is theresult of the transition function anddefines the condition required for thatchange of state. An unlabelled line is atransition that will always occur as soonas the function of that state is com-pleted. The lines that loop back upon astate show iteration, or that the FSMremains in this state doing somethinguntil a terminal condition is reached, atwhich time a defined transition that islabelled will occur. Here we see that oursoda machine FSM will remain in state0 until two quarters have been given, atwhich point our FSM will transition tostate 1. Here we will wait, looking atbuttons until a selection is made. Whena selection is made, our FSM will thentransition to state 2, 3 or 4 dependingon the selection made. From these ter-minal states, our FSM will immediatelytransition back to state 0 after complet-ing. This is the general process of defi-nition and representation for the FSMsthat we will be using to define our BoE-Bot behaviours.

Remembering where you are inyour subroutine is called saving stateand is essential if you are to pick upwhere you left off when last this sub-routine ran. Each state in our behav-iour FSM will be executed when itssubroutine is called and will exit thesubroutine when that state is com-pleted. Subsequent calls of that sub-routine will execute the next correctstate that is defined. Why is this useful?Let’s look at two code snippets in List-ing 9 that show why this can makeyour whole program run faster. Both ofthese pieces of code operate the hobbyservos that make your BoE robotmove, don’t worry about understand-ing them exactly, what this code doeswill be fully explained in due course.The one thing you must know is that ahobby servo requires that a pulse of1 ms (millisecond) to 2 ms must be sentto each servo every 20 to 30 ms or theservo will not perform correctly. If yousend it too often (say every 7 ms) theservo will jitter, if you send it too rarely(say every 50 ms) then the servo willstop. These pulses need to be repeatedcontinuously, and regularly in order to

operate correctly, a single pulse is notvery useful to a servo.

The code on the left looks very sim-ple and fast, but looks can be deceiv-ing. The pulsout instructions are usedto output a pulse of the needed widthto turn the servos. Remember, thispulse needs to be repeated every 20 to30 milliseconds (ms) in order for theservo to respond properly. Also, itneeds to have several repetitions of thispulse for the motor to turn and keeprunning. The pause instruction willcause the Stamp II to pause for 20 ms,each of the pulses sent will be 2microseconds * 750, or 1.5 ms. So, eachpass through this for/next loop will take3 ms + 20 ms = 23 ms at least, 10 timesthrough the loop will take 230 ms!That is almost 1/4 of a second whennothing else can be done!

Now let’s look at the code on theright that implements a two-state FSMto move the servos. You can see thatour subroutine on the right does one oftwo operations at any given time. Thefirst operation is to output the pulses tothe servos and set the aDur variable.The second operation is to simplydecrement the aDur variable. In eithercase, after the operation has beenaccomplished we exit the subroutine.Each of these operations will bedefined as a state for the act behaviour.

We will get into more details onhow to describe and design statemachines for our robotic behavioursusing examples and programs that youwill write for your BoE-Bot in laterinstalments.

Returning to our code samples, let’sfigure the time spent in the subroutineon the left now. Since the Stamp II exe-cutes about 4000 lines of code a secondthis means that each instruction willtake about 250 µs to execute. The pul-sout instructions will obviously take1.5 ms each to execute because that isthe length of the pulse that is beingsent. In state 1 it will take 3 ms for thepulsout instructions + 750 µs for theother three instructions, which equals3.75 ms. In state two our second sub-routine will take about 750 µs ofprocessor time each time it is executed.

Instead of the 230 ms of processor

time taken by the left subroutine, wenow will take 5*750 µs + 3.75 ms =7.5 ms of processor time total (we aretaking 5 turns through it after the initialpulse outputs remember?) to accom-plish the same purpose. If we onlycount a single 23 ms loop for each passthrough the first subroutine, we willhave saved 15.5 ms of processor time,which, at 4000 instructions per secondamounts to 62 instructions that can beexecuted elsewhere and give us theexact same activity on our servomotors. If we take into account the full230 ms time for the left loop we saveover 226 ms which is a whopping 904instructions!

But why is this important? A robotdoes not just wander aimless aroundin its environment, it usually has sometask to accomplish. Whether it issearching for a fire to put out, trash topick up or for another robot to attack,it is doing something else more impor-tant than just running its motors.When we use the motor driver routineon the left above, the robot is doingabsolutely nothing but concentratingon running the motors for 230 ms.During this time it cannot look at a sen-sor, pick up trash or put out a fire. If itruns into something, it will just keeprunning into it until it is finished withthat loop and can then do somethingelse. Each of the other behaviours thatwe implement in our robot will besome activity that the robot will needto perform in a timely manner. It doesus no good to detect an object to avoidafter we have already run into it! Let’sassume that our robot is running thefollowing behaviours, listed in lowestpriority to highest priority, to achievesome objective:

Go North until home is found(chooses a direction to travel)

Avoid hitting anything by using IRproximity detection (if something isa danger, choose another direction)

If I hit something, back up andturn left (chooses yet another direc-tion to go)

Stop and beep when I am home(choose no direction at all, just stop)

Select the highest priority direction

37Elektor Electronics 2/2000

Linear based servo controller subroutine

act:for I = 1 to 10

pulsout LEFT,750Pulsout RIGHT,750pause 20

nextreturn

FSM based servo controller subroutine

act: if aDur > 0 then aDec

aDur = 5pulsout LEFT,750pulsout RIGHT,750goto aDone

aDec: aDur = aDur - 1

aDone:return

Listing 9. Linear vs FSM programming

Page 35: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

to go and call act to implement it

Many of these behaviours will tell themotors to perform some action; back-ing up, turning left, whatever. Each ofthese behaviours will need to refer tosensors in order to perform theiractions. Each of these behaviours(using the system I am suggesting) willbe Finite State Machines implementedin subroutines that will be called fromwithin some main code loop (you willsee some of these behaviours definedlater on). In the motor driver routineact shown as the right side code snip-pet there is a variable aDur defined.When the act FSM is first called aDur isset to 5. This means that the pulsoutinstructions will be executed once, thenthe next 5 times the act subroutine iscalled it will do nothing but decrementaDur and exit. This means that it willspend as little time in the subroutine aspossible. Why is this useful? It is usefulbecause act only needs to send thosepulsout actions once every 20 to 30 ms.Our robot can be looking at sensorsand selecting the next motor actionwhile it is waiting to send that nextseries of pulses out. In this way, we usethe time it takes to read sensors andmake decisions in those other four sub-routines as the delay we must takebetween pulses we send to the servo

motors instead of wasting that timewith a pause instruction! In effect, thismakes it look like everything is hap-pening at the same time instead of onething after the other. If we were to usea linear programming model instead ofFinite State Machines to implement allof our behaviours and actions then wewould not be able to look at the com-pass or check for an obstructing objectuntil all 230 ms in the code snippet onthe left had completed. In that time ourrobot might miss seeing the chair infront of it and collide with it before itgets a chance to change direction.There is nothing special about thenumber 5 chosen for aDur either, I usedthat number as a suggested startingpoint. In reality this number is chosenby trial-and-error to achieve thesmoothest timing. I started with thisnumber in my own robot and as Iadded behaviours I reduced it. Forexample, with four behaviours active Ihave my act routine set aDur to only 2.

When we implement all of ourbehaviours as FSMs this has the effectof interleaving the code that needs tobe executed in each subroutine so thatno one behaviour needs to wait untilthe prior behaviour completes in orderto do at least some of the work thatneeds to be done in its own routine.This improves our robot’s response

time to its environment. In the case ofthe act subroutine above, this results ina smoother motor response andquicker reaction to obstacles and objec-tives.

Before using the Finite StateMachine method of behaviour imple-mentation I would notice that myrobot would appear to hesitate longerand longer as I added more and morecomplex behaviours. This FSM methodwill all but eliminate this hesitation. Itis more complex to design and codethan linear programming, but theresults, I feel, merit the complexity. Tryprogramming your robots both linearlyand using FSMs, I think you will agreethat using Finite State Machinesimproves your robot’s abilities andallows us to get as much out of ourStamp II as we can! Eventually a set ofbehaviours may become so complexthat even using FSMs will not preventsome hesitation, but we can do muchmore using FSMs as our programmingmodel rather than linear programmingbefore that happens.

(990050-6)

Next month we will continue with a methodcalled Subsumptive Programming which willhelp us develop a step-by-step plan to implementrobotic behaviour.

38 Elektor Electronics 2/2000

Page 36: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

Elektor Electronics 2/2000

tion of the original IC.However, anyone who has tried to

use a BASIC-52 interpreter in EPROMin an 80535 or 80537 system has experi-enced a bitter disappointment. The ini-tialisation routine for the serial interfaceuses properties of the 8052 that havenot been passed on to the 80535 inexactly the same form. The culprit isTimer 2, which is not compatible withthe 8052.

The new processors can however beused if the reset routine is modified.The 8052-BASIC interpreter has provi-sions for a custom reset routine and foradding new user-developed instruc-tions. We could thus write modifica-tions that work with the new micro-controllers. In particular, the modifiedinterpreter supports the Elektor 80537Single Board Computer as well as thenew 537 ‘Lite’ computer.

The most commonlyused dialect of

BASIC for microcon-trollers, Intel’s

8052AH-BASIC, can-not be used as is

with the new 8051derivatives. This arti-cle presents a modi-

fied version of theinterpreter that also

supports the80535/537 microcon-

trollers. These havebeen used in recent

Elektor projects,such as the 80C537Single-Board Com-

puter and the 537‘Lite’ computer.

40

Design by B. Kainka

a high-level language for the80535/537

The Intel BASIC-52 interpreter wasoriginally provided in the form of amask-programmed microcontrollerwith the type designation 8052AH-BASIC. The interpreter automaticallyrecognises the amount of availableRAM and the baud rate of the con-nected terminal when the system startsup. There are also Autostart functionsthat allow a program to be run auto-matically on start-up. It is even possi-ble to program an EPROM in the sys-tem, as long as you use the originalIntel IC.

The 8052AH-BASIC IC is no longerproduced. However, the program hasbeen released for public use, so it cannow be used legally in an EPROM. Ifyou combine this with an 80C32 micro-processor, you have a low-powerBASIC system. The only thing that youlose is the EPROM programming func-

MICROPROCESSORS

BASIC-537

Page 37: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

The modified interpreter, which we callBASIC-537, has the following features:

9600 baud data transfer rate with a 12 MHz clock

32kB RAM6 new instructionsdirect A/D converter pollingLCD support (address FFCOh)Autostart function

The BASIC-537 interpreter occupiesthe EPROM memory region from0000h to 403Fh, and also requires 32 kBof RAM starting at address 0000h. Afew jumper settings must be changedon the 80537 boards, as shown inTable 1, to ensure that the addressregions are properly configured.

In principle, any available terminalemulator program running at 9600baud can be used with the BASIC-537interpreter. After the system isswitched on, the interpreter announcesitself with the following start-up mes-sage:

MCS-51(tm) BASIC V1.1 / ES537READY>

You can now enter lines of BASIC codein the usual manner. Each character issent back to the terminal via the serialinterface. Each time a Return characteris received, the interpreter converts thecomplete line into its internal tokenformat and stores the tokens in theRAM. The program can be started bytyping RUN, and it can be interruptedat any time by pressing Ctrl-C. TypingLIST sends the complete program list-ing to the terminal, and typing NEWclears the memory.

Instead of a simple terminal emula-tor, you can also use the Windows pro-gram BASIC.EXE, which is found onthe same diskette as the interpreter.

This is a combined terminal emulationand editor program that is speciallydesigned for the BASIC-535 interpreter.The diskette also holds an instructionsummary file (BASIC52.HLP), an ini-tialisation file (SBASIC.INI), the binaryfile of the EPROM contents(BASIC537.BIN) and sample programswith the extension BAS.

T H E P R O G R A M E D I T O RWhen BASIC.EXE is first started, it isset up to use COM2. A different portcan be selected via the Options/RS232menu. The selection is saved in the fileSBASIC.INI when you quit the pro-gram.

When the microcontroller board isswitched on, the BASIC-537 interpretersends its start-up message. You canthen enter the first program and run it.The sample program Test1.bas outputsdata to port P1 and uses the originalBASIC-52 instruction PORT1:

10REM Port outputs 20FOR N=0 TO 25530PORT1=N40FOR I=1 TO 200 : NEXT I50NEXT N60GOTO 20RUN

BASIC.EXE has two text windows. Atext editor with many editing functionsruns in the upper window. The lowerwindow displays all the charactersreceived from the microcontroller.Every time that <Return> is pressedin the editor, the complete line is sentto the microcontroller.

The echoed characters appear in theterminal window. You can edit eachline as much as you wish before it istransferred. This also applies to linesthat appear earlier on in the text andthat you want to modify after the fact.In the terminal window, you can seewhether each line has been accepted orhas caused an error message to bereturned. Alternatively, you can acti-vate the terminal window and use itfor entering text, which will be trans-ferred a character at a time.

The program’s special functions canbe called up using the Program menu.These are the RUN, LIST, BREAK,CONTINUE and NEW instructions forthe interpreter in the microcontroller,and CLS, which clears the terminalwindow. You can use LIST to fetch afinished program and display it in theeditor window, and then to save it todisk.

Naturally, instructions such as NEW,LIST, RUN and so on can be entereddirectly from the keyboard, the same asprogram lines. For testing, directqueries such as PRINT PORT1 can beused. A special feature of the overallsystem is that code lines of a program

that is already in the microcontrollerare not overwritten by new linesunless the new lines have the same linenumbers. This means that you canstock a collection of subroutines thatcan be downloaded as needed. Inorder to start from scratch, enter NEWbefore downloading a program.

You can load a program via theFile/Open menu. First you should useProgram/Break to stop any program thatis already running, and then use Pro-gram/New to delete it. The text of theprogram will appear in a new editorwindow, and in the terminal windowas well if the interpreter was ready.Several editor windows may be opensimultaneously, which allows programsections to be copied back and forth.

I N S T R U C T I O N S U M M A R YThe most important instructions andfunctions of BASIC-537 are listed inTable 2. Numerous special functionshave been adapted to the environmentof the microcontroller. Some of theoriginal BASIC-52 instructions cannotbe used with the extended version andare not shown. Four new instructionshave been specially added for the80537.

The measurement range of thetwelve possible analogue inputs is 0 to+5 V, but this can be modified withinwide limits using the instructionDAPR, which writes a parameter byteto the processor register with the samename. A one-byte control parametercan be specified for each measurement.Its two 4-bit nibbles set the upper andlower limits of the range. Bits 0–3 setthe lower limit in units of (5 V/16), andbits 4–7 set the upper limit in the sameway. These two reference voltagesmust have a minimum separation of1.25 V. For example, a parameter valueof 84h sets the measurement range to1.25–2.5 V. The value 00h is an excep-tion; it sets the range to 0–5 V.

The instructions SFR and WrSFRallow all of the special hardware func-tions of the 80C537 to be used. Theyprovide access to both serial ports, thetimer, all supplementary ports and soon. Providing free access to all special-function registers presents a specialchallenge to an interpreter, since all8051 derivative ICs allow only directaddressing (via an instruction such asmov 90h, A). The SFR address thuscannot be passed via another register.A compiler has no problem with this,since it hard codes the address, but aninterpreter must be able to pass theaddress. This difficulty is probably thereason why the original BASIC-52interpreter allowed free access to theinternal RAM, the external RAM andeven the program region, but not tothe special function registers. Since a32-kB EPROM has enough room forthe necessary extensions, an indirect

41Elektor Electronics 2/2000

80C537 Single Board Computer IC2 holds the BASIC-537

EPROM IC4 holds a 32-kB RAM IC5 and IC5 remain unused all 6 jumpers of J1A are con-

nected to J1C (stand-alonemode)

537-Light computer J7:1—2 (12 MHz) J1A– J1C: 1—2 (stand-alone

operation) switch S1: RUN

Table 1. 80537 com-puter board settings

Page 38: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

approach can be used. There are twosmall subroutines for reading and writ-ing every address in the range from128 to 255. When the interpreterencounters an SFR or WrSFR instruc-tion, it calculates a jump address thatleads to the proper subroutine. Theextended interpreter is thus preparedfor microcontrollers that haven’t evenbeen invented yet.

The text file Sample Programs, whichis also located on the diskette, containsprograms that illustrate the use of thespecific instructions of the interpreter.

L C D C O N T R O LBASIC-52 allows serial interface out-puts to be redirected to a different out-put routine. This capability is used inthe BASIC-537 interpreter to drive aliquid-crystal display. The display islargely addressed using normalinstructions. Only the instruction forinitialising the LCD (LCDINIT) and theinstruction for setting the characterlocation (CURSOR) have been added.

The new 537 ‘Lite’ computer (Janu-ary 2000) has an interface for an LCDmodule. This is located in the addressspace starting with address FFCOh.The display is initialised using the newinstruction LCDINIT. After this, thereare several ways to output characters

42 Elektor Electronics 2/2000

InstructionsRUN Ctrl-C CONT LIST NEW

Operators+ - / * = > >= < <= <> .AND. .OR. .XOR. ABS() NOT() INT() SGN()SQR() RND LOG() EXP() SIN() COS() TAN() ATN()

StatementsCALL DATA READ RESTORE DIM DO-WHILE DO-UNTIL END FOR-TO-STEP NEXT GOSUB ON-GOTO ON-GOSUB IF-THEN-ELSE INPUT LETONERR PRINT REM STOP

Extended BASIC-537 StatementsONEX1 subroutine call following Interrupt 1ONTIME timer interrupt callRETI end of an interrupt subroutinePH0., PH1. output a hexadecimal number with/without leading zerosPUSH, POP move data to/from the argument stackSTRING reserve memory for a text stringIDLE wait for interrupt

Special function operators and system variablesCBY() DBY() XBY() GET IE IP PCON T2CON TCON TIME TIMER0 TIMER2PI XTAL MTOP LEN FREE

80C537 I/O handling AD (channel) [read-only] C = AD (0) analogue input (0 – 5V) at the

AD0 inputC = AD (11) analogue input (0 – 5V) at the

AD11 inputDAPR [write-only] DAPR = 128 switch the measurement

range to 2.5 V SFR [read-only] print SFR (90H) reading special function reg-

istersWrSFR [write-only] WrSFR 90H,255 writing special function regis-

tersTable 2. Summary ofBASIC-537 instructions

Page 39: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

to the display. The desired characterposition can be specified using theCURSOR instruction. The PRINT@instruction writes directly to the dis-play. A sample program is available onthe diskette or from the Elektor web-site.

A program can send its outputs tothe terminal emulator using PRINT, orto the LCD using PRINT@, as desired.All output data can be formatted withthe USING instruction. However, theline feed function has no effect on theLCD. This means that the CURSORinstruction should be used as much aspossible to specify the desired locationof the output data. Various types ofLCDs can be used, with one, two orfour lines. The sample programLCD.BAS shows the character positioncorresponding to the start of each line.

Another option is use the instruc-tion UO 1 to redirect the entire out-put to the LCD. The instructionUO 0 switches the output back tothe terminal

A U T O S T A R TThe original BASIC-52 tests the entireRAM after start-up, clears it and thenstarts any program that it recognises inthe external EPROM. Both of the Elek-tor 80C537 computers have battery-backed RAM, so that the program thatwas last run before the computer wasswitched off remains present in theRAM. The BASIC initialisation routinehas therefore been modified to auto-matically start a program that isalready in the RAM.

All that you have to do is to load aprogram into the computer’s memory.After this you can disconnect the serialcable to the PC and let the computerwork on its own. Each time the com-puter is started up, the program is runanew, at least as long as the lithiumbattery provides enough power tomaintain the contents of the RAM. If atany time you don’t want the system toautomatically run a program when itstarts up, all you have to do is to sendit a NEW instruction.

W E H A V E N ’ TF O R G O T T E N T H E8 0 5 3 5 !Now we come to the widely used80535 systems, such as the Elektor80535 Single Board Computer. Thenew interpreter can also be used withthis system, if you first carry out a fewmodifications.

The system must run at 12 MHz, inorder to yield a data transfer rate of9600 baud. Everything else works aswell, as long as you take the availableprocessor hardware into account. TheA/D converter has only eight channels,but is otherwise compatible. Naturally,the 80535 has fewer timers, ports and

so on than the 80537.Intel’s BASIC-52 interpreter expects

to find data RAM starting at address0000h. The new initialisation routinedoes not change this. However, the80535 Single Board Computer dividesits 32 kB of RAM between the addressranges 4000h–7FFFh andC000h–FFFFh. Special logic allows theRAM in these regions to be used tostore program code as well as data.

The necessary changes are quitesimple. Remove IC2 (a quad NAND IC,type 74HC00) from its socket andreplace it with three small wire bridges,as follows:

pin 3 to pin 4 (OE direct to RD)pin 11 to pin 12 (CE direct to A14)pin 7 to pin 8 (CS direct to

ground)

In this configuration there is 16 kB ofRAM available to the system, startingat address 0000h. The normal BASIC-537 interpreter can work with this. Ofcourse, you must tell the interpreterthat only 16 kB of RAM is available, byentering:

MTOP = 16383

This line should also be placed at thebeginning of every program, since theinterpreter initialises itself to 32 kB ofRAM after a restart. Since all variablesare stored just below the upper RAMboundary, the interpreter will functioncorrectly only if it has accurate infor-mation about the amount of availableRAM.

If you would rather be able to use thefull 32 kB of RAM, you must make twofurther modifications, as follows:

Bend pin 1 of the RAM IC (A14) so thatit does not stick into the socket, andthen connect it directly to addressline A14 (for example, at pin 12 of thesocket for IC2).

Bend pin 20 of the RAM IC (CE) so thatit also does not stick into the socket,and then connect it directly toaddress line A15, which is on pin 1 ofthe same socket.

Now the system will see the full 32 kBof RAM in one continuous block, start-ing at address 0000h. With this modifi-cation, it is not necessary to specify theamount of available memory withMTOP.

The 80535 Single Board Computerdoes not have battery-backed RAM.However, it is possible to use a ‘zero-power’ RAM, which has a built-inbackup battery. If such a RAM is used,this computer behaves the same wayas the new 80537 computer. With azero-power RAM you can have a pro-gram start automatically. Even withoutthis luxury, though, the Autostart func-

tion of the extended BASIC interpretermakes its presence known. This can beseen if a reset is executed while poweris still applied. In this case the programthat is already present starts immedi-ately after the reset. This is a quite use-ful feature during program develop-ment. Instead of entering Break andthen Run, you can simply press theReset button.

An additional difference can be seenin the fact that it is possible to use a liq-uid crystal display. The ’535 computerdoes not have any decoding logic forthe LCD, so you will have to eitherbuild some extra circuitry or else con-nect the LCD to a port and use the 4-bit mode. The display can be driven bya somewhat complicated BASIC rou-tine.

All of the supplementary ports ofthe 80535 can be addressed not onlyvia their SFR addresses but alsodirectly. The instructions P3, P4 and P5can be used for output only. An outputvalue can be directly assigned to a port(e.g. P4 = 255). Reading input datafrom the ports with the InP3, InP4,InP5 and InP6 instructions is unfortu-nately not as convenient, since thismust be done via the result stack. Portstates that have been read can befetched and put into a variable usingthe POP instruction:

InP4 : POP A : PRINT A

The direct port instructions also workwith the 80C537, but only up to portP6. BASIC-52 allows only a limitednumber of new keywords. It is thusnot possible to give every new functionits own name. This means that wehave to continue programming thespecial hardware of the microcontrollervia register addresses. With read oper-ations in particular, the use of registeraddresses (e.g. Print SFR(0E8h)) is oftenmore elegant than the use of directport instructions.

It is relatively easy to write somereset routines and supplementaryinstructions yourself, since the BASIC-52 interpreter already has suitableinterfaces. You can find more detailedinformation in the relevant literature.

(000018-1)

You can find additional information andsample programs for 80535 and 80537microcontrollers, and a DOS terminalemulator for BASIC-52, at the author’shomepage on the Internet:http://home.t-online.de/home/B.Kainka

Project SoftwareDiskette, order code 996029-1.(terminal emulator, help file and sample

programs)

EPROM, order code 996532-1.(BASIC-537 interpreter)

43Elektor Electronics 2/2000

Page 40: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

Elektor Electronics 2/2000

Be that as it may, the most obviousway of increasing power output is toraise the supply voltage of 12 V to ahigher level by means of a converter.Such a converter, however, is notexactly cheap and is, moreover, a noto-rious source of noise and interference.In view of the extensive electronic cir-cuits in modern motor vehicles, this lat-ter point is not to be underestimated.

Fortunately for the loudness-hun-gry, there is an alternative to a con-verter. Some years ago, Philips intro-duced a special integrated outputamplifier chip, the TDA1560Q, that isable to provide 30 watts into 8 Ω froma 12 V power supply (without the useof a converter). This output power is

44

Design by T. Giesberts

50+ watts from a 12 V battery

The integrated output amplifierdescribed in this article consistsof little more than one integratedcircuit. It is intended especially foruse in motor vehicles and other battery-operated applications. Although it appears

simple and hardly worth looking at, the amplifiercan produce an appreciable audio power output.

power output, their design is far fromsimple.

A simple calculation shows that aconventional amplifier operating from12 V (or maximum 14.4 V when thebattery is fully charged) cannot pro-vide a power output of much morethan 6 W. Use of a bridge arrangementmay push this up to some 20 watts, butthat is just about the maximum possi-ble.

Nowadays, many motorists, andmore particularly the younger ones,want considerably more power than6–20 watts. Loudness is their god, butthey unfortunately forget that this is anunforgiving god, leading them to earlydeafness.

Amplifiers come in all sorts. Most ofthe amplifier designs published in thismagazine are intended for domestic orstudio use. As such, they are usuallypowered by a 60–150 V supply, whichmay, moreover, be further divided intotwo balanced voltages. This makesthese amplifiers unsuitable for use inmotor vehicles.

Amplifiers that can operate from a12 V supply are quite different units,designed as they are for low-voltagesupplies. If, moreover, they arerequired to provide a substantial

AUDIO & HI-FI

designed for in-car use

one-IC audio power amplifier

Page 41: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

obtained by operating the amplifier inClass H (see box elsewhere in this arti-cle).

An amplifier based on the Philipsdevice was described in the February1995 issue of this magazine.

Philips designers have furtherimproved a number of properties ofthe IC, among which the power out-put. According to the Philips datasheet, the improved device, theTDA1562Q, can deliver 70 watts into4 ohms, but that is at the cost of the dis-tortion, which at 10 per cent is rathertoo high, even for in a car.

The prototype of the designdescribed in this article provides54 watts into 4 ohms at 1 per cent dis-tortion. Since the number of requisiteexternal components is smaller than inthe case of the earlier device, theprinted-circuit board is even morecompact than that for the February1995 amplifier.

T H E T D A 1 5 6 2 T QThe internal circuitry of the new deviceis very similar to that of its predecessor.Since, however, not everybody can beassumed to be au fait with the February1995 article, the circuitry is describedanew.

The block schematic of the device isshown in Figure 1. Particular attentionis drawn to the boxes marked ‘lift sup-ply’, which are necessary in a Class Hsystem (see box).

The IC evaluates the input signaland estimates the consequent drive ofthe output transistors. When thesetransistors tend to go into saturation,the supply voltage is raised briefly byswitching the capacitors connected topins 3 and 5, and 13 and 15, in serieswith the supply voltage.

Apart from the input amplifier and

Class H output amplifier, the devicecontains several protection circuits.One of these protects the IC against anexcessive output current and againstshort-circuits.

The temperature protection circuitworks in two steps. When the firstthreshold temperature is exceeded, thedevice switches from Class H to Class Boperation. There is then no question ofincreased supply voltage. When thesecond threshold temperature is

exceeded, the drive to the output tran-sistors is reduced.

There is also a protection circuitagainst overvoltage and one againsttoo low load impedances. When theload impedance drops below a prede-termined critical level, operation isswitched from Class H to Class B. Aload impedance smaller than 0.5 Ω isseen as a short-circuit, which causesthe device to be switched off alto-gether.

45Elektor Electronics 2/2000

1

Figure 1.Block diagram of the innards of the TDA1562Q. Anumber of protection networks make the amplifier virtu-ally foolproof.

Brief technical dataPropertiesHigh power output through Class-H operationLow power dissipation during reproduction of music signalsProof against short-circuitsProtection against excessive temperaturesStandby switchNo power-on or power-off clicksVisible error indication

Measurement results (at Ub=14.4 V)Supply voltage 8–18 VSensitivity 760 mV r.m.s.Input impedance 70 kΩPower output 54 W r.m.s. into 4 Ω (f=1 kHz; THD+N=1%)Harmonic distortion (THD+N) at 1 W into 4 Ω: 0.046% (1 kHz)

0.29% (20 kHz)at 35 W into 4 Ω: 0.12% (1 kHz)

0.7% (20 kHz)Signal-to-noise ratio (with 1 W into 4 Ω) 88 dBAPower bandwidth 7.5 Hz – 185 kHz (at 25 W into 4 Ω)Quiescent current about 135 mA (‘on’)

Page 42: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

C I R C U I TD E S C R I P T I O NThe circuit diagram inFigure 2 emphasizes how few externalcomponents are needed to construct acomplete output amplifier (in fact,fewer than half the number in the Feb-ruary 1995 amplifier). For instance, thenew device does not need compensa-tion networks to enhance the stability.Also, because of the absence of switch-on phenomena, there is no need for aswitch-on delay network.

There is, of course, still a need forsupply line decoupling capacitors.

Capacitors C5 andC6 are required forClass -H operat ion,about which more inthe box.

The value of inputcapacitors C1 and C2 isrelatively low, thanks to

the high input impedance of the IC.Switched RC network R4-C4 at the

‘mode select’ input (pin 4) serves toswitch the IC to ‘mute’ or ‘standby’.When the supply voltage is switchedon, the IC is first switched automati-cally to the ‘mute’ mode and to ‘on’only after a short delay. The time con-stant R4-C4 is a few tenths of a secondand this delay between the two statesis sufficient to obviate disturbing (andannoying) switch-on phenomena.

Switch S1 enablesthe amplifier to beswitched to ‘standby’when the use of theamplifier is not needed

for a period of time. When that timehas elapsed, the amplifier is quicklyreverted to normal operation. The cur-rent drain in the standby mode is vir-tually negligible at only 200 µA.

Resistor R3 prevents a short-circuitcurrent ensuing when S1 is beingclosed at the instant C4 is being dis-charged.

E R R O R I N D I C A T I O NThe diagnostic output (pin 8) of theTDA1562Q is one of the few facets ofthe device that is completely new. Asshown in the diagram, it can now beused to drive an visible error indicator,D1, directly. During normal operationthe diode should be out. Its lightingmay be caused by one of four possiblecauses.1. The amplifier is being overdriven.

The internal circuit responsible forthe indication is the ‘Dynamic Dis-tortion Detector’ (see Figure 1). Inpractice, this will be the case whenthe distortion rises above 1.6 percent at 1 kHz. The diode is, there-fore, a kind of clipping indicator.

2. There is a short-circuit between theoutputs or between one of the out-puts and the supply line. In the firstcase, the outputs are disabled,whereupon the protection networkascertains at short intervals of timewhether the short-circuit has beenremoved. The DIAG output is thendisabled for 30 µs at 20 ms intervals.In the case of a short-circuitbetween one of the outputs to thesupply line, the DIAG outputremains active.

3. The internal sensor measures a tem-perature of 145 °C, whereupon the

46 Elektor Electronics 2/2000

TDA1562

PG

ND

2

PG

ND

1

MODE

IC1

SG

NDVREF

OUT+

OUT–

STA

TDIAG

+IN

–IN

C2+C2–

C1+C1–

VP

1

VP

2

1217

16

11

1315

14

1053

4

8 9

6

1

2

7

C54700µ

25V

C6

4700µ25V

C1

470n

C2

470n

C7

100n

C3

10µ63V

C8

4700µ25VC4

10µ63V

R1

1M

R4

10

0k

R2

4k

7

D1

S1

standby

LS+

LS–

000004 - 11

12V

R3

1k

2

Figure 2. The circuit ofthe amplifier is con-spicuous by its sim-plicity. Diode D1 is anerror indicator.

000004-1(C) ELEKTOR

C1

C2

C3

C4

C5

C6

C7

C8

D1

H1

H2H3

H4

IC1

R1

R2

R3

R4

LS+

LS

-

0+

S1

Tstandby

00

00

04

-1 000004-1(C) ELEKTOR

3

Figure 3. The compactprinted-circuit boardfor the amplifier isavailable through theReaders’ services(towards the end ofthis issue).

COMPONENTS LIST

Resistors:R1 = 1MΩR2 = 4kΩ7R3 = 1kΩR4 = 100kΩ

Capacitors:C1,C2 = 470nFC3,C4 = 10µF 63V radialC5,C6,C8 = 4700µF 25V radial

(18mm max. dia., raster 7.5 mm)C7 = 100nF, raster 5 mm

Semiconductors:D1 = high-efficiency-LEDIC1 = TDA1562Q (Philips)

Miscellaneous:S1 = single-pole on/off switchFour spade connectors, PCB mountHeatsink for IC1 (Rth<2.5 K/W)PCB, order code 000004-1 (see

Readers Services pages)

Page 43: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

relevant protection circuit isenabled.

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

A C O M P A C T B O A R DThe amplifier is best built on the single-sided printed-circuit board shown inFigure 3 (available through our Read-ers’ services – see towards end of thisissue). As mentioned earlier, the boardis small for an output amplifier. In fact,most of its surface is taken up by thefour car-type (spade) connectors viawhich 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,the electrolytic capacitors are mountedfirst, the fitting of the IC becomespretty difficult. It is, therefore, advis-able to start with fitting the IC onto theheat sink (using plenty of heat con-ducting paste).

Also, ensure that after the board hasbeen placed in a suitable enclosure, itssolder (track) side remains readilyaccessible. After the board and heatsink have been secured in the case, sol-der the pins of the IC to the board.

Figure 4 shows a photograph of thecompleted prototype as built up in ourdesign lab.

Make sure that when the board isfitted in the case, the loudspeaker ter-minals are not (and cannot be) short-circuited to earth. Although the IC isprotected against much abuse and mis-use, it is always better not to temptprovidence.

In most cases, two amplifier mod-ules will be fitted in one enclosure: onefor the left-hand channel and the otherfor the right-hand channel.

Constructors who find 2×54 wattsinsufficient may consider driving thefront and rear speakers in the vehicleby separate amplifiers. This would takethe total number of modules requiredto eight, and these deliver some400 watts of audio power into the vehi-cle. A case of minding the windows!

[000004-1]

Text (Dutch original): S. van Rooij

47Elektor Electronics 2/2000

4Figure 4.There cannotbe many 50 W outputamplifiers that are thissmall.

Class-H operationA Class H amplifier is somewhat akin to a Class G amplifier, which is a power ampli-fier in which two Class B amplifiers with different supply voltages are combined. Small-amplitude signals are boosted by the one with the lower supply voltage, resulting inmuch higher average efficiency for speech and music. When signals exceed the low-voltage supply amplitude, the amplifier that operates from the higher supply voltage takesover, while the first one is switched off.

In a Class H amplifier the supply voltage is varied by an efficient Class S amplifieror the arrangement in the present design so that it remains just above the minimumvalue required to prevent saturation. This configuration also achieves a much higheraverage efficiency for speech and music signals. (A Class S amplifier is a pulse-width-modulated audio amplifier in which the active elements are switched by a control fre-quency several times higher than the signal frequency being amplified. This type ofamplifier has an efficiency of some 90 per cent).

In the present amplifier, Class H operation is achieved by the use of two switchedcapacitors, C1 and C2. These are charged to the battery voltage and switched intoseries with the 12 V supply line during brief drive peaks.

In the diagram, transistors T1–T4 are part of the ‘normal’ amplifier, while T5–T8 andC1 and C2 are added for Class H operation. At small-signal amplitudes, T7 and T8are on and C1 and C2 are charged to the battery voltage via diodes D1 and D2. Whenthe signal amplitude tends to drive T1 or T3 into saturation, the internal sensor(lift/recharge control) detects this and causes T7 and T8 to be cut off and T5 and T6to 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 byT7 and T8, whereupon their charge is topped up.

C1 C2

R1

D2D1

T1

T2

T6

T8

T5

T7 T3

T4

LIFT/RECHARGECONTROL

LIFT/RECHARGECONTROL

E1

950024 - 12

V3

V1 V2

V4

Page 44: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

Elektor Electronics 2/2000

In short, even though using desol-dering braid may appear to be themost primitive of the three options, ourexperience in the Elektor lab is that ityields the best results.

B R A I D E D W I R EDesoldering braid or ‘Wick’ is actually abraided wire ribbon consisting of thincopper wires together with impreg-nated solder flux. The spaces betweenthe wires soak up the solder, so that itis removed from the place where it is

no longer desired. Desoldering braidcan be obtained in small rolls a fewmetres long (see Figure 1).

Using desoldering braid is very easy.Before you start, remember that solderflows best when it is good and hot. Youshould thus not use too small a solder-ing iron. If you have a temperature-controlled soldering iron, set it to atleast 350 degrees. Now all you have todo is to make sure that the desolderingbraid is hotter than the joint that is tobe desoldered, since the solder will

We can assume that themajority of our readers have

sufficiently mastered thenoble art of soldering. How-ever, the art of unsoldering

already soldered compo-nents, or desoldering, is

something else. Even ratherexperienced solder artists

often prove to be extremelyclumsy in this area. They goabout it the wrong way, and

lacking both patience andthe right touch, they tend to

mess around until theyhave ruined not only thecomponent but also the

printed circuit board.

48

By K. Walraven

a craft in its own right

1

P U M P I N G O R S U C K I N G ?The only good way to desolder is topatiently remove all of the solder fromthe points where the component isattached to the circuit board. This canbe done using a special ‘solder-sucker’soldering iron, a vacuum pump or des-oldering braid.

Of these various options, the vac-uum pump and the special solderingiron may seem to be the most conve-nient at first glance, but in practice thisis not so. The nozzles of these tools areeasily clogged, and the sucking actionis not always perfect. If you use a sep-arate pump, you have to heat the sol-der joint quite strongly, which is initself risky. Even then you have toquickly switch between the solderingiron and the pump, since otherwise thesolder will cool down and becomehard again.

GENERAL INTEREST

desoldering

Page 45: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

flow to the hottest point.Proceed as follows: First place a clean piece of desolder-

ing braid on the solder joint that youwant to remove, and then place thetip of the soldering iron on top of thebraid.

Now press quite firmly with the sol-dering iron, to make good thermalcontact (see Figure 2). The solder willbe drawn into the braid.

As soon as the braid is saturated, itwill not absorb any more solder. Youcan easily see how saturated it isfrom its colour. It is initially copper-coloured, but becomes increasinglysilver-coloured as it absorbs moreand more solder (see Figure 3).

In order to fully clean the solder froma joint, you sometimes have to work intwo steps. In the first step you removemost of the solder. After this, you canslowly draw the braid along under thesoldering iron, while holding the sol-dering iron stationary (this takes a bitof practice). Following this, you canremove the last remains of the solderwith a fresh, unused piece of desolder-ing braid.

F L U XOnce you have gained some experi-ence in working with desolderingbraid, you will quickly realize that thistechnique works well only if sufficientflux is present. If there is not enoughflux, even liquid solder simply forms aball and will not soak into the braid.

Sometimes certain parts of the braiddo not have enough flux. This can becaused, for example, by repeated flex-ing of the braid at a particular location.

This fault can be remedied byputting additional flux on the solderjoint that is to be removed. You canbuy flux paste in tubes for this pur-pose. You can also use violinist’s rosin,which is available in small tins, toimpregnate the braid. Since rosin ishard, getting it into the braid is a bittricky. Set your soldering iron to a lowtemperature (100 to 150 degrees); ifyou do not have a regulated iron, youwill just have to be quick. Lay a smallpiece of braid on the surface of therosin and warm the braid from the topwith the soldering iron (see Figure 4).The rosin will melt and soak into thebraid. Hold the iron stationary and pullthe braid through underneath it.

You can also make your own desol-dering braid in this manner. You canuse any piece of stranded wire (from abit of mains cable, for example) — justremove the insulation and impregnateit with flux. This is handy to know ifyou run out of desoldering braid, orsimply find it too expensive.

(000006-1)

49Elektor Electronics 2/2000

2

3

4

Page 46: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

Elektor Electronics 2/2000

EPROM contains the monitor pro-gram, while the RAM chip acts as acombined program and data storagedevice. In this mode, jumper J7 has tobe set to the 12 MHz crystal position. Ifnot, the communications data speed isnot properly set up. However, once theprogram has been downloaded, J7may be changed at any time, if only toensure that the program runs about33% faster after a reset. Do remember,however, that the higher clock speedalso results in time-dependent routinesbeing executed faster.

The EPROM-resident monitor pro-gram allows simple direct entry ofassembler commands as well as com-fortable debugging at assembly-codelevel. You may enter help to call up anoverview of all available functions.

In Run mode the previously down-loaded user application program may

be executed straightaway by means of a

reset, after which the program runs inthe RAM area. The RAM componentthen acts as an EPROM program stor-age device, obviating the need to pro-gram your own EPROM to be able toemploy the system in stand-alonemode running the final version of theprogram. The RAM component acts asa shared program and data memory.An essential component in this mode isthe backup battery, because, as you willno doubt be aware, a RAM chip is a‘volatile’ device which means that itloses its contents when the supply volt-age disappears.

When the Monitor EPROM is used(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,if the program is to run in Stand Aloneor Run mode, this serial interface ini-tialisation is sadly missing. Unfortu-nately, you have to provide and embedthe necessary routine for SS0 yourselfto make sure the communication withthe PC operates as it should.

P R O G R A M M I N GBefore you can start programmingaway, you have to know some elemen-tary facts about the memory configura-tion of the 537 Lite board. After all, pro-grams and user data are both stored inRAM component IC7. This sharedmemory space extends from 0000Hthrough 7FFFH, so its size is 32 kBytes.In the programming environment(8051 Compiler or Interpreter) youhave to indicate exactly which rangesare reserved for the program andwhich ones for the data. If you fail todo this, memory contention may occurand program(s) and data may actuallydestroy each other!

Having built the board and successfully run thefirst communication tests, you are ready to startprogramming the 537 core system. In doing so,some rather special points should be observed

which are discussed in this article. What’smore, we show you how the board may beused in practice by adding extensions and

components.

50

Design by Prof. B. vom Berg and P. Groppe

part 2: programming and practical use

M O D E S O F T H E5 3 7 ‘ L I T E ’ C O M P U T E RThe fact that it can be used in three dif-ferent modes adds considerably to thepower and versatility of the the 537Lite board. The modes are StandAlone, Program Download and Run.Table 1 shows how to set jumpers andswitches to select between thesemodes.

Stand Alone mode is typically used forthe final application of the board,when a program has been fully testedand is known to work error-free in thetarget system. After a reset, the userprogram is immediately executed fromEPROM.

In Program Download mode, a termi-nal program is used to download theprogram (developed on a host PC) tothe 537 Lite board. The program thenhas to be started fromthe host PC. The

Mode Jumper Switch EPROM RAMJ1A,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

Table 1. Jumper- andswitch settings of thethree modes

MICROPROCESSORS

537 ‘Lite’ computer (2)

Page 47: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

You should also be aware that theEPROM-resident Monitor program,whose functions include control overthe program download operation, alsorequires a small scratch area in RAM.Obviously, this area may not be over-written by the program code or userdata! The monitor scratch area isdefined as 7F00H through 7FFFH inRAM.

All this has the following implica-tions if you want to start writing pro-grams:

51Elektor Electronics 2/2000

7FFF End of RAM range (fixed): 32 kByteSize: 256 bytes

7F00 Fixed start address of memory range for Monitor program

7EFF End of data memory range (fixed)Size: 7.75 kBytes

6000 Start of data memory range (variable)

5FFF End of program code rangeSize 24.0 kBytes

0000 Start of program code memory range (variable)

(************************************************************************)(*** p2: Capture analogue values with the 537 Lite Board ***)(*** =================================================== ***)(*** 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 *)beginadu:=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.

Figure 1.P2.PASlisting.

Table 2. RAM memory map

Page 48: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

The total RAM rangeavailable for programand data extends from 0000Hthrough 7EFFH, so its size is32,512 bytes.

The program memory range alwaysstarts at address 0000H, and is imme-diately followed by the data memoryrange.

The data memory range may notreach into the monitor memoryrange. The memory division is illus-trated in Table 2.

At this point, an example may help toshow what considerations play a rolein practical programming.

Let’s assume that a program with a sizeof about 20 kBytes and requiring about5 kBytes of data memory is not quitefinished and therefore requires someadditional memory locations. The com-piler/interpreter should be ‘informed’that the program code range starts at0000H, and the data range, at 6000H.Consequently the program space has asize of 24,576 bytes (24 kBytes), whilethe data memory measures 7,936 bytes(7.75 kBytes).

When the program is developedfurther, you should take care that theprogram code does not cross the5FFFH border, and the data, the 7EFFHborder. If that happens, the two mem-ory blocks will corrupt one another.

Programming the 537 Lite boardtakes four steps:

The user program is written in a pop-ular and widely used programminglanguage like Assembler51, C51,

BASIC52, PL/M51 orPascal51. BASIC52 and

Pascal51 in particular allow very fastand powerful results to be obtained.Whatever programming language isused, the final product of your pro-gramming efforts, a block of objectcode, should be either an Intel-Hexfile, a file with the extension .hex oran ASCII file containing BASICtokens.

The object code file is downloaded tothe 537 board via one of the availableRS232 interfaces on the PC.

Test the program in combinationwith the target system hardware.

Once all errors have been sorted outand the program works as it should,there are two possibilities to accom-modate the final version of the soft-ware in the system.– The first option is to program anEPROM and install it instead of theMonitor EPROM. The system thenruns in Stand Alone mode(mode 1), so that 32 kBytes ofdata/program memory is available.

– The second option is to switch S1to RUN (mode 3) after the programdownload operation, promptingthe program to execute from RAM.When a backup battery is used, theRAM contents is not lost when thebattery voltage is switched off. ALithium battery should haveenough energy for several years ofproblem-free use.

The advantage of the second optionis that you do not have to burn an

EPROM. Consequently there’s noneed to have an EPROM programmerand/or UV eraser available.

P R A C T I C A LA P P L I C A T I O N SOf course, the 537 core should not lieidle among half a dozen or so othermicrocontroller boards in one of yourdrawers. We strongly suggest you actu-ally use the board by giving it a practi-cal application. A good example is thatof a CAN bus system host as describedin last month’s issue of this magazine.Other experimental circuits and appli-cations include peripheral devices withserial control (3-channel D-A converter,temperature sensor, LED display, etc.),keypad/keyboard interfaces, voice pro-duction, digital and analogue I/Ocards, IrDA, radio and fibre-optic com-munication systems. Many such pro-jects may be found in existing litera-ture, or will be published shortly.

Even if space is at a premium in thismagazine, an example should beincluded that illustrates the use of the537 Lite computer in combination withthe DOS version of Pascal51. This inte-grated programming environment alsoruns in a Windows 95/98 DOS box.

Having launched the editornilied.exe you first have to set up thedesired memory model. This is done inthe menu Options|NiliPascal Parame-ters (Figure 1). The minimum settingsare the definitions of data and programmemory start addresses, the microcon-troller clock frequency and the baudrate of the communication between thePC and the 537 Lite board. Your per-sonal preferences and settings aresaved and the menu is closed.

At this point you may enter a pro-gram or load an available piece of code,for example, one of the examplesfound on the project diskette, 976008-1. The example program p2.pas cap-tures input voltages on the first threeinputs AN0, AN1 and AN2 of the 537’son-chip A-D converter. The samplingrate is one per second. You may applydifferent voltages in the range 0-5 V topins 3, 4, 5 and 15 of connector K3 andcheck the associated conversion resultson the display.

The program p2.pas should be com-piled without errors after pressingShift-F9. Next, you quit the programeditor by typing Alt-x which takes youback to the DOS level. The next step isto download the object code to the 537Lite board and run it! Figure 2 showswhat you should see on your display.

(990054-2)

Design editing: K. WalravenText editing

(German original): R. Gerstendorf

52 Elektor Electronics 2/2000

Program p2: Capture analogue values using 537 Lite Board=====================================================

now capturing measurement values .....

Input AN0: 118 = 2.3046875e0 V

Input AN1: 122 = 2.3828125e0 VInput AN2: 118 = 2.3046875e0 V

Input AN0: 66 = 1.2890625e0 VInput AN1: 56 = 1.0937500e0 VInput AN2: 29 = 5.6640625e-1 V

Input AN0: 75 = 1.4648437e0 VInput AN1: 91 = 1.7773437e0 VInput AN2: 109 = 2.1289062e0 V

Input AN0: 107 = 2.0898437e0 VInput AN1: 112 = 2.1875000e0 VInput AN2: 111 = 2.1679687e0 V

Figure 2. Measure-ment results producedby P2.PAS on the PCdisplay.

Page 49: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

DATASHEET 2/2000

HT12D

Integrated circuitsSpecial Function

HT12A

Integrated circuitsSpecial Function

DATASHEET 2/2000

53E

lektor Electronics

2/2000

HT12A212 Series of Encoders

ManufacturerHoltek Semiconductor Inc.,

No.3 Creation Rd. II, Science-based Industrial Park,Hsinchu, Taiwan, R.O.C. Fax: 886-3-563-1189.Internet: http://www.holtek.com.tw

Features (HT12A only) Operating voltage 2.4V- 5V Low power and high noise immunity CMOS tech-

nology Low standby current: 0.1µA (typ.) at VDD =5V 38kHz carrier for infrared transmission medium Minimum transmission: one word Built-in oscillator needs only 5% resistor Data code has positive polarity Minimal external components 18-pin DIP or 20-pin SOP package available

Application exampleIR Remote Control for Sony MZ-R30 MiniDisc Walk-man, Elektor Electronics February 2000.

General DescriptionThe 212 encoders type HT12A and HT12E are CMOSLSIs for remote control system applications. They arecapable of encoding information which consists of Naddress bits and 12–N data bits. Each address/data

HT12D212 Series of Decoders

ManufacturerHoltek Semiconductor Inc.,

No.3 Creation Rd. II, Science-based Industrial Park,Hsinchu, Taiwan, R.O.C. Fax: 886-3-563-1189. Internet: http://www.holtek.com.tw

Features (HT12D only) Operating voltage: 2.4V-12V Low power and high noise immunity CMOS tech-

nology Low standby current Capable of decoding 12 bits of information Pair with Holtek’s 212 series of encoders Binary address setting Received codes are checked 3 times Address/Data number combination 8 address bits and 4 data bits

Built-in oscillator needs only 5% resistor Valid transmission indicator Easy interface with an RF or an infrared transmis-

sion medium Minimal external components

Application exampleIR Remote Control for Sony MZ-R30 MiniDisc Walk-man, Elektor Electronics February 2000.

Pin Descriptions (HT12A only)

Pin Name I/O Internal Connection Description

A0 – A7 I CMOS IN, pull-highInput pins for A0-A7 setting. These pins can be externally set to VSSor left open

D8 – D11 I CMOS IN, pull-highInput pins for data D8-D11 setting and transmission enable, activelow. These pins can be externally set to VSS or left open

DOUT O CMOS OUT Encoder data serial transmission output

L/MB I CMOS IN pull-highLatch/Momentary transmission format selection pin. Latch: floating or VDD. Momentary: VSS

OSC1 I OSCILATOR 1 Oscillator input pin

OSC2 O OSCILLATOR 1 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)

VDD I — Positive power supply

Pin Descriptions

Pin Name I/O Internal Connection Description

A0 – A11 I NMOS TRANSMISION GATEInput pins for A0-A11 setting. They can be externally set to VDDor VSS

D8 – D11 O CMOS OUT Output data pins

DIN I CMOS IN Serial data input pin

VT O CMOS OUT Valid transmission, active high

OSC1 I OSCILLATOR Oscillator input pin

OSC2 O OSCILLATOR Oscillator output pin

VSS I — Negative power supply (GND)

VDD I — Positive power supply

Pin AssignmentPin Assignment

Page 50: as offered by the Nintendo 64, combined with the pro-...2 - 2/2000 Elektor Electronics EXTRA —————————————— PC TOPICS Awkward keyboard commands and uncomfortable

HT12D

Integrated circuitsSpecial Function

HT12A

Integrated circuitsSpecial Function

DATASHEET 2/2000DATASHEET 2/2000

54E

lekt

or E

lect

roni

cs2/

2000

input can be set to one of the two logic states. Theprogrammed addresses/data are transmitted togetherwith the header bits via an RF or an infrared trans-mission medium upon receipt of a trigger signal. Thecapability to select a DATA trigger on the HT12A fur-ther enhances the application flexibility of the 212

series of encoders. The HT12A provides a 38kHzcarrier for infrared systems.

Functional descriptionOperationThe HT12A encoder begins a 4-word transmissioncycle upon receipt of a transmission enable (D8-D11,active low). This cycle will repeat itself as long as thetransmission enable (D8-D11) is held low. Once thetransmission enable returns high the encoder output

completes its final cycle and then stops as shown inthe transmission timing diagram.

Information wordIf L/MB=1 the device is in the latch mode (for usewith the latch type of data decoders). When thetransmission enable is removed during a transmis-sion, the DOUT pin outputs a complete word andthen stops. On the other hand, if L/MB=0 the deviceis in the momentary mode (for use with the momen-tary type of data decoders). When the transmissionenable is removed during a transmission, the DOUToutputs a complete word and then adds 7 words allwith the ‘1’ data code.

General DescriptionThe HT12D decoder is a CMOS LSIs for remote con-trol system applications. It is paired with Holtek’s212 series of encoders. For proper operation, a pairof encoder/decoder with the same number ofaddresses and data format should be chosen. Thedecoders receive serial addresses and data from aprogrammed 212 series of encoders that are trans-mitted by a carrier using an RF or an IR transmis-sion medium. They compare the serial input datathree times continuously with their local addresses.If no error or unmatched codes are found, the inputdata codes are decoded and then transferred to theoutput pins. The VT pin also goes high to indicate avalid transmission.The HT12D decoder is capable of decoding informa-tion consisting of N bits of address and 12–N bits ofdata. The HT12D is arranged to provide 8 addressbits and 4 data bits.

Functional descriptionOperationThe HT12D decoder receives data that are transmittedby an encoder and interpret the first N bits of codeperiod as addresses and the last 12–N bits as data,where N is the address code number. A signal on theDIN pin activates the oscillator which in turn decodesthe incoming address and data. The decoders will thencheck the received address three times continuously. Ifthe received address codes all match the contents ofthe decoder’s local address, the 12–N bits of data aredecoded to activate the output pins and the VT pin isset high to indicate a valid transmission. This will lastunless the address code is incorrect or no signal isreceived. The output of the VT pin is high only whenthe transmission is valid. Otherwise it is always low.

Output typeThe HT12D provides 4 latch type data pins whosedata remain unchanged until new data are received.

HT12A Block Diagram HT12D Block Diagram

Transmission timing for HT12A (L/MB = VSS) Decoder timing for HT12D