You are on page 1of 53

TEST&MEASUREMENT

Climate Logger
Recording temperature and humidity
Design by T. Poms http://chripo.icb.at/Rooney

This electronic alternative to mechanical temperature and humidity


recorders is a very compact standalone unit which draws very little
current. The Dallas DS1616 device used comes already equipped with a
temperature sensor, and besides a humidity sensor we can add a range
of other sensing devices. The collected data can be transferred to a PC
or notebook over an RS-232 port for analysis by user-friendly Windows
software. The system can also be connected to a microcontroller board.

12 Elektor Electronics 1/2004


TEST&MEASUREMENT
The climate logger operates com-
pletely autonomously while it is car- SCLK
rying out a ‘mission’ (measurement RST
I/O SERIAL
sequence), and can run on battery
COMSEL INTERFACE MEMORY
power for a long period in this mode. Tx FUNCTION
The device can, for example, be left CONTROL
Rx
in the refrigerator or in the wine cup-
board to continuously record the
temperature and humidity. The Win- X1
OSCILLATOR INTERNAL RTC
RTC AND CONTROL
dows-based software running on a AND AND CONTROL
REGISTERS
DIVIDER REGISTERS
PC is used not only after a mission to X2
download and analyse the stored USER NVRAM

data, but also before a mission to OPTIONAL


ST SERIAL NUMBER
configure the data logger. With the INSPEC
CONTROL
aid of the software, both the sample OUTSPEC LOGIC
ALARM TIME STAMP
AND DURATION
rate and the selection of which chan- INT LOGGING MEMORY
nels are to be recorded can be con-
HISTOGRAM ME MORY
figured.
The version of the climate logger
DATALOG MEMORY
described here connects to the PC
over a serial interface. The planned AIN 3 TO 1 A/D TEMPERATURE
MUX CONVERTER SENSOR
USB version previewed last month is 030076 - 13
still in development.

Figure 1. Internal circuit of the DS1616.


DS1616
‘Intelligent’ temperature sensors pro-
duced by Dallas frequently appear in needed for certain commands such CRC (cyclic redundancy check) allows errors
circuits in Elektor Electronics. There as Clear Memory to be carried out. in transmission to be detected, so that the
is a wide range of ICs offering a The DS1616’s built-in temperature command can be repeated if necessary.
wide range of peripherals, so that sensor determines the operating The RAM is non-volatile (NV), which
the ideal device can easily be found temperature range of the climate log- means that the memory contents are pre-
to match the requirements of any ger at –40 °C to +80 °C. The compo- served even when power is lost. This RAM is
particular application. A built-in nents used for the remainder of the used to store important parameters when the
memory comes in very handy for circuit, including the humidity sens- master software is exited: these values can
building a temperature logger. The ing circuitry, must also be specified then be reloaded by the software when it is
DS1616 device used here is a partic- for at least this temperature range, restarted at a later date. The following para-
ularly well-equipped member of this or the overall specifications of the cli- meters are stored by the current version of
series of temperature sensors. mate logger will be degraded (Fig- the software:
The internal block diagram of the ure 2).
DS1616 is shown in Figure 1.
Besides the temperature sensor and Status
the memory the most interesting fea- Memory Map Check
Push
LED
red
LED
green
Button
ture is certainly the analogue-to-dig- The DS1616 offers 2048 bytes of
ital converter, which has a resolution memory divided into pages of 32
of 8 bits. The converter is equipped bytes each (Figure 3). The RTC and
with a 3-to-1 input multiplexer. It is Control Registers and the User NV DS1616
& Humidity
possible to use the converter to RAM areas can be written to. The Sensor
On Chip
accurately measure three external use of the RTC and control registers Temperature Sensor
voltages in the range 0 V to 2 V, and in our climate logger application will
to store them along with the internal be discussed further in the ‘Soft-
temperature signal. ware’ section below. All the other
The DS1616 also offers a real-time locations can only be read. Each read RS232 µP Interface
clock driven from a built-in oscillator command contains the start address
(which requires a 32.768 kHz watch from which reading is to begin, and
crystal). The clock is also used to data are then transmitted until the
drive a simple serial RS-232 interface end of the page is reached. This
to allow alarm times, sampling clock means that each read command will PC
rates, timestamps and time delays to cause a maximum of 32 bytes, plus a
030076 - 12
be retrieved from the device’s mem- 2-byte CRC generated in hardware
ory. It is also required for scanning by the DS1616, to be sent to the mas-
the measurement channels and is ter device (a PC in this case). The Figure 2. Block diagram of the Climate Logger.

1/2004 Elektor Electronics 13


TEST&MEASUREMENT
– The measurement channels selected for the DS1616 MEMORY MAP
most recently initiated sequence of mea-   
  
surements
– Sample rate         
– Performance-related parameters 
    

The detailed circuit diagram for the climate ! #
 $$ %&    ' !(
logger is shown in Figure 4. The serial inter-  "
face of the DS1616 requires a 5 V supply, but  ) * $+, !((
 
only, of course, when there is actually any   + + *+-   .$  " ' /
communication occurring. This supply is  "
generated using a 78L05 voltage regulator  ) #
 $$ %&    ' !
which takes its input voltage from the PC’s "
) +-$  + ! 0 
01 %23 ! ' !"
COM port. )"
The two LEDs provide an indication of the )) . 3   .  + ! 0 
01 %23 !) ' "
status of the DS1616. The pushbutton con- )
/ #
 $$ %&   " ' "
nected across JP1 must be pressed for at 
least 0.5 s to request status information.  .  + 1 ! -  ) ' /
Before a sequence of measurements (or ‘mis- "
sion’) has been initiated, the red LED (OUT- ) #
 $$ %&   / 4
  33
SPEC, D2) and the green LED (INSPEC, D3)
will flash together four times. If a mission has (  ) ,1
(( 5 ) ,1
been initiated, but the first measurement has
yet to be taken, the LEDs will flash four times
alternately, starting with the red LED. A Figure 3. DS1616 memory map.
sequence of measurements can be initiated
either from the PC, or, in standalone opera-
tion, by pressing the pushbutton. See also the combination formed by R1, R2 and duces a fixed reference from the
software description below and the guide to C1 sets the period at about 1 s. varying battery voltage, used to sup-
operation at the end of this article. IC1.A triggers the second half of the ply the whole humidity measure-
The software allows threshold values to be timer, which operates as a mono- ment circuit as far as IC3. This
defined. If a measured analogue value (an stable multivibrator, creating the ensures a good power supply rejec-
external voltage or a reading from the tem- pulse-width modulated waveform. tion ratio (PSRR) figure.
perature sensor) is above (or below) the At its output we have a lowpass fil-
threshold value, a bit is set in the Status 1 ter which finally turns the PWM sig-
register. When this happens, the red LED (D2) nal into an analogue DC voltage pro- A Compact Data Logger
flashes four times. If the user-defined thresh- portional to the atmospheric humid- The climate logger is constructed on
olds are not crossed, the green LED (D3) will ity. Depending on the characteristics a single-sided printed circuit board
flash four times. of the sensor, this voltage varies from (Figure 5). There are no wire links,
An interface is also provided to allow the approximately 990 mV to 1190 mV. and construction should not present
data logger to be used in conjunction with a The signal must now be processed any difficulties. The ICs should be fit-
microcontroller board instead of with a PC. In so that it lies in the range 0 V to 2 V, ted in sockets. Terminals are pro-
contrast to the asynchronous communication so that good accuracy can be vided for all the external connec-
used with the PC, here we use synchronous obtained using the analogue inputs tions, including for the 9-way sub-D
communication with the signals SCLK, IO of the DS1616. According to its socket for the RS-232 interface, and
and RST. To switch the device from asynchro- datasheet, the sensor capacitance for the two batteries BT1 and BT2.
nous mode to synchronous mode, pin 6 only varies between 161 pF and BT1, which powers the humidity
(COMSEL) should be tied to VCC (+5 V). 200 pF, and the electrolytic capaci- measurement circuit, has to supply a
tors used have a wide tolerance: this considerably greater current than
means that the circuit will require ‘backup battery’ BT2, which only
Humidity Sensor calibration. supplies the DS1616 when it is in
The HS1101 capacitive humidity sensor mea- This facility is provided using autonomous mode. This means that
sures relative atmospheric humidity. The instrumentation amplifier IC3, which BT1 should be made up from AA or
capacitance of the sensor, which changes in amplifies the generated voltage by a C cells in series, whereas BT2 can
proportion to humidity, is first converted into factor of 10. Very high resistances just be a coin cell (see also the text
a pulse-width modulated signal. A fair are used here in order to keep cur- box). BT2 also determines how long
amount of electronics is required to turn this rent consumption low. The output as the climate logger can retain its
signal into a voltage suitable for the AIN2 signal is also passed through a high- stored data and settings, while, BT1
input of the DS1616. value resistor before being taken to only determines for how long humid-
One half of a TS556 dual timer is con- the analogue input of the DS1616. ity measurements can be taken.
nected as a free-running multivibrator, gen- The voltage VCCHUM is gener- The enclosure must not only
erating a regular squarewave signal. The RC- ated using an LM385-2.5. This pro- house the printed circuit board, but

14 Elektor Electronics 1/2004


TEST&MEASUREMENT
also the batteries and their holders, impedance multimeter. The offset trimmed. When 2.00 V is measured at the out-
the pushbutton, and the RS-232 voltage (the voltage between the put of the operational amplifier, calibration
socket. The humidity sensor should input of preset P1 and ground) has been successfully completed.
be soldered as close as possible to should have the same value. The
K1. It is not recommended to mount voltage at the output of IC3 should
the sensor on the side of the enclo- be between 2 mV and 7 mV. The Software
sure, since this will involve a voltage cannot be set to exactly zero, The software runs under Windows 2000 and
greater cable length. The enclosure since we cannot do anything about Windows XP; versions for Windows 95 or 98
should not be airtight so that the offset voltage of the operational are not currently available but may be devel-
atmospheric humidity is present at amplifier. Now connect the second oped later (watch the author’s website). The
the humidity sensor. capacitor to K1 and once more mea- main window allows control over the main
sure the voltage at the output of the settings and shows real-time measurement
lowpass filter. The value should be results (Figure 6). The measurement chan-
Calibration about 200 mV higher than the previ- nels (temperature, ADC1, humidity/ADC2
Two reference capacitors (or combi- ous reading with the smaller capaci- and ADC3) can be individually enabled and
nations of capacitors) of 161 pF and tor. Since we have a voltage varia- disabled. When the DS1616 is not ‘on a mis-
200 pF are required for alignment. tion of about 200 mV over the humid- sion’, the temperature and humidity values
The values should be checked ity range, and a voltage range of 0 V are measured once per second (assuming the
directly by measurement. First con- to 2 V is required, the amplifier cir- corresponding measurement channels are
nect the 161 pF capacitor to K1, and cuit is configured for a non-inverting enabled) and the results displayed. This fea-
measure the voltage at the output of gain of 10. Preset P2 at the non- ture is implemented using a timer whose
the lowpass filter using a high- inverting input allows the gain to be default period is one second. However, this

+U HUM +U HUM

R4
220Ω
R2 R5
14
68k
100k

C10 C8
R10
IC1 R11
150k

7 100n 10M 100n


10
C4 1
13 R R9
DIS 2 7
12 1M 5 R12
100n 4 THR 6
IC1.B R7 R8 P2 IC3 1M D1
K1 1 R 9 3 BT1
DIS OUT 10k 470k
R6 R1 556 4
2M +3V
10M

10k

IC1.A 5
P1 MCP6041
8
OUT TR 250k
CNTR
HS1101 2
THR 11
6
TR R3 R13
CNTR C9 C5
47k

10M

3 IC1 = TS556
10µ 100n
C3 C2 C1 16V
+5V
LM385-2.5
* * *
IC2
+5V
* see text C11
R14
D5 78L05 +5V
10k

100n
1N4148
R16 R17
24 K5 K4 C7 C6
1k

1k

1 19 330n 22µ
VBAT RST
R21 R19 R20 20 16V
2 IC4 I/O
1k

1k
100k

X1 21 T2
X1 SCLK R15

DS1616 10k SUB D9


22 1
3 TX
D2 D3 X2 23 BC547 K6 6
RX
BT2 6 2
COMSEL K2 K3
7 11 T1 7
+3V INSPEC INT R18
8 14 3
OUTSPEC AIN1 10k
15 8
AIN2
10 16 BC547 D4 4
ST AIN3
A 9
JP1
X1 = 32.768kHz 5
17 4 12 18
1N4148
030076 - 11

Figure 4. Circuit diagram of the Climate Logger.

1/2004 Elektor Electronics 15


TEST&MEASUREMENT
T2

C7
1-670030 030076-1
ROTKELE )C( R15 (C) ELEKTOR
R17 T1
IC2

R3 C6

Y
H2

H3
R4 K6
R10 P1 K4 D4
R9 K2 R18
R11
K3 D5
R12 C5 C11 K5 R16
D3 R14
IC3
R20
IC4 R19
Bt1- C8
+

D2 R21
X1

P2

Bt2
JP1
R5
R8
C4
- +
R7 R6
R13 C10 030076-1

IC1
K1
H1

C9
H4

R1
D1

R2
C1C2C3

Figure 5. Layout and component mounting plan for the single-sided printed circuit board.

timer requires CPU power to operate, which COMPONENTS LIST T1,T2 = BC547
can have an impact on performance in older IC1 = TS556
computers. For this reason the timer period Resistors: IC2 = 78L05
can be set as desired under Settings/Perfor- R1,R7,R14,R15,R18 = 10kΩ IC3 = MCP6041-I/P (Microchip)
mance. The new value is stored in RAM so R2,R21 = 100kΩ (Farnell # 396-8790)
that the timer period does not need to be R3 = 47kΩ IC4 = DS1616
entered every time the software is started up. R4 = 220Ω
R5 = 68kΩ Miscellaneous:
When the DS1616 begins a mission, only
R6,R11,R13 = 10MΩ JP1 = pushbutton, 1 make contact
the active channels are sampled and
R8 = 470kΩ K1 = 3-way pinheader
recorded. The data logging memory of the Humidity sensor type HS1101
R9,R12 = 1MΩ
DS1616 has a capacity of 2048 bytes. The (www.humirel.com), available from
R10 = 150 kΩ
more channels are enabled, the shorter the Unitronic (www.unitronic.de)
R16,R17,R19,R20 = 1kΩ
maximum recording time available. If just one P1 = 250kΩ preset (vertical K2-K6 = 4-way pinheader
channel is enabled, up to 2048 values can be mounting) BT1 = 3V Lithium cell
recorded; with two channels enabled the P2 = 2MΩ preset (vertical mounting) X1 = 32.768 kHz quartz crystal
maximum is 1024. If four channels are BT2 = 2 UM-5 (AM-5) or AA
enabled, then the maximum is 512. Capacitors: batteries (depending on available
The main window displays only the two C1,C2,C3 = see text enclosure)
most important values: humidity (ADC2) and C4,C5,C8,C10,C11 = 100nF 9-way sub-D socket (female), angled
temperature. The remaining values can be C6 = 22µF 16V radial pins, chassis mount
shown by selecting ADC Channels/Show C7 = 330nF ABS enclosure with battery
Channels. C9 = 10µF 16V radial compartment (OKW size # 3 for AA
cells, e.g. RS Components # 583-
Semiconductors: 218)
Sample Rate
D1 = LM385-2.5 PCB, order code 030076-1 (see
‘Sample rate’ specifies the time interval in min-
D2= LED, red, 3mm, low-current Readers Service page)
utes between measurements. The registers of D3 = LED green, 3mm, low-current Disk, Windows software, order code
the DS1616 are eight bits wide, and so the D4,D5 = 1N4148 030076-11 or Free Download
maximum value that can be set is 255 minutes.
For the RTC to work correctly, and so that a
series of measurements can be initiated, the
sample rate must be set to a value greater than surements. The enabled channels Serial Number
or equal to one. When the battery is changed and the sample rate should already Each DS1616 is factory-programmed
the sample rate is reset to zero; if the RTC is set have been set: incorrect settings with a unique serial number. When
but the sample rate not set to a value of at least will case a pop-up to appear. Real- a save command is issued, this num-
one, the RTC will not operate properly. time values of temperature and ber is stored along with the mea-
humidity will no longer be updated sured data, so that the particular
Start Mission once per second, but rather at the module that produced the data can
This button initiates a sequence of mea- preset sample rate. be identified.

16 Elektor Electronics 1/2004


TEST&MEASUREMENT
the window or by pressing the Update but-
ton.
Auto Scaling gives an overview of the
series of temperature readings. The graph
limits are no longer set at –40 °C and +80 °C,
but are set to the lowest and highest tem-
perature values stored in the data memory.
The Save command stores the measured val-
ues on the local hard disk, with a user-
selected path.
The Humidity, ADC1 and ADC3 plots are
identical in terms of function and appearance.
In future versions of the software the two
spare channels will also be used.

Other Windows
The ADC Channels window can be called up
under ADC Channels/Show ADC Channels in
the main menu. It provides up-to-date read-
ings from the analogue channels. Disabled
inputs are displayed in grey, as shown on the
right in Figure 8. Threshold values can also
be set for the analogue inputs: these operate
Temperature Thresholds Temperature in the same way as the temperature thresh-
These threshold values set the tem- and Other Graphs olds.
perature limits above or below The Alarm Settings window (Figure 9)
which the alarm flag in the Status 1 This window provides information includes the various settings relating to the
register will be set, which in turn about the measured temperature val- RTC (real-time clock).
pulls the interrupt output INT low. ues (Figure 7). Sample 1 corre- The RTC can be set to the PC’s system
This latter signal is available on K2 sponds to the time given under Mis- time using Set. The remaining settings can be
and K3 and can be used, for exam- sion started @. This allows the date used, for example, to implement a time
ple, to trigger an acoustic warning and time of each stored sample to be switch function. An interrupt on INT is gen-
signal. The ‘Clear’ button must be determined. In order not to waste erated when the RTC value agrees with the
pressed to reset the alarm flag. CPU time needlessly, an automatic preset alarm time. RTC and alarm settings
update feature is not provided. The can only be changed while the DS1616 is not
graph can be updated by re-opening busy taking a sequence of readings.
Under Settings/Performance is a facility for
setting to any desired value the timer period
which governs the regular reading of data
Calculating the battery life from all the sensors and analogue inputs. The
greater this value, the greater the interval
The type CR1620 backup battery (3 V, 60 mAh) supplies only the DS1616 and its
between samples, and the correspondingly
internal temperature sensor. The humidity measurement circuit consumes rather
smaller the amount of CPU time consumed by
more current and so is supplied from two AA cells to give a reasonable battery
the software. An optimum value for the timer
life. The life of the coin cell depends on the selected sample rate; in order to cal-
period can be found using the System Moni-
culate the battery life, its capacity must simply be divided by the average current
tor (a Win XP utility) to accurately measure
consumption of the circuit (Iavg).For example, with a sample period of 60 s we
the CPU load and performance. PCs and lap-
have:
tops that have plenty of memory and proces-
sor power should have no problem with a
Battery life=battery capacity / I avg
timer interval of one second. The functions of
the System Monitor are described in more
where the average current is given by
detail in the help.
I a v g = [ t t c ⋅ i t c + ( T – t t c ) ⋅i O S C ] ] / T
Operation
where tTC is the duration of one measurement (150 ms), iTC is the current
The climate logger is connected to a free ser-
drawn while carrying out a temperature measurement (0.5 mA), iOSC is the qui-
ial port on the PC or notebook using an ordi-
escent current consumption (450 nA), and T is the sample period (60 s).
nary serial cable (straight-through, not a null-
modem cable). The first time the logger soft-
The calculated battery life is approximately four years.
ware is run the selected COM port must be
specified; this setting is stored and need not

1/2004 Elektor Electronics 17


TEST&MEASUREMENT

Figure 6. All the important parameters are


shown in the main window.

be entered again unless the logger is con-


nected to a different COM port.
When first powered up a new DS1616 has
its RAM filled with 0xFFs. When the climate
logger is connected to the PC for the first
time, the RTC time and a (sensible) sample Figure 7. The series of measured values (temperature, humidity, or either of the
rate must be set. This must also be done two spare inputs) can be displayed as a graph or as a table.
whenever the device’s backup battery volt-
age is interrupted (i.e., when BT2 is
changed). Until the sample rate is set, the PC
will read a measured value every second, and can be set and adjusted as desired If any of the settings (enabled
the display will be updated every second. for the next mission. When the data channels or sampling rate) is
While the data logger is connected to the logger is disconnected from the PC changed after ‘Enable External Start’
PC, the sample rate and other parameters it retains these settings and oper- has been clicked, the ‘Enable Exter-
ates in standalone mode. The set- nal Start’ feature is automatically
tings will only be lost if the backup reset. ‘Enable External Start’ should
battery supply to the DS1616 is only therefore be clicked when all
interrupted. the needed settings have been con-
In the most recent version of the figured, since it is at this point that
software available as we went to the selected sample rate and chan-
press (v1.23), a mission can also be nel selections are transferred to the
initiated using the pushbutton con- DS1616. If any settings are subse-
nected across JP1. This is done as quently changed on the PC, they will
follows. First configure the sample not be sent to the DS1616, and so the
rate, enabled channels and so on as configuration of the logger will not
described under ‘Software’ above. match what is displayed on the
Then click on ‘Enable External Start’ screen.
Figure 8. The three external analogue inputs and clear the memory contents: the (030076-1)
are shown under ADC Channels. ‘Memory Cleared’ indicator will
appear on the screen. The logger can
now be disconnected from the PC
and taken to the location where
measurements are to be made. To
initiate the mission, it is now simply
necessary to press the pushbutton Free Downloads
for at least 0.5 seconds; data record-
Windows software. File number:
ing will then begin. 030076-11.zip.
Measurements can also be initi-
ated using the pushbutton while the PCB layout in PDF format. File
logger is still connected to the PC. It number: 030076-1.zip.
is not necessary to shut down the www.elektor-electronics.co.uk/dl/
program: it can remain running and dl.htm,
Figure 9. Using the alarm settings the Climate will check whether a mission has select month of publication.
Logger can be used as a time switch. been initiated.

18 Elektor Electronics 1/2004


GENERALINTEREST

FMS Flight Simulator


Encoder
Practice without crashing your models
By Dean Sarelius d.sarelius@bigpond.com

We all know that even


the best pilots spend
many hours practising
on flight simulators
before taking to the real
thing, so why should it
be any different for
radio control planes?
With the FMS R/C Flight
Encoder described here
you can polish your
flying skills and gain the
valuable experience you
need without having to
invest in a radio control
or even to build a
model airplane. In fact
the FMS encoder will
even allow you to use
your own radio control
to further enhance your
flying ability.

22 Elektor Electronics 1/2004


GENERALINTEREST
Last year the author purchased a JR use an adapter which converts the anything above would make it turn clock-
4-channel radio control (R/C) and ‘buddy’ signal from the radio into wise. The greater the time delay positive or
built his first electric powered plane. data to interface to the computer. negative from 1.5 ms the further the rotation
Unfortunately the maiden flight was More about this further on. of the servo. When the encoder is used to
a disaster so a more serious look at interface to your radio control, it is the time
flight simulators was in order. Unfor- delay between these pulses which is con-
tunately, the cost of the so called A brief history verted into numerical form to interface to the
professional simulators was too In the 1960’s two engineers, Doug computer.
much to justify. Searching the Inter- Spreng and Don Mathers of NASA, There are a number of different ways to
net, a website called FMS was developed the original digital pro- obtain the PPM signals from your R/C radio
found. portional control system and a stan- and this will depend on which radio you
FMS (Flying Model Simulator) is a dard was set for the type of pulses have. More about this later.
freeware 3D flight simulator program required to control servos in radio
developed and written by Roman & control applications. With the Math-
Michael Möller. FMS has been com- ers and Spreng pulse position mod- So how does the encoder work?
piled to run in both DOS and Win- ulation system (or PPM) pulses are The encoder can work ‘stand alone’, without
dows and with thanks to Roman and transmitted — five pulses for a 4- any need for a radio control. In this mode you
Michael it is available as a free channel, six for a 5-channel and so simply plug it into the serial port of your com-
download from their website on. It is the space between these puter and use both joysticks as you would a
http://n.ethz.ch/student/mmoeller/ pulses which determines the posi- normal R/C.
fms/index_e.html. tion for the servos. These pulses are In the second mode of operation you will
The FMS simulator provides con- modulated such that the position need the PPM signal from your radio. Once
trol of planes and helicopters either between them is allowed to vary you have connected this signal you only need
by keyboard, joystick, parallel port or between 1 ms and 2 ms. For a 1.5- to press down on the joystick (actuating the
the serial port. The keyboard and joy- ms delay between pulses the servo internal switch) to toggle the mode so that
stick options are fine but if you wish would remain at centre, while any- the PPM signal from your radio control is used
to practice flying planes with your thing less than 1.5 ms would force to interface to the simulator. In this mode you
own radio control it is necessary to the servo to turn anti-clockwise and use the encoder to decode the PPM signals

IC2
+5V +5V
S1 7805 +5V

R8
K1
D1 D2 C3 C6
C4 C5
10k

+9V
0V
22u 100n 100n 10u
R1 R2 16V 16V
15
S2
470Ω

470Ω

12 1
P1.0 P0.0
11 20
P1.1 IC1 P0.1
+5V 10 19
P1.2 P0.2
9 18 P1 P2
P1.3 P0.3
8 17 CTS 10k 6 CTS 10k 6
K2 P1.4 P0.4 7 7
T2 4 16
R6 P1.5 P0.5 5 5
1 3 87LPC767 14
10k P1.6 P0.6 8 8
6 2 13 4 4
P1.7 P0.7
2 RxD BC557
7 R7 X1 X2
3 5 6 7
4k7

X1 1 2 3 1 2 3
8
4 DTR +5V
C1 C2
9
5
R5 27p 27p

11.0592MHz
1k

SUB D9

K3 T1
R3 P3 P4 P5 P6
1k
5k 5k 5k 5k
R4
BC547
100k

030066 - 11
+5V

Figure 1. Circuit diagram of the FMS Encoder. All intelligence is vested in microcontroller IC1. Connector K3 allows you to connect your
own R/C transmitter unit via its ‘buddy/trainer’ outlet.

1/2004 Elektor Electronics 23


GENERALINTEREST
from the radio and convert them into serial
data for the computer. You are now using your
own radio control to fly the virtual models, so
with practice you gain confidence flying with
your own R/C.
Within FMS options for ‘Control’ you will
find the ‘Serial PIC-interface’. You can choose
from two options, but it is the 19200 Baud /
0xFF Sync which this design is set to run
with. Make sure to select the correct COM
port and set it up in the following way:

– 19200 baud
– 8 bit data, 1 stop bit, no parity
– RTS set to HI
– DTR set to LOW

With the FMS encoder plugged in and the


correct COM port set up and calibrated you
are ready to start flying.
The encoder sends one packet for all chan-
nels. Every packet starts with 0xFF and a
byte is added with a value between 0 and
254 (0x00 to 0xFE hex) which provides the
information for the servo position. Since 0 to
254 values are available for a range of 1 ms to Figure 2. Pulses captured from an 8-channel R/C.
2 ms, the value which equates to 1.5 ms or
centre position is 127 (0x7F hex).
So for a 4-channel R/C with all servos in R/C generates — the more channels, achieved by pressing S2. Pulling the
the neutral position the data being sent to the the shorter the pause. P1.1 port line to ground causes the
computer would look like this: MCU firmware to change to the R/C
encoder mode.
Pause 0xFF 0x7F 0x7F 0x7F 0x7F Pause The circuit In this mode pulses continuously
0xFF 0x7F 0x7F 0x7F 0x7F Pause etc. The circuit diagram of the FMS sent to the MCU are converted and
Flight Simulator Encoder appears in conveyed to the computer. The MCU
The pause is actually the pause between Figure 1. You can see that it is basi- waits for a pause before it samples
PPM signals from the radio. This value would cally the Philips low pin count the time delay between consecutive
vary depending on how many channels your P87LPC767 MCU, that’s doing all the pulses. After the MCU detects the
work. The LPC767 is an 8-bit 8051 first pulse, it counts up in steps of 10
based MCU with one-time program- microseconds until it detects the
mable (OTP) PROM and four (!) chan- next pulse. Thus for a delay of
Signal nels of 8-bit analogue to digital con- 1.5 milliseconds between pulses, the
3 verters. A programmer for the value it sends to the serial port is
2 4
6
LPC76x family was described in approximately 127 decimal or 0x7F.
1 5 Hitec (all types) Elektor Electronics December 2003. Minor variations are not so critical
7 Futaba (new models) At power-up the encoder is in since the built-in driver for FMS
GND
SIM mode, reading the joystick posi- takes care of any calibration differ-
tions from the four 10-kΩ linear ences.
potentiometers contained in joy- If the MCU fails to detect any
GND sticks P1, P2, then converting this more pulses it simply bails out and
analogue information into packets of sends only those channels which it
2
5 4 data to send to the serial port on the could count, this may be anything
Signal
3 1 PC. To provide a means of trimming from a 2-channel to an 8-channel R/C
Futaba (old models) the controls, 5-kΩ presets (P3-P6) pulse train.
6 Sanwa, Airtronics have been added in series with the Figure 2 shows the pulses from
030066 - 13 joysticks pots. an 8-channel R/C. You can see that
To engage the R/C mode (which there are actually nine pulses, and
Figure 3. Signal functions on the buddy/trainer allows you to use your own R/C that there is a delay of around 10 ms
socket of some commonly used R/C transmitter) you simply press down between pulse trains.
transmitters. If yours is not shown, consult the on either of the two joysticks to acti- It is the inverted version of these
owners manual or ask help from fellow FMS vate an internal tactile switch. If the pulses which are sent to buffer tran-
users via the FMS Forum. joysticks are not fitted, the same is sistor T1. These pulses are inverted

24 Elektor Electronics 1/2004


GENERALINTEREST
COMPONENTS LIST
Resistors: T
K1
R1,R2 = 470Ω D1 D2
0V +9V K3

HOEK1
K2
HOEK2

R3,R5 = 1kΩ
S1 R4
R4 = 100kΩ
R7
R6,R8 = 10kΩ R3
T2 S2
R7 = 4kΩ7

R2
R1
P1 P2
P1,P2 = mini joystick, CTS model

R6
T1
25A104A60TB (order code
CTS25A from www.dil.nl)* X1
C1

IC1
P3-P6 = 5kΩ preset P4 P6

R8
R5
Capacitors:
C1,C2 = 27pF P3
C6
C2 P5
C3 = 22µF 16V axial C4
1-660030
C5
C4,C5 = 100nF 030066-1
ROTKELE )C(
C3
C6 = 10µF 16V axial IC2

HOEK3
HOEK4

Semiconductors:
D1 = LED, green, 3mm
D2 = LED, red, 3mm
IC1 = 87LPC767BN,
programmed, order code (C) ELEKTOR
030066-1
030066-41
IC2 = 7805CP
T1 = BC547B
T2 = BC557B

Miscellaneous:
K1 = 9-V battery with clip-on
leads
K2 = 9-way sub-D socket
(female), PCB mount
K3 = 3.5mm mono jack socket,
chassis mount
S1 = on/off switch
S2 = pushbutton, 1 make contact
X1 = 11.0952MHz quartz crystal
PCB, order code 030066-1 Figure 4. Copper track layout and component mounting plan of the PCB designed for the
3 wire links FMS Encoder (board available ready-made).
RS-232 cable (non-crossed)
Case, e.g., Pactec WM-46 (Conrad
Electronics # 54 13 03 )

* Worldwide distributor
information from
www.ctscorp.com

by T1 thus bringing them back to


normal before they are sent to MCU
pin13.
Output data from MCU port line
P1.6 (pin 3) is buffered by T2, with
R7 providing the required level shift-
ing to drive the RS232 port.
Only two wires are required from
your R/C radio to interface to the

Figure 5. Our finished and fully


working prototype.

1/2004 Elektor Electronics 25


GENERALINTEREST
FMS encoder. Where these connections are Electronics Readers Services. The and approved the presence of the +5
will depend on what type of R/C you have. A respective order codes are 030066-11 volt supply voltage at a number of
few are listed in Figure 3. You may have more and 030066-41. The MCU for this relevant points in the circuit, for
information available from your radio control project is only available ready-pro- example, IC1 socket pin 15, the emit-
manual. If you are unsure which connections grammed. The author receives roy- ter of T2 and the anode wires of
to use then don’t be afraid to experiment alty payments for every copy sold LEDs D1 and D2. Okay so far? Then
since the buffered input is quite safe. If you hence no hex code or source code switch off and insert the MCU,
fail to place them the right way around the files can be supplied. observing the position of the notch
encoder will behave erratically — just swap The PCB (Figure 4) is spacious on the PCB overlay.
them over and everything should be okay. and single-sided. As usual, polarized Pinheader strips beside joysticks
The whole circuit runs off a single 9-V components like LEDs, electrolytic P1 and P2 are provided to connect
(6F22) battery and draws only 21 mA, most capacitors, transistors and inte- joysticks that do not fit the board, or
of which is consumed by the LEDs D1 and D2 grated circuits should mounted the an old R/C of which the RF sections
which indicate SIM mode and R/C mode right way around on penalty of cre- are faulty or even missing.
respectively. A 7805 regulates the battery ating a hard to find circuit fault (best
supply down to 5 V to power the MCU. At case) or destroying them when the
least five hours play time should be available power is applied (worst case). Don’t Finally
from a standard 9-V battery. swap T1 and T2, the devices looking Users of the Encoder described in
identical but being complementary this article are encouraged to com-
(npn and pnp respectively). municate with other FMS users via
Construction The MCU being the most expen- the Forum which can be accessed
Construction of the FMS Flight Simulator sive component, it really deserves to via the FMS homepage. Happy fly-
Encoder board should be easy if you use a be fitted in a good quality IC socket. ing!
ready-made printed circuit board and a pro- However, it should not be inserted in (030066—1)
grammed MCU supplied through the Elektor the socket before you have verified

Advertisement

26 Elektor Electronics 1/2004


AUDIO&VIDEO

RIAA Preamp
with FETs
SRPP equaliser for moving magnet (MM) cartridges
Design by H. Breitzke

This preamplifier and equaliser is based around field effect transistors and
is an updated version of the SRPP valve preamp we published in March
and April 1987. Various changes are necessary due to the fact that the
FET SRPP configuration offers a considerably higher gain and output
impedance than its valve sibling.
The Shunt Regulated Push-Pull (SRPP) topol- for use with bipolar transistors or increased. Using FETs, however, we
ogy is frequently used in high-frequency with operational amplifiers because can employ the SRPP topology as
applications, but is seldom seen in audio cir- the circuit does not employ negative effectively as with valves.
cuits. This is simply because SRPP works feedback.
well with valve technology, but is not suitable As a result distortion is considerably

28 Elektor Electronics 1/2004


AUDIO&VIDEO
Figure 1. Push-pull circuit with SRPP nected in series. The signal is taken to the
topology. gate of the lower FET. The AC voltage
dropped across the impedance in the source
connection of the upper FET serves as an out-
SRPP of-phase drive voltage for the upper FET,
since the drain of the lower FET is connected
The SRPP technique is based on a to the gate of the upper FET. Meanwhile, the
push-pull arrangement (Figure 1), DC voltage drop across the trimmer poten-
where the transistors or valves are, tiometer provides the gate bias voltage for
for the purposes of DC analysis, con- the upper FET. From the point of view of the

030162 - 14 Figure 2. The circuit of the RIAA equaliser includes a high-quality power supply.

24V +24V +24V

T2.B BF245B
7 T4
C7 C8
6

5 100n T5 100µ
40V
P1
C3
P2 BC550C
1k
1µ C6 K2 L
250Ω
T1.A
1
L K1 T3 1µ R11
2 T2.A R7

47k
1
68k
3 C2 R6
2
1k33

R10
1µ 3 220k
BF245B
R1 R2 R3 R4 R5 R8 R9 R12
C1 C4 C5
100Ω

100Ω

470Ω
47k

47k

10k

15k
12k1

27p 220n 82n

+24V
T1 = 2SK389
T2 = 2SK389 T6.A
1 BF245B T8
T6 = 2SK389 C15 C16
2

3 100n T9 100µ
40V
P3
C11
P4 BC550C
1k
1µ C14 K4 R
T1.B 250Ω
7
R K3 T7 1µ R23
6 T6.B R19
47k

7
68k
5 C10 R18
6
1k33

R22
1µ 5 220k
BF245B
R13 R14 R15 R16 R17 R20 R21 R24
C9 C12 C13
100Ω

100Ω

470Ω
47k

47k

10k

15k
12k1

27p 220n 82n

TR1

K5 C25 C22
L1 IC1

C27 C26
47n 47n
R28 LM317 24V
X2 X2 B1 22Ω
R27 R25
100n 100n
C24 C23
274Ω

250V
10k

250V
2x 27mH
47n 47n C18 C17

D1 R26
2x 12V C19 10µ 100n
B80C1500 C21 C20
4k87

1VA8 63V

1000µ 100n 10µ


POWER
63V 63V

030162 - 11

1/2004 Elektor Electronics 29


AUDIO&VIDEO
lower transistor the upper transistor appears – generous headroom; U DS < 30V

as a current source, while the output is taken – low output impedance.


from the upper transistor in a source-follower
arrangement. This special push-pull topology
reduces the output impedance of the transis- The Circuit
I DS = constant
tors by a factor of 3 or 4. The operation of the Aside from the power supply, the cir-
SRPP circuit is straightforward: it is surpris- cuit in Figure 2 consists of two iden-
ing to discover, then, what advantages it tical amplifier stages: we will
offers both technically and in terms of how it describe the left channel. Central to
sounds: the amplifier is the SRPP arrange-
ment around T2a and T2b, which 030162 - 15
– very low distortion; has a gain of approximately 280. A
– extremely high linearity; type 2SK389 dual FET is used to Figure 3. Circuit used for selecting
– high gain; reduce noise and to improve thermal FETs.

stability. Because of the high input


Characteristics capacitance there is a Miller capaci-
(with 200 mV output voltage, 1 kHz, 47 kΩ load) tance of a few nanofarads, and so an
input buffer in the form of source-fol-
Power supply voltage 24 V
lower T1 is necessary. Here again a
Current consumption approximately 18 mA
Nominal sensitivity approximately 2 mV
2SK389 is used (one transistor per
THD+N (400 Hz to 22 kHz) 0.054 % channel), which guarantees good
S/N >71 dBA matching between the two chan-
nels. In principle any low-noise FET
+6
can be substituted.
A Following the SRPP stage there is
+5
an RIAA equaliser network compris-
+4
ing C3, C4, and C5, and R5, R6 and
+3
R7. The maximum deviation from the
+2
official RIAA equalisation curve is
d
+1 just –1.6 dB at 20 Hz and agreement
B
r -0 is generally within about 0.3 dB.
[A]
-1 T3 to T5 form the output stage of
-2 the equaliser, with a gain of 12. The
-3
gain can be adjusted over a wide
-4
range by changing the AC feedback
network formed by R10, R11 and
-5
R12. The output impedance is just a
-6
20 50 100 200 500
[Hz]
1k 2k 5k 10k
030162 - A
20k few ohms.
For T3 and T4 we would ideally
Curve A shows that the deviation from the standard RIAA correction curve is very low:
like to use a dual FET with a low
only –1.6 dB at 20 Hz.
input capacitance but with a
+0 transconductance comparable to
-10
B that of the BF245B. Unfortunately
-20 such a dual device does not exist,
-30 and so we must select two suitable
-40 BF245Bs. We therefore connect the
-50 transistors as shown in Figure 3 and
d
B -60 try to find pairs with the closest pos-
r
[A] -70 sible drain currents. The lower tran-
-80 sistors of the two channels should
-90 also be as similar as possible in
-100 order to achieve good channel
-110 matching.
-120 Since a clean DC supply is essen-
-130 tial for a sensitive circuit such as
20 50 100 200 500 1k 2k 5k 10k 20k 50k 90k
[Hz] 030162 - B
this, a few words about the power
The spectrum plot in Curve B shows the second harmonic at –67 dB. The third is barely supply are in order. High-frequency
above the noise floor. interference is suppressed by a
mains choke and two capacitors on

30 Elektor Electronics 1/2004


AUDIO&VIDEO

COMPONENTS LIST
K1 K3
C27 L1 C26

R14
H5

H2
H6 H3

R2
Resistors: ~ K5 L R
R1,R3,R11,R13,R15,R23 = 47kΩ C8
T1
C16
R1 R13
R2,R4,R14,R16 = 100Ω C2 C10
C1 C9
R5,R17 = 12kΩ1
R4 R16
R6,R18 = 1kΩ33

C13
C5

R15
R7,R19 = 68kΩ

R3
~ T2 C3 C11 T6
R8,R20 = 470Ω

C7

C15
R9,R21,R27 = 10kΩ P1 P3
R10,R22 = 220kΩ TR1
R12,R24 = 15kΩ R5 R17

R18
R6
R25 = 274Ω P2 R7 R19 P4
R10 R22
R26 = 4kΩ87
C21 C24
R28 = 22Ω C25 T3 T4 T8 T7
C20 B1 R8 R20
P1,P3 = 250Ω preset

030162-1

ROTKELE )C(
1-261030
R12 R24
R11 T5 C4 C12 T9 R23
P2,P4 = 1kΩ preset C22 +
R28

C23 K2 R9 R21 K4

C6

C14
C19
L R
Capacitors: R25
R26
0
OUT1 OUT2

C18 +
C1,C9 = 27pF R27

H8

H4
H7 H1
C17

D1 IC1 0
C2,C3,C6,C10,C11,C14 = 1µF
MKT, lead pitch 7.5mm
C4,C12 = 220nF
C5,C13 = 82nF
C7,C15,C17,C20 = 100nF
C8,C16 = 100µF 40V radial

(C) ELEKTOR
030162-1
C18,C19 = 10µF 63V radial
C21 = 1000µF 63V radial
C22-C25 = 47nF ceramic, lead
pitch 5mm
C26,C27 = 100nF 250 VAC (Class
X2), lead pitch 15mm

Inductors:
L1 = suppressor choke 2 x 27mH
(Epcos # B82721-K2401-N21)

Semiconductors:
B1 = B80C1500 bridge rectifier,
rectangular case (80V piv, 1.5 A)
D1 = LED, low current
T1,T2,T6 = 2SK389-BL (Toshiba),
(www.reichelt.de)
T3,T4,T7,T8 = BF245B (see text)
T5,T9 = BC550C
IC1 = LM317 (TO220 case) Figure 4. Printed circuit board layout.

Miscellaneous:
K1-K4 = cinch socket, PCB mount
age regulator produces a stable and so that the voltages at the source connections
(Monacor/Monarch # T-709G)
clean 24 V supply. of T2b and T4 are each equal to Ub/2. The
K5 = 2-way PCB terminal block,
Figure 4 shows the layout for the input capacitance of the circuit is formed by
lead pitch 7.5m
TR1 = mains transformer, 2 x 12V printed circuit board, which has an capacitor C1 and the input capacitance of T1,
/ 1.8VA (e.g. Gerth # 304.24-2) extensive ground plane. Unless the which, in the case of the 2SK389, is around
PCB, available from The PCBShop. board is to be mounted as a whole 20 pF. The optimum input capacitance
inside the enclosure, the power sup- depends on the type of cartridge, and will
ply section should be cut off before normally be found in the specifications of the
populating the board. The layout system.
the primary side of the small 24 V and the component arrangement (030162-1)
transformer. On the secondary side are practically symmetrical, and
capacitors are connected across the there are two wire links, near to K2 Internet address:
diodes in the rectifier bridge, which and K4. www.tubecad.com/may2000/
suppress interference caused when Alignment of the circuit involves
the diodes switch. The LM317 volt- adjusting potentiometers P1 and P2

1/2004 Elektor Electronics 31


GENERALINTEREST

Multi-event
Alarm Clock
In control of many daily events
Design by K.-U. Mrkor

A regular alarm clock, whether stuffed with electronics or of the


mechanical variety, will not get you very far if you need to be reminded
of several events during the day (for example, taking your medication).
What you need is a multi-talent like the circuit described here.

The circuit diagram of the Multi-event Alarm


Clock shown in Figure 1 is easy to under-
stand, the central parts being a contemporary
combination of a microcontroller, a real-time
clock and an LC display. At the heart of the
circuit sits a powerful yet inexpensive and
widely available 8051-compatible 8-bit micro-
controller type AT89C2051 from Atmel. Its
main features may be summarized as follows:

– full 8051 software compatibility;


– 2 kbytes of Flash memory;
– integrated analogue comparator;
– multiple outputs with LED drive capability;
– static architecture (0-24 MHz)
– extended supply voltage range (2.7-6 V).

Quite important for this application, the chip


comes in a small enclosure with ‘just’ 20 I/O
pins. Port 1 and Port 3 (with the exception of
the P3.6 line) provide 15 freely programmable
port lines. This should be more than adequate
to connect the following peripherals: an LCD
to display time and menus, two pushbuttons Clock reference quartz crystals and found pulse peri-
to set the clock and the alarm times, an LED adjustment ods of up to 1.000008 seconds at the
and a piezo buzzer as an acoustic alarm. chip output. Unfortunately, what
To these elements should be added a real- In real life, the clock output of the appears to be a totally harmless
time clock (RTC) component type DS1307 DS1370 will rarely supply a pulse error in the sixth decimal position
which communicates with the MCU via an with a period of exactly 1.000000 can well be the cause of serious
I2C link. Thanks to a 3-volt Lithium backup seconds. This is because the quartz degradation in the clock’s final accu-
battery, the DS1307 will keep ‘ticking’ in the crystal used in the RTC clock oscilla- racy, amounting to an error of four
absence of the supply voltage. Suitably pro- tor circuit is subject to a certain pro- minutes per year.
grammed, the chip supplies a seconds pulse duction tolerance. The author pur- Although the error may be com-
at the SQW/OUT pin. chased and tested a number of these pensated by adjusting trimmer C5,

32 Elektor Electronics 1/2004


GENERALINTEREST
that really makes sense only if you +5V
+5V
have a reliably and extremely well
calibrated frequency counter boast- R5 R6 R7
C6

4k7

4k7

4k7
ing a microseconds range. Assuming 8 3
C4 100n
you have such an instrument (or VCC VBAT
100n 7
have access to it) then the probe R1 C3 SQW/OUT
X1
1 32.768kHz
BT1
X2

1k
may be connected to pin 7 of the 6
IC2
1µ 63V 20 SCL
DS1307 and the trimmer adjusted for DS1307 2 3V
1 5 X2
a reading that’s acceptable. Failing RST
12 SCL
SDA
C5
P1.0 GND
the above, C5 is best omitted from 2
IC1 13 SDA
P3.0 P1.1 4
the circuit. 3
P3.1 P1.2
14 RS
25p
6 15 E
P3.2 P1.3
7 16 D4
P3.3 P1.4
D1 AT89C2051
Power supply 8
9
P3.4
-12PC
P1.5
17
18
D5
D6
P3.5 P1.6
19 D7
The power supply for the circuit is of P1.7 +5V
11
a less conventional design, consist- P3.7
X1 X2 LCD1
ing of a low-drop voltage regulator,

4 RS
14 D7
12 D5

E
10 5 4

16 K
K
IC3, with its usual satellite parts. Its X1

10
8
6

2
S1 S2

Backlight
function is to turn the external sup-
C1 C2
ply voltage (from a battery or a

A 15
D6 13
D4 11
9
7
5
3
1
mains adapter) into a stable 5-V sup- 33p 6MHz 33p

ply rail for all circuit parts except the A


LC-Display
P1
LCD backlight. Jumper JP1 ensures T2
8 x 2 Chars.
C7
that the backlight current is never ≥ 7V D2 R8
BD242
1Ω5 100n
drawn from a battery — after all, ≈ 40...240mA 10k
+5V 1N4001
we’re looking at something between
40 and 240 mA depending on the R4
T4

LCD type you decide to use. The cur- R9 BF256C


10Ω

100Ω
rent circuit around T2-T3-T4 (actually R10
BC557C P2
a current mirror) only works when a JP1 T3 220Ω

mains adapter is used to power the Mains


R2
circuit, supplying the necessary cur- Batt. 2k5
47k

BZ1
rent for the backlight lamp(s).
The current consumption of the IC3
4805 +5V
circuit with the exception of the LCD T1 BT2
C8
amounts to just 5 mA which may be 6V
lowered even further by a small 220µ 10V R3
C11 C10 C9
47k

reduction in the MCU clock fre- BC547B


quency. The MCU itself does not exe- 470µ
16V
100n 10µ
63V
cute time-critical tasks and will hap-
020304 - 11
pily run at a clock frequency as low
as 2.4576 MHz. The only conse-
quence of a relatively low MCU clock Figure 1. The main components in the project are a microcontroller, a real-time clock chip,
frequency (determined by the quartz an LCD and two pushbuttons.
crystal) is a slightly sluggish menu
when the clock and alarm times The only limitations of this version the DS1307 and fed to the AT89C2051 MCU by
have to be set. are (1) non-commercial use and (2) a way of an I2C bus interface. Unlike some other
Obviously the DS1307 is not maximum object code size of 8051 derivates from Philips, the AT89C2051
affected by these changes because 2 kbytes. The latter limitation is hard does not have an on-chip I2C interface, hence
it employs its own timebase. to object to if you realize that the a few I2C routines had to be written based on
size of the AT89C2051 Flash memory an example supplied by Keil.
is also 2 kbytes! Access to the real-time clock is similar to
Software The microcontroller executable reading/writing a memory device. The only
The software for the project was code looks after several tasks includ- point to keep in mind is that the first eight
written in the ‘C’ higher language, ing outputting the current time, com- bytes in the RTC RAM are reserved for the
using Keil’s µVusion2 package as a municating with the user via a menu clock itself. The battery backup makes the
development platform of which a structure and, last but not least, remaining 56 free memory locations ideal for
free evaluation version may be enabling the acoustic actuator when the storage of alarm times. However, the
downloaded from an alarm time is reached. DS1307 has to be initialised before it can be
The seconds clock pulse that’s used as a timebase. The initialisation com-
www.keil.com/demo/eval/c51.htm crucial to the function of the Multi- prises adjusting the clock and loading the
event Alarm Clock is generated by control bytes. The memory map in Figure 2

1/2004 Elektor Electronics 33


GENERALINTEREST
shows the meaning and function of the indi- Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
vidual bits contained in the first eight control
bytes. The MSB (most significant bit) in the CH seconds (tens) seconds
seconds byte (CH, clock halt) is the most 00h 0 minutes (tens) minutes
important in this respect. Whenever the IC is seconds
hours
powered up, this bit always reads 1, and the minutes 0 12/24 10/A/P (tens) hours
clock is not started until CH is made 0. Set- hours
0 0 0 0 0 day
ting the OUT and SQWE bits prompts the day
DS1307 to supply a rectangular signal at its date 0 0 date (tens) date
month month
OUT pin. The frequency of the output signal 0 0 0 (tens) month
year
is determined by the RS1 and RS0 bits. A 1-
07h control year
second pulse is obtained by programming the year (tens)
08h
value 00b. 56 Byte OUT 0 0 SQWE 0 0 RS1 RS0
By connecting the OUT line of the DS1307 RAM
to the INT0 input of the microcontroller, a 1-
3FH 020304 - 12
second interrupt is generated. The relevant
interrupt service routine updates the time
output to the display. Next, a check is per- Figure 2. DS1307 memory map.
formed to see if the current time matches one
of the alarm times stored in the DS1307 RAM
area. If so, that event is signalled by three The control program then checks pushbuttons to call up the menu. If
acoustic and optical signals. if the user is pressing one of the so, the menu is made available, else,

COMPONENTS LIST
C11 = 470µF 16V radial chassis mount
Resistors: LCD1 = LC display, 16 characters (2
R1 = 1kΩ Semiconductors: lines x 8), e.g. AV0820 from Anag
R2,R3 = 47kΩ D1 = LED, red, 5mm, low current Vision) plus 16-way boxheader
R4 = 10Ω (optionally with chassis-mount X1 = 6MHz quartz crystal (parallel
R5,R6,R7 = 4kΩ7 holder) resonance)
R8 = 1Ω5 D2 = 1N4001 X2 = 32.768 kHz quartz crystal
R9 = 100Ω T1 = BC547B BT1 = 3V Lithium cell type CR2032
R10 = 220Ω T2 = BD242 with PCB mount holder (22.75mm
P1 = 10kΩ preset T3 = BC557C diam.)
P2 = 2kΩ5 preset T4 = BF256C BT2 = see text
IC1 = AT89C2051-12PC, BZ1 = 5V or 6V DC buzzer (active
Capacitors: programmed, order code 020304- piezo)
C1,C2 = 33pF 41
C3 = 1µF/63V radial IC2 = DS1307 PCB, available from The PCB Shop
C4,C6,C7,C10 = 100nF IC3 = 4805
C5 = 25pF (trimmer) Disk, microcontroller C (source) and
C8 = 220µF 10V radial Miscellaneous: hex files, order code 020304-11 or
C9= 10µF 63V radial JP1 = 3-way pinheader with jumper Free Download
S1,S2 = pushbutton, 1 make contact,

T2
A
H2

H3

K
R9

R8

T4
LCD1 C7
T3
C9 P2 C3
R10

P1 D1
IC1
IC3

C4
R1

X1
C11
C10 R2
C2 R3
C1
S1 S2
R4
R7
R5
R6

IC2
C8
+ JP1
D2

Batt. 1-403020 C6 T1 020304-1


ROTKELE )C( (C) ELEKTOR
- - +
BT1 X2
>=7V
H4

H1

0 + 020304-1 C5 BZ1

Figure 3. Copper track layout and component mounting plan of the PCB designed for the Multi-event Alarm Clock.

34 Elektor Electronics 1/2004


GENERALINTEREST
update and pushbutton check routines are
run again.

Construction and use


The circuit is conveniently built on the single-
sided printed circuit board of which the lay-
out is shown in Figure 3. It should be noted
that a number of components are not accom-
modated on the board — these include the
‘large’ battery, BT2 (which may take the form
of two Lithium cells, four Alkaline cells or a
single 9-V battery), piezo buzzer BZ1, push-
buttons S1 and S2 and, of course, the LC dis-
play. The latter is connected by way of a 16-
way pinheader and two extra solder pins (A
and K for the backlight).
Populating the board should not cause
problems as there are no unusual compo-
nents to deal with or special mounting
methods to observe. As a matter of course,
electrolytic capacitors, transistors and inte-
the microcontroller changes to (assuming a clock of 6 MHz). The grated circuits must be mounted the right
‘sleep’ mode. In this energy-saving MCU does not wake up until the way around as they are polarized compo-
mode, the AT89C2051 consumes just next interrupt is request is received nents. Transistor T2 and voltage regulator
1.6 mA as opposed to 7.5 mA from the DS1307, when the display IC3 do not need heatsinks as they pass rel-
atively low currents. As illustrated in the
introductory picture, the two pushbuttons
are fitted directly onto the case panel, just
adjust clock enter new clear alarm below the display (S1 to the right, S2 to the
alarm time time 17:45 left). The alarm LED may also be mounted
below the display.
All user settings are guided by the in-built
menu and entered using the two pushbut-
tons. The menu is entered by keeping one of
the pushbuttons pressed for about one sec-
ond. Within the menu, the items to define
invariably have two options, which are dis-
played in the lower of the two display lines.
The desired option is selected by pressing
the pushbutton below the relevant text on the
2 1
display (i.e., left or right).The three main func-
tions, clock adjust, alarm adjust and alarm
clear, are shown pictorially in Figure 4.
(020304-1)

Web pointer
2 1 2 1
DS1307 datasheet at
http://pdfserv.maxim-ic.com/en/ds/DS1307.pdf

2 1 2 1
Free Downloads
Microcontroller C (source) and hex files.
File number: 020304-11.zip
PCB layout in PDF format.
File number: 020304-1.zip
020304 - 13
www.elektor-electronics.co.uk/dl/dl.htm,
select month of publication.
Figure 4. Operating the clock could not be easier using the built-in menu.

1/2004 Elektor Electronics 35


APPLICATIONNOTE
The content of this note is based on information received from manufacturers in the electrical and electronics industries or
their representatives and does not imply practical experience by Elektor Electronics or its consultants.

HV9901
A novel LED driver
By E. Haug

LEDs have been around for years now but it’s only recently that things
have started to get interesting with white and superbright versions
appearing at reasonable cost. LEDs of course require some form of
driving circuit and there is a lot of interest in more efficient or versatile
techniques for driving them. This circuit isn’t fussy; it outputs a constant
current suitable for high power LEDs and it doesn’t care whether the
input is 12 V or 230 V!

It sometimes happens that a chip manufac- VIN

turer comes up with an IC to perform a spe- LED current


I LED HV9901
cific function and later the chip is found to be VDD Int
Reg SYNC
useful in a different application, not antici-
LED
pated by the original designer. The HV9901 D
GT

Universal Relay Driver from Supertex Inc. is VREF VREF PWM CS


L
just such a device. It was originally designed fast
to provide a constant current output drive for U suppressor
diode
H/D
RT
a relay coil from a very wide range of supply
voltages from 10 V up to 450 V DC without
peak current
the need to alter any of the circuit compo- Ip
S Aux POL
nents. This device offers a number of benefits VCC Reg
ENI
both to the designers of white goods where
peak current switch FB ENO
the variety of relays used in equipment can (constant clock frequency f)
be reduced (optimising quantity discounts) 030212 - 11 COM 030212 - 12
and also to the maintenance engineer who
does not need to check coil ratings of a
replacement relay. The HV9901 operates at Figure 1. The switched current source Figure 2. Internal diagram of the
DC voltages only so for AC operation a bridge configuration. HV9901.
rectifier is also needed (but no reservoir
capacitor is usually necessary).
tive of the level of supply voltage. In devices consuming a few hundred
How come that LEDs and relays are so the past with low current LEDs tak- milliamps up to 1 A the need for
alike that they can both be driven by the ing only a couple of milliamps the efficient drivers is more acute to
same chip? Well both require the drive cur- problem of driver design was not so avoid excessive dissipation in the
rent to be as constant as possible irrespec- great but with today’s high power driver circuit.

36 Elektor Electronics 1/2004


APPLICATIONNOTE
MOSFET to the load and measures the load
I LED
[mA] current through a sense resistor to produce a
(rippled) constant current output. The oscil-
lator frequency is set by the value of resis-
IP tance connected from the RT input to ground.
∆I The ripple current ∆I (Figure 3) is gov-
erned by the coil inductance, clock frequency
f and the peak LED current IS. It is important
to accurately control current through the LED
because the maximum peak current of high
t current LEDs is only slightly more than their
continuous current rating so it is important to
[ms]
achieve high brightness from the LED with-
out over-driving it. Each time the peak value is
1/f exceeded the stress causes brightness reduc-
030212 - 13
tion, colour change and can lead to the
untimely death of the LED.
Figure 3. Load current waveform.
The ReLED driver
A switched the coil and back to the positive sup- The circuit is capable of driving both relays
current source ply but it decays almost linearly (also electro mechanical valves and solenoids
because of the energy losses through etc.) and all types of LED so the circuit was
The step-down generator used in the the coil and LED. Once more the given the name ReLED (well it seemed like a
HV9901 is a switched current source. switch is closed and current good idea at the time). The circuit controls its
Figure 1 shows the principle of the increases again until it is inter- output current by measuring peak current
circuit. When the switch is closed rupted. This process is continually through the coil via a sense resistor and
current through the coil begins to repeated so that current through the switching the supply on and off. This is not
rise. The rate of current rise depends load has a ripple characteristic. The the conventional method of providing a con-
on the value of supply voltage and faster the switching process repeats, stant current source but the circuit is very
the coil inductance. Before current in the smaller the peaks and troughs of simple to use and performs reliably.
the circuit rises too much the switch the ripple will be. The HV9901 The HV9901 can accept input voltages in
is opened and the flow is inter- shown in Figure 2 generates the the range from 10 V to 450 V DC (providing
rupted. The ‘flywheel’ diode allows PWM signals to switch the high volt- that suitable MOSFETs and diodes are used)
current to continue to flow through age input through an external power and not just ‘pure’ DC but also pulsed sup-

(P)DR127-102 (SMD)
PE-53120 D2
SWC-0.95-1000 1N4148

+9V
LED C2
D1 350mA 47µ
optional 16V
surge protection and mains filter LUXEON 1W
1 16
L F1 VIN VDD
UF4004 L1
1mH IC1
15
500mA/M CY1 500mA VREF
C3
STD5NM50(-1)
(from 12V AC*/DC)

1n Q1 (best choice) 14 100n


L2 HOLD/DELAY
RU
SPD04N50,
115 / 230V

CX1 CX2 or SPD07N60, 4 13


GL1 IRF830A GT FB
100n 100n
C1 C1* 5 12
CY2 CS VCC
2x 1mH R1.1 R1.2
dimens. for

265V
300mA

0.5A 33n
4Ω7

4Ω7

1n 6 11
N 275V COM ENI
HV9901P
current compensated choke 7 10
S10K275 CDV-1.0-A / 42V15 10 01 SYNC ENO
S07K275 2% resistors
R2
PE 8 9
560k RT POL

Caution: live area -- no galvanic isolation

GND
local ground – do not bond out

030212 - 14

Figure 4. Circuit of the ReLED driver including the mains filter.

1/2004 Elektor Electronics 37


APPLICATIONNOTE
plies like unsmoothed rectified 50 Hz mains 1 16 C2 10µ
VIN VDD
supply. This feature allows a high current out- 16V
IC1 C3 100n
put supply to be produced without the need VREF
15

for expensive and bulky electrolytic reservoir


14
HOLD/DELAY
capacitors. R3
68k
The circuit in Figure 4 provides an output 4
GT FB
13
R4
current of around 300 mA and is suitable to

220k
5 12 CMOS-IC
drive a blue or white 1 W Luxeon LED. Over- CS VCC
C4 100n
voltage protection and a mains filter is
max 1 mA current
+5V
included on the input to the circuit to comply consumption
(see HV9901 datasheet)
with EMC recommendations for any mains 6
ENI
11 ON
control output
COM
powered clocked circuit. Other types of LED HV9901P
7 10
can also be driven from this circuit providing SYNC ENO (inverted ENI return)

that the value of the current sense resistors 8 9


RT POL (ENI signal polarity)
(R1.1 and R1.2) are changed if the LED current
rating is different. The current sensing resis-
tor should be of a type having low parasitic GND
common ground
inductance, connecting two identical resistors
030212 - 15
in parallel helps to reduce any inductance and
also shares the energy dissipation.
The coil inductance and the oscillator Figure 5. Auxiliary power for additional CMOS circuits.
PWM switching frequency both play an
important role in keeping the current ripple
C2
to an acceptable level. 1 16 10µ
VIN VDD
In contrast to linear current regulators the 16V
IC1
value of input voltage has only a small effect VREF
15 +9V

on the power dissipation in the driver (and the C3


14 100n R9
efficiency of the circuit). Several individual HOLD/DELAY

1M
LEDs can be connected in series and driven 4 13
GT FB 4 8
from this circuit provided there is sufficient
R
supply voltage available. The minimum sup- 5
CS VCC
12
DIS
7
R10
ply voltage required to drive an LED is 12 V DC IC2

150k
6 11 ON 3 2
or AC but with a rectified AC supply of less COM ENI OUT TR

than around 30 V the period that the circuit HV9901P TLC555


7 10 6
SYNC ENO THR
cannot conduct around the zero crossing
CV
points of the rectified AC waveform is rela- 8
RT POL
9
5 1
tively long so the LED will noticeably flicker. A C8 C7
220 µF reservoir capacitor (with an appropri-
100n 2µ2
ate voltage rating) can be used to prevent this.
GND 030212 - 16
Connections to the LED are both open and
short circuit proof provided that these leads
are not shorted to ground! A fast-acting fly-
wheel diode suitable for the 50 KHz switch Figure 6. Flasher circuit showing VDD and VCC linked.
frequency must be used in the circuit other-
wise there is a risk that the MOSFET will be
destroyed. capacitance. Unfortunately MOSFETs mains supply voltage without the
with low RDS(ON) have correspond- need for any heat sink.
ingly high input capacitances so that The coil specification is also
Component choice switching power MOSFETs at speed important to ensure that it does not
One area often overlooked by newcomers to gets more of a problem at high fre- become saturated at the peak cur-
FET design is the gate characteristic of the quency and high supply voltages. rent over the complete operating
MOSFET. At first glance we notice that the When choosing the MOSFET type temperature. A check with an oscil-
input impedance is very high and mistakenly it’s therefore important to check out loscope should indicate that the volt-
jump to the conclusion that not much energy is the gate capacitance and not just age rise across the sense resistor is
necessary to switch the MOSFET. This is true select the device with the lowest more or less linear.
if the device is operated at low frequencies or RDS(ON). The HV9901 can comfort-
DC but if we are switching the MOSFET at ably switch devices with a gate
speed another factor is important: the gate capacitance up to 500 pF and can More features
capacitance. The maximum switching fre- also cope with 1 nF at a push. The In addition to providing a stable LED
quency of the MOSFET will be governed to a suggested MOSFETs in this design drive current from a wide range of
large extent by how fast the gate driving cir- can switch the LED supply at a input voltages the circuit also has a
cuit can charge and discharge this input PWM frequency of 50 kHz from number of other features that may be

38 Elektor Electronics 1/2004


APPLICATIONNOTE
C2 a step-up regulator by placing the load (e.g.
10µ
10V a 12 V LED cluster) in series with the fly-
1 16
VIN VDD wheel diode. In this mode the supply has a
IC1
15
much higher ripple current.
VREF
C3
14 100n
HOLD/DELAY Testing times
4 13 R8 R6
GT FB Before you try the circuit out with an expen-

2k7
100k
5 12
sive Luxeon LED it is a good idea to substi-
CS VCC
tute a power zener diode instead of the LED.
6
COM ENI
11 A zener diode has almost identical electrical
HV9901P R7 characteristics providing you choose one with
7 10
SYNC ENO the same conduction voltage as the LED. The
10k
8 9
zener diode is a little more robust that the
RT POL C6 LED and any errors during testing will be far
1µ less costly. Connect a standard red LED
GND together with a 180 Ω series resistor in paral-
lel with the zener diode so that you can get a
030212 - 17
visual indication that the circuit is driving the
LED with equal brightness at different input
Figure 7. Simple dimmer control. voltages.
All tests must be carried out initially using
a low voltage (12 V) input. If the circuit is
useful in some applications: The LED required and VCC is connected to powered from the mains it is important to be
can be switched on and off by a logic VDD. The logic threshold levels of aware that the chip will have lethal voltages
signal applied to the ENI input (gal- the ENI and POL inputs will also cor- on its pins and all appropriate safety guide-
vanically isolate this input logic sig- respond to this supply voltage (Fig- lines must be adhered to. Early tests using
nal via an optocoupler). The polarity ure 6). The circuit flashes an LED an isolated variable transformer to provide an
of the ENI signal can also be (not shown) at approximately two- adjustable input voltage were unsuccessful
inverted by changing the level on second intervals. The POL input is but a mains transformer with tapped secon-
the POL input. The HV9901 also con- used to invert the sense of the timer daries gave better results for test purposes.
tains an auxiliary voltage regulator output. In a similar manner a switch- If the input mains filter is not fitted it is
that can be used to power additional on or switch-off delay can be simply important to keep supply leads to the circuit
circuitry. Two resistors are used to implemented with some additional as short as possible.
program the auxiliary voltage in the logic gates. Light level detector cir- On the positive side the circuit does not
range from 2 V to 5.5 V the maximum cuits or PIR movement detectors can employ large reservoir capacitors on the high
output current is only 1 mA but this is also be powered from the HV9901. voltage side so once the ReLED is discon-
enough to power a couple of CMOS Resistors connected to the H/D nected from the mains supply any high volt-
chips or a CMOS 555 timer or even a input of the HV9901 are used to pro- ages lurking around the circuit will be quickly
low power microcontroller so that gram the relay pull-in and holding discharged.
many more applications can now be currents when the device is used to (030212-1)
realised using flashing lights or drive a relay coil but this feature can
timed light control etc. (Figure 5). also be used to implement a simple
External circuits can also be pow- dimmer when an LED is used in Web Pointer
ered from 9 V available from VDD, in place of the relay (Figure 7). HV9901 datasheet from:
this case the two resistors are not The HV9901 can also be used as www.supertex.com/pdf/datasheets/HV9901.pdf

The internet site for all professionals and hobbyists


actively engaged in electronics and computer technology

www.elektor-electronics.co.uk
1/2004 Elektor Electronics 39
AUDIO&VIDEO

OTL Headphone
Amplifier with ECC82 (12AU7)
An ‘iron-free’ valve amplifier
Design by H.-J Friedli, PhD

A headphone amplifier with outstanding sound quality can be built using


readily available modern components. Omitting the output transformer,
avoiding overall negative feedback and using good coupling capacitors
guarantees a highly linear frequency characteristic, while certain
construction methods yield low channel crosstalk.

Measured values (with filter)

Supply voltage: 187 V


THD+N: (1 mW / 600 Ω) 2.3 % (right channel)
1.86 % (left channel)
S/N: (1 mW / 600 Ω) >93 dB
>100 dBA
Filament supply ripple voltage: 30 mVpp
Total power consumption: 17 W

Valve experts know that even power valves that can


deliver several hundred milliampères of anode current can
never drive a loudspeaker with an impedance of 8 Ω,
since the internal resistance of a valve is several kiloohms.
The two impedances are thus almost always matched
using a transformer. In principle, there isn’t any objection
to using this form of impedance conversion, but every
transformer tends to degrade the sound quality. Keeping
this effect to a minimum requires very careful and com-
plicated coil winding techniques, good-quality trans-
former iron and large core cross-sections.
However, if the load impedance is not just a few ohms
but instead several hundred ohms, as is the case with
many types of headphones, and if in addition the required
power level is not overly high, an amplifier with no output
transformer — sometimes referred to as an ‘output trans-
formerless’ (OTL) amplifier — can be a feasible option. In
this case, the load is driven directly by the valve.
The OTL amplifier described here is a cathode follower

40 Elektor Electronics 1/2004


AUDIO&VIDEO
design suitable for use with a single R9 R10 R11 +200V
or dual headphone, with each head- +200V 33k 2k2 2k2
+200V R8
phone element having a rated K2 C5 C6

10k
impedance of at least 300 Ω. 10µ 400V 47µ 400V
6 V1.B

The circuit C2
7

The circuit shown in Figure 1 uses 1µ


400V 8
the readily available ECC82 double V1.A 1
C4
triode (equivalent to the North L
L C1
R6
American 12AU7) to provide amplifi- 2
470µ

330Ω
1M
R3 63V
cation. In Europe, ‘special quality’ 1µ
400V 3
R4
(SQ) versions of this valve with bet-
82k
ter specifications and longer service R1 R2 R5 R7
C3
life are also available under type

470Ω

1k8

4k7
1M
numbers E802CC and E82CC, 47µ 63V

respectively. R12 R13 R16 R18


A preamplifier stage is necessary C9

470Ω

4k7
1k8
1M
to generate signal amplitudes suffi- 47µ 63V
R15
cient to adequate drive a head-
82k
phone. The triode section with base 3 R17

330Ω
R14
pins 1, 2 and 3 is used for this pur- C7

1M
2 C10
470µ
pose. The input signal arrives at the R 1µ
circuit board via an external 50-kΩ 400V
63V R
V2.A 1
logarithmic potentiometer (P1, not 8
+12V6 V1 V2
shown in the schematic) that serves K1 C8
7
as a volume control, and it is directly 5 5
9 9 1µ
coupled to the preamplifier stage via 4 4
400V
6 V2.B
C1. R1 provides the necessary nega- R19
C11 C12
tive grid bias. The gain is essentially
10k

JP1
determined by R8, while the maxi- 10µ 400V 47µ 400V
R20 R21 R22
mum input voltage is determined by 33k 2k2 2k2
R2. R9 is dimensioned such that the +200V
V1, V2 = ECC82 020195 - 11
quiescent anode current is situated
in the most linear possible portion of
the characteristic curve. Figure 1. Schematic diagram of the amplifier using two ECC82 (12AU7) valves.
The inverted and amplified input
signal on the anode is coupled to F1
TR1 TR2
the grid of the second stage via C2.
100mA T
The cathode resistor of the second K1 C7 D7 D5 C5

stage is split into two resistors (R5


230V
12V

12V

and R6). The series resistance of R5 R1


and R6 forms the load resistance,
100k

+200V
C8 D8 D6 C6 K3
while the voltage division provided
R2
by the resistor pair allows the grid C13 C14
100k

12V 12V
4x 1N4007
bias to be set to the proper level. 16VA 10VA
4x 47n 275V X2 10n 47µ
The bias voltage is decoupled from 400V 400V
D10
the load and stabilised by R4 and
C3 before being applied to the grid.
The anode current flowing through POWER JP1
the triode, which depends on the IC1
C3 D3 D1 C1 LM2940CT-12
grid voltage and corresponding
characteristic curve, generates a
voltage across the combination of +12V6
K2
R5 and R6 that is exactly propor- C4 D4 D2 C2
tional to the current. This voltage is C9 C10 D9 C11 C12
in turn fed to the headphone via 4x 1N4002
2200µ 25V 220n 220n 10µ
coupling capacitor C4. R7 holds the 4x 47n 1N4148
63V
output at ground potential for DC
signals in order to avoid crackling 020195 - 12
noises when the headphone is
plugged in. Figure 2. Two mains transformers are used to generate the high voltage.

1/2004 Elektor Electronics 41


AUDIO&VIDEO
0 0 +200V

+12V6
COMPONENTS LIST K1 K2

H2
H3

(Amplifier) R22

JP1
R21
Resistors: R10 C5 R11 C11
C6 R20 C12

ROTKELE )C(
R9

1-591020
R1,R3,R12,R14 = 1MΩ

020195-1

R19
R2,R13 = 470Ω

R8
R4,R15 = 82kΩ V1 V2
R5,R16 = 1kΩ8
R6,R17 = 330Ω

R14
R15
R16
R17
R6
R5
R4
R3
R7,R18 = 4kΩ7

R12
R13
R2
R1
R8,R19 = 10kΩ
R9,R20 = 33kΩ
R10,R11,R21,R22 = 2kΩ2 C3 C9

Capacitors:
C1,C2,C7,C8 = 1µF 400V (MKP4 or MKS4, C2 C8
C1 C7
R7 R18
250V)
C4 C10
C3,C9 = 47µF 63V radial OUT1

T L T T R T OUT2

H4
H1

L R
C4,C10 = 470µF 63V radial
C5,C11 = 10µF 400V radial, e.g., Panasonic
ECA2GHG100n (Farnell # 219-9320)
C6,C12 = 47µF 400V radial (e.g., Conrad
Electronics # 475858)

Valves:
V1,V2 = ECC82 or 12UA7, with Noval (9-
way) socket (Chelmer Valve Corp.)

Miscellaneous:
JP1 = 2-way PCB pinheader with jumper
K1 = 2-way PCB terminal block, 5mm lead
pitch
K2 = 2- way PCB terminal block, 7.5mm
lead pitch

(C) ELEKTOR
020195-1
PCB, available from The PCBShop

Figure 3. Layout of the amplifier printed circuit board.

Power supply icon diode in the ground lead. are physically larger, which makes
The power supply for the headphone ampli- LED D10 not only serves as a pilot them better for audio purposes.
fier is shown in Figure 2. The high voltage is light, but also works together with For the large-volume electrolytic
generated using a standard mains trans- R1 and R2 to provide a minimum capacitors (C6 and C12), types with
former. The winding normally intended to be load and ensure that capacitor C14 lead spacings of 5 or 7.6 mm can be
used as a secondary winding is connected to is discharged, even if no load is con- used, or radial snap-in types with
the 12-V terminals of the actual mains trans- nected to K3. lead spacings of 10 mm. The latter
former. This results in an open-circuit voltage type of capacitor has a larger diam-
of around 200 VAC on the primary winding of eter and thus absorbs less heat from
the ‘reversed’ transformer, which serves as Layout the nearby valves. Low-inductance
the anode supply transformer. This AC volt- The layout of the printed circuit board electrolytic capacitors designed for
age is rectified and then smoothed by C14. for the amplifier, as shown in Fig- high-frequency switching applica-
The DC filament voltage is rectified by ure 3, is designed such that it is pos- tions should preferably be used, and
D5–D8 and then smoothed by C15. The sible to use not only ‘normal’ MKS4 in any case they must be specified
capacitors connected in parallel with the capacitors for C1, C2, C7 and C8, but for operation at 105 °C .
diodes suppress high-frequency noise gener- also coupling capacitors with lead Power is supplied to the individ-
ated by the diodes. A voltage of 12.6 V is gen- spacings of 15 or 22.5 mm, such as ual channels via the combination of
erated in a simple manner using an WIMA MKP4 types. These capacitors R10 and R11 or R21 and R22, respec-
LM2940CT12 (for low voltage drop) with a sil- have higher breakdown voltages and tively. These resistors dissipate

42 Elektor Electronics 1/2004


AUDIO&VIDEO
around 0.18–0.25 W, depending on
the supply voltage. Be sure to use
resistors with adequate power rat-
Anode voltage filter
ings. There are resistors available The circuit forms a power RC
R1
T1 filter that reduces the ripple
that can dissipate 0.3–0.4 W with the

1M
BUZ41A
component of an unstabilised
same package size (such as 1/4-W supply voltage. Naturally, this
K1 K2
metal film resistors), and the PR01 results in a voltage drop of a
series from BC Components can even C2 D1 few volts. Here a MOSFET suit-
handle 1 W. In any case, it won’t do 10n 10V
able for use with high voltages
any harm to fit these four resistors 400V C1 1W3 C3 (a BUZ41A, rated at
well clear of the circuit board in order 500 V / 4.5 A) is wired as a sim-
47µ 10n
to improve their cooling. 400V 400V ple source follower. The gate is
In the circuit board layout, atten-
020195 - 13 very slowly brought up to the
tion has also been given to keeping desired voltage via the R1/C1
network. It takes four minutes (five RC time constants) for the output voltage to reach
the signal paths of the two stereo
99 percent of its nominal value. As the valves also take a while to warm up, this delay does
channels as widely separated as not matter. The effect of using the filter can be clearly seen in Curve B.
possible. The connections between The voltage drop across T1 is primarily determined by the gate–source cutoff voltage
the ground terminals of the four and is approximately 3.5–4 V. The gate is protected against excess voltages by Zener diode
anode decoupling capacitors and the D1. C2 and C3 are necessary to eliminate the tendency of the circuit to oscillate. No circuit
common ground point are routed board layout has been designed for the filter circuit, but it can easily be built on a small piece
separately for each channel. Inci- of prototyping board. The filter dramatically reduces the amplitude of the ripple voltage.
dentally, there is one wire bridge on
the amplifier board (between C5/C11
and C1/C7).
The power supply circuit is voltage. For a transformer with a formers is that the high voltage is isolated
housed on a second printed circuit nominal secondary voltage of 9 V, from the filament voltage. Nevertheless, the
board, to which the amplifier board this can easily be 12 V. two ground potentials must be intercon-
can be attached in sandwich fash- To balance out the reactive nected. This can be done on the amplifier
ion. However, the amplifier is some- power, an X1-type capacitor rated at board and/or on the power supply board
what sensitive to the stray fields around 150 nF / 250 V can be con- (JP1).
emanated by the transformers, nected across the secondary wind-
whose magnitude depends on the ing of TR2. This will cause the anode
type of transformer used. The 50-Hz voltage to actually increase slightly, Construction
components in the frequency spec- but the mains power consumption Fitting the components to the circuit boards
trum (see measurement curves A and current will decrease by around should not present any problems. All com-
and B) clearly indicate the presence 6–7 percent. ponents are fitted on the ‘normal’ compo-
of the two transformers, which were An advantage of using two trans- nent side.
located at distance of 20 cm. Diodes
D1–D4 are ‘solid’ 1N4002 types, but
there is enough room for even more
robust types. Capacitors C5–C8,
which have a lead spacing of 15 mm,
must be X2 types.
If you want to fully eliminate any
ripple in the filament voltage, you
can use a 15 V / 20 VA transformer
for TR1. As this is a slightly larger
type, it will not fit on the circuit
board. Although the dissipation of
IC1 will increase in this case, the
specified heat sink is fully adequate.
We also tried using a 15 V / 16 VA
transformer, but it drew 23 VA from
the mains (significantly overloaded).
You are welcome to experiment with
various transformers; a wide variety
of results may be obtained, depend-
ing on the transformer type, open-
circuit voltage, loaded voltage, core
size, and material. The winding ratio
is always determined by the design
value of the open-circuit secondary

1/2004 Elektor Electronics 43


AUDIO&VIDEO
The voltage regulator requires a heat sink. externally, which leaves consider- the controls and connectors.
Its cooling tab is connected to its middle lead, able room for personal choice in The circuit board layout (Figure 3)
which is 0.6 V above ground potential in this selecting an enclosure and arranging has been kept highly symmetric with
circuit due to the diode.
As everybody knows, the electrolytic
capacitors must be fitted with the correct 0
+200V

IC1
polarity. However, it is also necessary to

H2
H3

observe the proper polarity when fitting the SK104 C11


D9 C12

C14
four 1-µF capacitors. As the grid terminal is

C10
0 +12V6 K2 K3
the most sensitive point in a valve circuit, it
D2 D4 JP1
must be connected to the inner foil of the C13 R2
C1 C3
C2 C4 C7 C5 R1 C6
capacitor. The outer foil, which is sometimes D1 D3 C8
marked by a stripe, then has a screening
D10
effect. C9

D7

D8
H7

D5

D6
The Cinch sockets, potentiometer, phone
socket and mains switch must be wired TR1

COMPONENTS LIST
(Power supply) 2-591020
ROTKELE )C(
Resistors: H5 H6

R1,R2 = 100kΩ

020195-2
Capacitors:
C1-C4 = 47nF ceramic
C5-C8 = 47nF 275 VAC, Class X2, lead
100mA T

pitch 15mm
C9 = 2200µF 25V radial TR2
F1

C10,C11 = 220nF K1
C12 = 10µF 63V radial ~ ~

H4
H1

C13 = 10nF 400V, lead pitch 7.5mm or


10mm
C14 = 47µF 400V radial (BC Components
# 22215266109, Farnell # 322-7984)
(BC Components # 22215266479, Farnell
# 322-8009)
Panasonic ECA2GHG470 (e.g., Farnell #
319-9356)

Semiconductors:
D1-D4 = 1N4002
D5-D8 = 1N4007
D9 = LED red, low current
IC1 = LM2940CT-12 with heatsink, Fischer (C) ELEKTOR

type SK104 (50.8 mm) 020195-2

Miscellaneous:
JP1 = 2-way PCB pinheader with jumper
K1,K3 = 2-way PCB terminal block, lead
pitch 7.5mm
K2 = 2- way PCB terminal block, lead pitch
5mm
F1 = fuse, 100mAT (slow), with PCB mount
holder
TR1 = mains transformer 12V / 16VA (ERA
BV054-5383.0K (Conrad Electronics #
506575)
TR2 = mains transformer 12V /10VA (ERA
BV048-5383.0H (Conrad Electronics #
506478)
PCB, available from The PCBShop

Figure 4. The power supply printed circuit board can be fitted to the amplifier board ‘sandwich’ fashion.

44 Elektor Electronics 1/2004


AUDIO&VIDEO

Curves and sound


Curve A shows the frequency spectrum of a 1-kHz signal (1 mW into 600 Ω). +0

-10
The distortion components (right channel) amount to 2.3 percent, but this is -20

primarily due to the second harmonic. Besides this, an enormous effect can -30

be seen from the ripple voltage of the unstabilised anode voltage supply. To -40

-50
remedy this, we developed an active filter (see box) that almost fully sup- -60

presses the 100-Hz component and its harmonics. The results obtained using d
B
r
-70

this filter can be seen in Curve B. The third curve, C, shows the distortion as A -80

-90
a function of output power. The distortion level increases quite linearly with -100

the output power level. The amplifier ‘runs out of room’ at around 5 mW. -110

It’s almost impossible to describe the performance of a piece of audio -120

-130
equipment using bare figures alone. The most noticeable aspect of the -140

sound is dynamic range: what is supposed to be loud is loud, and what is -150
20 50 100 200 500 1k 2k 5k 10k 20k

supposed to be soft is soft. The sound is warm and spacious, and although it Hz 020195 - 14

is perhaps slightly lacking in clarity of detailing at the upper edge of the fre- Measurement curve A. Frequency spectrum without a
quency spectrum for high volume levels, this by no means reduces the pre-filter for the anode voltage.
enjoyment of opera voices. The sound is very pleasant and remains so
during
extended lis- +0 100

-10
tening. Low -20
50

tones do not -30 20

present any -40


10
-50
problems, and -60
5

it is certainly d
B -70
r %
2
quite enjoy- A -80
-90 1
able to listen -100
0.5
to music with -110

strong bass -120 0.2

-130
components, -140
0.1

such as rock, -150


20 50 100 200 500 1k 2k 5k 10k 20k
0.06
1u 2u 5u 10u 20u 50u 100u 200u 500u 1m 2m 5m 10m

pop and jazz. Hz 020195 - 15 W 020195 - 16

Measurement curve B. Using a filter provides a clear Measurement curve C. The distortion level increases
benefit, with significantly reduced 100-Hz components. linearly with output amplitude.

regard to its visual aspect, so there as possible from the signal inputs. If heard if the Cinch sockets are open and the
is no reason not to use an enclosure the transformers are too close to the volume control is turned up full.
design featuring a visible circuit inputs, a typical 50-Hz hum will be (020195-1)
board with its valves and other com-
ponents. If you would rather conceal
the circuit board but still wish to
have the valves visible, you should
etch the circuit board using a mirror
image of the layout. In this case, the
tube sockets are fitted to the copper
side of the board, with all other com-
ponents being mounted in the usual
manner so they face downward after
the board is fitted in the enclosure.
All polarisations remain the same.
All 230-V wiring must be made
using wire with sufficiently thick
insulation. It is essential to apply
additional insulation to the solder
points and fit an insulating sheet
between the mounting panel and
the undersides of the transformers.
You must also provide for good ven-
tilation. A double-pole on/off switch
must be fitted in series with the 230-
volt wiring. The transformers should
be fitted in the enclosure as far away

1/2004 Elektor Electronics 45


READERSCIRCUITS

Burglar Alarm
With individual sensor signalling
Design by E. Martens

This is a circuit of a simple but effective burglar alarm, which shows the
status of each sensor with a separate LED. This allows you to see at a
glance whether any doors or windows aren’t closed properly before
switching the alarm on.

microcontroller provides all the func- when the alarm is armed and after
Main Specifications tionality of the burglar alarm. It also the exit-delay has expired, the entry-
– Maximum number of sensors that can be takes care of (software) filtering of delay (60 seconds) will begin. Under
connected: 8 the signals at the inputs. Only after normal circumstances, the alarm will
– Monitoring and signalling of each sensor an input has remained unchanged be deactivated with key switch S1
for activation and cable continuity for 30 milliseconds, is this new sig- during the entry-delay. In the event
– Tamper input nal level passed on for processing by of a burglary, the alarm will trigger
– Panic pushbutton the microcontroller program. after the entry-delay has expired.
– Exit delay: 60 seconds The schematic for the burglar The entry-delay can only be inter-
– Entry delay: 60 seconds alarm (Figure 1) is simplicity itself rupted by switching the alarm off
– Power supply: 230 VAC or backup battery
and only a small number of compo- with key switch S1.
– LEDs indicate:
nents are required. The special ‘panic button’ S2, can
- alarm armed
be used for those situations — what-
- alarm activated
ever the reason may be — that
- tampering Sensors require the alarm signal to be acti-
- backup battery active
– Outputs: 2 (12 VDC, 500 mA) A maximum of 8 sensors can be con- vated. The alarm signal will be acti-
– Alarm duration: 60 seconds nected to the burglar alarm. These vated immediately, independent of
can be found along the left side of the armed or disarmed status of the
Figure 1. These sensors need to burglar alarm. The alarm will be
have their contacts closed when in silenced after 60 seconds or after
Please note: Readers Circuits have not been tested or the inactive state (i.e. Normally pressing the panic button again.
post-engineered by the Elektor Electronics design laboratory.
Closed). In addition, each sensor
needs to have its tamper connection
This article describes a design of a burglar wired as well. A power supply volt- Sabotage
alarm that can monitor up to eight sensors. age of +12 VDC is available for each The purpose of tamper input K11 is
The status of each individual sensor is indi- sensor at the corresponding wiring to detect tampering attempts when
cated with an LED. This LED shows whether terminals (K3 through K10). the alarm is armed. Possible scenar-
the sensor has been activated and whether ios are opening of the burglar alarm
the wiring to the sensor is in order. enclosure, the cutting of cables, etc.
Obviously, this burglar alarm also has an Operation The tamper input needs to be nor-
input to ‘arm’ the alarm, a tamper input and The alarm is switched on by opening mally closed (NC). A number of NC-
a couple of outputs to control a siren and/or a key switch S1, at which point the so- contacts and wires can be con-
strobe light. The alarm is also fitted with a so- called ‘exit-delay’ begins. This time nected in series (the cables to the
called ‘panic button’. delay (60 seconds) allows you to alarm sensors, for example).
leave the protected area without
triggering the alarm. The alarm is
Circuit description deactivated when key switch S1 is Signalling
The burglar alarm is built around the closed. Eight LEDs (D10 through D17) indi-
AT89C51 microcontroller from Atmel. This If a sensor contact is opened cate the status of the corresponding

46 Elektor Electronics 1/2004


READERSCIRCUITS
DC output X
12Vdc max 500mA
+
100N -
10uF T1
10K

green
green
10K

10K

10K

10K

green
green
10K

green

green
10K

green
10K

10K

10K

10K
10K

10K
10K

10K

green
green
10K
C6 63V K12

red

red
red
red
C5
D10 D11 D12 D13 D14 D15 D16 D17 D18 D19 D20 D21 D22

R21
R14

R18

R20
R15

R19
R12
R10

R13

R17
R16
R11
R6

R8
R9
R7

IC3 BUZ11
40
R22 R23 R24 R25 R26 R27 R28 R29 R30 R31 R32 R33 R34
9 Vcc 31
alarm R5 RST EA

3K3
1K
1K
1K

1K
1K

1K
1K
1K

1K
DC output Y

1K

1K
1K
sensor 0

tamper

8K25
12 Vdc max 500mA

power
alarm active

sabotage

battery powered
sensor 1

sensor 3
sensor 0

sensor 7
sensor 5
sensor 2

armed
sensor 6
+12Vdc

sensor 4
+
0V -
AT89C51 T2
K13
alarm
1 39
sensor 1

tamper P10 P00


2 38
3
P11 P01 37 BUZ11
+12Vdc P12 P02
4 36
P13 P03
0V 5 35
6
P14 P04 34
P15 P05
alarm 7 33
P16 P06
8 32
sensor 2

tamper P17 P07


+12Vdc 28 1N4001
P27 27
P26 26
D9
0V 10 P25
P30
11
P31 25
alarm 12 P24
P32 24
sensor 3

tamper 13 P23
14
P33
P34
+12Vdc 15 R2 R3 R4
P35
16
P36
0V 17
P37 DIV1

10K
10K

10K
alarm 30 D7 IC2
ALE/P TR1 D1-D4
sensor 4

tamper 29 23 7812 7805


PSEN P22
22
+12Vdc P21 F1
21 K11 IC1 1N4001
P20 S2 315mA
19 C2 C3
0V XTAL1

1K
R1
12 MHz 18 10uF 10uF
XTAL2 330N 100N
alarm C1 63V 63V
panic
arm

GND
sensor 5

sabotage
tamper S1
230V

1N4001
D5 D6

1N4001
X1 20
+12Vdc 470uF D8 C4 C5
C7 C8 K1 15Vac 4x1N4001 63V 1N4001
0V
33pF 33pF +
12Vdc
alarm -
sensor 6

tamper
BT1 K2
+12Vdc

0V

alarm
tamper
sensor 7

+12Vdc

0V 020422 - 11
K3-K10

Figure 1. The alarm consists mainly of a microcontroller, a number of sensor inputs and a set of indicator LEDs.

sensors. When the alarm has been Outputs age is subsequently reduced to about 12 V
activated, the LED of the sensor that by diode D7. Voltage regulator IC2 in turn
caused the alarm will light up, or The burglar alarm is provided, from changes this 12 V into a stabilised 5 V power
flash in the event of a cable failure. the viewpoint of reliability, with two supply voltage.
When the alarm is armed, the separate outputs (K12 and K13). Both In the event that the mains voltage at K1
LED ‘alarm armed’ (D18) will flash outputs are controlled by a BUZ11 disappears, the 12-V lead-acid battery con-
during the exit-delay. After the exit- (T1 and T2) and can switch up to nected to K2 will immediately take over the
delay, the LED will light continu- 500 mA at 12 V. This is more than power supply for the circuit. The battery is
ously. D18 turns off, of course, when enough for all common signal sources continually being charged via resistor R1 and
the alarm is disarmed. such as strobe lights and sirens. If diode D6, when the mains voltage is present.
The LED ‘alarm triggered’ (D19) more power is required or a signal D7 and D8 prevent the charging current from
flashes during the entry-delay and source with a different voltage needs flowing in the wrong direction.
will turn on continuously once an to be controlled, then a 12-V relay can
actual alarm has been generated. be connected directly to the alarm
D19 turns off only when the alarm is output and it in turn can then switch Software
switched off with key switch S1. the signal source on and off. The software that is required for the alarm is
When an alarm has taken place, it of a relatively simple design. The flow chart
can be determined afterwards shown in Figure 2 illustrates this. This really
which sensor (or tamper input) Power supply shows a kind of logical summary of all the
caused the alarm to trigger. The circuit is provided with its own things that have been described above.
The LED ‘tamper’ (D20) lights up mains power supply. It follows the After the reset-phase of the microcon-
when the tamper input (K11) is usual design of transformer, bridge troller, all the LEDs are switched on for a
opened. This LED will also continue rectifier (D1 through D4) and filter period of two seconds. This allows for a quick
to be on until the alarm is switched capacitor (C1) and generates an lamp test to check if all the LEDs are func-
off. input voltage of about 18 V for volt- tional and are connected correctly.
Finally, the LED ‘battery opera- age regulator IC1. With the addition In the source code for the software, the
tion’ (D22) indicates that lead-acid of diode D5 in the ground connec- values for the various timers can easily be
battery BT1 has taken over the tion, the output voltage if IC1 adjusted to suit your own requirements. It
power supply for the burglar alarm. amounts to about 12.65 V. This volt- concerns the following timers:

1/2004 Elektor Electronics 47


READERSCIRCUITS
Construction perils
PANIC
button pressed?
YES panic period NO
activate panic period
It is recommended to build the bur-
active?
glar alarm into two separate enclo-
NO YES sures, as illustrated in the sketch of
Figure 3.
panic period YES
panic timer YES
The larger enclosure contains the
elapsed? end panic period
active? (>60 seconds) more important part of the circuit,
NO NO
including the power supply and
lead-acid battery, but excluding the
YES
alarm timer
YES
controls and indicators. This enclo-
alarm period elapsed? end alarm period
active? (>60 seconds?) sure needs to be mounted in a place
that is relatively difficult to access.
NO NO
This enclosure actually has only
alarm cables going in and out of it. When
ALARM YES switched on for YES
switch on? <60 seconds? building the mains power supply,
keep the relevant safety require-
NO NO
NO
ments in mind and provide sufficient
isolation and a good strain relief
end alarm period entry period
alarm contact NO NO
end entry period open?
elapsed
(<20 seconds?) NO
tamper contact
open?
sabotage contact
open?
(grommet) for the mains cable.
The enclosure for the LEDs and
YES YES YES YES
switches needs to be mounted in an
easily accessible place, of course.
alarm period
NO
or panic period activate entry period activate alarm period Because of the way the circuit is
active?
designed, damaging this enclosure
YES will have no influence on the correct
operation of the burglar alarm (the
activate outputs
key switch to operate the alarm is
020422 - 12
normally closed). It is also recom-
mended to include this enclosure in
the tamper circuit.
Figure 2. This flowchart makes it obvious how the software has been designed. To prevent the burglar alarm from
being easily circumvented without
this being detected, it is necessary
timer variable default (s) Incidentally, the software for the bur- that the cables to the sensors are
panic timer PANVAL 60
glar alarm (ref. no. 020422-11) can be located in such a way that they are
exit-delay timer UITVAL 60
entry-delay timer INLVAL 60 downloaded free of charge from difficult to access. These cables can
output X active ALXVAL 60 the www.elektor-electronics.co.uk also be included in the tamper cir-
output Y active ALYVAL 60 website. cuit.
A practical application of the tam-
per circuit is shown in Figure 3. A
switch (normally closed) is also
+ +
included in the tamper loop. This
- - output X switch needs to open in the event
that the enclosure is opened or van-
PCB output Y
siren
dalised.
lead-acid If not all sensor inputs are being
battery signal lamp
sabotage used, the alarm contact and tamper
contact of each unused sensor needs
to be shorted out.
(020422-1)
sabotage loop

CONTROL
&
INDICATORS
020422- 13

Figure 3. A practical implementation of the burglar alarm separates the control and indication
from the other parts.

48 Elektor Electronics 1/2004


MINIPROJECT

Relaxation Machine
A servo-powered pendulum
Design by B. Kainka

It is a generally known and accepted fact that servos used in radio-


controlled models see very little or no use outside the model flying, racing
or boating season. A pity, considering these devices can be used for many
useful tasks…

For example, a servo that’s not used anyway of about 0.25 Hz which corresponds trolled, while the ‘space’ length is
could be attached to a large pendulum of to one full period in four seconds. not affected.
which the smooth and steady motion may The sinewave generator employs a A PCB was designed for the Relax-
help people relax and even fall asleep. For phase shifting network and supplies ation machine (see Figure 2). Like all
this (psychological) effect to be achieved the a sinewave with very low distortion. PCB designs that appear in this mag-
movement has to be sine-shaped like that of a If you want to lengthen the period, azine the artwork files to enable you
real and very long pendulum. simply increase the value of C1, C2 to make your own board may be
The small circuit of the Relaxation and C3 a little. found among this month’s Free
Machine you find in Figure 1 consists of two The generator drives the control Downloads on the Publisher’s web-
parts. A pulse generator based on a 555 sup- input of timer component IC1 via an site at www.elektor-electronics.co.uk.
plies positive pulses with a length between electrolytic capacitor. IC1, by the With the board available, the cir-
1 and 2 ms (‘mark’) and a pause of 20 ms way, should be a 7555, 555C or cuit should be easy to build up. All
(‘space’), representing a typical servo control another CMOS version of the 555. you need to do is follow the parts list
signal. In addition there’s a sinewave gener- The generator drive scheme ensures and the components mounting plan.
ator designed to supply a very low frequency that the timer ‘mark’ duration is con- There is one wire link on the board

50 Elektor Electronics 1/2004


MINIPROJECT
BC547 10mA +4V8
directions without hitting any of the stops. If
BC548 the elongation (the distance the between a
BC549
BC550
R1
C6
R8 moving body and the point of origin) is too

1k
15k

small or too large, you may need to experi-


220µ 10V
ment a little with the value of R1. If you make
D1
1V...1V75
the resistors too small (<10 kΩ) then the
R6
R2
T2
1N4148
oscillator will no longer oscillate. Capacitor

10k
C E 1.2 ...1.7 ms
B
100k C4, too, has an effect on the amplitude.
4V8
0V2...3V
C1
BC549C 4 8 The current consumption of the circuit is
P1
22µ 10V 7
R 0V of the order of 10 mA excluding the servo.
4s DIS 16 ms
0V5...1V4 The 3-way pinheader in position K1 will
10k IC1
0V6 0V8 3V...3V5
6
THR K1 allow most servos to be connected up easily.
3
T1 R3 R4 C4 OUT If you are using a ‘less than standard’ servo,
5
CV
100k 100k
555 then a small adapter may be required. The
220µ
BC549C 10V 2
TR
connections of a couple of well-known servos
R5 R7 are shown in Figure 3.
C2 C3 C5
Using our circuit, a correctly connected
1k

1
220k

22µ 22µ servo will turn slowly, describing a pure


10V 10V 100n
sinewave, its period being about equal to
16 ms
010129 - 11 that of a pendulum with a length of four
1V5...3V5
metres (!). Of course, you may also attach a
smaller pendulum, a painted carton board or
another ingenuous creation to the servo spin-
Figure 1. Circuit diagram of the Relaxation Machine. dle, provided is not too large or heavy
(because of the mechanical load on the
servo).
The swinging pendulum has a relaxing
effect, while the sound of the servo motor at
H1

H3
R6

R8
D1

P1 such a low speed is not unlike snoring.


ROTKELE )C(

010129-1 (C) ELEKTOR


K1

C5
Warning
R7

IC1
This circuit should not be used on (or by) per-
1-921010

C6 sons with an epileptic or narcoleptic condi-


C2
+ tion or subject to easy hypnosis.
R5

C4
R1

0 (010129-1)
010129-1

T2
T1 R2
R4

R3
H4

H2

C1 C3 COMPONENTS LIST
Resistors:
Figure 2. PCB design. R1 = 15kΩ
R2,R3,R4 = 100kΩ
R5, R8 = 1kΩ
Graupner R6 = 10kΩ
Conrad Futaba Multiplex Robbe Microprop Simprop
/JR R7 = 220 kΩ
P1 = 10kΩ preset

Capacitors:
C1,C2,C3 = 22µF 10V
000160-13
C4, C6 = 220µF 10V
C5 = 100nF
Figure 3. Servo pinouts.
Semiconductors:
D1 = 1N4148
T1, T2 = BC 549C
which should not be forgotten. The this means that C suffix devices will
IC1 = 555C or 7555 (CMOS)
link is best made using thin isolated work best, i.e., the hfe should exceed
wire because it runs dangerously about 300. Suggested types include Miscellaneous:
close to the pins of IC1. the BC547C, BC548C, BC549C and K1 = 3-way pinheader
Positions T1 and T2 can take BC550C. 2 solder pins
almost any NPN transistors with a Preset P1 is adjusted until the PCB, available from The PCBShop
sufficiently high gain. In most cases, servo covers the full motion in both

1/2004 Elektor Electronics 51


GENERALINTEREST

LED Roulette
using LEDs instead of a ball
Design by P. Goossens

Everybody gambles sometimes, perhaps in a lottery or even in a casino. After


all, who doesn’t dream of becoming rich without having to work hard?
Although you can’t win much with the LED roulette wheel described here, it
does provide an excellent opportunity to practice the game of roulette at
home in an honest manner. That’s because you can’t cheat with this version
— the microcontroller that controls the LEDs doesn’t take bribes!

Roulette
In the game of roulette, a random
number is chosen for each round
using a dished, spinning wheel
within which a small ball circulates
in the opposite direction. The ball
ultimately lands in one of 37 com-
partments (numbered 1–36 and 0),
with each compartment having a
colour (black, red or green). The play-
ers can bet on the number, colour,
etc, of the compartment where the
ball ends up.
Roulette is not played very often
at home, since it requires a proper
roulette wheel. Any irregularity in
the construction of the wheel will
distort the probabilities and thus
make the game unfair. A good
roulette wheel is not cheap, and it
also takes up a lot of space. An elec-
tronic version provides a solution to
these problems: it doesn’t cost a lot
and it doesn’t take up much space.

Implementation
In this circuit, the circulation of the
ball is simulated by a number of
The game of roulette has been known for cen- turntable, which is the dished wheel LEDs arranged in a circle.
turies, and it is played all over the world. In used with a small ball to select a ran- Our electronic wheel has more to
order to make it easier to play this game at dom number for each round of the offer than just a simulation of a cir-
home, here we a present an electronic roulette game. You will have to make the play- culating ball. As anyone who has
game. This electronic version only replaces the ing field and the counters yourself. ever visited a casino knows, at first

52 Elektor Electronics 1/2004


GENERALINTEREST
the ball rolls quite smoothly over the
IC2
surface of the wheel when it is spun. 11
+5V
C1
But after the ball has lost speed and 1
EN
IC7
hits one of the compartment walls, it 7805 +5V
D0 3 2 D1 R1
starts jumping all over the place. Our D1 4
1D
5 D2
1k
R2
1k
wheel shows the same characteris- K1 D2 7 6 D3
1k
R3
C9 C10 C11
+9V
tics, but if you would rather have the 0V
D3 8 9 D4
1k
R4

100n 100n 100µ D4 13 12 D5 R5


ball exhibit a ‘wheel of fortune’ type D5 14 15 D6
1k
R6
1k
of behaviour, you can configure the D6 17 16 D7
1k
R7
D7 18 19 D8 R8
circuit for this using a switch. 1k

74HCT373
IC3
Another nice feature of our 11
C1
‘wheel’ is that as soon as the ball 1
EN

has stopped, the circuit automati-


D0 3 2 D9 R9
cally indicates whether the present D1 4
1D
5 D10
1k
R10
1k
number is higher or lower than the D2 7 6 D11
1k
R11
+5V D3 8 9 D12 R12
previous number. This means that in D4 13 12 D13
1k
R13
1k
addition to the usual manners of D5 14 15 D14
1k
R14

playing roulette, you can also bet on R42 R43


D6 17 16 D15
1k
R15
D7 18 19 D16 R16
whether the next number will be C12 C3 1k

10k
10k
74HCT373
higher or lower than the current 1µ 16V 100n IC4
number. 11
C1
20 1
EN
R41 1
RST
Schematic diagram
10k

12 D0 D0 3 2 D17 R17
P1.0 1D 1k
2 IC1 13 D1 D1 4 5 D18 R18
P3.0 P1.1 1k
Figure 1 shows the schematic dia- 3
P3.1 P1.2
14 D2 D2 7 6 D19
1k
R19
6 15 D3 D3 8 9 D20 R20
P3.2 P1.3
gram of the roulette wheel. As is 7 16 D4 D4 13 12 D21
1k
R21
P3.3 P1.4 1k
common nowadays with relatively 8
P3.4 P1.5
17 D5 D5 14 15 D22
1k
R22
9 18 D6 D6 17 16 D23 R23
complex digital circuits, it is based P3.5 P1.6
19 D7 D7 18 19 D24
1k
R24
AT89C2051 P1.7 1k
on a microcontroller. 11
P3.7 74HCT373
In this case the microcontroller is X1 X2 IC5
10 5 4
an AT89C2051 (IC1), which requires X1
11
C1
1
only a small number of external com- S1 S2 EN

ponents. C12 and R41 generate a C2 12MHz C1 D0 3 2 D25 R25


1D 1k
reset signal when the supply voltage D1 4 5 D26
1k
R26
22p 22p
D2 7 6 D27 R27
is switched on. X1, C1 and C2 ensure D3 8 9 D28
1k
R28
1k
that the internal oscillator of IC1 D4 13 12 D29
1k
R29
D5 14 15 D30 R30
generates a 12-MHz clock signal. 1k
D6 17 16 D31 R31
1k
The user controls are provided by a D7 18 19 D32 R32
1k
regular switch and a push-button 74HCT373
switch (S2 and S1), each of which is IC6
11
directly connected to an I/O pin of 1
C1
EN
the microcontroller. +5V
D0 3 2 D33 R33
1D 1k
The visual representation of the D1 4 5 D34
1k
R34
D2 7 6 D35 R35
simulated ball is provided by 40 D3 8 9 D36
1k
R36
20 C4 20 C5 20 C6 20 C7 20 C8 1k
LEDs (D1–D40), with each LED hav- IC2 IC3 IC4 IC5 IC6
D4 13 12 D37
1k
R37

100n 100n 100n 100n 100n D5 14 15 D38 R38


ing its own series resistor (R1–R40). 10 10 10 10 10
D6 17 16 D39
1k
R39
1k
The LEDs are driven by 8-bit latches D7 18 19 D40
1k
R40

(IC2–IC6). 030168 - 11 74HCT373


LEDs D1–D37 are arranged in a cir-
cle, and they represent the various
compartments of the wheel. LED Figure 1. The schematic diagram of the roulette circuit: 40 LEDs controlled by a
D38 indicates that the value of the microcontroller.
most recent spin is higher than that
of the previous spin. By contrast,
LED D40 indicates that the value of battery, whose voltage is reduced to Resistors R42 and R43 are present
the most recent spin is lower than 5 V by IC7 to meet the demands of because P1.0 and P1.1 are the only I/O pins
that of the previous spin. LED D39 the digital components. Naturally, of the AT89C2051 that do not have internal
lights up as soon as the ‘ball’ stops the necessary buffer capacitors and pull-up resistors. This allows these two ports
moving. decoupling capacitors are also pre- to double as analogue inputs. However, in
The circuit is powered by a 9-V sent in the circuit. this circuit pull-up resistors are needed for all

1/2004 Elektor Electronics 53


GENERALINTEREST
030168-1 1-861030
(c) ELEKTOR ROTKELE )c(
HOEK3
HOEK4

R29

D29
R28

D30

D28
D31

D 27

R38
R30
17 34 6 R27

2
D3
27

6
25

D2
3
13

D3
R31 R26
2

5
D2
C4
D3 36
R32 4 21 C3
IC5 4 R25
11 D2

R39
R33 D3 4 R24
5
30 D2
3
R34 19 R23
D36 8

IC6
R35 C6
IC4 D22 R22
15
R36 D37 23 R21
D21
32 D38
R37 R20
D1 C7 10
R41 IC1 D20
R1 0 C5
R19
C12 5 D39
R2 D2 X1 R43 R18
26 D19 D40
R42
R3
D3
C1 C2 24 R17
K1
S1
3 D18
IC2

R4 R16 +9V
16

R40
C8 S2 0V
R5 D4 35 D17 R15 C9
IC3 33
IC7
R6 D5 12 D1 R14
1 6
R7 28 D1 R13
20
D6

5
R8 7 14 4 R12
D7

29 31 D1 C11
18 22
3

9
D8

D1

R9 R11
D 12
D9

D10

D11

C10

HOEK1
HOEK2

R10

(c) ELEKTOR
030168-1

Figure 2. The double-sided printed circuit board holds the entire circuit except for the 9-V battery.

bits of port 1, so R42 and R43 have been Construction electronic roulette game. A double-
added to ensure that a well-defined ‘high’ sided printed circuit board is used
signal is also present on bits 0 and 1 when Figure 2 shows the printed circuit here, because otherwise too many
their outputs are not low. board that has been designed for the wire bridges would be needed to

54 Elektor Electronics 1/2004


GENERALINTEREST

COMPONENTS LIST D3,D5,D7,D9,D11,D13,D15,D17, Conclusion


D19,D21,D23,D25,D27,D29,D31,
Resistors: D33,D35,D37 = LED, 3mm, red, The software for the AT89C2051 was written
R1-R40 = 1kΩ low current in C and compiled using the Keil C51 com-
R41-R43 = 10kΩ IC1 = 89C2051-12PC, programmed, piler, for which (as you probably know) an
order code 030168-41 evaluation version is available free of charge
Capacitors: IC2-IC6 = 74HCT373 (http://www.keil.com/demo/eval/c51.htm). As
C1,C2 = 22pF IC7 = 7805CP (TO-220 case) the source and hex code are available from
C3-C10 = 100nF the Elektor Electronics website under num-
C11 = 10µF 16V radial Miscellaneous: ber 030168-11 (and naturally on diskette as
C12 = 1µF 16V radial K1 = 9V battery with clip and on/off well), you can adapt the program to your own
switch (optional) wishes if so desired. To do this, in addition to
Semiconductors: S1 = pushbutton with make contact the compiler you will need to have a certain
D1,D38,D40 = LED, 3mm, green, S2 = on/off switch
knowledge of the C programming language
low current X1 = 12MHz quartz crystal
and a programmer for the AT89C2051.
D2,D4,D6,D8,D10,D12,D14,D16, PCB, order code 030168-1
Disk, contains source and hex code
If you have no desire to modify the pro-
D18,D20,D22,D24,D26,D28,D30,
D32,D34,D36,D39 = LED, 3mm, files, order code 030168-11 or Free gram or do your own device programming,
yellow, low current Download you can simply purchase a pre-programmed
version from Readers Services (order number
030168-41).
(030168-1)
allow the LEDs to be arranged in a If desired, all of the LEDs can be
nice circle. fitted on the solder side of the board,
Little needs to be said about but that naturally depends on what
building the board. Just solder sort of enclosure you plan to use.
everything where it’s supposed to
be and you’re all set. Of course, you
The switches can also be con-
nected to the board using lengths of
Free Downloads
must pay attention to the correct wire, so they can be fitted at the Microcontroller software.
File number: 030168-11.zip
polarisation of the LEDs, ICs and side of the enclosure if so desired.
PCB layout in PDF format.
electrolytic capacitors. Sockets can You can also fit an on/off switch at File number: 030168-1.zip
be used for the ICs, but they are not the side of the enclosure and con- www.elektor-electronics.co.uk/dl/dl.htm,
necessary if you have a certain nect it in series with the battery select month of publication.
amount experience with soldering. connector (K1).

1/2004 Elektor Electronics 55


GENERALINTEREST

The Sense Resistor


in step-up converters
By K.-J. Thiesler

Sense resistors in series with the load are central to regulating current in
switch-mode power supplies. It is possible to optimise the power loss in
these resistors, as we show with an example converter circuit that drives
eight white LEDs from a 4.8 V battery.

L1 D2
Switch-mode regulator ICs generally include K1 BZV55C6V2 BZV55C24V 2 x 4 white LEDs
10µH
a reference voltage generator and a differen- SS24 K3 K5
D1 J2 D3
tial amplifier. This combination is used to BAT 1 C1 C2

compare the voltage dropped across an exter-


100n 100n
nal sense resistor with the reference and then D4 D8
suitably drive the output stage. The voltage IC1
5 1
D5 D9
drop across the resistor must be of the same PWM IN
VIN SW

order of magnitude as the reference, which in K7 4 TPS61040 3


EN FB D6 D10
modern DC-DC converters is around 1.2 V. GND
However, particularly when high currents are 4x 1V2 2 D7 D11

involved, this can mean an unreasonably


IC2 U BIAS
large amount of power is wasted. With the K2 MAX6063 K4 K6
following elegant circuit we can reduce the R1
B
R2
A
1 2
voltage drop across the sense resistor and 39k 28k3
P1 R4 R5
hence reduce the power wastage.
6Ω8

6Ω8
3
R3
820k
10k
Key points U ADJ
Figure 1 shows a typical switching regulator 020430 - 11

configured to drive eight white LEDs from a


4.8 V battery supply. The switching regulator Figure 1. Modified step-up converter.
has to produce a voltage ULED BIAS across the
LEDs of nominally 4 _ 3.5 V = 14 V. The volt-
age actually required in practice is not impor- of around 30 Ω, and the power dissi- us a simple way to adjust the output
tant here, since the LEDs are driven with a pated in it will be 50 mW. current. To do this we also connect
regulated current rather than at a regulated The alternative circuit uses a resis- up a further voltage source UADJ,
voltage. A DC current of nominally 40 mA tor R2 in series with the feedback con- adjustable from 0 V to 3 V, via R3.
should flow through each chain of LEDs. nection. A constant voltage source of In order to calculate the resistor
Resistor R4 serves here as the sense resis- UBIAS = 3.000 V (generated by a values, we start from the fact that a
tor: the voltage UA, which depends on the MAX6063) is connected to point B via current of 45.3 µA will be flowing in
LED current, is brought to the feedback pin R1. Now, in order to generate a feed- R1 (39 kΩ). If UADJ is set at 1.233 V,
(pin 3) of the switching regulator IC as UFB. back voltage of 1.233 V, we require a then no current will flow in R3 and
The output is controlled so as to make the much lower sense voltage at point A. so this path will not have any effect
feedback voltage 1.233 V. In standard appli- Resistor R4 can be reduced signifi- on the circuit: all the current flowing
cations point A is connected directly to pin 3. cantly (to a theoretical value of 7 Ω), in R1 will flow through R2. From the
Then UFB = UA = R4 ⋅ ILED, and the power and the power dissipated in it is cor- graph in Figure 2 we can see that a
dissipated in R4 can be calculated as follows: respondingly reduced. voltage UA of 144 mV corresponds to
PR4 = UA ⋅ ILED = R4 ⋅ ILED2. With a feedback The circuit with the auxiliary volt- a voltage UADJ of 1.233 V, and so R2
voltage of 1.233 V we require a sense resistor age reference generator also gives should have a value of 24 kΩ.

56 Elektor Electronics 1/2004


GENERALINTEREST
The LED current should be not be connected to the battery volt- I LED U SENSE
adjustable from 0 mA to 50 mA. age: remove jumper J2 and instead
This corresponds to a voltage drive EN from an external PWM signal mA mV
across R2 from 144 mV lower to via K7. This way it is possible not only 50 350
206 mV higher than the value just to control the brightness from 0 % to
considered. To achieve the latter, R3 100 % in ‘current mode’, but also to 40
235
must draw a current of exploit the brightness-enhancing 30
206 mV/24 kΩ = 9.58 µA to ground. effect of using double the nominal cur-
This means R3 should be 144 kΩ. rent pulsed at a frequency of 1 kHz 20
125
In order to calculate all the values with a duty cycle of 10 %. This gives 10
exactly we can use Kirchhoff’s cur- the subjective effect of ten times the
rent law, which states that the sum expected light intensity. In this case 0
0 1 2 3
of the currents into a junction (here the values for R1, R2 and R4 need to U ADJ
point B) is zero. be recalculated. At such a high cur- V 020430 - 13

rent the voltage drop across a white


LED can rise as high as 5 V, and this Figure 2. Effect of potentiometer voltage on
Analogue or PWM? should also be taken into account. See LED current.
With UADJ at 3 V the switching con- also the article ‘LED Arrays’ in the
verter stops operation and its quies- April 2003 issue of Elektor Electronics.
cent current in this mode is 28 µA. The disadvantage of this method inputs all need to be added. Then the circuit
With UADJ at 0 V the converter oper- is of course that the LED current is has to be tested in practice. It’s therefore
ates at its maximum frequency and pulsed and so the EMI characteris- worthwhile to take a brief look at the compo-
the LEDs light at full brightness. tics are worsened. To mitigate this nents used in the circuit.
Using this analogue control signal the LEDs should be mounted directly The key component is the TPS61040 step-
we can obtain adjustable brightness next to the regulator and the con- up converter, in an SMD package. The effi-
with good EMI emissions character- nections should be kept as short as ciency of this device when used as a current
istics since there are no edges of a possible. The datasheet recom- source is between 70 % and 85 %. The output
PWM control signal to get through to mends using a frequency of 100 Hz voltage can go as high as 28 V, and so it is
the LEDs. What may be a disadvan- to 500 Hz at the enable input in capable of driving up to six white LEDs.
tage is that the varying current PWM mode. In fact somewhat higher Internally the devices uses two-point regu-
through the LEDs results in a change frequencies of 1.5 kHz to 2.5 kHz (but lation, and it can operate reliably with an
in the emitted colour: the wave- no higher) are more efficient. Below output capacitor of only 100 nF. The peak
length of the light emitted by an LED 100 Hz the pulses of light are visible current is regulated using pulse frequency
is dependent on the bias current. It to the eye. A PWM signal at a fre- modulation at a frequency of up to 1 MHz
is necessary to decide whether this quency of 1 kHz and an adjustable and the interval between pulses is guaran-
shift in colour will be acceptable or duty cycle in the range 0 % to 10 % is teed to be at least 400 ns. Stable operation
not in each individual application. If optimal both for the switching regu- with such a small output capacitor is only
analogue control of the output cur- lator and for the LEDs. possible at such a high switching frequency.
rent is not desired, then connect The voltage at the FB input is monitored
UADJ directly to UBIAS or simply omit using an internal comparator. The reference
the circuit involving R3 altogether. Components voltage UREF is 1.233 V.
Brightness control without affect- Of course, the circuit as presented The internal power switch is turned off
ing the resulting colour can be here is only a building block. Control when the current through the coil exceeds
achieved using PWM. To this end the circuitry, reverse polarity protection 400 mA: this is the second point of regulation.
enable pin EN of the regulator should and overvoltage protection on the The next pulse is started when the minimum
interval between pulses of 400 ns has expired
and the sense voltage UFB has fallen below
Standard Modified the sense voltage reference UFB.
LED current mA 40 This regulation scheme runs in discontin-
uous mode, which means that as soon as the
ULED BIAS: 4 LEDs V 14 two criteria mentioned above are met the
PLED mW 560 next cycle starts. The PFM switching fre-
UFB V 1.233 quency is therefore dependent on the input
voltage, the output voltage, the inductance
UA V 1.233 0.387 and the output current. The maximum pulse
R4 (E24 series) Ω 30 10 width is 6 µs. This way the device achieves
PR SENSE mW 51 17 its very high efficiency, without using exter-
nal MOSFETs, over the entire range of load
PMAX6063 mW 0 0,5 currents, and the tolerance of the coils and
PTOT mW 611 577.5 output capacitors is not critical to operation.
The switching current through the N-chan-
Efficiency % 91.7 97.6
nel MOSFET is internally limited to a maxi-

1/2004 Elektor Electronics 57


GENERALINTEREST
mum of 400 mA in this modern IC, which SS24 SMD diode in a type B package rial used is suitable for the switching
effectively prevents possible saturation of the (DO-241 AA) from Fairchild is readily frequency of the regulator. The
coil by limiting the duration of the PFM available and has a low forward volt- DO1608C-103 by Coilcraft is ideal. In
pulses. Naturally the device features ‘soft age. Alternatively the 10BQ015 from no circumstances should an ordinary
start’ and can operate reliably at full load International Rectifier (in the same suppressor choke be used.
even with batteries that are practically package) can be used, or the more
exhausted. In the first group of pulses the recent MBR0520LT1, a device with a
current through the switching transistor is low leakage current offered by ON Printed circuit board
limited to one quarter of its maximum value; in Semiconductor in an SOD123 pack- When designing a printed circuit
the next group to one half of its maximum; age. board it is essential to observe a
and then after 512 pulses the full current is The MAX6063 reference voltage ‘switching supply’ layout in order to
allowed to flow. If the input voltage falls generator, available in an SOT23 keep the electromagnetic interfer-
below 1.5 V the internal MOSFET is switched package, produces a precise output ence emissions as low as possible:
off. voltage of 3.000 V. The output noise SMD components, wide tracks kept
The effective series resistance of the out- is extremely low and no output as short as possible where high cur-
put capacitor C2 has a significant effect on capacitor is necessary. Its input volt- rents flow, and a ground plane on
the efficiency and switching behaviour of this age can be from 3.2 V to 12.6 V, and the underside of the board.
type of boost converter circuit. Normally a it has a negligible current consump- (020430-1)
ceramic capacitor is required, but the tion of 90 µA. If this boost converter
TPS6104x can also manage with inexpensive circuit is used as part of a larger cir-
tantalum capacitors. If a value greater than cuit, there will often be a reference Reference
100 nF is chosen — as would be required in voltage source already available The circuit is adapted from the article
applications where low output noise is impor- which can of course be used instead Extending Battery Life of a White Light
tant — the EMI emissions characteristics are of the MAX6063. LED Driver by Michael Day of Texas
made worse. The inductor L1 is a tiny drum- Instruments: the original is available on
For the switching diode, a Schottky type core coil which can easily be made the Internet at
with low leakage current is called for. The by hand. Be sure that the core mate- www.chipcenter.com/analog/c071.htm.

See your design in print!


Elektor Electronics (Publishing)
are looking for
Freelance Technical Authors/Designers

If you have
 an innovative or otherwise original design you would like to see in print
in Europe’s largest magazine on practical electronics
 above average skills in designing electronic circuits
 experience in writing electronics-related software
 basic skills in complementing your design with an explanatory text
 a PC, email and Internet access for efficient communication with our
in-house design staff

then do not hesitate to contact us for exciting opportunities in getting your designs published on a regular basis.

Elektor Electronics
K. Walraven, Head of Design Dept.
P.O. Box 75, NL-6190-AB Beek, The Netherlands, Fax: (+31) 46 4370161
Email: k.walraven@segment.nl

58 Elektor Electronics 1/2004


MICROCONTROLLER

64-K 80C552
Flash Board
Inexpensive, multifunctional and in-circuit programmable
Design by L. Hamers

This microcontroller board is a standard 8051-based system, with a few


extras that make it suitable for use as a development system or control
module for a larger system. Its most important features in this regard are
on-board Flash memory programming via the serial RS232 port, direct
on-board program debugging and low cost.

Features
– 80C552 microcontroller clocked
at 11.0592 MHz
– 64 KB Flash ROM, 32 KB RAM
– in-circuit programmable
(max 64 KB)
– compatible with the MSC1210
source code debugger for in-cir-
cuit debugging
– address logic fully implemented
in GAL
– nine chip-select signals for exter-
nal devices connected to the
data bus
– eight 10-bit A/D inputs or eight
digital inputs
– eleven free I/O pins
– I2C bus
– watchdog timer, battery voltage
monitor, RAM backup battery
– true RS232 interface (MAX232)
– two 36-way pin headers (2.54
mm) for all connections

60 Elektor Electronics 1/2004


MICROCONTROLLER
Program Data A variety of microcontroller boards between 00000 and 0FFFF (here an extra
FFFF
based on 8051 successors have digit is used compared with normal
already been published in Elektor addresses because the ROM is twice as big
Electronics, but this one has several as the normal 64-K address region).
RAM features that clearly distinguish it For data memory, there are 32 KB of SRAM
from the rest. Read on to learn the in the address range from 8000 to FFFF. Mem-
details! ory-mapped I/O devices can be connected in
the lower, unused portion of the data mem-
8000 FLASH ory address range (0000 to 7FFF). A total of
Operating principle nine chip-select signals are available for this
Normally speaking, with a microcon- purpose: CE0 through CE7 for addresses 0000
CE I/O 1 troller the program is read from the through 00070, and CE IO1 for the remainder
ROM, while the RAM is used to store of the region (0008 through 7FFF).
variables and data. However, during
software development it is handy to Debugging mode (Figure 1)
0008
CE I/O 2 also have the program in RAM, since The software provided with the MSC1210
0000
030042 - 12 this allows it to be easily and quickly development platform recently described in
modified. For programming the Flash Elektor Electronics includes a source-level
Figure 1. Flash ROM configuration in memory, it is also necessary to have debugger called SLD51. This debugger lets
normal mode. the program in RAM, since is it not you to copy a program to the board via the
possible to program a Flash ROM serial port and then the run the program, stop
FFFF
and execute a program from it at the it, allow it to run one step at a time, and
same time. It is thus necessary to examine variables. It is also possible to set
have a mechanism for switching breakpoints, which cause the program to stop
RAM RAM back and forth among various oper- at certain points so you can look for problems.
ating modes. The following modes In debugging mode, the Flash address
are possible: range from 10000 to 17FFF is mapped onto
– debugging the range 0000 through 7FFF for the micro-
– Flash programming controller. This part of the Flash memory con-
8000
– normal tains a combined operating system and mon-
itor program called OS552. As the port lines
The 80C552 microcontroller can only of the microcontroller are set to ‘1’ following
FLASH CE I/O 1
address 64 KB of the Flash memory, a reset, the monitor program is started at
since it has only 16 address lines. In Flash address 10000 after a reset. The upper
debugging mode, part of the Flash 32 KB of the Flash memory cannot be used,
0008
memory must be used for the moni- since the RAM is addressed as both program
CE I/O 2 tor program, which reduces the and data memory in this range.
0000
030042 - 13
amount of memory available for the This is necessary for two reasons. First, it
application program in normal mode. allows a given program to be tested in mem-
Figure 2. Flash ROM configuration in As the 29F010 Flash ROM has a ory (RAM) using the monitor program, and
debugging mode. capacity of 128 KB, half of it is not second, it makes it possible to run this pro-
being used. However, with a bit of gram. Memory-mapped I/O is located in the
clever circuit design we can use the same region as in normal mode, so it can also
FFFF
A16 address pin to switch between be tested during debugging.
the two halves of the Flash ROM
under control of a port line, which Programming mode (Figure 3)
RAM
we call Debug/Run (or D/R for short). The third mode is used to program the Flash
ROM. As it is not possible to erase and repro-
Normal mode (Figure 1) gram the Flash ROM while the program
This mode is used after program intended to control this process is being exe-
8000 FLASH development has been completed cuted from the Flash memory, it is necessary
and the board is built into a stand- to make certain changes to the memory
alone system. In normal mode, the organisation. Here the RAM is used as pro-
Flash ROM is used as program mem- gram memory, and the Flash memory is used
ory over the entire memory address as data memory (which means it can be writ-
range of 0000 to FFFF (64 KB). The ten). The chip-select signals for memory-
D/R (Debug/Run) line is set to ‘0’ in mapped I/O are disabled in order to avoid
this mode, which means that A16 of undesirable effects on external circuits.
0000 030042 - 14
the Flash ROM is also set to ‘0’. The firmware for programming the Flash
The program for the normal mode memory must be written to RAM in
Figure 3. The third mode is used to is located in the lower half of the advance. The PC program FlashMon does
program the Flash ROM. Flash ROM in the address range this automatically.

1/2004 Elektor Electronics 61


MICROCONTROLLER
+5V +5V +5V +5V
K1 K2
1 1
2 D1 2 RD
R4 R3 R18 C10 +5V +5V +VRAM
3 T1 D0 3

3k3

10k
3k3
4 T0 R17 100n C12 C13 D1 4
R11
20
1k
5 INT1 C11 D2 5

0Ω
6 IC3 100n 100n
INT0 D3 6
RST
7 SDA 100n 10 D4 7
2
8 SCL 32 D5 8
9 P1.5 T1 59 61 A0 12 28 D6 9
AVREF+ AVDD A0
10 P1.4 15 IC3 A1 11 D7 10
RST A1 10 A0
11 P1.3 57 D0 D0 2 19 A0 A2 10 A0 11 CE0
AD0 1D A2 9 A1
12 P1.2 P1.0 16 56 D1 D1 3 18 A1 A3 9 A1 12 CE1
BC516 P1.0 AD1 A3 8 A2
13 P1.1 P1.1 17 55 D2 D2 4 17 A2 A4 8 A2
D0 13
IC5 D0 D0 11 13 CE2
P1.1 AD2 A4 D0 7 A3
14 P1.0 P1.2 18 54 D3 D3 5 16 A3 A5 7 A3
D1 14
D1 D1 12 IC8 14 CE3
P1.2 AD3 A5 D1 6 A4
15 P4.7 P1.3 19 53 D4 D4 6 15 A4 A6 6 A4
D2 15
D2 D2 13 15 CE4
P1.3 AD4 A6 D2 5 A5
16 P4.6 P1.4 20 52 D5 D5 7 14 A5 A7 5 A5
D3 17
D3 D3 15 16 CE5
P1.4 AD5 A7 D3 4 A6
17 P4.5 P1.5 21 IC4 51 D6 D6 8 13 A6 A8 27 18 D4 D4 16 RAM A6 17 CE6
K3 P1.5 AD6 A8 D4 D4 3 A7
18 P4.4 22 50 D7 D7 9 12 A7 A9 26 A7
SCL/P1.6 AD7 A9 29F010 D5 19 D5 D5 17
D5 25 A8
18 CE7
1 19 P4.3 23 A10 23 20 D6 D6 18 A8 19 WR
SDA/P1.7 A10 D6 D6 62256 24 A9
6 20 P4.2 39 A8 A11 25 21 D7 D7 19 A9 A12 20
A8 A11 D7 D7 21 A10
2 21 P4.1 P4.0 7 40 A9 11 1 A12 4 A10 A14 21
P4.0 A9 C1 EN A12 23 A11
7 22 P4.0 P4.1 8 41 A10 A13 28 A11 A13 22
P4.1 A10 A13 2 A12
3 23 P4.2 9 42 A11 74HC573 A14 29 20 A12 A7 23
P4.2 A11 A14 CE 26 A13
8 24 P4.3 10 43 A12 A15 3 A13 A8 24
P4.3 A12 A15 1 A14
4 25 STADC P4.4 11 44 A13 A16 2 A14
CE 22
A6 25
P4.4 A13 A16
9 26 P5.0 P4.5 12 45 A14 30 OE WE A9 26
P4.5 A14 A17
5 27 P5.1 P4.6 13 46 A15 1 22 14 27 A5 27
P4.6 A15 A18
28 P5.2 P4.7 14 WE OE A11 28
P4.7
29 P5.3 80C552 48 31 16 24 A4 29
SUB D9 ALE
30 P5.4 P5.0 1 A3 30
P5.0
31 P5.5 P5.1 68 47 A10 31
P5.1 PSEN
32 P5.6 P5.2 67 A2 32
P5.2
33 P5.7 P5.3 66 24 A1 33
P5.3 RXD
34 AVREF– P5.4 65 25 A0 34
P5.4 TXD +5V +5V

A16
35 AVREF+ P5.5 64 26 INT0 35
P5.5 INT0
36 RST P5.6 63 27 INT1 C8 C7 36
P5.6 INT1
P5.7 62 28 T0
P5.7 T0
+5V 29 T1 100n 100n
T1
4 30 20 16
PWM0 WR
R6 5 31 A11 1 12

CE ROM
PWM1 RD I0 F0

* see text * WATCHDOG 3


STADC
A13 2
3
I1 F1
13 A0 1
0 DX 0
15 CE0

R5: ENABLE 6 60 R7 A14 14 A1 2 0 14 CE1


EW AVSS P1.0 I2 IC6 F2 G 1
R6: DISABLE 58 49 0Ω 4 15 A2 3 7 13 CE2
AVREF– EA P4.0 I3 F3 2 2
R5 0Ω A15 5 16 IC7 12 CE3
X1 X2 I4 F4 +5V 3
* R12
36 37 35
X1
34
R8 A12 6
I5 GAL
16V8
F5
17 74HC138 4 11 CE4
7 18 OE 6 10 CE5
+5V I6 F6 5
0Ω

8 19 CE IO0 5 9 CE6
I7 F7 & 6
C5 C1 C2 R1 9 4 7 CE7
P1.2 I8 7
0Ω

CE RAM
D/R 11
P4.2 I9
1µ 33p 33p 0Ω
2 8
11.0592MHz R2 10
1 V+ 16
C3 C1+
CE IO1
3 IC2
1µ C1–
14 11 +5V
T1OUT T1IN
13 12
R1IN R1OUT +VRAM
7 10
T2OUT T2IN 030042 - 11
8 9
R2IN R2OUT 3 R15
4 P4.1
C4 C2+ 0Ω
1 2 P1.1
MAX232 VBAT VOUT 0Ω
1µ 5 15 R9
C2– JP1 IC1 11 R16
330k

V- WDI R13
10 INT1
6 PFO 0Ω
C6 INT0
9
MAX691 0Ω
PFI
16 12 R14
1µ BT1 RST CE OUT
15 13
RST CE IN
R10
C9
3V
130k

4
100n

Figure 4. The full schematic diagram of the microcontroller board.

The circuit I/O. The PSEN and RD lines are used /CE_RAM = /A15+/PRG*/PSEN
to generate output-enable signals in +/WR*/RD*/D_R*PRG
Processor and memory the address regions where these sig- +D_R*/RD*/WR*/PSEN
Figure 4 shows the complete schematic dia- nals are necessary. /CE_ROM = PRG*/PSEN
gram of the microcontroller board. The vari- +/WR*/RD*/PRG+D_R*A15*PRG
ous elements that make up the circuit can be GAL /CE_IO0 =
quite easily recognised. The GAL is the central element for /(/A11*/A12*/A13*/A14*/A15*
The microcontroller is a Philips 80C552 switching between the various oper- PRG*/PSEN)
(IC4). Its most important added features com- ating modes of the system. Several /CE_IO1 = A15+CE_IO0+/PRG+PSEN
pared with a standard 8051 microcontroller processor signals are applied to its A16 = D_R
an I2C interface, an 8-channel 10-bit A/D con- inputs, including PGM (which
verter, and an extra I/O port. As usual, the causes the GAL to switch to the pro- The file upboard.pds (available on
lower eight bits of the address bus are multi- gramming mode when it is ‘0’) and diskette or the Elektor Electronics
plexed, and they are separated from the AD D/R (‘0’: normal run mode; ‘1’: website under order number 030042-
signals by IC3. debugging mode). The GAL outputs 11) can be read using the program
A 32-KB RAM (IC8) and a 128-KB Flash control the memory ICs and the chip- Palasm, which is available on the
ROM (IC5) are connected to the address bus. enable signals for memory-mapped Internet as freeware. However, if the
Only 96 KB of the Flash ROM is actually used. I/O. The GAL programming descrip- GAL programming does not require
The central address decoder is a 16V8 GAL tion is as follows: any modifications, it can be pro-
(IC6), which generates the control signals for grammed directly using the JEDEC
both memory ICs and the memory-mapped /OE = /PSEN*/RD file upboard.jed.

62 Elektor Electronics 1/2004


MICROCONTROLLER
I/O
K2 R15 R18
BT1 030042-1 All signals necessary for connecting exter-
R16

H1
H2

R14
C11 IC7
nal hardware are fed out via headers K1 and
C12

C7
R13 IC1 C13
K2. Besides the full data and address buses,
they include several chip-select signals that
IC3
R10

can be used to directly drive external mem-


C9 R9
JP1
ory-mapped I/O devices. Signals CE0
through CE7, which correspond to addresses

IC5
R11
R12

0000 through 0007, are output via address

IC8
C10

IC4 X1
decoder IC7.
C1
R6
C2
If even more control signals are needed,
R5 030042-1 the CE IO1 signal can be used to handle the
remainder of the I/O range (from 0008 to
7FFF). If a MOVX command is executed in
R17 T1 this region, the CE IO1 signal goes to ‘0’.
D1

IC6 R8 R7
The 5-V signals from the serial port of the
microcontroller are converted to genuine

C8
C3 C4

RS232 levels by the MAX232 (IC2), in order to


C5

C6

R3
R4
allow the circuit to be connected directly to a
H3
H4

R2 R1
K1
PC. If RXD and TXD are connected as shown
in the schematic diagram, it is not necessary
to use a null modem cable; a regular 1:1 ser-
ial cable can be used instead.
The 80C552 has a full I2C interface that
supports the complete standard in both sin-
gle-master and multi-master modes. Activity
(C) ELEKTOR
030042-1 on the clock line of the bus is indicated by
LED D1. This line is also used by the monitor
program to display system status during
start-up by means of blink codes.
The A/D inputs (P5.0–P5.7) are connected
directly to K1. The supply voltage for the
microcontroller serves as the reference volt-
age. If this is not sufficiently accurate, resis-
tors R11 and R12 can be removed and an
external 5-V reference voltage can be con-
nected to K1.34 and K1.35.

Power supply and protection


A small (70 mA minimum), stabilised 5-VDC
supply can be used to power the microcon-
troller board. The circuit is protected against
an insufficient supply voltage by IC1. This IC
(a MAX691) has been specially developed for
such tasks, and it generates a reset pulse
immediately after power is applied.
If the voltage on the microcontroller drops
below 4.5 V, it is placed in the Reset state, the
RAM is powered from the backup battery (if
JP1 is fitted) and the RAM is put into standby
mode. If the voltage drops below 4.6 V, PF0 is
set to ‘0’ (the voltage level can be adjusted
using R9 and R10; the threshold voltage of the
030042-1

PF1 input is 1.3 V). If R13 and R14 are fitted,


this can be used as an early indication that
the supply voltage is collapsing.

Figure 5. SMD components are used to keep


the printed circuit board nicely compact.

1/2004 Elektor Electronics 63


MICROCONTROLLER
IC1 also includes a watchdog timer, just in
case the watchdog timer in the 80C552 is not
sufficiently safe. The watchdog is enabled or
disabled by soldering R15 or R16 in place. If
you would like to know more about the
MAX691, you will find its data sheet at
www.maxim-ic.com.

Circuit board assembly


The circuit board layout designed for this cir-
cuit is shown in Figure 5. SMD components
have been used to keep the circuit board very
compact. This makes assembling the circuit
board somewhat more difficult, but with a
fine soldering tip and a steady hand, you
should be able to manage it without too
many difficulties. Incidentally, a bit of desol-
dering braid works wonders if things occa-
sionally go wrong.
First fit all of the resistors to the board. The
values of SMD resistors are printed on them
using three or four digits. The final digit
always indicates how many zeros have to be
placed after the value. For instance, ‘333’ Figure 6. The fully assembled circuit board.
means ‘33’ followed by three zeros, which
amounts to a resistance of 33 kΩ. However, a
marking of ‘3302’ (‘330’ and two zeros) also
indicates a value of 33 kΩ.
A variety of options can be selected by fit-
ting 0-Ω resistors, which are used as jumpers.
(If you find it difficult to obtain such resistors,
you can also use 1-Ω resistors or wire bridges
instead.) The following settings are the stan-
dard values, for which the software is config-
ured:

Function Fitted Open


Debug/Run mode R1 R2
Disable watchdog R6 R5
Programming mode R7 R8
Reference potential + R11 –
Reference potential – R12 –
‘Low voltage’ interrupt – R13/R14
External watchdog – R15/R16

When software is being developed, it is a nui-


sance to have to repeatedly reset the watch-
dog timer (internal or external), and this often
leads to problems. Besides this, neither of the
watchdogs is serviced by OS552. This means polarity. For rectangular electrolytics, Next, solder the SMD ICs to the
that it is better to not use the watchdog until the positive terminal is marked by a circuit board. Here you also have to
the major portion of the software is finished. small + sign or a thick stripe, but pay attention to the orientation. Start
Resistors R15 and R16 are thus not fitted ini- electrolytics in round packages are by melting a small amount of solder
tially. just the opposite; they have their onto a solder pad at the corner of the
Once you have soldered all the resistors, negative terminal on the side IC. Using tweezers, place the IC on
you can fit the ceramic capacitors. Be careful marked with black paint. No doubt the board and use the soldering tip
not to mix up the 33-pF and 100-nF types. the manufacturers did this on pur- to press down the pin above the
These SMD capacitors all look the same, pose to see whether you’re paying tinned solder pad. Once the IC is
since no value is printed on them. attention! In any case, it keeps firmly attached, solder the pin at the
After this, fit the electrolytic capacitors in things interesting, because elec- opposite corner. Now check the posi-
the vicinity of IC2. It hardly needs saying that trolytics fitted the wrong way round tioning of the IC, which can be
it’s vitally important to observe the correct occasionally tend to explode. altered if necessary by warming the

64 Elektor Electronics 1/2004


MICROCONTROLLER
socket. There is usually a ‘flat’ on version of OS535, which is used with the
COMPONENTS LIST one of the corners. Finish the solder- MSC1210 development platform. This forms
ing work by fitting the transistor, the part of a complete development system
Resistors:
LED, the battery and the crystal. including a C compiler, a project manager
(all resistors: SMD case shape
Finally, press the four ICs into their with ‘make’ files and a debugger. As OS535
1208)
sockets. Note that before being fit- was developed for a different board with an
R1,R2,R5-R8,R11-R16 = 0Ω (see
ted, the GAL (IC6) must be pro- 80C535 microcontroller, several small modifi-
text)
R3, R4 = 3kΩ3 grammed using the file upboard.jed cations are necessary, among other things
R9 = 330 kΩ and the Flash ROM (IC5) must be with regard to driving the GAL.
R10 = 130kΩ programmed using the file You can use the board in three different
R17 = 1kΩ upboard.hex. If you cannot do this manners, assuming you have fitted a Flash
R18 = 10kΩ yourself, you can order pre-pro- ROM containing the monitor program:
grammed versions from Readers Ser- 1) To program the board, run the program
Capacitors: vices (order numbers 030042-21 and FlashMon on your PC. This allows you to pro-
(all capacitors: SMD case shape 030042-31). gram up to 64 KB of the Flash memory.
1208) A fully assembled version of the 2) To debug a program you have written
C1,C2 = 33pF circuit board is shown in Figure 6. yourself, run the program SLD51 on your PC.
C3-C6 = 1µF 16V The maximum available memory is 32 KB.
C7-C13 = 100nF 3) To run a program you have written your-
Testing self (maximum size 64 KB), first program it
Semiconductors: the assembled circuit into the Flash memory and then reset the
D1 = LED, red, 3mm, high- For testing the circuit board, you can board. You can also run a terminal emulator
efficiency
stick a few loose pins into connector program on the PC, but not FlashMon or
T1 = BC516
K1 for the connections or use a piece SLD51. The board will now run your program.
IC1 = MAX691CWE (SO16 case)
of perforated prototyping board. The monitor program is located above the 64-
IC2 = MAX232 (SO16 case)
IC3 = 74HC573 (SO20 case)
Mount two pin headers on the proto- KB boundary in this mode and does not affect
IC4 = 80C552EFA (PLCC68 case) typing board, each with 36 contacts. the operation of the board.
IC5 = 29F010 (32-pin DIP case), Connect pins 23 and 24 of K1 to pins
≤120ns, programmed, order 3 and 2 of a female sub-D connector, These operating modes are described in more
code 030042-21 and connect ground (pin 1 of K1) to detail below.
IC6 = GAL 16V8D15QP, pin 5, pin 1 to pins 4 and 6, and pin
programmed, order code 7 to pin 8. Simulator
030042-31 Next, connect the board to a PC Software can be developed and debugged
IC7 = 74HC138 (SO16 case) using a 1:1 serial cable and start a using the program SLD51. To use the board in
IC8 = 62256 (28-pin DIP case), terminal emulator program (such as this mode, select the proper COM port under
≤120 ns HyperTerminal). Configure the serial Options/Com Settings and set the bit rate to
link for 57.6 kbit/s, 8N1, no hand- 57,600. After the board has been switched on,
Miscellaneous: shake. If you now connect a power it will remain in debug mode. You can use
X1 = 11.0592MHz quartz crystal source to the board (5 V at 70 mA File/Open and File/Download to load a pro-
B1 = Lithium battery type CR minimum), the message ‘Hello gram into the RAM, where it can subse-
2032 with PCB mount holder World’ will appear on the screen. quently be run. The program located in direc-
K1,K2 = 36-way SIL pinheader This will be repeated if you press a tory \src\hello_debug can be used as an exam-
K3 = 9-way sub-D socket (female)
key. The file upboard.hex pro- ple for this purpose.
(not on PCB)
grammed into the Flash ROM con-
IC sockets for IC4, IC5, IC6, IC8
tains a small application program in FlashMon
JP1 = 2-way jumper
PCB, order code 030042-1
addition to the monitor. The only The program FlashMon from the µC51 devel-
Disk, project software, order code thing this program does is write opment environment can be used to erase the
030042-11 or Free Download ‘Hello World’ to the outside world. Flash ROM on the board and reprogram it. To
Congratulations – you now know do this, first copy the file flashmon.bix into the
that your system is alive! bin directory of the development environ-
If the Flash ROM has not been ment. Then start the FlashMon program.
soldered pin and shifting the IC. programmed, nothing will happen. Under Options/Com Settings, set the bit rate
Once the IC is properly positioned, You can’t program the monitor into to 57,600 and select the proper COM port. To
you can solder the remaining pins. the Flash ROM yourself, because the prevent the program in the ROM from start-
Allow the IC to cool down after sol- board needs the monitor for pro- ing, enabled ‘Disable Flash Autostart’ in the
dering each pair of pins, so it does gramming (what a pity!). Toolbox menu.
not become overheated. When the board is switched on, the start-
After all of the SMD components up of the regular program will be intercepted
are in place, you can fit the IC sockets Software and the internal monitor program will be
and connectors to the board. Make The combined monitor and operating started instead. Now you can use
sure that the sockets are correctly system program for the board is Toolbox/Clear Flash All to erase the program
oriented, particularly the PLCC called OS552. It is a slightly modified in the Flash ROM (the monitor program will

1/2004 Elektor Electronics 65


MICROCONTROLLER

Summary of 8051 microcontroller boards


Unlike one competitor who appears to be stuck with PICs, Elektor Electronics has already published quite a few development board
designs for microcontrollers in the 8051 family. Here we briefly describe the most important ones:

89S8252 Flash Micro Board:


a simple system for programs up to 8 KB, targeted at both experienced and novice users. Also pro-
vides the basis for a programming course that explains the basics of microcontroller technology and
examines several programming languages (assembler, BASIC-52 and the Reads11 C compiler). Pub-
lished in the December 2001 through June 2002 issues, with an I/O extension in January 2003.

High-speed Controller Board:


the DS89C420 is a super-fast 80541 derivative that can be used for processing rates up to 33 MIPS. An
ideal development system, with 16 KV of Flash program memory and in-circuit programming capabil-
ity. Described in the June and September 2002 issues.

XA Development Board:
with a PC/104 interface for 16-bit microcontrollers, 64 KB of program memory and 64 KB of RAM.
The XA family was presented as a 16-bit successor to the 80C32, but it essentially goes much further.
The XA core is considerably faster than its 8-bit predecessor. Described in the May and June 2003
issues.

MSC1210 Development Platform:


a small but powerful board built using SMD technology, which unlike the other boards described here
is supplied ready-made (no soldering required!). Can handle programs up to 8 KB (8 KB development,
16 KB max in Flash), but has additional I/O and 24-bit A/D inputs. Includes a free Basic and C develop-
ment environment. A digital measuring instrument using this board has already been described as an
application. Published in the July/August through November 2003 issues (‘Precision Measurement Cen-
tral’ series).

64-K 80C552 Flash Board:


a classic design for programs up to 32 KB (32 KB development, maximum 64 KB in Flash), with in-circuit-programmable Flash memory
and 32 KB of RAM. Has eight 10-bit analogue inputs and three sets of 8 free I/O lines. Uses the same development environment software
as the MSC1210 development platform (with minor modifications).

not be erased) and Toolbox/Download to


Flash to write the new program to the Flash
Once this has happened, the
monitor waits for commands from
Free Downloads
ROM. Note that this program must contain the the PC, and the LED on the board Project software, including OS552
instruction LJMP (0x02) at address 0000, since flashes regularly. If no command is (source), ‘Hello’ program (C
source), Flash552.hex, upboard
otherwise it cannot be started by the monitor sent to the board after it is switched
(GAL source and JEDEC files). File
program. The program located in .\src\hello_run, on, the monitor checks whether a number: 030042-11.zip.
which is already included in the standard LJMP command (with destination
FlashMon and SLD51 (in
firmware, can be used as an example. 0x02) is present at address 0000 of
µC51/bin.) are included in
the Flash ROM. This is how the 030060-11a.zip, see ‘Precision
Monitor operation monitor recognises whether a valid Measurement Central’ part 2, Sep-
Immediately after starting up, the board program is present in the Flash tember 2003).
enters the debugging mode and the OS552 Memory. The board then switches to PCB layout in PDF format. File
monitor program sends a command to the PC. the run mode and starts program number: 030042-1.zip.
If a program such as FlashMon is running in execution at address 0000 in the
www.elektor-
the PC, the PC sends back a command to the Flash memory. electronics.co.uk/dl/dl.htm, select
board to cause it to remain in the debugging (030042-1) month of publication
mode.

66 Elektor Electronics 1/2004


ELECTRONICSONLINE

Analogue
Filter Design By Harry Baggen

In electronics, filters are required for all sorts of applications, ranging from
a simple audio circuit to the speech processor in a GSM phone. Filter
theory being complex stuff for the average electronics worker and
certainly no part of everyday chores, a couple of Internet addresses may
come in handy if you’re suddenly faced with selecting and dimensioning
a filter for an application on hand. In this month’s instalment of Electronics
Online we look at a dozen or so calculation aids for analogue filters.

Electronic filters represent a complex matter From the latter group we made a and band-pass filters to be dimen-
which is not, or not fully, mastered by many selection, with an eye for software sioned, enabling you to select
electronics enthusiasts. Not to worry, that’s offered free of charge. We between filter responses like Bessel,
because lots of professional engineers will begin with a number of calculation Butterworth and Chebyshev, all with
also admit defeat to the niceties of modern fil- tools that can be run directly off the various ripple responses.
ter design. Fortunately, neither the hobbyist relevant website. A helping hand for passive filter
nor the professional worker needs to have a Analog Devices on their massive design is offered by various tools on
few dozen equations in his head — what website [2] offer a number of online the Max Froding website [3]. We
matters is to know where the information can calculation aids for active filters. The found a page discussing the design
be found when it is needed. To help you on scripts allow second-order through of passive Butterworth filters (high-
the way, and perhaps add a few bookmarks eighth-order high-pass, low-pass or low-pass) with up to 25 ele-
in your Favourites folder, we searched the
Internet for software tools that considerably
lighten the job of passive and active analogue
filter design.

An excellent point to start from when you


need filter information in the widest sense is
Circuit Sage [1]. Set up a number of years ago
by a bunch of IC designers, this website cov-
ers a vast range of electronic designs. With
each subject, the designers themselves make
relevant information available, or point the
way to other sources on the web. Looking
under the heading ‘Filter Design’ the list
starts with a number of calculations intended
for use with the familiar MathCad mathemat-
ics program. Various types of low-pass and
high-pass filters are available in passive as
well as active guises.
If you can not, or do not want to, work
with MathCad, the second list on this web
page contains addresses of alternative filter
calculation programs.

72 Elektor Electronics 1/2004


ELECTRONICSONLINE
under the name Burr Brown Filter Designer
Software. These days TI supply a revamped
version running under Windows under the
name FilterPro [6]. The program suite com-
putes Sallen and Key or multiple feedback
constellations with a Bessel, Butterworth or
Chebyshev response.
Linear Technology [7] also offers a few fil-
ter programs that are certainly worth your
thorough examination and practical use —
the names are FilterCAD and the Filter
Design Guides for the LT1567 and LT1568.
Although the programs assume you’re using
LT integrated circuits, they’re easy to adapt
to similar products from other manufacturers.
Filterlab from Microchip [8] is another
dimensioning program for active Bessel, But-
terworth and Chebyshev filters up to eighth
order (low-pass, high-pass and band-pass).
The program is easy to use, allowing you to
view a simulation of the frequency and phase
response immediately after the filter dimen-
sioning operation.
Tunekit 2.0 [9] is a small Windows pro-
gram written by Max Froding. It is suitable for
Chebyshev low-pass and high-pass filters
comprising 2 to 25 poles, band-pass and
notch filters. The program has been designed
as a front-end to the famous ARRL Radio
Designer and so allows your filter to be
analysed straight away.
Finally, those of you interested in ‘big gun’
programs only should follow these links to
demo versions that provide excellent intro-
ductions to filter dimensioning: Filtroid by
Gigasim [10], Filter Master by Intosoft [11],
Super Filter by Those Engineers [12] and
Quickfil by Omicron [13].
(045005-1)

ments. Another page helps you


compute passive elliptical (or Internet Addresses
Cauer) band filters. [1] Circuit Sage: www.circuitsage.com/
Tony Fishet’s interactive LC Filter [2] Analog Devices Interactive Design Tools: www.analog.com/Analog_Root/ static/
Design page [4] is certainly worth techSupport/designTools/interactiveTools/filter/filter.html
trying. Although graphically less [3] Max Froding filter calculations: http://users.aol.com/maxfro/private/butter.html
sophisticated that the above web- http://users.aol.com/maxfro/private/cauerbpf.htm
sites, Tony’s pages look technically [4] LC Filter Design: www-users.cs.york.ac.uk/~fisher/lcfilter/
sound and it’s results that count at [5] RF Tools: http://rfengineer.cc/rftools.htm
the end of the day. [6] FilterPro: http://focus.ti.com/analog/docs/sampleutilities.tsp?path=templatedata/cm/
Software for the design and sim- utilities/data/filterpro&templateId=3&familyId=57&navigationId=9742
ulation of filter responses has always [7] Linear Technology filter software: www.linear.com/software/
been pricey. Fortunately, a few pro- [8] Filterlab: www.microchip.com/1010/pline/tools/analog/software/flab/10626/index.htm
grams are available at no cost at all. [9] Tunekit 2.0: http://members.aol.com/maxfro/private/tunekit2.html
To begin with, we should mention [10] Filtroid: www.gigasim.com/gsFiltroid.html#anchor647705
Burr Brown’s Filter Perfect. A bit [11] Filter Master: www.i-t.com/engsw/intusoft/filtrmstr.htm
dated, maybe, but still a great piece [12] SuperFilter: www.spiceage.com/demo.htm
of DOS (!) software, it can be down- [13] Quickfil: www.omicronsw.com/downloads/swdemos/index.html
loaded from the RF Tools website [5]

1/2004 Elektor Electronics 73


READERS’ CORNER P.O.Box 190

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 and email received, it is not possible to
answer all correspondence, and we are unable to respond to individual wishes and requests for modifications to,
or additional information about, Elektor Electronics projects.

Directional Microphone vide any substantial amplifica- The missing diode was already transistor-based Zener diode
In Elektor November 2003 on tion of the microphone signals. noticed before we received your achieves an accuracy of about
page 26 the author tells us that Even at extremely high volumes letter (see Corrections & 10% which is more than ade-
the low-pass filter frequency is no more than about 8 mA of out- Updates). It failed to show up in quate for this application.
determined by the combination put current will flow (not count- the circuit diagram because the A Goldcap, then, can be
R8 and C3 — this makes me sad. ing the external load), which is author employs the charger and expected to pump a short-circuit
I believe the references should be way below the maximum of the step-up converter as separate current of up to 6 A, which
to C7 and R9 (else I have taught ±50 mA specified for the units (as shown in the photo- defeats the use of a largish diode
all my students the wrong thing opamps used. graph). The ersatz Zener may as you suggest and can only be
for more than 15 years !). look haphazard but in reality is a stopped by a fuse. In the unfor-
good choice because the only tunate event of a short-circuit,
Also, I wonder, what is the mean- Flawed Mini Project requirement for the Zener voltage we’d rather see a small diode
ing of resistors R19 -R30? As far Dear Editor — your ‘SuperCap is better stability than that of the destroyed than the coil.
as I can see they are all paralleled Battery’ article (October 2003, battery. Also, the use of a reverse- Arguably, every project publica-
with P2 which is ‘only’ 1 kOhm. Ed.) suffers from a couple of biased transistor fits the bill of a tion can be optimised or
Besides, resistors R37-38 (470 design flaws I’d like to mention. Mini Project because most hob- extended in some respect. How-
Ohm) will work as RL’s — when byists will have a few spare tran- ever, a Mini Project should be
you look in the data-sheet from The Goldcap is discharged by R1 sistors lying around but no Zener simple, brief and open to experi-
TI you’ll see that all data are and R2, so a diode behind the diodes. In our experience, the ments.
measured at RL> 10 kOhm. I’ve charger circuit would have been
used the TCL2272 series and in order. Without such a diode,
found that the distortion of you will be unable to justify the
these op-amps will be rather ‘2-mA under no-load conditions’
high (>1% at 1 kHz) when RL is claim made in the article, simply
smaller than 10 kOhm at an out-
put swing greater than a few
because the series combination of
R1 and R2 already draws more at
CORRECTIONS&UPDATES
hundred milliVolts. 2.3 V. An additional load is formed
by the voltage regulator, because Rev Counter for R/C Models
current flows into its output. November 2003, p. 56-61, 024111-1.
I think it’s sad that Elektor
Electronics brings articles with A 4.7 kΩ resistor should be inserted between pin 7 of IC1 and the
such essential faults ! To use a reverse-biased transis- base of T4. Without the series resistor, the comparator output is
Soeren Ploug, Denmark tor b-e junction as a Zener diode short-circuited to ground by way of the base-emitter junction of T4.
(by email). is ludicrous for a circuit sup- The resulting current will however not damage the TLC272.
posed to be reproducible — the
There’s no reason for sadness Zener voltage will stray far too
caused by one typo. The refer- much. Also, a transistor with Electric Charge Meter
ence to C3 in the formula on higher gain (C-suffix version) November 2003, p. 20-21, 030018-1.
page 26 is wrong and should would help to reduce the no-load On the PCB overlay, the symbols ‘+ ‘ and ‘–‘ near K2 should be
have been to C7 (see Corrections current, as it would have allowed swapped. This error does not affect the operation of the circuit.
& Updates elsewhere in this a higher value for R3 (approx.
issue). Still, the two components 4.7 kΩ). Diode D2 is clearly
R8 and C7 are not related to the under-dimensioned. This diode Directional Microphone
low-pass filter function, and no can be expected to carry high November 2003, p. 24-30, 030046-1.
such statement is made in the currents as the full Goldcap volt- The equation in the article text on page 26 contains a wrong
article. Obviously, the low-pass age is applied to the load by way component reference and should be amended to read:
filter roll-off frequency is deter- of the coil and the diode. In this R8 = d / (c · C7)
mined by R9-C7, see also the position I would have liked to see
inset at the end of the article a Schottky diode capable of pass-
and in particular, equation 16. ing in excess of 1 A, or failing USB-RS232 Interface
The function of R19-R30, then, is that, an 1N4002 as the bare min- April 2003, p. 60-65, 0200375-1.
to prevent audible clicks in the imum. The statement that the In the circuit diagram on page 62, the value of R10 should be
output signal when the rotary coil resistance should be under amended to read: 100 kΩ. This does not affect the Components
switch is operated, which is 1 Ω is incorrect — although it List or the PCB layout.
achieved by providing a DC path stands to reason that the con-
to ground for all capacitors C11- verter efficiency drops with coil
C22 when they are not selected resistance. I would have like to Supercap Battery
by S2. After all, the output of see this mentioned. October 2003, p. 52-53, 030109-1.
IC1.D is at roughly half the sup- Components IC1, R1 and R2 cause a rather too high discharge
ply potential (you may have Finally, it would have been nice current of about 5 mA on the Goldcap battery. This can be pre-
missed this point). to see a graph with efficiency vented by an additional diode between the Goldcap and the
Contrary to what you seem to plotted against output current. LM317.
assume, the circuit does not pro- Dr T. Scherer

74 Elektor Electronics 1/2004

You might also like