Professional Documents
Culture Documents
creative solutions
for all areas of electronics
R
310 circuits
elektor international media bv – 089018/uk
pagina 1
R
310 circuits
elektor international media bv – 089018/uk
pagina 3
The publishers have used their best efforts in ensuring the correctness of the information contained in this
book. They do not assume, and hereby disclaim, any liability to any party for any loss or damage caused by
errors or omissions in this book, whether such errors or omissions result from negligence, accident or any
other cause.
ISBN 978-0-905705-78-1
089018/UK
L
310 circuits
elektor international media bv – 089018/uk
pagina 4
Actuators Communications
12 V Bidirectional Motor Control 341 2.4 GHz Antenna for Robotics Vehicles 418
3 Amp PWM DC Motor Controller 446 IR Communications using a UART 438
Catapult for Robots... or Other Uses 389 IR Remote Control with the R8C 346
Complete Stepper Motor Driver 405 Radio Remote Control for PDAs and
Controlling Servos 486 Smartphones 401
Driving Higher Power DC Motors 510 Receiver for RC5 Remote Controls 483
Driving Stepper Motors 530 Removed Pulse Detector 452
Driving Stepper Motors: KISS 351 Robot Voice 384
From Cassette Recorder zBot: Wireless Link 523
to Robot Propulsion 515
MotoBox 424 Computers & Internet
PIC Indicator Relay 377
PIC12C508 Stepper Motor Controller 497 Assistance for BASCOM Programmers 315
Robot Footballer 464 Computer Off Switch 22
Servo to Motor Conversion 480 Delphi Floating Strings 338
zBot: 10-A Power Stage 492 Expansion for Universal Interface 155
Hard Disk Switch 114
Audio, Video & Photography Mobile Phone Data Cable = Interface
Converter 125
Automatic S/PDIF Selector 142 Multicolour HD LED 304
Auto-off for Audio Gear 129 SCSI Adapter 80
BBC Radio-MP3 for Seniors 85 Serial to Bluetooth 82
Camera = Data Store 44 Simulation Applets 265
DC-coupled Audio Amplifier 49 Speed Pulse Generator for PC Fans 89
Five-output Video Distribution Amplifier 104 USB Fuse 210
Hybrid Headphone Amp 158 USB Standby Killer 140
ISO Standard for Car Radios 234 USB/RS232 Cable 61
Multimedia RIAA Preamplifier 34 USB Switch for Printers 262
Paraphase Tone Control 282
Phantom Supply for TV Antenna 40 Hobby & Modelling
Phono Splitter 224
Play the Guitar – Recycle Tip 68 123 game – all MCU-free 66
Simple Audio Power Meter 196 Automatic Windshield Washer Control 258
Simple Hybrid Amp 204 Bicycle Speedometer with Hub Dynamo 15
Simple Slave Flash 281 Binary Clock 307
Slave Flash trigger I 63 Deluxe ‘123’ Game 182
Slave Flash Trigger II 131 Design for Märklin Light Signals 264
Stepped Volume Control 495 Direction-sensitive Light Barrier 328
TV Muter 185 Discrete Robot 332
Video Isolator 231 Fog Lamp Switch 303
Wireless Audio Transmitter 99 Golf Tally 254
Intelligent Interface for 1 to 8 Servos 161
Intelligent Presence Simulator 163
R
310 circuits
elektor international media bv – 089018/uk
pagina 5
L
310 circuits
elektor international media bv – 089018/uk
pagina 6
Low Cost USB Demo Board 393 PR4401/02 off the Beaten Track 176
LPC900 Programmer 407 PWM Control for Permanent
Multitasking Pins 237 Magnet Motors 239
Optimised STK200/300 Programmer 505 Rear Fog Lamp for Vintage Cars 197
Programmer Board for the R8C/13 41 Recycling Flasher Lights 313
Programming the Propeller IC 284 Simple Capacitive Touch Sensor 129
Propeller Prototyping Board for BoeBot 378 Simple LED Bike Light 247
R8CKey 242 Simple One-wire Touch Detector 191
Reaction Race using ATtiny13 33 SMD Crystal Adapter 139
Satnav for Robots 430 SMD Soldering Aid 336
Serial Interface for the Propeller 448 Smooth Flasher 171
Servo Control from a PC 526 Solar Lamp using the PR4403 272
SimpleProg 209 Stepped Volume Control 495
Simple USB AVR-ISP Compatible Stroboscope with Trigger Input 119
Programmer 113 The Gentle Touch 207
‘TEAclipper’ Postage-stamp Programmer 342 The OC171 Mystery (solved) 285
Tiny RGB 36 Thrifty 2-Hz Clock 333
Turbo BDM Lite ColdFire Interface 223 Thrifty LED Protector 117
Universal LCD Module 92 Walking Works! 455
Universal Thermostat 288
Which Brain for my Robot? 353 Power Supplies, Batteries & Chargers
R
310 circuits
elektor international media bv – 089018/uk
pagina 7
L
310 circuits
elektor international media bv – 089018/uk
pagina 8
R
310 circuits
elektor international media bv – 089018/uk
pagina 9
L
310 circuits
elektor international media bv – 089018/uk
pagina 10
Jan Middel
11
R
310 circuits
elektor international media bv – 089018/uk
pagina 11
used to drive transistor T1, which in turn gram then shows a welcome message. Next,
drives a relay that turns the lights on and off. press the Enter switch. Use the Up and Down
The supply voltage is stabilised using a stand- switches to set the correct value for the
ard 7805 voltage regulator IC. S1 is the reset hours. Press the Enter switch to set the min-
switch, which is connected to the MCLR input utes (in the same way as for the hours). After
of the PIC. MCLR should be ‘high’ during nor- pressing Enter again, you are asked for a
mal operation (and ‘low’ for a reset). Hence value for the light threshold. This value is
this input has been connected to the positive compared with the amount of light falling on
supply voltage via pull-up resistor R1. the LDR. When the value of the LDR becomes
less than the threshold the lights come on.
A program has been written in Flowcode that Another press of the Enter switch takes you
activates the relay when the following condi- to the day-of-week setting. This determines
tions apply: the days when the light stays on for longer at
night. A final press of the Enter switch then
à when it is later than 16:00; starts the clock.
à when the amount of light reaching the It is of course possible to modify the software
LDR is less than an adjustable threshold; in certain places. You could for example
change the time at which the lights come on
à during the morning between seven and in the morning. This function could even be
eight o’clock; removed completely if you have no need for
it.
At night the relay is turned off at 23:00 (ex- (080113-I)
cept on Friday, Saturday or Sunday, when the
lights stay on one hour longer).
Downloads
During the day the display shows at what The Flowcode (.fcf) file for this project, 080113-
time the garden lights were last turned on. 11.zip, is available on the Elektor website as a
free download, as is the layout for the printed
The following procedure should be used to circuit board (080113-1.zip).
set the time: press the Reset switch; the pro-
In order to measure higher voltages we have nected in series with the + input of the mod-
to reduce the voltage with a potential divider. ule and R2 is connected in parallel with the
For this purpose we add R1 and R2. R1 is con- inputs. In the table we can see the correct ra-
12
L
310 circuits
elektor international media bv – 089018/uk
pagina 12
INL
To measure current with a
voltmeter we first have to
convert the current into an 040037- 11
13
R
310 circuits
elektor international media bv – 089018/uk
pagina 13
D3
1N4007
IC1
TL783KC +48V
F1 D1 C1 C3 R1 R3
ADJ
150 Ω
4k7
160mA T TR1 100n 4700µ 1%
63V
1W
1N5408
R2
C5 C6 C7 D5
230V
230V
5k6
24V
1% 100n
100n 100µ
1W 100V
1N5408
30VA D4
D2 C2 C4
100n 4700µ
63V
1N5408
070602 - 11
fier formed by diodes D1 and D2 and capacitors where reference voltage Vref = 1.27 V.
C3 and C4. Capacitors C1 and C2 suppress the
switching noise produced by the rectifier di- These resistors should preferably have a tol-
odes. This voltage-doubling rectifier provides erance of 1%, and R2 is likely to dissipate
around 72 VDC, and so offers an adequate 0.5 W. Resistor R3 provides a minimum load
margin to allow for ±10% fluctuations in the that is vital for maintaining the PSU’s off-load
mains voltage. voltage at 48 V, and is also used to supply LED
D4. If the LED is not used, R3 must without
Voltage regulation is taken care of by fail be connected to ground.
TL783KC regulator IC1 on which an abundant
amount of information may be found at [3]. Last but not least, regulator IC1 must be
Basically, this is an adjustable regulator in a mounted on a heatsink with a thermal resis-
TO220 package that offers excellent residual tance of less than 1.5 °C/W using the standard
ripple and low noise on its output voltage. insulating kit: top-hat insulating washer, mica
washer, and heat sink compound... make sure
The TL783KC regulator includes a MOS series you use enough, but not too much!
pass transistor and accepts an input voltage (070602-I)
of up to 125 V, making it an ideal candidate
for this application. Diodes D3 and D5 respec- Bibliography and Web Links
tively protect the PSU against transients at [1] Microphone Essays, p. 83. Jorg Wuttke,
switch-off and reversed polarity. www.schoeps.de/E-2004/miscellaneous.html
(11 MB document in German, downloads via
The output voltage is set by resistors R1 and links at bottom of page)
[2] DIN EN 61938 standard
R2 according to the formula:
[3] http://focus.ti.com/docs/prod/folders/print/
æ R2ö tl783.html
Vout = Vref × ç1+ ÷ [4] http://en.wikipedia.org/wiki/Phantom_power
è R1ø
14
L
310 circuits
elektor international media bv – 089018/uk
pagina 14
Hans Michielsen
+12V
R3
*
15k0
16
+12V
9 D6
0 1
2x 7
*
CTR12 1
R1
BAT18 10 6 D9
10k0 + 2
5
IC2 D3 D10 3
3 D7 IN
D1
LM7812 IC1 4 2
2
C1 MBR5828 5
3x
CT 4
6 BAT18
R2 4040 13
100µ 7
25V 12
20k0
8 3
G1 14
D2 C2 C3 9 GND
11 15
CT=0 10
1
100µ 330µ 11
6V
25V 25V
8
MBR5828 3x BAT18
D4
* see text
D5
D8
060166 - 11
15
R
310 circuits
elektor international media bv – 089018/uk
pagina 15
16
L
310 circuits
elektor international media bv – 089018/uk
pagina 16
rent will now flow trough the inductor coil L1 Besides, it allows the output voltage to be
via diode D1 to the load (capacitor C2 and regulated. Low-value resistor R3 is switched
possibly the battery), irrespective of the out- in parallel with the solar cell array by T1 so
put voltage level. Capacitor C2 and/or the bat- that the current from the solar cell array flows
tery will then be charged. So, in the steady through it. Zener diode D2 is of course essen-
state the output voltage is higher than the in- tial in this circuit as its zener voltage limits
put voltage and the coil voltage VL1 is nega- the output voltage when T1 should be turned
tive, which leads to a linear drop in the on, connecting the solar cell array to ground
current flowing through the coil. In this via R3. In this way, there is no input voltage to
phase, energy is again transferred from the the boost converter and the battery cannot
coils to the output. Transistor T2 is turned on be overcharged.
again and the process is repeated.
Sealed lead-acid (SLA) batteries with a liquid
A type BC337 (or 2N2222) is suggested for T2 electrolyte produce gas when overcharged,
as it achieves a high switching frequency. In- which can ultimately result in damage to the
ductor L1 should have a saturation current battery. So, it’s important to choose the right
larger than the peak current; have a core ma- value for zener diode D2. Special lead-acid
terial like ferrite (i.e. high-frequency) and low- batteries for solar use are available, with im-
resistance. Diode D1 should be able to sus- proved charge-discharge cycle reliability and
tain a forward current larger than the maxi- lower self-discharge than commercially-avail-
mum anticipated current from the source. It able automotive batteries.
should also exhibit a small forward drop and a Finally, never measure directly on the output
reverse voltage spec that’s higher than the without a load connected – the ripple current
output voltage. If you can find an equivalent can damage your voltmeter (unless it’s a 1948
Schottky diode in the junk box, do feel free to AVO mk2).
use it. (070894-I)
17
R
310 schakelingen
elektor international media bv – 089018/nl
pagina 17
10p
may not be higher than 12
330p V, because the IC cannot
withstand that. The current
060095 - 11
consumption at 9 V is only
15 mA.
ing charged and discharged when the voltage As with all free-running oscillator circuits, the
reaches the hysteresis threshold. The output output frequency of this specimen is also sen-
continually toggles as a consequence. This re- sitive to variations of the power supply volt-
sults in a square wave output voltage. With a age. For optimum stability, a power supply
10-pF trimmer capacitor the frequency can be voltage regulator is essential.
adjusted into the VHF FM broadcast band 88-
108 MHz). The frequency of the oscillator is As an additional design tip for this circuit, we
stable enough for this. The output voltage is show an application as VCO for, for example,
about 6 V PP at a power supply voltage of 9 V. a PLL circuit. When the trimmer capacitor is
The transmitter power amounts to about replaced with a varicap diode, the frequency
50 mW at a load of 50 Ω. This is about 20 range can be greater than that of an LC oscil-
times as much as the average oscillator with a lator. That’s because with an LC oscillator the
transistor. range is proportional to the square root of
the capacitance ratio. With an RC oscillator
With a short antenna of about 10 cm, the the range is equal to the entire capacitance
range is more than sufficient to use the circuit ratio. For example: with a capacitance ratio of
in the home as a test transmitter. Because the 1:9, an LC oscillator can be tuned over a range
output signal is not free from harmonics the of 1:3. With an RC oscillator this is 1:9.
use of an outdoor antenna is not recom- For the second tip, we note that the circuit
mended. This requires an additional filter/ can provide sufficient power to drive a diode
adapter at the output (you could use a pi-filter mixer (such as a SBL-1) directly. This type of
for this). mixer requires a local oscillator signal with a
power from 5 to 10 mW and as already noted,
The FM modulation is achieved by modula- this oscillator can deliver 50 mW. A simple at-
ting the hysteresis, which influences the oscil- tenuator with a couple of resistors is suffi-
lator frequency. An audio signal of about cient in this case to adapt the two to each
20 mVPP is sufficient for a reasonable output other.
amplitude. (060095-1)
18
L
310 circuits
elektor international media bv – 089018/uk
pagina 18
Hesam Moshiri
Features
à Controls 6 high-power DC devices
This circuit can be called using your mobile or à Five digits password security
a regular telephone set (with DTMF keys) and à User-defined password
after passing some procedures, you can con- à Feedback to user by sounds
trol DC-powered appliances installed in your à Password and device status retained in
home. Examples include the front door latch EEPROM
and the pump of a plant watering system. à Device status on LED panel
19
R
310 circuits
elektor international media bv – 089018/uk
pagina 19
20
L
310 circuits
elektor international media bv – 089018/uk
pagina 20
2
75%
the circuit to receive and process the number When you call the circuit, one +5 V ring pulse
pressed. appears at the cathode D9. The answer circuit
A maximum of three wrong password entries includes B1, C5, R4, R3 and T1. If you want
is accepted. With every wrong password you the circuit to answer to one ring, put one re-
enter, you will hear one long beep and if you sistor in parallel with the telephone line, re-
enter a wrong password thrice, you will hear ducing the line voltage to approximately
one long beep again and the circuit will hang 15 VDC and passing about 20 mA through the
up on you. The circuit shows the status of all resistor. Answering the call implies driving T1
devices by its LED panel. D1 indicates the cir- into saturation. Therefore the telephone line
cuit power, D2 the answer status (ON: phone current will pass through R3. To hang up, T1
line is busy; OFF: phone line is free). The other is switched off. The function of C5 is to inject
LEDs indicate the status of the controlled de- a sound produced by the microcontroller.
vices (LED ON: device = ON, LED OFF: device The DTMF tone decoder circuit includes R5,
= OFF). R6, R7, C9, C10, C11, X1 and IC2.
The schematic diagram Figure 1 has these IC2 (an MT8870) is a DTMF tone decoder IC. It
main parts: power supply, ring detector, receives the DTMF tones via R5, R6 and C9.
answering circuit, tone decoder, micro- The corresponding binary data of each code
controller, output relays and LED panel driv- appears on the Q1-Q4 pins. An incoming code
er. The power supply includes IC3, C6, C7 and is indicated by a rising edge on the STD pin.
C8 producing the +5 V supply voltage for the The event is fed to the INT0 pin of the
circuit. The ring detector comprises B2, C1- microcontroller. A High level on the TOE pin
C4, R1, R2 and D9. C1, C2 and C3 pick up the of the MV8870 enables the outputs Q1-Q4.
ring (AC) voltage of between 80 V and 100V, Here it is strapped to the +5 V rail.
25 Hz. B2 converts the ring voltage to DC. C4
serves for noise reduction and R1, R2 and D9 The micro is an ATMega8 from Atmel. The fi-
create a suitable voltage level at the PD4 pin nal stage has a ULN2003 high voltage and
of the microcontroller. high current Darlington transistor array IC,
21
R
310 circuits
elektor international media bv – 089018/uk
pagina 21
that easily copes with the relay and LED panel Connect the 9-12 VDC mains adapter to J1.
currents. Each output pin of this IC can drive Next, program the microcontroller by means
up to 500 mA. The LED panel includes D1-D8 of the ISP socket, K2. Select an 8-MHz internal
that indicate circuit activity and status of all clock source for the micro by setting the fuse
devices. Caps C11 and C12 are included for bits per Table 1. Don’t forget to program
noise reduction and it is to use multilayer ca- both the Flash (filename.hex) and the
pacitors ceramic for this purpose. EEPROM (filename.eep) file! Connect your
electrical appliances to the circuit observing
The PCB for the controller is shown in Figure all relevant electrical safety precautions. The
2. One PCB section comprises the main circuit EEPROM in the circuit ensures that settings
the other is for the LED panel. The two PCBs are not lost after a reset or when a mains
are interconnected with a 10-way (2×5) IDC power interruption occurs.
connector. Once the circuit has been built up,
the micro has to be programmed with the Finally, we can calculate the security of the
firmware hex file from free download archive system. With a five-digit password, we have a
080037-11.zip found on the Elektor website. 1 in 100,000 probability of hitting the correct
The source code is also available: it was pro- code by chance, which seems adequate for
duced using MikroC from MikroElektronika. such a simple system.
22
L
310 circuits
elektor international media bv – 089018/uk
pagina 22
IC1.C
1N5817 R1 C2
5 6
100k 1
D1 10µ
25V
R3 R2 IC1.D
14
K1 9 8
1M
100k
1 IC1 1 2x
+5V IC1.A
2 7 C3 1N5817 1N5817
D– 1 2
3 1
D+ IC1.E
4 10µ D3 D4 D5
GND 11 10
1
USB - A D2 D6
Re1
C8 C9 C1 C7 C6 C5
IC1.F
470µ 330p 10µ
25V 13 12 25V 1N4148
1
1N5817 3x 1000µ
25V
IC1 = 40106
IC1.B T1
3 4
1
C4
BSS295
1µ
060177 - 11
C9, which drives inverters IC1c to f. The fre- turned off. T1 is a type BSS295 because the
quency is about 50 kHz. The four inverters in resistance of the coil is only 24 Ω.
parallel power the voltage multiplier, which When the PC is switched on, the circuit draws
has a multiplication of 3, and is built from C1 a peak current of about 200 mA, after which
to C3 and D2 to D5. This is used to charge C5 the current consumption drops to about
to C7 to a voltage of about 9 V. The generated 300 µA. The current when switching on could
voltage is clearly lower than the theoretical be higher because this is strongly dependent
3 × 4.8 = 14.4 V, because some voltage is on the characteristics of the 5-V power supply
lost across the PN-junctions of the diodes. C5 and the supply rails in the PC.
to C7 form the buffer that powers the coil of There isn’t much to say about the construc-
the switch when switching off. tion of the circuit itself. The only things to
take care with are the mains wires to the
The capacitors charge up in about two sec- switch. The mains voltage may not appear at
onds after switching on. The circuit is now the connections to the coil. That is why there
ready for use. When Windows is closed down, has to be a distance of at least 6 mm between
the 5-V power supply voltage disappears. C4 the conductors that are connected to the
is discharged via R2 and this results in a ‘0’ at mains and the conductors that are connected
the input of inverter IC1b. The output then to the low-voltage part of the circuit. Also re-
becomes a ‘1’, which causes T1 to turn on. A fer to the Electrical Safety page elsewhere in
voltage is now applied to the coil in the mains this book.
switch and the power supply of the PC is (060177-1)
23
R
310 circuits
elektor international media bv – 089018/uk
pagina 23
47µ 400V
C3 C1
K1 D3 D1
47n 47n L1 L2
F1
30V 5 IC1 4
VIN VSW
80VA 100µH 100µH 16V
C4 C2 2A5 T 5A 5A R3 R4 5A
LT1074CT
6k8
14k0
D4 D2 VC GND FB
47n 47n
2 3 1
R1
D1...D4 = B10100 D6
2k2
D5
C8 R2
C5 C6 C7 C9 C10 C11 C12 C13
2k21
POWER
100n 100n 100n 100n 220µ 220µ 100n
63V 63V
6V C14 C15
750 mA 12V
K5 1A
0A5 T 100n D7 10µ
f 63V
230V
1N4148 JP1
6V
4VA5
064011 - 11
for the 12 V and a separate transformer for output voltage of 12 V is required you should
the 6.3 V filament supply. close JP1, which shorts D7.
We’ve chosen an LT1074CT (IC1) for the regu- IC1 and D5 require a little more cooling and
lator, which means that the circuit can be for this the 63.5 mm version of the SK129 will
built with relatively standard components suffice (4.5 K/W). Both components can be
and will have a high efficiency. The power loss mounted on opposite sides of the heatsink.
is less with this device compared to a linear You have to make sure that they are electri-
voltage regulator. This allows us to use a cally isolated from each other and the
higher transformer voltage and a smaller cas- heatsink! You should take a look at the
cade section to generate the 170 V (which is website of Linear Technology and take note
required for the SRPP stage in the amplifier). of the layout recommendations regarding the
use of an LT1074 (www.linear.com).
The lower input current also results in smaller You can use standard chokes for L1 and L2,
losses in the bridge rectifier (D1 to D4). A rated at 5 A. If you want to remove more of
standard 12 V regulator (IC2) turns the 16 V the residual 100 kHz switching frequency you
into a stabilised voltage for the buffer stage. could always add an extra LC filter at the out-
When an ECC83 (12AX7) is used in the hybrid put. The diodes in the bridge rectifier are
amp we could use this 12 V to power the fila- B10100’s. These are Schottky rectifiers,
ments in the valve as well, although we really which have a low forward voltage drop (only
need 12.6 V. The current taken by the valve is 0.7 to 0.8 V at 10 A). We have chosen diodes
about 150 mA, which means that the 12 V reg- with a reverse voltage rating of 100 V so we
ulator needs to be fitted with a heatsink. This have the option of using an LT1074HVCT in-
can be a small version of an SK129 heatsink stead. This can work with an input voltage of
from Fischer (38.1 mm, 6.5 K/W). To increase up to 60 V, which means we could use a
the voltage by 0.6 V we’ve added diode D7 to 40 VAC transformer. The same cascade circuit
the ground connection of the regulator. If an can then easily generate 220 VDC . The stan-
24
L
310 circuits
elektor international media bv – 089018/uk
pagina 24
dard LT1074CT can cope with up to 45 V, so IC1. When the cascade supplied 20 mA the
we’re using IC1 fairly close to the limits of its output voltage dropped to 140 V. At heavier
specifications in this circuit. loads we recommend that you use a smaller
A cascade circuit generates the HT supply for cascade circuit and a higher transformer volt-
the valve. It would also have been possible to age (and also use an LT1074HVCT because of
use a separate transformer with a bridge rec- the higher input voltage).
tifier and smoothing capacitor to generate The filament voltage for the valve is gener-
this voltage. But then we’d have to find a ated by a 4.5 VA transformer, which in prac-
4.5 VA transformer with a 40 V secondary and tice had an output a bit above 6 V and
connect it the ‘wrong’ way round. As this isn’t therefore came closer to the required 6.3 V.
exactly a standard transformer we dropped Another solution is to use a special trans-
that idea. former or a stabilised 6.3 VDC supply. Any of
The source for the cascade generator is now these will work, so it’s down to your own
an 80 VA transformer. The capacitors in the preference which of these you’ll use.
cascade circuit have higher values than are It is in principle possible to use the supply for
strictly necessary. This makes it easier to cal- two channels. However, if you use the ECC88
culate the expected output voltage. In our in the amplifier you may find it’s necessary to
case this is 4 × 30 × √2 V for the no-load volt- use a separate cascade generator for each
age, which comes to nearly 170 V. L3 and C22 channel.
filter out any HF interference coming from (064011)
T1
10k
10k
39k
a tail light.
47µ 47µ R7
2x 1V2
2k2
AA batteries. In darkness, 2x
BC547B
the solar cell voltage disap- 080312 - 11
pears and the batteries
automatically power the cir-
cuit. The flash frequency is about one per sec- duty cycle should enable the batteries to
ond and the LED on-time is about 330 ms. The power the circuit over night.
25
R
310 circuits
elektor international media bv – 089018/uk
pagina 25
The circuit is composed of three parts. Under high-brightness yellow types and one (D3) is a
normal daylight conditions the batteries are normal 3-mm red LED for control purposes.
charged through diode D4. In darkness, pnp Of course it is possible to increase the num-
transistor T1 is switched on, supplying bat- ber of LEDs to obtain higher brightness. How-
tery current to the second part, a low-fre- ever you will run into limitations regarding
quency oscillator comprising T2 and T3. the maximum collector current of transistor
The third part is the LED driver around T4. It T4. For really high power applications a
conducts and switches on the LEDs D1-D2-D3 MOSFET transistor is suggested instead of
when the collector voltage of T3 swings high. the common or garden BC547B.
Two LEDs (D1, D2) are 20,000-30,000 mcd (080312-I)
1N4004
C1 C3 C2 4
IC4
100n 220n 470µ 11
25V
3
1
IC3 3 IC4.A P1 D1
2 R3
4 R6
IC4 = LM324
1k
-VO 22k D2
47k
3
2 9
+VO D3
8 12 1
R4 IC4.C L1
10 14 7 18
1 1k IC4.D REFOUT L2 D4
13 5 17
SIG IC2 L3
6 16
MPX2200AP 5 RHI L4 D5
R5 R9 R8 15
7 L5
IC4.B 1k 1k 14
120 Ω
6 L6 D6
13
LM3914 L7
4 12
R2 RLO L8 D7
9 11
1k MODE L9
R7 8 10
REFADJ L10 D8
R1
1k
2
D9
1k
D10
060110 - 11
26
L
310 circuits
elektor international media bv – 089018/uk
pagina 26
which is ensured here by the use of IC1. Since should not have a need to go beyond that in
the output of the MPX2200 is differential and either direction.
at a very low level, we had to resort to the use The circuit may be conveniently powered
of four operational amplifiers IC4.A to IC4.D, from a 9-volt battery but only if used very oc-
contained in one LM324, to obtain levels that casionally. Since this is usually not the case
can be processed easily. As long as poten- for a barometer, we advise you to use a mains
tiometer P1 is adjusted correctly, this group adaptor instead supplying approximately
of operational amplifiers delivers a voltage of 9 volts.
1 volt per atmospheric pressure of 1,000 hPa Calibration basically entails adjusting the po-
to the LM3914. Since the atmospheric pres- tentiometer P1 to light the LED correspond-
sure will be within the range 950 to 1040 hPa ing to the atmospheric pressure of your
at sea level, we need to make an expanded- location at the time. Compare with an exis-
scale voltmeter with this LM3914 in order to ting barometer or, even better, telephone the
better exploit the 10 LEDs that it can control. closest weather station. They will be happy to
That is the role of resistors R7 and R8 which give you the information.
artificially raise the minimum voltage value (060110-1)
the chip is capable of measuring.
After Evangelista Torricelli, 1608-1647, Italian
Consequently, we can ‘calibrate’ our LED physician who proved the existence of atmos-
scale with one LED per 10 hPa and thus bene- pheric pressure and invented the mercury baro-
fit from a measurement range which extends meter.
from 950 hPa to 1040 hPa. In principle, you
Christian Wendt
1
Men like their hobbies. The
author is a particular fan of
fishing, and like many an-
glers is the proud owner of
not only a fishing rod, but
also a boat: and this is
where the electronics co-
mes in. The author’s boat
has an electric outboard
motor, and with his mind wrapped up in his go back to first principles and find an elec-
sport it can easily happen that the battery is tronic solution.
allowed to run down, leaving the not very en-
ticing prospect of a long paddle home. Energy measurement
In order to estimate and show the energy
Simple approaches, such as computing the stored in the battery we need an LCD panel, a
optimal point to stop and turn round, are not microcontroller and suitable sensors. In the-
really satisfactory, as angling involves the ory we need to measure time (easy enough)
boat making a relatively large number of and voltage (also easy) as well as current. En-
short hops. The author therefore decided to ergy dissipated in measurement should be
27
R
310 circuits
elektor international media bv – 089018/uk
pagina 27
minimised (trickier). The product of the three –50 A to +50 A with a transfer characteristic
measured values gives electrical energy. of 1 V per 25 A, ideal for feeding into the ana-
Time measurement is straightforward on a logue-to-digital converter in the microcon-
microcontroller. Modern devices have an in- troller.
tegrated analogue-to-digital converter which In this application voltage measurement is
is accurate enough for measuring the battery not so critical. The voltage should be moni-
voltage. It is harder to measure current as the tored in case a fault (such as a bad connec-
current drawn by the outboard motor is large tion) causes it to drop rapidly. Typically,
and it is difficult to avoid dissipating a few however, the voltage remains fairly constant
percent of the power delivered by the battery and it is adequate to display the charge used
in heating up the shunt resistor. in amp-hours (Ah), the unit normally used to
Fortunately there are current sensors avail- express battery capacity.
able for just this kind of application. The The capacity of the battery is best determined
ACS750 [1] is essentially a thick piece of wire experimentally: charge the battery, do a few
with accompanying Hall-effect sensor and laps of a lake until the battery is completely
conditioning circuitry. The series resistance is flat, and let the circuit tell you the capacity in
130 µΩ and so the voltage dropped across Ah. Make a note of this value. It would be pos-
the sensor is very small. The IC requires a 5 V sible to extend the meter to allow the battery
supply and in the quiescent state (no current capacity to be entered, in order to provide a
flow) has an output voltage of 2.5 V. When a ‘petrol gauge’ display calibrated in percent.
current flows this voltage will rise or fall, de- The circuit’s ‘user interface’ consists of a sin-
pending on the direction of flow. The version gle button which is used (among other things)
used here, the ACS750SCA-050, is linear from to reset the Ah counter. If the button is held
2a
28
L
310 circuits
elektor international media bv – 089018/uk
pagina 28
down when the meter is turned on the coun- On the sensor side of the system a PIC16F676
ter will be reset to zero; if the button is not is used. It has analogue inputs with a resolu-
held down when the meter is turned on, it tion of 10 bits, which, taking into account the
will start from the most recent stored value. effect of the voltage divider formed by R2 and
R3, gives a resolution of 20 mV for the battery
Circuit(s) voltage measurement. LED D1 is an under-
In the interest of reliable operation the circuit voltage alarm, lighting when the battery volt-
of the battery meter is divided into two parts. age falls below 10.6 V. RA0 of IC1 is con-
The normal arrangement is that the battery nected directly to the output of current
and motor are at the stern of the boat, while sensor IC2, giving a current resolution of ap-
the captain is looking forward. A couple of proximately 125 mA. The measurement results
meters of cable are therefore required be- then flow out of the serial port and via the
tween the two parts. Data transfer between MAX232 over the RS-232 link to the display.
the two parts of the circuit must be resilient A PIC16F628 drives the display, polls push-
to noise (even that generated by electric button S2 and jumper J1, and receives serial
eels!). data from the measurement unit. Contrast is
The author decided to use a microcontroller adjusted using P1, and T1 switches the
both in the measurement part of the circuit backlight on and off. With the suggested val-
and in the display part, with an RS-232 serial ues for R6 and R8 the backlight current in the
link between the two. Conversion to standard prototype was 38 mA. If more brightness is
voltage levels is done using a MAX232 at each required, lower resistor values can be used as
end, as shown in the combined circuit dia- long as the maximum rating for the display
gram (Figure 1). (150 mA) is not exceeded.
2b
29
R
310 circuits
elektor international media bv – 089018/uk
pagina 29
3
85%
Each part of the circuit has its own regulated plugs also are conveniently able to pass
5 V supply to improve overall reliability. The through small holes. Cables with four-way
current consumption of the sensor part is ap- plugs will of course not fit in six-way sockets.
proximately 20 mA, and the display part draws If you wish to use a different sort of connec-
approximately 17 mA with the backlight off. tor, then you should of course dispense with
the mini-DIN sockets. The important thing is
Circuit board to ensure that the 12 V supply is provided on
A printed circuit board has been designed for the cable along with ground and the RxD and
each half of the circuit, making two small TxD signals.
modules that can be connected together us- The LCD panel is fitted directly to the solder
ing a cable. The only unusual component on side of the display module circuit board (see
the sensor module (Figure 3) is the current Figure 4). It is therefore best to leave solder-
sensor. The copper tracks that run to it are ing the display until last.
wide and the tags are fixed to the board with Pin 1 of the display is marked ‘LCD1’ on the
assistance from plenty of solder tinning. component side of the circuit board. As long
Other slightly unusual sights are the minia- as care is taken to observe this, nothing
ture fuse with solder connections to the right should go wrong with mounting the display.
and the six-pin PCB-mount mini-DIN socket to It is well worth fitting the two microcon-
the left. This socket allows ready-made six- trollers in sockets in case you should want to
way cables to be used, and the miniature alter the program at a later date. The display
board is equipped with a six-way connector
K3 to allow in-circuit programming of the
4
microcontroller.
The software for each processor is as always
available as source code (for Microchip’s
MPLAB) and as object code for free download
from the Elektor website [2].
Operation
When the unit is switched on using S1 the dis-
play will briefly show:
Accu Control
WEN May 07
30
L
310 schakelingen
elektor international media bv – 089018/nl
pagina 30
31
R
310 circuits
elektor international media bv – 089018/uk
pagina 31
IC1.B D4 230V
5
4
P1 6 & 14
1N4148
IC1
470k 10V
16 7 0W4 T1
D1
R5
2M2 CTR14 7
3
IC2 5 BC547 TRI1
4
4
C2 11 !G 5 IC1.D C3
1µ RCX 6 12 D2 4µ7 R7
9 6 11
CX + 14 13 & 100 Ω TIC206D
R1 P2 10 7
63V RX CT
8
13 1N4148 63V
22k
CT=0 12
3 load
IC1.A 13
R2 1 S2 0W5 BC557
3
1M 2 & R6
8
* C4
390k
R3 IC1.C
C1 8 D3
10 220n F1 N
9 &
LDR 22µ
25V
1N4148 100mA
32
L
310 circuits
elektor international media bv – 089018/uk
pagina 32
the effect of blocking triac TRI1 through X2 model, rates for 230 VAC. Such a model,
IC1.D, T1 and T2. Simultaneously, diode D1 called a self-healing capacitor, is actually the
blocks the oscillator contained in IC2 and, only type of capacitor we should use for
therefore, the assembly stops in this state. It power supplies that are directly connected to
is dark, the light was lit for one to four hours, the mains supply.
according to the setting of P2 and the wiring
of S1 or S2, and it just went out. A return to To ensure proper operation, we should pay
the initial state can only happen after IC2 is careful attention to the placement of the LDR,
reset to zero, which occurs when its input to prevent the device being influenced not
from reset to zero (pin 12) goes to high level, only by light from the house to be protected,
in other words at dawn and LDR R3 detects but also by potential street lights, or even
lights again. headlights of passing cars. Finally, since it is
directly connected to the mains, the assembly
Thanks to its low consumption, this circuit must be mounted in an insulating housing,
can be directly powered by the mains using for obvious safety reasons.
capacitor C4. The latter must be a class X or www.tavernier-c.com (060106-1)
47 Ω
4
the LED turns yellow. The
first to press during this pe-
D1
BZ1
S2 S3
33
R
310 circuits
elektor international media bv – 089018/uk
pagina 33
IC1
magnetic cartridge which 4 10n 1000µ
25V
100µ
25V
correction.
5n6 1n5
R7 R8
R6 R5
C10
5n6 1n5
R14 R15
R13 R12
C15
34
L
310 circuits
elektor international media bv – 089018/uk
pagina 34
tridges, and its 1,000-Hz gain is 35 dB which cuit only uses a few mA, such a solution is ac-
allows it to supply an output level of a few ceptable unless your collection of vinyls is
hundred mV typically required by for the line impressive...
input of a PC sound cards. If you desire a more elegant technical solu-
The connection between the cartridge and tion, you may want to wire up the compo-
the input of the amplifier requires shielded nents within in the dotted lines and you can
wiring to avoid the hum problems discussed steal the 12 V positive voltage available from
above. Likewise we recommend fitting the as- your PC. A Y-connector inserted on the power
sembly in a metal housing connected to the supply of one of the internal drives or periph-
electric ground. With respect to the power erals will work very well for that.
supply, three solutions are proposed: If you Finally, you may also use a mains adapter set
are a purist and you want to rule out any to 12 V and connect it to the +12-volt point
noise whatsoever, you will utilize a simple 9-V of the drawing in order to benefit from addi-
battery. Then, the components outlined with tional filtering, which is not a luxury for some.
a dotted line will not be useful. Since the cir- (060111-1)
Mathieu Coustans
10k
14
IC1 = 4013 IC1
the letterbox is often a slot 7 acoustic
indication
optical
indication
tries.
Of course, it rains a lot less
letterbox
35
R
310 circuits
elektor international media bv – 089018/uk
pagina 35
ally detect the postman, but any kind of post tive high. You can find the truth table for the
slipped into the post-box by lifting the flap flip-flop in the inset. It’s more complicated
protecting the opening) and can indicate this than it seems at first sight (CL = Clock, D =
‘event’ visually (an LED) or audibly (buzzer or Data, R = Reset, S = Set, Q = Q output and Q
vocal alarm based on the ISD25xx). However, = Q output).
that the author soon ruled out the latter op- You can see that this is only triggered once on
tion because of the noise pollution it gener- a rising edge.
ates and the noticeably higher current This edge is generated by the magnetic leaf
consumption compared with just an LED. switch, since the latter is sensitive to any sig-
nificant variation in the magnetic field: the
Those readers who are keen to provide their simple fact of opening the hinged flap of the
system with a vocal-type alarm at any cost can post-box to put the post in can be used to
take a look at the author’s website, where he produce a change of state in the reed switch.
describes the system he used from the follow- The diagram illustrates the respective posi-
ing supplier, before abandoning it. Conrad tions of the reed switch and magnet.
Electronics sell a module the size of a chew-
ing-gum leaf for around £ 6 [1]. The author has all sorts of potential develop-
A glance at the circuit shows how stagger- ments in mind for his circuit. If the subject in-
ingly simple it is. The central component is a trigues you, why not drop by his blog [2] from
CD4013 logic IC (sequential logic), a D-type time to time, to see how things are develop-
flip-flop with reset and priority set to ‘1’, ac- ing? — a basic knowledge of French is re-
quired, though.
CD4013 truth table (080243-I)
CL D R S Q Q
Low>High transition 0 0 0 0 1
Low>High transition 1 0 0 1 0 Web Links
[1] Author’s website:
High>Low transition x 0 0 Q Q
http://ludvol.free.fr/articles.php?lng=fr&pg=211
Immaterial x 1 0 0 1
[2] Author’s blog:
Immaterial x 0 1 1 0 http://lespace-electronique.blogspot.com
Immaterial x 1 1 1 1
Tobias Flöry
36
L
310 circuits
elektor international media bv – 089018/uk
pagina 36
10k
8
100n
180 Ω
180 Ω
27 Ω
www.elektor.com free of
4
1 ANODE RED
Kingbright 1 2 3 4
R B G B
2 ANODE BLUE
charge as file no. 050027-
D1
LF59EMBGMBW 5 6
2 5 1 5 COMMON CATHODE
4 ANODE BLUE
controller (part no. 050027- 6 COMMON CATHODE
37
R
310 circuits
elektor international media bv – 089018/uk
pagina 37
ZEROCROSS
3
GP4/OSC2
IR DATA
RESET
The data is sent every second via IrDA using
2
GP5
PIC12C683
an IR LED and at a baud rate of 38k4. With R3 J2 R3
the current during the short pulse is limited 8 D2
100 Ω
to about 35 mA. 1N4148
With J2 the accumulated data can be reset R1 R2
RESET
In the Init() routine the processor is initialised The circuit can easily (temporarily) be
and the ON/OFF counter is incremented by mounted inside, for example, a lamp fitting
one and the value is saved in EEPROM. It also and must be connected in parallel with the
clears the data in the EEPROM if the jumper is load.
in place. (070349-I)
The main loop (for(;;)) waits for the zero-
crossing detection in the CheckZeroCross()
Downloads
routine. As soon as this arrives the time infor- The source and hex code files for this project
mation is updated in Realtime(), which also are available as a free download from
sends part of the IrDA data every 100 ms. www.elektor.com; file #070349-11.zip.
Only a small part of the data is sent to the IR-
diode each time to prevent C1 from being dis- Web Links
charged too much (relatively large current Freeware C-compiler:
www.sourceboost.com/CommonDownload/
through the LED).
Binaries/SourceBoostV6.85/
The CheckZeroCross() routine also checks sourceboostv685.zip
whether the zero-crossing arrives every 20 ms. Terminal program for PDA:
If not, then is the power has been switched off www.coolstf.com/ztermppc
and the data has to be saved to the internal
38
L
310 circuits
elektor international media bv – 089018/uk
pagina 38
Do you think it is possible to drive an 8-digit, table feature in Figure 2 is that the common
7-segment display with only nine (9) connec- output of each display is also connected to a
tions? Yes certainly, and here we show you segment (but each to a different segment). In
how it’s done. addition it is necessary that the drive elec-
tronics is capable of both sourcing current
Normally speaking, a 7-segment display has and sinking current. This works as follows:
eight LEDs (including the decimal point) that
have to be controlled with eight inputs and To keep things simple we’ve drawn only two
one common output. The corresponding seg- displays in Figure 3. CC0 drives both a seg-
ments of all the displays are connected to- ment (of display 1) as well as a common cath-
gether and only one display is activated at a ode (of display 0). When this line is logic zero,
time because each display has its own com- the segments from display 0 can be illumi-
mon anode (or cathode) connection. This re- nated when they are supplied with current.
quires 8 + 8 = 16 connections, as shown in The segments of display 1 would also like to
Figure 1. But it is certainly possible to do this light up, but there is nowhere for their cur-
with only nine connections, provided the rent to flow. This current has to flow via a seg-
multiplexing is done a little smarter. The no- ment (the leftmost one in this case) but that
1
Seg dp
Seg dp
Seg dp
Seg dp
Seg dp
Seg dp
Seg dp
Seg dp
Seg b
Seg d
Seg g
Seg b
Seg d
Seg g
Seg b
Seg d
Seg g
Seg b
Seg d
Seg g
Seg b
Seg d
Seg g
Seg b
Seg d
Seg g
Seg b
Seg d
Seg g
Seg b
Seg d
Seg g
Seg a
Seg c
Seg e
Seg a
Seg c
Seg e
Seg a
Seg c
Seg e
Seg a
Seg c
Seg e
Seg a
Seg c
Seg e
Seg a
Seg c
Seg e
Seg a
Seg c
Seg e
Seg a
Seg c
Seg e
Seg f
Seg f
Seg f
Seg f
Seg f
Seg f
Seg f
Seg f
CC
CC
CC
CC
CC
CC
CC
CC
Seg a
Seg b
Seg c
Seg d
Seg e
Seg f
Seg g
Seg dp
Cathode 8
Cathode 7
Cathode 6
Cathode 5
Cathode 4
Cathode 3
Cathode 2
Cathode 1
060124- 11
2
Seg dp
Seg dp
Seg dp
Seg dp
Seg dp
Seg dp
Seg dp
Seg dp
Seg b
Seg d
Seg g
Seg b
Seg d
Seg g
Seg b
Seg d
Seg g
Seg b
Seg d
Seg g
Seg b
Seg d
Seg g
Seg b
Seg d
Seg g
Seg b
Seg d
Seg g
Seg b
Seg d
Seg g
Seg a
Seg c
Seg e
Seg a
Seg c
Seg e
Seg a
Seg c
Seg e
Seg a
Seg c
Seg e
Seg a
Seg c
Seg e
Seg a
Seg c
Seg e
Seg a
Seg c
Seg e
Seg a
Seg c
Seg e
Seg f
Seg f
Seg f
Seg f
Seg f
Seg f
Seg f
Seg f
CC
CC
CC
CC
CC
CC
CC
CC
Drive Pin 8
Drive Pin 7
Drive Pin 6
Drive Pin 5
Drive Pin 4
Drive Pin 3
Drive Pin 2
Drive Pin 1
Drive Pin 0
060124- 12
39
R
310 schakelingen
elektor international media bv – 089018/nl
pagina 39
Seg dp
Seg dp
Seg g
Seg d
Seg b
Seg e
Seg c
Seg a
Seg f
remains dark therefore and CC0 CC1 CC2 CC3 CC4 CC5 CC6 CC7
Seg dp
Seg dp
Seg g
Seg d
Seg b
Seg e
Seg c
Seg a
Seg f
CC0 CC1 CC2 CC3 CC4 CC5 CC6 CC7
www.maxim-ic.com/ CC0
appnotes.cfm/ DISPLAY 1
appnote_number/1880 CC1
060124- 14
40
L
310 circuits
elektor international media bv – 089018/uk
pagina 40
41
R
310 circuits
elektor international media bv – 089018/uk
pagina 41
1 K5
SUB-D9
R3
4k7
1 R8C/13 T2
6 R4
1 32
2 RXD RXD1 TXD1 100k
2 31
7 T1 AN6 BC
R1 3 30 R5 558C
10k
3 TXD RESET AN5
27k 4 29
8 AN4
5 28
4 BC VSS MODE
R2 548C 6 27
10k
9 AN3
7 26
5 S1 VCC AN2
8 25
P17 AN1
RESET 9 24
P16 AN0
10 23
P15
K4 IC1 11 22
P14 P30
D1 7805 12 21 S2
P13
13 20 MODE
P12 P31
1N4004 14
P11
19
+9V C1 C2 C3 15 18
P10 P32
16 17
P45 P33
10µ 10V 100n 100n
R6
1k
K1 K2 K3 C4
D2
10µ 10V
060125 - 11
The reset pushbutton is found on the bottom, Tom Thumb module, use IC socket strip that
slightly shifted to the left, and the program- can be sectioned.
ming switch is found on the right.
Connectors linked to the R8C module are The component overlay and other PCB art-
male but there is nothing to stop you from work (Proteus format) are available on the au-
using female connectors, even though the thor’s web page devoted to this project. Lots
male connectors seem to be sturdier. For the of other information on the project may be
2 3
100%
100%
42
L
310 circuits
elektor international media bv – 089018/uk
pagina 42
COMPONENTS LIST
Capacitors Miscellaneous
C1, C4 = 10 µF/10V S1 = pushbutton (reset)
C2, C3 = 100 nF S2 = slide switch,
lead pitch 2.5 mm
43
R
310 circuits
elektor international media bv – 089018/uk
pagina 43
compile the program in the listing, whose click on program flash. After confirming pro-
purpose is to make all of the R8C/13 ports gramming, move the Mode switch up and
blink. press S1 (reset). With the help of an LED and a
Now you are fully equipped to better discover 1-kΩ resistor in series, verify the operation of
the possibilities of the R8C/13 module and to the R8C outputs one by one. If one of them
conjure up super applications from this mini- does not produce LED flashing, you should
mal configuration. verify the soldering.
The author, who contributed to a series of
Programming pages in the R8C section on the French
To program the module, all you need to do is Elektor site, has his own website at the fol-
to move switch S2 toward the bottom and lowing address:
press the pushbutton to reset the module.
Start the FDT Simple interface. In the menu, http://perso.wanadoo.fr/asnora/R8C/platine_de_
as an option, check Autodisconnect and Erase programmation.htm.
device before program. Load toggle_all.mot and (060125-1)
44
L
310 circuits
elektor international media bv – 089018/uk
pagina 44
+5V
R3 R5
C6
2k2
390k
10µ
C3 16V
T1
10µ
16V
TR1
T2
BF C2
256A
antenna input
DCF77 antenna
C5 DCF77 signal
C4 DCF77
10n
BC
L1 548C 1n 5...110p receiver
C1 R1 R2 R4 R6 module
220 Ω
4k7
82k
1M
Amidon
FT50-77
2x 57 turns, Ø 0.35mm
080248 - 11
selective preamplifier stage will usually im- a 77.5 kHz sine wave, is also very useful. This
prove the situation further. signal is fed, at an amplitude of a few milli-
The original ferrite antenna is desoldered volts, into the antenna input. With the oscil-
from the receiver module and connected to loscope connected across C4 and C5 to
the input of the preamplifier. This input con- monitor the signal on the output resonant cir-
sists of a source follower (T1) which has very cuit, trimmer C5 is adjusted until maximum
little damping effect on the resonant circuit. amplitude is observed.
A bipolar transistor (T2) provides a gain of It is essential that the transformer used is
around 5 dB. The output signal is coupled to suitable for constructing a resonant circuit at
the antenna input of the DCF77 module via a the carrier frequency. Our prototype used a
transformer. The secondary of the trans- FT50-77 core from Amidon on which we
former, in conjunction with capacitors C4 and made two 57-turn windings. It is also possible
C5, forms a resonant circuit which must be to trim the resonant frequency of the circuit
adjusted so that it is centred on the carrier by using a transformer whose core can be ad-
frequency. justed in and out. In this case, of course, the
An oscilloscope is needed for this adjust- trimmer capacitor can be dispensed with.
ment, and a signal generator, set to generate (080248-I)
Carlos Ferreira control all these devices, and more, with the
TV remote control.
Happens to everyone! You’re comfortably in-
stalled on your sofa watching TV and then all The circuit designed for maximum indolence
of a sudden you need to get up to turn the in front of the telly is built around the
lights on or off, or to draw the curtains. PIC16F84. The ’F84 was chosen mainly be-
cause of its internal EEPROM, which is neces-
Many living rooms these days have a double sary to store the user-programmable infrared
head-up ceiling light, a floor lamp and an elec- codes. To control such devices as mentioned
tric window/curtain control. The idea is to above, four relays are used, working together
45
R
310 circuits
elektor international media bv – 089018/uk
pagina 45
BC547A
ered by a 5-V regulated sup- +5V 1 2 3 +5V
+5V
K2
mA for microcontroller, IR
R4
4 6
MCLR RB0/INT 1k
7
sensor and LED.
RB1
17 IC1 8 BC547A
RA0 RB2
18 9 K3
RA1 RB3 +5V
1 10
consists in a frame of 14
1k
R1 1 5x10k
BC547A
bits. The first two bits, al-
R2
C1 4MHz C2
K4
+5V +5V
1k
46
L
310 circuits
elektor international media bv – 089018/uk
pagina 46
1-332050 050233-1
ROTKELE )C( 050233-1 (C) ELEKTOR
K4
D1
T4
D5
R2 RE4
IC2
R6
K3
T3
D4
IC1
RE3
C3 R5
X1 T2
D3
S1 RE2
R4
K2
T1
C1
C2
D2
RE1
R1
R3
K1
- +
75%
75%
Note that in RC5 speak a COMPONENTS LIST
logic ‘1’ is a transition from
0 V to Vcc, and logic ‘0’ is a Resistors T1-T4 = BC547
transition from Vcc to 0 V, R1= 5-way 10 kΩ SIL array
where the period of one bit R2-R6 = 1 kΩ Miscellaneous
X1 = 4MHz quartz crystal
is 1.7778 ms. Many articles Capacitors IC1 = PIC16F84, programmed,
on RC5 have appeared in C1, C2 = 22 pF order code 050233-41
Elektor Electronics. C3 = 100 nF (see Elektor Shop pages
or website)
The software developed for Semiconductors PCB, ref. 050233-1 from
the project is stored in the D1= LED, low current The PCB Shop
D2-D5 = 1N4148 Re1-Re4 = PCB mount relay,
PIC microcontroller. It al- IC2 = IR receiver module, e.g. 5V coil, 140mA
lows four different RC5 TSOP1836, SFH5110 or
codes to be saved and used TK1833
to control the four outputs.
47
R
310 circuits
elektor international media bv – 089018/uk
pagina 47
For example, your TV remote may be able to 2 Flip ON switch #5 (switch connected to
control five systems: TV (default), VCR, DVD, RA4/TOCK1) to enable programming
AMP, SAT. If, for example, you do not have mode. Using Table 1, set the other swit-
VCR then the relevant IR codes are available ches as required to save desired IR codes
for Easy Home Control. If your remote control in EEPROM.
is not compatible with RC5 codes, you can 3 Flip OFF switch #5 to select working
buy a cheap universal remote control to do mode. Using Table 2, configure the other
the job. switches to select the desired relay mode.
To avoid the relays changing state owing to a In working mode a fast-blinking LED (D1)
power cut in your home, the state of the re- means reception of IR codes with no associ-
lays is saved in the microcontroller EEPROM ated function; 1-second blink means pro-
and retrieved every time the PIC re-initialises. grammed IR code was received and
The actuation of electric curtains differs from corresponding action was performed. In pro-
lamps as it’s necessary to send a short pulse gramming mode, the 1-second blink means
to the relays. the IR code was saved in the microcontroller
EEPROM.
To make the home control more versatile it is
possible to control all relays (configurable by The assembly code file for the PIC used in this
the DIP switches) in one of two modes: project is available as a free download from
the Elektor Electronics website. File number
à toggle between ON and OFF positions 050233-11.zip may be found by clicking on
with memory for lamps; Magazine ÷ 2006 ÷ July/August.
à output pulse for other devices like electric
windows-curtains. The PIC is also available ready-programmed
from the Publishers as order code 050233-41.
If you’re a keen energy saver, it is also possi- (050233-1)
ble to program an IR code to turn off all the
relays (and save 5 V·140 mA = 0.7 watts per
relay). Warning
Screw contacts on K1-K4 and PCB tracks to the
The Easy Home Remote Control is configured relay contacts may carry the mains voltage.
as follows. All relevant precautions must be observed in re-
spect of electrical safety.
1 Switch the circuit on with all DIP switches
set to OFF.
48
L
310 circuits
elektor international media bv – 089018/uk
pagina 48
49
R
310 circuits
elektor international media bv – 089018/uk
pagina 49
10k
100k
is coupled in via the poten- LS a
C1a
tiometers. P1a
50k R4a
log 470µ
300 Ω 6V BT1
1k
C2 and R2 have a special
R2
4k7
purpose: C2 connects the u C2
1k
10µ
input signal) to the virtual P1b
50k
3V LS b
C1b
10k
100k
50
L
310 circuits
elektor international media bv – 089018/uk
pagina 50
IC2
7805
C1 C2
100µ 10µ
16V 16V
IC1 8
R2
5
BT1 MOSI/PB0
1 6
100k RST/PB5 MISO/PB1 R1
3 7
PB4 SCK/PB2
1k5
2
PB3
9V S5
S2
4
ATtiny13V
alarm wire S1
S3
R3 BZ1
green D2
100k
S6
S4
red
Another sensor connected to PB4 is an LDR on/off’. Of course, this does not turn the
(light dependent resistor). If the LDR is left in alarm on and off. On the right of the device is
a dark place (such as under a sleeping bag) the switch S2 with the legend ‘Speaker on/off’,
thief will trigger the alarm if he moves the bag which, naturally, does nothing of the sort. As
to expose the sensor to light. The resistance you have probably already guessed, the red
of the LDR is about 100 kΩ in the dark and and green buttons also have nothing to do
just a few ohms in the light. If only the light with arming or disarming the alarm.
sensor is to be used, the alarm wire (or reed
contact) socket can be shorted using a These decoys should be enough to annoy and
jumper. If the LDR is not to be used, it can delay all but the most resourceful of robbers.
either be (temporarily) taped over to exclude Naturally, once the alarm has been triggered
light from it or (more permanently) replaced by uncovering the LDR, it will not turn off
by a 100 kΩ resistor. again if the LDR is then covered.
A third sensor which can trigger the alarm is a The only way to disable the alarm is to set S1
vibration detector (S6), which is wired in se- and S2 in the correct positions (namely,
ries with a tilt sensor. The tilt sensor allows ‘Power on’ and ‘Speaker on’) and hold down
the vibration sensor to be disabled when the the two buttons simultaneously for five sec-
alarm unit is left upside-down. When the tilt onds. More complicated deactivation proce-
sensor contacts are open, PB1 cannot be dures can be programmed into the software,
pulled low and so no alarm can be triggered. in case you are worried that some light-fin-
The unit also features a number of push- gered Elektor reader (not that such a person
buttons and switches connected to PB2. The exists) will be able to steal your valuables af-
arrangement and labelling of these buttons ter having seen this article.
and switches is described below.
On the left of the device lies switch S1 with The circuit requires a supply voltage of be-
the (deliberately misleading) legend ‘Power tween 3.6 V and 5 V. In the circuit diagram we
51
R
310 circuits
elektor international media bv – 089018/uk
pagina 51
show a power supply made using a 9 V battery confirm that the device has woken up; after a
and a 5 V voltage regulator. brief delay of approximately three seconds
The ATtiny13 microcontroller belongs to the alarm is armed. This state is indicated by
Atmel’s AVR family, and can be programmed three flashes of the LED. While the alarm re-
using BASCOM. Source and object code files, mains in the armed state the LED blinks
including fuse settings, are available in a ZIP briefly once every few seconds.
archive that is available for free download When the alarm is triggered the red LED
from the Elektor website. The source code lights immediately. If it is not disarmed, the
can be modified to suit your own application alarm sounds after a short pause.
and then recompiled using the free version of
BASCOM. The software arranges matters so To disarm the unit, both switches again need
that the processor enters sleep or power- to be in the ‘on’ position as described above
down mode when the alarm is correctly deac- and both buttons must be pressed. After a
tivated; there is no other way to turn the de- double flash, whether the LED is on or off in-
vice off. To wake the device up the switches dicates whether the buttons must then be
must be set correctly (both to ‘on’) and the pressed again or not.
unit shaken briefly. The LED blinks twice to stefankhoffmann@yahoo.de (080135-I)
52
L
310 circuits
elektor international media bv – 089018/uk
pagina 52
In our case this results in: 25% with an LCD that itself draws a current of
293 1.2 mA. In a battery powered application this
R1 = 227 × 10 -6 ´ = 333 Ω is definitely worth the effort! In addition, the
200 × 10 -6 contrast does not need to be adjusted as the
Note that the current supplied by the LM334 battery voltage reduces.
depends on the temperature. This is also true
for the current from the display, but it is not When used with LCDs with new technologies
strictly necessary to have a linear relationship such as OLED and PLED it is advisable to care-
between these two. Temperature variations fully test the circuit first to determine if it can
of up to 10° will not be a problem however. be used to adjust the brightness.
This circuit results in a power saving of over (060091-1)
Burkhard Kainka
+300V
If you are the proud owner
of an old oscilloscope tube,
you may be interested in
using it once more for its
original purpose. All you
need are the right voltages
6V3
on the right pins: in practice
you may need to peer P1
1M
known provenance. C2
53
R
310 schakelingen
elektor international media bv – 089018/nl
pagina 53
nected capacitor reaches the strike voltage of be able to see the waveform on the screen. It
the lamp, it is discharged with a brief pulse of must be admitted that the design’s sensitiv-
current. It is hard to imagine a simpler way to ity, linearity, trace size, bandwidth and trig-
generate a sawtooth waveform. gering facilities leave a little to be desired.
The supply voltage of 300 V is adequate for Nevertheless we have shown how little cir-
simple experiments, even if the tube is rated cuitry is required to make a real working os-
for operation at 1000 V or even more. Now, if cilloscope.
a signal is applied to the Y input, we should (080386-I)
+15V
IC1 IC4 IC6
+U IN LM317 R1 7815 7805 +5V
adj. R3
C1 C4 C6 C8
100n 100n
C3 IC3
100p
adj.
LM317 R4
P1
C2
C5 C7 C9
R5
100n
100n
adj. R2
54
L
310 circuits
elektor international media bv – 089018/uk
pagina 54
The circuit shown produces outputs at ±15 V voltage drop is achieved using an extra cur-
and ±5 V. rent of 10 mA. The current limit now is adjust-
able till (almost) 0 A. If the current in this
The voltage regulators at the outputs (7815/ branch is reduced to zero, the current limit
7805 and 7915/7905) need no further com- will be 1 A.
ment; but the current-limiting circuit itself,
built around an LM317 and an LM337, is not For the negative branch of the circuit the
quite so self-explanatory. The upper LM317 LM337, along with resistors R2 (1.2 Ω) and R5
(IC1) manages the current limiting function (120 Ω), performs the same functions.
for the upper branch of the circuit. The clever
part is the combination of the two resistors A further LM317 (IC3) is used to set the over-
R1 and R3 between the output and the adjust all current limit point by controlling the addi-
input of the regulator. tional current. The resistance used with this
voltage regulator, wired as a current sink (R4
In the basic LM317 configuration in current- in series with P1) determines the additional
limiting mode (i.e., as a constant current current and therefore also the output current
source), just one resistor is used here, across in both the negative and positive branches of
which the regulator maintains a constant the circuit. Since we also want the total resis-
voltage of 1.25 V. The current is thus limited tance of R4 and P1 to be 120 Ω, we use a
to a value of 1.25 V/R. To obtain a maximum value of 22 Ω for R4 and 100 Ω for P1 to give a
current of 1 A, for example, the formula tells wide adjustment range for the output current
us that the necessary resistor value is 1.25 Ω. from a few milliamps to 1 A.
Unfortunately it is not practical to try to build
an adjustable dual-rail current-limited supply The minimum input voltage for the circuit de-
in this way, as stereo potentiometers with a pends on the desired output voltage and max-
value of 1.2 Ω are extremely difficult, if not imum output current. The input to the 7815
impossible, to obtain. should be at least 18 V. We should allow ap-
proximately a further 1.2 V + 2.2 V for the
We can solve the problem using the tech- voltage drops across IC1 and R1. If we allow a
nique of dividing the resistor into two resis- total of 4 V for the current limiting circuit in
tors. Only the resistor at the output of the each branch, this means that the circuit as a
LM317 (R1) serves for current sensing. The whole should be supplied with at least ±22 V
second resistor (R3) causes an additional volt- to produce well-regulated outputs at ±15 V
age drop depending on an additional (and ad- and ±5 V.
justable) current. When the sum of the two
voltages reaches 1.25 V current limiting cuts If the symmetrical input voltage is to be pro-
in. This makes it possible to adjust the cur- vided using a single transformer winding, two
rent limit smoothly using the current in the diodes and two smoothing capacitors, it im-
second resistor (R3). This can be done simul- portant to ensure that the capacitor values
taneously in the positive and negative are sufficiently large, as there will be consid-
branches of the circuit, as the diagram shows. erably more ripple than there would be with
full-wave rectification. Depending on the
It would of course be wasteful to arrange for application, capacitors C6 to C9 at the out-
the current flowing in the second resistor to puts of the fixed voltage regulators can be
be of the same order of magnitude as the cur- electrolytics with a value of 4.7 µF or 10 µF.
rent in the main resistor. We therefore make
the value of the second resistor considerably To improve stability, electrolytic capacitors
greater than that of the main one. If the main can also be connected in parallel with C1, C2,
resistor (R1) has a value of 1.2 Ω (giving a C4 and C5.
maximum current of 1 A), and the second re- (060123-1)
sistor (R3) a value of 120 Ω, the necessary
55
R
310 circuits
elektor international media bv – 089018/uk
pagina 55
Ludovic Mézière
1
If we were looking for a slo-
gan to sell this project in
some mailorder catalogue,
we might well have chosen
the slogan “16 Million Col-
ours under Water in Your
Swimming Pool” as its sub-
title. In just a few months,
we’ve seen increasingly ‘vis-
ible’ applications for (high)
power LEDs. After all, was it
not Philips that paid for the
illuminations on some of
the most famous avenues in
the world?
Circuit
A quick glance at the circuit might make us
wonder if the designer hasn’t forgotten
something, given the excellent ‘readability’ of
the electronics employed.
A microcontroller and no less than three
strips of ten or so LEDs, each with its own
dropper resistor. Each strip is driven by a
transistor, and there you have all the ingredi-
ents of this recipe.
56
L
310 circuits
elektor international media bv – 089018/uk
pagina 56
3
+5V +5V D2 ... D11 = red
D2 D3 D4 D5 D6 D7 D8 D9 D10 D11
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10
6Ω8
6Ω8
6Ω8
6Ω8
6Ω8
6Ω8
6Ω8
6Ω8
6Ω8
6Ω8
+5V +5VMCU
D1
1N4004 C2 C1 D
T1
1000µ 16V 10n
G
S IRFI540NPBF
40
+5V +5V D12 ... D21 = green
39 1
PA0 PB0
38 2
PA1 PB1 D12 D13 D14 D15 D16 D17 D18 D19 D20 D21
37 IC1 3 +5VMCU
PA2 PB2
36 4 K2
PA3 PB3
35 5 1 2
PA4 PB4
34 6 3 4 R12 R13 R14 R15 R16 R17 R18 R19 R20 R11
PA5 PB5/MOSI
33 7 5 6
6Ω8
6Ω8
6Ω8
6Ω8
6Ω8
6Ω8
6Ω8
6Ω8
6Ω8
6Ω8
PA6 PB6/MISO
K1 32 8 7 8
PA7 PB7/SCK
9 10
30 ALE 9
RESET
31 29 D
ICP OC1B
T2
AT90S8515P
21 10 G
PC0 PD0
22 11
PC1 PD1 S IRFI540NPBF
23 PD2 12
PC2
24 PD3 13
PC3 +5V +5V D22 ... D31 = blue
25 14
PC4 PD4
26 15 D22 D23 D24 D25 D26 D27 D28 D29 D30 D31
PC5 PD5
27 16
PC6 PD6
28 17
PC7 PD7
XTAL1 XTAL2
R21 R22 R23 R24 R25 R26 R27 R28 R29 R30
19 20 18
6Ω8
6Ω8
6Ω8
6Ω8
6Ω8
6Ω8
6Ω8
6Ω8
6Ω8
D 6Ω8
T3
G
S IRFI540NPBF
071037 - 11
the presence of three PWM drivers in the The spot draws a whopping maximum cur-
same package, as well as by its very affordable rent of nearly 10 amps a t 5 V , meaning that a
price and excellent availability. The board has powerful PSU is needed.
an ISP connector (In System Programming), Building one yourself would turn out expen-
K2, to allow for future software updates. sive. So the solution to this cost issue is to opt
The three PWM outputs drive type for a PC PSU module, which usually has no
IRFI540NPBF MOSFET transistors T1–T3, problems providing some 30 A at 5 V, for only
which have a power dissipation rating that’s a modest sum. And there you have it – every-
easily sufficient for this application. You may thing has been said that needs to be about
like to fit them with a small heatsink, which the electronics employed.
will be enough to dissipate the small amount The aspect we’re going to tackle in the next
of heat produced by the transistor switching. paragraph is very important, given its implica-
These transistors each drive ten or so LEDs. tions…
57
R
310 circuits
elektor international media bv – 089018/uk
pagina 57
Construction
As shown in the introduc- 4
tory photo, the whole of the
electronics fits onto a pair
of printed circuit boards.
58
L
310 circuits
elektor international media bv – 089018/uk
pagina 58
59
R
310 circuits
elektor international media bv – 089018/uk
pagina 59
60
L
310 circuits
elektor international media bv – 089018/uk
pagina 60
100k
The author uses a standard computer crystal
of 10 MHz. Depending on the setting of C3,
the circuit provides a stable output at fre-
quencies between 50 and 70 MHz. It should R3
3
7
8 3f, 5f, 7f
be noted that these frequencies are multiples
330 Ω 1
IC1
of the series fundamental frequency of the 2
6
crystal. 4
10 Ω
100k
ting of C3 is not critical. When tuning is com-
pleted, the output frequency is crystal-stable. 10n
61
R
310 circuits
elektor international media bv – 089018/uk
pagina 61
FTDI TTL-RS232
5 T-RXD 10 7 TXD 3
T2IN T2OUT
Elektor website). 4 T-TXD 12
R1OUT R1IN
13 CTS 8
3 T-CTS 9 8 4
R2OUT R2IN
62
L
310 circuits
elektor international media bv – 089018/uk
pagina 62
Downloads
To finish off, you can protect the whole thing
The PCB artwork for the board is available for
by slipping it into a piece of heatshrink free download from our website
sleeving of suitable diameter. (www.elektor.com); file #080470-1.zip.
(080470-I)
Hermann Sprenger
3M3
3k3
63
R
310 circuits
elektor international media bv – 089018/uk
pagina 63
Uc = U - Uo = U × (1- A)
060075 - 11
Substituting into the formula the current that
flows through a capacitor, Ic = C⋅(dUc /dt) re-
sults in necessary to prevent R1 from appearing in
dU(1- A) parallel with C m and affecting the corner fre-
I =C× quency. A2 is the actual (inverting) amplifier.
dt The gain of A2 is equal to P1/R1. C is the ca-
We rearrange this as pacitor which is enlarged artificially. The re-
dU maining components only serve to set the
I = (1- A) × C × operating point of the circuit. C b blocks any
dt DC voltages and needs to be relatively large,
Now we can see that the gain determines the for example 25 times the maximum Cm.
relationship between I and C. C appears to be From the test results it appears that Cm is in-
larger by a factor of (1–A) (note: if A is nega- deed equal to (1+P/R1)⋅C. C m can be varied
tive, you can actually speak of a factor 1+A with a potentiometer from about 560 pF to
larger). 12 nF.
This is called the Miller effect. The apparent As is usually the case, there are a few limita-
(larger) capacitance is called the Miller capaci- tions in practice. The input signal may not be
tance. When designing signal amplifiers you too large. Otherwise, the AC voltage across
need to take this capaci-
tance into account. We can 2
actually use this Miller ca- +Ub
pacitance in other ways. If C1
we make A variable, with an R2
adjustable resistor for ex- 560p
100k
quency. JFET-opamp A1 is
64
L
310 circuits
elektor international media bv – 089018/uk
pagina 64
Cm will cause clipping at the output of the For LF applications we could also use a dual
second opamp. At maximum Cm, the gain of opamp for A1 and A2, such as the TL082.
A2 is about 20 times. The peak-to-peak value The value of capacitor C can be changed to
of the input voltage may therefore not be suit the application. With opamps of the type
more than about 1/20 of the power supply AD8099 with a C of 22 pF we can make a
voltage. The circuit will always work well for (tuning) capacitor with a value from 22 to
smaller signals, provided the frequency is not 440 pF, for use up to 30 MHz. The alternative,
too high. a varicap diode that can be varied in capaci-
For A1 and A2 we used an LF356 and TL081 tance over a range of 20 times (or more) is not
respectively. These are mainly used for fre- used in practice very much any more. Other
quencies not exceeding 100 kHz. Very fast applications for this circuit are, for example,
JFET opamps could extend the useful fre- adjustable LC-filters for audio applications.
quency range to applications in the RF-range. (060075-1)
OUTSIDE INSIDE
+12V
R1 R2 R9 P3 R13 R14
8 8 14
10k
27k
10k
3k3
3k3
10k
IC2 IC3 IC4
4 4 7 20 °C
R11
100k
LM335
3 IC4.A
R6 R7 1 IC4.B 0 ... 20 °C
1 3 5
100k 100k IC3.A 2 ≥1 4
2 6 ≥1
R3
3
100k
1 5
R4 IC2.A
2 7 6 IC4.C IC4.D 0 °C
100k IC2.B 8 12
6 7 10 11
IC3.B 9 ≥1 13 ≥1
5
10k
100k
P1
10k
10k
LM335
060088 - 11
UT UT - 2.62 V UT UT x 26.6 V
65
R
310 circuits
elektor international media bv – 089018/uk
pagina 65
the second case you can open the windows Next, we use two of the comparators in IC3 to
and switch off the heating. You can adjust the determine whether the outside temperature
switchpoint temperatures to suit your is below freezing or above 20 °C. IC3a and P3
wishes. provide the setpoint for around 0 °C, while
IC3b and P2 do the same for 20 °C. As it is a bit
The output of the LM335 provides a potential difficult to precisely set P2 and P3 in practice
of 10 mV/K. You can obtain the temperature (you would have to wait until it is 0 °C or 20 °C
in °C by subtracting 273 from the output outside), you can initially set them to the cal-
value. For example, at an output voltage of culated values (2.93 V for P2 and 8.26 V for
2.98 V the temperature is 25 °C (298 – 273). P3). You can adjust the settings later on if the
switchpoints differ too much from the de-
In this case, we only need to be able to mea- sired temperatures.
sure over the range of –5 °C (2.68 V) to +25 °C
(2.98 V), which is a span of only 0.3 V. Conse- Finally, four NOR gates are used to derive
quently, we first expand this range using two three switching signals from the two output
of the opamps in IC2. signals. These switching signals can be used
to drive three LEDs (for example) to indicate
A reference potential of exactly 2.62 V is set which range the temperature lies in. You
using P2. IC2a compares the output voltage should preferably use low-current LEDs to
of IC1 with the reference potential and passes avoid overloading the CMOS gates, and con-
the difference on to IC2b. The combination of nect each of them to ground via a 3.3-kΩ re-
IC2b, R7 and R8 forms a gain block that ampli- sistor. It’s a good idea to place the left part of
fies this signal by a factor of 27. As a result, the circuit (up to and including IC2b, R7 and
the output voltage over the temperature R8) indoors and the right part outdoors. An
range of approximately –10 °C to +30 °C is interconnecting cable of 10 metres will not
mapped into a voltage range of approxi- present any problems. However, you should
mately 0 V to +11 V. connect a 100-µF, 16-V capacitor across the
supply voltage on the outdoor circuit board.
Bear in mind that the indicated voltages can In principle, you could also use an LM358 in
vary slightly due to tolerances in the resistor place of the LM258, but its operation is not
values. Also be sure to use a stabilised 12-V guaranteed by the manufacture at tempera-
supply, because any fluctuations in the supply tures below 0 °C.
voltage will also be amplified by IC2b. (060088-1)
66
L
310 circuits
elektor international media bv – 089018/uk
pagina 66
33 Ω
68 Ω
actly.
D1 D2 D3
How can such simple cir-
BT1
cuitry represent such a
formidable opponent? As
4V5 already mentioned, the path
from the start to the goal is
R3 R4
D4 D5
33 Ω
2x socket has an associated
1N4148
ideal next move.
There are three possibili-
2 3 1
ties, of course: 1, 2 or 3. As
S1 you can see from the sche-
matic diagram, switch S1
080130 - 11
closes the circuit (which
means the player asks the
‘computer’ how many steps
it wishes to move) if the
probe is touching one of the
sockets. All 30 sockets are
classified into three types,
D1 D2 D3
represented in the sche-
2 1 3 1 2 matic diagram by one
socket for each type.
3 2 3 1 3 All sockets belonging to a
particular type are simply
2 1 1 2 connected together electri-
cally, which is not shown on
3 1 1 2 3 the schematic diagram for
the sake of clarity.
2 3 2 3 1
This is how the LED display
1 1 1 1 1 works: the player touches
the right-hand contact with
R4 (only LED D3 lights up),
S1
the left-hand contact with
080130 - 12
R3 (LEDs D1 and D2 light
up), or the middle contact
with diodes D4 and D5 (all
three LEDs light up). The
starting position is at the bottom right, and two diodes prevent all three LEDs from light-
the goal is in the middle of the playing area. ing up if the player touches the left-hand or
The electronics becomes the ‘active player’ righthand contact.
when the button is pressed. The number of
steps it wants to move is shown by three LEDs The key to all this lies in the assignment of the
(one, two or three LEDs light up) at the top of 30 sockets to the three types of logic, which
the playing area. Naturally, the human player means the three types of ideal next move.
67
R
310 circuits
elektor international media bv – 089018/uk
pagina 67
Working backward from the goal, no further The correct response of the ‘computer’ is
move is possible when the goal is reached. shown in Figure 2 by the number next to each
For this reason, the last socket is not con- position. As the two opponents take turns
nected to anything. At the socket just before playing, the electronics always tries to arrive
the goal, the ‘computer’ naturally wants to be at a strategically favourable position (marked
exactly one step in front. Consequently, this by the arrows). If the electronics manages to
socket is connected to R4. At the second reach one of these positions, it’s impossible
socket before the goal, the electronics wants for the human player to win.
to move by two steps. This socket is thus con-
nected to R3. Obviously, three moves before This means that the human player can only
the finish, a threestep is best as it leads to in- win by starting first and always making the
stant victory. Consequently this socket is con- right move.
nected to D4/D5. (080130-1)
68
L
310 circuits
elektor international media bv – 089018/uk
pagina 68
The circuit is build around a trio of standard lengths in three different decades, namely: 1 /
logic ICs. Firstly a 74HC4060 (IC1) is used to 2 / 4 / 10 / 20 / 40 / 100 / 200 / 400 ms.
provide a quartz crystal accurate reference With jumper J1 you select a frequency of
for the duration of the pulses. For the crystal 1000, 500 or 250 Hz (see table). The fre-
frequency we choose the common 4.096 MHz quency is then passed on to J2 and the dual
value. To test all the ranges of the shutter decade counter IC2 (a 4518). This does not
time meter, we choose three different pulse need to be a fast HC-type, since the frequency
+5V
S1
C4 16 C5 IC2 = 4518
IC2
100n 100n C6
8
IC2.B
R3 100n
CTRDIV10 C3
10 11
1M
E ≥1 0
9 + 12
IC1 16 C 1 10n IC3 16
13
2 3
7 15 14 R4 0
CTR14 3 CT=0 3 CTRDIV10/ 2
5 1
10k
4 DEC 4
11 !G 4 2
RCX 5 15 7
9 6 CT=0 3
R2 CX + 6 10
10 14 4
1M RX 7 IC2.A 1
R1 CT 13 5 R5
8 CTRDIV10 5
J1 J2 6
180 Ω
15 2 3 13
1k
9 E ≥1 0 & + 6
X1 1 2 1 1 + 4 1 2 7
11 C 1 9
12 2 4 3 5 3 4 14 8
CT=0 12 2 11
3 6 5 7 6 5 6 9
13 CT=0 3 12 D1
4,096MHz CT≥5
C1 C2
8 8 HSDL-4230
74HC4060 74HC4017
33p 33p
064006 - 11
69
R
310 schakelingen
elektor international media bv – 089018/nl
pagina 69
C6 J2 C5 J1 C4
+
IC3
IC1
0
ROTKELE )C( 1-600460
R2
R1
064006-1
D1 R4 X1
R3 S1
C2
C3
C1
100%
100%
70
L
310 circuits
elektor international media bv – 089018/uk
pagina 70
If necessary, the pulse lengths can be circuit is delivering a pulse, the current con-
changed be selecting another crystal fre- sumption increases briefly to about 18 mA.
quency. Do not forget the wire link under IC2 when
The current consumption in the idle state is assembling the circuit.
less than 2 mA. In our prototype, while the (064006-1)
+U
R1
1M
CTR7 12
0
IC1.A 11
1
1 2 1 9 T3 T4
1 + IC2 2 D1
6
CT 3
C1 5
4 1N4148
2 4 IC1.E IC1.C
CT=0 4024 5 R2 BUZ171 BUZ171
100n 3 11 10 5 6
6 1 100k 1
3
IC1.B C2
K2
1 10n
4
D2
+U
1N4148
IC1.D
R3 D3
9 8
100k 1
14 C5 14 C6
C4 T1 T2
IC1 IC2
7 100n 7 100n
10n
BUZ11 BUZ11
+U
IC1 = 40106 T5
R4 R6 R8 BUZ11 R7
F1 +U 8
47k
2k2
K1
1M
160k
BT1
1A6 IC3 2
HYST
3 IC1.F
C3 THRESH D4
4 13 12
6V R5 OUT 1
100n ICL8211
1N4148
47k
060179 - 11
71
R
310 circuits
elektor international media bv – 089018/uk
pagina 71
A second experiment was done based on a placed inside the square. Nothing happened
home-made design: Square pieces of PCB ma- at first: the slugs sleep during the day. At the
terial of 5×5 mm were glued on the four cor- fall of dusk they started to move and they
ners of a large printed circuit board. Copper appeared to be able to escape the square
wire with a diameter of 1 mm was soldered without effort. They did this by stretching
on the little squares so that the surface of the themselves out at a right angle and bypass the
PCB was completely enclosed. A voltage of 6 V copper wire without touching it. This was ob-
was applied to the copper wire. This worked viously not a good solution.
much better. Two slugs that acted as guinea
pigs stayed the entire night on the PCB. They Therefore, another, new construction was re-
were, despite the rain, not able to beat the quired.
electronic obstacle. Unfortunately, by the
morning the copper wire was already badly The solution was found by suspending the
oxidised. wire outside the tin sheet, at a distance of
about 5 mm. The slugs are then unable to
The search was now on for a practical me- pass without touching the wire and water
chanical construction for this system in the droplets hang straight down from the wire
garden. Moreover, AC has to be used for the where there is no tin sheet. The wires are
power supply to limit the corrosion. The first again soldered to small PCBs, which are
choice was an L-shaped tinplate profile of screwed to the tin sheet angle profile. For this
12×165 mm. The long side of the metal was purpose a hole of 3.2 mm diameter was
pushed deep into the ground to prevent the drilled in the tin sheet every 15 cm. First, the
slugs from crawling underneath. Every 15 cm PCBs are screwed to the tin profile, the profile
small pieces of PCB of 10×10 mm were glued is placed in the garden and bent into the cor-
on top (250 pieces in total), with the copper rect shape to enclose the strawberry field.
wire soldered on top of that. The distance be- The final step is to attach the wire to the
tween the tin sheet and the copper wire was PCBs. During assembly, it is wise to keep a
about 1.5 mm. The results were excellent: not conduction tester at hand and check fre-
a single slug dared to cross the barrier. They quently for short circuits. The smaller the dis-
crawled up to the copper wire and then tance between the wire and the tin sheet, the
turned back. better it works, even against small snails, but
as the distance is decreased, the risk of short
Except, this barrier does not work against fly- circuits is increased.
ing slugs. Flying slugs? Certainly! These are
the slugs that the neighbour finds in his gar- This installation has proved itself in a practi-
den and throws across the fence. cal experiment lasting two years. During this
time it functioned without problems and
After a few months, it was noticed that the keeps slugs out of the vegetable garden.
battery was exhausted quite quickly and
there was also some corrosion. Measure- The AC voltage power supply consists of a
ments indicated that during heavy rain the clock generator, a driver stage in bridge con-
current could increase to about 1 A because figuration and an under-voltage detector. The
of droplets on the copper wire. So, another clock generator is formed by R1, C1 and IC1a.
solution was required. The wires had to be No great demands are placed on the clock cir-
suspended, just like the overhead conductor cuit, except one: Only when the duration of
of a tram. the positive voltage is exactly identical to the
duration of the negative voltage is the corro-
In the next experiment, a square of 1×1 m sion of the wires effectively suppressed. That
was surrounded by a slug barricade where the is why IC2 divides the generated frequency by
wire was fastened on the underside of the two and in this way guarantees a duty-cycle of
horizontal piece of tin sheet. Ten slugs were exactly 50%.
72
L
310 circuits
elektor international media bv – 089018/uk
pagina 72
The buffer stages are built around IC1b, c, d faster. In addition, transistor T5 will block, so
and e and provide for a small delay in the that no voltage is applied to the slug barrier
drive signal for the driver stage. This prevents any more. This is only necessary if the circuit
that T1 and T3, and T2 and T4 respectively are is powered from a rechargeable battery. If or-
driven simultaneously. Otherwise the current dinary batteries are used to power the circuit,
consumption of the circuit is too high. The T5 can be omitted and replaced with a wire
circuit alternately turns on T1 and T2 at the link. With a battery power supply it is also a
same time, or T3 and T4. In this way, a square good idea to connect a switch in series with
wave AC voltage of 12 Vpp is generated at the the LED, which is then only turned on when
output. checking the battery voltage. This improves
the life expectancy of the battery. This re-
IC3, an ICL8211, provides the under-voltage duces the current consumption from 1.5 mA
protection. The LED flashes slowly while the to 0.4 mA. During damp weather the current
battery is in good condition. When the volt- consumption increases considerably.
age becomes too low, the LED will flash (060179-1)
Thierry Duquesne
Displaying longitude and latitude information
GPS has many other applica- There are three possible formats for displaying longitude and latitude
tions than just satnav in cars data:
and other vehicles. It can
also be used, for example, à ‘GPS co-ordinates’ format (degrees, minutes, and fractions of minu-
to note the position of a ‘se- tes) e.g.: 36°35.9159
à ‘DDMMSS’ format (degrees, minutes, seconds) e.g.: 36°35 54.95
cret spot’ for finding wild à ‘decimal’ format e.g.: 36.5986°
mushrooms out in the
woodlands near your holi- The author normally uses the ‘GPS co-ordinates’ format display
day chalet in Southern
France…
73
R
310 circuits
elektor international media bv – 089018/uk
pagina 73
(£ 65 or so) and the weight, the receiver de- tional, while waiting for the European Galileo
scribed here is also interesting because of its system. Set up by the US Defense Department
powering, since it operates from just a simple in the 1960s, the system allows a person
9 V battery, unlike commercial receivers that equipped with a receiver for the GPS frames
use a special built-in battery that’s usually not to find out their position on the surface of the
removable. Earth. The first experimental satellite was
launched in 1978, but the constellation of 24
Lastly, the system can very easily be incorpo- satellites only really became operational in
rated into a mobile object like a robot etc. 1995.
LC DISPLAY LM016L
9V D1 C2 C4 C3
VDD
VSS
R/W
VO
RS
D0
D1
D2
D3
D4
D5
D6
D7
E
470n 470n 100µ
1N4007 16V 1 2 3 4 5 6 7 8 9 10 11 12 13 14
+5V
R1
1k5
PGD
PGC
+5V
C1
R2 100n
10k
S2 Mode 20
J2
1 21
MCLR MCLR RB0/INT
22
PGD IC2 RB1
2 23
PGC RA0 RB2
3 24
GND RA1 RB3
4 25
ICD-2 RA2 RB4
+5V programming 5 26
RA3 RB5
i/f
6 27
RA4 RB6/PGC
7 28
2 RA5 RB7/PGD
PIC16F876
11
RC0
M1 3 12 14
SIO RC1 RC3
4 13 16
RAW RC2 RC5
GPS 17 15
receiver RC6/TX RC4
18
RC7/RX
1 J3 OSC1 OSC2
TXD 8 9 10 19
X1
RXD
GND
R3
PC comms C5 C6
10k
(hyperterminal)
22p 20MHz 22p
080238 - 11
74
L
310 circuits
elektor international media bv – 089018/uk
pagina 74
arrive, it is possible to calculate the distance if this is not the case, it takes four satellites to
between satellite and receiver. To measure be able to resolve the clock issue and receive
the time taken by the wave to reach it, the the data correctly.
GPS receiver compares the transmission time
(included in the signal) and reception time of A GPS can operate anywhere, just as long as it
the wave transmitted by the satellite. If the has an unobstructed view of the sky, 24 hours
receiver has a clock that is perfectly synchro- a day, 7 days a week. However, it’s important
nized with that of the satellites, three satel- to be aware that the position data may be in-
lites are enough to determine the position in correct in the presence of electromagnetic in-
three dimensions by triangulation. However, terference.
75
R
310 circuits
elektor international media bv – 089018/uk
pagina 75
$GPGGA,170834,4124.8963,N,08151.6838,W,1,05,1.5,280.2,M,-34.0,M,,,*75
$GPGSA,A,3,19,28,14,18,27,22,31,39,,,,,1.7,1.0,1.3*34
$GPGSV,3,2,11,14,25,170,00,16,57,208,39,18,67,296,40,19,40,246,00*74
$GPRMC,220516,A,5133.82,N,00042.24,W,173.8,231.8,130694,004.2,W*70
These strings of characters can be exploited satellites and adversely effect its operation
to extract the wanted information, including and performance. The acquisition time for a
for example the time, date, latitude, longi- minimum of four satellites may take up to five
tude, altitude, speed and direction of move- minutes.
ment, and even the number of satellites being In the application described, we’re going to
received or the validity of the received data. be using the GPS module in ‘smart mode’.
The GPS receiver used is based on the inte-
grated module offered by Parallax Inc. from Electronics
the USA (or their local distributors). Taking a look at the diagram, we can see that
Its principal characteristics are as follows: our receiver revolves around a PIC16F876A
microcontroller from Microchip Technology.
à Reception of up to 12 satellites Amongst its other tasks, it takes care of the
transcoding and dialogue between the Paral-
à Data updated once per second lax GPS receiver and the LCD display.
It’s worth noting that the circuit has been de-
à 2 operating modes: signed with two operating modes: you can
Smart Mode: when the RAW pin is opencir- either display just the geographical coordi-
cuit (internally pulled up to logic high), nates of latitude and longitude, or scroll
the default ‘Smart Mode’ is enabled. In through a whole mass of information (re-
this case, the commands for receiving the ceived frame validity, number of satellites
special GPS data can be executed and the received, date, GMT, altitude, latitude, longi-
result returned. Each command is repre- tude, and so on).
sented by one hexadecimal byte. Depen-
ding on the command, a certain number Powering is by way of a simple 9 V dry battery
of data bytes will be returned. To send a (or rechargeable), which connects to terminal
command to the GPS receiver module, the block JP1. The 5 V supply voltage is generated
user must first send the header characters by IC3, a 7805 regulator. Connector J3 allows
‘!GPS’ (obviously without the quotes) fol- dialogue with a PC via an RS-232 link (make
lowed by the specific command of their provision for interfacing with a MAX232),
choice (for example, 0x02 to obtain the while connector J2 allows programming of
number of satellites being received) – in the PIC and in-circuit debugging thanks to the
this instance, the receiver module would ICD2 marketed by Microchip.
return one byte of data with the number
of satellites. The on/off switch S1 connects to the S1 termi-
Raw Mode: When the RAW pin is forced nal block on the board, the mode selection
low, the ‘RAW Mode’ is enabled, the mo- switch connects to the adjacent S2 terminal
dule can then transmit the characters of block.
the standard NMEA 0183 frames (GGA,
GSV, GSA, and RMC), making it possible to PCB
use the raw GPS frames directly. It only takes a few minutes to build this circuit
using the circuit board suggested here. The
Certain devices, like engines, computers, and first step consists of soldering the small num-
Wifi links, emit magnetic fields and interfer- ber of wire links, then the resistors, IC socket,
ence that can prevent the module from re- unpolarized capacitors, and then the electro-
ceiving the required signals from the lytic capacitors, taking great care to observe
76
L
310 circuits
elektor international media bv – 089018/uk
pagina 76
+U LOGIC
+5V...+12V
* see text
L1
T1
TRI1 * TIC206D
2x MT2
1N4148
BC547 D1
G MT1 TRI2
C1 R1 2x MT2
470 Ω TIC206D
D2
47µ G MT1
16V
T2 R2 R3
MT1 G
10k
10k
MT2
BC557
050155 - 11
77
R
310 circuits
elektor international media bv – 089018/uk
pagina 77
If the input is set low, a negative current flows The TIC206D can handle several ampères, so
briefly via C1. It can flow through D2, but not it can easily drive just about any type of turn-
through D1. T4 is switched on now, and the out coil.
other turnout coil is energised. This circuit
takes advantage of the fact that triacs can be You can also use a different type of triac if you
triggered by negative as well as positive gate wish. However, bear in mind that the TIC206
currents. requires only 5 mA of gate current, while
If the turnout coils are energised for too long, most triacs want 50 mA. That will cause the
you should reduce the value of C1. If they are switching times to become quite short, so it
not energised long enough, increase the may be necessary to reduce the value of R1.
value of C1. (050155-1)
78
L
310 circuits
elektor international media bv – 089018/uk
pagina 78
F1 D1
TR1
R1 R2 R4
100mA 50V 5A
820 Ω
680 Ω
1k2
18V
1W 1W 1W
230V
LED1 LED2
*
THY2
18V
ON CHARGED D4
S1 D2
1N4004
50V 5A R6
THY1
TIC106D *
D3 R5
1k
*
6V8
see text 400mW F2
5A
+BATT
R3 P1 BT1
C1 D5
10k
12V
22µ
25V
1N
4k7 5402
080224 - 11 –BATT
high enough, THY1 is triggered and thus pre- with P expressed in watts and R6 in ohms, of
vents THY2 from being triggered. This phe- course.
nomenon is not in fact quite as clear-cut as we
have just described, but takes place very pro- Thyristor THY2 should be a 100-V type (or
gressively, so as it approaches full charge, the more) rated at 1.5 to 2 times the desired max-
battery’s average charging current gradually imum charging current.
reduces automatically, eventually stopping And lastly the transformer, which should have
completely once the fullycharged voltage has a power in VA given by:
been reached.
LED1 acts as a charging indicator, while LED2 P = 18× 12
. ×I
lights more when THY1 is being triggered fre-
quently, thereby acting as a fully charged indi- where I is the maximum desired charging cur-
cator. rent, expressed in amps.
Three components of the circuit proposed The only adjustment to be made concerns pot
here need to be selected according to the P1 and will require access to a wellcharged
characteristics you want your charger to battery. Connect it to the charger output and
have; these are R6, THY2, and TR1. R6 needs replace the 5-A fuse with an ammeter – pref-
to be calculated according to the maximum erably an old analogue type, better able to re-
charging current you want, from: R6 = 16 / I spond to average currents than certain
where I is the current expressed in amps. modern digital types. Then adjust potentio-
Warning! Given the value of the other ele- meter P1 to obtain a current of around 100 mA.
ments in the circuit (D1, D2, TR1, and the Later on, when you have the opportunity to
fuse), do not exceed 5 A. The power dissi- charge a very flat battery, you will be able to
pated in R6 can be calculated from fine-tune this adjustment by tweaking P1 to
36 obtain a charging current close to the maxi-
PR6 = mum you have set by means of R6. You’ll need
R6 to find a compromise setting between the
79
R
310 circuits
elektor international media bv – 089018/uk
pagina 79
float charging current, which mustn’t exceed treated better by this project than by many of
around 100 mA, and this maximum current. its non-electronic counterparts to be found in
Whatever the accuracy of your adjustment, the shops.
you can be reassured that your battery will be (www.tavernier-c.com) (080224-I)
Ton Giesberts
TERMPWR_B
GND_B
064007 - 11
80
L
310 circuits
elektor international media bv – 089018/uk
pagina 80
COMPONENTS LIST
064007-1
K1 = 25-way sub-D plug (male), angled pins,
PCB mount
K2,K4 = 2x21-pins pinheader (see text)
K3 = 50-way angled SCSI-2 highdensity
connector, PCB mount
(e.g. Farnell # 369-3752 or # 854-037)
PCB, ref. 064007-1
100%
to the PC have a female connector. The new
cable that you bought cannot be used and you
will have to look for another solution. One of
these is to make an adaptor, which allows the
USB/SCSI converter to be connected directly
to the scanner. For the scanner we assumed a
064007-1
25-way sub-D and for the converter a high-
density connector. The schematic shows the
necessary connections and their names. We
(C) ELEKTOR
don’t discuss this any further, there is plenty
of information available on the Internet.
The PCB consists of two parts. One is for fit-
ting the right-angle 25-way male sub-D con-
nector and the other for the high-density
connector. The PCB has been designed in
such a way that the two component sides can
be connected together via a double row pin
100%
(064007-1)
81
R
310 circuits
elektor international media bv – 089018/uk
pagina 81
Henry Schouwstra
+12V
270Ω
testing all normal LEDs. If you wish, you can
connect a multimeter across the LED to mea-
sure the voltage on the LED. 080170 - 11
Richard Hoptroff
+3V3...+5V
When computer makers switched from RS232
to USB, one of the collateral benefits was TTL VDD
compatibility with regard to the supply volt- RxD TxD CTS
82
L
310 schakelingen
elektor international media bv – 089018/nl
pagina 82
which raises the question: if you already have vice of the LinkMatik module. If the security
to use an extra IC, why not go directly to function is enabled, you will have to enter the
Bluetooth? PIN code of the module (set to ‘0000’ when
And in fact, there are already several first delivered). Once a connection has been
Bluetooth modules available, complete with established, the Status pin of the module
an integrated antenna and simple serial in- goes to a high level to indicate that it is ready
puts and outputs. However, many of them for bidirectional data transmission.
have the disadvantage that they are con- Now you can simply use the familiar TxD and
trolled using AT commands, which makes it RxD lines to transmit serial data. The RTS and
necessary to use an additional controller. CTS lines are also available for controlling the
However, there are also autonomous models data flow. If you do not need that function,
available, such as the new LinkMatik module you can simply connect these two lines to-
(www.flexipanel.com). If its Mst/Slv pin is held gether. However, this wireless serial interface
low, it waits until something wants to con- does not allow you to use these lines for pur-
nect to it. If the pin is high, the module ac- poses other than their intended use, as is of-
tively searches for devices that are ready to ten done with ‘normal’ serial interfaces.
establish a connection. That means you can As the data is buffered in the module before
set up a shortrange radio link without using a and after wireless transmission, RTS and CTS
computer by simply coupling two modules are generated locally. These two signals only
together. control data flow to or from the module, but
not over the wireless link.
However, generally speaking you will proba- It is generally not possible to have more than
bly want to control an external device from a one serial link via Bluetooth per PC. However,
PC. In that case, you can let your PC search for Bluetooth-2.0 compatible modules have re-
devices that are ready to establish a connec- cently become available, and they allow up to
tion. When the PC finds a module, it lists its four serial links to be used concurrently along
available services. The service known as ‘Se- with other functions.
rial Port Profile’ (SPP) is the appropriate ser- (060077-1)
83
R
310 circuits
elektor international media bv – 089018/uk
pagina 83
+12V
IC2 = LM358
R5
47k
3 1N4148
D2
1 5 8
IC2.A R7
2 7 2
IC2.B 1k5 D3
R2 6
4
100k
1
LED
R3 R4 R6
C4
10k
1M
1k
100n
R1
0Ω33 IC1
D1 78L12 +12V
IN4004
K1 C1 C2 C3
1 2 3
new S1 F1
TR1 4
C
1 6
X1
S
2
230VAC
3
new 7
solder iron TCP-S
1
solder iron
potential
WTCP-S 080121- 11
heating element in the iron. It is not necess- ing output signal charges up capacitor C4 to
ary to carry out any calibration on the circuit. approximately 10 V via diode D1 when the el-
This design can be fitted to the WTCP-S, ement is on. IC2.B is configured as a compara-
WTCP 50 and WTCP 51 soldering iron sta- tor and resistors R5 and R6 set the reference
tions from Weller. voltage to around 2.1 V. When the element is
The add-on indicator circuit can be seen in heating the comparator output is positive
the uppermost dashed box of the circuit dia- and the LED lights. As the operating tempera-
gram, the lower box represents the internals ture is reached the magnetic switch opens
of the soldering iron station. A transformer in and the voltage across C4 is discharged
the base supplies 24 V to the heating element through R4 (time constant = 100 ms) and the
in the iron and is connected via a cable and LED turns off.
three pin plug/socket on the base unit. The Power for the circuit is derived from the 24 V
heating element has an impedance of 12 Ω transformer in the solder station. Diode D1
which produces an average current of 2 A and performs half wave rectification and C1 is a
a peak value of 2.822 A. Using a 33 mΩ resis- reservoir capacitor to produce a DC voltage
tor for the shunt (R1) gives a voltage drop of for the 12 V voltage regulator (IC1).
93 mV (peak) when the element is heating. The maximum offset voltage for the LM358 is
IC2 is a LM358 type dual operational ampli- only 7 mV, with a gain of 100 this can produce
fier. The amplifiers are powered from a sin- an output offset of 0.7 V which is well below
gle-ended power supply and IC2.A is the 2.1 V comparator threshold and is not
configured as an amplifier with a gain of 100. likely to be a problem so it is not necessary to
It amplifies the positive half waves of the volt- fit any form of offset adjustment.
age dropped across the shunt R1. The result- (080121-I)
84
L
310 circuits
elektor international media bv – 089018/uk
pagina 84
Richard Salisbury
to twin speakers
AUDIO
USB-A
to K1
TR1
12V
Mains
12V IC1 D1 D2
L7806 1N5819 1N4007
D3
R1
68 Ω
K1
C1 C2 C3 1N5819 1
+5V
2
D–
100µ 390n 390n BT1 3
B1 25V D+
4
GND
4 cells 1V2 R2 R3
500mAh USB-A
22k
22k
060070 - 11
85
R
310 circuits
elektor international media bv – 089018/uk
pagina 85
pearing on the USB connector it assumes it is The unit is working well and plays the client’s
connected to a computer and stops playing. favourite music for about 4-3/4 hours, more
The circuit diagram is all straightforward and or less like a personal radio station. Of
speaks for itself. The U10 is fixed in a window course, much more music could be loaded on
on the back of the player with the keys the player since stereo makes no sense and it
locked. Hence, it plays continuously whether could be encoded at a slower rate.
the amplifier is on or not (the author used a
15-pound speaker set/amplifier for a com- An initial problem of the MP3 player’s output
puter which switches the 12 volts AC). The level not being well matched to the amp input
transformer was replaced with a double sec- was solved by choosing another amplifier
ondary winding to avoid any earthing prob- (Velleman K4001) which has a more suitable
lems between the USB charging device and input sensitivity of 40mV.
the amplifier ground. (060070-1)
Thijs Beckers
86
L
310 circuits
elektor international media bv – 089018/uk
pagina 86
4k7
nents (that’s all!) are all readily available. You IC1
10n
might already have them in your parts 7
drawer.
Here we use an electret capsule for the micro- ANT1
and C3. 2
The microphone signal is fed to pin 5 of the C3
4 &
6
suitable antenna.
080480 - 11
The circuit operates on the third harmonic at
around 100 MHz. It takes a bit of experimen-
ting to find the right frequency on the radio,
but within a range of a few metres the circuit This very simple circuit is highly sensitive and
can even overpower signals from relatively somewhat prone to positive feedback, espe-
powerful transmitters. Of course, this circuit cially if you hold it in your hand. The best ap-
is not entirely legal, so you shouldn’t try to proach is to put it down somewhere and stay
boost the power too much. A range of 20 away from it; then it works fine. If you want to
metres is certainly possible with the circuit as experiment with the circuit, feel free!
shown. (080480-1)
Stijn Coenen
87
R
310 circuits
elektor international media bv – 089018/uk
pagina 87
470Ω
D3
47k
tential at the non-inverting
input of IC1.B is 6 V, while
10CTQ150-1
P1
D2 1N4148
that at the inverting input 47k
2
8
R4
T2
150W
1k
R2
doorbell. 5W C1
T1
2200µ
The operating principle is simple. A circuit * see text 25V BC
547
that causes a voltage drop of only a couple of
volts is connected in series with the lamp. As
080169 - 11
88
L
310 circuits
elektor international media bv – 089018/uk
pagina 88
the circuit needs a DC voltage, the current for The charging time of C2 determines how long
the lamp is passed through a bridge rectifier. the buzzer remains energised, and here it will
The voltage drop across the circuit is deter- be a few tenths of a second. Depending on
mined by R1. The function of C1 is to smooth how much current the buzzer draws, you can
the raw DC voltage. Note that this is not an increase the value of R2 in order to extend
example of peak rectification, but instead of the time (this is certainly necessary with the
averaging. For this reason, the voltage on C1 above-mentioned buzzer type).
is lower than you might expect. Ultimately, Depending on the lamp power, you can con-
the DC voltage on C1 reaches the same value sider adjusting the value of R1. This will cer-
as the average voltage across R1. tainly be necessary if you use a 150-W lamp or
larger. In this case, cut the value of R1 in half,
For example, consider what happens with a primarily because the power dissipation will
100-W lamp. For convenience, we can assume otherwise be too large. In the example de-
that the lamp has a resistance of 529 Ω. If we scribed here, it is around 3 watts.
ignore the voltage across the diodes and the The bridge rectifier also deserves special at-
voltage across R1, the current is approxi- tention. A large current can flow briefly when
mately 0.39 A on average (not 0.43 A). This is the lamp is switched on ‘cold’. A 250- V, 1.5-A
because the average mains voltage is only bridge rectifier is adequate for a 100-W lamp,
230 V × 2 but heavier-duty diodes are necessary with
= 207 V higher lamp power – such as the 1N5408
p2 (1000 V / 3 A).
This yields a voltage of approximately 8.5 V
on C1. As the buzzer and T1 only draw a few Due to the heat generated by R1, make sure
milliampères from C1, in practice the voltage that R1 is located a certain distance away
will differ from this value by at most a few from the other components in the assembled
tenths of a volt. circuit. Also bear in mind that the entire cir-
cuit is connected to mains potential. Never
Here you should use a DC buzzer with a large make any adjustments while the circuit is
operating voltage range. A good example is connected to the mains! It’s thus a good idea
the CEP-2260A, which has a voltage range of to test the circuit before fitting it into the
3–20 V (available from Digi-Key and other on- switch box.
line sources). (080169-1)
89
R
310 circuits
elektor international media bv – 089018/uk
pagina 89
V+
K1 R8 R1 R5 K2
C3
470 Ω
1k
47k
8 16
100n
IC1 IC2
R3 4 8
56k IC1 = TL082 IC2 = 4520
2
2 EN 3
D2 R6 0
1 6 IC2.A 1 4 R7
C1 IC1.A 22k
3 7 1 5
4k7
1N4148 IC1.B C 2
5 6 T1
100µ 3
16V R4 R
7
1k
BC547C
R9 R2
D1 C4 C2
470 Ω
1k
15n
100n
1N4148
060146 - 11 V–
K2 can be connected directly to a fan connec- for the opamp. Diode D1 should have the low-
tor on the motherboard. The 12-V supply est possible voltage drop to minimise the
voltage for the circuit is also taken from the voltage loss to the fan.
motherboard via this connector.
The circuit is suitable for use with CPU fans
Components C3, C4, R8 and R9 create an arti- and fans for graphics cards in addition to
ficial ground potential at half the supply volt- power-supply fans.
age (6 V), which serves as a reference voltage (060146-1)
Hans-Jürgen Zons But first let’s consider the basic question: arti-
ficial sparkling or glittering can best be simu-
A question recently asked on the Elektor lated by having the different light sources
website forum was how to make several switch on randomly at a particular frequency.
white LEDs ‘sparkle’. The helpful author has Surprisingly enough, it is not all that easy to
not only provided a useful suggestion (use a generate truly random sequences electroni-
random effect), but also developed a suitable cally.
circuit and even designed a PCB layout. However, the electronic randomness does
not necessarily have to be perfect for glitter
You can download the Eagle files for this from applications. Patterns that appear to be ran-
the Elektor website page for this article dom are sufficient for the desired visual im-
(www.elektor.com, archive #080329-1.zip). pression.
90
L
310 circuits
elektor international media bv – 089018/uk
pagina 90
+9V
R1 R3
C6
270Ω
1k5
14
47µ
IC1 16V
≈ 850Hz 7 ≈ 180Hz
4 10
BT1
R R
1 13
DIS DIS
R2 R4
IC1.A IC1.B
9V 2 5 12 9
8k2
39k
THR OUT THR OUT
6 8
TR TR
CV CV
3 11
C1 C2 C3 C4
+9V
C5 IC1 = NE556N
100n
16 SV2 SV2'
3 1 1 R12 D8
0 2k2
CTRDIV10/ 1 2 2 2 R8 D4
DEC 2k2
4 3 3 R7 D3
2 2k2
7 4 4 R11 D7
IC2 3 2k2
10 5 5 R6 D2
4 2k2
14 1 6 6 R5 D1
& + 5 2k2
5 7 7
6
13 6 8 8 R10 D6
7 2k2
9 9 9
8
CD4017 11 10 10 R13 D9
9 2k2
15 12 11 11 R9 D5
CT=0 CT≥5 2k2
12 12 R14 D10
2k2
8 13 13
14 14
080329 - 11
91
R
310 circuits
elektor international media bv – 089018/uk
pagina 91
13 being driven by the lowerfrequency signal. ommended to use series resistors (2.2 kS to
The result is ‘genuine pseudo-random’ blink- 4.7 kS) to reduce the load on the IC outputs if
ing. the supply voltage is higher than 10 V. If you
want to have more than ten LEDs glitter, you
LEDs can be connected directly to the ten out- can naturally build several copies of this cir-
puts, since a CMOS output can anyhow only cuit.
supply a few milli-ampères. However, it is rec- (080329-1)
92
L
310 circuits
elektor international media bv – 089018/uk
pagina 92
1
LCD1
+5V
+5V IN LC DISPLAY
C4
VDD
VSS
R/W
VO
RS
D0
D1
D2
D3
D4
D5
D6
D7
A
K
E
10µ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
16V
C1 C5
+5V
100n 100n
K1 R1
*
+5V
RXD 20
GND
1
TXD RST 12
PB0
LED+ 2 IC1 13
T1
PD0 PB1
3 14
PD1 PB2
6 15
PD2 PB3
7 16
PD3 PB4
8 17
BS170
PD4 PB5
9 18
PD5 PB6
11 19
PD6 PB7
AT90S2313
XTAL1 XTAL2
5 X1 4 10
* see text
C2 C3
27p 27p
11.0592MHz
S1 S2 S3 S4
0 1 2 3 D1
S5 S6 S7 S8
1N4148
4 5 6 7 D2
8 9 A B D3
C D E F D4
1N4148 050259 - 11
Software for IC1 can be downloaded from available on the Internet but this version con-
www.elektor.com for free, the file number is tains a restriction of 500 bytes on the maxi-
050259-11.zip. A preprogrammed controller mum code size. A ‘modification’ in the code
can also be ordered from the site shop as item gets round this by specifying the larger 8515
050259-41. controller and then resetting the stack
pointer to the correct value for the 2313, the
The CodeVision AVR compiler was used for overall effect is to increase the code space to
software development. A demo version is 2 kBytes.
93
R
310 circuits
elektor international media bv – 089018/uk
pagina 93
COMPONENTS LIST
Resistors
R1 = see text
Capacitors
C1, C5 = 100 nF
C2, C3 = 27 pF
C4 = 10µF 16V radial
65%
Semiconductors
D1-D4 = 1N4148
T1 = BS170
IC1 = AT90S2313,
order code 050259-41
Miscellaneous
X1 = 11.0592MHz quartz
crystal
S1-S16 = pushbutton
type D6
LCD module,
2x16 characters
PCBs, ref. 050259-1
65%
94
L
310 circuits
elektor international media bv – 089018/uk
pagina 94
In addition the display has a Table 1. Command character function in ‘N’ mode.
‘RAW’ mode which writes Dec. ASCII Function
all subsequent characters 8 BS clear the character on the left of the cursor
directly to the display. An 9 TAB move the cursor to position 0 or 8
‘Esc N’ sequence switches it 10 LF Line Feed – change line
back to normal mode. 11 HOME cursor to top left hand corner
12 CLR clear the display
Finally special characters 13 CR cursor to the start of the line
can be created and used for 27 ESC begin the command sequence
display dimming; further 28 RIGHT shift cursor one position right
details are contained in the 29 LEFT shift cursor one position left
downloadable PDF file. 30 UP change the line the cursor is on (like LF)
31 DOWN change the line the cursor is on (like LF)
Figure 2 shows the popu-
lated doublesided PCB. The LCD module and Fit a good quality socket for IC1 so that it can
keypad are mounted on one side while the be easily removed for future software up-
controller and all the other components are dates.
fitted to the reverse. (050259-1)
The axle is made from the core of a roller The upper end of the roller blind axle must be
blind with two bearings. Suitable angle brack- filed down to a suitable (generally square)
95
R
310 circuits
elektor international media bv – 089018/uk
pagina 95
cross section to allow it to be driven by the most 0.25 m2 in area as otherwise the force of
rotisserie motor. the wind may be too great for the gears in the
rotisserie motor’s gearbox to withstand. The
Now to the electrical department to find a angle of inclination of the module is fixed,
cheap electronic mains timeswitch. The and depends on the latitude at which it is in-
switch must be programmable for at least stalled.
four on-off cycles per day. For the solar panel
itself any 12 V solar charger designed for car, The mains portion of the timeswitch and the
camping or boat use is ideal. It should be at switching relay are not required and are re-
96
L
310 circuits
elektor international media bv – 089018/uk
pagina 96
moved. The remainder of the timeswitch will The author uses his solar panel to operate a
act as a clock which causes the axle to be ro- small water pump. For this purpose the out-
tated eight times during the course of each put of the panel is regulated to 5 V using a
day: each on-to-off or off-to-on transition of highly efficient switching regulator. Alterna-
the clock will advance the axle by 22.5 de- tively, 12 V lighting could be powered from
grees from east to west via south. The angle the panel, with no need for the regulator.
through which the roller blind axle turns is
defined by its octagonal shape: the corners Of course, both the control electronics and
operate a microswitch S1, which is fitted with the timeswitch need to be housed in a water-
an actuation lever. The position of the proof enclosure. Energy storage to cover for
microswitch must be set carefully so that the the inevitable cloudy days can be provided by
switch is closed when the lever is pushed a 12 V battery comprising ten 2800 mAh AA-
aside by a corner and open when between size NiMH cells in a suitable battery holder,
corners. Each time the timeswitch changes which can be fitted inside an ordinary electri-
state IC2, a CMOS 4011 which contains four cal junction box. A 3000 mAh D cell is fitted in
NAND gates, switches the drive motor on via the battery compartment of the rotisserie
p-channel MOSFET T3 for as long as necessary motor, wired in series with the 12 V battery
until the microswitch also changes state. Rea- and also charged from the solar panel.
sonable settings for the timeswitch have been
found to be as follows: 7.30 am on; 9.00 am The motor and battery connections from the
off; 10.30 am on; 12 noon off; 2.00 pm on; rotisserie motor are taken to the control cir-
4.00 pm off; 6.00 pm on; and 9.00 pm off. cuit using a four-core cable. The rotisserie
motor’s switch is removed. Resistor and ca-
After eight moves the solar panel has rotated pacitor values shown in the circuit are not
through a total of 180 degrees and points di- particularly critical, and other similar types
rectly west. Counter IC1, constructed from can be substituted for T1, T2 and T3. A
the two CMOS JK flipflops in a 4027, detects Schottky diode should be used for D3, which
the eighth clock pulse and turns on relay Re1 prevents current flow back into the solar
via IC3. This in turn reverses the polarity of panel, in order to minimise power losses. The
the power to the motor and the panel starts 5 V regulator operates at around 250 kHz and
to turn back from west to east. When it so a high-speed switching diode is needed for
reaches its original position facing due east D4. Using an ordinary 1N4007 considerably
limit microswitch S2, actuated directly by the reduces the efficiency of the regulator and is
solar panel, opens. The connected load is also therefore not a good idea. A small toroidal-
switched on and off by S2, which is open core inductor is used for L1.
during the night and closed during the day. (080119-I)
97
R
310 circuits
elektor international media bv – 089018/uk
pagina 97
100 Ω
which is not only cheap but D2
The circuit diagram shows a simple mains they will switch on and off at 100 Hz. C3 is
slave switch based on this idea. The coil may therefore fitted to slow down the transistor
be wound directly onto the reed switch using response and keep the relay energised during
insulated single core hook-up wire or enam- the mains zero crossings when the current
elled copper wire of sufficient gauge to carry drawn by the appliance falls to zero and the
the current drawn by the power tool (or mas- reed switch opens.
ter appliance). C1 drops the mains voltage to about 15 V (de-
termined by zener diode D1) and this is recti-
In practice this should be as thick as possible fied and smoothed by D2 and C2 to provide a
to cater for any power appliance while still DC supply for the circuit.
enabling a sufficient number of turns to be ac-
commodated to produce the required mag- The relay contacts should be rated to switch
netic field which will depend on the reed the intended appliance (vacuum cleaner) and
switch and is therefore best determined by the coil should have a minimum coil resis-
experiment. As a guide, a one-inch reed tance of 400 Ω as the simple d.c. supply can
switch with 40 turns reliably switched on with only provide a limited current. C1 drops virtu-
the current flowing through a 150- watt lamp ally the full mains voltage and should there-
(approx. 625 mA) but larger reeds may re- fore be a n X2-class component with a voltage
quire more turns. If the master appliance rating of at least 250V AC.
draws less current (which is unlikely with (050385-2)
power tools) more turns will be required.
Warning
The reed switch is used to switch on transis- The circuit is by its nature connected directly to
tor T1 which in turn switches the relay RE1 the mains supply. Great care should therefore
and powers the slave appliance. Since reed be taken in its construction and the circuit should
switches have a low mechanical inertia, they be enclosed in a plastic or earthed metal box
have little difficulty in following the fluctua- with mains sockets fitted for the master and
tions of the magnetic field due to the alter- slave appliances.
nating current in the coil and this means that
98
L
310 circuits
elektor international media bv – 089018/uk
pagina 98
* D1 +12V
C1 C3
R2
* see text 1N4004
47k
10n
470µ
25V
Aurel FM transmitter
R4
1 2 3 4 5 6 7 9 13 15 16
10k
P1
R5
AUDIO
IC1 100k C5
J1
22k
C2 R1 ANT1
2 7
47k 5n6
6 sensitivity
220n TL081
3
4
R3 R6
C4
47k
4k7
22µ
25V
080232 - 11
99
R
310 schakelingen
elektor international media bv – 089018/nl
pagina 99
1 2 3 7 10 11 15 16 18 19 20
ANT1
IC3
7805 D1 +9V
P1 1N4004
C2 C4 C8 C9
220n
R1
R3
C5
10k
100 Ω
16
10µ 25V
VDD
13
0 MDX 1
14 3 3 6
1 COM 8 C7
15 5
2 IC1 IC2
12 11 2
3 0 1000µ
1 10 R4 25V
4 8x 0 1 4
7 7
5 9 LS
10 Ω
5 2
2
LM386
6 4051
4 6 P2
7 G8 R2 C3 C10 C6
VEE VSS
100k
volume
080232 - 12
The power supply can be obtained from a good-quality analogue switch that is easy to
12 V battery or a ‘plug-top’ power supply; di- use.
ode D1 protects the circuit from reversed po- Its output passing via the volume control P2
larity. and is applied to the well-known small inte-
grated power amplifier LM386. The transmit-
The receiver is just as simple, since it uses the ter’s RF output power of a few hundred
complementary module to the previous one, milliwatts is more than adequate for such an
again from Aurel, and naturally called their application, and its quality likewise, espe-
‘FM audio receiver’. cially if you combine it with a loudspeaker
This receiver has a squelch (FM noise silenc- worthy of the name, with a pair of head-
ing) adjustment, set by the voltage applied to phones as the next best alternative.
pin 15. Potentiometer P1 connected to this The Aurel receiver module and CMOS multi-
makes it possible to adjust the squelch plexer both require a 5 V supply; this is stabi-
threshold so as to have a receiver that won’t lized by a standard 3-terminal regulator. The
output noise in the absence of a signal, using circuit as a whole is powered from 9 V, and is
the information provided on pin 18. This is also protected against possible reverse polar-
High when a signal is present and Low when ity by diode D1.
absent. Here it drives an 8-into-1 CMOS ana-
logue multiplexer, of which only input 8 is Given the relatively high current consump-
used. This solution employs a very cheap, tion of the amplifier, especially if you use it
100
L
310 circuits
elektor international media bv – 089018/uk
pagina 100
for longer periods, rechargeable NiMH bat- but a simple piece of stiff wire around 17 cm
teries will obviously be preferable to primary long (that is a quarter wavelength at
cells, which wouldn’t last very long and will 433.92 MHz) will do the job just as well, and
turn out rather expensive in the long term, as cost a lot less.
well as bad for the environment. Equipped with these two modules you can
As far as the antennas are concerned, for both make the most of your music wherever you
transmission and reception, simple quarter- like. Don’t forget, though, that outdoors, the
wave whips ensure a range of a hundred best music of all is that of birds, that is, the
metres or so – even more if line-of-sight. You feathered variety.
can of course buy such antennas ready-made, www.tavernier-c.com (080232-I)
101
R
310 circuits
elektor international media bv – 089018/uk
pagina 101
LCD1
+5V
DS1820
16 C4
IC2 LC DISPLAY 2 x 16
8 100n
VDD
VSS
R/W
VO
RS
D0
D1
D2
D3
D4
D5
D6
D7
A
K
E
+5V
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
DQ
+5V
R1 R6 R7
C3
10k
3k3
P1 R8
IC3
K2 100n 10k
10 Ω
3
2
1
14
BC547 T1
DS1820 R3 IC2
4 1
1k MCLR C2
15
EN3
6
K1 RB0/INT SRG8
7 IC1 17 3
RB1 RA0 C1/
1 8 1 R9
RB2 RA2
6 9 PIC16F84 18 2 4
RB3 RA1 1D 2D 3
10k
2 10 2 5
R4 RB4 RA3 LCD_1
7 11 3 6
10k RB5 RA4/T0CKI LCD_2
3 12 7
RB6
8 13 14
RB7
4 13
R5 OSC2 OSC1
9 12
1k 15 16 5
5 X1 11
R2
9
10k
SUB-D9 C1 C2 10
060090 - 11
the LCD is controlled via the series/parallel Design a project in MPLAB and within this,
converter in IC2. The LCD proper is driven in load the source code available at the Elektor
the 4-bit mode (DB4–DB7). Also, the Register website (the .ASM file). After you have added
Select, RS, and the backlight must be pro- your own adaptations, make a .HEX image by
vided with the appropriate signals. IC2 con- clicking on the BUILD icon.
verts the 8 bits provided serially by IC1 into 8
parallel bits. The rising edge of the strobe sig- Then, use the free program NTPICPROG.EXE
nal from RA2 instructs IC2 to set the previ- from Andres Hansson (www.geocities.com/Cape
ously received eight bits at the outputs. The Canaveral/7706/ntpicprog.zip) to program the
falling edge clocks them to the screen via en- .HEX file in the PIC via the COM gate of the
able input E of the LCD. Since only six of the PC. The 5-V supply rail must remain con-
eight bits are needed, individual extensions nected during programming. Do not program
may be accommodated at outputs LCD1 and the PIC with a notebook, but use a desktop
LCD2: for instance, a buzzer or an LED. The PC, since the voltage levels at the COM gate of
combination of R9, T1 and R8 provides a cur- a notebook often are only 3–5 V, whereas a
rent of 100–200 mA from output Q3 (pin 7) of
IC2 to the backlight of the LCD. The contrast
PIC16F84 Configuration Bits
of the display may be adjusted with P1. Oscillator XT (01
WDTE off (0)
The associated program is written in assem- PWRTE on (0)
bly code; it may be adapted as needed by CP off (1) (all bits)
downloading development area MPLAB from
102
L
310 circuits
elektor international media bv – 089018/uk
pagina 102
90%
90%
COMPONENTS LIST
minimum of 10 V is needed. Also, do not use a the PIC yourself, a programmed one may be
USB/RS232 converter, because that usually ordered from the Elektor shop (order code
confuses the timing. 060090–41). A power source of 5 V capable of
providing a current of up to 100 mA is re-
Once you have this setup working, the step to quired.
other applications is easy.
The circuit is readily constructed on the Note that the circuit does not provide protec-
printed-circuit boards shown. Start with the tion against polarity reversal or too high a
wire links, so that they are not overlooked at supply voltage.
a later stage. If you do not want to program (060090-1)
103
R
310 circuits
elektor international media bv – 089018/uk
pagina 103
104
L
310 circuits
elektor international media bv – 089018/uk
pagina 104
+6V...+20V
D3
R1 R3 R4 R8
8 C1
10M
10k
10k
100k
D1 D4 IC1
4 R7
100µ
D5 25V 100k
R6
5
1k
3 7
IC1.B
1 6
IC1.A
2
S1 R2 R5
D2 D1, D2 = 1N4001 IC1 = LM393
10k
10k
D3...D5 = 1N4148
060084 - 11
105
R
310 circuits
elektor international media bv – 089018/uk
pagina 105
Note that a fly walking across the touch cuit too long to prevent picking up interfer-
switch conducts enough to generate a switch- ence.
ing signal. So do not operate important The power supply voltage for the circuit is not
things with this circuit (such as the heating very critical. Any regulated DC voltage in the
system or the garage door). Do not make the range from 6 to 20 V can be used.
wires between the touch contacts and the cir- (060084-1)
1 R2 R3
+5V
C1 C2
470 Ω
2k7
10µ 100n
16V
LED1
SCK
MISO
MOSI
IC1 14
S1 S2 VCC
6 4 2 6 4 2
1 24
P0.0/RXD P0.4/SPI-SS/LCD-ON
2 23
IIC-SCL/P0.1 P0.5/SPI-MOSI/LCD-RS
3 22
5 3 1 5 3 1 IIC-SDA/P0.2 P0.6/SPI-MISO/LCD-R/W
4 21
SPI-DRDY/P0.3 P0.7/SPI-SCK/LCD-E
SS1 5 20
LCD-DB0/P1.0 P1.1/LCD-DB1
SS2 6 19
LCD-DB2/P1.2 P1.3/LCD-DB3
7 18
LCD-DB4/P1.4 P1.5/LCD-DB5 K1
8 17 1
LCD-DB6/P1.6 P1.7/LCD-DB7 +5V
10 16 D+ 2
PullToGND D+ D–
11 15 D– 3
12
VREG IO-Warrior D–
13 4
D+
POWER 24 NC GND
MINI-USB
GND
9
R1
1k3
080101 - 11
106
L
310 circuits
elektor international media bv – 089018/uk
pagina 106
2 C1 C2 C3 C4
GND1 GND2
080101 - 12
Technologies [1]. The device is a micro- identical inclinometers are connected to the
mechanical sensor which measures angle on two SPI ports.
two axes using a capacitive method. The The completed module is shown in Figure 3.
SCA100T-D01 has a range of –30 degrees to One inclinometer is screwed to a black guide
+30 degrees and a resolution of 0.0025 de- plate in order to simplify attaching it to the
grees. The measured angle can be read out in rotor blade. The other inclinometer, which is
digital form over an SPI port. mounted on a grey block, is attached to the
flybar.
If we want to connect the device to a laptop The whole assembly is shown in Figure 4, at-
or desktop PC, we need a suitable interface. A tached to a model helicopter and ready to
simple approach is to use a ready-made USB- make some adjustments.
to-SPI converter such as the IO-Warrior 24 The last piece in the jigsaw is some suitable
from Code Mercenaries [2]. As the circuit in software running on the host PC. Using the
Figure 1 shows, this unit can drive two SPI IO-Warrior hardware simplifies matters con-
ports simultaneously, and also sports an LED siderably in talking to the hardware, as li-
to indicate operation. The circuit diagram braries are available for download from the
shown in Figure 2 therefore shows how two Code Mercenaries website to allow access to
3 4
107
R
310 circuits
elektor international media bv – 089018/uk
pagina 107
the SPI data from programs written in C++ less than ten degrees. The sign (positive or
or in Visual Basic. The author plumped for the negative) of the displayed results can be
latter language, as a free development envi- changed to suit the mounting arrangement
ronment for it is available from Microsoft. He with a click on the button marked ‘+/–’. The
then wrote a short Visual Basic program to Visual Basic software is available as a free
display the measured angles, rounded off to download from the Elektor web page for this
the nearest tenth of a degree. project.
The two values measured are the inclinations (080101-I)
of the flybar and of the rotor blade. The differ-
ence between these two values can be calcu-
lated to yield the pitch angle. Since the Web Links
sensors measure angles on two axes, the less [1] www.vti.fi/en/products-soluions/productfinder/
search/motion.html
relevant values are shown in smaller text on
[2] www.codemercs.com
the display. These values depend on the hori-
zontal alignment of the model and should be
Stefan Delleman
108
L
310 circuits
elektor international media bv – 089018/uk
pagina 108
BF245
BF247
ANT1
L7
C3 C4
T1 D
100n 47µ 1mH
C1
G BF247B 25V
1n T3 G D
S R4
100 Ω S
K1
3V2
2N5109 C2 R6 coax
50 Ω
2N5109
39 Ω
to K2 BFW16
100n
2V4
L1 L2
10 w 10 w
R1 R2 R3 R5
150 Ω
1k
470k
220k
C E
B
040383 - 11
+9V
L8 30mA
C9 C10 BFY90
1mH
100n 47µ
25V
T2
0V
Low D
S1 C7
L5 G
C E
22 w BF245A
47p S B
K2 C5 CASE
High receiver
L6
K3
2V5
C8
47p BFR91
BFR96
L3 L4 100n B C
C6 R7
1w 8w
1M
P1
500p 470 Ω E
log.
040383 - 12
The active antenna is readily constructed with A few hints for readers who conduct their
the aid of the two printed circuit boards own experiments. A lower value of capacitor
shown. C1 results in a somewhat looser coupling to
the antenna, but also in lower signal strength.
Since we are concerned with only relatively
low radio frequencies, the choice of compo- It may be worthwhile to replace the capacitor
nents is not too crucial. Various types of FET with a variable type. Inductor L6 ensures that
may be used: BF245, BF246, BF256, or the the output voltage at higher frequencies
SMD variants of these, but do mind their con- (30 MHz) is not much higher than at lower fre-
nections! quencies (3 MHz). This is because the Q factor
of coils L4 and L5 increases at higher frequen-
The same applies for the transistors: BFW16, cies, which leads to higher amplitudes. This is
BFY90, BFR91, BFR96; any of these will do. compensated by L6. This inductor may be
109
R
310 circuits
elektor international media bv – 089018/uk
pagina 109
75%
75%
75%
COMPONENTS LIST
omitted and replaced by a wire bridge, but better to wind the two coils as one, that is, 30
then the output voltages at higher frequen- turns with a tap than to wind two separate
cies increases. coils (see photograph).
Aim at obtaining as tight a coupling as feasi- (040383-1)
ble between L4 and L5. Because of this, it is
110
L
310 circuits
elektor international media bv – 089018/uk
pagina 110
Stefan Hoffmann R1 C1 R2
2k2 220Ω
It’s not hard for electronics enthusiasts to de- reason the components must be placed inside
sign a little circuit to mitigate the effects of an insulated plastic case for protection, with
absentmindedness. The notion is simple; if no way that people can touch any part of the
the light is left on when the hatch or door is circuit (this includes the sounder).
closed, a rhythmic sounder/buzzer signal pro- The connecting wires to the LED and the reed
duces an alarm that hopefully will not be switch contact must be fully protected to the
masked by other noise. same touch-proof degree too. For the
The circuit is powered as long as the lamp sounder you can use any type that operates
bulb is switched on by light switch S1. If the on direct current in the region between 1 V
reed switch S2 then signals that the hatch has and 3 V. In this circuit the operating voltage is
been closed, the sounder operates. The red limited by the LED connected in parallel to
LED, mounted outside the loft next to the en- the buzzer. Using a red LED will provide
try hatch, also indicates that the lamp up around 1.7 V to the sounder. The current re-
there needs to be switched off. The circuit quirement of this kind of miniature sounder
does not use a transformer, meaning that the is about 5 mA.
whole circuit is at mains potential. For this stefankhoffmann@yahoo.de (080115-I)
111
R
310 circuits
elektor international media bv – 089018/uk
pagina 111
+12V
C3 C2
100n 10µ
25V
+5V
R10
14 C31 14 C32
680 Ω
IC1 IC2
7 100n 7 100n IC1.F IC4
R3 5
13 12 3 7
1 10k
R6 6
1%
2
5k6
1
IC1.E 4
R4 8
11 10 1% R11
1 10k LT1227
R7 R9
470 Ω
1%
5k6
10k
IC1.D
P1 R5
9 8 1% 1% C6 C7
1 10k
R2 R8
10k 1%
100n 10µ
1k
10k
25V
IC1.A CTR4
3
1 2 1 0 1%
1 + IC2.A 4
C1 CT 5 –5V
2
CT=0 6
3 11 MUX
470p 0
10 0
G
9 7
2
4
Ch 1 0
3 5
Ch 2 1
2 IC3 +5V
Ch 3 2
1 3 74HC151
Ch 4
15 6
Ch 5 4 16 C8
14
Ch 6 5 IC3
13 100n
Ch 7 6 8
12
Ch 8 7
7
EN
0
060013 - 11
waveform generator with N output level multiplexing, each of the eight inputs will be
steps. All the common logic families contain a redrawn in the same position one above the
multiplexer chip in their ranks and the type other on the screen.
74HCT151 (IC3) used in this design is a low-
cost eight to one multiplexer which switches The display is useful for analysing the timing
any one of the eight input signals through to behaviour of simple digital circuits and its
the common output. If this output was dis- eight bit wide input is ideal for monitoring
played on an oscilloscope the screen would the data bus and input/output ports of a low-
show all eight signals superimposed on each speed microprocessor system. The circuit ac-
other so it is necessary to separate them ver- tually is useful as a rudimentary logic analyser
tically. This output signal is therefore mixed for digital circuits using slow clock speeds.
with the output of a staircase waveform gen-
erator which switches in time with the chan- The staircase waveform is generated by an
nel multiplex signal so that each channel is R/2R type of resistor network (R3 to R8)
displayed as a different horizontal trace on driven by the three binary coded outputs of
the screen. Providing the staircase waveform the counter which also switch the multiplexer
remains in synchronism with the channel (IC3). The multiplexer output signal and stair-
112
L
310 circuits
elektor international media bv – 089018/uk
pagina 112
case waveform are now mixed at the inputs of With a switching frequency in the order of
the fast opamp IC4. The oscillator frequency 2 MHz it is necessary to display the eight
can be adjusted by P1 from 100 kHz to ap- channel outputs on an oscilloscope which has
proximately 1.8 MHz. This allows adjustment a minimum input bandwidth of around 20
of the multiplex frequency to suit the type of MHz.
signal under measurement. (060013-1)
K4: 1 = MOSI
2 = VCC
+3V3 4 = GND
5 = RESET
R1 6 = GND
D2 7 = SCK V+
C3
10k
8 = MISO
2x 100n K4
BAS316 D1
R8 1 2
7 20 68 Ω
3 4
VCC AVCC
21 28 R9 5 6
AREF PC5(ADC5/SCL) 68 Ω
27 R10 7 8
PC4(ADC4/SDA) 68 Ω
1 26 R11 9 10
PC6(RESET) PC3(ADC3) 68 Ω
R14 25
PC2(ADC2)
IC1 PC1(ADC1) 24
1k5
K1 2 23
PD0(RXD) PC0(ADC0)
1 3
VBUS R12 PD1(TXD) K2
2 4 19 5
D– 68 Ω PD2(INT0) PB5(SCK)
3 5 18 4
D+ 68 Ω PD3(INT1) PB4(MISO)
4 R13
6 17 3
ID PD4(XCK/TO) PB3(MOSI/OC2)
5 11 16 2
GND PD5(T1) PB2(SS/OC1B)
12 15 1
PD6(AIN0) PB1(OC1A)
USB 13 14
PD7(AIN1) PB0(ICP)
ATMega8-16
GND XTAL1 XTAL2 AGND +3V3 K3
8 9 X1 10 22
C5 C1 C2
V+
100n 22p 12MHz 22p
080161 - 11
113
R
310 circuits
elektor international media bv – 089018/uk
pagina 113
observed that this microcontroller does not since the controller is available in a DIP-28
have a USB interface and the circuit does not package. If you are going to program the con-
use a USB to serial converter either. The troller yourself (via connector K2) then make
strength of this circuit is found in the firm- sure that you set the configuration fuses so
ware. The USB interface has been imple- that the internal oscillator uses the external
mented in software, as we have shown in an crystal as the clock source.
earlier article ‘AVR drives USB’ in the March
2007 issue of Elektor. The firmware ensures Jumper K3 is provided in the event you would
that the circuit is recognised by the PC as a se- like to power the circuit to be programmed
rial port and communicates with AVR Studio, from the USB port. We do not recommend
the standard Atmel development environ- that you do this, however, but sometimes
ment, as if it were a ‘real’ AVR-ISP program- there is no other option. K4 is a 10-way box
mer. header which has the same standard pinout
The circuit is easily built on a small piece of that Atmel uses everywhere.
prototyping board or even on a breadboard, (080161-I)
Uwe Kardel
disks inside the case of a PC, from PC supply RE2 Hard disk 2
K3
K1
other.
F1
C1 S1 D6 ADSL
Modem
500mA
1000µ
D3
25V RE3 Hard disk 3
In this case there are three 4
K4
+12V
114
L
310 circuits
elektor international media bv – 089018/uk
pagina 114
manifests itself there as well. In this case, ode D1, D2 or D3. The relays are provided
fault finding can be made much easier. with a hold circuit via a second diode (D4, D5
and D6). In this way the selected relay re-
The circuit operates by only switching over mains energised as long as the power supply
the power supply voltages (5 V and 12 V) of voltage is present. After switching on, elec-
the hard disks. The hard disk is out of service trolytic capacitor C1 is charged via R1, so that
without a power supply. This works without a the common contact of the rotary switch is
problem with S-ATA disks. With IDE disks this quickly at 0 V. This prevents an accidental
only works with modern drives. There may change of hard disk while the computer is in
only be a combination of hard disks on the operation.
relevant port and no CD-ROM, DVD-drive, CD-
burner or something similar. The ADSL modem is powered from the PC.
The selection of the desired hard disk is done This power supply voltage is only present if
with a rotary switch. This has to be set to the hard disk number 2 is selected. This prevents
correct position before the computer is the use of the Internet if one of the other
switched on. When the power supply is disks is selected.
turned on, one of three relays is driven via di- (060178-1)
115
R
310 circuits
elektor international media bv – 089018/uk
pagina 115
IC1 +5V
1 D4
1N4004 78L05
C7
R1
C1 C3 R8 R6
15k
10µ
820 Ω
820 Ω
SOLAR 25V
470µ 220n
D1 25V
1N5821 C4
SOLAR
10n
Rel1 D2
1
Q2 supply
R4 OFF
1N4148 2 7 P2
F1 5k6 GP5 GP0/AN0
BATT
IC2 1k
3 6 P1
2A BC548 GP4/AN3 GP1/AN1 supply
1N4148 OFF recharge
BATT PIC12C671 1k OFF
5 4
GP2/AN2 GP3
R2 D5 R5 R7
D3 C2 C5 C6
Rel2
5k6
2k2
2k2
8
100n
4V7 100n 100n
400mW
LOAD Q1
R3
080225 - 11
5k6
1 2 3 4
LOAD automatic lighting
BC548 connector
116
L
310 circuits
elektor international media bv – 089018/uk
pagina 116
solar panels to the battery. Hence it is ener- Elektor server, as well as from the author’s
gized as long as the battery is not being over- own website (see end of article). Once built,
charged, otherwise it is off. The second, T2, is the project is elementary to adjust, and only
used to connect the battery to the load being requires a DC voltmeter and an adjustable
powered. So it is energized as long as the bat- PSU, even a very simple one. Do not connect
tery is not too deeply discharged, otherwise any of the external elements to the charger,
it is off. and replace the battery by your stabilized PSU
set to 12 V, with a voltmeter across it.
Diode D1, which must be a Schottky type to
minimize the forward voltage drop, avoids Then increase the voltage to 14.5 V and ad-
the battery discharging through the solar just P2 so that Rel1 just drops out. Then re-
panel in periods of weak sunshine. A normal duce this voltage to confirm that Rel1 is
silicon diode in this position will have a too energized again at around 12.8–13 V (de-
high forward drop (about 0.6–0.7 V) to ensure pending on component tolerances).
optimum results hence is not recommended. Continue to reduce the voltage down to
Note the 4-pin connector at the bottom of the 10.5 V and then adjust P1 so that Rel2 drops
circuit diagram. This allows the present out. Increase the voltage again to check that
charger to be connected to the Solar-pow- Rel2 is energized again around 12 V or just
ered Automatic Lighting Module described under. P1 and P2 do not interact, so it is easy
on page 212. If this module is not being used, to adjust them independently.
all you need do is connect a jumper across
pins 1 and 2, as indicated in the diagram. Lock the wipers of P1 and P2 with a little seal-
To make this project easy to build, we’ve de- ant and fit your project into a case, taking
signed the PCB shown here. As usual, the cop- care to protect it from damp if it is to be used
per track layout is contained in the free outdoors. A sealed electrical junction box is
download available from the Elektor website. ideal for this, at a ridiculously cheap price.
This PCB has been designed for 10 A Finder www.tavernier-c.com (080225-I)
SPDT relays, which leaves plenty of freedom
in terms of choice of panels and battery.
When designing this charger, we planned for Downloads
a maximum battery current of 2 A, as indi- The source code and .hex files for this project
cated by the fuse value given, but there’s are available for free from www.elektor.com;
nothing – apart, perhaps, from your wallet, file #080225-11.zip.
for the cost of the battery and solar panels –
The PCB design is available for free download
to stop you from going higher. from our website www.elektor.com;
file #080225-1.zip
The .hex file to be programmed into the PIC
12C671 is available free to download on the
An LED is sure to fail if the current through it cause in this case you need only one addi-
is too high. You will soon discover this after tional cheap component. As the power supply
you have blown a few up. A simple resistor in voltage increases, an increasing amount of
series suffices to solve the problem and a power is lost in the resistor. In particular with
better solution is almost inconceivable, be- battery-powered equipment it is worthwhile
117
R
310 circuits
elektor international media bv – 089018/uk
pagina 117
15k
make sure it doesn’t become too large. L1 will T3
* see text
will conduct, T1 will block and T3 will also
block. The current cannot flow through T3 R6 L1
any more and will look for another path, in T1
*
D1 C1
100k
2N3904
As soon as the current drops, T2 will block
again and T3 will conduct. R6 provides a small
amount of hysteresis so that the switching BC547B
BC557B
2N3904
2N3906
060128 - 11
118
L
310 circuits
elektor international media bv – 089018/uk
pagina 118
Bernd Oehlerking D1
1 P R1 1N4007
1k
The Conrad Electronics 5W
R2
1M
stroboscope kit in its prod- A
uct line (number 580406)
which can be easily ex- P1
5M
panded with an electrically
isolated trigger input. 230V
THY1
A
LA2
Figure 1 shows the original G K
100µ 35V
rent of about 1 mA. B
R6
119
R
310 circuits
elektor international media bv – 089018/uk
pagina 119
a long duration input pulse there is neverthe- The optocoupler used is a CNY65, which eas-
less only a short pulse sent to the gate. R6 is ily provides class II isolation (generous space
necessary for the periodic discharge of C2. A between the connections to the LED on the
standard 5 V digital signal is sufficient for one side and the transistor on the other side).
driving this trigger input. Please note: this circuit operates at high volt-
ages that can be lethal. Even after the mains
With this expansion circuit it is possible to voltage is removed there may still be danger-
reach a repetition frequency of more than 20 ously high voltages present across the elec-
Hz. Above this frequency the flash tube starts trolytic capacitors in the circuit!
to flash erratically. (080367-I)
Dimitris Kouzis-Loukas
1
This circuit is a laser alarm
system like the one we see
in various movies. It uses a
laser pointer beam to se-
cure your valuables and
property. Essentially, when
the beam gets interrupted
by a person, animal or ob-
ject, the resistance of a
photodiode will increase
and an alarm will be acti-
vated.
TL072
10k
10µ
120
L
310 circuits
elektor international media bv – 089018/uk
pagina 120
121
R
310 circuits
elektor international media bv – 089018/uk
pagina 121
F1
AC1
P2
3A T
500 Ω
4V...15V R5
10k
5
7
IC1.B
6
F2
AC2
3A T
P1
500 Ω 2 3
R1
3
10k
1
IC1.A
2
1k R7 R8
1k
D T1 D T2
G G
R9 D3 S R10 D4 S
BUZ11 BUZ11
100k
100k
15V 15V
R3
1
10k
4 C1 C2 C3
IC1
R2 R4 R6 100n
D1 D2 8 2200µ 2200µ
35V 35V
10k
10k
10k
AC3
BAT42 BAT42 IC1 = AD822 080499 - 11
These considerations led to the development in order to test it more thoroughly. It ap-
by Wolfgang Schubert two years ago of an ac- peared that the outputs of the TL084 did not
tive rectifier using suitably-driven power always swing close enough to the positive
MOSFETs, published on page 232 of this and negative rails to switch the FETs off fully.
book. The circuit was highly symmetrical, Time for some modifications.
consisting of a quad opamp and four MOS-
FETs, forming a bridge rectifier with a very The first thought was, why not use a trans-
low voltage drop. former with a centre tap on its secondary
winding? Then we only need to simulate the
However, reports in the Elektor online forum action of two diodes, reducing circuit com-
indicated that some people had experienced plexity and cost, as well as power losses, by
problems with the circuit. Curiosity aroused, nearly a factor of two. It also means that we
the author was prompted to look more do not have to find complementary p-channel
closely at the design, and so he built a version FETs.
122
L
310 circuits
elektor international media bv – 089018/uk
pagina 122
The second thought was, instead of using 1 % R5 and R6 is less than the 7.5 V reference, the
resistors, why not use two trimmer poten- output of the corresponding opamp will go
tiometers and allow an adjustment to find the high and the connected MOSFET will be
optimal switching voltages for the pseudo- turned on. P1 and P2 allow the point where
diodes? the MOSFETs are turned on to be set individ-
ually in terms of the voltage difference be-
The result of these considerations was the cir- tween input and output. These voltages can
cuit shown here, which roughly resembles be measured using an oscilloscope (a multi-
one half of the original design. AC1 and AC3 meter will not do the job!) between test
are connected to either end of the secondary points 1 and 2 and between test points 1 and 3.
winding of the mains transformer, and AC2 is
connected to its centre tap. Each half of the With the component values given the thresh-
dual opamp drives its own power MOSFET. old voltage can be set in the range 0 V to
When power is first applied the reservoir ca- 375 mV in our example. In practice, with a 3 A
pacitors are both discharged, and the para- load and using BUZ11 MOSFETs, a suitable
sitic diodes present in each MOSFET are put threshold voltage is between 50 mV and
to positive use: through them the capacitors 100 mV. Power losses in the MOSFETs are
are initially charged to provide power for the only around 150 mW to 300 mW and so the
opamp. Usually the circuit will be in normal devices do not need extra cooling. The poten-
operation after the first half-cycle of the tiometers should not be set so that the
mains. MOSFETs conduct for longer than necessary,
as this leads to brief short circuits of the in-
Let us suppose for illustration that the input put, audible as a humming of the transformer.
is connected to a transformer with two 12 V It is best to start with the potentiometers ad-
secondaries and a power rating of 50 VA, and justed to the centre of their travel.
that at the output of the circuit we connect a
load of approximately 5 Ω. D1 and D2 ensure that the inputs to the
opamps never see excessive voltages of the
Roughly speaking we would expect a rectified wrong polarity. D3 and D4 protect the gates
output voltage of approximately 15 V and an of the power MOSFETs.
output current in the region of 3 A. The volt-
age divider formed by R3 and R4 will provide With the components shown the active recti-
a reference voltage of 7.5 V. fier is suitable for output currents of up to
around 5 A. The maximum transformer volt-
Every 10 ms there will be a negative voltage age is 15 V and so the output voltage is lim-
peak either on AC1 or on AC3. If the voltage at ited to about 20 V under load. With no load, a
the junction of R1 and R2 or at the junction of nominally 18 V transformer with poor regula-
123
R
310 circuits
elektor international media bv – 089018/uk
pagina 123
tion can give rise to DC voltages of over 32 V, links, and 6.3 A slowblow fuses should be fit-
exceeding IC1’s maximum rating. Lower-im- ted for electrical safety.
pedance toroidal transformers with second-
aries rated at up to 20 V (corresponding to Other dual opamp ICs besides the AD822 can
27 V at the output under load) work fine. The be used. The author has also had good results
reservoir capacitors should be rated at at using an original Texas Instruments TLC272.
least twice the secondary voltage of the trans- The outputs of this device can swing down to
former. If more current is required (as is quite very nearly 0 V, which is essential in this cir-
likely, since the circuit is designed for opera- cuit. Other suitable types include the
tion at low voltages) higher-power (lower ‘on’ OPA2244 and the better-known LM358N.
resistance) FETs and larger smoothing capaci-
tors are needed. Using the IRFZ48N and two An Eagle layout file for the printed circuit
4700 µF electrolytics up to 10 A can be deliv- board is available for free download from the
ered with minimal losses. With a small piece Elektor website. The author would like to
of aluminium as a heatsink the FETs barely thank Hans-Jürgen Zons for his help in design-
get warm. The printed circuit board tracks ing the printed circuit board.
need to be reinforced with soldered wire (080499-I)
John Dobson
1
Connecting a project to
your computer used to be a
simple affair – your micro-
controller would have a
UART (Universal Asynchron-
ous Receiver Transmitter)
which was compatible with
the RS232 protocol. You
would then simply put a
MAX232 converter chip 2
onto the microcontroller
and a 9-way D-type socket
which linked your design
using a standard lead di-
rectly to your PC.
From an application like Vi-
sual Basic, you could then
communicate directly to
your project using Win-
dows COM routines. Alter-
natively, you used the parallel port and simply trivial coding required to tame the USB inter-
waggled individual pins using the old BASIC face in microcontrollers having internal USB
[outp] command. Then USB came along to connectivity, alternative solutions have
make all our lives “easier”. Due to the non- emerged – most notably the FTDI chip that
124
L
310 circuits
elektor international media bv – 089018/uk
pagina 124
125
R
310 circuits
elektor international media bv – 089018/uk
pagina 125
126
L
310 circuits
elektor international media bv – 089018/uk
pagina 126
47k
100k
100p
values for these resistors
C1 15p
T1
0W5
The current limiting section
R3 R4 D3
C4
R7 built around T1 couldn’t be
simpler. When the output
10M
47k
100k
39V
0W5
100n
current rises above 30 mA
the voltage across R1
064016 - 11
causes T1 to conduct. T1
then limits the base-emitter
combination with the quad power supply for voltage of T2. R2 is required to protect T1
the hybrid amp (see page 23). against extremely fast peak voltages across
R1. R3 is needed to start the regulator. With-
The actual regulator consists of just three out R3 there wouldn’t be a voltage at the out-
transistors. A fourth has been added for the put and hence there wouldn’t be a base
current limiting function. The circuit is a posi- current in T2. R3 lets T2 conduct a little bit,
tive series regulator, using a pnp transistor which is sufficient for the regulator to reach
(T2) to keep the voltage drop as low as possi- its intended state.
ble.
The operation of the circuit is very straight- During normal operation with a voltage drop
forward. When the output voltage drops, T4 of 15 V across T2 and a current of about
pulls the emitter of T3 lower. This drives T2 30 mA there is no need for extra cooling of
harder, which causes the output voltage to T2. The junction temperature is then 70 °C,
rise again. R4 restricts the base current of T2. which means you can burn your fingers if
C1 and C2 have been added to improve the you’re not careful!
stability of the circuit. These are connected in
series so that the voltage across each capaci- The lower the input voltage is, the more cur-
tor at switch-on or during a short circuit rent can be supplied by this regulator. This
doesn’t become too large. You should use ca- current is determined by the SOAR (Safe Op-
pacitors rated for at least 100 V for C1-C3. D1 eration ARea) of T2. During a short circuit and
protects T2 against negative voltages that an input voltage of 140 V the current is about
may occur when the input is short-circuited 30 mA and T2 certainly requires a heatsink of
or when large capacitors are connected to the at least 10 K/W in those conditions.
output. To increase the output voltage you should
use a larger value for R6. If you want to use a
We use two zener diodes of 39 V connected higher reference voltage, you should replace
in series for the reference voltage, giving 78 V T4 with a MJE350. If you only ever need to
127
R
310 circuits
elektor international media bv – 089018/uk
pagina 127
draw a few milli-amps there is no need to in- about 50 dB. The quiescent current is 2.5 mA
clude T4 and R4. The potential divider (R6/R7) and for small currents the dropout voltage is
can then be connected directly to the emitter only 1.5 V.
of T3. The ripple suppression of the circuit is (064016-1)
Karel Walraven
128
L
310 circuits
elektor international media bv – 089018/uk
pagina 128
Joseph Zamnit
+5V
100k
10k
12k
4 8
quiet place with just the C3 D1
RE1
1k
10k
R5 R2 3
12k
D2
IC1 = LM358
dropped silent due to flat IC2 = 4538 +5V
green
batteries. What a pity! 080420 - 11
Wim Abuys
129
R
310 schakelingen
elektor international media bv – 089018/nl
pagina 129
Capacitive switches have clear advantages about 2.9–3.2 V when the plate is touched
compared to other types of touch switches (and 2.6 V when it isn’t touched);
(for example 50 Hz or 60 Hz detection or re-
sistance detection), but are often more com- à an LM339 comparator is used to compare
plex to implement. Manufacturers such as the voltage at point C with a reference volt-
Microchip have in the past designed specialist age (D). The latter is set to about 2.8 V
ICs for this purpose. However, it is still possi- using a potential divider.
ble to design a reliable capacitive detector
and/or switch using only a limited number of As long as the contact plate is touched the
standard components. output of the circuit will be active. To make
130
L
310 circuits
elektor international media bv – 089018/uk
pagina 130
work in battery-powered
systems without a connec-
COMPONENTS LIST tion to Earth.
131
R
310 circuits
elektor international media bv – 089018/uk
pagina 131
1
IC1 = 4013
S1.A R1 R2 S1.B
22k
10k
T1
C3 14 6
IC1 5 S 1
D
4n7 7
IC1.A
2N3906 3 2
C
R
BT1 4
C1 C2
to remote
9V 10 Flash Gun Trigger
100µ 100n R via lead
9 13
25V D
D2 D1
IC1.B
11 12
C
S 2x
1N4148
8
R4 R5 R7
TRI1
1k
1k5
470k
D3
R3 R6 R8 TIC206D
D5 D4
C4 1N4148 C5
10k
10k
100k
2µ2 47p
SFH300-2 Tant 16V
READY
060116 - 11
R1 & R2
The presented trigger cir-
cuit optically receives the CLK1 & CLK2
132
L
310 circuits
elektor international media bv – 089018/uk
pagina 132
advantage of the triac is that a trigger voltage The SFH300-2 photodiode is supplied by
of either polarity can be handled. The 2N3906 Maplin as part number MES NP64U. The triac
may be replaced by its near equivalent the may also be a TIC126D.
BC212L. (060116-1)
Burkhard Kainka C4 K1
ANT1 PC
Software-defined radio (SDR) 100n
133
R
310 schakelingen
elektor international media bv – 089018/nl
pagina 133
A weakness of the receiver is that it only has audible interference, in which case the only
one output channel. This means that each remedy is to tune to another transmitter. And
transmitter can be seen twice in the spectrum if none of the channels appeals, you can sim-
display, and there is no suppression of image ply move to another band with a twist of the
frequencies as would be expected in a fully- screwdriver.
featured SDR. Sometimes this can result in (080384-I)
* see text
The device we’re offering as R1 R4 R5
6k8
22k
134
L
310 circuits
elektor international media bv – 089018/uk
pagina 134
IC2, supply stable current of 12 V DC to supply windings each. They have to be wound
power to the oscillators. around the pipes carrying the water to be
The entire secondary makes it possible to ‘treated’ and are spaced about ten centime-
have available, after rectification, approxi- ters from each other. Neither the material of
mately 40 VDC which is used to supply power the pipe system, nor its diameter, should
to coils L1 and L2, wound around the pipe sys- have any influence on the efficiency of the de-
tems on which the assembly will work. To do vice.
that, IC3 is followed by high-voltage transis- Paradoxically, these coils have one end in the
tor T2 (a BF457 or equivalent) which chops air, which may surprise you as much as us but
this high voltage to 5 or 10 kHz frequency de- we indicated at the beginning of this article,
pending on the state of IC1. that our goal with this project is not to ex-
LED D3 lights up to signal that the power sup- plain the principle but rather to allow you to
ply is present. make the same device as those sold in stores,
Coils L1 and L2 are simple inductors made so that you can perform your own tests.
from insulated flexible wire, with about ten www.tavernier-c.com (060105-1)
Romain Liévin
On a petrol engine (motorbike or car), it’s sensor (UGN3140) that delivers a pulse every
very easy to pick up pulses that reflect the en- time a magnet passes in front of it. You could
gine revs. The number of articles that have equally well use a reflective photodetector…
appeared in Elektor are proof of this.
The biggest difficulty lies in finding a spot to
Most circuits confine themselves to detecting fit one or more magnets. The timing belt pul-
the pulses generated by the ignition, either leys would be a good location, but the whole
by magnetic coupling or directly, after shap- assembly is always protected by a cover. Die-
ing of an electrical signal. Since diesel en- sel vehicles are often fitted with a vacuum
gines by their very nature don’t have spark pump for the brake servo system. This pump
plugs, an alternative method has to be found. is connected to the camshaft via a belt. The
Here, it takes the form of a logic Hall-effect ideal spot for fitting two magnets and the
135
R
310 circuits
elektor international media bv – 089018/uk
pagina 135
136
L
310 circuits
elektor international media bv – 089018/uk
pagina 136
sensor! Why two magnets? Any good me- Two additional magnets make it possible to
chanic knows that a 4-stroke engine has to increase the resolution to 60 rpm. The num-
make two revolutions for each engine cycle. ber of magnets fitted can be configured by
But the camshaft controls this cycle in just a means of the jumper fitted to header K4
single revolution, and hence it turns at half (which may, as applicable take the form of a:
the engine speed. So using two magnets en-
ables us to obtain the correct number of à no jumper = two magnets,
pulses. à jumper fitted = one magnet.
As you can see, the circuit amounts to just a Not much needs be said about the power sup-
single IC, an AVR microcontroller from Atmel. ply, except that:
Long gone are the days when it took no less
than six ICs to produce even a two-digit a rev à the regulator might need a heatsink, as
counter! the vehicle on-board voltage can reach
14 V, which represents a volts drop of 9 V
What’s more, using a microcontroller with a with a current consumption of 30 mA, i.e.
crystal-controlled clock makes it possible to . 0.3 W;
dispense with any form of calibration. The
microcontroller contains everything needed à the (vital) presence of a special car varistor
to count pulses, using its interrupt input, and to protect the regulator from voltage spi-
directly drive a multiplexed
display, using its I/O lines
that can sinking up to 20
mA. The display comprises
four digits, to count from 60
to 9,999 revs.
137
R
310 circuits
elektor international media bv – 089018/uk
pagina 137
kes. Otherwise, it’s goodbye to the regula- two to obtain the frequency, and then by 60
tor the first time you start up! to obtain a value in revs per minute.
All that then remains is to convert the binary
This project requires relatively few resources, result into a decimal value, which is achieved
whence the use of a small microcontroller: using Atmel’s binary-to-BCD conversion rou-
the Atmel AT90S2313, which by now is an old tines (AVR204 Application Note). The most
faithful in Elektor. It has two timers, I/O lines significant digit (MSD) is set to 0, and the re-
capable of driving LEDs directly, and an inter- sult is then converted back to binary. This is a
rupt input. The interrupt input is used to crafty method for calculating a remainder out
count pulses by incrementing a software of 1,000 (modulo) for the bargraph. This value
pulse counter (cntH:cntL). The timer is set to then has to be divided by eight, as the
generate an interrupt every 2.5 ms. This inter- bargraph has eight LEDs (coded by subtrac-
rupt is used to: tion and a loop). The result is used as an index
for a decimal-to-7-segment transcoding rou-
à multiplex the display: each display is re- tine. As supplied, the software occupies
freshed every 2.5 ms; hence the whole dis- about 75% of the program flash memory.
play is refreshed at a frequency of 80 Hz; The software has been developed to work on
an AT90S1200 or an AT90S2313. With a bit of
à increment a software counter up to 250 ms luck it should also work on an AT90S1200,
(= one tick). but although we haven’t actually tried that,
we’re sure there are Atmel programming en-
At each tick, the value of the pulse counter is thusiasts among our readers capable of doing
stored alternately in counter 0 or counter 1. it. Let us know!
This tick is also used in the primary loop to (071133-I)
trigger counter processing and display re-
fresh. Downloads
The PCB artwork file is available for free down-
In the primary loop, counters 0 and 1 are loading from our website www.elektor.com;
added together to obtain the number of archive #071133-1.zip.
pulses seen during the last two consecutive The source code and .hex files for this project
are also available from www.elektor.com;
250 ms time slots, i.e. 0.5 s. This trick makes
archive #071133-11.zip.
it possible to update the display more fre- Web Links
quently (250 ms) without having to wait for AT90S2313 datasheet:
the end of the measurement (0.5 s). This www.atmel.com/dyn/resources/
makes it possible to increase the speed of the prod_documents/doc0839.pdf
digital chain without compromising accuracy. S14K14 varistor datasheet:
The remainder of the software consists of www.datasheetarchive.com/preview/
3078060.html
converting the number of pulses into rpm. Ev- UGN3140 Hall-effect sensor datasheet:
erything is implemented in integer arithme- www.datasheetarchive.com/
tic. Given that the measurement is performed preview/3527952.html
over 0.5 s, the result has to be multiplied by
138
L
310 circuits
elektor international media bv – 089018/uk
pagina 138
Ton Giesberts
139
R
310 circuits
elektor international media bv – 089018/uk
pagina 139
Wim Abuys R1 R2 F1
680 IC1 180
K1
1 6 1A
When turning a computer
1
+5V 230V
2
on and off, various periph-
D– TRI1
3
D+ MT2
erals (such as printers, GND
4
dios).
however. In that case and/or when using a
This so-called ‘USB-standby-killer’ can be real- very inductive load a so-called snubber net-
ised with just 5 components. work is required across the triac. The value of
The USB output voltage provides for the acti- the fuse will also need to be changed as ap-
vation of the triac opto-driver (MOC3043) propriate.
which has zero-crossing detection. This, in The circuit can easily be built into a mains
turn, drives the TRIAC, type BT126. multi-way powerboard. Make sure you have
The circuit shown is used by the author for good isolation between the USB and mains
switching loads with a total power of about sections (refer to the Electrical Safety pages
150 W and is protected with a 1-A fuse. The elsewhere in this book).
circuit can easily handle much larger loads (080259-I)
140
L
310 circuits
elektor international media bv – 089018/uk
pagina 140
Eberhard Haug
D21
4Ω75
of around 90 %. This is the 2µ2 4 8 2µ2
141
R
310 circuits
elektor international media bv – 089018/uk
pagina 141
3 V to 10 V. If fewer than five LEDs are used in driver circuit with a switching speed of
each chain, or if LEDs with a lower forward 1.2 MHz the layout and construction of
voltage are used, the battery voltage may switching regulators should be observed.
need to be reduced: it must be lower than the
total forward voltage drop of the chain. The MIC2291-34BML and its lead-free coun-
Otherwise, as with any boost converter, an terpart the MIC2291-34YML in a 2 mm by
unregulated and potentially damaging cur- 2 mm MLF package have a 34 V overvoltage
rent will flow continuously through the LEDs. protection circuit (and an extra OVP pin); the
MIC2291YDS in a 5-pin SOT-23 package is a
Also, if the chains contain different numbers low-cost version without overvoltage protec-
of LEDs or if different colour LEDs are used, tion.
care must be taken to ensure that the sum of
the LED forward voltages is greatest in the Since we would otherwise have to implement
first (regulated) chain. this protection externally, the MLF type is
preferred.
The EN input allows the LED array to be (060156)
turned on (EN>1.5 V) or off (EN<0.4 V), or
dimmed using a PWM signal. An alternative
(analogue) dimming technique is also de-
scribed in the MIC2291 data sheet. Internet links
Ton Giesberts
142
L
310 circuits
elektor international media bv – 089018/uk
pagina 142
+9V
+9V
BT1
R1 9V
1M
T1
K1
S/PDIF C1 C2
R2
C3
10M
22n 22n BS250
D1 D2 D3 D4
22n
RE1 1 2 13 8 6
T2
C4 C5 R3
1M
22n 22n C6
BC
D1...D4 = BAT85 547B 16 15 9 11 4
47n
+9V
R4 K3
1M RE1, RE2 = G6AK-234P-ST-US-DC12
T3
K2
S/PDIF C7 C8
R5
C9
10M
080484 - 11
S/PDIF inputs to accommodate all these de- and then on again to select it. It is relatively
vices, or the receiver is at the other side of the easy to expand the circuit with more inputs.
room from the TV and other equipment, and Because we wanted to avoid the use of a
we’d rather not lay three or four separate mains adaptor for this circuit we decided to
S/PDIF cables along the skirting boards. This make it battery-powered. For the design we
clever little circuit gets round these problems therefore strived to keep the current con-
in an ingenious way. It doesn’t need a mains sumption as low as possible. That meant that
supply nor does it have any external switches. we didn’t use buffer stages or comparators to
The latter makes it possible to hide the device detect the input signals. Instead we used bi-
behind the equipment. stable relays, which only require a short pulse
to change their state, which is then latched.
The circuit detects the appearance of a new When an S/PDIF signal appears on one of the
S/PDIF signal on one of its two inputs and inputs, a cascade circuit is used to derive a DC
switches this to its output, so that only one voltage from it. Because the nominal voltage
connecting cable is required to connect two of S/PDIF signals is only 0.5 Vpp (when termi-
devices with S/PDIF outputs to the receiver. nated by 75 Ω), each input has a cascade
When several devices are turned on that out- stage with four diodes and four capacitors.
put a continuous S/PDIF signal, the required The generated voltage then becomes twice
device needs to be momentarily turned off the peak-to-peak value, which in this case re-
143
R
310 circuits
elektor international media bv – 089018/uk
pagina 143
sults in nearly 1 V. In order to keep the Depending on the type of relay used, you typ-
threshold voltage as low as possible the cas- ically need about 15 mA to energise each coil.
cade stage is loaded as little as possible, the This means that the maximum possible num-
capacitors are as small as possible and for the ber of inputs is much more than you’re ever
diodes we’ve used special Schottky types likely to need.
(BAT85).
This signal is then fed to a bipolar transistor It is possible to use 12 V types for the relays.
that requires about 0.5 V to 0.6 V for it to con- The G6A series made by Omron are guaran-
duct. A base resistor of 1 MΩ and a capacitor teed to switch at 8.4 V, for example the G6AK-
are used for interference suppression. The bi- 234P-ST-US-DC12. The coil resistance is
polar transistor drives a differentiator C3/R1 800 Ω, which means that it requires only
(C9/R4 for the other channel) to create a short 11 mA. If you find you have some ‘hesitant’ re-
pulse for the relay. The gate of the following lays when you’re using more inputs and
P-channel MOSFET is momentarily connected switch the relays via diodes, you can always
to ground via capacitor C3 and transistor T2. use 5 V types. The switching current will then
This FET then drives the set-coil of one relay be higher, but in practice this has little effect
and the reset-coil of the other relay. The on the battery life.
BS250 used here can switch a direct current
of 250 mA without any problems, and has an The current consumption of the circuit with
even high peak-current capacity (up to signals present at both input is about 1.6 µA.
500 mA). This implies that the maximum theoretical
The number of inputs can be increased by battery life could be 35 years for a standard
adding more of these stages. Note that when 9 V battery (500 mAh), which is much longer
there are more than two stages you need to than its expected shelf life. Another option is
connect each reset-coil via diodes (e.g. to use three or four Lithium cells in series.
BAT85) to the FETs. In that way the voltage on These probably will give the circuit ‘near-eter-
the reset-coils doesn’t end up at the set-coils nal life’.
of the other relays. (080484-I)
144
L
310 circuits
elektor international media bv – 089018/uk
pagina 144
D5
8 4 D1 D2
R
7 +12V
R2 DIS 4x indicator
IC1 T1 1N4001 relay
R3
100k
3
OUT 1k2
2 555 D3 D4
TR
6 THR BC327
LA3 LA4 S1
CV
BZ1
1 5
C2 C3
T2 LA1 ... LA4: indicator lights
2µ2 10n S1, S2: indicator switch
25V
050392 - 11
tor T1. The output of the 555 is active Low, sounder to operate. This applies only when
meaning that initially the transistor is +12 V is present at the collector of transistor
blocked and the sounder is silent. The timer T1, which is the situation when the flasher re-
always charges and discharges capacitor C2 lay is just switched on and the indicator bulbs
to a level between a third and two-thirds of light up.
the operating voltage, producing an interval
of 0.7 × C2 × (R2 + R1 + P1) [s]. The circuit is built inside a splash-proof enclo-
The preset enables you to set this delay up to sure, installed on your machine in a position
a second or so. The initial delay, before the that’s out of harm’s way. The audible sounder
sounder first operates, is significantly longer, can be positioned anywhere outside the en-
however, because the electrolytic has zero closure if it’s a waterproof type. The audible
charge. control unit requires only two cable connec-
Only after this delay is the output active, for tions, which can be made at any convenient
the pulse duration of 0.7 × C2 × R2 (equiva- access point.
lent to about 0.15 seconds), enabling the (050392-1)
Hence this module is inserted between one of Generally, it is also often useful to be able to
the receiver outputs and the servo motor to adjust the end positions of the output arm
be driven. and the neutral position independently (when
145
R
310 circuits
elektor international media bv – 089018/uk
pagina 145
modulation (PWM). 6
GP1 GP4
3
10k
GP0 GP5
PIC12F675
signal repeating at 20 ms in- 4
GP3 GP2
5 S1
146
L
310 circuits
elektor international media bv – 089018/uk
pagina 146
We start first of all by confirming the mea- movement takes place in the opposite direc-
surement of the input signal, very important tion. This mode is exited automatically if the
in order for the output signal calculation to push-button hasn’t been pressed for 2 sec-
be correct. Warning: the remark to not touch onds. The servomotor ‘flutters’ a little to indi-
the transmitter during this stage applies here cate the end of the steps.
too, for the same reasons. If the push-button
is pressed a second time, the gradual shift of One conclusion is called for: it works very
the neutral position starts, then if it is re- well, and it doesn’t cost an arm and a leg...
leased and immediately pressed again, the Clemgill@club-internet.fr (080323-I)
Burkhard Kainka
147
R
310 circuits
elektor international media bv – 089018/uk
pagina 147
opamp which can provide up to 30 dB gain of enamelled copper wire (ECW) with a tap at
the 12 kHz IF output signal to compensate for the second turn up from the ground end of
signal fading. Two VMOS transistors type the coil, it is wound on a 5 mm diameter coil
BS107 are used as the controlling element former fitted with a screw-in ferrite slug.
where the drain-source current controls the The regulated output signal is available at
internal resistance. connector CON1 and the stereo jack socket
The finished PCB in Figure 2 shows a neat cir- CON3. This PCB is connected to the receiver
cuit layout, coil L1 consists of 20 turns of 0.3 mm PCB via connectors CON4 to CON7, jumper
148
L
310 circuits
elektor international media bv – 089018/uk
pagina 148
2a 2b
100%
100%
149
R
310 circuits
elektor international media bv – 089018/uk
pagina 149
470 Ω
the 13-way female connector in order to 1N4005
T1
here. 54G/2
Here a type P521 optocoupler detects trailer
D4
150
L
310 circuits
elektor international media bv – 089018/uk
pagina 150
151
R
310 circuits
elektor international media bv – 089018/uk
pagina 151
Ralf Künstler
The support circuitry required for the SF6107 The voltage across the coil is demodulated by
consists of just a couple of passive compo- D2 and then passes via C3 to pin 6 on the IC.
nents, two transistors, a handwound coil and, An RFID tag in the vicinity of the coil absorbs
if desired, a DC buzzer. As the circuit diagram energy from the field produced by the coil
shows, a complete door opener, capable of and uses it to subsequently transmit its
recognising a master RFID tag and learning stored ID code. The IC compares this code
the codes of up to twenty further tags, is not against the values it has registered in its
very complicated at all. memory. If there is a match, T2 is driven on,
The IC drives the coil via pin 3 and T1. To- which in turn activates the relay and then the
gether with C1, the coil forms a parallel reso- door lock electromagnet.
nant circuit. The cable linking the main Simultaneously the IC emits the ID code of
electronics and the coil can be up to 80 cm the recognised tag in serial format on pin 2.
152
L
310 circuits
elektor international media bv – 089018/uk
pagina 152
68k
33n T1
#T3
#R00:CC00154423
#R01:CC00154427
#R02:CC00154434
153
R
310 circuits
elektor international media bv – 089018/uk
pagina 153
an ordinary serial cable. If, on the other hand, coil current from the 5 V supply, a BC337
the serial output is to be taken directly to a should be used for T1.
microcontroller without level-shifting, a 10 kΩ
pull-up resistor should be connected A to pin For optimum tag reading reliability and range
2. The IC checks which resistor is present at the parallel resonant circuit consisting of the
start-up and inverts its serial output if necess- coil and capacitor should have as high a Q
ary. (quality) factor as possible. Coils made from
Use the following procedure to erase all the 0.5 mm enamelled copper wire on a diameter
stored ID codes prior to reprogramming: of between 50 mm and 60 mm have given
good results. These dimensions are not par-
1 Switch the unit off ticularly critical, but it is important that the
2 Fit JP1 (this pulls pin 5 to ground) resonant frequency of the circuit is as close to
3 Switch the unit on the operating frequency of 125 kHz as possi-
4 Wait ten seconds ble.
5 Switch the unit off
6 Remove JP1 In our prototype we measured the inductance
of a 30-turn coil with a diameter of 55 mm at
Now a master tag (any RFID card) can be read about 100 µH. It was possible to read RFID
and its ID stored. Hold the tag up to the coil. tags with values of C1 between about 47 nF
Then take it away and bring it up a second and 14 nF, corresponding to resonant fre-
time: if the relay is activated then this means quencies of 71 kHz to 133 kHz.
that the card has been successfully pro-
grammed as the master and its ID code has It is not necessary to have an oscilloscope to
been stored. adjust the resonant frequency and Q factor.
An ordinary digital voltmeter measuring the
To program further tags into the unit it is voltage across capacitor C4 (or at the cathode
necessary to switch it into programming of D2) will do. Different values for C1 can be
mode. This is done by holding the master tag tried: the higher the measured voltage, the
up to the coil for around one minute. There better. With the correct capacitance voltages
then follows a twenty-second time window of more than 8 V are possible.
during which further tags can be pro- After these measurements have been carried
grammed. Programming mode can be reen- out and the tag IDs have been programmed
tered as above to store further tag IDs, up to a into the unit, further tests can be carried out
maximum of twenty (plus the master tag). making small adjustments to C1 to obtain
maximum reading range.
The circuit can be constructed using the (071154-I)
printed circuit board shown, whose layout is
available for download from the Elektor
Web Link
website. Current consumption with the relay [1] SF6107 information (in German):
off is around 16 mA. If a more powerful relay www.smatronic.mine.nu/SF6107.htm
is to be used, drawing more than 100 mA of
154
L
310 circuits
elektor international media bv – 089018/uk
pagina 154
Roland Plisch the TXD signal to clock eight data bits from
the DTR signal into a 4094 shift register.
The ‘Universal Interface for Windows’ de-
signed by Burkhard Kainka (Elektor Decem- On the positive-going edge of the RTS strobe
ber 1999 Supplement, page S2) provides for a it transfers these bits simultaneously to its
range of input interfaces along with eight dig- outputs. This arrangement can easily be ex-
ital outputs, all under direct control of a PC’s tended by adding further shift registers in
serial port. The program (available for free cascade, allowing data words of (in theory)
download from co.uk under ‘Magazine’) uses any desired size to be built up byte by byte.
1 R4 1
IC5.A
3
4k7 2 ≥1
C1
U+
680p
15 IC5.B IC5.C IC5.D
RTS EN3 5 8 12
IC1 1 4 10 11
C2 6 ≥1 9 ≥1 13 ≥1
SRG8
3
C1/
DTR
2 4
1D 2D 3
5
6
7
TxD 14
13
12
D1 D2 D3
11
9
4V7 4V7 4V7
10
4094N
+UB U+
U+
C2 C3
16 14
IC1 IC5
8 7 15 15 15
100n 100n EN3 EN3 EN3
1 1 1
IC2 C2 IC3 C2 IC4 C2
IC5 = 4081N 2 4 2 4 2 4
1D 2D 3 1D 2D 3 1D 2D 3
5 5 5
6 6 6
U+ 7 7 7
14 14 14
13 13 13
C4 C5 C6
16 16 16 12 12 12
IC2 IC3 IC4 11 11 11
8 8 8
100n 100n 100n 9 9 9
10 10 10
4094N 4094N 4094N
050109 - 11
155
R
310 schakelingen
elektor international media bv – 089018/nl
pagina 155
The circuit in Figure 1 shows shift register IC1 Q7 and Q8 respectively) of the first shift regis-
connected as before to the PCs interface. The ter is active. The software sends a 16-bit word
serial data pass through this device first, and containing the address and a data byte in a
then, via its serial cascade output (pin 9) to single transfer. For example, to select Q6 and
three further 4094s. The last (i.e., eighth) bit hence IC2, it is necessary simply to add 2048
of the shift register appears on this cascade to the eight-bit data value; for IC3 add 4096,
pin. and for IC4 add 8192.
The three shift registers IC2, IC3 and IC4 re- The circuit can be extended in similar fashion
ceive their strobe pulses, slightly delayed by using the spare outputs of IC1 (pin 4 to pin 7
R4 and C1, via AND gates IC5.B, IC5.C and and pin 14) to control further 4094s.
IC5.D when the corresponding output (Q6, (050109-1)
B. Broussas
1
This fine Summer’s day, you’ve decided to go +12V
out for a breath of fresh air – but without
wanting to give up your ‘hi-tech toys’ –
+12V
R3
T3
your daughter’s MP3 player (all borrowed of T1
3 2
But the problem gets a bit more complicated R4 R5 R6 R7
LED1
out in the country, and as Murphy’s Law has
56 Ω
10 Ω
4Ω7
1Ω5
156
L
310 circuits
elektor international media bv – 089018/uk
pagina 156
2 COMPONENTS LIST
Resistors
R1 = 820 Ω
R2 = 1 kΩ
R3 = 4kΩ7
R4 = 56 Ω
R5 = 10 Ω
R6 = 4Ω7
R7 = 1Ω5
Semiconductors
D1 = 1N4004
LED1 = LED, red
T1 = BC557
T2 = BC547
T3 = TIP20
Miscellaneous
S1 = 1-pole 4-way rotary switch (see text)
4 solder pins
PCB, ref. 080226-1 from www.thepcbshop.com
100%
cialized integrated circuit (IC). In spite of this, Now this voltage is produced by the current
it will look after your batteries, especially if passing through one of the resistors R4–R7,
you are reasonable about the charging time. and hence also the battery to be charged. So
it’s easy to see that this current is quite simply
Whether they are old nicads (NiCd) – becom- given by I ch = 0.6 / R where Ich is the desired
ing extinct these days because of their many charging current and R is one of the resistors
shortcomings and toxicity – or the omnipres- R4–R7.
ent nickel-metal-hydrides (NiMH), these types
of battery have to be charged at constant cur- As T2 turns on (and hence the battery is
rent. This charging current should be 10% of charging), transistor T1 increasingly satu-
their rated capacity (printed on the label) for a rates. If this current drops too much, or falls
normal or slow charge, or a maximum of 100% to zero in the event of a poor contact or faulty
of their capacity, if you want a fast charge. battery, the LED goes out to indicate a prob-
lem. Diode D1 protects the circuit from possi-
So, to recharge the NiMH or NiCd batteries in ble reversed polarity of the battery being
our various portable devices from a car bat- charged.
tery – for that’s what it’s all about – all you
have to do is build a constant current genera- We have designed a small PCB for this project
tor. To achieve this takes just two common or with provision for direct mounting of a rotary
garden transistors, T2 and T3. The latter is switch to be mounted, thereby reducing the
turned on to a greater or lesser extent by way wiring needed to nothing. This switch is
of R3 and T2. By virtue of the very principle of Lorlin part no. PT6422/BMH and is available,
transistors, there cannot be more than about for example, from Farnell under product ref.
0.6 V between the base and emitter of T2. If 1123675. However any other equivalent may
this voltage tends to drop, T2 will tend to be used if it can be adapted to the circuit
turn off, which will then increase the conduc- board. In most case, that means installing
tion of T3 – and vice-versa. In other words, some extra wires between the PCB and the
the base-emitter voltage of T2 will virtually al- switch pole and contacts. Transistor T2 may
ways remain at 0.6 V. be required to dissipate quite a lot of heat for
157
R
310 circuits
elektor international media bv – 089018/uk
pagina 157
low-voltage batteries being charged at high do take care all the same if you increase the
currents, so space has been provided to fit it charging current too much not to exceed the
with a U-shaped heatsink. The various de- maximum power dissipation in T3 (65 W) and
signed charging currents are 400, 130, 60, more importantly, the power allowed by the
and 10 mA for positions 1–4 of the switch. small heatsink provided for on the PCB. A cur-
The unavoidable voltage drop across T2 rent of 500 mA seems to us a reasonable max-
means the maximum voltage of the battery to imum value to not exceed. The value should
be recharged cannot exceed 9.6 V. cater for most NIMH and NiCd batteries if a
few hours are allowed to charge them. But
If you want different charging currents from then it was a sunny day so that shouldn’t be a
those designed, all you need do is simply serious concern.
replace one or other of R4–R7 by a resistor (080226-I)
whose value has been calculated as above
(R = 0.6 / I ch) and whose power is given by
Downloads
P = 0.36 / R. The PCB copper track and component mounting
plan can be downloaded from www.elektor.com;
As a constant-current generator, the circuit is file #080226-1.zip
naturally protected against short-circuits, but
V1 C4
100n ECC82 1 (6)
The small power require- BC517
D1
ment means that transduc- C1
(7) 2 T2
2200µ
16V
BC550 T1
reducing THD and other
non-linear distortions. R2 R3 R5
C3
22 Ω
91k
15k
158
L
310 circuits
elektor international media bv – 089018/uk
pagina 158
quality equipment aspires will generate a Since we have a low impedance output stage,
power of the load may be capacitively coupled via C4.
U 2 0775
, 2 Some purists may baulk at the idea of using
= = 18 mW an electrolytic for this job but he fact remains
R 32 that distortion generated by capacitive cou-
per channel across a headphone of this im- pling is at least two orders of magnitude
pedance. An examination of available head- lower than transformer coupling.
phones at well known high street emporiums The rest of the circuitry is used to condition
revealed that the sensitivity varied from 96 dB the various voltages used by the circuit. In or-
to 103db/mW! So, in practice the circuit will der to obtain a linear output the valve grid
only require unity gain to reach deafening lev- needs to be biased at half the supply voltage.
els. This is the function of the voltage divider R4
and R2. Input signals are coupled into the cir-
As a unity gain design is required it is quite cuit via C1 and R1. R1, connected between
possible to employ a low distortion output the voltage divider and V1’s grid defines the
stage. The obvious choice is an emitter fol- input impedance of the circuit. C1 has suffi-
lower. This has nearly unity gain combined ciently large a value to ensure response down
with a large amount of local feedback. Unfor- to 2 Hz.
tunately the output impedance of an emitter
follower is dependent upon the source im- Although the circuit does a good job of reject-
pedance. With a volume control, or even with ing line noise on its own due to the high im-
different signal sources this will vary and pedance of V1’s anode and T3’s collector
could produce small but audible changes in current, it needs a little help to obtain a silent
sound quality. To prevent this, the output background in the absence of signal. The
stage is driven by a cathode follower, based ‘help’ is in the form of the capacitance multi-
around an ECC82 valve (US equivalent: plier circuit built around T5. Another BC517 is
12AU7). This device, as opposed to a transis- used here to avoid loading of the filter com-
tor configuration, enables the output stage to prising R7 and C5. In principle the capaci-
be driven with a constant value, low imped- tance of C5 is multiplied by the gain of T5. In
ance. In other words, the signal from the low practice the smooth dc applied to T5’s base
impedance point is used to drive the high im- appears at low impedance at its emitter. An
pedance of the output stage, a situation important added advantage is that the supply
which promotes low overall THD. voltage is applied slowly on powering up.
This is of course due to the time taken to fully
At the modest output powers required of the charge C5 via R7. No trace of hum or ripple
circuit, the only sensible choice is a Class A can be seen here on the ‘scope. C2 is used to
circuit. In this case the much vaunted single- ensure stability at RF.
ended output stage is employed and that The DC supply is also used to run the valve
comprises of T3 and constant current source heater. The ECC82 has an advantage here in
T1- T2. The constant current is set by the Vbe that its heater can be connected for operate
voltage of T1 applied across R5. With its value from 12.6 V. To run it T4 is used as a series
of 22 Ω, the current is set at 27 mA. T3 is used pass element. Base voltage is obtained from
in the emitter follower mode with high input the emitter of T5. T4 has very low output im-
impedance and low output impedance. In- pedance, about 160 mΩ and this helps to pre-
deed the main problem of using a valve at low vent extraneous signals being picked up from
voltages is that it’s fairly difficult to get any the heater wiring. Connecting the transistor
real current drain. In order to prevent distor- base to C5 also lets the valve heater warm up
tion the output stage shouldn’t be allowed to gently. A couple of volts only are lost across
load the valve. This is down to the choice of T4 and although the device runs warm it
output device. A BC517 is used for T3 because doesn’t require a heat-sink.
of its high current gain, 30,000 at 2 mA! (050347-1)
159
R
310 circuits
elektor international media bv – 089018/uk
pagina 159
Bernhard Schnurr
160
L
310 circuits
elektor international media bv – 089018/uk
pagina 160
exceeds a certain value, forming a kind of The graph shows the points at which the reed
electronic fuse. Equally, we can produce a switch changes state, as a function of the an-
normally-off contact which makes at a de- gle at which the second magnet is placed and
fined coil current: essentially a configurable on the coil current. The curve is not particu-
relay. With the prototype shown we achieved larly smooth, as you might expect from genu-
switching currents of up to approximately ine measured data.
180 mA, and with the second magnet cor-
rectly adjusted it is possible to achieve Without the second magnet the contact pulls
switching currents down to just one in at 63 mA and drops out at –17 mA.
milliamp. (071158-I)
161
R
310 circuits
elektor international media bv – 089018/uk
pagina 161
R4 +4V8...+5V5
100 Ω
K1
C2 C1 A
10n 100µ
10V K2
B
14
K3
see below 4
K7
G
K8
H
060104 - 11
C
R3
A TTL B
4k7
servo
PIC BASIC
RS232 B
T1
A R1 B A R2
22k 10k
BC547
Graupner
Conrad Futaba Multiplex Robbe Microprop Simprop
/JR
Dialogue with the MIC800 occurs at 2,400 à m is a letter included between S and Z
baud on 8 data bits, without parity. The syn- which corresponds to the MIC800 ad-
tax of the commands to be sent for control- dress. In fact, if you consult the datasheet
ling the servos is extremely simple and is available on the Mictronics site, you’ll
composed of the next group of coded charac- soon notice that you can place up to eight
ters in ASCII m n xxx where: MIC800s on a single serial connector and
162
L
310 circuits
elektor international media bv – 089018/uk
pagina 162
control up to 64 servos in this way. This SEROUT Pin, 16780, ["S", "’X"’, DEC Pos, CR]
option is not utilized here and the address
is set to S using pin grounding AD0 to where Pin is utilized for the serial port, X is
AD2. the letter identifier of the servo included be-
tween A and H (K1 to K8) and Pos is the de-
à n stands for a letter between A and H indi- sired position included between 1 and 128.
cating the servo to control in compliance With a PICBasic ( and the same text as below,
with the marks, as indicated in our dra- we would write:
wing at the connectors (K1 corresponding
to A, and K8 to H). SEROUT Pin, 138, 0, 0, ["S", "X", DEC(Pos), 13]
à xxx is a number between 001 and 128 After turning on the MIC800, all outputs of
which indicates the position required for the servo control are inactive. Then, as soon
the servo, 001 corresponding to the extre- as a command has been sent to a servo desti-
me counter-clockwise position and 128 to nation, the corresponding output automati-
the extreme position in the other direction. cally generates the pulses required to
maintain its position as long as the circuit re-
From a Basic Stamp, all you need to do is mains on.
write it as shown in the following example: www.tavernier-c.com (060104-1)
163
R
310 circuits
elektor international media bv – 089018/uk
pagina 163
S1
magnet
T2
R4
5 1
screening D 4k7
Reset IC1.A T1
C1 R3
reed relay 3 2
C 4k7
1µ R S
4 6 R5 R6
R1 R2
LED
BZ1 D1
10k
10k
14
IC1 = 4013 IC1
7 acoustic optical
indication indication
080243 - 11
magnet glued to lid
reed relay
opposite
fixed part
letterbox
COMPONENTS LIST
164
L
310 circuits
elektor international media bv – 089018/uk
pagina 164
grounding or not of GP2 or GP3 via override by switching to manual mode. The relay
switch S1. So there are three possible states: should be released in the ‘off’ position and
permanently off, permanently on, and auto- energized in the ‘on’ position. Then all that
matic mode, which is the one normally used. remains is to adjust the day night threshold
Given the software programmed into the by adjusting potentiometer P1. To do this,
12C508 (‘firmware’) and the need to generate you can either use a lot of patience, or else
very long delays so as to arrive at lighting use a voltmeter – digital or analogue, but the
times or an hour or more, it has been necess- latter will need to be electronic so as to be
ary to make the MCU operate at a vastly re- high impedance – connected between GP4
duced clock frequency. In that case, a crystal- and ground.
controlled clock is no longer suitable, so the When the light level below which you want
R-C network R5/C3 is used instead. For sure, the lighting to be allowed to come on is
such a clock source is less stable than a crys- reached, adjust P1 to read approximately
tal, but then in an application like this, that 1.4 V on the voltmeter. If this value cannot be
may well be what we’re after as a degree of achieved, owing to the characteristics of your
randomness is a design target instead of a dis- LDR, reduce or increase R8 if necessary to
advantage. achieve it (LDRs are known to have rather
wide production tolerances).
Our suggested PCB shown here takes all the Equipped with this inexpensive accessory,
components for this project except of course your home of course hasn’t become an im-
for S1, S2, and the LDR, which will need to be pregnable fortress, but at least it ought to ap-
positioned on the front panel of the case in pear less attractive to burglars than houses
order to sense the ambient light intensity. that are plunged into darkness for long per-
The PCB has been designed for a Finder relay iods of time, especially in the middle of sum-
capable of switching 10 A, which ought to mer.
prove adequate for lighting your home, un- www.tavernier-c.com (080231-I)
less you live in a replica of the Palace of Ver-
sailles.
Downloads
The program to be loaded into the 12C508 is The PCB layout can be downloaded free from
available for free download from the Elektor our website www.elektor.com; file # 080231-1.
website as file number 080231-11.zip or from The source code and .hex files for this project
the author’s own website. are available free on www.elektor.com;
On completion of the solder work the circuit file # 080231-11.zip.
should work immediately and can be checked
165
R
310 circuits
elektor international media bv – 089018/uk
pagina 165
telephone line
gas
discharge LA1
near a telephone line, the line carries tran- tube
sient voltages up to several thousands of VDR
166
L
310 circuits
elektor international media bv – 089018/uk
pagina 166
167
R
310 circuits
elektor international media bv – 089018/uk
pagina 167
formance. Large output capacitors (which, in Current regulation is carried out by IC1D.
the case of a fault, will discharge into your cir- Again to ensure stability, the bandwidth of
cuit) and voltage overshoot are other prob- the feedback loop is restricted by R19 and C8.
lems. If the voltage dropped across R17 exceeds the
value set by P2, the current limit function co-
The power supply described here is a simple mes into action and T2 begins to conduct.
unit, easily constructed from standard com- This in turn reduces the input voltage to the
ponents. It is only suitable for small loads but voltage regulation circuit until the desired
otherwise has all the characteristics of its big- current is reached. R7, R9 and C3 ensure that
ger brethren. Between 18 V and 24 V is ap- current regulation does not lead to output
plied to the input, for example from a laptop voltage overshoots and that resonance does
power supply. This avoids the need for an ex- not occur with inductive loads.
pensive transformer and accompanying
smoothing. No negative supply is needed, but The controls of the power supply are all volt-
the output voltage is nevertheless adjustable age-based. This means, for example¸ that P1
down to 0 V. and P2 can be replaced by digitalto-analogue
converters or digital potentiometers so that
A difficulty in the design of power supplies the whole unit can be driven by a micro-
with current limiting is the shunt resistor controller. IC1B acts as a buffer to ensure that
needed to measure the output current, nor- the dynamic characteristics of the circuit are
mally connected to a differential amplifier. not affected by the setting of P1.
Frequently in simple designs the amplifier is IC1A is used as a comparator whose output is
not powered from a regulated supply, which used to drive two LEDs that indicate whether
can lead to an unstable current regulation the supply is in voltage regulation or current
loop. This circuit avoids the difficulty by using regulation mode. If D2 lights the supply is in
a low-cost fixed voltage regulator to supply constant voltage mode; if D1 lights it is in
the feedback circuit with a stable voltage. constant current mode, for example if the
This arrangement greatly simplifies current output has been shortcircuited. The power
measurement and regulation. supply thus boasts all the features of a top-
class bench supply.
To generate this intermediate supply voltage IC1A and its surrounding circuitry can be dis-
we use an LM7815. Its output passes through pensed with if the mode indication is not
R17, which measures the output current, to wanted.
MOSFET T1 which is driven by the voltage A type LM324 operational amplifier is sug-
regulation opamp IC1C. Here R11 and C4 de- gested as, in contrast to many other similar
termine the bandwidth of the control loop, devices, it operates reliably with input volt-
preventing oscillation at high frequencies. ages down to 0 V. Other rail-to-rail opamps
R15 ensures that capacitive loads with low ef- could equally well be used. The particular n-
fective resistance do not make the control channel MOSFET devices used are not critical:
loop unstable. The negative feedback of AC a BUZ21, IRF540, IRF542 or 2SK1428 could be
components of the current via R12 and C5 used for T1, for example, and a BS170 could
makes the circuit reliable even with a large ca- be used in place of the 2N7002. The capaci-
pacitor at its output, and negative feedback tors should all be rated for a voltage of 35 V or
of the DC component is via the low-pass filter higher, and R15 and R17 must be at least
formed by R14 and C6. This ensures that the 0.5 W types. The fixed voltage regulator and
voltage drop across R15 is correctly compen- T1 must both be equipped with an adequate
sated for. C7 at the output provides a low im- heatsink. If they are mounted on the same
pedance source for high-frequency loads, and heatsink, they must be isolated from it as the
R16 provides for the discharge of C17 when tabs of the two devices are at different poten-
the set voltage is reduced with no load at- tials.
tached. (080326-I)
168
L
310 circuits
elektor international media bv – 089018/uk
pagina 168
Ray King
R5 R4 R6 R1
C3
10k
10k
10k
10k
100n D1
14
D2
4 6
MCLR RB0
7 D3
K1 RB1
S 17 IC1 8
RA0 RB2 C4
Servo 18 9 D4
under RA1 RB3
1
Test RA2 PIC16F84 RB4 10 100n
2 -AP 11 D5
RA3 RB5
3 12
RA4/T0CKI RB6
13 D6
RB7
D8 OSC2 OSC1
D7
15 16 5
X1
R3 R2
S1 S3 S2
C2 C1
1k
1k
27p 27p
DOWN UP MODE 8MHz
040172 - 11
169
R
310 circuits
elektor international media bv – 089018/uk
pagina 169
170
L
310 circuits
elektor international media bv – 089018/uk
pagina 170
servos on a model can be tested at once. The like the 4805 or the LM2940 you find sug-
board shown in the photograph is a proto- gested here because it will not drain an al-
type differing from the final version in minor most flat battery due to its own current. An
detail. on/off switch is also recommended. The
standby current consumption of the circuit
The source code was written using Proton PIC amounts to about 5 mA.
Basic+ which then compiles into assembler Finally, PIC burners among you using the hex
and object code. For those with a PIC pro- file should set the config bits as follows: HS
grammer, all project software including the (10) (since xtal > 4 MHz ); WDTE disable (0);
hex and source code files is available as a free PWRTE enable (0). The other config bits are
download, file ref. 040172-11.zip, from the for code protection and their use is at your
Elektor website. The PIC is also available discretion.
ready programmed under number 040172-41. (040172-1)
Burkhard Kainka R6
22k
171
R
310 circuits
elektor international media bv – 089018/uk
pagina 171
Operation is largely independent of supply 0.6 V). The phase shifting network gives rise
voltage, and the average LED current is set at to the oscillation around this average value.
about 10 mA. The circuit adjusts the voltage In the prototype of this circuit we used an ul-
across the emitter resistor so that it matches tra-bright red LED.
the base voltage of the first transistor (around (080383-I)
R5
C2 C3 C1
3k3
IC1.B
IC1.C
IC1.D
IC1 1N4148
S3 3 4 10 11
3 7
& & & &
16
S4
IC socket
4 1 2 5 6 8 9 12 13
3
0 CTRDIV10/
2
S5 1 DEC
5 4
2 CT=0
15
7
3
S6 10
IC2
6 4
1
5
5
S7 6 4017
7 6 14
R7 7 & electronic
9 + doorlock
8
3k3
S8 D6 red 11 13 connections
8 9
IC1 = 4011 12
CT≥5
S9
9
8
green
dual LED T1
S10 R8
0 R1 R2 R3 R4
10k
3k3
3k3
3k3
3k3
BC517
060085 - 11
172
L
310 circuits
elektor international media bv – 089018/uk
pagina 172
counter outputs are at the ‘0’ level. Dual LED correctly within 10 seconds, the Q4 output
D6 will be on and red to indicate that a code (pin 10) will ultimately go to ‘1’ and the dual
can be entered. If the button for the first digit LED will change to green. After 10 seconds,
of the preset code is now pressed (in this case C1 will again be discharged and the dual LED
the ‘0’ button), the output of IC1a will go to will change back to red. The Q4 output can be
‘0’ and the reset input of IC2 will also go to ‘0’ used to switch something, such an electronic
via D1 and D5. When the button is released, a door latch.
rising edge appears at the clock input of IC2, If you want to change the code, you only have
which causes the counter to be incremented to change the configuration of the wire jump-
by 1. Thanks to R6 and C1, the reset input of ers in the IC socket.
IC2 remains low for around 10 seconds. Out- The combination of diodes D1–D4 and R5
put Q1 (pin 2) of the counter is now ‘1’ as a re- acts as an AND gate. If the output of one of
sult of the clock pulse, and IC1b is waiting for the four NAND gates in IC1 is ‘0’ (which is al-
the second button (‘2’) to be pressed. If that ways the case if a correct button is pressed), a
doesn’t happen within 10 seconds, C1 dis- ‘0’ is applied to the clock input of IC2 as long
charges via R5 and R6 to a level that causes as the button is held pressed. If you find a de-
IC2 to be reset. Dual LED will again become lay of 10 seconds too long, you can reduce the
red, and the user must start entering the code value of R6 or C1. The time is approximately
again. However, if the buttons for the each of equal to the product of R6 and C1 (R6× C1).
the remaining digits of the code are pressed (060085-1)
R1 RCX 5 G2
470k 8 D1 3D
ues. 4
PWM
3 S 5
C3 16 16 C4 C
modules in
070378 - 11
173
R
310 circuits
elektor international media bv – 089018/uk
pagina 173
8-bit word can be produced for example from The diagram shows the circuitry required to
an expansion board fitted in a PC or from an produce just one waveform. For the full two
8-bit port of a processor which does not have channel circuit it is necessary to use an addi-
built-in PWM capability or from a laptop’s tional 74HC193. The clock signal produced by
printer port. the HCF4060 generator can be used to drive
The mark/space ratio is only programmable both channels and the free flip flop in the
up to 15/16 rather than 16/16; a binary input 74HC74 package can be used for the second
of 0000 produces a continuous low on both channel (the corresponding pin numbers are
outputs turning both motors off. Similar cir- shown in brackets).
cuits often employ a dedicated ‘enable’ input Altogether the entire two channel circuit can
to turn the motors off but it is not necessary be built using just four ICs.
in this design. (070378-I)
174
L
310 circuits
elektor international media bv – 089018/uk
pagina 174
U+
R2 R8
C3
10k
100k
S1 1000µ
IC3 25V
5
1
4
R1
R4 16 2
1k
470k 3 3
0
CTRDIV10/ 2 D1 TDA2030
1
DEC D2 "I"
4
IC1 2
7 D3 M1
1 IC2 3 IC5 A2 A1
3 7 10 D4 "Q" 5
4 1
5
6 14 1
LF356 & + 5 4 M
2 5
6 4x 2
4 P1 13
7
6 1N4148
9 3 B1 B2
4017 8
11 TDA2030
R5 9
15 12
330k CT=0 CT≥5 IC4
1M 5
2
8
4
1
3
R3 R6 R7 R9
C1 C2
TDA2030
5k6
5k6
10k
100k
0µ47 2µ2
16V
050246 - 11
The other ends of the windings are in turn ble for the motor to continue turning a cer-
connected to half the supply voltage, pro- tain amount due to its own inertia or the
vided by IC5. As one end of each winding is mechanical load on the motor (flywheel ef-
connected to a square-wave signal that alter- fect). It’s also possible for the position of the
nates between 0 V and a potential close to the motor to disagree with the states of the I and
supply voltage, while the other end is at half Q signals when power is first applied to the
the supply voltage, a voltage equal to half the circuit. As a result, the motor can sometimes
supply voltage is always applied to each wind- ‘get confused’ when starting up, with the re-
ing, but it alternates in polarity according to sult that it takes a step in the wrong direction
the states of the I and Q signals. That’s exactly before starting to move in direction defined
what we want for driving a bipolar stepper by the drive signals.
motor.
These effects can be avoided by adding the
The rpm can be varied using potentiometer optional switch S1 and a 1-kΩ resistor, which
P1, but the actual speed is different for each can then be used to start and stop the motor.
type of motor because it depends on the When S1 is closed, the clock signal stops but
number of steps per revolution. The motor IC2 retains its output levels at that moment,
used in the prototype advanced by approxi-
mately 9° per step, and its speed could be ad-
justed over a range of approximately 2 to 10
seconds per revolution. In principle, any de-
sired speed can be obtained by adjusting the
value of C1, as long as the motor can handle
it. The adjustment range of P1 can be in-
creased by reducing the value of resistor R5.
The adjustment range is 1 : (1000 + R5) / R5,
where R5 is given in kΩ.
175
R
310 circuits
elektor international media bv – 089018/uk
pagina 175
so the continuous currents through the mo- IC3, IC4 and IC5 to a heat sink (possibly a
tor windings magnetically ‘lock’ the rotor in shared heat sink) when a relatively high-
position. power motor is used. The tab of the TO220
case is electrically bonded to the negative
The TDA2030 has internal overtemperature supply voltage pin, so the ICs can be attached
protection, so the output current will be re- to a shared heat sink without using insulating
duced automatically if the IC becomes too washers.
hot. For that reason, it is recommended to fit (050246-1)
Ernst Krempelsauer
& Burkhard Kainka 1
L1
IC1
*
The well-known PR4401 and PR4402 LED PR4401/02
drivers from PREMA have enjoyed great popu- 1 3
larity as a result of their low cost, tiny physical FF
size, and ready availability. The device is a BT1 D1
switching regulator that is specifically de-
signed for driving white LEDs from a single 0V9...1V5
2
mA (PR4402). 080486 - 12
176
L
310 circuits
elektor international media bv – 089018/uk
pagina 176
3 4
L1
D1...D3 = 1N4148
IC1
10µH...20µH
L1 PR4401/02
10µH (PR4401)
D1 +9V
IC1 1 3
4µH7 (PR4402)
PR4401/02 FF
BT1
D2 D4
1 3 C2
FF 1N4148
BT1 1V5 47µ
D2 2 16V 9V1
C1
1V5 47µ
2 25V 3V3...15V
C1 D2 C3
080486 - 13
100n 47µ
16V
D3
080486 - 14 –9V
voltage) the current will fall. With ten cells struments and in remote controls for garage
(12 V) the current flow to the battery is just 6 door openers. The maximum output current
mA (PR4401) or 12 mA (PR4402). from the voltage regulator can be calculated
as follows:
The ICs are less suitable for applications Pmax
where the load characteristics are not con- I max =
stant. The lower the load, the higher the out- UZ
put voltage, and with an open-circuit output Pmax is 70 mW (PR4401) or 140 mW (PR4402)
an internal zener diode limits the output volt- and UZ is the zener voltage, which is equal to
age to approximately 18 V. This diode there- the output voltage. The circuit is most effi-
fore effectively replaces the missing load and cient when the output current is near to Imax.
dissipates the power output by the regulator. If necessary, Imax can be reduced by using a
If the output voltage is limited to a lower higher-valued inductor to match it better to
value using an external zener diode then the the required output load. To a reasonable ap-
regulator will deliver all the output power not proximation, doubling the inductance will
taken by the load into the diode. The upshot halve the maximum output current.
of all this is that the lower the load, the We can also use a LED driver to generate a
poorer the efficiency of the circuit. symmetrical supply from a single NiMH or al-
kaline cell. Figure 4 shows a practical exam-
Applications of this attractive device as a volt- ple generating +9 V and –9 V. Because of the
age source are also worth a quick look. For additional diode in the negative arm of the
example, you might be looking for an applica- circuit, the negative output is about 0.7 V
tion for the printed circuit board, with lower in magnitude than the positive. In our
PR4401 IC and coil ready fitted, that came prototype, where we used a 15 µH inductor
free with the September 2007 issue of Elektor. and a 1.5 V cell voltage, we obtained the mea-
sured output voltages of +9 V and –8.3 V
Figure 3 shows the circuit of a simple voltage (with no load), and +8.6 V and –7.9 V (with a
regulator using a PR4401 or PR4402. The 2.2 kΩ load, simulating the 4 mA current
zener diode voltage is chosen according to draw of a typical opamp circuit).
the wanted output voltage, between 3 V and
15 V. These voltages can be generated from a The current drawn from the 1.5 V cell was
single NiMH or alkaline cell (1.2 V or 1.5 V), 50 mA in the no-load case and 80 mA in the
which, for example, allows you to replace the 2.2 kΩ load case.
expensive 12 V batteries found in some in- (080486-I)
177
R
310 circuits
elektor international media bv – 089018/uk
pagina 177
Rainer Reusch sis of the comparator has been set so that the
comparator state will only change again, tur-
Where there is heat, let us bring cooling: a fan ning off the fan, if the temperature falls below
will do the job, but unfortunately fans are 30 °C. Capacitor C3 ensures that the fan is run
usually noisy. In many cases there is no need at full voltage for about 0.7 seconds immedia-
for the fan to run continuously at full speed, tely after switch-on, so that the motor will
and so it makes sense to control the fan speed start reliably.
in response to the temperature of the heat- The fourth opamp in the LM324, IC1.C, is
sink or device being cooled, switching the fan used to create an over-temperature warning
off entirely if it should fall to
room temperature. 4,00V @ 30°C (1,040k)
4,11V @ 35°C (1,080k)
4,23V @ 40°C (1,122k)
The circuit shown here does 4,47V @ 50°C (1,209k)
82k
1k2
ture sensor, in a negative-
feedback arrangement with R6
T1
an operational amplifier. C2
4k7
4k7
voltage at the non-inverting IC1.A
1 13
39k
12V DC
verts this relatively small 10µ
25V
swing and inconvenient
voltage offset into the IC1 = LM324
+12V
range 8 V to 12 V suitable R11 R14
for the fan. The third opera- 4 C1
2k4
20k
IC1.B OVERTEMP
5 8
with it, switching transistor 1N4148
10
IC1.C
T1 off. R13 C3
130k R17
10µ 180k
If the temperature exceeds R12 25V R15
12k
178
L
310 circuits
elektor international media bv – 089018/uk
pagina 178
indicator. This is necessary in case the fan, connected to its output (pin 8); alternatively a
even running at full speed, is not able to pro- transistor could be used to drive a relay.
vide enough cooling, or, because of a fault, The circuit is sufficiently accurate without ad-
cannot reach full speed. This opamp is also justments, but metal-film resistors with a to-
configured as a comparator. If the sensor lerance of 1 % should be used. Some of the
temperature reaches a value of 60 °C, the values used are from the E24 series.
comparator output goes high (to nearly 12 V). The supply voltage is used as a reference
The output will only go low again (nearly 0 V) throughout, and so should be well regulated:
if the temperature falls below 40 °C. An LED a 7812 voltage regulator is adequate.
(with series current-limiting resistor) can be (060057-1)
In a very small space, and powered by simple As the circuit diagram shows, the project is
primary cells or rechargeable batteries, the extremely simple, as it contains only a single
proposed circuit generates a low-energy, active element, and then it’s only a fairly ordi-
high voltage of the order of around 200 to nary transistor. As shown here, it operates as
400 V, harmless to humans, of course, but still a low-frequency oscillator, making it possible
S1
TR1 R2 HT
470k
0W5
R1
9V
C2 C3
240V
22k
C1
R3 HT
12V 470k
1VA2...3VA
25V T1 0W5
C4 1N4007 R4 +HT
2N2219A 470k
470n D2 0W5
630V
D1 C5
470n
1N4007 630V
R5 –HT
470k
080229 - 11 0W5
179
R
310 circuits
elektor international media bv – 089018/uk
pagina 179
to convert the battery’s DC voltage into an AC voltage doubler, shown at the bottom right of
voltage that can be stepped up via the trans- the figure, which will then produce around
former. Using a centre-tapped transformer as 300 V, even more unpleasant to touch. Here
here makes it possible to build a ‘Hartley’ os- too of course, the resistors, now know as R4
cillator around transistor T1, which as we and R5, must always be present.
have indicated above was used a great deal in
radio in that distant era when valves reigned The circuit only consumes around a few tens
supreme and these was no sign of silicon of mA, regardless of whether it is ‘warding off’
taking over and turning most electronics into someone or not! If you have to use it for long
‘solid state’. The ‘Hartley’ is one of a number periods, we would however recommend
of L-C oscillator designs that made it to eter- powering it from AAA size NiMH batteries in
nal fame and was named after its invertor, groups of ten in a suitable holder, in order
Ralph V.L Hartley (1888-1970). not to ruin you buying dry batteries.
For such an oscillator to work and produce a Warning! If you build the version without the
proper sinewave output, the position of the voltage doubler and measure the output vol-
intermediate tap on the winding used had to tage with your multimeter, you’ll see a lower
be carefully chosen to ensure the proper step- value than stated. This is due to the fact that
down (voltage reduction) ratio. Here the step- the waveform is a long way from being a sine-
down is obtained inductively. wave, and multimeters have trouble interpre-
Here, optimum inductive tapping is not possi- ting its RMS (root-meansquare) value.
ble since we are using a standard, off-the- However, if you have access to an oscillosco-
shelf transformer. However we’re in luck – as pe capable of handling a few hundred volts on
its position in the centre of the winding crea- its input, you’ll be able to see the true values
tes too much feedback, it ensures that the os- as stated. If you’re still not convinced, all you
cillator will always start reliably. However, need do is touch the output terminals…
the excess feedback means that it doesn’t ge-
nerate sinewaves; indeed, far from it. But To use this project to protect the handle of
that’s not important for this sort of applicati- your beach bag or your attaché case, for
on, and the transformer copes very well with example, all you need do is fix to this two
it. small metallic areas, quite close together,
each connected to one output terminal of the
The output voltage may be used directly, via circuit. Arrange them in such a way that un-
the two current-limiting resistors R2 an R3, wanted hands are bound to touch both of
which must not under any circumstances be them together; the result is guaranteed! Just
omitted or modified, as they are what make take care to avoid getting caught in your own
the circuit safe. You will then get around trap when you take your bag to turn the cir-
200 V peak-to-peak, which is already quite cuit off!
unpleasant to touch. But you can also use a (080229-I)
180
L
310 circuits
elektor international media bv – 089018/uk
pagina 180
re1
12V
10A
D1 D4 D3 D5
OVERLOAD OK
red 1N4001 1N4001 green
K1 K2
RE1 R5
D2
1k
9V...19V2 320 Ω
+10V...+30V DC 1N4001
R1 L1 D7
*
100 Ω
4mH
0Ω9 1N4001
T1
*see text R3
1k
D6
1N4001
2N3904 R4 R2 R6
C2 C1
0Ω47
100k
100k
47µ 47µ
25V 25V 3W
060076 - 11
tion! In this circuit, the detecting element is Inductor L1 slows the inrush of current when
resistor R6. Under normal conditions, its volt- the circuit is switched on, which would other-
age drop is not high enough to switch on wise cut off the circuit immediately. D2 and
transistor T1. The value of R6 can be altered D7 provide the usual back-emf protection
to give a different cut-off current, as determi- across the coils.
ned by Ohm’s Law, if required. When a short
circuit occurs in the load, the voltage rises ra- In use, the input of the circuit is connected to
pidly and T1 starts to conduct. This draws in the main transformer-rectifier-capacitor-fuse
the relay, switching its contacts, which cuts power supply via K1, and the output is con-
off power to the external circuit, and instead nected to the (experimental) load via K2. Note
powers the relay coil directly, latching it in that the input voltage must be a floating sup-
this second state. The circuit remains in this ply if Vout– is grounded via the load, as Vin–
state until the primary power supply is swit- and Vout– must not be connected together.
ched off.
Some consideration needs to be given to a
Capacitors C1 and C2 hold enough charge (via number of components.
D3, D4 and D6, which prevent the charge
from being lost to the rest of the circuit, First, the choice of relay Re1. For the proto-
whichever state it is in) to keep T1 switched type, this was obtained from Maplin, part
on and power the relay while it switches over, number YX97F. This is has a coil resistance of
and R2 and R4 provide slow discharge paths. 320 Ω, which with R1 forms the collector load
LEDs D1 (red) and D5 (green) indicate what for T1. Its allowed pull-in voltage range is no-
state the circuit is in. minally 9 V to 19 V, which limits the input
181
R
310 circuits
elektor international media bv – 089018/uk
pagina 181
power supply voltage to between around the input power supply should be a ‘slow-
10 V to 30 V (DC only). R1 could be replaced blow’ type; ‘fast’ fuses will rupture before the
by a wire link for operation at input voltages relay has time to switch. Also note that this
below 10 V, or increased in value, as determi- device is meant to save fuses, not replace
ned by either the application of Ohm’s Law them.
once more or trial and error, for an input volt- A mains transformer must always be fused if it
age above 30 V. is not designed to run safely, i.e., without pre-
senting a fire hazard, even if its output has a
Coil L1 was obtained from Farnell, part num- continuous short-circuit fault.
ber 581-240. Finally, the protective fuse for (060076-1)
Stefan Hoffmann tons take over the role of the probe tip. In
contrast to the simple version, the built-in ‘in-
The rules of the ‘123’ Game are described in telligence’ of the microcontroller also allows
the ‘123 Game – all MCU-free’ article (see two humans to play against each other.
page 66). Naturally, a more luxurious version
can be built with a microcontroller. Here you A ‘welcome screen’ with various LED patterns
don’t have to manipulate a probe tip to play is displayed after the circuit is switched on. A
the game, and the playing field is formed by bicolour LED then cycles through all three co-
LEDs instead of mini-sockets. A microcontrol- lours (red, green and orange) while waiting
ler drives the LED array, and three input but- for the player to select a game mode:
182
L
310 circuits
elektor international media bv – 089018/uk
pagina 182
à Button 1: Human vs. MCU; human starts; the goal, this is corrected automatically. In
à Button 2: MCU vs. human; MCU starts; the human vs. human mode, the bicolour LED
à Button 3: Human vs. human. turns orange to indicate that it’s the oppo-
nent’s turn.
The course of play is essentially the same as
before. The human player and the computer The winner is determined by the microcon-
take turns moving by one, two or three steps. troller. If the human player wins, the bicolour
When it’s the human’s turn to move, he or she LED blinks green, and if the computer wins it
presses a button for the desired number of blinks red. If the opponent wins, the LED
steps (‘1’, ‘2’ or ‘3’). The selection steps is con- blinks orange/red. A beeper gives extra lustre
firmed by the ‘123’ LEDs and then performed to the ‘victory ceremony’. It gives a low beep
on the playing field LEDs. The bicolour LED is if the human loses and celebrates a human
green when it’s the human’s turn and red victory with two high beeps.
when it’s the computer’s turn. Purely for ef-
fect, the computer does not move right away, The software for the ATmega8 was generated
but instead ‘ponders’ a while before moving, using BASCOM, and it can be compiled with
and the moves are made slowly, step by step, the demo version. The BASCOM source code
instead of all at once. and a hex file can be downloaded from the
The number of steps the computer wants to www.elektor.com – the archive file number is
move is also shown by the ‘123’ LEDs. The 080132-11.zip. A preprogrammed microcon-
move is then performed on the playing field troller is also available (order no. 080132-41).
LEDs. If the human player tries to move past (080132-1)
Back in November 2003 you could already software. In plain language: this method only
read about a small development system for works with a well-behaved program. And this
the (then) new series of controllers from the is obviously not always the case in a develop-
8051-compatible 89LPC9xx-family. ment environment!
A nice feature of the current 89LPC9xx-series When you also look at the schematic from
is that these chips can remain in the circuit 2003, you will see that very little has changed.
while (re-)programming. All that’s required Really the only difference is that the RS232 in-
for this programming is an RS232 port. But terface chip has been replaced with the
because many modern computers do not FT232R. As you will know, the USB-interface
have an RS232 connection any more, we pro- is terribly slow when the handshake lines
pose here a USB version. For this we use a such as DTR and RTS are used. Fortunately
well-known USB/RS232-converter chip, the that is not the case here, since DTR and RTS
FT232R. are used just once at the beginning and end of
The 89LPC9xx series can be placed in pro- the programming cycle. The actual program-
gramming mode in two different ways: by ming is done by transmitting commands and
transmitting a ‘break’ over the serial port or data across the serial port.
by providing three defined reset pulses im-
mediately after power-on. We use the latter A few remarks
method, because this is a hardware solution. To be able to program you will have to
This is because the ‘break’ has to be sensed by change a jumper each time. On the one hand
183
R
310 circuits
elektor international media bv – 089018/uk
pagina 183
this is a little tedious, but on the other hand it placed in power-up mode by the brownout
gives a little bit of security. During software circuit and therefore cannot be placed in pro-
development a double pole change-over gramming mode either.
switch does wonders! Note that the proces- That is why a resistor of 4k7 has been added
sor is placed in programming mode by three to drop the power supply voltage faster and
reset pulses after power-on. If the power sup- lower. Check the inputs in your application. If
ply voltage does not drop sufficiently before- these are powered from another voltage then
hand (<2.7 V), then the processor will not be the processor will be powered from its inputs
184
L
310 circuits
elektor international media bv – 089018/uk
pagina 184
via the protection diodes and programming You can also omit L1, but it is better to put a
will not work then! few turns of wire through a ferrite bead.
It is possible (but not necessary) to power the The pin numbering shown is for the SSOP-28
circuit through a low-drop regulator from the package.
USB-connection. (064013-1)
R4 R8
C7
9k1
15k
D3 RE1
100n
re 1a re1b
IC2
1N4001
TSOP1136 2 T1
2 R1
1
P2 D1 IC1.A 1k
3 3 K2 K4
L R
1M 1N4148 BC547C
1
R3 R5 IC1 = LM393N
1k8
33k
T2 R7 P1 R2
C1 C6
100 Ω
330k
10k
3µ3 22µ
16V 16V
BC559
TSOP1136 IC3
+9V S1 D2 7805 +5V
R6
1N4001
1k
8
C2 C3 C4 C5 IC1
1 3 4 D4
2
220µ 100n 100n 220µ
25V 16V
080325 - 11
185
R
310 circuits
elektor international media bv – 089018/uk
pagina 185
control to switch channels, and the remote If you do not have a stabilised 5-V supply volt-
control emits IR signals. There are even inex- age available, you can use the circuit at the
pensive ready-made IR receiver modules avai- bottom of the schematic diagram (with a 5-V
lable, such as the TSOP1136 used here, which voltage regulator) together with a simple (un-
produce trains of active-low pulses in respon- stabilised) AC mains adapter that supplies a
se to such signals. voltage in the range of 9 V to 12 V to the 7805
About the circuit: when no IR signal is pre- (IC3).
sent, a capacitor is charged via P2 and a dio- You can also use a relay with normally-closed
de. IC1 is a comparator that compares this IR contacts instead of normally-open contacts.
voltage (applied to its non-inverting input on In this case, simply swap the signals on pins 2
pin 3) to a voltage applied to its other input and 3 of IC1 so the relay pulls in when an IR
on pin 2. This reference voltage, which can be signal is received instead of dropping out.
adjusted with P1, determines the switching This saves a bit of power because the relay is
threshold of the comparator. If IC2 receives only energised during zapping. If you can’t
an IR signal, T2 conducts, and as a result the find any worthwhile use for the second com-
voltage on C1 drops rapidly below the parator of IC1, it’s a good idea to connect pin
threshold level set by P1. This causes T1 to 6 to +5 V and pin 5 to ground.
change from its previous ‘on’ state to the ‘off’
state. As a result, the relay drops out and the To improve noise immunity, you should
audio link to the stereo system is interrupted shield the IR sensor so it is not exposed di-
for the duration of the noise interval. It’s all rectly to light from a fluorescent fixture.
quite simple, as you can see. (080325-1)
Jaap van der Graaff Behold a feasible circuit. Buy a wireless power
point and an enclosure that is big enough for
As the only electronics engineer in my family the remote control and a small piece of proto-
and circle of friends, it is sometimes not pos- typing board.
sible to evade an appeal for help. This time
the request came from a friendly elderly lady On the prototyping board build the circuit ac-
in a retirement home. In her room the light cording to the accompanying schematic and
switch by the door and the pull cord above (carefully) open the remote control and sol-
the bed operate the light fitting on the ceiling der wires to the push buttons for ‘on’ and
in the middle of the room. However, she ‘off’. Measure if these are polarised and if that
would prefer that her standing lamp was ope- is the case connect them to the 4N25 opto-
rated by these switches instead, since she couplers as shown in the schematic, where
does not actually have a light fitting mounted pin 5 has a higher voltage than pin 4.
on the ceiling. This standing lamp has an
on/off switch in the power cord and is plug- The operation is as follows. The lady operates
ged into a power point. However, it stands the pull cord or light switch to turn the light
rather far from the bed so that she always has on. This causes the mains voltage to be ap-
to find her way in the dark. A wireless opera- plied to the transformer. The relay is activa-
ted power point is not really a consideration, ted which charges C1. While C1 charges, a
because it is just a matter of time before the small current flows through optocoupler 1.
remote is lost. Or maybe not? The result is that the ‘on’ button on the remo-
186
L
310 circuits
elektor international media bv – 089018/uk
pagina 186
R3
100 Ω
TR1 D1
1N4148
C1 C2
1k5
1k5
IC1
1 6 5
IC2
1 6 5
C3 D2
RC "ON"
RC "OFF"
2200µ
25V
2 4
4N25 2 4
1N4148 4N25
080252 - 11
te control is pressed. The remote control The remote control continuous to operate
switches the corresponding power point on from its normal battery and the white enclo-
and to which the standing lamp is connected. sure is attached to the ceiling in place of the
The standing lamp will therefore now turn light fitting.
on. Capacitor C2 is charged at the same time.
If the lady pulls the cord again, or if she ope- Diode D1 ensures that C1 is discharged when
rates the switch near the door, the relay will the relay de-energises.
de-energise and C2 discharges across opto- D2 ensures that C2 cannot discharge across
coupler #2. This operates the ‘off’ contact of the relay, but only across optocoupler 2.
the remote control and the light goes out. (080252-I)
187
R
310 circuits
elektor international media bv – 089018/uk
pagina 187
270 Ω
solar LT1300
cell R4 R3
LED1 3
LT1301 * 5
100 Ω
SHDN I LIM
1k
1k
548C
–BATT 0
080223 - 11
188
L
310 circuits
elektor international media bv – 089018/uk
pagina 188
100%
powered on the one hand
and constant sunshine on
the other, the circuitry COMPONENTS LIST
around IC2 and T1 has been
added. IC2 is just a variable Resistors Semiconductors
zener which will turn on T1 R1, R8 = 10 kΩ D1,D2 = 1N5817
harder as the voltage at the R2 = 22 Ω T1 = BC548C
wiper of P1 increases. In R3, R6 = 1 kΩ IC1 = LM317
R4 = 100 Ω IC2 = TL431
this way, when the voltage R5 = 180 Ω IC3 = LT1300 or LT1301
at the battery terminals ri- R7 = 270 Ω (see text)
ses too high, as at the end P1 = 10 kΩ potentiometer LED1 = LED
of charging, T1 will be tur-
ned on harder and harder, Inductors Miscellaneous
L1 = 22 µH (or 33 µH, see text) S1,S2 = 2-way pinheader, lead
bypassing part or all of the
pitch 2.54 mm, with jumper
charging current to ground Capacitors 6 solder pins
via R5 and R7, and lighting C1 = 100 µF 25V PCB, ref. 080223-1
the LED as it does so. This is C2 = 47 µF 25V from www.thepcbshop.com
simply a contemporary vari-
ation of the traditional
shunt voltage regulator. Table 1
IC3 LT1300 LT1301
The whole of the project fits L1 22 µH 33 µH
easily onto a compact prin- S1 fitted +V = +5 V +V = +12 V
ted circuit board of which S1 absent +V = +3,3 V +V = +5 V
the component mounting S2 fitted Imax = 400 mA Imax = 400 mA
plan reproduced here. The S2 absent Imax = 1 A Imax = 1 A
copper track layout is a free
pdf download as usual. Building up the board many ordinary moulded types. Our 22 µH one
should not present problems as there are no comes from Radiospares (RS Components)
oddball components to solder or mount. and is an ELC08D from Panasonic.
An 8-pin DIL socket should be soldered in the It is vital that diodes D1 and D2 are Schottky
IC3 position to allow fitting of one or the ot- types, to minimize forward voltage drop, and
her of the intended ICs. If your usual retailer in the case of D2, to be fast enough in terms
doesn’t have them in stock, you should be of recovery. AA or even AAA 1.2 V batteries
able to obtain them from mail order sup- will be suitable, given the impressive capacity
pliers, for example, from Farnell. Take care of current types on the market.
choosing the choke L1 (22 µH for the LT1300
or 33 µH for the LT1301). It must be able to The circuit should work the moment it is po-
handle a current of 800 mA without satura- wered; all that remains is to adjust potentio-
ting, which is far from being the case with meter P1. To do this, temporarily disconnect
189
R
310 schakelingen
elektor international media bv – 089018/nl
pagina 189
Gert Baars
r 2 + s 2 = ( r + H ) 2 = r 2 + H 2 + 2rH s = 2rH
190
L
310 schakelingen
elektor international media bv – 089018/nl
pagina 190
The average radius of the Earth is 6,371 km. tances that can be covered appear to be
2r is therefore about 113. The formula can larger than predicted by theory, as already
now be simplified to: mentioned.
With the antenna height of 15 m assumed
s = 113 H earlier, the distance that can be covered ap-
pears to be of the order of 40 km, instead of
where s and H have to be expressed in kilo- the calculated 13.8 km.
metres. How the propagation of electromagnetic wa-
An example: a VHF FM antenna is positioned ves actually works is a complicated matter
at a height of 15 m. the maximum distance at covered in many excellent books and publica-
which a line-of-sight connection is possible tions. However, it is known that at frequen-
amounts to 113 0,015 = 138 , km. cies in the GHz range the distance that can be
covered becomes progressively smaller as the
In practice these distances turn out to be lar- frequency increases. This is also the reason
ger than those computed using the formula. why parabolic antennas for SHF frequencies
This has to do with the propagation of elec- are positioned as high as is practicable. The
tromagnetic fields. It appears that the wave is amount of transmitter power plays a secon-
subject to reflection and does curve a little dary role in all this.
with the surface of the Earth. What does matter however, is the height of
This is readily observed with so-called tempe- the receiving antenna. The same formula can
rature inversion layers. The weather circum- be used for this antenna (that is s = 113 H ).
stances are such that hundreds of kilometres The theoretical total distance that can be co-
can be covered without problems using signal vered is then the sum of both distances to the
frequencies in the VHF range. But even with- horizon.
out these special weather conditions the dis- (060083-1)
IC1
ting it to microcontroller, relays, secret 7
alarms, robot applications or just turn on R1
D1
IC1 = 40106
40106 IC, a small capacitor to keep strong RF 10p
191
R
310 circuits
elektor international media bv – 089018/uk
pagina 191
static discharge (ESD) energy from damaging its maximum continuous rated value. Most re-
the inverter gate input. ESD may occur when gular LEDs are 20 mA types. The circuit still
you have been charged with an amount of works if you remove LED1 and just have the
electrostatic energy by walking on a carpet pull-up resistor R3 connected to output pin 2
with rubber soles. You can increase the sensi- and then connect a microcontroller input pin
tivity of the detector by experimenting with directly to pin 2.
lower values fore R1 e.g. 1 kΩ and a smaller Do check however that the microcontroller
metal plate. has a weak pull-up (i.e. to +VDD ) at its port
The value of pull-up resistor R3 is calculated line.
such that the current through LED1 is below (080057-I)
Jörg Trautmann
100µ
Common to all the devices is that they emit Since this treatment does not take the form
intense red light with a wavelength of of a medicine, but rather the form of visible
660 nm. Some biophysicists claim that light of light, there is no risk of side-effects.
this wavelength can have a positive effect on There has been scientific research showing
the human body and can initiate healing pro- that this therapy does not work in every case,
cesses. but success rates as high as 72 % have been re-
This so-called ‘phototherapy’ is a treatment ported.
which is claimed to have an effect against al-
lergic reactions in the body, since it acts Since it may not be possible to obtain these
against free oxygen radicals and strengthens devices under the NHS or under private medi-
the immune system, reducing inflammation cal insurance, our thoughts naturally turn to
of the mucous membrane. do-it-yourself.
192
L
310 circuits
elektor international media bv – 089018/uk
pagina 192
For the enclosure we decided to use an old stands for driving a highbrightness 660 nm
nasal hair trimmer. These can be obtained red LED to make a do-it-yourself photo-
new for a few pounds, or you may have an old therapy unit.
one that can be recycled. The choice of enclo-
sure also dictates the choice of battery: the In view of the small number of components,
unit contains a holder for an AA-size cell. The the circuit can be assembled by soldering
circuit must therefore not only be very com- them together directly or by using a small
pact (there is little spare room in the enclosu- piece of stripboard. The circuit can operate
re), it must also be able to drive a high- from a wide range of voltages, and so we can
brightness red LED from a voltage between use either an alkaline AA cell or an AA-size
1 V and around 1.6 V. NiMH rechargeable cell with a voltage of
Here again we can indulge in a little recycling: 1.2 V. The current consumption of the circuit
we can re-use the circuit from a Mini Project is about 20 mA. Assuming the circuit has been
by Burkhard Kainka for driving a white LED, built correctly, the red LED should light
published in Elektor Electronics in June 2002. In brightly as soon as power is applied. Five to
this circuit the inductive voltage pulse is limi- ten minutes’ use in each nostril every day
ted by the LED itself, ensuring that the output should be sufficient to obtain noticeable be-
voltage will automatically match the forward nefit after two weeks of treatment.
voltage of the LED. The circuit is suitable as it (060143-1)
Mike Mobbs
193
R
310 circuits
elektor international media bv – 089018/uk
pagina 193
COMPONENTS LIST
Capacitors
C1, C2 = 100 nF
Semiconductors
IC1 = CD4017 (SMD)
IC2 = CD4081 (SMD)
Miscellaneous
K1 = 3-wire cable with 3-way socket
K2 = 3-wires cable with 3-pin plug
PCB, ref. 080136-1 from www.thepcbshop.com
100%
The circuit uses a type 4017 CMOS decade blished before the input pulse, and is stable
ring counter, which is clocked by the falling for the duration of this pulse.
edge of the input via the CP1 (enable) pin, and
reset by output 7. Other divider ratios can be used by choosing
the relevant output for the reset. A miniature
The first input pulse after reset sets output 1 PCB with SMD parts on it was designed for
high, which allows the next input pulse the converter to enable it to be incorporated
through to the output via a CMOS 4081 OR into a model where space is always at a pre-
gate. Thus only one pulse in every eight is fed mium!
to the output. The use of negative logic to The circuit is best encapsulated in heatshrink
provide the AND function removes any risk of sleeving.
timing glitches, as the gating signal is esta- (080136-I)
194
L
310 circuits
elektor international media bv – 089018/uk
pagina 194
VCC
S1 R1 R3 R4 Ron
CIN
82 Ω
12k
10k
82k
CB
470µ
16V
BOOST 10n
8 8 2
VS VIN BOOT
L1
3 4 6 1
ISET S2OUT RON SW
PWM 50µH
IC1 IC2 D1
P1 2 7 3
VCNTRL OUT DIM
U2352 LM3404 LED
1 5 7 5
COSC S2IN VCC CS
10k
R2 GND GND Rsns
C1 CF DFR CBuffer
6 4
0Ω3
8k2
1n 100n 100n
1N8517
080373 - 11
RON
tON = 0134
, s× = 183
, µs lue of the current is one half of the ripple cur-
VIN rent greater.
(where RON is in kΩ and VIN in V). With Rsns = 0.3 Ω the average current is
given by
After this time period has expired the 200 mV
MOSFET is turned off and an approximately li- I avg = = 667 mA
nearly-falling current flows through the fly- 300 mW
back diode and the LED until U sns, the voltage This is around the maximum permitted value
across R sns, reaches 200 mV, whereupon a for a 3 W LED.
new cycle begins. While the MOSFET is off no
current flows in the supply to the regulator. The LED current can be adjusted by changing
The minimum off time is 0.3 µs. Rsns , for which we can use a twisted length of
resistance wire. More elegantly, we can use
Ripple current is inversely proportional to the the PWM IC to drive the DIM input of the swit-
inductance and to the switching frequency. ching regulator.
During t ON the current rises linearly and the The U2352 can generate a PWM signal adjus-
voltage across the coil is table from 0 % to 100 % using a minimum of
external components. The basic frequency of
UL = UIN - ULED - USNS = 18
. V the internal triangle wave oscillator is set by
C1 to around 10 kHz:
Hence 55
DI f osc =
UL = LED C osc × Vs
Dt (where fosc is in kHz, Cosc in nF and Vs in V).
With ∆t = tON we obtain a ripple current of
66 mA. The triangle wave voltage is compared
against a reference voltage set by P1, and at
When the current reaches its lowest value the the output of the comparator we have our
voltage across Rsns is 200 mV. The average va- PWM signal.
195
R
310 circuits
elektor international media bv – 089018/uk
pagina 195
The signal passes through some internal con- The PWM signal is taken from the output of
trol logic before reaching the output of the the U2352 to the DIM input of the LM3404
device to protect the output from overload. and imposes a 10 kHz pulse-width modulati-
Since we do not require this function it is dis- on on the light produced.
abled by taking pin 5 to ground and pin 3 to The ‘Boost’ switch (or pushbutton) forces the
V CC via R3. It is not clear from the datasheet PWM output high and thus the LED to maxi-
whether resistor R4 is strictly necessary for mum brightness.
internal voltage stabilisation. jean-claude.feltes@education.lu (080373-I)
go out.
680Ω
1k5
196
L
310 circuits
elektor international media bv – 089018/uk
pagina 196
15
RE1
5A
85
30
LA1 86
D1 S1
87
15 85
D2
T3 1N4008 T4
R8
10k
BC517 BC337
R7
C3 16 C4
10k
IC1
47µ 7 9
LA2 100n
8
16V R6
1 S 6 10 S 15 L
J J 3k3
IC1.A 5 11 IC1.B
K K
58K 2 3 13 14
C C
R10 R9 R1 R2 R R R5 R4
4 12
820 Ω
10k
10k
47k
100k
470k
0W5
T1 T2
R3
S
D3 1k IC1 = 4027
C1 C2
BC547B BC547B
15V 1µ 1µ
500mW 16V 16V
050378 - 11
fuse bay
197
R
310 schakelingen
elektor international media bv – 089018/nl
pagina 197
ched on. For safety reasons, the supply volt- mechanical voltage regulator. These regula-
age is tapped off from the number plate lamp tors are less reliable than the electronic versi-
(L2), because it is on even if you accidentally ons used in modern cars. For that reason, a
drive with only the parking lights on. The Zener diode voltage-limiter circuit (D3 and
wire that leads to the number plate lamp usu- R9) is included to keep the voltage at the
ally originates at the fuse box. emitter of T3 below 15 V and thus prevent the
4027 from being destroyed by an excessively
As the states of the outputs of IC1a and IC1b high voltage.
are arbitrary when power is switched on, the The supply voltage for the circuit is tapped off
reset inputs are briefly set high by the combi- from the fuse box. An accessory terminal is
nation of C1, R1 and T1 when the lights are usually present there. Check to make sure it is
switched on (ignition switch on). That causes fed from the ignition switch.
both Q outputs (pins 1 and 15) to go low. The pushbutton switch must be a momenta-
ry-contact type (not a latching type).
IC1a and IC1b are wired in toggle mode (J and Ensure that the pushbutton and LED have a
K high). The Set inputs are tied to ground (in- good ground connection. Fit the LED close to
active). the button.
The driver uses pushbutton switch S1 to ge-
nerate a clock pulse that causes the outputs The following ‘Bosch codes’ are used in the
of the flip-flops to toggle. The debouncing schematic:
circuit formed by C2, R4 and T2 is essential
for obtaining a clean clock pulse, and thus for 15 = +12 V from ignition switch
reliable operation of the circuit. C1 and C2 58K = number plate lamp
should preferably be tantalum capacitors. 86 = relay coil power (+) IN
The Q output of IC1b directly drives LED D1 (a 85 = relay coil power OUT
low-current type, and yellow according to the 30 = relay contact (+) IN
regulations). The Q output of IC1a energises 87 = relay contact OUT
relay Re1 via T4 and thus applies power to the (050378-1)
rear fog lamp L1. Free-wheeling diode D2
protects T4 against inductive voltage spikes
that occur when the relay is de-energised. Note
This circuit is only suitable for use in cars with
12-V electrical systems and negative ground.
In older-model cars, the charging voltage of
the generator or alternator is governed by a
198
L
310 circuits
elektor international media bv – 089018/uk
pagina 198
R3 R4
470k 470k
R1 C1
100 Ω
K1 680n
250V
X2
+12V
230V
B1
50mA
D1
R2 C2
100 Ω M
B250C1500 1000µ
12V 16V
1W3
080507 - 11
ten not known, we choose to have two resis- ted for simplicity. The calculated value is then
tors for the current limit. The same is true for rounded to the nearest E-12 value.
the discharge resistors R3 and R4 for C1. If
the circuit is connected to a mains plug then The impedance of the capacitor at 50 Hz is
it is not allowed that a dangerous voltage re- 1/(2π⋅50⋅C). If, for example, we want to be
mains on the plug, hence R3 and R4. able to supply 50 mA, then the required impe-
dance is 4600 Ω (230 V/50 mA). The value for
Capacitor C1 determines the maximum cur- the capacitor is then 692 nF. This then beco-
rent that can be supplied. Above that maxi- mes 680 nF when rounded. To compensate
mum the power supply acts as a current for mains voltage variations and the neglec-
source. If the current is less then zener diode ted voltage drops you could potentially
D1 limits the maximum voltage and dissipa- choose the next higher E-12 value. You could
tes the remainder of the power. also create the required capacitance with two
It is best to choose the value of C1 based in smaller capacitors. This could also be neces-
the maximum expected current. As a rule of sary depending on the shape of the available
thumb, start with the mains voltage when cal- space. It is best to choose for C1 a type of ca-
culating C1. The 12 V output voltage, the dio- pacitor that has been designed for mains volt-
de forward voltage drops in B1 and the age applications (an X2 type, for example).
voltage drop across R1 and R2 can be neglec- (080507-I)
Heino Peters the room. The circuit for this has many simila-
rities with the modulated light barrier appea-
With two light barriers closely positioned one ring on page 236.
after the other it is possible to establish in
which direction they have been crossed. If, There are two ways to position the light bar-
for example, you place it at the entrance of riers, namely a completely duplicated installa-
the toilet then you can use it to control the tion in opposing directions (this to prevent
lights: on when entering and off when leaving mutual interference) and a version with one
199
R
310 circuits
elektor international media bv – 089018/uk
pagina 199
+5V
10k
10k
10k
100k
100k
IC5 IC6
IC3 4 7
3 D4 RE1
2
1
D2 IC5.A
3 2
1N4148
1 1N4001
T1
TSOP1736 R14
9 13
D 10k
IC6.B
11
C
12 BC517
IC4
5 R S
2
7 10 8
D3 IC5.B
3 6
IC5 = LM393
1N4148
1 IC6 = 4013
R10
C4 C5
TSOP1736
10k
10n 10n
TSOP1736 5 1
D
IC6.A
3 2
C
R S
4 6
060086 - 2 - 11
IR transmitter and two receivers. Both types tion with two separate IR-transmitters it is
of installation are shown here, which one is sufficient to duplicate R6, T1, D1, C3 and R7
most suitable depends on the actual applica- from the circuit of the modulated light bar-
tion. rier. Output OUT (pin 3) of IC2 can drive two
of these IR-drivers without any difficulty. The
When used in a doorway, one transmitter is receivers are slightly different than those of
sufficient if the receivers are placed about 5 the modulated light barrier and the circuit is
cm apart. With a wider passage, an installa- the same for both types of installation.
tion with two separate IR-transmitters is a
better solution. This circuit has a range of se- We again use the TSOP1736, which is sensiti-
veral meters, even if the sun shines directly ve to IR-light that is modulated at a frequency
on the receiver! of 36 kHz. D2, R8 and C4 ensure that the re-
ceived pulses from IC3 at the output of IC5a
We use the exact same IR-transmitter(s) as for result in a ‘1’ when the beam is not interrup-
the modulated light barrier. For the installa- ted. When the beam is interrupted this out-
IC3 D1 IC3
TSOP1736 LD274 TSOP1736
light barrier 1
outward direction
outward direction
D1
inward derection
inward derection
D1 IC4 IC4
LD274 TSOP1736 TSOP1736
060086 - 2 - 12
200
L
310 circuits
elektor international media bv – 089018/uk
pagina 200
put will become a ‘0’ within about 1 ms. In the of light barrier 1 (IC3) through to output Q1.
same way IC5b generates a ‘0’ when IC4 stops This signal drives the relay via T2, which ope-
receiving IR-light. The 4013 CMOS-IC used rates the light in the room. The circuit there-
here contains two Dflipflops, of which we use fore turns the light on or off the moment that
only one. The instant that light barrier 2 (IC4) light barrier 1 is uninterrupted.
is unblocked again, is used to clock the state (060086-2)
If air (or another non-flammable gas) flows The BASIC program that runs in the PICAXE is
through the pipe in which the filament is available for free download from the Elektor
mounted, the filament will
be cooled and the voltage
1
across it will fall. The grea-
plastic tube
201
R
310 schakelingen
elektor international media bv – 089018/nl
pagina 201
2 +5V +5V
P1
R2
D1 100 Ω 100k
R12
2
100k
T1 1 5 8
IC1.A
3 7
IC1.B
6 R5
BC327 4
47k
R1 R3 R4 P2
390 Ω
100k
100k
SENSOR
IC1 = LM358
10k
+5V
R6 R8
C3 470 Ω
4k7
10µ
16V D4
1
K1
4 8 6 3 1
R IC3 6
7 CAL.
R7 DIS 4 7 2
IC2 PICAXE 7
10k
PC RS232
1N4148 R10
NE555 C2 5 08M 2 3
2 TR 3 22k
OUT R9 8
6 THR
22µ D2 4
10k
16V 8
CV 9
R11
5 1 5
10k
C1 D3 C4 C5
33n 470n
1N4148 22µ 16V
070346 - 12
website at www.elektor.com, look for file # The sensitivity of the unit is highly dependent
070346-11.zip. on the filament used and on the current
The NE555 is present only to provide a small through the filament (although this is com-
negative voltage of around –2 V for the pensated for by the calibration that the
LM358. This lets us use this low-cost operati- PICAXE carries out).
onal amplifier in such a way that its output Also inconvenient is the strong dependency
can swing down to 0 V. The NE555 inverter on the temperature of the gas whose flow
circuit allows the unit as a whole to be powe- rate is being measured. To compensate for
red from a single 5 V supply. this the gas flowing through the pipe must be
Using this circuit the author has obtained a heated to a defined temperature before being
usable output signal from 0 V to 3.5 V when passed over the filament.
measuring very gentle flows from 0 nl/h to (070346-I)
only 120 nl/h. He used the circuit to check the
operation of an industrial nitrogen (N2) flow
rate meter. And we cannot emphasise strongly enough:
do not under any circumstances use this cir-
It must be admitted that a circuit as simple as cuit with flammable gases!
the one described here has a few infelicities.
202
L
310 circuits
elektor international media bv – 089018/uk
pagina 202
R1
56 Ω
dimmed by altering the cur-
rent flowing through them, R2 R4
15k
10k
this effect in this circuit by BT1
using an AVR microcontrol-
S
R3 T1
P1 B.1 G
D1 B.4
ler (the 2313 from Atmel)
C1 AC1 100 Ω
6V 250 Ω
operating in comparator 100µ 4V7 CURRENT
AVR2313
B.2
D
IRF9Z34N
0Ω1
On power-up the microcon- 100n
203
R
310 circuits
elektor international media bv – 089018/uk
pagina 203
to limit and stabilise the microcontroller sup- lengthy period and is more economical in bat-
ply voltage, which is used also as a reference tery use than a halogen lamp.
voltage for the voltage divider set with P1. One problem arose in use when the LED got
(far) too hot. It appeared that the current cut-
The LED chosen is a Luxeon LXHL-LW3C off value was not being observed, due possi-
(nominal values: 3 watts, ULED = 3.7 V, ILED = bly to microcontroller failure or a dirty (or
0.7 A). A 100-nF capacitor connected in paral- faulty) trimpot. If the latter’s wiper loses con-
lel with the LED and shunt is wired direct to tact with the carbon track the comparator in-
the PCB; this is to eliminate possible inter- put becomes open-circuit and can become
ference effects from cable capacity. The 100- any old value (as then does the LED current).
µF electrolytic capacitor is vital to smooth the Installing a watchdog timer could help (to re-
6 V operating voltage, which would otherwise start the microcontroller promptly), also a
‘droop’ or ‘sag’. The choke should not satu- pulldown resistor from the comparator input
rate at maximum current but match the load to ground.
of the current being carried. To avoid genera- (070963-I)
ting square-wave effects that could produce
false current values, the shunt resistor used
should be a carbon film type, not wirewound. Source code and hexfile for the program can be
The lamp, used for speleology (cave explora- downloaded free of charge at www.elektor.com.
tion), has operated very reliably over a
Frans Janssens
204
L
310 circuits
elektor international media bv – 089018/uk
pagina 204
If you’re keeping an eye on the quality, you For L1 we connected two secondary windings
should at least use MKT types for coupling ca- in series from a 2×18V/225 VA toroidal trans-
C2
220p
R3 P1
BUZ11 2k2
4k7
1N4001 C9
L1
G S
R6 R9
C3 C5 D1 4700µ 25V
D 50mH
4k7
100k
2A
10µ 400V 100n
C8
V1 T1
4 700µ
1,3A
1 6 R4 25V
T2
180 Ω
C1 BC337 R13
2 7
C7
1Ω5
100n C4
3 8 R10
2µ2 LS1
4 9 5
47k
1Ω5
1Ω5
1k
4k7
1M
100k
100µ 100n
25V 4k7
1N4001 050153 - 11
205
R
310 circuits
elektor international media bv – 089018/uk
pagina 205
D1
R6
T1
C9
R4
R12
C6
R10
R7
R8
R9
R11
D2
V1
C8
R1
R2
R3
ECC 88
R13
C4
f C3 +180V
f 5 1a C2
P1
050153-1
P2
+ LS1 - C10
80%
4 6
2k 3 7 1g
2 8 050153-1
2g f f 1k (C) ELEKTOR
1 9
2a s
80%
206
L
310 circuits
elektor international media bv – 089018/uk
pagina 206
together with a piece of paper in between as If you use a separate transformer for the fila-
isolation. ment supply you can try and see if the circuit
works without R5. During the testing we used
The concepts used in this circuit lend them- a DC voltage for the filament supply.
selves very well to some experimentation.
The number of supply voltages can be a bit of Although you may not suspect it from the test
a problem to start with. For this reason we measurements (see specifications), this ampli-
have designed a power supply especially for fier doesn’t sound bad. In fact, it is easily
use with this amplifier (Quad power supply better than many consumer amplifiers. The
for hybrid amp). This can of course just as eas- output power is fairly limited, but is still
ily be used with other amplifiers. enough to let your neighbours enjoy the mu-
sic as well. It is possible to make the amplifier
The supply uses a cascade stage to output an more powerful, in which case we recommend
unstabilised voltage of 170 V for the SRPP that you use more than one MOSFET in the
(single rail push pull) stage (V1). During initial output stage.
measurements we found that the ripple on The inductor also needs to be made beefier.
this supply was responsible for a severe hum Since this is a Class A amplifier, the supply
at the output of the amplifier. To get round needs to be able to output the required cur-
this problem we designed a separate voltage rent, which becomes much greater at higher
regulator (High-voltage regulator with short output powers. The efficiency of the amplifier
circuit protection, see page 126)), which can is a bit over 30%.
cope with these high voltages. (050153-1)
207
R
310 circuits
elektor international media bv – 089018/uk
pagina 207
required, along with a little software. When The circuit itself draws no current in the off
power is applied T1 initially remains turned state, and for (rechargeable) battery-powered
off. When the button is pressed the gate of T1 appliances it is therefore best to put the
is taken to ground and the p-channel power switch before the voltage regulator.
MOSFET conducts. The microcontroller cir-
cuit is now supplied with power. For mains-powered devices the switch can
also be fitted before the voltage regulator (af-
Within a short period the microcontroller ter the rectifier and smoothing capacitor).
must take output PB1 high. This turns on n- Since there is no mains switch there will still
channel MOSFET T1 which in turn keeps T1 be a small standby current draw in this case
turned on after the pushbutton is released. due to the transformer. Be careful not to
exceed the maximum gate-source voltage
Now the microcontroller must poll the state specification for T1: the IRFD9024 device sug-
of the pushbutton on its input port (PB0) at gested can withstand up to 20 V. At lower
regular intervals. Immediately after switch-on voltages R2 can be replaced by a wire link; ot-
it will detect that the button is pressed (a low herwise suitable values for the voltage divider
level on the input port pin), and it must wait formed by R1 and R2 must be selected.
for the button to be released.
The author has set up a small website for this
When the button is next pressed the device project at http://reweb.fh-weingarten.de/elektor,
must switch itself off: to do this the firmware which gives source code examples (which in-
running in the microcontroller must set the clude dealing with pushbutton contact boun-
output port pin to a low level. When the but- ce) for AVR microcontrollers suitable for use
ton is subsequently released T1 will now turn with AVR Studio and GNU C. Downloads are
off and the supply voltage will be removed also available at www.elektor.com.
from the circuit. (080251-I)
Heino Peters
+5V...+15V
3k3
3k3
3k3
3k3
IC1
hood
range hoods in our kitch- 4
100n RE1
3k3
208
L
310 circuits
elektor international media bv – 089018/uk
pagina 208
perature difference, the hood will be swit- in the transition region. The output of the
ched on, possibly along with the lamp under IC3b will thus be at the supply voltage, which
the hood. After the burners are shut off, the will switch on T1 via R11. That causes the re-
hood fan and lamp will switch off again by lay to engage and switch on the fan and lamp
themselves. The advantage of using two sen- of the range hood. R2 can be used to adjust
sors is that the hood will have the same swit- the output voltage of IC1 over a range of ap-
ching characteristics in the summer as in the proximately 0.1 V, which corresponds to
winter. around 10 °C. It’s a good idea to use a supply
voltage that matches the operating voltage of
When building the circuit, it’s important to the relay. It’s also convenient to fit the relay
ensure that IC1 is located beneath the hood in a small box with an electrical outlet and
in the middle and IC2 is located next to the plug so it can be easily and safely inserted be-
hood or above it. If the temperature under tween the plug and outlet of the range hood.
the hood is higher than the temperature out-
side it, the open-collector output of IC3 will The circuit works best with a gas cooker, be-
be pulled up to the supply voltage by R6. The cause the heat rises immediately after a bur-
combination of IC3 and R7–R11 forms a ner is lit. With a ceramic or inductive cooking
Schmitt trigger, which we need because the top, it takes a bit longer for the relay to be ac-
output of IC3a does not change immediately tuated.
from 0 V to the supply voltage (or vice versa) (060089-1)
Easy ISP K1
for AVR microcontrollers Printer
1
Dr. Thomas Scherer 14
2
15
3
16
A trawl of the Internet will 17
4
R1 V+
reveal no end of simple AVR 18
5
270 Ω
K2
microcontroller programmer 19
6
7
R2
MISO 1 2 V+
designs for connection to 20
8
270 Ω
SCK 3 4 MOSI
the parallel port of a PC. 21
9
R3
RST 5 6 GND
Here at Elektor we have also 22 270 Ω
10
23 R4
published a few variations 24
11
270 Ω
ISP
on this particular theme. 25
12
R5
One thing that is perhaps
13
1k
209
R
310 circuits
elektor international media bv – 089018/uk
pagina 209
Andreas Köhler
210
L
310 circuits
elektor international media bv – 089018/uk
pagina 210
the motherboard.
PUMP
IN 5 2
FAULT
IN 7
circuit. 1µ
10k
220n 4µ7
3a D1 1-420060 3b
P1 +
IC1
0 0
R2
060024-1 060024-1
C3
C2
R1 C1
100%
100%
COMPONENTS LIST
211
R
310 circuits
elektor international media bv – 089018/uk
pagina 211
3.057 A. This range should be sufficient for Figure 2 shows a diagram of the manufactu-
the majority of applications. Increasing the rer’s application circuit. The FAULT output
preset resistance reduces the current limit le- drives an LED via a series limiting resistor
vel. which reduces the LED current to 2 to 3 mA.
The MAX1562 is available in a HESA variant
Any intermittent connection in the preset (with an active high ON signal) or ESA version
(caused by a dirty track etc.) will switch the (with an active low ON signal). The chip is
chip into shut down. The MAX1562 also con- packaged in an 8-pin SMD outline. Figure 3
tains a thermal cut out which turns off the shows a small PCB layout for the circuit using
output when the chip temperature exceeds mostly SMD components.
160 degrees C. (060024-1)
212
L
310 circuits
elektor international media bv – 089018/uk
pagina 212
1 2 3 4
R3
1k
+5V
infrared detector
+5V
C3 C2
R1 R2 R5 R4 R6
100 Ω
100 Ω
10k
10k
47µ 10n
10k
15V
1
P2
C5
2 7 1k
GP5 GP0/AN0 threshold
100n
S2 IC1 day/night
ON 3 6
GP4/AN3 GP1/AN1
(override) P1
PIC12C671 C4
4 5
GP3 GP2/AN2 1k
100n
lighting
duration
8
R7
S1 C1
OFF
(override)
100n
LDR
080228 - 11
GP4 of the charger’s 12C671, is fed to input application is available for example under re-
GP4 of IC1 via pin 2 of the connector. ference PI8377 from Lextronic (www.lextro-
nic.fr) where the author got it from. Some
This same input also receives override (optio- judicious online shopping may be in order to
nal) switch S1, which makes it possible to find a local equivalent.
force the lighting off. Input GP3 also receives
a switch making it possible to force the The ambient light level is measured using an
lighting on all the time, for example, when LDR connected to analogue input AN2, while
you want to admire or show off your garden adjustable potentiometers are connected to
at night, by overriding the presence detector both inputs AN1 and AN0.
circuit.
The latter employs a ready-to-use offthe shelf Preset P2 allows adjustment of the day/night
module, since these days it’s no longer threshold according to the characteristics
worthwhile nor sensible to build such a unit and positioning of the LDR used, while P1 al-
from scratch. It’s powered at 5 V and provides lows adjustment of the duration of the
a logic high output when a presence is detec- lighting following presence detection, from a
ted, which is connected to input GP3. few seconds to around ten minutes or so.
Watch out! Different modules of this type cur- The program for the 12C671 PIC is of course
rently on the market exist with various supply available for free download from the Elektor
voltages and generating high or low levels du- website or from the author’s own website:
ring detection. One module suitable for this www.tavernier-c.com. The project works im-
213
R
310 circuits
elektor international media bv – 089018/uk
pagina 213
Klaus Rohwer S1
A Transcutaneous Electrical R1
BC556 T1
Nerve Stimulation (TENS)
100k
D1
6k8
DIS
47 Ω
IC1
100µ 3
16V OUT
The author was prescribed 9V P1 2 TR 555 TR1
214
L
310 circuits
elektor international media bv – 089018/uk
pagina 214
The simple circuit uses a CMOS 555 timer to turned up far to obtain the necessary sensa-
produce a brief pulse which feeds a 1:10 mini- tion. Less sensitive parts, such as the knee or
ature transformer. Together with a 4.7 nF ca- foot, need a rather higher voltage and hence a
pacitor the transformer makes a parallel correspondingly higher potentiometer setting.
resonant circuit: the resonance leads to a con- Anyone considering building a TENS unit with
siderable increase in the output voltage. multiple (microprocessor-controlled) pro-
The pulse width can be adjusted using a grammes might wish to read the article ‘Low
potentiometer, here shown combined with Impact Muscle Stimulator’ in the April 2000
the on-off switch. Wider pulses produce hig- issue of Elektor Electronics.
her output voltages. Since a peak voltage of The article is also available for purchase as a
up to 200 V can be produced, the transformer pdf file at www.elektor.com.
must have adequate insulation: Conrad Elec- (050281)
tronics type 516260-62 is suitable.
A low-cost phono socket at the output gives Warning
reliable connection to the electrode cable. No part of this circuit may be connected to the
The adhesive electrodes shown in the photo- mains voltage, accidentally or intentionally, by
graph (disposable and permanent types are means of any equipment or component including
available) can be obtained from pharmacies a transformer.
and medical suppliers. They generally have
Disclaimer
connectors compatible with 2 mm banana This circuit is not approved for medical use and
plugs, and so it is possible to make up the ne- must not be used on young children or persons
cessary cable yourself. suffering from epilepsy. Medical advice should
To treat responsive parts of the body, such as be sought from your GP before all use.
the arm, the potentiometer need not be
B. Broussas S1
idyllic scene. 7
Although indoors it’s easy
to get rid of them these 080230 - 11
days, indeed even to pre-
vent them coming into the
house, the same can’t be said for the great Chinese coils – the only thing Chinese about
outdoors. We might mention the well-known them is undoubtedly their name – which very
215
R
310 circuits
elektor international media bv – 089018/uk
pagina 215
often drive people away as much as mosqui- research this summer, especially since the cir-
toes, if not more! Moreover they are nasty cuit proposed is very simple and cheap to
things to handle. build.
There are also UV (ultra-violet) ‘electrocutors’ As the figure shows, it uses just a single IC, a
consisting of a blue lamp surrounded by two CMOS type 4047. This very multi-purpose IC
closely-spaced grilles between which a high can be wired in very many operating modes,
voltage is applied. The mosquitoes (and flies including that of the multivibrator or astable
and other flying insects) are supposedly at- used here. The operating frequency is set by
tracted by the colour of the lamp and as they the external components C1, R1, and P1; the
approach, get electrocuted in contact with latter makes it possible to slightly adjust the
the two grilles. The only thing you have to do frequency, given the uncertainty that exists
is pull out the drawer from time to time and over the most effective value…
get rid of the mass of dead insects. To best reproduce the high frequencies pro-
Even though the effectiveness of these first duced by the generator, the output trans-
two products remains questionable, it is less ducer used is a simple tweeter, but it must be
so than the one we’re nonetheless going to a piezo one. Such a tweeter behaves in fact
describe here. We’re talking about an ultra- much like a capacitor, and so doesn’t overlo-
sonic mosquito repellent. ad the CMOS IC outputs that are incapable of
The principle, as described by its numerous supplying a substantial current, as everyone
promoters, is as follows. Only the female knows who’s ever worked with 400 series
mosquitoes bite (that at least is an undispu- CMOS logic.
ted scientific fact) and they bite when they To obtain an output signal of sufficient ampli-
need to feed, and above all, to feed their tude while being powered from a single 9 V
eggs. In this situation, they seek to avoid the battery, this tweeter is connected between
males whose ‘job’ has already been done, and the 4047’s Q and Q outputs, making it poss-
so they fly away from the frequencies emitted ible to apply complementary (antiphase) sig-
by the males when they are on heat. This is nals to the tweeter so it ‘sees’ an alternating
where opinions now diverge. According to voltage of double the
certain publications, the frequency emitted supply voltage. In purely theoretical terms,
by the male mosquitoes is said to be around this quadruples the output power available.
20–25 kHz, and so within the realm of ultra- In practice, it’s better to regard it as tripling
sound. But according to others, it is in the re- it, but the benefit achieved by doing it this
gion of 5–7 kHz instead; frequencies that a way is nonetheless very real.
human ear, even an elderly one, can still hear All that remains is for you to place the project
very well. in the middle of the patio table or beside your
Rather than spending lots of money (of the or- lounger in order to get a taste of the calm of a
der of tens of pounds) buying such a device, summer’s evening without mosquitoes
which moreover generally have a fixed fre- bothering you acoustically or worse, biting.
quency, we’re suggesting building one your- At any rate, that’s what we wish for you…
self so that you can carry out your own (080230-I)
Light effects have always been popular. Now whole gamut of possibilities has become fea-
that LEDs are available in all sorts of shapes, sible. Examples are case modding (embel-
sizes and colours for reasonable prices, a lishing PC cases with all kinds of lights,
216
L
310 circuits
elektor international media bv – 089018/uk
pagina 216
Jean-Pierre Duval
217
R
310 circuits
elektor international media bv – 089018/uk
pagina 217
à a microlight always takes off with the fuel All these conditions are taken into account by
tank full; the firmware – the program burned into the
à fuel consumption is usually between 7 microprocessor – more than by the hardware,
and 9 litres/hour; which can thus remain relatively simple.
à it’s important for the gauge to be perfect-
ly readable in all circumstances, e.g. in the Apart from the fuel flow sensor, an Atmel
form of a bargraph; ATmega8 microcontroller, and the display, all
à an indication of the amount of fuel remai- it takes is a few capacitors and a very small
ning, expressed in litres; number of resistors.
à an indication of the instantaneous fuel Time now to take a look at the circuit. Let’s
consumption (l/h); start with the power supply.
à it must be possible to have complete con-
fidence in the gauge, so provision needs Totally conventional, we start out with the
to be made for a warning in the event of it 12 V supplied by the battery, dropped to 5 V
going wrong; by a 7805 regulator. Upstream of this, a fuse,
à for the transducer, we use the manufactu- not shown on the circuit, protects the whole
rer’s data (in this case Digmesa); for grea- unit. Diode D1 protects the regulator against
ter safety, all data used are taken at unintentional polarity reversal of the voltage
minimum values; at the power supply input. LED D2 indicates
à two alerts need to be provided: 3.5 litres the presence of the output supply rail from
and 2 litres of fuel reserve remaining. the regulator IC1.
218
L
310 circuits
elektor international media bv – 089018/uk
pagina 218
Now let’s move on to the more interesting The Reset pin has an internal pull-up, so no
bit, which is the electronics of the virtual fuel external one is needed.
gauge proper. BASCOM Basic includes the tools needed to
configure the fuses.
Leaving aside the microcontroller, the most All unused ports are configured in the pro-
important component in this project is the gram as inputs, and from an electrical point of
flow sensor. This is an FHKSC 932-8501 from view are tied to ground on the board.
Digmesa ([1] & [2]). This detector can measure
fluid flows from 0.03 to 2.0 l/min, equivalent The liquid flow sensor produces very clean
to a range of 1.8 to 120 l/hr — more than suf- 5 V (TTL) pulses which trigger an interrupt
ficient for the application envisaged. Original- (INT1) used to measure the engine’s fuel con-
ly developed for measuring water flow in sumption. Here, it is wired in accordance with
coffee machines, it is equally capable of mea- the manufacturer’s data (see [1]), i.e. by
suring other fluids, as long as they are not too adding a 4.7 kΩ pull-up resistor and a 100 nF
chemically aggressive (alcohols, petrol, wines, capacitor between the signal output and
etc.). The ability to set the sensor port con- ground (TTL-mode output).
nections at different angles gives it unques- Preset P1 allows adjustment of the LCD dis-
tionable installation flexibility. play contrast by adjusting the voltage VEE.
After that, we are interested in the (artificial) The program is written in BASCOM BASIC, a
heart of the circuit – now it’s time to get powerful, economical programming language
down to the really clever stuff. that’s all the same very easy to implement.
There is a free version available that is capa-
The microcontroller used here, IC2, is an ble of producing up to 4 k of code [4].
ATmega8 from the Atmel stable [3]. We
shouldn’t underestimate it – despite its name, The irreproachable operation of this fuel gau-
this is a powerful component that we are far ge relies on a plethora of arithmetic calcula-
from pushing to its limits. It uses its internal tions going on inside the microcontroller.
8 MHz oscillator to run the program and an We’ll describe the most important ones so
external 32.768 kHz clock crystal to measure that if necessary you can adapt the characte-
the instantaneous consumption. The crystal ristics of this flowmeter so as to use it for
frequency is common, by the way, from the other applications.
use in watches where it’s one on the easiest
ways of creating a stable source for seconds Let’s suppose that our fuel tank has a capacity
pulses. of 29 litres. If we assume that the sensor pro-
This ATmega8 microcontroller has 24 I/O vides 1,800 pulses per litre (we measured
ports, of which we are only going to be using over ten tanks and were at between 1,900
a few, for the following functions: and 2,000 pulses per litre – in accordance
with the manufacturer’s data, but reduced
à six ports are used for the LCD display, i.e. down to 1,800); that gives us a maximum of
almost the whole of port C (PC0–PC5); 1,800 × 29 = 52,200 pulses for a completely
à one INT1 port (PD.3) as an input for the full tank; in order to maintain a degree of
pulses supplied by the flow sensor; safety margin (poorly-filled tank, leaks, and so
à two ports, PB.6 and PB.7, are devoted to on) we’ll give ourselves a margin of 10%, and
the above mentioned clock crystal. so will only count 48,000 pulses. Each pulse
corresponds to 1,000 /1,800, i.e. 0.555 ml.
For Reset we use the microcontroller ‘Brown-
out’ programmed via the microcontroller ‘fu- The calculation of the instantaneous con-
ses’. ‘Brown-out’ defines the supply voltage sumption expressed in litres/hour is a
level at which the program starts – in our case weighted value, recalculated every 10 se-
the minimum voltage is 2.7 V. conds.
219
R
310 circuits
elektor international media bv – 089018/uk
pagina 219
If, at the outset, volume=48000 One of the most interesting aspects of this
project is the very customized way the dis-
------interrupt routine------ play is used. It’s worth taking a slightly closer
rem at each interrupt, the volume is look at it.
decremented Some display tricks are used to display the va-
DECR volume lues. The top line of our display (two lines of
16 characters) is used to show the numeric in-
------display------
formation about the volume remaining (V)
rem after a formatting step and instantaneous consumption (l/h).
volume_remaining=volume The character at the extreme right of this top
Tank = Str(volumeremaining) line is a user defined character intended to
Tank = Format(tank , "00.0") symbolize the flowmeter. As long as the latter
Locate 1 , 1 : Lcd "V:" ; Tank is working, this character changes shape,
giving the impression of rotation. This is what
we’ve called the ‘operation indicator’.
The TIMER interrupt is used here in the Clock In the measuring second, we make it change
configuration to generate a very precise se- between two characters symbolizing the
cond value, so even with very low consump- flowmeter. If the flowmeter isn’t working,
tions, the response is very close to the true there is no variation in volume during the
value. The calculation of the volume remai- measuring period, and so this right-hand end
ning in the tank is performed by decremen- character remains static.
ting the amount consumed per unit of time
from the volume remaining (see inset ‘Proce- Let’s see now what the bottom line does. It’s
dure for calculating volume of fuel remai- used to indicate the tank status in graphical
ning’). form. When it is full, we will have 15 solid
blocks to the right of the R (for ‘Reservoir’ =
All that remains to mention is the alert Tank).
thresholds, at 3.5 and 2 litres, defined in the The characters on the LCD display are each
firmware. made up of an 8 row by 5 column matrix of
Again, if you want to adapt thee values to pixels. To be able to display the gradual re-
your personal requirements, do feel free to duction in the amount of fuel available, we
edit the microcontroller source code. have created several special user characters.
COMPONENTS LIST
220
L
310 circuits
elektor international media bv – 089018/uk
pagina 220
221
R
310 circuits
elektor international media bv – 089018/uk
pagina 221
R6 R4
47 Ω
3k9
ANT1
P1 R6
D2
330 Ω
1N4148
22k
L1 T2
C3 D1
10mH 100n
R1 R2 R3 BT1
C4 C6
22k
180k
2k2
3V
T1 100µ 100µ
C2 T3
10V 10V
10n
C5
T4
4n7
L2 R5
C1
2k7
330µH 820p
222
L
310 circuits
elektor international media bv – 089018/uk
pagina 222
Luc Lemmens
The USB drivers (page 13 of the manual) are Once this has been done the LED on the
contained in usb_drivers_v10.zip. Extract all TBLCF should be lit continuously if it has been
the files from this .zip file into a new folder on correctly recognised by Windows. Whenever
the hard drive. You can then connect the in- communications take place between the PC
terface to the PC, which should result in a and the target system the LED flashes.
223
R
310 circuits
elektor international media bv – 089018/uk
pagina 223
Adding the TBLCF to the CodeWarrior 6.3 IDE SW_Main_Board (archive 071102-11.zip).
is clearly explained in the manual, and Check that the Target Processor in this window
tblcf_gdi.dll can be found inside pc_binaries is set to: 5223x. For the Connection choose
_v10.zip. The item ‘Startup file’ can be left TBLCF and make sure that the target initialisa-
blank. tion file is M52235EVB_PnE.cfg. Then click on
Flash Configuration and from the Device table
Up to this point the manual has held our hand select the CFM_MCF5220_25MHz. Then over-
through the installation process, but there is write setup.xml using Save Settings to keep
(as with the parallel programmer interface the new settings.
from the May issue) a section that requires (080448-I)
extra attention: the settings for the flash pro-
grammer. From CodeWarrior, open the menu Web Link
Tools Flash Programmer. Click on Load Set- http://forums.freescale.com/freescale/board/
tings and load the file setup.xml, which can be message?board.id=CFCOMM&thread.id=624
found in the folder DigiButler software\
The circuit was originally designed by a local Connecting in parallel was not an option, be-
VHF FM broadcast station called ‘Haarlem cause it will create a ground loop and the load
224
L
310 circuits
elektor international media bv – 089018/uk
pagina 224
+12V IC1
7812T +17V...+30V
2x 1N4148
R8 R10
C12 C11 D2
301 Ω
120 Ω
10µ 10µ
D3 1%
T4
C13 C8 C23 C22
R13
10k
R1 R6 R2 R3
C1 C2 C3
499 Ω
499 Ω
499 Ω
12k
8n2 8n2
1% 8n2 1% 1%
R11 T1 T2 T3
C9
294k
12p
1% BC560 BC560C BC560C
C4
T5 C15 C19
C10 470p 47µ K2 47µ K3
220n
BC550 R14 R15 R16 R17
T6 C5 C14 C18
105 Ω
105 Ω
1k8
1k8
K1
10µ 1n 1n
1% 1%
J310
R5
100 Ω
1%
R9 R4 R7
D1 C7 C6
D4 C17 C16 D5 C21 C20
22k
1M
100p
2k5 470µ 47n 47n 47n 47n
for the element will be wrong. An RIAA ampli- or R16 to the local ground of the mixing pa-
fier for each player was not possible either nel, the signal voltage will be between the in-
because all the line inputs of the small club put and the local ground of the mixing panel.
mixing panel were already in use. Switching This connection to the local ground of the
between them was also not desirable; mixing panel is done via the screens of the
another switch that can be in the wrong posi- phono plugs. The part of the chassis at the
tion... output must definitely be isolated.
The circuit works as follows. The feedback D4 and D5 operate like a kind of automatic
ensures that the signal voltage of the element ground lift switch. It is the intention that the
will be across R5. The signal current that re- ground from the distribution amplifier is con-
sults from this, runs through T1 and, because nected in one way or another to the ground
the bases are tied together, also through T2 of the mixing panels, obviously without cre-
and T3. This causes a signal voltage across ating a ground loop. The DC from T2 and T3
R14 and R16. By connecting one side of R14 flows via the screens of the phono cables and
225
R
310 circuits
elektor international media bv – 089018/uk
pagina 225
the ground connection back to the distribu- An input impedance of 47 k is absolutely es-
tion amplifier. There is hardly any DC voltage sential to properly terminate an MD-element.
across D4 and D5, so that they do not con- This is realised in this amplifier with feedback
duct. As a result the outputs for the signal via R11. This results in lower input noise com-
voltages are well isolated from each other, pared to simply soldering a 47-kΩ resistor in
which reduces the risk of a ground loop. parallel with the input. Trimpot R4 is required
because of the wide tolerance of field effect
If there is no connection between the ground transistor T6. Adjust R4 so that there is about
of the distribution amplifier and the grounds 1 V across R1. If R4 is a carbon trimpot, then
of the mixing panels then D4 and D5 will con- the wiper has to be connected to the positive
duct. Everything continues to function, but side (as indicated in the schematic) to prevent
there is a relatively low-impedance connec- anodisation of the wiper.
tion between the screen of X2 and the screen The distribution amplifier has four identical
of X3 via the diode, which can cause a weak channels, enough for two stereo record play-
ground loop if the grounds of the mixing pa- ers and is powered from one 7812, which
nels are also connected together via another does not need a heatsink.
path. (060119-1)
weak stations.
080387 - 11
226
L
310 circuits
elektor international media bv – 089018/uk
pagina 226
make a 320 pF variable capacitance. The air- put volume. If the potentiometer is turned up
cored inductor has 25 turns on a diameter of too far, the receiver will go into self-oscilla-
10 mm, with taps at 5-turn intervals. The re- tion and become a mini-transmitter. At the
sonant circuit so formed is capable of cover- optimal setting the sound quality is very plea-
ing the full shortwave band from 5 MHz to sant and certainly no worse than many ordi-
25 MHz. nary shortwave radios.
The shortwave detector can be connected to If you find shortwave detectors that use a bat-
a power amplifier, or, for example, amplified tery and an amplifier a little new-fangled, you
PC loudspeakers. The antenna does not have can get your fix of nostalgia by dispensing
to be very long: in experiments we used a with the battery and connecting a crystal ear-
one-metre length of wire. Tuning the radio in- piece to the detector’s output. The radio will
volves adjusting the variable capacitor to of course also work without the feedback cir-
bring in the station and then adjusting the cuit, but with rather poorer performance.
gain of the feedback circuit for optimal out- (080387-I)
Gert Baars
227
R
310 circuits
elektor international media bv – 089018/uk
pagina 227
Notable is the fact that in this way the gain powering the amplifier from 340 V and set-
can be very high in theory, by selecting a high ting the collector current to 1 mA, the collec-
power supply voltage. Such a voltage could tor resistor will have a value of 338 kΩ.
be obtained from an isolating transformer Whether the ‘hoe ’-parameter has any influen-
from the mains. An isolating transformer can ce depends in the type of transistor.
be made by connecting the secondaries of
two transformers together, which results in a We also note that with such high gains, the
galvanically isolated mains voltage. That base-collector capacitance in particular will
means, that with a mains voltage of 240 Veff start to play a role. As a consequence the in-
there will be about 340 VDC after rectification put frequency may not be too high. For a hig-
and filtering. If in the amplifier circuit the po- her bandwidth we will have to use a transistor
wer supply voltage is now 340 V and the col- with small Cbc , such as a BF494 or perhaps
lector voltage is 2 V, then the gain is in theory even an SHF transistor such as a BFR91A. We
equal to 40 × (340 – 2). This is more than will have to adjust the value of the base resis-
13,500 times! tor to the new hfe .
However, there are a few drawbacks in prac- The author has carried out measurements
tice. This is related to the output characteris- with a BC547B at a power supply voltage of
tic of the transistor. In practice, it turns out 30 V. A value of 2 V was chosen for the collec-
that the transistor does actually have an out- tor voltage.
put resistor between collector and emitter.
This output resistance exists as a transistor Measurements confirm the rule of thumb.
parameter and is called ‘h oe’. The gain was more than 1,000 times and the
effects of ‘hoe’ and the base-collector capaci-
In normal designs this parameter is of no tance were not noticeable because of the now
consequence because it has no noticeable ef- much smaller collector resistor.
fect if the collector resistor is not large. When (060074-1)
228
L
310 circuits
elektor international media bv – 089018/uk
pagina 228
229
R
310 schakelingen
elektor international media bv – 089018/nl
pagina 229
Things should be arranged so that there is a The counterweight is made from an M3×10
gap of about 1 mm between wire and pin screw with nut and a 4 mm washer, which al-
when the top is stationary. lows for a little adjustment to be made.
The bottom contact pad for the button cell If more weight proves necessary, further was-
can be made by soldering a small drawing pin hers or nuts can be added.
in the middle of the battery holder area. (070916-I)
Florian Schäffer
1
+5V
Cars made by the Volkswa- C5
1µ +U B
gen/Audi group (VAG) are
easy to interface to using 2
16V
R3
560 Ω
C3 C1+
be set. 9
R1OUT
R2OUT
R1IN
R2IN
8
4
5
9 BC547B
4
C2+
C6 2N3904
C4
1
6
8 IC3 2 2
CEN NC 7
5 3 IC2
TX 8
A popular and rather mini- 6
RX
MC33290
ISO
4 4
5
9
D1 78L05
230
L
310 schakelingen
elektor international media bv – 089018/nl
pagina 230
two interesting ICs: the L9637D from ST use only the K-line and do not require the L-
Microelectronics and the Motorola/Freescale line at all.
MC33290D. Both include an ISO 9141-com- We have therefore also added a switch to al-
pliant interface. The L9637D, at a price of two low the signal to be isolate from the OBD con-
pounds or so, is the more expensive, but can nector. This allows testing of whether the car
withstand voltages of up to 36 V, making it uses the L-line for initialisation or not. A
suitable for use with commercial vehicles that straight-through (not a crossed-over null mo-
use a 24 V supply. At 58 kbit/s it is also too dem) cable is used to connect to the PC.
slow to connect to the CAN bus, which can
operate at up to 500 kbit/s. The MC33290D is The components are readily available; the ISO
only specified for operation up to 18 V, but is interface chip can be obtained from Farnell or
fast enough for OBD over CAN and is therefo- Segor Electronics. No adjustments are requi-
re the better choice for our circuit. As far as red to the circuit, since all the devices used
VAG-COM is concerned the difference is not are standardscompliant. The author has made
significant, as KW 1281 operates at a maxi- a printed circuit board layout available on his
mum speed of just 10400 bit/s. homepage, as both an Eagle file and a PDF.
The page also contains much other informa-
This chip is responsible for the OBD side of tion, including details of the software.
the circuit; on the serial port side we use a (060097-1)
MAX232. The MAX232 converts the serial sig-
nals between the levels used on the interface Internet Link
and TTL levels, while the MC33290 converts www.blafusel.de
between TTL levels and the ISO levels. The
circuit draws power from the car’s 12 V sup-
ply over the OBD cable. A simple voltage re-
gulator produces the +5 V supply voltage,
whose presence is indicated by the LED. To
ensure that the circuit remains compatible
with older cars, separate provision must be
made for connection to the L-line as the ISO
interface chip only supports the K-line. We
have therefore added a transistor to drive the
L-line: the direction of data transfer on this
line is only from the PC to the car. Most cars
Harry Baggen video cables, which may cause hum and other
interference.
These days many more audio-visual devices in
the home are connected together. This is es- The surround-sound receiver contains a tuner
pecially the case with the TV, which may be that takes its signal from a central aerial dis-
connected to a DVD player, a hard disk recor- tribution system. The TV is also connected to
der, a surround-sound receiver and often a PC this and it’s highly likely that the PC has a TV-
as well. This often creates a problem when card, which again is connected to the same
earth loops are created in the shielding of the system. On top of this, there are many analo-
231
R
310 schakelingen
elektor international media bv – 089018/nl
pagina 231
232
L
310 schakelingen
elektor international media bv – 089018/nl
pagina 232
F1
R5A
4A T
IRFZ48N
82 Ω
IRF4905
R5 R1
10k
10k
13
14
IC1.D
12 D D
G T1 G T3
G S
S S D
2 R9 IRFZ48N R11 IRF4905
68k
68k
1
IC1.A
R6 R2 3
8k2
8k2
6V 4 C1 C3
C2
IC1 = TL084 IC2
R7 R3 11 2200µ 100n 2200µ
3A 16V 16V
8k2
8k2
10
8
IC1.C
9 R12 R10
68k
68k
IRF4905 IRFZ48N
S S
G T4 G T2
5
7 D D
IC1.B
6
R8 R4
10k
10k
R8A
82 Ω
060042 - 11
it would naturally be even nicer to reduce it posite T3 must also be switched on at the
to practically zero. That’s possible with a syn- same time. That’s taken care of by IC1b. The
chronous rectifier. What that means is using polarity of the AC voltage is reversed during
an active switching system instead of a ‘passi- the next half-wave, so IC1c and IC1a switch
ve’ bridge rectifier. on T4 and T1, respectively.
As you can see, the voltage dividers are not
The principle is simple: whenever the instan- fully symmetrical. The input voltage is redu-
taneous value of the input AC voltage is grea- ced slightly to cause a slight delay in swit-
ter than the rectified output voltage, a ching on the FETs. That is better than
MOSFET is switched on to allow current to switching them on too soon, which would in-
flow from the input to the output. As we want crease the losses. Be sure to use 1% resistors
to have a full-wave rectifier, we need four for the dividers, or (if you can get them) even
FETs instead of four diodes, just as in a bridge 0.1% resistors.
rectifier. The control circuit around the TL084 is powe-
R1–R4 form a voltage divider for the rectified red from the rectified voltage, so an auxiliary
voltage, and R5–R8 do the same for the AC in- supply is not necessary. Naturally, that raises
put voltage. As soon as the input voltage is a the question of how that can work. At the be-
bit higher than the rectified voltage, IC1d ginning, there won’t be any voltage, so the
switches on MOSFET T3. Just as in a normal rectifier won’t work and there never will be
bridge rectifier, the MOSFET diagonally op- any voltage...
233
R
310 schakelingen
elektor international media bv – 089018/nl
pagina 233
Fortunately, we have a bit of luck here. Due to like a lot, but an average current of 5 A can
their internal structures, all FETs have inter- easily result in peak currents of 50 A in the
nal diodes. They allow the circuit to start up FETs. The IRFZ48N (55 V @ 64 A, 16 mW) spe-
(with losses). cified by the author is no longer made, but
you might still be able to buy it, or you can
There’s not much that has to be said about use a different type. For instance, the IRF4905
the choice of FETs – it’s not critical. You can can handle 55 V @ 74 A and has an internal
use whatever you can put your hands on, but resistance of 20 mΩ.
bear in mind that the loss depends on the in- At voltages above 6 V, it is recommended to
ternal resistance. Nowadays, a value of 20 to increase the value of the 8.2-kΩ resistors, for
50 mW is quite common. Such FETs can hand- example to 15 kΩ for 9 V or 22 kΩ for 12 V.
le currents on the order of 50 A. That sounds (060042-1)
Table 1
A Group Power Supply
1 RPM pulse A pulsed RPM signal is used to maintain a constant volume level
or to operate a navigation system. Tis is also known as SCV
(Speed Controlled Volume) or GALA (GeschwindigkeitsAbhängige
LautstärkeAnpassung).
2 Remote control / Mutes the audio output of the radio. This requires a hands-free kit
ground / telephone mute that pulls pin 2 to ground during a telephone call.
3 Remote control Strongly brand-dependent.
4 Constant 12 V in Constantly connected to the +12-V terminal of the battery. Memo-
orange (yellow) ry settings (stations, tone and time) are thus retained when the ra-
dio is switched off.
5 Switched 12 V out / The motor-driven antenna is extended when 12 V is present on
antenna remote this pin. It can also be used to switch accessories such as ampli-
blue fiers or sound processors.
6 Lighting 12 V must be present on this pin to illuminate the buttons of the
yellow/black radio and allow the display to be dimmed.
7 Switched 12 V in The radio can be switched on if 12 V is present on pin 7 (via the
red ignition switch).
8 Ground Connection to the chassis and thus to the negative terminal of the
black (brown) battery.
The assignments of pins 1 to 3 may be swapped, depending on the make or brand. Pin 3 is sometimes
used for a brand-specific bus signal.
The assignments of pins 4 and 7 are often swapped (for example, by VW, Audi and Opel).
In recent VW models, pin 5 is used as a supplementary connection for constant +12 V. This means that if
you install a different radio, you must disable this connection, as otherwise the new radio will have a short
life.).
234
L
310 circuits
elektor international media bv – 089018/uk
pagina 234
A Group
exchanging the terminals for the constant
supply voltage and switched voltage. As a re-
sult, if you connect a new radio it will behave
in a very irritating manner: every time you
switch off the ignition and remove the key, all
your settings will be lost. As a result, most car
radio manufacturers provide a simple way to
B Group
swap these connections in the cabling.
C Group
multimeter to check whether everything is
connected as it should be, especially for the
connections in the ‘A’ group.
(080471-1)
Table 2
B Group Loudspeakers B Group Loudspeakers
1 + Right rear, blue 5 + Left front, green
2 – Right rear, blue/black 6 – Left front, green/black
3 + Right front, grey 7 + Left rear, brown
4 – Right front, grey/black 8 – Left rear, brown/black
Table 3
C Group Extensions C Group Extensions
1 Line out, left rear 13 CD ID
2 Line out, ground 14 Brand / make dependent
3 Line out, right rear 15 Ground
4 Line out, left front 16 Constant +12 V
5 Antenna / remote 12 V out 17 Switched +12 V
6 Line out, right front 18 CD changer line in, ground
7...10 Brand / make dependent 19 CD changer line in, left
11 Phone in 20 CD changer line in, right
12 Phone in, ground
The assignments of pins 1–6 are always as described here. However, recent Becker radios use pin 6 for
the subwoofer output.
Manufacturers can use the remaining pins as they see fit.
235
R
310 circuits
elektor international media bv – 089018/uk
pagina 235
10 Ω
1k
10k
enough in the garage to be
able to close the door. The 4 8 4 8
circuit consists of a trans- 7
R R4
7
R D1
R1
IC1 IC2 LD274
lated infrared light and a
IR
3 3
6k8
OUT P1 OUT
555 555
receiver, which recognises
2 TR 2 TR R6
6 THR 6 THR
10k
this. The circuit used here is CV 10k CV
T1
C3
10k
3k3
100k
IC4
236
L
310 schakelingen
elektor international media bv – 089018/nl
pagina 236
to 2.5 V, with the aid of R10 and R11, the out- sure that IC3 during the calibration does not
put of IC4a will be a ‘1’. In the intervening receive too high a signal by placing the IR-LED
quiet periods of 470 ms, C4 will partially char- a considerable distance away or by not point-
ge via R8, but this is not of sufficient duration ing directly at the receiver. If this procedure is
to exceed the voltage of 2.5 V. Only when the not that successful then just set P1 to the cen-
light barrier is interrupted will C4 charge far tre position, this works just fine usually.
enough that the output of IC4a will toggle
and become a ‘0’. Because IC4a has an open- You should not have a problem with ambient
collector output, C5 will be immediately dis- light with this circuit. If you do have a pro-
charged and the output of IC4b will become a blem because, for example, there is direct
‘1’. sunlight on IC3, then you will need to place it
inside a small tube and point it at the IR LED.
With R9 and C5 this signal is stretched to In this way no direct sunlight can reach the re-
about one second. If you increase the value of ceiver. If the IR LED and the receiver are pla-
R9 to 100 kΩ, then this will become about 10 ced too close together it is possible that the
seconds. R12 and R13 are included to prevent receiver will sense light reflected off the
chatter of the output around the trigger walls, even when someone is standing be-
point, although there is not really a risk of tween the transmitter and receiver. In this
that happening in this circuit. Together with case the solution is also a short piece of tube
R14, the output of IC4b delivers a clean logic for both the transmit LED as well as the recei-
signal that we can use for further processing. ver (Figure 3). Make sure that the tubes are
The quickest way of calibrating the frequency opaque (paint black or use water pipe, for
of IC2 to 36 kHz, using P1, is with the aid of an example). The wires to the IR LED can be se-
oscilloscope. If you do not have one of those, veral meters long without any problems. Do
then point the IRLED D1 at the receiver IC3 not place the receiver IC too far from the cir-
and turn P1 so that the voltage on the invert- cuit.
ing input of IC4a is as low as possible. Make (060086-1)
Roland Plisch U+
237
R
310 circuits
elektor international media bv – 089018/uk
pagina 237
levels in 5-V operation (preferably types with pin connected is at high impedance. The non-
rail-to-rail outputs). Suitable examples to use inverting input of IC1A lies at twothirds and
are the LM393 or LM311. The resistances in the inverting input of IC1B at one third of the
the voltage dividers in this circuit are uni- operating voltage, so that in both cases the
formly 10 kilohms. outputs are set at High state. If the microcon-
troller pin at input A becomes Low, the out-
Consequently input A lies at half the oper- put of IC1B becomes Low and that of IC1A
ating voltage (2.5 V), assuming nothing is con- goes High. If A is High, everything is reversed.
nected to the input – or the microcontroller (080095-I)
Sebastian Westerhold
IC2
220 Ω
120 Ω
of electronics and who shows 100n
hobby.
238
L
310 circuits
elektor international media bv – 089018/uk
pagina 238
The inventive project described here is also a very tiny quantities are needed: one gram of
product of Jessica’s creative flair. The couple dye is enough for at least ten wine bottles full
were experimenting with filling wine bottles of water.
with water, and adding various chemical
colourants. Even more spectacular effects can be achie-
Then LEDs of various colours were submer- ved using a full-colour RGB LED in conjuncti-
ged in the liquid, giving strange and beautiful on with these dyes. The driver circuit, which
lighting effects. The ultraviolet-active dye is an ideal project for beginners, can be built
‘fluorescein sodium’ gives off an intense on a small piece of perforated board in half an
green light when stimulated using blue, or hour or so. Being microcontroller based, the
even better, ultraviolet, LEDs. Rhodamine B is circuit is very compact.
another ultraviolet-active dye: in this case the As always, the software is available for down-
emitted light is bright red. load from the Elektor website at www.elek-
Both fluorescein sodium and Rhodamine B tor.com.
can be ordered via chemist’s shops, or, more Ready-programmed microcontrollers are also
economically, over the Internet. Although the available: the order code is 080076-41.
prices of these dyes may appear high, only (080076-I)
1N4148
R7
C1 C3
100k
39n 1000µ
16V BT1
IC1.A IC1.B T1
R1 R3
1 2 3 4
1k 1 1 4k7
T2 4x 1V2
R6
BC557 47 Ω
R5
50µA
IC1 = 40106 2N3055
1k
060187 - 11
239
R
310 circuits
elektor international media bv – 089018/uk
pagina 239
Schmitt trigger IC. The multivibrator has a is available at the collector of this transistor
mark-space ratio (‘duty factor’) that can be ad- to drive the base of the 2N3055 power tran-
justed over a very wide range, independent of sistor. R4 and C2 provide decoupling for the
its operating frequency. Adjusting the oscillator from the large currents switched by
potentiometer changes the ratio between R a the power output stage. The moving-coil me-
and Rb, which together make up the total re- ter connected via R7 serves to monitor the
sistance of the potentiometer. Capacitor C1 is state of the battery, which is useful when
charged via Rb and is discharged via R a. The rechargeable cells are used.
corresponding mark-space ratio is present at The circuit has been used by the author to
the output of the oscillator on pin 4 of the drive a motor salvaged from an old cassette
40106. The output high time is determined tape recorder. In this case the 2N3055 did not
by Ra , while the output low time is determi- require a heatsink.
ned by Rb. The oscillator frequency is con- Interested readers will find that a search of
stant at approximately 115 Hz. Transistor T1 the Internet turns up plenty of information on
provides current gain: when pin 4 of the the theory and practice of driving DC motors
40106 is low, T1 turns on, and when the out- using pulsewidth modulation.
put is high, T1 is turned off. Sufficient current (060187-I)
IC2
470µ 7
25V R6 R7
390 Ω 470 Ω
1
IC3 6
IC2 = 74HC74
TRI1 230V
2 4
4 10
C2 MOC3041
3 S 5 11 S 9
C C TIC206D
10n
IC1 IR receiver 2 IC2.A 6 12 IC2.B 8
D D
R R
T1 R3 1 13
R1 C3 R4
D2
1M
100k 1M5 C4
1µ
BC547
15V 47n
0W4 250V N
X or X2
060107 - 11
240
L
310 circuits
elektor international media bv – 089018/uk
pagina 240
Therefore, the first one you find allows you to using capacitor C5 which must be a class X or
turn off the light and enjoy your movie in the X2 model rated at 230 volts AC. This type of
best possible conditions. capacitor, called ‘selfhealing’, is the only type
The infrared receiver part of our project is en- we should use today for power supplies that
trusted to an integrated receiver (Sony SBX are connected to ground.
1620-52) which has the advantage of costing ‘Traditional’ capacitors, rated at 400 volts, do
less than the components required to make not really have sufficient safety guarantees in
the same function. After being inverted by T1, this area. Considering the fact that the setup
the pulses delivered by this receiver trigger is connected directly to the mains, it must be
IC2a, which is nothing other than a D flip-flop mounted in a completely insulated housing. A
configured in monostable mode by feeding power outlet model works very well and can
back its output Q on its reset input via R4 and easily be used to interspace between the
C3. The pulse that is produced on the output grounded wall outlet and that of the remote
Q of IC.2A makes IC.2B change state, which control device.
has the effect of turning on or turning off the Based on this principle, this setup reacts to
LED contained in IC3. This circuit is an opto any infrared signal and, as we said before, this
triac with zero-crossing detection which al- makes it compatible with any remote control.
lows our setup to accomplish switching with- On the other hand, it has a small disadvantage
out noise. It actually triggers the triac T2 in which is that sometimes it might react to the
the anode where the load to be controlled is ‘normal’ utilization of one of these, which
found. The selected model allows us to switch could be undesirable. To avoid that, we ad-
up to 3 amperes but nothing should stop you vise you to mask the infrared receiver win-
from using a more powerful triac if this model dow as much as possible so that it is
turns out to be insufficient for your use. necessary to point the remote control in its
In order to reduce its size and total cost, the direction in order to activate it.
circuit is powered directly from the mains www.tavernier-c.com (060107-1)
IC1
With the addition of a low power voltage re-
JP2 7
3 CS
VIN– 6
241
R
310 circuits
elektor international media bv – 089018/uk
pagina 241
conversion results are out- Type Notch (Hz) Sample rate (Hz) Eff. res. (bit)
put using a serial interface MCP3550-50 50 12,5 21,9
that is easy to connect to MCP3550-60 60 15 21,9
the SPI port of a microcon- MCP3551 50 & 60 13,75 21,9
troller. A file containing a MCP3553 – 60 20,6
printed circuit board layout
for this design is available for free download
from www.elektro.com.
Microchip make four versions of these ICs. As Web Links
the table shows, they differ in the frequency [1] ww1.microchip.com/downloads/en/
of the built-in notch filter, which is designed DeviceDoc/21950c.pdf
[2] http://datasheets.maxim-ic.com/
to help suppress mains hum. They also have en/ds/MAX6520.pdf
different sample frequencies, as well as diffe-
rent effective resolutions.
(070967-I)
Jean Brunet
242
L
310 circuits
elektor international media bv – 089018/uk
pagina 242
1 T2
R1
2a
100k
K1 K2
R2 TXD1
BC
1 MODE
4k7
558C
6 GND
2 RXD +5V
7 T1 RESET
R3
3 TXD RXD1
27k
8
4 BC
9 R4 548C
5 S1 S2
10k
SUB-D9
K3
TXD1
MODE
100%
GND
+5V
RESET
RXD1
2b
R8C/13
1 32 R5
RXD1 TXD1
2 31
10k
AN6
3 30
RESET AN5
4 29
AN4
5 28
VSS MODE
6 27
AN3
7 26
VCC AN2
8 25
P17 AN1
9 24
P16 AN0
10 23
P15
11 22
P14 P30
12 21
P13
13 20
P12 P31
14 19
P11
15 18
P10 P32
16 17
100%
P45 P33
Mounting the R8CKey board The cable is soldered on the R8Ckey with the
There isn’t a lot to say about making the braided ground wire directly on the ground
R8Ckey board. The PCB artwork (Figure 2) layer of the board. Two nylon self-locking ca-
shows that installing the components is ex- ble ties keep the cable in place. At the end of
tremely easy. Adding a switch, a button and a the cable, pin 2 of the RS-232 port corres-
few passive and active (two transistors) com- ponds to RxD on the board, while, on the cop-
ponents should not be too difficult. per side, pin 3 corresponds to TxD, and pin 5
Begin by soldering the gold-plated singlerow carries ground.
6-contact connector. Solder it with its plastic
base in order to retain the proper spacing, Implementation of the R8CKey
then forcefully slide out the plastic part to re- Warning: Make sure the R8Ckey is properly
move it. oriented in socket K3. It must be positioned
Solder the resistors, the transistors, the Reset with the copper side toward the R8C. Inver-
button and the slide switch S2. sion will destroy the transistors on the board.
243
R
310 circuits
elektor international media bv – 089018/uk
pagina 243
3a 3b
100%
100%
The R8Ckey is very easy to use. You only have mounting plan for this second board and its
to insert it into its socket in front of the R8C, track design in Figure 3. Making the second
respecting the orientation, as we were saying printed circuit, the one for the R8C side is
above, the ‘copper’ side facing toward the very simple, as can be seen in this example.
R8C. Then, connect the 9-way sub-D plug to The only thing to solder on the board being
the RS232 port on the PC. Turn the setup on, tested is the 10 kS resistor connected be-
slide the Mode switch toward the top, and tween the Mode pin (pin 28) of the R8C board
push the Reset button. Now, all that’s left to socket and the +5 V line.
do is start programming the chip. The PCB artwork was produced in Proteus
ARES format and can therefore be used ‘as is’
Installation at the top of the R8C/13 with this printed circuit design program. The
The diagram given in Figure 1b is practically relevant files can be downloaded from the
‘transparent’ because it is limited to a simple author’s website (see below).
6-pin connector. We propose the component http://perso.wanadoo.fr/asnora/R8C/r8ckey.htm (060175-1)
244
L
310 circuits
elektor international media bv – 089018/uk
pagina 244
10k
PWM 100µ MHz) on the OC2 output
(PD2) of the ATmega32 mi-
S T1 16V
G
1
4 minally 2.56 V, and so an
D1
C1
R2
C3
R4
TLC271 LED current of 100 mA will
lead to a tenbit conversion
10 Ω
1k1
245
R
310 circuits
elektor international media bv – 089018/uk
pagina 245
V+ S1 CIRCUIT TEST
V+
R9 R17
SOLAR
PANEL R7 R11
-Θ 2k7
2k2
100k
Hyst. min (133k) = 0V5
NTC 10k Hyst. max (33k) = 1V5
5
R6
7
R2 IC1.B 100k R8 P2
C7 6
R5 33k
9k1
100k
100k
1µ
25V
3 T1
R12
V+ 10 1
IC2.A 10k
8 2
R10 IC1.C
9 BC638
POOL
-Θ
R13 D1 RE1
NTC 10k R3 CIRCULATION
680 Ω
3 PUMP
R4 100k
1
R1 IC1.A 100k
C8 2 P1
C3 D2 1N4001
9k1
Vref min = 0V
1µ Vref max = 5V
25V 100n
PUMP ON
100k
5
13 12
7
IC2.B
6 IC1.D
R21
10k
IC3 R23
LM7812 14 V+
470 Ω
16 14
+15V D3 V+ R20
V PH V STAB
470 Ω
11 10
R19 VCNTRL
1N4001
IC4 R22
680 Ω
13 15
C4 C5 C6 VR MAX VI 1k
D21 D22 UAA170
D4 12 1
330n 330n 100µ VR MIN
25V
5V1 5V1 H G F E D C B A
POWER ON
2 3 5 4 6 7 8 9
IC1 = LM324
V+ IC2 = LM393
D5 D6 D7 D8 D9 D10 D11 D12 D13 D14 D15 D16 D17 D18 D19 D20
4 C9 8 C10
IC1 IC2
11 100n 4 100n
050217 - 11
doesn’t need to be on continuously. The basis the supply voltage at a temperature around
of operation is as follows. When the tempera- 25 °C. C7 and C8 suppress any possible inter-
ture of the water in the solar collector is at ference. The NTCs (R9 and R10) are usually
least 10 °C higher than that of the swimming connected via several meters of cable, which
pool, the pump starts up. The warm water can easily pick up interference.
will then be pumped to the swimming pool
and the temperature difference will drop ra- Both potential dividers are followed by a buf-
pidly. This is because fresh, cool water from fer stage (IC1a/IC1b). IC1c and R3, R4, R5 and
the swimming pool enters the collector. Once R6 make up a differential amplifier (with unit
the difference is less than 3 °C the pump is gain), which measures the temperature diffe-
turned off again. rence (i.e. voltage difference).
R10/R1 and R9/R2 each make up a potential When both temperatures are equal the out-
divider. The output voltage will be about half put is 0 V. When the temperature of the solar
246
L
310 circuits
elektor international media bv – 089018/uk
pagina 246
collector rises, the differential amplifier out- The power supply has been kept fairly simple
puts a positive voltage. This signal is used to and is built around a LM7812 regulator. The
trigger a comparator, which is built round an circuit is protected against a reverse polarity
LM393 (IC2a). at the input by D3. You have to make sure
R7 and P1 are used to set the reference volt- that the input to the regulator is at least 15 V,
age at which the comparator changes state. otherwise it won’t function properly.
R8 and P2 provide an adjustable hysteresis.
R11 has been added to the output of IC2a be- There are a few points you should note regar-
cause the opamp has an open collector output. ding the mounting of the NTCs. NTC R9
A power switch for the pump is created by should be placed near the output of the solar
R12, T1 and Re1. D1 protects T1 against volt- collector. You should choose a point that al-
age spikes from the relay coil when it is tur- ways contains water, even when some of the
ned off. water flows back a little. NTC R10 should be
mounted inside the filter compartment
A visual indication of the state of the control- (where it exists), which continually pumps the
ler is provided by IC4 (UAA170), a LED spot swimming pool water. This will give a good
display driver with 16 LEDs. The reference indication of the temperature of the water.
voltage for the comparator is buffered by The way the circuit has to be set up depends
IC1d and fed to input VRMAX of the UAA170. how it has been installed and is very much an
R20/D21 and R23/D22 limit the input voltages experimental process. To start with, set hys-
of IC4 to 5.1 V, since the maximum permiss- teresis potentiometer (P2) halfway. Then set
ible input voltage to the UAA170 is 6 V. the reference voltage to about 1.5–2 V with
P1.
When there is no temperature difference, On a sunny day you can measure the voltage
LED D20 turns on. As the temperature diffe- difference to get an idea as to which refer-
rence increases the next LED turns on. The ence voltage needs to be adjusted.
full scale of the LED bar is equal to the refe- The hysteresis setting determines how long
rence voltage of the comparator. This means the pump stays on for, which is until the mini-
that when the last LED (D5) of the UAA170 mum temperature difference has been
turns on, the comparator switches state. This reached.
is also indicated by D2. (050217)
247
R
310 circuits
elektor international media bv – 089018/uk
pagina 247
J1 D1 D4 T1
G1
1 BD911
2
R1 J2 J3
R3 R2
500 Ω
D2 D3 LA1 LA2
1 1
20k
20k
2 2
4x 1N4004 C4 C3
10µ 10µ
63V 63V
D5 T3 T2
C1 C2
47µ 47µ
63V 63V 6V8
BD911 BD911
080504 - 11
t = R3× C 3 = 20 × 10 3 × 10 × 10 -6 = 0.2 s and has been working for more than a year
now.
You can use a 22 kΩ (common value) for R2 There are a few things I would change for the
and R3, that doesn’t make much ifference. next revision. An on/off switch would be nice.
On a small piece of prototyping board are ix And if the whole circuit was built with SMD
LEDs with a voltage dropping resistor in se- parts it could be mounted near the front light.
ries with each pair of LEDs. Such a PCB is used This would also be more onvenient when rou-
for both the front and the rear of he bike. Of ting the wiring. Now he cable from the dyna-
course, you use white LEDs for the front and mo goes all the way to the seat and from
red ones for the rear. The PCB ith the main cir- there to the front and rear lights.
cuit is mounted under the eat, where it is safe (080504-I)
248
L
310 circuits
elektor international media bv – 089018/uk
pagina 248
L
The field, which appears
around the lamp cable
C1
X2
when the mains is connec-
1µ 250V ted, can be sensed by a
R1 short piece of insulated
wire simply wrapped around
100 Ω S1 it and this is amplified by
D2
the three stage amplifier
1N4148 RE1 D3 R2 which can be regarded as a
single super-transistor with
1k
230V
L1
a very high gain.
1N4148 T2 BC557
249
R
310 circuits
elektor international media bv – 089018/uk
pagina 249
250
L
310 circuits
elektor international media bv – 089018/uk
pagina 250
Wim de Jong
251
R
310 circuits
elektor international media bv – 089018/uk
pagina 251
method for determining the time. This clock The DS1820 temperature sensor shown in the
does not need to be set. The solar clock is schematic and the 433-MHz transmitter (a
born. cheap transmit/receive module from Conrad
Electronics) are optional. These can be used
The controller is built around a PIC16F628A, to measure the outside temperature and send
which runs from its internal RC oscillator at 4 it to a receiver in the house. This outside tem-
MHz. perature is sent as a byte once every minute
When sunrise is detected, a counter is star- and at a baud rate of 1200 bits/s (8 bits, no pa-
ted, this counter keeps running until the fol- rity) with a resolution of half a degree.
lowing sunrise (reset). –2=–1°, 0=0°, 2=1° etc.
At sunset, the current value of the counter is
stored in the variable ‘zontot’. So after sunset Sensor and transmitter can be omitted with-
the time can be determined with the formula: out any problems if this functionality is not
required.
time = counter – zontot/2
The adjustment procedure is as follows. Set
This design has two pushbuttons to set the the potentiometer so that the LED is on when
switching times; ‘Evening off’ (S1) and ‘Mor- it is dark and off when it is light. Leave the cir-
ning on’ (S2). The push buttons can only be cuit alone for a 24-hour period so that the
operated after sunset and before sunrise. controller can synchronise with the daily sun
If in the evening (after sunset, the garden cycle.
light are on) button S1 is pushed, the lights After that you can use the two pushbuttons to
will from now on go off at this particular time. set the switching times.
When button S2 is pressed in the morning be- (080258-I)
fore sunrise, the lights, from now on, will turn
on at this time and continue to be on until Downloads
sunrise. The source and hex code files for this project
These times are stored in the EEPROM inside are available as a free download from
the PIC so that they are not lost when the sup- www.elektor.com; file #080258-11.zip.
ply voltage is removed.
252
L
310 circuits
elektor international media bv – 089018/uk
pagina 252
+5V
IC1
7805
K1
R3
C3 C4 C2 C1
33k
14
16 13
RA7/OSC1/CLKIN RB7/T1OSI/PGD
15 12
RA6/OSC2/CLKOUT RB6/T1OSO/T1CLK/PGC
4 11
RA5/MCLR/VPP RB5
3
IC1 10
RA4/TOCLK/CMP2 RB4/PGM
2 9
RA3/AN3/CMP1 RB3/CCP1
1 8
RA2/AN2/VREF RB2/TX/CK
18 7 S5
RA1/AN1 PIC16F628 RB1/RX/DT
17 6
RA0/AN0 RB0/INT
SAVE 1
5
S1 S3 S6
D2 D1
MIN MAX
+ RECALL 1 SAVE 2
R2 R1 S2 S4 S7
1k
1k
060082 - 11
à check for pushbutton presses; We have a few things that need to be noted
à check for valid values and turn on one of regarding the construction of the circuit. Pro-
the LEDs if the limit value has been vide sufficient cooling for IC1, particularly if it
reached; is used with a high power servo or if the servo
à send the pulse; is exerting force continuously, for example
à wait 20 ms. against a spring. Also make sure that the
253
R
310 circuits
elektor international media bv – 089018/uk
pagina 253
servo is connected correctly. Different manu- ton PICbasic compiler. It is however necessa-
facturers use different colour codes. Fit C3 as ry to remove the comments.
close as possible to the PIC. This is because The program code can be downloaded from
C3 serves to suppress interference from the www.elektor-electronics.co.uk, you’ll find it
servo. filed as number 060082-11.zip. A pre-pro-
The software for the project has been written grammed PIC is available as order code
in PICbasic and includes comments. The pro- 060082-41. A version of PICbasic can be ob-
gram is easily compiled and optionally tained from www.picbasic.org.
changed with the free Lite version of the Pro- (060082-1)
Stefan Hoffmann
R8
C1 C3 C4 C2
10k
S1 1
47µ 10n 10n 47µ
25V 16V LD1 12 LD2 12
13 2 2
PA0 R1 A R9 A
IC1 12 15 15
PA1 R2 B R10 B
2 11 13 13
PB0 PA2 R3 C R11 C
BT1 3 10 11 11
PB1 PA3 R4 D R12 D
6 9 5 5
PA7 PA4 R5 E R13 E
5 8 3 3
PB2 PA5 R6 F R14 F
9V 7 14 14
PA6 R7 G R15 G
ATtiny44 4 10 10
PB3 DP DP
S3 S2
7 SEGMENT 7 SEGMENT
14 TENS UNITS
DOWN UP
080181 - 11
254
L
310 schakelingen
elektor international media bv – 089018/nl
pagina 254
255
R
310 circuits
elektor international media bv – 089018/uk
pagina 255
MASTER SLAVE
S1
S2
R1 R2 R3 BZ1
D2 D3
10k
100k
100k
blue red
BT1
R4
560 Ω
9V
D1 optional
C1 C2 1N4148
2x 1N4148
2N3904
050385 - 3 - 11
room. Rather than resorting to a full-blown is much more noticeable than a continuous
intercom system, a simpler solution was envi- signal especially in noisy conditions. Since
saged and while a buzzer could easily fulfil the voltage across a red LED is typically about
this function, this circuit has the advantage of 1.5 V while a blue LED requires at least 2.5 V
providing a visual indication of a call as well to 3 V to light, the blue LED will remain off
as confirming to the caller that the ‘message’ when the call button S1 is pressed. Despite
has been received. This is especially useful in being rated for operation at 3-12 V, most
the latter case, as the call may be easily piezo sounders can still produce a piercing
drowned out by the music playing in the sound from the pulsed 1.5-V available across
headphones. the red LED which should get the attention of
The circuit, which requires no complicated even the most preoccupied teenager.
switching, uses a simple two-wire connection
between the two stations and utilises the fact When the recipient presses the acknowledge
that the forward voltage drop of a blue (or (push to break) switch S2, the red LED/buzzer
white) LED is greater than that of a red, green are disconnected allowing the blue LED to
or yellow one. flash at the sending station indicating to the
The circuit is based on a two-transistor multi- caller that his call has been received. Alterna-
vibrator which is used to pulse a red LED (D3) tively, if a blue LED is not available, a red or
as well as the buzzer Bz1 on and off at about green type in series with a forward biased sili-
1.5 Hz when push button S1 is closed. This con diode to raise its forward voltage above
frequency may of course be altered if requi- that of the red LED in the receiver could be
red by changing the values of the capacitors. used instead.
The diode D1 in series with the collector of
transistor T2 is required to isolate the output The circuit may be powered by a 9-V battery,
from the effects of the buzzer circuitry, which a mains power supply being unnecessary in
would alter the multivibrator frequency. view of the low power consumption and in-
In principle, the multivibrator could be dis- frequency of use of the circuit.
pensed with but a pulsed buzzer/flashing LED (050385-3)
256
L
310 circuits
elektor international media bv – 089018/uk
pagina 256
DVM LPD335LCD
+5V
P1
+5V
3
C2
20k
IC2 IC1
100n 1
+VIN
–VIN
P1
P2
P3
+VBAT
–VBAT
12 3 7
+5V 8
6
OP07
2
4
D1
BAW76 –5V
–5V
R1
0V2
900k
0%5 +5V
R2 R4 R3
20V/200V D2 C1 T3
9k1
1k0
100k
100n R5
BAW76 +3V2 0%5 0%5 T1
10k
T2
BS250
R6 R7
BS250
R8 R9
10k
10k
+5V BS170
15k0
33k0
IC2 = TLC374
R12 +3V2 5
(±200mV) 6 2
2k2
R10
0V2
R11 IC2.B
1 4
IC2.A 47 Ω 1M
7
R14
R15
1k0
5k6
R13 8
P2 IC3
14
1k0
2k C5 C3 IC2.C
9
C4
R16 100n 100n
22k
100n 10
13
IC2.D
11
TL431C 080249 - 11
257
R
310 circuits
elektor international media bv – 089018/uk
pagina 257
into a ground-referenced voltage. This part of adjusting the value of R10. However, the cir-
the circuit is based on a design idea from Car- cuit will oscillate if the value is too high. Film
sten Weber [1] that was published in the June capacitors C1, C3 and C4 suppress noise and
2005 issue of Elektor Electronics. create a certain amount of inertia for range
If the input voltage is less than 20 V, the volt- switching. This prevents frequent back-and-
age divider formed by R1 and R4 reduces it by forth switching in the threshold region.
a factor of 100. Transistor T2 is cut off, so R3 The other two comparators of IC2 supply mu-
has no effect on the division ratio. The volt- tually complementary output levels that de-
age at the junction of voltage divider R8/R13 pend on the measuring range. The associated
is 200 mV because the open-collector output decimal points of the DVM module are driven
of comparator IC2A is in the high-impedance via p-channel FETs.
state. If the input voltage rises above 20 V,
IC2A changes state and the voltage at the The circuit has two trimpots: P1 is used to
junction of voltage divider R8/R13 drops to correct for the offset voltage of the operatio-
less than 20 mV. In response to this, the out- nal amplifier (IC1), while P2 is used to set the
put of comparator IC2B goes high and T2 con- threshold level for range switching. For this
ducts. R3 is now connected in parallel with purpose, first adjust the trimpot to produce
R4. This yields a division factor of 1000 (200-V the maximum possible reference voltage
range). Of course, the larger division factor (around 3.4 V). Next apply an input voltage
also causes the input voltage of IC2A to drop. that causes a display reading of 19.99 (which
To prevent this comparator from changing ideally means 19.99 V). Now turn P2 until the
back to its previous state (which would cause measuring range switches. As a check, reduce
the circuit to act like a sort of oscillator), the the input voltage to force the measuring
value of R10 must be chosen such that the range to switch back, and then slowly in-
voltage at the junction of voltage divider crease the input voltage again. The ideal set-
R8/R13 is less than 20 mV, as previously men- ting is reached when the measuring range
tioned. The calculated value (with R10 in pa- switches before the DVM module displays an
rallel with R13) is approximately 9.6 mV. In ‘overrange’ indication.
practice, the value is around 18 mV due to the (080249-1)
resistance of the output transistor of the
comparator. This means that the circuit will Reference
switch back to the lower voltage range when [1] DVM Without Isolation,
the input voltage drops below approximately Elektor Electronics June 2005.
18 V. The amount of hysteresis can be set by
258
L
310 circuits
elektor international media bv – 089018/uk
pagina 258
259
R
310 circuits
elektor international media bv – 089018/uk
pagina 259
F1 +12V
+12V
5A
P1
C2 14
Frequency IC2 IC2 = 4013
1000µ 7
100k 25V
MJ3001 240V
TR1
8 4 T2
B T2 LA1 R6
R R4 240V
7 5 1
9V
DIS D 1k5
IC2
240V
R1 IC1 R3 R5
9V
2 3 3 2
18k
330n
0
080227 - 11
place in this summer issue. Let’s not forget, facturer, of course!) which are cheap and rea-
for example, that just to get a meagre 1 amp dily available, but any equivalent power
at 230 V AC, the battery primary side would Darlington could be used.
have to handle more than 20 ADC !
These drive a 230 V to 2×9 V centre-tapped
The circuit duiagram of our project is easy to transformer used ‘backwards’ to produce the
follow. A classic 555 timer chip, identified as 230 V output.
IC1, is configured as an astable multivibrator The presence of the 230 VAC voltage is indica-
at a frequency close to 100 Hz, which can be ted by a neon light, while a VDR (voltage de-
adjusted accurately by
means of potentiometer P1.
As the mark/space ratio
(duty factor) of the 555 out-
put is a long way from being
1:1 (50%), it is used to drive
a D-type flip-flop produced
using a CMOS type 4013 IC.
100%
260
L
310 circuits
elektor international media bv – 089018/uk
pagina 260
pendent resistor) type S10K250 or S07K250 adjustment being to set the output to a fre-
clips off the spikes and surges that may ap- quency of 50 Hz with P1. You should keep in
pear at the transistor switching points. minds that the frequency stability of the 555
is fairly poor by today’s standards, so you
The output signal this circuit produces is ap- shouldn’t rely on it to drive your radio-alarm
proximately a squarewave; only approximat- correctly – but is such a device very useful or
ely, since it is somewhat distorted by passing indeed desirable to have on holiday anyway?
through the transformer. Fortunately, it is Watch out too for the fact that the output
suitable for the majority of electrical devices voltage of this invertor is just as dangerous as
it is capable of supplying, whether they be the mains from your domestic power sockets.
light bulbs, small motors, or power supplies So you need to apply just the same safety ru-
for electronic devices. les! Also, the project should be enclosed in a
Note that, even though the circuit is intended sturdy ABS or diecast so no parts can be
and designed for powering by a car battery, touched while in operation.
i.e. from 12 V, the transformer is specified The circuit should not be too difficult to
with a 9 V primary. But at full power you need adapt to other mains voltages or frequencies,
to allow for a voltage drop of around 3 V be- for example 110 V, 115 V or 127 V, 60 Hz. The
tween the collector and emitter of the power AC voltage requires a transformer with a dif-
transistors. This relatively high saturation ferent primary voltage (which here becomes
voltage is in fact a ‘shortcoming’ common to the secondary), and the frequency, some ad-
all devices in Darlington configuration, which justing of P1 and possibly minor changes to
actually consists of two transistors in one the values of timing components R1 and C1
case. on the 555.
(080227-I)
We’re suggesting a PCB design to make it
easy to construct this project; as the compo-
nent overlay shows, the PCB only carries the Web Links
[1] MJ3001
low-power, low-voltage components.
www.st.com/stonline/products/
literature/ds/5080.pdf
The Darlington transistors should be fitted Downloads
onto a finned anodized aluminium heatsink The PCB pattern is available for free download
using the standard insulating accessories of from our website www.elektor.com;
mica washers and shouldered washers, as file # 0080227-1.zip.
their collectors are connected to the metal
cans and would otherwise be short-circuited.
An output power of 30 VA implies a current
consumption of the order of 3 A from the 12 V
battery at the ‘primary side’. So the wires con-
necting the collectors of the MJ3001s [1] T1
and T2 to the transformer primary, the emit-
ters of T1 and T2 to the battery negative ter-
minal, and the battery positive terminal to
the transformer primary will need to have a
minimum crosssectional area of 2 mm2 so as
to minimize voltage drop.
The transformer can be any 230 V to 2×9 V Robots, robots
type, with an E/I iron core or toroidal, rated at and more
around 40 VA. robots
from page 340
Properly constructed on the board shown of this book!
here, the circuit should work at once, the only
261
R
310 circuits
elektor international media bv – 089018/uk
pagina 261
Liam Maskey K2 D+ D+ K1
USB-B 3 3 USB-B
262
L
310 circuits
elektor international media bv – 089018/uk
pagina 262
K2
1 1
2
R12 D17 R5
C1 3
10k
10k
100n receiver
R13
1N4448 14
1k
K3
1
4
MCLR 2
CAL 6
RB0 3
IC1 7
RB1 T1
3 8
R8 RA4 RB2 motor
2
RA3 RB3
9 controller
220k
K1 1 10 with BEC
1 R7 RA2 RB4 2N7002
Lipo (3 cells)
18 PIC16F84 11
2 100k RA1 RB5
17 12
3 R6 RA0 RB6
13
4 33k RB7
R9 R10 R11
OSC2 OSC1
10k
10k
10k
15 16 5
X1
3x 100n
080053 - 11
263
R
310 circuits
elektor international media bv – 089018/uk
pagina 263
264
L
310 circuits
elektor international media bv – 089018/uk
pagina 264
560 Ω
D2
3k3
Da Db positions. Standard LEDs
draw more than 10 mA,
whereas low-current types
brown green red
dark blue
Simulation programs for analogue circuits on a PC instead of reaching for the soldering
come in all shapes and sizes, and at various iron. The website of Paul Falstad contains a
prices. It is often much easier to test a circuit free Java applet that illustrates how various
265
R
310 circuits
elektor international media bv – 089018/uk
pagina 265
basic analogue and digital circuits work. Volt- educational as well. Each simulation is ac-
ages and currents can be brought to life in si- companied by a short escription.
mulated scope screens; circuits can be The simulations aren’t limited to just electro-
modified by the ddition, removal or altera- nics; other subjects such as physics and ma-
tion of components. thematics have also been extensively
covered. There’s more than enough on this
Unfortunately, the addition of components as website to keep you happily occupied for a
not (yet?) been fully implemented in the pro- few hours...
gram: you’ll see the dded component appear (060196-1)
in the circuit iagram, but it won’t have any ef-
fect in he operation of the circuit.
Web Link
www.falstad.com/mathphysics.html
But don’t let that spoil your fun. Its usefulness The electronics simulation can be found under
is increased by the addition of a large ibrary Electrodynamics/Analog Circuit Simulator Applet
of example circuits, which makes his applet
266
L
310 circuits
elektor international media bv – 089018/uk
pagina 266
1M
330k
330k
T2
T3 C6 C7
26µA @ Ue = +12V
BC327
R5 220µ 220µ
C3 C4
63V 63V
220k
2SJ221
1n 3n3 2SJ174
100V
20A
0Ω22
D1 D2
BAT46 C2 BAT46
1µ
+3V3
IC1
L1
* +5V
R2 T1
3 7 ≈110mH
100k D4 1Ω ≤ 500mA
6
TL061
2
BS170
4 SB360
SB160
R4 C8 C9
100k
R3.A R3.B C5 220µ 220µ
D5 C1 10V 10V
330k
470k
10n
3V3 100n
ZRC330A01
to 5 V, D2 becomes forward biased and rent; with no load attached the circuit oscilla-
powers the IC from the output. Diode D1 be- tes at about 40 Hz while at 500 mA it runs at
comes reverse biased reducing current approximately 5 kHz. The variable clock rate
through R1. When the circuit is first powered dictates that the output inductor L1 needs to
up the voltage on pin 2 of IC1 is below the have the relatively high value of 100 mH.
reference voltage on pin 3, this produces a
high level on output pin 6. The low power The coil can be wound on ferrite core ma-
MOSFET T1 is switched on which in turn terial with a high AL value to allow the smal-
switches the power MOSFET T3 via R5 and lest number of turns and produce the lowest
the speed-up capacitor C4, the output voltage possible resistance. Ready-made coils of this
starts to rise. value often have a resistance greater than 1 Ω
and these would only be suitable for an out-
When the output approaches 5 V the voltage put load current of less than 100 mA.
fed back to the inverting input of IC1 be-
comes positive with respect to the non inver- The voltage divider ratio formed by R4 and R3
ting input (reference) and switches the output sets the output voltage and these values can
of IC1 low. T1 and T3 now switch off and C3 be changed if a different output voltage is re-
transfers this negative going edge to the base quired. The output voltage must be a mini-
of T2 which conducts and effectively shorts mum of 1 V below the input voltage and the
out the gate capacitance of T3 thereby impro- output has a minimum value of 4 V because of
ving its switch off time. the supply to IC1.
The switching frequency is not governed by a A maximum efficiency of around 90 % was
fixed clock signal but instead by the load cur- achieved with this circuit using an input volt-
267
R
310 schakelingen
elektor international media bv – 089018/nl
pagina 267
age between 9 and 15 V and supplying a cur- ting, these devices tend to have a smaller for-
rent greater than 5 mA, even with an input ward voltage drop which reduces losses in
voltage of 30 V the circuit efficiency was the diode at high currents. At higher input
around 80 %. If the circuit is used with a rela- voltage levels the value of resistor R1 can be
tively low input voltage efficiency gains can increased proportionally to reduce the
be made by replacing D4 with a similar device quiescent current even further.
with a lower reverse breakdown voltage ra- (050264-1)
Friedrich Weigand
1
It has been known since Ein- +5V
1 R1 9x 1k
vice!
PB7
18 IC1 2
PB6 PD0
17 3
PB5 PD1
The circuit of the 16
15
PB4 PD2
6
7
toothbrush timer (Figure 1) 14
PB3 PD3
8
uses the familiar Atmel RISC
PB2 PD4
13 9
PB1 PD5
AT90S2313 microcontrol- 12
PB0 PD6
11
IC2
ler, together with an oscilla- AT90S2313P ≥ +9V D10 7805 +5V
tor formed by X1, C1 and XTAL1 XTAL2
C2. 1N4001
5 4 10
X1
C5 C4
268
L
310 circuits
elektor international media bv – 089018/uk
pagina 268
COMPONENTS LIST
2a 2b
C3
IC1
D1 X1
C1 C2
D2 D3 D4 D5 D6 C4
R1
IC2
D7 D8 D9
0 + 050146-1 C5
1-641050 050146-1
D10 ROTKELE )C( (C) ELEKTOR
85%
85%
269
R
310 circuits
elektor international media bv – 089018/uk
pagina 269
damage should the 9 V PP3 (6F22) type batte- mounted flat on the board to allow the LEDs
ry be accidentally connected the wrong way to stand above the other components and
around. poke through holes in the enclosure.
The whole circuit can be built on the printed A socket should be used for the microcontrol-
circuit board shown in Figure 2. There are a ler. Almost all the components are polarity-
few wire links near to the resistor array. The sensitive: check carefully before you solder!
voltage regulator, crystal, C4 and C5 are (050146)
G. Baars
270
L
310 circuits
elektor international media bv – 089018/uk
pagina 270
COMPONENTS LIST
Resistors:
R1 = 180 kΩ
R2 = 47 kΩ
R3 = 10 kΩ
P1 = 50 kΩ linear potentiometer
Capacitors
C1, C2 = 100 nF
C3 = 47 nF
Semiconductors
D1 = 1N4148
IC1 = 74HCT00
Miscellaneous
K1 = 2-way SIL pinheader
K2 = 3-way SIL pinheader
100%
servo from Futaba it was observed that with a tion amounts to about 120 degrees. Since the
pulse duration of 1–2 ms it rotated through S3003 servo has a not inconsiderable torque
an angle of 90 degrees. However, by shorte- of 4 kg⋅cm, at can be used, for example, to re-
ning the pulse duration a little more, to about mote control the tuning capacitor of a so-
0.6 ms, there was a further 30 degrees of rota- called ‘magnetic-loop’ RF antenna.
tion. The current consumption of the servo de-
pends on the torque that needs to be de-
The component values in the circuit were livered and varies from a few tens to several
chosen so that the pulse duration can be set hundreds of milliamps.
from 0.6 to 2 ms with P1 and the total rota- (080026-I)
1k
G T1
47µ
25V
271
R
310 circuits
elektor international media bv – 089018/uk
pagina 271
sing button S1 rapidly charges C1 via R1. governs the capacitor discharge current, sec-
When the voltage on C1 exceeds the thres- ondly the capacitance of C1 and finally the
hold voltage at the gate of FET T1 it conducts supply voltage from the battery BT1. When
and switches the battery to RL. The drain- C1 is charged to a higher voltage it takes
source voltage drop introduced by the FET is longer to fall below the threshold level. The
negligible for the two types of FET specified component values given will produce an ‘on’
(for a maximum load current of either 100 mA time of around 10 minutes with a supply of
or 1 A). 5 V. The FET turns off relatively slowly at the
end of the ‘on’ period; this should not cause a
T1 remains conducting as long as the voltage problem if the switched equipment uses only
on C1 is greater than the FET gate threshold analogue circuitry but can lead to a momen-
voltage (around 2 V for the FET types speci- tary malfunction if the equipment contains di-
fied). The length of the ‘on’ period depends gital circuitry.
on three factors; firstly the value of R2 which (060121-1)
Burkhard Kainka
2 7
LS NC
The LS input is connected directly to the solar 4
NC VOUT
6
272
L
310 circuits
elektor international media bv – 089018/uk
pagina 272
Peter Herlitz
R1.A R9.A
47k
470k
especially designed for use
0W5 0W5
LA1
47k
470k
(FLs). The circuit contains 0W5 0W5
4M7
10k
4k7
100k
board of only 2 by 3 cm if 230V
T2 T4
4k7
THY1
470 Ω
4k7
10µ 4µ7
273
R
310 circuits
elektor international media bv – 089018/uk
pagina 273
supply voltage.
R1 C3
6 4
209k
ILIM PG 330k
15n
3 10
current consumption is less 100n
are:
274
L
310 schakelingen
elektor international media bv – 089018/nl
pagina 274
100%
100%
à high operating frequency (750 kHz) → better if the output voltage is 3.3 V or more.
small external inductor; The input voltage can be anywhere in the
à integrated power MOSFETs → high effi- range of 2 V to 5.5 V, and of course it has to be
ciency (up to 95 %); higher than the desired output voltage. The
à no external switching diode necessary. output voltage is 3.3 V with the indicated
component values and an input voltage of
You can thus use this device to build a very 5 V.
compact, highly efficient voltage converter. A If you want to reduce the component count
sample layout generated by the author is even further, you can use a member of the fa-
available as a file on the Elektor website. mily with a fixed output voltage. The available
voltages are 0.9, 1.0, 1.2, 1.5, 1.8, 1.9, 2.5,
The TSOP62000 provides an internal referen- and 3.3 V. With this approach you can omit
ce potential of 0.45 V, which can be used to R2, R3 and C3, so the output can be connec-
set the output voltage in the range of 0.5 V to ted directly to pin 5.
5 V by means of resistors R2 and R3. The for- (070966-1)
mula for this is:
R2
Vout = 0.45 V + 0.45 V × Web Link
R3 TPS6200-datasheet:
focus.ti.com/lit/ds/symlink/tps62000.pdf
For relatively low voltages, the value of induc-
tor L1 should be 10 µH, but a value of 22 µH is
275
R
310 circuits
elektor international media bv – 089018/uk
pagina 275
randomly.
BT1
C1
The source and hex code files for the
C3 C2
9V
PIC12F675 device are available as free down- 100n 1µ
16V
100n
Marcel Cremmel
276
L
310 circuits
elektor international media bv – 089018/uk
pagina 276
1 2
product: the LCD in a Nokia 3310 mobile tele- à we solder an 8-wire ribbon cable to the
phone (the 3410 can also be used, the resolu- pads (Figure 1). Don’t forget, the pitch is
tion is then 96×64 pixels). You can find 1.14 mm!
numerous sites on the web which sell this
product (new or used) as a one-off or in bulk. à we reproduce the original connection sys-
tem. Tests have shown excellent reliabili-
After such praise, what is there to criticise? ty with tin-plated solder pads. Interested
Any difficulty in implementation is due to the readers will find artwork for PROTEL soft-
connections. ware on the Elektor website.
The connector is composed of gold-plated
‘spring’ blades (on the LCD) which rest on sol- Connector
der pads (in the telephone) to establish con- Do not attempt to extract the display from its
tact. Two DIY solutions are possible: plastic casing as the display also includes part
277
R
310 circuits
elektor international media bv – 089018/uk
pagina 277
LSB
4
0
Y-address
MSB
5
0 X-address 83
060080 - 13
5 6
of the telephone keyboard. You can get rid of Assigning registers for the PCD8544 configu-
it with a plastic cutout (the red line on the ration and for the ‘screen’ RAM is carried out
photo in Figure 2). Do not cut out the top part by a synchronous serial connection:
if you are planning to use the original connec-
tion system – the securing screws can be used à SCE : selection of the circuit (5)
to maintain contact pressure. à SDIN : serial input output (3)
à SCLK : synchronous clock (2)
Power supply à D/C : given selection/command (4)
All you need to do is apply a supply voltage of à RES : Reset (8)
between 2.7 and 3.3 V to the display. The dis-
play has its own the DC-DC converter which Figure 5 shows the typical timing diagram for
produces the required current for the LCD, writing a command.
decoupled by C2 (see diagram in Figure 3).
You will find a test program in C on the Elek-
Programming tor website (ref. 060080-11.zip) that has the
The LCD uses a controller type PCD8544 from most common functions: initialisation, write
Philips [1]. Full documentation is available on text (two font sizes) and simple drawing
the web. The circuit has a screen memory or- (pixel and straight track). It is written for the
ganised into six lines of 84 bytes, or 504 MSP430 family in the free IAR environment [2]
bytes. but is easily adaptable to other microcontrol-
lers because it does not rely on hardware
The eight bits of a byte represent the states of from a specific resource (SPI coupler, among
eight vertical pixels corresponding to the other things).
screen (state 1 = black pixel, see Figure 4). In
order to display text, for example, the pro- Furthermore, a program called Test_LCD_No-
gram should ‘draw’ each letter in the screen kia_3310 is available (see Figure 6). It runs on
memory. the PC and is used to test the display connec-
278
L
310 circuits
elektor international media bv – 089018/uk
pagina 278
ted to the parallel port as shown in the dia- buffer gates have been added to avoid any
gram in Figure 3. risk of damaging or overloading the LCD elec-
The installation of this program is simple: tronics. For example, the LCD does not seem
copy the executable to any folder and the to like voltages applied to logic inputs in the
TVicLPT.sys file to C:\Windows\System32\Dri- absence of the supply voltage.
vers. (060080-1)
Available functions:
Internet Links
à free drawing with the mouse; [1] www.semiconductors.philips.com/products/
à text drawing; [2] MSP430, 4K KickStart Edition v3.40A
à variable speed scrolling in 4 directions; on www.iar.com
à saving the drawing.
The archive file ‘LCD_Nokia’ containing all of the
files mentioned in this article can be downloaded
The low current consumption of the LCD
free of charge from www.elektor.com
means it can be powered from the printer
output port. However, a 3 V regulator and
R2
2k2
LM1117-3.3
ZigBee wireless system if XBee Digital Input
you use the XBee and XBee
1 20
VCC i/o
2 19
279
R
310 circuits
elektor international media bv – 089018/uk
pagina 279
280
L
310 circuits
elektor international media bv – 089018/uk
pagina 280
cannot include parameters with some of the The PIR transmitter module can be placed
commands and the module will not under- anywhere within a range of 30 metres from
stand some of the commands. the receiver, such as in the garden. For a
larger range, you can use the somewhat more
Also be sure to perform a Read operation first expensive XBee Pro modules.
when you update the firmware (from 1083 to (080166-1)
10A2).
Downloads
If you immediately perform a Write with the The source code and hex code for this design
new version, you will lose communication are available on www.elektor.com for free down-
with the module because the configured loading; file # 080166-11.zip.
parameters will be overwritten.
F. Roesky
+U
TH1
any of their usefulness as 0
3 R5
a number of advantages: 5
1
14 5
& 6
9
power is derived via the T2
74HC4017
CT≥5
12
T3
>100 V).
In spite of these proven practical properties, tacts of the main flash unit via resistor R1 and
the design is simplicity itself. It is controlled voltage limiter D1.
by a low-current CMOS decimal counter IC1, a
Type 74HC4017, which enables the entire cir- The control circuit based on transistor T1 also
cuit to be powered directly via the sync con- operates with minimal quiescent current.
281
R
310 circuits
elektor international media bv – 089018/uk
pagina 281
When a flash is detected, T1 provides a clock the voltage across C1 collapses. This is of no
pulse to IC1. Depending on the position of consequence, however, since after at most
switch S1, the low-power thyristor fires on one second C1 is recharged to a level at which
the second or third flash pulse, so that it does the circuit is operational again.
not react to the preliminary flash that pre- If the circuit is to be polarity-sensitive, con-
vents the red-eye effect. After about 0.4 sec- nect a small bridge rectifier rated at 400 V be-
ond, when the main flash unit is discharged, tween the contacts of the main flash unit and
IC1 is reset via R4, C3 and T3. At that instant, terminals JP1 and JP2.
the current drain of IC1 increases briefly and (050047-1)
Ton Giesberts
282
L
310 circuits
elektor international media bv – 089018/uk
pagina 282
1 R2
10k
R6
7k15
K1 6 K2
R1 C9 R16
2 13 7
10k C1 C2 C3 C4 IC1.B 100 Ω
1 14 5
IC1.A IC1.D 2µ2
3 P2 12 R17
47n 47n 47n 68n
100k
TREBLE
R9 R10 R11
100k IC1 = TL074
8k2
8k2
8k2
R4 R5
+15V
1k
10k +15V
R3 R7 C10
1k
10k
R15 100n
C5 C6 C7 4
1M
P1
10n 10n 10n
IC1
11
BASS C11
10
R12 R13 R14 C8
100k 8
100n
IC1.C 2k2 2k2 2k2
9
100n -15V
R8
6k8 -15V 060015 - 11
by R6 = 7.15 kΩ and R8 = 6.80 kΩ. However, IC1.B buffers the summed signal across R15.
the operating principle requires the input sig- C9 removes any DC-offset voltage and R16
nals to the two networks to be in anti-phase. protects the output buffer from the effects of
For best operation the networks are driven by too high capacitive loads. R17, finally, keeps
two buffers providing some extra gain. The the output at 0 V.
gain of IC1.D is slightly higher than that of The choice of the quad opamp is relatively un-
IC1.C to ensure the overall response curve re- critical. Here the unassuming TL074 is used
mains as flat as possible at equal settings of but you may even apply rail to rail opamps as
the tone controls. Because each network in- long as they are stable at unity gain. Also,
troduces a loss of about 1.72 (times), IC1.D watch the supply voltage range.
and IC1.C first amplify the signal. The gain is The graph in Figure 2 (produced by our Audio
set at about 8 (times) allowing input signal le- Precision analyser) shows nine response cur-
vels up to 1 V to pass the circuit at maximum ves obtained by setting the two tone controls
gain and distortion-free. The gain also com- to minimum, mid position and maximum.
pensates the attenuation if
you prefer to keep the tone +6
2
controls at the mid positi- +4
ons for a straight response. +2
rewarding to experiment d
with, especially in respect
-3
B
20 dB.
283
R
310 circuits
elektor international media bv – 089018/uk
pagina 283
3a 3b
100%
100%
COMPONENTS LIST
Note that 0 dB is relative to the mid position of boards are required for a stereo application.
the pots! The relevant connections on the boards are
A simple circuit board was designed for the then wired to a stereo control potentio-
project (Figure 3). Linear-law potentiometers meter.
may be fitted directly onto the board. Two (060015-1)
Parallax, well known for its successful Basic difference. It packs no less than eight 32-bit
Stamp IC, has recently introduced the Propel- processors (referred to as COGs in Propeller
ler: a new microcontroller with a certain jargon) into a single package with only 40
284
L
310 circuits
elektor international media bv – 089018/uk
pagina 284
10k
kes it relatively easy to im-
R1 R4
Parallax Propeller
1
plement video and signal-
10k
4k7
6
processing applications. 2
7
Rx
BC547
Rx 40 (38)
A31
T1
R2
3 Tx
10k
9
uage or the high-level Spin 5 GND BC557
language. The processor
and the programming tools SUB D9
9 (5)
VSS
were developed entirely in- LQFP
285
R
310 circuits
elektor international media bv – 089018/uk
pagina 285
470 Ω
470 Ω
470 Ω
10k
680 Ω
22k
33k
33k
33k
6k8
1k
1k
2k2
1k
1k
4k7
4k7
4k7
4k7
1k
080473 - 12
286
L
310 circuits
elektor international media bv – 089018/uk
pagina 286
2 3
you were unlucky a hair would land between grot’, so due attention should be given to RF
the E and B wires. Another disadvantage is decoupling and changed internal capaci-
the transistor case then being at the emitter tances.
or collector potential, causing RF radiation There is no point in buying NOS (new old
and the magical but unwanted ‘hand effect’ – stock) OC17x or AF11x transistors on EBay as
the TO-7 is a relatively large case! the shiny devices you’ll get will have the pro-
The hairs may be ‘zapped’ using a 47 µF elec- blem too.
trolytic charged to about 50 V and connected Reportedly some audio transistors like the
between the S (shield) wire and the E, B and C AC127, AC128, AC176, AC187 and AC188 also
wires twisted together. Although this method suffer from unwanted hair growth in invisible
is good to retain the originality of your radio, places.
the fault may occur again after some time as (080473-I)
the hair growth continues.
Germanium transistors have a bias voltage of
[1] Electronic Classics, Collecting, Restauration
0.2–0.3 V, so if an OC171 or one its siblings is and Repair, Andrew Emmerson. ISBN 0-7506-
replaced by a modern silicon p-n-p RF transis- 3788-9.
tor like the BF450 or BF451 (Figure 3), resis- [2] 50 Jaar Herkennen (Recognising 50 Years).
tors may have to be changed to get 0.6–0.7 V Philips Semiconductors Nijmegen, C. van
V B-E bias levels in the circuit. Also, almost all Anrooij, F. Geersten. H. Jacobs, P. Willemsen,
silicon transistors will have a much higher G. de Wind (Editors). ISBN 90-90-17050-2.
transition frequency than the old ‘geranium
287
R
310 circuits
elektor international media bv – 089018/uk
pagina 287
Ruud van Steenis While designing the circuit for this electronic
thermostat a decision was made to increase
This circuit came about because of the dis- the control range so that it would also be suit-
satisfaction regarding the operation of the able for other applications. Potential applica-
thermostat in a refrigerator. When using the tions are the temperature control of a (living)
built-in thermostat, it turned out that it as room, heating of a flower box and obviously
necessary to reduce the temperature setting the etching tank!
in the summer in order to
keep everything cold, com-
pared to the setting in win-
ter.
288
L
310 schakelingen
elektor international media bv – 089018/nl
pagina 288
D1
IC1
1N4001 7805 +5V
K1 LCD
C1 C2
K4
10µ 10µ
63V 63V
+5V
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
R7
P1
33 Ω
10k
+5V
K2 +5V
D2
1N4001 R6 C3
K3
10k
T1
R4 100n R3 R2 R1
2k2 14
4k7
4k7
4k7
BC547 4 6
MCLR RB0
7
RB1
17 IC2 8
RA0 RB2
R5 18 9
RA1 RB3
IC3 1 10
4k7
K5 RA2 RB4
3 2 11
RA3 RB5
2 3 12
RA4 RB6
1 PIC16F628 13
RB7
MODE
4MHz
080090 - 11
The control range is adjustable from –25 °C to a high rate, which generally leads to extra
+75 °C in steps of 0.25 °C. The hysteresis is wear and tear in the compressor (cooling) or
also adjustable. Hysteresis is the temperature pump (heating).
error at which the system will turn on or off. A The hysteresis can be adjusted from 0.1 °C
very small hysteresis results in a very stable (very stable temperature) to 10 °C (practically
temperature but has as disadvantage that the no control at all...) in steps of 0.1 °C. The set-
heating or cooling system turns on and off at tings can be changed with 3 push uttons and
the information is displayed
on a 2×16 character LCD.
The settings are stored in
the EEPROM inside the PIC.
During ormal operation the
LCD is used to isplay the ac-
tual temperature.
289
R
310 circuits
elektor international media bv – 089018/uk
pagina 289
80%
80%
COMPONENTS LIST
portant role in the circuit (connected to K5). circuit makes the selection between cooling
Fortunately the DS1820 is already factory cali- (jumper 2-3 on K3) and heating (jumper 1-2
brated, so this saves us from a difficult task. A on K3) possible.
classic 7805-regulator and a common transis-
tor pretty much complete the circuit. The When the circuit is turned on, the display
clock source for the PIC is supplied by a shows ‘temperature’ with underneath that
4 MHz ceramic resonator with built-in capaci- the actual temperature in degrees Celsius. If
tors (Conrad Electronics order number the sensor is not connected then an error
726406/726507). message will be displayed. By holding down
the ‘Mode’ button until an asterisk appears,
There are two switching outputs from the the text ‘set temperature’ appears and you
PIC, one for cooling applications and another can set the desired temperature in steps with
one when heating is called for. When cooling, the + and – buttons. By pressing the Mode-
the refrigeration system obviously has to be button again it is possible to set the desired
turned on when the temperature is too high, hysteresis with the + and – buttons.
while when heating, the appropriate action A hysteresis of 1 °C means that with a tempe-
needs to be taken when the temperature rature setpoint of 20 °C and when heating,
threatens to become too low. A jumper in this the output becomes active when the tempe-
290
L
310 circuits
elektor international media bv – 089018/uk
pagina 290
rature drops below 19 °C (20–1), while every- from the Elektor website as file number
thing turns off when the temperature reaches 080090-11.zip.
21 °C (20+1). The source code is liberally commented, so
To connect the circuit to external equipment that making changes (changing the tempera-
a relay control (via K2) was chosen because of ture range, for example) is quite straightfor-
safety considerations. The transistor can eas- ward.
ily handle currents up to 100 mA and a free- The temperature is initially set to 20 °C and
wheeling diode suppresses the back-emf the hysteresis to 2 °C.
from the relay coil. The power supply voltage
can be selected based on the rated coil voltage For the sensor it is best if you use a ‘plain’
of the relay that is used, 12 V, for example. DS1820 and fit it with a length of 3-way rib-
Keep in mind that when using this circuit to bon cable. When using it with a refrigerator
replace the thermostat in a fridge, the com- this has the advantage that the sensor cable
pressor motor which is to be controlled is di- can be easily routed to the outside because
rectly connected to the mains and a safe the rubber seal on the fridge door still closes
implementation of the complete circuit is sufficiently well to seal around the cable.
therefore absolutely essential. Once the ribbon cable is connected to the
If this circuit is used to heat, for example, a DS1820, you can cover the sensor entirely
flower box, it can be useful to replace the with a thin layer of two-part epoxy glue and
switching transistor with a HEXFET. A proto- (before the glue has set) shrink a small length
type circuit with an IRFP3710, supplied a 12-V of heatshrink tubing around it. This gives a
heating element with 1.5 A without any trou- good, waterproof seal.
ble at all, while the losses where so small that Alternatively you can buy a ready-made
no heatsink was required. The 5-V output waterproof DS1820 sensor (for example Con-
voltage from the PIC was in this case suffi- rad Electronics # 184037/184052). These
cient to turn the FET on properly. have, however, a type of telephone cable that
The program in the 16F628 fills only about is somewhat thicker than the ribbon cable.
half of the available program memory space. (080090-I)
Because there was no compelling need to
program the whole thing in a particularly Downloads
‘compact’ way, the PicBasic Pro compiler was The source- and hex-code for this project,
used for generating the hex file for the PIC. 080090-11.zip, as well as the layout for the PCB
Both the source file (1820THER.BAS) as well (080090-1.zip) are available as a free download
as the hex file to be programmed into the from the Elektor website.
16F628 (1820THER.HEX) are available free
291
R
310 circuits
elektor international media bv – 089018/uk
pagina 291
+3V3...+6V R1
33m Ω
S
G T1
IC1 4
Si2323
I SENSE D L1 +3V3
5 6
VIN SW
5µH 24m Ω
2A9
TPS64202 R2 R3
DBV C3
619k
1 3
EN FB
4p7
Optional
2
C1 C4
R4
X7R 10µ D1 C2 47µ 6V3
10V 100m Ω
365k
MBRM120
050267 - 11
output voltage, the device can connect the The circuit diagram shows a classical step-
output directly to the input. down converter with an input voltage range
from 3.3 V to 6 V and an output voltage of
Using just a few external components the 3.3 V at a current of up to 2 A. The optional
TPS6420x can cover an output voltage range 33 mΩ shunt resistor provides for current li-
from 1.2 V up to the input voltage at up to 3 A, miting. The TPS64202 offers a minimum on-
as long as a suitable Pchannel MOSFET and time selectable between 1.6 ms, 0.8 ms,
Schottky diode are used. The device is an 0.4 ms and 0.2 ms and a fixed off-time of
asynchronous step-down converter which, 300 ns. A MOSFET in the supply voltage path
unlike the more widely-used PFM (pulse-fre- is switched on by the controller for as long as
quency modulation) and PWM (pulse width is necessary for the output voltage to reach
modulation) types, involves a constant on- its nominal value, or until the maximum per-
time and/or constant off-time. Conventional missible current, as determined by the shunt
controllers operate in PWM mode at medium resistor, is reached. If the current does ex-
to high loads, switching to PFM at lower loads ceed this limit the MOSFET is switched off for
in order to minimise switching losses. The 300 ns. If the nominal output voltage is
controller described here also adjusts its reached, the MOSFET is switched off and re-
switching frequency in accordance with the mains in the off state until the output voltage
load to achieve a similar effect to the once again falls below the nominal value. At
PFM/PWM controllers. very low output currents the controller there-
292
L
310 circuits
elektor international media bv – 089018/uk
pagina 292
fore operates in ‘discontinuous mode’ (DCM). type) or IRLML6402 (20 V type) from IRF can
Each switching cycle begins with the current be used instead. Both these types have a
at zero. It rises to the threshold or maximum higher on resistance, but do offer a lower
value, and then falls again back to zero. At the gate capacitance.
moment of switch-off the Schottky diode cau- An alternative for the Schottky diode
ses the residual energy in the inductor to ap- suggested is the MBRM140 (available from
pear as a quickly-decaying oscillation at the Digi-Key and Farnell), although this is in an
resonant frequency of the output filter. This SMB package rather than the Powermite
low-energy oscillation in discontinuous mode package of the MBRM120. The voltage drop
is normal and has no adverse effect on the ef- at 1 A is somewhat higher: 0.6 V instead of
ficiency of the converter. It can be damped 0.45 V. The devices are manufactured by IRF
using the (optional) RC series network. and ON Semiconductor.
At higher output currents the switch-down (050267-1)
converter operates in continuous conduction
mode (CCM). In this mode the inductor cur- Literature at www.ti.com:
rent never falls to zero. The output voltage is SOT23 Step-Down Controller,
directly proportional to the switching mark- document reference number SLVS485
space ratio in this mode. TPS6402 Evaluation Module (3.3 V, 2 A),
If the Si2323 P-channel MOSFET from Vishay- document reference number SLVU093
Siliconix is not available, the IRLML6401 (12 V
Web Link
www.flying-pig.co.uk/pagesv/logicgoat.html
293
R
310 circuits
elektor international media bv – 089018/uk
pagina 293
R8 C6
S1
27k
100n
1
2x TDSL3160
2
RA5 LD1 LD2
R7 10 a 10 a
120 Ω
1 IC3 2 10 R6 9 9
RC0 120 Ω b b
1 13 IC5 9 R5 7 7
IC2.A RA0 RC1 120 Ω c c
2 3 12 8 R4 5 5
RA1 RC2 120 Ω d d
7 R3 4 4
P1 RC3 120 Ω e e
4 6 R2 2 2
RA3 RC4 120 Ω f f
3 LM35 IC2 = LM358 5 R1 1 1
RC5 120 Ω g CC g CC
4k7 PIC16F628 3, 8 3, 8
11
R9 R10 RA2
C5 C4 3
RA4
27k
10k
1µ 1µ 14
16V 16V R12 R14
1k
1k
IC4
T1 T2
+9V LP2950 +5V
10k
100n 1µ 100n 4
16V
080418 - 11
294
L
310 circuits
elektor international media bv – 089018/uk
pagina 294
temperature sample is read every 30 s to pre- may also be run from three AA dry batteries in
vent the value displayed from changing due series with no series regulator.
to fluctuations in the temperature. An LP2950 The PIC software can be downloaded free of
is used to regulate the supply voltage to 5 V. charge from the Elektor website. The archive
This is a low dropout regulator which can file number is 080418-11.zip. The software
work down to 6 V hence juicing the battery was developed using CCS C.
for the last drop of energy. The thermometer (080418-I)
Peter Lay
295
R
310 circuits
elektor international media bv – 089018/uk
pagina 295
296
L
310 circuits
elektor international media bv – 089018/uk
pagina 296
now enjoying a well-earned retirement) put configured to operate on the same channel.
together an interesting article about novel In general this configuration cannot be
applications for radio controlled switches. changed, and so the best solution is to use
The transmitter was modified so that the button 1 on the first set to switch the remote
sockets could be switched on and off under device and button 2 on the second set to send
timer control [1]. the feedback signal.
Suddenly inspiration struck and the author
was off to the DIY shop to buy another set of The rest is obvious enough: the socket at the
radio controlled mains sockets. With a few receiver end of the second set will now indi-
more pounds invested in the project, he was cate whether the remote appliance has been
ready to start experimenting. properly powered up. One possibility would
be to use the second receiver socket to power
The idea was to use the two systems together an LED night light or similar device.
to make a remote switch suitable for ‘safety
critical’ applications. The system is armed by closing the switch
A multi-way extension lead is plugged into that shorts the pushbutton on the second
the remotely switched socket, and the appa- transmitter, and (if it has a power switch) tur-
ratus to be switched is plugged into one of ning on the mains adaptor. And amazingly,
the sockets on the extension lead. An ordina- the prototype worked first time: a press of
ry mains adaptor is plugged into another of the ‘on’ switch of the first transmitter
the sockets on the extension lead. Usually an switched on the remote socket, powered up
adaptor with a 12 V output will be required. the extension lead, and triggered the second
transmitter into sending its feedback. The
Now we turn to the second transmitter- second receiver socket duly turned on, indi-
receiver set. The transmitter has to be modi- cating that the original transmission had
fied a little by taking the contacts normally been successfully received.
used for the battery to a suitable socket so (080500-I)
that the unit can be powered from the mains
adaptor. One of the ‘on’ buttons on the trans- Web Link
mitter must also be bridged by a small switch. [1] www.elektor.com/magazines/2005/octo-
There is the possibility of a small difficulty ber/remote-control-operator.57913.lynkx
here if the two transmitter-receiver sets are
Stefan Dickel
297
R
310 circuits
elektor international media bv – 089018/uk
pagina 297
298
L
310 circuits
elektor international media bv – 089018/uk
pagina 298
The demodulation function is carried out by LED inside optocoupler IC3. The phototran-
the circuit around T2. The value of the current sistor inside the optocoupler is now also tur-
sense resistor R6 is chosen so that when con- ned on. Finally, at connector K4 the signal is
verter IC1 is in its quiescent (off) state T2 is available with a low impedance, suitable for
not switched on. When the output transistor further processing.
of the converter turns on, extra current is So that we can arrange for the circuit to ope-
drawn from the supply via R5, making the rate from a single supply we use an isolating
total current drawn considerably higher. In DC-DC converter. This not only provides the
turn, the voltage drop across R6 increases sig- 12 V needed by the sensor circuit, but also
nificantly and T2 is turned on. A large collec- offers up to 1000 V of electrical isolation.
tor current now flows through R7, R8 and the (080096-I)
Reuben Posthuma ber of the solar cells and the current pull of
the equipment connected to the output. Here
This device is designed to be a simple, in- the low-drop 4805 is suggested but other re-
expensive ‘comparator’, intended for use in a gulators may work equally well as long as you
solar cell power supply setup where a quick observe the output voltage of the solar cells.
‘too low’ or ‘just right’ voltage indicator is Transistors T1 and T2 are complementary ty-
needed. The circuit consists only of one 5-V pes i.e. one each of the pnp and npn variety.
regulator, two transistors, two LEDs, five re- Although the ubiquitous BC557B (pnp) and
sistors, two capacitors, and one small battery. BC547B (npn) are indicated, any small-signal
Although a 4-V battery is indicated, 4.5 V (3 al- equivalents out of the junk box will probably
kalines in series) or 3.6 V (3 NiCd cells in se- do. The values of voltage dividers R1/R6 and
ries) will also work. R3/R4 may need to be adjusted according to
The specifications of voltage regulator IC1 the type of transistor and its gain, or accor-
are mainly determined by the size and num- ding to the desired voltage thresholds. Using
IC1
4805
R1 R3
100 Ω
3k3
C1 C2
10µ 10µ
T1 T2
40V 25V
BC557B BC547B
Solar Cells R2 BATT1 R5
100 Ω
100 Ω
3V6 - 4V5
R6 R4
D1 D2
270 Ω
10k
GND
080453 - 11
299
R
310 circuits
elektor international media bv – 089018/uk
pagina 299
the resistor values shown in the schematic, connected across the terminals of LED D1 to
LED D2 turns on fully when the voltage is just give a more substantial warning if the voltage
above 5 volts. LED D1 turns on when the volt- drops below operating limits.
age drops below 4.2 volts or so. Between tho- The current consumption of the circuit is
se two thresholds, there is a sort of no man’s about 20 mA at 5 V, and it decreases with the
land where both LEDs are on dimly. voltage supplied by the solar cells.
A buzzer or other warning device could be (080453-I)
D1
R4 1N4001
10k
IC2
3
5 10 20 1
SIG L10
9 11 19 2
MODE L9
12 18 3
IC1 L8
13 17 4
BT1 L7
6 14 16 5
RHI L6
S1 R2 7 15 15 6
REFOUT L5 C1
16 14 7
2k2
12V LM3914 L4
17 13 8
L3 100µ
8 18 12 9 25V
REFADJ L2
4 1 11 10
RLO L1
R6 R5 R3 R1
C2
2
6k6
20k
4k7
88k
100n
300
L
310 circuits
elektor international media bv – 089018/uk
pagina 300
4k7
4k7
The Pixie Switcher from Flexipanel (www.flexi- VDD
1N4148
network to join. Security permitting, any rou- D3 RE2
ter node can then allow the new node to be- MODE VDD
T1
1N4148
Once the new node has become a member of BIND
Pixie
EP1 T2
the network, its inputs and outputs must be Switcher
301
R
310 schakelingen
elektor international media bv – 089018/nl
pagina 301
mitter will operate in sleep mode and only Routers, however, must be always-on and so
wake up when a button is pressed. are not really suited to battery powering.
The modules can run at anything between ModeA is also wired High, indicating that this
2.1 V and 3.3 V, so it can be connected di- router is in fact a coordinator. The difference
rectly to two AA batteries. The Bind input and between the two is that when a coordinator
Status LED are only used during joining and powers up, it starts a new network instead of
binding. When the pushbuttons connected to looking for an existing one to join. Every
EP1 and EP2 are pressed, messages are trans- ZigBee network has one coordinator. If fur-
mitted to the receiver. ther routers nodes were added to this net-
work, they would have to have the ModeA pin
Figure 2 is the receiver. By setting ModeB low. EP1 and EP2 on the receiver are connec-
high, it is configured as a router. This means ted to relays via MOSFET driver transistors.
it can allow battery powered sleeping devices The relay contacts can then be connected to
(such as the transmitter) to join it as a neigh- any project circuit.
bour. (060078-1)
Christian Tavernier D1
LA1
C1 R1 1N4004 R2
1k 220 Ω
If you are lucky enough to have 1µ D3 230V
a big house, a large garden, and 250V 2A max.
L
small children, this project just a
IC1 R3
302
L
310 circuits
elektor international media bv – 089018/uk
pagina 302
ringer signal is present. This voltage lights from the Conrad Electronics website (www1.
LED D3 which only serves as a visual indicator uk.conrad.com).
of proper operation as does the LED con- For the purpose of safe operation, the circuit
tained in IC1. This is a high-power photo triac is protected by a GeMOV on the mains side,
with zero crossing detection from the mains, called Varistor, VDR or SiOV depending on
which allows it to switch the load it controls the manufacturer. The model indicated here
without generating even the lowest level of is generally available. The load will be limited
noise. This component, that we might just as to 2 A, considering the model selected for
well call a solid-state relay, was selected be- IC1, which is more than sufficient for the ap-
cause it is comes in the form of a package plication planned here.
similar to a TO220, a little bigger, and equip- Finally, since a number of components in this
ped with four pins. The pinout will not cause circuit are connected directly to the mains
confusion because the symbols shown on our power supply, the assembly should be placed
diagram are engraved or printed on the pack- in a completely insulated housing for obvious
aging. Since this circuit is not yet very com- safety reasons.
mon, we need to mention that it’s available (060113-1)
J. Geene
trailer
In most countries it is now mandatory or at fog light fog light
303
R
310 circuits
elektor international media bv – 089018/uk
pagina 303
Peter Jansen
304
L
310 circuits
elektor international media bv – 089018/uk
pagina 304
10k
R1
100%
305
R
310 circuits
elektor international media bv – 089018/uk
pagina 305
COMPONENTS LIST
Resistors:
R1, R3 = 10 kΩ
R2, R4 = 560 Ω
Semiconductors:
D1 = Dual LED with 3 pins
(Conrad Electronics # 187496)
IC1, IC2 = CNY17-2
T1, T2 = BC547B
Miscellaneous:
K1 = 4-way SIL connector
Small disk drive connector for PCB mounting,
or solder pins (see text)
PCB, order code 030117-1 from the PCBShop
The circuit board has been designed to be so The supply voltage reaches the circuit via a
small that the components can be fitted in a normal small drive connector, to make it easy
few minutes and everything can be suspen- to obtain the necessary plug. Otherwise, you
ded from the LED in the PC enclosure. A drop can also use ordinary solder pins.
of hot-melt glue will prevent the circuit board (030117-1)
from becoming dislodged due to vibration.
306
L
310 circuits
elektor international media bv – 089018/uk
pagina 306
It’s not even necessary to add any circuitry This means that in most cases you can man-
around the IC. Figure 1 shows how a MAX232 age without any additional filtering of the
is typically wired in a microcontroller circuit. output voltage. In sensitive applications, such
The symmetrical voltages (at around ±9 V) as amplification of small audio or measure-
generated from the +5-V supply voltage can ment signals by one or more opamps, it’s a
be taken from pin 2 (VDD; +9 V) and pin 6 good ideal to use a small gyrator circuit for
(VEE, –9 V) of the IC. As you can see from Fig- additional suppression of the residual 50-kHz
ure 2, the no-load voltage is nearly 10 V and signal. Figure 3 is an example of such a circuit
you can draw up to 5 mA at 9 V, which is that has been proven frequently in practice.
enough for most standard opamps and plenty Of course, you can use other types of compli-
for low-power opamps. mentary small-signal silicon transistors, such
The MAX232 has two charge pumps, each of as the BC547 (NPN) and BC577 (PNP), in place
which has two external capacitors for voltage of the BC550 (NPN) and BC560 (PNP) shown
doubling. These are 10-µF electrolytic capaci- on the schematic.
tors in Figure 1, which yields a somewhat sta- Transistors in the current gain class ‘B’ (such
bler output voltage than the standard circuit as the BC547B and BC557B) are also suitable,
with 1 µF as shown in Figure 2. The charge and the values of the capacitors between the
pumps of the MAX232 are operated at an os- bases of the transistors and ground can also
cillator frequency of around 50 kHz, so the be increased (e.g. 100 µF) or decreased (e.g.
amount of ripple on the output voltage is 1 µF). The voltage drop across the gyrator cir-
quite small (typically less than 10 mV with a 2- cuit is only around 0.7 V.
mA load). (080498-1)
307
R
310 circuits
elektor international media bv – 089018/uk
pagina 307
IC1
K1 LM7805
+5V
7V...12V B1
R11
390Ω
I = 100mA max.
C3 C1 C2 C4
B80C1500 D21
470µ 100n 100n 47µ
25V 16V
D22
+5V
"1"
R2 D1 D2 D3 D4 D5 D6
220Ω
R13 R14 R16 C5
D23
"2"
4k7
4k7
10k
S1 S2 R15 D24 1k
C6 C7 4MHz C8 T6
R10
4k7
1k
10µ 15p 15p
4V7 16V
6x BC550C 020390 - 11
of minutes, tens of seconds, and units of sec- with long-term stability. As PIC16C54 does
onds. The values are read row by row from not have enough output ports to individually
top to bottom: one, two,
four, and eight – in other
words, binary. With a bit of
practice, it’s even possible
to quickly and easily read
the time in a single glance.
308
L
310 schakelingen
elektor international media bv – 089018/nl
pagina 308
70%
70%
COMPONENTS LIST
drive all of the LEDs, and doing so would also Pressing S1 takes you to the next column.
require several additional components, the This continues in the same manner until the
display is multiplexed. In order to neverthe- configuration mode is exited after the final
less make the low-current LEDs nice and column. The clock will continue to run, star-
bright, the magnitude of the current pulses is ting with the newly set value.
made significantly higher than the rated cur-
rent. We have designed a printed circuit board lay-
out for the binary clock. Fitting the compo-
Buttons S1 and S2 can be used to set the time. nents to the board couldn’t be easier,
If you press S2, you will arrive at the setting although you mustn’t overlook the set of nine
menu after a brief LED test (all LEDs on). The wire bridges. As one of them is underneath
value of the first column can now be set to the microcontroller, the latter must be fitted
any desired value using S2. with a socket.
309
R
310 circuits
elektor international media bv – 089018/uk
pagina 309
The LEDs should initially be fitted with only enclosure is quite practical, since it elimina-
one lead soldered in place, after which they tes the need to drill holes for the LEDs.
must be aligned. The remaining leads should (020390-1)
only be soldered after the LEDs are all nicely
lined up. Web Link
[1] www.mmgi.de/htdocs/mathematikum/
The board can be displayed ‘bare’ or fitted index.php?513
into a small plastic enclosure. A transparent
1M5
routes to the protective earth (PE) connecti- earth R1 0W5
ons. In this setup, mains voltage, however E 150k
small, will cause the differential circuit LA1
breaker to trip. The circuit breaker is part of C1
However, all that’s needed is an extremely If the earth connection is disconnected, the
simple system to automatically detect any current supplied by D1 and R2 charges up ca-
break in the earth connection; so simple that pacitor C1. When the voltage at the terminals
we ask ourselves why it is not already inclu- of the capacitor reaches about 60 volts, neon
ded as part of all factory production for appli- indicator light La1 is turned on and emits a
ances that carry any such risk, as we have flashing light which discharges capacitor C1
discussed above. We propose it as a project at the same time. This phenomenon is repro-
for you to build using this schematic. duced indefinitely as long as the earth con-
310
L
310 schakelingen
elektor international media bv – 089018/nl
pagina 310
nection has not been restored, and the neon obviously get rid of its series resistor which
light continues to flash to attract attention in would prevent proper operation here.
case of danger.
During installation of the circuit in the ap-
Building the project is not particularly diffi- pliance to be protected, we should also clear-
cult but, since it is a project aimed at human ly mark Live (L) and Neutral (N) (for example,
safety, we must take the maximum of precau- seek Live with a simple screwdriver) because
tions concerning the choice of components inverting these two wires at this point will
utilised. Therefore, C1 must have an opera- disable proper operation.
ting voltage of at least 160 volts while R2 The final point, which is self-evident conside-
must be a 0.5-watt resistor, not for reasons of ring the principle used here: the earth con-
power dissipation, but in order to maintain nection for our setup must be hooked up to
the voltage. The neon light can be any type, the frame of the appliance to be protected at
possibly used, or it may be part of an indica- a different point than where the normal earth
tor light to make it easier to attach to the pro- wire is connected.
tected appliance. In the second case, we must www.tavernier-c.com (060108-1)
D1 IC1
1 1N4002 7805
R3
100 Ω
R1 1 LM35CZ
C3 C5 C7
3k9
100µ 2
100n
100µ IC3
25V 25V JP1
1
5
3 R8
7
2 0 IC2.B 330 Ω T
R4 6
P1 1 K2
IC2.A 100 Ω
3
K1 250 Ω R6 R7
C1 8 C2
9...12V 1k3 4k7
IC2
AC/DC
470µ 25V 4 100n R2 R5
C6 C8 C9
820 Ω
27k
100n 1µ 100n
25V
C4 D2
311
R
310 schakelingen
elektor international media bv – 089018/nl
pagina 311
COMPONENT LIST
2a 2b
100%
100%
312
L
310 circuits
elektor international media bv – 089018/uk
pagina 312
means that the voltage at the output of IC2.B (when a DC supply is used). To avoid the need
is exactly 0 V at a temperature of –24 °C and to use rail-to-rail opamps, diode D2 is used to
5 V at +84 °C. lift the circuit ground to approximately 0.7 V
above the IC’s negative supply.
These two formulae can be used to select The sensor electronics can be built on the
component values for any desired tempera- small printed circuit board shown in Figure 2.
ture range. Calculating suitable values for the There is a single wire link, between C3 and
voltage divider formed by R1, P1 and R2 is IC2. It is worth pointing out that not only the
straightforward. Jumper JP1 allows the circuit sensor, but also all the other components,
to be calibrated: connecting the output of the must be capable of operating over the desired
offset opamp IC2.A directly to the input of temperature range. The ‘C’-suffix versions of
amplifier IC2.B simulates the condition of the sensor are specified to work from –40 °C
being at the lower extreme of the tempera- to +110 °C, while the ‘D’ versions are speci-
ture range. fied to work from 0 °C to +100 °C. The overall
accuracy of the thermometer is highly depen-
The circuit is powered from a mains adaptor dent on the precision of the components
with an output of 9 V to 12 V (either AC or used. In particular, R6 and R7 should be as
DC). Although the current consumption is close as possible to their calculated values.
only around 50 mA, a 1 A fixed voltage regula- The output voltage of the regulator is also im-
tor is used to produce a stable 5 V supply, sin- portant if it is used as the reference voltage
ce no heatsink is then required. The regulator for the A/D converter. Deviations from nomi-
directly supplies the voltage divider for IC2.A nal values will result in an expansion or a
and can also provide power for a connected compression of the overall temperature scale.
ADC circuit. The supply for the sensor is de- (030190-II)
coupled from the rest of the circuit by R3 and
C7 to reduce interference. Diode D1 operates Internet Link
either as a rectifier (when an AC supply is www.national.com/pf/LM/LM35.html
used) or as protection against reverse polarity
313
R
310 circuits
elektor international media bv – 089018/uk
pagina 313
TR2
big which will force you re- C2
BT1
it produces approximately R2 R3 R4
tery. T1
D2
314
L
310 circuits
elektor international media bv – 089018/uk
pagina 314
charged via R3, exceeds the firing threshold a protection resistor of about 10 Ω to limit
of the diac DI1 which supplies the trigger cur- the current surges, not forgetting a 1-amp
rent. fuse.
A judicious choice of values for R3 and C3 The best result will be obtained using an ad-
makes it possible to have one flash per justable constant current power supply be-
second. In order to avoid too high energy tween 0.5 and 1 A, which allows us to play
consumption, the value of C1 is adjusted to with the flash frequency. The number of
4.7 µF, even 10 µF, for nicely padded flashes flashes is obviously a function of the current
without using too much current. supplied.
It is recommended, for safety reasons, to stay
You will, no doubt, have noticed the absence below 40 volts. This corresponds to close to
of the neon miniature bulb and its resistor 40 flashlamps (and a few evenings to set them
which are no longer useful. up), but since we still have quite a few months
before the holiday season...
Last problem to solve: the power supply. We
are not going to interrupt the New Year’s Eve What remains is the ‘packaging’. Everything
party to replace used batteries. It is out of the depends on the size of the finished module.
question to power the setup from 1.5 V as the You could potentially use housing for trans-
number of flashes we are dealing with, the lucent film in which you drill two holes to force
current would be too high. It would be better thewires through and ensure an airtight seal.
to supply 1.5-V voltage to each module, the Another option is translucent heat shrink tu-
modules being mounted in series, taking care bing of the proper size. We will cut an ade-
to limit the current to approximately 500 mA. quate length of tubing, or 4 cm more than the
As illustrated in the partial diagram of Figure length of the module. The wires are coated
3, we will provide each module with a pair of with a drop of heat shrinkable glue, then the
1N4001 diodes that will produce a drop in tubing is retracted. The end is immediately
voltage between 1.3 V and 1.4 V, and that flattened using a flat clamp until totally
works out perfectly. cooled. Repeat for the other end. This should
The flashers are mounted in series on a wire make for a good airtight seal.
whose two end points are connected to a DC A purposely designed printed circuit will al-
power supply. We should account for about low you to reduce the size of the module to a
1 V per module. We can actually consider that minimum.
the majority of flashes will occur during charg- Average consumption is approximately 12
ing and will only reach the 1.4 V level a few watts for 20 flasher modules, which is per-
tenths of a second before the actual flash, the fectly reasonable and the result obtained is
average voltage being around 1 V. It’s reason- surprising, original and superb.
able to reserve 24 V for 20 flasher units, with (060161-1)
315
R
310 circuits
elektor international media bv – 089018/uk
pagina 315
The connection between the controller and For example an instruction to configure data
PC can be made using a USB port where it will transfer from the controller to the terminal
be necessary to use a USB to TTL adapter ca- emulator:
ble like the one manufactured by FTDI and
featured in the June 2008 edition of Elektor Open "COMB.3:9600,8,N,1" For
(page 48). An even simpler solution is to use Output As #1
the spare serial port (RS232) on the PC, it will
only be necessary to convert the signals from B.3: indicates that port B.3 is used which is
the TTL levels required by the controller to pin 2 of a ATtiny25 controller.
the RS232 levels used by the PC. Output indicates that data is sent from port
B.3.
A suitable circuit can be built using a MAX232 #1: File handle, used in the following Print
IC together with four capacitors. The author command.
was able to make use of a cable taken from a
redundant serial PC mouse. The 9-way D-type Data can now be sent using the normal Print
connector was fully encapsulated so it was command:
necessary to solder the IC together with the
capacitors into the cable and protect the cir- Print #1 , "Hello" ;
cuit with a length of heat-shrink sleeving. De- The variable to display
316
L
310 circuits
elektor international media bv – 089018/uk
pagina 316
#1 references the corresponding Open state- is no character waiting i.e. no key has been
ment above. pressed. For further information refer to the
It is helpful to use a simple test program just BASCOM online help pages.
to output some text. This will determine
whether the parameters defined in the Open- The screenshot shows a small test program
statement and the terminal emulator (found listing together with the program output in
under ‘Tools’ along the top of the screen or the terminal emulator window. The hex file of
invoked with ctrl + t) are correctly configu- this program is available for free download
red and also if the cable is connected to the from the Elektor website, the file number is
correct controller pin. There are different 080370-11.zip.
ways of sending variables to the controller; (080370e)
firstly it is necessary to use the Open state-
ment to configure the Input and choose a dif-
ferent file handle (e.g. #2) in the Input or
Inkey statements as in:
Paul Goossens
317
R
310 circuits
elektor international media bv – 089018/uk
pagina 317
+U B
+U B = max. +15V
D1
R4 R2 K2
D2
100k
150k
IC2.D
9 10
1
8 4
IC2.A BAT85
R JP1 1N4148
3 2 7 5 1 IC2.E max. 100mA
1 DIS D
IC1 IC2.C IC3.A 11 12
K1 C2 1
2 3 7 6 3 C 2
TR OUT 1
IC2.B
1n TLC555 R S IC2.F
5 4 6
0V 1 THR 4 6 14 15
1
CV
+U B
1 5
IC2 = 4049 R5
R1 IC1 = 4013
470k
4k7
9 13
D
1 14 T1 IC3.B T2
C3 C4 C1 R3
IC2 IC3 11 C 12
47k
8 7
100n 100n 10n R S
BC547 10 8 BC547
044030 - 11
is differentiated by C2. This has the effect that over 1.5 ms when T1 does not conduct. When
at each rising edge a negative start signal is T1 does conduct, the duration will be a little
presented to pin 2 of IC1. D1 and R4 make shorter than 1.5 ms. We will explain the pur-
sure that at the falling edge the voltage at pin pose of this a little later on.
2 of IC2 does not become too high.
Via IC2.C, the fixed-length pulse is, presented
IC1 (TLC555) is an old faithful in a CMOS ver- to the clock input of a D-flip-flop. As a conse-
sion. A standard version (such as the NE555) quence, the flip-flip will remember the state
works just as well, but this IC draws an un- of the input (servo signal). The result is that
necessarily high current, while we strive to when the servopulse is longer than the pulse
keep the current consumption as low as form the 555, output Q will be high, other-
possible in the model. wise the output will be low.
The aforementioned 555 is configured as a
one-shot. The pulse-duration depends on the It is possible, in practice, that the servo signal
combination of R2/C1. Lowering the voltage is nearly the same length as the output from
on pin 5 also affects the time. This results in the 555. A small amount of variation in the
reducing the length of the pulse. In this cir- servo signal could therefore easily cause the
cuit the pulse at the output of IC will last just output to ‘chatter’, that is, the output could
K1 C4
JP1
+
R3
0V
1-030440IC3
IC2
R5
044030-1
T1
R2
C3
C1
T2
R4
R1
IC1
C2
D1 + K2
D2
100%
100%
044030-1
318
L
310 circuits
elektor international media bv – 089018/uk
pagina 318
COMPONENTS LIST
be high at one time and low the next. To pre- pulse will now have to be longer by a reason-
vent this chatter there is feedback in the form able amount before the flipflip changes back
of R1, R3 and T1. This circuit makes sure that again. This principle is called hysteresis.
when the flip-flip has decided that the servo- Jumper JP1 lets you choose between the nor-
pulse is longer than the 555’s pulse (and sig- mal or inverted output signals. Buffers IC2.D
nals this by making output Q high), the pulse through to IC2.F together with R5 drive out-
duration from the 555 is made a little shorter. put transistor T2, which in turn drives the
The length of the servo-signal will now have output. Note that the load may draw a maxi-
to be reduced by a reasonable amount before mum current of 100 mA. Diode D2 has been
the servo-pulse becomes shorter than the added so that inductive loads can be switched
555’s pulse. The moment this happens, T1 as well (for example, electrically operated
will stop conducting and the mono-stable pneumatic valves).
time will become a little longer. The servo- (044030-1)
319
R
310 circuits
elektor international media bv – 089018/uk
pagina 319
termine the state of charge of the battery. Charge it fully and then connect the load, for
Note that the figure shows three graphs each instance, the five 100 Ω resistors. Measure
relating to a given load. This means that the the output voltage every five minutes and
output voltage must be measured under load enter the results on an Excel sheet to give a
conditions to obtain a satisfactory result. Mo- nice curve. If the 5-minute intervals are not
reover, the value of the load must be known. exact, enter the real times and choose
Also, the battery must be under load for at ‘spread’ as curve. Only this type of sheet can
least a minute. cope with irregular measurement intervals.
Moreover, Excel is able to transpose the time
There are two ways to proceed. If the load is on the horizontal (x-) axis into charge.
known and constant as, for instance, in a Calculate the current during an interval by di-
pocket torch, measure the voltage and read viding the mean voltage (start voltage plus
the corresponding charge from the graph. If final voltage divided by 2) by the resistance.
there is no load, or it is not known or variable, The charge is the current thus computed
apply a temporary load in the form of a resis- times the elapsed time. The graph shown ap-
tor. If the value of this is 20 Ω, for instance, plies to a battery of 900 mAh. A current of
use the upper graph (0.2 C, 180 mA). If a 0.2 C is then 0.2 × 900 = 180 mA; 1 C is
single resistor is used, this will get quite hot, 900 mA; 2 C is 2 × 900 = 1.8 A.
because it has to dissipate 0.66 W, whereas
most standard resistors are only rated at The proposed method is not suitable for NiCd
0.25 W to 0.33 W. It is therefore wise to use a or NiMH batteries, but it is for lead-acid batte-
number of resistors in parallel, for example, ries, provided that the temperature is con-
five of 100 Ω each. stant. Bear in mind that an old lead-acid
battery has a slightly different graph from a
To obtain more exact measurements, first new one.
draw the graph of your particular battery. (064017-1)
320
L
310 circuits
elektor international media bv – 089018/uk
pagina 320
but when T1 turns on it diverts the base cur- Darlington transistor T4 now conducts as its
rent away from T2, which therefore remains base is pulled high via R4. T4 now provides
turned off. This situation is stable: the base of the trigger current for the triac via current li-
T3 is not pulled down and so this transistor miting resistor R10, and the second lamp
conducts. lights.
To turn the second lamp on, switch S1 is ope- T5 and T6 together form a zero-crossing de-
ned and then, within a second or so, closed tector. It ensures that the triac is never trigge-
again. The effect of this action on the flip-flop red at a moment when the AC mains supply is
is as follows. at a high voltage point in its cycle. This avoids
When the switch is opened the voltage across a rapid inrush current into La2, which would
C1 falls more rapidly than the voltage across give rise to considerable radio interference.
C2. The main reason for this is resistor R3, Also, trigger current is only required for the
which is directly responsible for the discharge triac for a small fraction of the period of one
of C1; C2 can only discharge through the rela- cycle of the mains supply. If this current were
tively high resistance of R5, since the other drawn continuously from the low voltage
path is blocked by diode D2. This means that supply, C1 would rapidly discharge; R1 and R2
T2 is driven via R5 for one or two seconds would have to be considerably reduced in re-
longer than T1 is driven via R7 and R9. If du- sistance, which would increase the heat dissi-
ring this time the supply voltage reappears, it pation of the module, perhaps making it
can no longer drive the base of T1 via R7 as T2 infeasible to build the circuit into a plastic
is conducting all the current to ground. This ceiling rose.
situation is also stable, as C2 is recharged via
D2 and R6. Using the component values shown the triac
When T2 conducts it pulls the base of T3 to is only driven when the instantaneous mains
ground, so that this latter transistor turns off. voltage is less than about 15 V in magnitude.
321
R
310 circuits
elektor international media bv – 089018/uk
pagina 321
The voltage divider formed by R11, R12 and resistors wired in series to ensure that the
R13 switches on the transistors T5 and T6 maximum voltage specifications of ordinary
when the voltage is greater than +15V or less 0.25 W components are not exceeded. This
than –15 V respectively. The collectors of applies to R1 and R2, as well as R11 and R12.
these transistors, which are connected to-
gether, pull the base of T4 down to ground or The whole circuit is at mains potentials and
to a slightly negative voltage when the mains great care must be taken to observe all rele-
cycle is outside the desired phase window. vant safety precautions in construction and
Any resistors across which mains voltages will installation.
be dropped are formed from two individual (070466-I)
220 Ω
220 Ω
220 Ω
says...’ sequence following 10µ
100 Ω
100 Ω
100 Ω
322
L
310 circuits
elektor international media bv – 089018/uk
pagina 322
The software was coded in AVR assembler The game runs from a 9-volt PP3 type battery
using the freeware Atmel AVR Studio4. It is The low quiescent current of less than 8 µA is
available free of charge from the Publishers’ due to the use of a micropower regulator type
website as file number 050391-11.zip. Care- LM2936Z-5 and extensive power saving fea-
ful use of modular programming allows for tures on the ATtiny13 (the micro draws less
easy changing of music generated during the than 1 µA!).
game (stored in EEPROM) and other features.
An 8-stage maximal length pseudo-random Construction is very simple and the parts are
number generator (in software) is used to inexpensive and easily obtained. The compo-
produce a varied and easily checked light se- nent count is so small that construction of the
quence. circuit on a piece of Veroboard is a perfectly
Feedback taps can be altered in software to acceptable option.
produce a different sequence. Each starting
point for a sequence is saved in EEPROM, so if The photograph shows an experimental con-
power is lost, a new starting point is automa- struction of the game is an ABS box. The
tically selected upon power-up. Dynamic I/O small, hand-held construction allows easy
switching is used to reduce pin-count – the operation for those with small fingers!
LEDs and pushbuttons are conected to the (050391-1)
same pins on the ATTiny13!
Karel Walraven
RL
switched on or not. D1 D2 D3 D4 D5 D6
323
R
310 circuits
elektor international media bv – 089018/uk
pagina 323
044029-1
C1 C3
H1
K1
D4
D6
D1
1-920440 D7 044029-1
D2
D3
D5
H2
C2 C4
100%
100%
It would be better to insert COMPONENTS LIST
two anti-parallel diodes in
the power lead. Unfortuna- Capacitors: Miscellaneous:
tely, the voltage drop is too C1-C4 = 220 µF 6.3V K1 = 2-way PCB terminal block,
low to power an LED. It lead pitch 5mm
does work with 6 diodes, Semiconductors: PCB, order code 044029
D1, D2 = 1N5401 from The PCBShop
for that matter, but the D3-D6 = BAT85
power loss is then also 3 (or any other Schottky diode)
times greater. D7 = LED, low current
324
L
310 circuits
elektor international media bv – 089018/uk
pagina 324
Uwe Reiser
1 R1
C1 C2
10k
100n 10µ
R2 D1
K1 16V 220 Ω +5
1 20 R3 D2
220 Ω +4
MCLR
R4 D3
T
7
RA5 220 Ω +3
6 18 R5 D4
RA4 RC7
17
220 Ω +2
JP2 RC6
R6 D5
S1
IC1 RC5
16 220 Ω +1
1 28 15
8 RB7 RC4
D6
2 27 14
5 4 RB6 RC3
R7
3 26 13 220 Ω
2 RB5 RC2
4 25 12 R8
0
1 RB4 RC1 220 Ω
11
RC0
PIC16F873 5
S2 RA3
1 24 4 R9 D7
8 RB3 RA2
2 23 3
220 Ω -1
5 4 RB2 RA1
R10 D8
2
3 22
RB1 RA0
2 220 Ω -2
4 21 R11 D9
1 RB0 220 Ω -3
OSC1 OSC2 R12 D10
8 9 10 19
220 Ω -4
X1
R13 D11
8MHz 220 Ω -5
030190 - 1 - 11
325
R
310 circuits
elektor international media bv – 089018/uk
pagina 325
R13
R12
R11
R10
S1 S2
R9
R8
R2
R3
R4
R5
R6
R7
will light green. If the tem-
ROTKELE )C(
perature deviates from this
JP2
value, the LED will light IC1 C2
yellow. LEDs D1 to D5 K1
R1
indicate positive deviations 1-091030
030190-1 X1 C1
and LEDs D7 to D11 indicate 100%
negative deviations in steps
of one degree.
2b
If the overall measurement
range is from –24 °C to +84 °C
we can therefore set the
centre point between –19 °C
and +79 °C.
Half-degree steps are indi-
(C) ELEKTOR
cated by two neighbouring
LEDs lighting simultaneous-
ly. For example, between
19.75 °C and 20.25 °C just 030190-1
326
L
310 circuits
elektor international media bv – 089018/uk
pagina 326
1N4148
In the first version (Figure 7
327
R
310 circuits
elektor international media bv – 089018/uk
pagina 327
270Ω
100Ω
IC1.A IC1.B
a
strips of tinplate (which can 1
1
2 3
1
4
IC1 = 74HC14
As in the first version, the 030187 - 12
328
L
310 circuits
elektor international media bv – 089018/uk
pagina 328
K1
IC3
7812
B1
R1 R2 P1 P2
14 14 10...16V
IC1 IC2 C11 C10 C12
10k...100k 10k...100k 1M 1M
7 7 B80C1500
4µ7 100n 470µ
R5 R6 R8 R7 R9 16V 35V
IC1.C IC1.B
47k
47k
27k
1M5
27k
8 9 5 6
D1
DIS
IC2.A
10n 10n 2 5 12V
THR OUT
NC
IC1.D 400Ω
13 C3 10
11 6 4x
& TR R
NO
12 13
CNTR DIS 1N4148
10n
3 IC2.B D3
12 9
THR OUT
IC1.A
2 C4
3 8
1 & TR K3
CNTR D4 RE2
10n
COM
11
T1 T2
R3 R4
C6 C7 C8 C5 C9 12V
NC
100k
100k
400Ω
100µ 100n 100n 100µ 100n
16V 16V
NO
2x
BPW40
030333 - 11
329
R
310 circuits
elektor international media bv – 089018/uk
pagina 329
100%
100%
elled past T1. When that happens, the pin 4 only one of these two pulses can proceed
output goes High again, but the pin 10 output further to act as a trigger signal for the subse-
toggles Low. When the vehicle has finally pas- quent timer stage.
sed both phototransistors, pin 10 also goes
back to the High level. The flip-flop is then The two identically configured timers of the
restored to its original state. 556 dual timer IC function as monostable
For this behaviour to take occur, photo- multivibrators, and thus act as pulse
transistors T1 and T2 must be arranged such stretchers. Each of them drives an output
that when a vehicle passes by, at first only one relay with switchover contacts. The time con-
of them is blocked, them both, and finally stants of the monostables can be varied over
only the other one. This means that the dis- the range of 3–170 s using the adjustment
tance between the phototransistors must al- networks P1/R8/C6 and P2/R9/C5, indepen-
ways be less than the length of the vehicle. dent of the supply voltage. RC network R7/C8
ensures that the two timers are in the quies-
When an output level changes, a pulse with a cent state (outputs Low) after power is
duration of around 10 ms appears at the input switched on.
of gate IC1b (pin 12) or IC1a (pin 1). The time Freewheeling diodes D2 and D4 are essential
constants are determined by the timing net- with inductive loads; they bypass the counter-
works (R3/C1 and R4/C2). As a High level (ge- EMFs generated by the relay coils. D1 and D3
nerated by the obscured phototransistor) is keep the voltage across the freewheeling dio-
required on the other gate input (pin 13 or 2) des away from the timer outputs. If you want
to allow the pulse to pass through the gate, to have a visual operation indicator, D1 and
330
L
310 circuits
elektor international media bv – 089018/uk
pagina 330
COMPONENTS LIST
D3 can be replaced by red LEDs with a voltage Small incandescent lamps (16 V, 1 W), which
drop of 1.6–2.0 V. As the circuit dissipates a naturally also emit IR light, are suitable as
fair amount of power, a small heat sink is re- light sources. If a visible light source is unde-
commended for the fixed voltage regulator sirable, the lamps can be almost completely
(IC3), to keep it from overheating. ‘camouflaged’ using infrared filters. The other
We have designed a circuit board layout for option is to invest in IR diodes: high-power
this circuit, which can be fitted with compo- types such as the SFH485 (100 mA max,
nents fairly quickly. Don’t overlook the (sing- 950 nm) allow barrier widths of more than 10
le) wire bridge between C6 and R5, and cm without any lenses. With suitable reflec-
ensure that the electrolytic capacitors, tors (with or without lenses), the range can be
diodes, transistors and ICs are fitted the right significantly increased. A value of 180 Ω / 1 W
way around. The ICs can be fitted in sockets if is recommend for the series resistor.
you wish.
This bidirectional light barrier is suitable for a
As the circuit board is relatively large, it pro- variety of tasks. For instance, one relay out-
bably should be mounted ‘under the floor’. In put can serve as a layover switch in one direc-
that case, the phototransistors will have to be tion, while a train travelling in the other
fitted off the board. The leads from the direction can cause a turnout or points to be
phototransistors to the circuit board should actuated. A voice recorder prepared with
be screened and certainly not be longer than whistle or bell signals can also be triggered by
around 10 cm. one of the relays. Flashing warning lights can
The values of the two collector resistors (R1 also be driven, or the relays can act as an
and R2) for phototransistors T1 and T2 can be automated ‘signalman’ for barrier gates.
varied over a wide range (10 kΩ to 100 kΩ) in Naturally, this light barrier circuit can also be
order to match the sensitivity to specific con- used for all sorts of counting tasks or as an
ditions. However, increasing the resistance alarm generator in domestic situations, if the
not only increases the response sensitivity nature of the object to be detected makes
and thus the range, it also increases the sus- this possible. If only relatively short pulses
ceptibility to interference from stray light (on the order of a tenth of a second) are
(which is any how rather high). If you have to needed, for instance to drive a counter, the
deal with bright stray light (direct sunlight or RC networks that determine the timer values
fluorescent lamps in the immediate vicinity), must be correspondingly modified. Photo-
you should fit the transistors with lengths of resistors in miniature packages can be placed
small-diameter plastic tubing blackened on so close together that entomologists could
the inside and/or IR filters with maximum sen- even use the circuit to count exactly how
sitivity in the invisible spectral range of many bees or bumblebees fly in or out.
800–900 mm. (030333-1)
331
R
310 circuits
elektor international media bv – 089018/uk
pagina 331
Gerhard Nöcker +U B
270Ω
25k 25k 10 4
10k
obstacles, can be built with- M
VSTAB INHA
5 12
VREF INHB
out using a microcontroller, LDR1 IC1 M RIGHT
programmer or PC. The only RIGHT
6
V6 A
2
Au
of a window comparator).
LEFT BC338
1
R2
10k
IC2 M
tor TCA965 compares the
1
C1 P3
2
mid-point voltage with an 3 330n
250Ω M LEFT
332
L
310 circuits
elektor international media bv – 089018/uk
pagina 332
stacle is detected, the output (pin 2) goes Low rechargeable batteries in series and used
and blocks transistor T2. This causes the BC388 transistors as drivers for Lego micro-
motor to stop, and the vehicle will rotate motors. You can build the robot entirely ac-
about the stationary wheel until the obstacle cording to what you have in your parts box.
is no longer in its path. The sensitivity of the The mechanical elements can also be freely
IS471 can be set using P3. As its range is only selected, but they partially determine the be-
around 10–15 cm, the vehicle must not travel haviour and operation of the robot. The aut-
too quickly, since otherwise it will not be able hor’s robot is made from a Lego chassis with a
to avoid obstacles in time. prototyping board holding the circuitry at-
tached using elastic bands. The motors are
This part of the circuit is also open for experi- fitted on the left-hand and right-hand sides.
mentation. If a relatively large and fast robot The third wheel at the front can turn freely.
requires an obstacle detector (or isn’t fitted
with the IS471), an ultrasonic detector can One problem must be mentioned: if an ob-
also be used. Suitable complete construction stacle is detected while an incorrect lighting
kits are available from Conrad, for example. relationship is present, the vehicle remains
You can also fit a suitable mechanical push- standing. In this case, a bit of logic could be
button switch mounted on a flexible rod. The added to cause both motors to rotate in re-
obstacle detector can also drive a warning verse. However, that would require direc-
buzzer or a lamp; the circuit leaves lots of tional switches for the motors or motor
room for your own ideas. driver ICs (L293D). The simple circuit would
The circuit works over a wide range of supply become more complicated and larger, and at
voltages from 4.5 to 16 V. If larger motors are some point you would end up using a micro-
used, transistors with increased power- controller after all – but that’s just the point
handling capacity and heavier batteries are of the story.
necessary. The author connected two 4.8-V (030090-1)
P.C. Hogenkamp
333
R
310 circuits
elektor international media bv – 089018/uk
pagina 333
been set with R4 to about 3 µA. This is suffi- than the nominal 5-V power supply voltage
cient to power IC1 and the oscillator circuit (IC1 is after all powered from a current source
around X1. The oscillator generates, with the with very low current). That is why the signal
aid of a cheap watch crystal and a few sur- on pin 3 of IC1 is amplified and inverted by
rounding parts, a signal that is subsequently T1.
applied to the divider in the 4060 and results IC3a finally turns it into a proper square wave
in a frequency of 2 Hz at pin 3 (output Q13). with acceptably steep edges.
The level of the output pulses is a lot lower (030172-1)
1k2
1V2
334
L
310 circuits
elektor international media bv – 089018/uk
pagina 334
Roman Mittermayr
Elbert Jan van Veldhuizen enough capacity left to power, for example, a
real-time clock (RTC) for many months in the
After two to three years of active use most event of a power outage. What’s more, the
mobile phone batteries will have lost a lot of battery is ‘surplus to requirements’ and there-
their original capacity, and are best replaced. fore free. Normally, a good amount of electro-
However, such a discarded battery may have nics is needed to charge Li-Ion batteries in a
335
R
310 circuits
elektor international media bv – 089018/uk
pagina 335
100 Ω
that may lead to explosion. The figure shows
a simple circuit for slow charging while pre- D1
venting any risk of overloading the battery.
The circuit consists of just four components. 3x
The battery is charged to about a quarter of 1N4148
its capacity in one day, to 50% in one week D2 D3
336
L
310 circuits
elektor international media bv – 089018/uk
pagina 336
337
R
310 circuits
elektor international media bv – 089018/uk
pagina 337
P. Goossens
338
L
310 circuits
elektor international media bv – 089018/uk
pagina 338
+5V
R1 P1 R2 R3
S1
330Ω C3 C5
10k
1M
R6
100n 100n 1 1 2
330Ω
IC3.A
10k 16 R7
3 1 4
4 330Ω
3 RO IC3.B LD1 3
RB 8
IC2 10 R8 7 CA CA
a 5 1 6 a
1 12 330Ω 6
4 8 CLK b IC3.C b
13 4
R c R9 c
7 15 9 9 1 8 2
DIS RESET d 330Ω d
R4 IC1 11 IC3.D 1
4033 e e
2 3 6 R10 9
56Ω
TR OUT f 11 1 10 f
555 2
CI g
7
IC3.E
330Ω 10
g dp
T2 6 14
THR LT 5 R11
CO 13 1 12 HD1131O 5
CV 330Ω
IC3.F
5 1 8 R13
BC R12
547
5k6
T1 330Ω
D1 R5 T3
C1 C2
100k
LD271 BPW 1µ 10n
40 16V BC547
+5V
IC4
7805 +5V BZ1 +5V
K1
>8V
C4 14
C7 C6
T4 IC3 IC3 = 74HC04
100n 7
100n 100n
BC547
020041 - 11
The heart of the circuit consists of – you edge will be applied to the clock input of IC2,
guessed it – a light gate! Diode D1 is an IR diode causing the counter in IC2 to be incremented
that normally illuminates IR transistor T1. The by 1. IC2 is conveniently equipped with an in-
light falling on T1 causes it to conduct to a ternal binary-to-BCD decoder, so its outputs
certain extent. The resulting voltage on the only have to be buffered by IC3 and T3 to al-
collector of T1 should be just low enough to low the state of the counter to be shown on
prevent the following transistor (T2) from the 7-segment display. Switch S1 can be used
conducting. This voltage can be adjusted to reset the counter to zero.
within certain limits using P1. If a one-second interval does not suit your
As soon as an object comes between D1 and wishes, you can modify the values of R3 or C1
T1, the light shining on T1 will be partially or to adjust the time. Increasing the value of R3
fully blocked, causing the IR transistor to con- lengthens the interval, and decreasing it nat-
duct less current. As a result, the voltage on urally shortens the interval. The same is true
its collector will increase, producing a brief of C1.
rise in the voltage on the base of T2. This will
cause T2 to conduct and generate a negative When building the circuit, make sure that T1
edge at IC1. This negative edge will trigger is well illuminated by the light from D1, while
the monostable multivibrator, which will at the same time ensuring that T1 ‘sees’ as
then hold the output signal on pin 3 ‘high’ for little ambient light as possible. This can best
a certain length of time (in this case, one sec- be done by fitting T1 in a small tube that is
ond). precisely aimed toward D1. The longer the
At this point, two things will occur. First, a tube, the less ambient light will reach T1.
buzzer will be energised by the output of IC1 The sensitivity of the circuit can be adjusted
and produce a tone for approximately one using P1.
second. When the buzzer stops, a negative (020041-1)
339
R
310 circuits
elektor international media bv – 089018/uk
pagina 339
David Gustafik
+5V
One of the traditional ‘disciplines’ in which
robots are supposed to compete is the Line R3 R2 R1
1k
10k
100k
predrawn black line (usually duct tape) on a P1
white-ish surface (usually paper, cardboard or
plastic). 5 3
10k 2
IC1
This discipline requires special sensors. 4
340
L
310 circuits
elektor international media bv – 089018/uk
pagina 340
puts. R3 determines the current going to the apply largely to the optosensor, but note that
IRLED. many different pinouts exist so check out that
Many comparators can be used, the LM339N datasheet.
just happened to be available. The same may (070230-I)
Stefan Brandstetter
and T2/T4. Transistors T5 and T6 together
This simple circuit drives DC motors with a with resistors R7 and R8 provide the current
maximum current of 1 A and can be built with sense and limiting mechanism. The maximum
readily available components. The output output current limit can be changed from 1 A
voltage is adjustable between 0 and 14 V and by using different value resistors for R7 and
the polarity can be changed so that not only R8:
motor speed but also rotation direction can 0.6 V
be adjusted by turning a knob. The circuit is I OUT =
also ideal as a controller for a DC model rail- R
way or small low-voltage hobby tool. where R gives the value for R7 and R8.
Power for the circuit is supplied by a 18 V For increased current limit the mains trans-
mains transformer rated at 1.5 A. Diodes former and diodes will need to be changed to
D1to D4 rectify the supply and capacitor C1 cope with the extra current as well as the four
provides smoothing to give a DC output volt- transistors used in the bridge configuration.
age of around 24 V. A classic ‘H’ bridge con- Motor speed control and direction is control-
figuration is made up with transistors T1/T3 led by a twin-ganged linear pot (P1). The two
TR1
R1 T1 T2 R3
150 Ω
150 Ω
D1 D2
R9
230V 1k
C2
D4 D3
1µ
18V 4x 1N5401
1A5
P1.A R7 R8 P1.B
C1
0Ω47
0Ω47
BC327 1W 1W BC327
1000µ 40V T5 T6
2k2 D5 R5 R6 D6 2k2
150 Ω 150 Ω
R2 T3 T4 R4
150 Ω
150 Ω
BAT42 BAT42
341
R
310 circuits
elektor international media bv – 089018/uk
pagina 341
tracks of P1 together with R1/R2 and R3/R4 motor is stationary. As the pot is rotated the
form two adjustable potential divider net- potential difference across the motor in-
works. Wiring to the track ends are reversed creases and it runs faster. The voltage drop
so that as the pot is turned the output voltage across D5 and D6 is equal to the forward volt-
of one potential divider increases while the age drop VBE of the bridge transistors and en-
other decreases and vice versa. In the midway sures that the motor does not oscillate in the
position both dividers are at the same voltage off position with the pot at its mid point.
so there is no potential difference and the (070104-I)
Richard Hoptroff
342
L
310 circuits
elektor international media bv – 089018/uk
pagina 342
1 GND GND 7
PTN78060
UO
UI VI VO VO VO
2 6
INH ADJ SNS
3 4 5
INH UO Sense
C1 R SET C2
RL
0W05 100µ
1%
070115 - 11
343
R
310 circuits
elektor international media bv – 089018/uk
pagina 343
Table
VO (V) RSET (kΩ) V O (V) V I-range (V)
Device
(desired) (standard value) (actual value)
2,5 Open 2,5 7...25
3,3 78,7 3,306 7...33
PTN780x0W
5,0 21,0 4,996 7...36
12,0 0,732 12,002 14,5...36
12,0 383 12,000 15...36
15,8 15,0 14,994 18...36
PTN780x0H
18,0 4,42 18,023 21...36
22,0 95,3 21,998 26...36
1 For PTN78060W devices supplying output rent is continuously supplied to the load until
voltages lower than 10 V, the minimum in- the fault is removed. Once it is removed, the
put voltage is (V O+2 V) or 7 V, whichever output voltage promptly recovers. When limi-
is higher. ting output current, the regulator experien-
ces higher power dissipation, which increases
2 For PTN78060Ws supplying output volt- its temperature. If the temperature increase
ages of 10 V and higher, the minimum in- is excessive, the module overtemperature
put voltage is (V O+2.5 V). protection begins to periodically turn the
output voltage off.
3 The maximum input voltage for
PTN78060W is 10⋅VO or 36 V, whichever The inhibit feature can be used wherever
is less. there is a requirement for the output voltage
to be turned off. The power module switches
4 For PTN78060H output voltages lower off the output voltage when the Inhibit control
than 19 V, the minimum input voltage is (pin 3) is pulled to ground, for example, by a
(VO +3 V) or 15 V, whichever is higher. switching FET.
5 For PTN78060H output voltages equal to Finally, good attention should be paid to the
19 V and higher, the minimum input volt- quality of the capacitors on VI and V O as they
age is (V O+4 V). determine the regulator stability and overall
performance to a substantial degree. Summar-
As an example, the Table gives the operating izing the extensive information on capacitor
input voltage range for some commonly used selection found in the datasheets, the mini-
output bus voltages. mum requirement for C1 is 2.2 µF (!) worth of
ceramic capacitors for the –W device and
The modules are protected against load faults 14.1 µF (!) for the-H device. Tantalum caps are
with a continuous current limit characteristic. not recommended.
Under a load-fault condition, the output cur-
rent increases to the current limit threshold. Similarly, at the regulator output, C2 should
Attempting to draw current that exceeds the be at least 100 µF worth of low-ESR electro-
current limit threshold causes the module to lytics.
progressively reduce its output voltage. Cur- (070115-I)
Datasheets
http://focus.ti.com/docs/prod/folders/print/ptn78060h.html
http://focus.ti.com/docs/prod/folders/print/ptn78060w.html
http://focus.ti.com/docs/prod/folders/print/ptn78060a.html
344
L
310 circuits
elektor international media bv – 089018/uk
pagina 344
47k
10k
10k
M M
R1
2k2
ition, giving the name ‘anti- 8
alone robot?
3 = GND 4µ7
4 = GLout 16V
345
R
310 circuits
elektor international media bv – 089018/uk
pagina 345
G. van Zeijts created this capability, mainly for his own use
but also made it available to others who may
Over the years various articles have appeared be interested.
in Elektor Electronics about microcontrollers The functionality has been designed in such a
that pick up the pulses from an IR remote way that it can optionally be used with either
control and do something with it. a Philips (RC5) or Sony remote control.
Unfortunately this capability was not avail- The system provides a 7-bit code at an output
able for the R8C microcontroller until now. port, to ‘inform’ a computer or other micro-
That is why the author plunged right in and controller which button has been pressed.
346
L
310 circuits
elektor international media bv – 089018/uk
pagina 346
+5V
+5V
10k
1k
1k
T1 JP1
2k2
8x 1k 2
BC638
3
green red
1
TSOP1736
070191 - 11
The 8 bits of the other output port can be the button is pressed for the first time the
controlled directly with the buttons 2 output goes high. The next press makes
through 9 of the remote control. This allows 8 the output low. These eight buttons can
digital devices to be directly switched or con- therefore control eight digital things from
trolled remotely. a distance. The state of all the bits on port
P1 are not affected by pressing any of the
The program has been written in C using the other buttons on the remote control, with
HEW software and has the following func- exception of the following three.
tions. Button ‘1’ makes all eight bits of P1 high.
Button ‘0’ and button ‘off’ make all eight
Depending on the position of jumper JP1, pul- bits of P1 low.
ses from Philips (RC5) are decoded (open) or Eight LEDs indicate the present state of
pulses from Sony (jumper in place). the eight bits – they load port P1 with
about 3 mA. Via connector K2, P1 can
1 Bit 7 of port P0 indicates whether RC5 or therefore be loaded for ‘heavier’ purposes
Sony pulses are being used. Bit 7 ‘High’ = with a further 17 mA at the very most (but
RC5 and bit 7 ‘Low’ = Sony. allow a margin just to be safe, so 15 mA
max, for example).
2 The code for the most recent button that
was pressed is on port P0. Bits 0 through 4 If RC5 is selected with JP1 (open) and the
to 6 are used for this. Bit 7 is used to indi- microcontroller receives pulses from a
cate RC5 or Sony. ‘non-RC5’ remote control (or the other
way around) a short alarm signal results:
3 The eight bits on port P1 (output) are di-
rectly driven high or low with buttons 2 à The red LED on P3.0 flashes briefly;
through 9 of the remote control. When à The outputs 0 to 6 of port P0 become
347
R
310 circuits
elektor international media bv – 089018/uk
pagina 347
Jonathan Hare
1
Here we couple LED oscilla- +9V
to your robot. 7
R S1
DIS
IC1 R1
As seen in the circuit dia- 2
TR OUT
3
220 Ω OSC(n)
gram in Figure 1, instead of 6
555
CV
555, the timing capacitor 5 1
348
L
310 circuits
elektor international media bv – 089018/uk
pagina 348
349
R
310 circuits
elektor international media bv – 089018/uk
pagina 349
270Ω
10k
22k
10k
part of the light emitted by 10n 47µ
the LED back onto the pho- 16V
10k
22k
10k
easily detected than a white
wall! +U
350
L
310 circuits
elektor international media bv – 089018/uk
pagina 350
when a sufficiently reflective and/or close ob- fact – from trying out other types, or even ma-
stacle reflects the light emitted by the diode king your own sensor using separate IR LEDs
back onto the phototransistor, this level and phototransistors of your own choice.
drops.
This information is shaped by comparator The cheapest sensor is the CNY70 (around
IC2A, whose switching threshold can be ad- £ 1). It only detects at very short distances, of
justed using P1. In this way, the circuit can be the order of 5 mm, and is easily dazzled by
adapted to different sensors and the detec- ambient light. At approximately four times
tion range can be adjusted to some extent. the price, we found the HOA709-001 from
The circuit output is TTL-compatible if it is Honeywell, available from Radiospares,
powered from 5 V and, given the way IC2A’s amongst others. It too can only detect up to
inputs are connected, it is logic high in the around 5 mm, but with significantly better ef-
presence of an obstacle. ficiency than the CNY70, and it proves harder
Construction is perfectly straightforward, but to dazzle. Lastly, if you double the stakes
the effectiveness of the circuit depends on again (i.e. eight times the price of the CNY70),
the correct choice of sensors. We suggest you can use the HOA1180-003, still from
three types that we’ve tried out, in a price Honeywell, very hard to dazzle and which de-
range from around £ 1 to £ 8, but there’s tects up to a distance of 15 mm.
nothing stopping you – quite the contrary, in (070300-I)
351
R
310 circuits
elektor international media bv – 089018/uk
pagina 351
+5V IC3
1
+5V 78L05
50mA max C2 C1 C3 C4
D8
IC1.A BD679
T4
1 R1
DIR 3 4
2 =1 2k2
IC1.C 6 R 1
5 J D1
4 3 IC2.A
6 =1 C
5 2
K R2 D2
S
2k2
7
D7
T3
+5V BD679
L2 L1
STEP +U motor
14 16
IC1 = 4070
IC1 IC2 M1 M
IC2 = 4027
7 8
L3 L4
D1...D8 = 1N4004
D6
BD679
T2
R3
9
2k2
10 R 15
9 J D3
10 13 IC2.B
8 =1 C
IC1.B 11 14
12 K R4 D4
11 IC1.D S
13 =1 2k2
12
D5
T1
BD679
070299 - 11
So the circuit of our driver without special- Remember that an exclusive-OR gate can be
ized ICs, shown in Figure 1, is very simple, regarded as a gate that inverts or not the sig-
since its ‘intelligence’ is in fact confined to nal from one of its inputs depending on the
two logic ICs, IC1 and IC2, which are simple state of its other input. This is easy to see
exclusive-OR (XOR) gates and a dual J-K flip- from the truth table in Figure 2. If input A is
flop, while the power stage is built around ‘0’, the output is the same as the signal ap-
perfectly ordinary general-purpose bipolar plied to input B (0 gives 0 and 1 gives 1). How-
transistors. ever, if input A is ‘1’, the signal applied to
The pulses to make the motor turn must be
applied to the STEP input. Each pulse makes Table
the motor turn through a single step in one Step number 1 2 3 4
direction or the other; this direction is deter- Winding 1 1 1 0 0
mined of course by the state of the DIR input. Winding 2 0 0 1 1
This acts on exclusive-OR gates IC1a and Winding 3 1 0 0 1
IC1d, used here as programmable invertors. Winding 4 0 1 1 0
352
L
310 circuits
elektor international media bv – 089018/uk
pagina 352
EXOR
tors used, it is possible to switch currents of
JK FLIP-FLOP
up to 3 A, allowing plenty of flexibility in the
CLK J K Qn Qn + 1 A B S
choice of stepper motor.
1 x 0 1 0 0 0
0 1 1
The logic side of the circuit is powered from a
X 0 1 1
1 0 1
0 X 0 0
X 1 1 0
1 1 0 fixed 5 V supply, stabilized by IC3, making the
1 1 Qo Qo
STEP and DIR inputs TTL-compatible. This
X X X Qn supply may also be used to power the circuit
070299 - 12
prior to this driver, as long as you don’t ex-
ceed around 50 mA with the regulator cho-
input B appears inverted at the output (0 sen.
gives 1 and 1 gives 0). Nothing very new
there, but we did want to underline this inter- If your motor is powered at 6 V, it is advisable
pretation of the truth table of the exclusive- to replace IC3 by an LM2936Z5, for example,
OR used as a programmable inverter, as we which is a low-volts-drop 5 V regulator. For
have noticed that many of you aren’t familiar correct operation, the 78L05 originally speci-
with it (or have forgotten!) fied for IC3 requires almost 2 V between input
The truly active part of the circuit is formed and output – clearly impossible to obtain
by the two J-K flip-flops IC2A and IC2B. Figure with a motor supply of only 6 V.
2 sums up the truth table for these flip-flops, Still on the subject of the motor supply volt-
which is made simpler here because J and K age, note that it can be up to 24 V if necess-
are always both at the same level. When these ary. As long as the current drawn by the motor
inputs are ‘1’, the flip-flops change state at doesn’t exceed 1 A, the transistors don’t need
each clock pulse, i.e. for each pulse applied to a heatsink, but one is advisable above that. It
the STEP input. In the reverse situation, i.e. need only be a few cm2, since the transistors
when J and K are both ‘0’, the outputs Q and Q are operating here in switching mode and so
remain in the previous state. If you still have dissipate relatively little power.
doubts that this will indeed generate the (070299-I)
timings in the table above, arm yourself with
some graph paper, a pencil, and some Web Link
patience, and draw out the timing diagrams L293 spec sheet:
of the signals supplied, when DIR is at some www.st.com/stonline/books/pdf/docs/1328.pdf
arbitrary level of your choice.
353
R
310 circuits
elektor international media bv – 089018/uk
pagina 353
complexity of the robot increases, it becomes So far, everything we’ve been discussing is
clear that certain ICs are more suitable than still within the scope of all current micro-
others for a purely robotic application. controllers, and it’s not much help to us in
choosing. But the situation is actually more
So, after briefly discussing the special requi- complicated than you might think from this
rements typical of robots, we’re going to pre- discussion, which might be described as
sent a certain number of microcontrollers and ‘static’. When our robot is moving, there is a
try to highlight their strengths in a robotics need to simultaneously control its motors, in-
context. terpret the information provided by the sen-
sors, and take the necessary decisions that
The need creates the system entails.
Compared to a conventional electronic pro- On the simplest robots with a small number
ject, a robot possesses certain particular fea- of sensors, all this can be managed using
tures that have a direct influence on the standard sequential programming; but as
choice of which microcontroller to fit it with. soon as the number or complexity of the sen-
So whether it is fixed or mobile – and the first sors increases, the situation soon becomes
robots amateurs build are very often mobile, unmanageable. It then becomes necessary to
as these are admittedly the most spectacular resort to multitasking, i.e. to a mode of ope-
– a robot always includes one or more ration in which the microcontroller handles
motors. As you’ve been able to discover the sensors, the motors, and the decision-
throughout this book, these may take the making all together and ‘at the same time’.
form of radio-control servos, stepper motors, Sadly, not all microcontrollers or program-
or DC motors. ming languages are able to manage this by a
None of these are controlled in exactly the long way.
same way, but all of them require the micro-
controller to know how to generate pulses The last particular feature of robots is that,
more or less repetitively. unlike conventional electronics projects, they
are often built by amateurs coming from
Our robot is obviously fitted with sensors. backgrounds other than electronics. Mecha-
Although the simplest versions make do with nics, modellers, those who are simply curious
simple ‘whiskers’ or contact-based obstacle all get involved in designing robots.
detectors, as robots evolve, they become
literally covered in sensors, some of which For all these designers, who contribute a great
can be highly complex. deal to the world of robotics as they have a
different view from the electronics enthusi-
The information they furnish is most often di- asts, the microcontroller needs to be simple
gital, from the simple on/off information of an to implement and program. This simplicity
open or closed switch to the complex NMEA sometimes founders on the reef of the
frames from a GPS receiver. A few, less multitasking we’ve just been talking about,
common sensors also furnish information in but we’re going to see that, by judiciously
analogue form, and it’s important not to over- choosing the microcontroller, it is possible to
look these ones. reconcile the irreconcilable.
354
L
310 circuits
elektor international media bv – 089018/uk
pagina 354
Hence from Microchip, the PIC18 family is use microcontroller, needing neither a clock
gradually supplanting the PIC16 family that crystal, an external reset circuit, nor even a
has been delighting amateurs for many years. stabilized supply to operate. All this is already
These new ICs actually perform better, are built in.
more powerful, and hardly any dearer. As for
the development tools, the unassailable Like any self-respecting microcontroller, the
MPLAB, increasingly userfriendly and of Basic Stamp has to be programmed, but this
course still free, works just as well for either, programming is done in Basic, easy to use and
so the transition is a gentle one. And if the accessible to everyone, to the point it has al-
power of the PIC18 isn’t enough for you, the most become a standard upon which all its
PIC24 family is all ready to replace it, as dis- successors have been based. No programmer
cussed in Elektor issue 343’s presentation of is required, as it only amounts to… a simple
the Explorer-16. cable to link the Basic Stamp to the serial port
of any PC, even an old or very basic model.
It’s the same picture with Atmel, where the The development tool, intended for program-
AVR ICs from the ATmega range – scarce and writing, is completely free and available for
expensive just a few years ago – are now with- download from the Parallax website.
in everyone’s pocket, with their innumerable
internal resources and sometimes impressive
memory capacities. Here again, the AVR Stu-
dio development tool is free and available
from the Atmel website.
355
R
310 circuits
elektor international media bv – 089018/uk
pagina 355
Table 1
Name Pin Function
SOUT 1 Programming output (PC serial port)
SIN 2 Programming input (PC serial port)
ATN 3 Programming input (PC serial port)
VSS 4, 23 Ground
P0...P15 5...20 Input/output ports
VDD 21 5 V stabilized output (input if VIN is too low)
RST 22 Manual external reset input (if required)
VIN 24 Unstabilized positive supply from 5...15 V (12 V for 2E, 2SX, and 2P24)
Table 1 Pinout for the Basic Stamp 2 in the 24-pin package, adopted by many of its competitors (Basic
Atom 24, Cubloc CB220, Javelin Stamp, among others).
Even though the simplest of all the Basic The first evolution to have seen the light of
Stamps, the Basic Stamp 1, can be used to day, the Basic Stamp 2SX or BS2SX, is in fact a
drive a robot, we unhesitatingly advise using significantly faster version of the BS2. It ex-
at least the Basic Stamp 2, to benefit from the ecutes on average 10,000 instructions per sec-
more numerous resources and a fuller in- ond, by replacing the BS2’s microcontroller
struction set. What’s more, many successors with a SX28 from Ubicom.
to the Basic Stamp 2 (referred to from now on
as BS2) are pin-compatible with it, allowing The program memory is also larger, accepting
for possible future upgrading as a robot around 4,000 lines of program. All this is of
evolves, without needing to modify the course transparent for the user and the
associated electronics. BS2SX instruction set is identical the BS2’s,
apart from three new instructions to manage
Figure 1 show both the physical appearance this extra memory.
of the BS2 and its pinout, while the functions
of the various signals available are listed in The BS2SX and its relatively large program
Table 1. Like all its successors, the Basic memory created a demand among certain
Stamp is not a ‘true’ integrated circuit, but a Basic Stamp users wanting to benefit from
tiny PCB the size of a 24- pin DIL IC fitted with this much larger memory, but not needing
a number of SMD components, including a the speed (and hence the price-tag!) of the
microcontroller, its clock and reset circuitry, BS2SX. So Parallax has offered them the Basic
an EEPROM memory for storing the program, Stamp 2E – simply a ‘degraded’ version, in
and a 5 V regulator to
power it.
Based on an ‘old’ PIC16C57
at 20 MHz, the BS2 is pro-
grammed directly in Basic,
sometimes called PBasic,
and is capable of executing
around 4,000 instructions
per second, while its memo-
ry can store around 500
lines of program. Its plane-
tary success, and the word
is not too strong, has
pushed Parallax to put onto
the market other BS2s,
whose strong points are
summed up here rapidly. Photo 2 The Basic Stamp’s offspring.
356
L
310 circuits
elektor international media bv – 089018/uk
pagina 356
pagina 357
310 circuits
Max. sink/source- 20/25 mA 30/30 mA 30/30 mA 30/30 mA 30/30 mA 30/30 mA
current per output
Max. sink/source-cur- 40/50 mA 60/60 mA 60/60 mA 60/60 mA 60/60 mA 60/60 mA
rent per chip/per group
of 8 inputs/outputs
Programming interface PC serial port PC serial port PC serial port PC serial port PC serial port PC serial port
Table 2 Principal characteristics of the various BASIC Stamps and the Javelin Stamp.
R
357
310 CIRCUITS
terms of speed only, of the BS2SX. So, the So in our opinion, the Basic Stamp is a good
Basic Stamp 2E has all the characteristics of choice for someone wanting to make a start
the BS2SX, but offers the same program ex- in robotics, even if it does present in our view
ecution speed as the BS2. two drawbacks, of unequal importance: it’s
still expensive compared to other similar ICs;
The Basic Stamp 2P24s and 2P40s offer more and it doesn’t support multitasking. This
innovations, but can be presented together point must, however, be taken relatively, in-
as their characteristics are identical except asmuch that a number of microcontrollers
for one detail we’ll look at in a moment. Apart that do support it are pincompatible with the
from being faster than the already fast BS2SX, 24-pin Basic Stamps, allowing easy substituti-
achieving 12,000 instructions per second, on in the event of your robot’s evolving in this
they also have an extended instruction set. direction.
The 36 or 39 instructions of the BS2 or BS2SX
increase to 55, introducing some very power- Basic Stamp ‘clones’
ful and extremely handy instructions capable The success of the Basic Stamp has clearly
of directly driving an LCD alphanumeric dis- made some people envious, and various pro-
play, talking to peripherals over the I2C bus, ducts have tried to imitate it, while seeking to
or driving ICs with a Dallas ‘1-Wire’ bus. This overcome some of its shortcomings. At least
evolution is done cleverly, however, and the two products fall into this category: the Basic
same 36 BS2 instructions are included within Atom 24 from Basic Micro and the PICBasic
the 55 instructions of the BS2P24 and range from Comfile Technology.
BS2P40. The BS2P24 uses a pinout compat-
ible with the other Basic Stamps, while the Based on a PIC16F876, the Basic Atom 24,
BS2P40 uses the 40-pin DIL IC format, allo- pin-compatible with the 24-pin Basic Stamp
wing it to have 16 additional parallel port li- 2s, has a program memory the same size as
nes compared with the 24-pin packages. the BS2E.
Faster overall, at around 33,000 instructions
To help guide your choice, Table 2 summar- per second, it also offers more internal re-
izes the most important details of the various sources, including an ADC, two PWM ports,
versions of Basic Stamp. Note that, for and up to a point supports interrupts. Its in-
reasons of convenience, it includes the Javelin struction set is also fuller than the ‘classic’ Ba-
Stamp, described later. sic Stamps, and is related to that of the Basic
Stamp 2P, though is a little fuller because of
All these Basic Stamps are wonderful in the increased internal resources. So it may re-
robots, as their instruction set has really been present a worthwhile alternative to the Basic
designed for microcontroller-oriented use. Stamp, especially since it’s a little cheaper to
So to make parallel port P2 go high, we buy.
simply write HIGH P2; to make it generate
pulses we use the instruction PULSIN; to On the downside, we must note all the same
receive data in asynchronous serial form, we that it isn’t multitasking either, and its avail-
use SERIN, while to make it output synchro- ability leaves something to be desired, as the
nous serial data we use SHIFTOUT . product has clearly not enjoyed the success
Because of the very simple and explicit syntax its designers were hoping for (or else it just
of these instructions, anybody can write pro- came on the scene too late).
grams for a Basic Stamp after just a few hours As it is not used a great deal, the library of
of practice and with no previous knowledge programs for it is nothing like that of the Ba-
of programming. Moreover, given the senior- sic Stamp.
ity and success of the Basic Stamp, the library
of programs available is immense. You only As for the PICBasic, it is, or rather was, an
have to do a bit of Googling to see for your- alternative to the Basic Stamp 2 designed by
self. Korean company Comfile Technology. We
358
L
310 circuits
elektor international media bv – 089018/uk
pagina 358
won’t talk about it here, as it’s clearly on the this type. So the Javelin Stamp can, for exam-
road to extinction, if we are to believe Comfi- ple, control a robot’s motors and convert the
le’s website, in favour of the Cubloc range analogue information coming from a sensor,
from this same manufacturer. When you dis- while still continuing to execute its main pro-
cover in a moment the possibilities of the Cu- gram.
bloc, and given that a CB220 (entry-level
Cubloc) costs virtually the same as a PICBasic Independently of these specific features, the
2S, you’ll easily understand why it’s being Javelin Stamp uses a Ubicom SX48 processor
dropped. operating at 25 MHz, giving it a speed of
8,500 instructions per second; its other key
A first steptowards multitasking characteristics are summarized in Table 2, to
Once again, it is Parallax who made the inno- let you make a quick comparison with the
vation in terms of multitasking with two dis- Basic Stamps.
tinct products for completely different
purposes. The first, and also the oldest, is the So the partially multitasking character of the
Javelin Stamp, much less well known than the Javelin Stamp does make it an interesting pro-
Basic Stamp. It has to be
said that its price (around £
45) might have something
to do with this...
359
R
310 circuits
elektor international media bv – 089018/uk
pagina 359
cessor for robotics applications, but in our 18 MHz, it can execute around 36,000 in-
view it suffers from two drawbacks: its exces- structions per second and its program mem-
sive price, compared with ‘competing’ pro- ory offers a very comfortable capacity of 80 kB.
cessors; and the fact that it is programmed in Note too that it has an 8-channel 10-bit ADC
Java, which is quite a difficult language to and a 3-channel, 16-bit DAC capable of gener-
master for anyone who has never done any ating PWM signals.
programming before.
So the Cubloc CB220 seems to us a good
One microcontroller with two heads choice today in terms of processors intended
The Cubloc range from Comfile Technology is for robotics, as it combines lots of advantages
much more innovative in the area of multi- in a single package: hardware compatibility
tasking. As seen in Figure 2, showing the with the Basic Stamp 2, the simplicity of Basic
Cubloc’s internal structure, this microcontrol- programming, and the possibility of multi-
ler is in fact a twin one, including on the one tasking; all this for a price that is still reason-
hand, a processor programmed in Basic, and able compared with the other products in this
on the other, a processor controlled in Lad- survey.
der. This language, which you may not have
heard of, is none other than the language And finally, some true multitasking
used for programmable automata. The Rest assured, Elektor readers, we have not
Cubloc’s twin processors can of course oper- been paid to write this article by Parallax,
ate simultaneously, making the Cubloc truly even though it’s another of this company’s
multitasking – provided of course we pro- products we’re going to be talking about
gram in both Basic and Ladder. next: the Propeller. We have to admit that
ever since the first Basic Stamp came out al-
To make it easier to get to grips with, it is of most 15 years ago, Parallax hasn’t been res-
course possible to only program it in one ting on its laurels. But while the previous
language or the other. If you choose Basic, products were based on existing processors,
the syntax is close to that of the Basic Stamp the Propeller is a real ‘chip’ developed by Pa-
with, however, lots of new instructions ma- rallax.
king it easier to handle PWM signals, or drive
an I2C bus, keyboard interfacing, etc. As Figure 3 shows, even at first glance it’s an
impressive product, consisting of no less than
Although the Cubloc rage currently com- eight independent functional blocks, the
prises four main models,
whose key characteristics
are summarized in Table 3,
we recommend starting out
with the CB220. Apart from
being it’s the cheapest of
the Cublocs, it’s also pin-
compatible with the Basic
Stamp 2, making it possible
todevelop a single-tasking
application using the latter
into a multitasking applica-
tion, without needing to
make the slightest modifi-
cation to the electronics.
What’s more, given that it’s Figure 3 Internal architecture of the Propeller – impressive, and al-
based on an ATmega128 at lowing true multitasking.
360
L
310 circuits
elektor international media bv – 089018/uk
pagina 360
Table 3
Parameter CB220 CB280 CB290 CB405
Microcontroller ATmega128 ATmega128 ATmega128 ATmega2560
Clock frequency 18,432 MHz 18,432 MHz 18,432 MHz 18,432 MHz
Program 80 K 80 K 80 K 200 K
memory
Dynamic memory 2 K (Basic) 2 K (Basic) 24 K (Basic) 51 K (Basic)
(RAM) 1 K (Ladder) 1 K (Ladder) 4 K (Ladder) 4 K (Ladder)
55 K (pile)
Data EEPROM 4K 4K 4K 4K
Speed (instr./s) 36.000 36.000 36.000 36.000
Inputs/outputs 16 49 91 (33 i/p, 32 o/p, 26 I/O) 64
Serial ports 1 RS232 1 TTL 1 RS232 1 TTL 1 RS232 1 TTL 4 RS232
ADC (10-bit) 8 channel 8 channel 8 channel 16 channel
DAC (16-bit, PWM) 3 channel 6 channel 6 channel 12 channel
External interrupts – 4 4 4
Fast counters 2 x 32 bits 2 x 32 bits 2 x 32 bits 2 x 32 bits
Real-time clock – – yes –
Supply voltage 5...12 V 5V 5V 5V
Operating current 40 mA 40 mA 70 mA 50 mA
Package 24-pin DIL 64-pin module 108-pin module 80-pin module
(BS2 compatible)
Table 3 Principal characteristics of the various Cublocs.
Cogs, each comprising its own processor and So if you need, for example, an RS 232 serial
some RAM. These Cogs are linked via a bus port, you only need to delve into the volumin-
managed by a Hub that takes care of synchro- ous object library made available to you by
nizing their exchanges. They all share the pro- Parallax to find what you’re looking for there.
duct’s 32 uncommitted input/output lines. You can do the same for generating PWM sig-
nals, driving an I2C bus, an LCD display, etc.
Very few specialized peripherals are built in
to the Propeller, but this isn’t a problem, Given that there are eight Cogs available, it’s
given that its programming language, called possible to run up to eight different applica-
Spin, is in fact an object-oriented language. tions simultaneously. So a robot fitted with
this sort of processor has no
difficulty in managing its
wheel motors, while analy-
sing the data from several
sensors and taking the rele-
vant decisions.
361
R
310 circuits
elektor international media bv – 089018/uk
pagina 361
Photo 5 The development tools for Basic Stamp Photo 6 The Propeller development tool sho-
and Cubloc include a very useful editing terminal. wing an example of Spin – not exactly a barrel of
laughs, but the results are worth the effort!
upload the various object modules they have can be programmed in object oriented
developed for the Propeller. This partici- language – ‘OO’ standing for ‘Object Oriented’
patory library currently has over 75 object – but that’s not all…
modules covering the most diverse fields, and
is continually growing. The OOPic is in effect a PIC that you will be
able to program in the language of your
So if you want to build a robot that requires choice: Basic, C, or even Java – but this pro-
true multitasking, the Propeller is currently gram will consist of simple scripts calling up
one of the best solutions there is, all the more objects.
so because the price is only a quarter of that These objects, currently 130 of them, are ca-
of a Basic Stamp, a Cubloc CB220, or similar pable of managing virtually anything you can
product. imagine driving with a microcontroller, and,
rather than list them here, we’ll send you off
An odd multitasking PIC to the OOPic website to discover them for
We couldn’t end this review of special proces- yourselves.
sors for robots without mentioning an IC
that’s relatively unknown on this side of the All these objects are able to operate simul-
world, despite its undeniable interest: the taneously and independently of each other as
OOPic. background tasks while the main program is
As its name might leads us to suppose, this IC running. So with an OOPic, it’s very easy to
is none other than a PIC microcontroller that produce a multitasking application. But the
Adresses
URL Company Comments
www.atmel.com Atmel Manufacturer of AVR-microcontrollers
www.basicmicro Basic Micro Manufacturer of Basic Atom
www.comfile.co.kr/english2/ ‘PicBasic’ website Manufacturer of PicBasic
www.comfiletech.com Comfile Technology General Site Manufaturer of Cubloc
www.microchip.com Microchip Manufacturer of PIC microcontrollers
www.oopic.com Savage Innovations Manufacturer of OOPic
www.parallax.com Parallax Manufacturer of Basic Stamp, Javelin
Stamp, Propeller
www.tavernier-c.com – Author’s website
362
L
310 circuits
elektor international media bv – 089018/uk
pagina 362
Another advantage, and not the least, of the But we hope that we have helped you dis-
OOPic is the possibility of networking it; a cover or re-discover some of the processors
maximum of 128 OOPics can be connected to- that are particularly well suited to robotics
gether to I2C ICs, thanks to a 3-wire bus and and which, while being simple to implement,
without any additional external components. do not in any way sacrifice performance.
So with the OOPic it’s possible to create what www.tavernier-c.com (070319-I)
Alexander Wiedekind-Klein
363
R
310 circuits
elektor international media bv – 089018/uk
pagina 363
1
FC LV
6
IC draws a quiescent cur-
2
IC1
7 rent of just 120 µA.
C+ OSC
C2
MAX660 There is little to say about
100µ STI
16V
4
C– OUT
5
the circuit itself. The 0 Ω re-
1
3 sistor on pin 1 selects the
2
operating frequency. With
C1 C3 C5
3 R1 fitted, the circuit oper-
ates at 80 kHz; without it, at
100n 4µ7
25V
100µ
16V 10 kHz.
L1
–5V The combination of L1 and
C5 slightly reduces ripple
10µH
070279 - 11
Abraham Vreugdenhil rection than the other, the robot will move
slightly forward. If it also keeps turning to-
The design brief for this robot was that it had wards the light it becomes a true light seeker.
to be simple, yet unusual, and also have a
specific purpose. But should we really call this A detailed description of some of the parts
a robot? It consists of one motor, one wheel, follows.
sensors, a microcontroller, LEDs, batteries
and ‘legs’. If the motor slowly turns one revo- Wheel
lution to the left and then one to the right, A normal rubber wheel is used for this robot.
and the ‘legs’ offer more resistance in one di- This gives sufficient grip on the floor, some-
364
L
310 circuits
elektor international media bv – 089018/uk
pagina 364
21k
For the lights sensors an old
favourite is used, the CNY- IC2 R3 R4
1 3
560 Ω
560 Ω
CNY70 R2 R6
vels, we end up with a neat 8MHz
560 Ω
21k
365
R
310 circuits
elektor international media bv – 089018/uk
pagina 365
Abraham Vreugdenhil
366
L
310 circuits
elektor international media bv – 089018/uk
pagina 366
367
R
310 circuits
elektor international media bv – 089018/uk
pagina 367
stable position (see Equation 2). A mathemati- Using a gyroscope, the angular velocity of the
cal/physical basis of this control strategy can sensor can be determined. The output signal
be found in [1], among others, including the is directly proportional to the speed at which
derivation of the relevant equations of the sensor rotates around its own axis. By
motion. simply integrating this signal the angle of the
robot can be calculated. The accuracy is a
Sensors problem however. If the sensor has a small
To determine the aforementioned variables static offset of, for example, 0.1 E/s per
an accelerometer and a gyroscope are usually measurement then the error after 100 times
used. of measuring and integrating has increased to
With an accelerometer the acceleration that 10 E. It is possible to build a balancing robot
the sensor is subject to can be measured. The based solely on a gyroscope, but you will see
direction of acceleration is also measured. A however that after some time the robot will
sensor that is frequently used is the ADXL202 start to swing and become unstable. The
from Analog Devices, which can measure ac- small amount of drift that these sensors have
celeration in two mutually perpendicular di- is amplified by the process of integration.
rections. Because the sensor is also sensitive By combining a gyroscope an an accelero-
to the static acceleration due to gravity (g), meter the disadvantages of both sensors can
the sensor can also determine the angle of be compensated for. In general this is done
the robot with respect to the Earth. with a so-called Kalman-filter. This sums the
The acceleration observed by the sensor is result from the gyroscope, the value from the
shown in Figure 2 with the vectors am1 and accelerometer and the calculated angle from
am2. When the sensor is not subjected to any the previous measurement cycle. These three
other acceleration, the sensor is only sensi- values when summed are weighted with
tive to the angle of the sensor with the direc- respect to each other. The weighing factors
tion of gravity (and gravity itself, which is that are used are determined dynamically
constant). As soon as the sensor is also sub- while balancing. Because the weighing values
jected to a dynamic acceleration (a), the tend to quickly converge to a particular value,
sensor will observe this as well. This is the fixed relationships can also be used (Equation
case, for example, when the robot is driving 3). The appropriate weighing factors can be
forwards or backwards. The resulting accele- determined during the calibration of the
ration am2 then depends on the dynamic system.
acceleration, gravity and the angle. This gives It is common practice for the motors in the
a direct insight into the problem: the instant robot to be fitted with encoders. These give
that the robot moves, the signal from the pulses when the motor turns. By counting the
sensor cannot be used any more to directly number of pulses per unit time or measuring
determine the angle of the robot. the time between pulses it is possible to de-
368
L
310 circuits
elektor international media bv – 089018/uk
pagina 368
Actuators Architecture
Another special point of interest are the actu- In the control loop that is executed by the
ators. While balancing the robot the motors software in the microcontroller a number of
have to be frequently switched into the for- things have to be carried out simultaneously.
ward and backward direction. However, the The sensors have to be read, calculations
combination of motors and gearbox is not have to be carried out and the actuators for
without friction or backlash. When the volt- the robot have to be driven. At the same time
age across the motors increases this does not it is often also desirable to communicate with
l
1 T = 2p
g
T period (s)
g gravitational acceleratoin (m/s 2)
l length from pivot to centre of mass (m)
2 PWM = k 1× q + k 2 × q + k 3 × n
3 q B [n ] = k 4 × q B [n - 1] + k 5 × q G [n ] + k 6 × q n [n ]
369
R
310 circuits
elektor international media bv – 089018/uk
pagina 369
a PC for the purpose of data acquisition. For If this factor is too small then the robot will
all this it can be a good idea not to use one react slowly; if this is too large then the robot
relatively powerful processor but to use a will quickly oscillate around the balance
number of smaller processors which send point. In the latter case the feedback factor
their data to one central processor. In this can be reduced and the feedback factor for
way the timing of measuring and controlling speed can be increased. In this way the robot
can be divided, which make the programming will quickly gain in stability. A final step can
task a great deal easier. be made by increasing the feedback for
speed. This will result in better positioning
Sum of parts for the robot. A feedback factor that is too
A balancing robot consists of a number of large however will make the robot very un-
parts that together have to hold the robot stable.
upright: sensors, any filters, a controller and A second step is the calibration of the sen-
drive system for the robot. Putting all this to- sors. The measurement values from the sen-
gether in one go is very ambitious, a better sors (gyroscope, accelerometer) can be read
chance of success is obtained by first testing into a PC via the microcontroller. Sensors that
and calibrating the individual parts. A good provide a read-out in the form of a pulse
method for this is the temporary addition of a width modulated signal are quite common.
small arm to the robot. This arm is attached By comparing the measured pulse width with
to the robot so that it can hinge with the aid the reading from the potentiometer that is
of a potentiometer, which functions as the mounted to the arm the angle and angular
hinge. The other end of this arm is fitted with velocity can be easily derived. During the cali-
a wheel that rests on the floor. When the bration, the drive for the robot can be swit-
robot loses its balance the position of the ched off. By moving the robot back and forth
potentiometer changes and therefore also its by hand the angle and angular speed are
output. The output of the potentiometer has changed and the calibration can be per-
a direct relationship with the angle of the formed. When calibrating the accelerometer
robot and can be used for calibration purpo- it is important to move the robot back and
ses. Note that it is important to choose a
potentiometer with a shaft that turns easily.
The next step is the controller. Because of the
arm, a read-out of the angle is available and
this can be used to test and calibrate the con-
troller for the robot. As already mentioned,
feedback from the angle of the robot, angular
velocity and speed of the robot are essential
for the successful control of the robot. It is
possible to calculate the necessary feedback
factors mathematically. However this makes a
complete and detailed physical description of
the robot and the behaviour of the motors
essential. It is simpler to determine these
factors experimentally. This can be done, for
example, by connecting a number of digital or
analogue potentiometers to the micro-
controller. The program that runs in the
microcontroller reads the position of the po-
tentiometers and converts the relevant values
into feedback values. The calibration can now
be done with a lot of patience. A first step is
to increase the feedback factor for the angle.
370
L
310 circuits
elektor international media bv – 089018/uk
pagina 370
371
R
310 circuits
elektor international media bv – 089018/uk
pagina 371
11 32
+5V 3V3
1 40
MCLR/VPP RB7/PGD
39
RB6/PGC
2 38
RA0/AN0 RB5 C2 C1 C3
3 37
RA1/AN1 RB4
4 36 10µ 220n 10µ
RA2/AN2 RB3
5 35
RA3/AN3 RB2
6 34
RA4/T0CKI RB1
7 33
RA5/AN4/SS RB0
8
RE0/RD/AN5
9 15
RE1/WR/AN6 RC0/T1CKI
10 16
RE2/CS/AN7 RC1/CCP2
17
RC2/CCP1
13 18
OSC1/CLKIN RC3/SCK/SCL
14 23
OSC2/CLKOUT RC4/SDI
PIC18Fxxx
19 24
RD0/PSP0 RC5/SDO
20 25 R6 R4 R3
RD1/PSP1 RC6/TXD 8
21 26 7
2k2
2k2
3k3
3k3
070318 - 11
memory is very inexpensive today (around £ 7 these memory cards. Contrary to what we
for 1 GB at the time of writing), very compact, might at first think, these are not just simple
and unwaveringly reliable, provided you do EEPROM Flash memories with serial access,
not exceed the maximum number of write but modules that have their own internal in-
cycles, which is however hundreds of thou- telligence. So it’s not possible to read or write
sands, or even millions, depending on how directly to these memories as you would do
optimistic the manufacturers are... with an ordinary serial access EEPROM like a
24C16, for example.
The hardware interfacing of such memory
with a PIC microcontroller is relatively easy, The dialogue has to respect a precise proto-
as the SD-type memories’ mode of operation col, as the card only recognizes and responds
is compatible with the SPI-type synchronous to a certain number of commands. We also
serial interface available in these micro- have access to various internal registers with
controllers. The only thing to watch out for is quite specific purposes. Lastly, the location of
the electrical levels, as these memory cards the data in the card is not just ‘any old how’,
work on 3.3 V while the PICs in our robots are but follows a principle similar to that found
most often powered from 5 V. The figure sug- on diskettes and hard disks, using in particu-
gests a circuit that can be used with all PIC mi- lar a FAT (File Allocation Table) that shows
crocontrollers in the PIC18 family from where the data, contained in files as a result,
Microchip. are stored.
However, the problem is noticeably trickier Even though it is possible to manage all this
when it comes to the software for managing information by writing the necessary subrou-
372
L
310 circuits
elektor international media bv – 089018/uk
pagina 372
tines yourself in machine language, this is a Reading the information stored on the SD
long, tedious, and error-prone task. card and transferring it to the robot proces-
sor’s RAM is just as simple, and amounts to a
Very fortunately, if you’re interested in using single line of code:
such a memory card in your robot, there is
one Basic compiler (for PIC microcontrollers status = Mmc _ Read _ Sector
only, at the time of writing) that has a full (number, buffer)
management library available for SD-type
memory cards wired as shown in our figure. where:
This is the MikroBasic compiler from Mikro-
elektronika, which you can find on the pub- à status is a variable containing a numeric
lisher’s website (www.mikroelectronika.co.yu), code indicating the outcome of the execu-
with a working demo version allowing you to tion of the command (0 for success, 1 for
try it out before buying. Apart from those failure).
standard functions available in all Basic com- à number is the number of the SD memory
pilers for PICs worthy of the name on the sector we want to read.
market today, it has a full management library à buffer is the label marking the start of a
for SD-type memory cards (also for Compact buffer whose size must be at least 512 bytes;
Flash types, but they’re not the subject of this this buffer is going to receive the data
article). read from the selected sector on the card.
We’re not going to detail here the sixteen in- As you will note, it would be difficult for
structions available for manipulating SD things to be much easier, even though in this
cards, especially since you can download the article, by nature only a summary, we have
manual for this compiler free of charge from not said anything about the card’s FAT man-
the publisher’s website. Just be aware that agement instructions. However, the latter are
using this product makes the management of much less frequently used, once the structure
such cards ever so much easier, to say the of the card is defined, and a detailed, annota-
very least! ted example about these is given in the com-
So for example, if you have filled a buffer and piler manual.
want to now store it onto the SD card, all you
have to do is write: So then, if your robot needs lots of memory,
lend it the SD card out of your camera and pay
status = Mmc _ Write _ Sector a visit to Mikroelektronika (www.mikroelektro-
(number, buffer) nika.co.yu).
(070318-I)
where:
373
R
310 circuits
elektor international media bv – 089018/uk
pagina 373
C. Tavernier
1k
374
L
310 circuits
elektor international media bv – 089018/uk
pagina 374
So as to get our robot up If In(0) = 1 And In(1)= 1 Then ' Right and left
and running quickly, we’ve whiskers?
used a ‘whisker’-type ob- Obstacle = 3
End If
stacle detector. To achieve
Pwm 1,3590,32768 ' Backward
this, we use two long-lever Pwm 0,3195,32768
microswitches – or two or- Pause 1500
dinary lever-operated mi- Else
croswitches with a few Obstacle = 0 ' No whisker activated
centimetres of piano wire End If
soldered to them – moun-
' Obstacle variable analysis
ted on the top plate. They
are positioned at an angle Select Case Obstacle
of around 45–60E to each Case 0 ' No obstacle
other, with their centrelines Pwm 0,3590,32768 ' Forward
intersecting on the robot’s Pwm 1,3195,32768
front/back centreline. This Case 1 ' Obstacle on the right side
Pwm 0,3600,32768 ' Light turn to the left
gives us one obstacle detec- Pwm 1,3600,32768
tor on the front right, and Pause 1000
another on the front left. Case 2 ' Obstacle on the left side
Pwm 1,3180,32768 ' Light turn to the right
The robot’s brain is en- Pwm 0,3180,32768
trusted to a Cubloc CB220 Pause 1000
Case 3 ' Head-on obstacle
module from Comfile Tech-
Pwm 0,3750,32768 ' Full half turn
nology, allowing us to both Pwm 1,3750,32768
write a very simple program Pause 1500
and build an equally simple End Select
electronic circuit, as you Loop
can see from the diagram.
375
R
310 circuits
elektor international media bv – 089018/uk
pagina 375
Ports P0 and P1 of the Cubloc are program- instructions that follow. Given that we are
med as inputs and receive the information using modified radiocontrol servos, remem-
coming from the obstacle detectors. Normal- ber they are stopped when they receive pul-
ly low, they go high when one or other of the ses of 1.5 ms; they rotate at full speed in one
whiskers is activated, i.e., in the presence of direction for 2 ms pulses; and at full speed in
an obstacle. the other direction for 1 ms pulses.
Ports P5 and P6 are programmed as outputs Note too that, as the servos are mounted in
and drive the propulsion servos. The choice reversed orientations in the Rogue Blue base,
of these ports is vital, as the Cubloc’s PWM they need to rotate in opposite directions to
signal-generating instruction we are going to make the robot go forwards or backwards.
be using only works with these. The servos Because of the mechanical and electrical tole-
are powered directly from the pack of four rances, 1.5 ms pulses don’t always give exact-
1.5 V cells, while we use the Cubloc’s VIN in- ly stop. So you may need to go back and
put so as to take advantage of its built-in 5 V tweak the first parameter of the PWM instruc-
regulator. However, if you are going to use tions (3410 in this example).
NiMH rechargeables instead of primary cells,
you’ll have to use the VDD input to power the Once the robot has stopped, we test to see if
Cubloc, as in this case the voltage available is the left or right whisker has been activated,
only 4.8 V. and set the variable ‘obstacle’ accordingly.
One last test checks if both whiskers have
Connector DB9 is designed for connecting been activated simultaneously, and if this is
the Cubloc to a PC, to program it with the the case – meaning the robot has encounte-
software we’ll be suggesting in a moment. red an obstacle directly ahead – reverse drive
Given the simplicity of the circuit, it can be is applied (2 ms pulses to one servo and 1 ms
built on perforated prototyping board or on a to the other).
CB220-Proto test board, which comes with
this connector already pre-wired. The variable ‘obstacle’ is then analysed by
means of a ‘select’ box that the Cubloc’s powerful
The software needed to control the whole Basic has borrowed from C. If the variable
thing is very simple, even for someone with ‘obstacle’ has a value of 0, no obstacle has been
only faint notions about programming. The encountered and our robot sets off forwards. If
Cubloc’s Basic language is both simple and the variable ‘obstacle’ has a value of 1 or 2, an ob-
very powerful. The source listing is available stacle has been encountered to right or left, and
on the Elektor website, as well as the author’s so a quarter-turn is made in the opposite direc-
own site ( but it’s so short, you can also just tion. However, if the variable ‘obstacle’ has the
type it yourself directly into the Cubloc Stu- value 3, an obstacle directly ahead has been
dio editor, which is the Cubloc’s (free) devel- encountered, and the robot does a complete U-
opment tool, and can be downloaded from turn.
www.comfiletech.com.
Watch out! Depending on what you call
The listing is very easy to analyse. After de- front/back and left/right on your particular
fining the type of Cubloc in use and the opera- robot, you may need to swap round the
ting sense of the ports P0, P1, P5, and P6, we successive PWM instructions in the listing
also define a variable ‘obstacle’. The main we’ve just given, so that they do indeed
program can then commence, in the form of a produce the movements intended.
continuous Do Loop. You might also need to tweak the first para-
meter of the various PWM instructions. We
We start by testing for one or other of ports explained the reason for this above for stop,
P0 or P1 going high, and if this is the case, the but the same thing happens for rotation of
robot is stopped by means of the two PWM the servos at full speed in one direction or the
376
L
310 circuits
elektor international media bv – 089018/uk
pagina 376
ly reprogrammable (a mini-
mum of 10,000 cycles
guaranteed by the manufac-
turer of the microcontroller
it’s fitted with!)
After a certain period of
use, you’ll doubtless realize
the limitations of this robot.
Then it’s up to you to devel-
op it, by adding, for
example, obstacle detec-
tors of the same type, but to
the rear, an ultrasonic
distant obstacle detector, a
other. If your robot fails to travel in a straight line-follower function, etc. The articles in this
line when running forwards or backwards, it’s book already ought to give you some good
just because the servos are not turning at the ideas to get you started.
same speed for pulses of the same width. In (070298-I)
this case, all you have to do is make minor ad-
justments to the first parameter of one or the Web Link
other of the PWM instructions in order to get Rogue Blue base kit:
correct results. Don’t be afraid to, the www.roguerobotics.com
Cubloc’s program memory is virtually infinite-
R2 R6
1k
100k
Vibrations transmitted 7
PIC12F675
5 BC547
through the frame are the
GP0 GP2
377
R
310 circuits
elektor international media bv – 089018/uk
pagina 377
The first attempt to solve the problem with power transistor (T2). The IRF4905 has an ex-
an analogue electronic flasher circuit was not tremely low on-resistance of just 20 mΩ and
successful: the first charge cycle of a capacitor is capable of switching 74 A maximum. The
was almost twice as long as successive supply (derived from indicator relay) is limi-
periods, so the flash rate was not constant ted to 4.7 V by diode D1 and smoothed by C1
(maybe an integrator circuit would have given to reduce the effects of any interference from
better results). the motorcycle supply.
A better solution was produced using the Firmware for this design applicable to the PIC
mini PIC circuit and FET shown here. This de- controllers 12F629, 12F683 and 12F675 is
sign also has a built-in bonus feature; motor- available to download free of charge from the
cyclists are notorious for forgetting to cancel Elektor website, look for file number 070090-
their indicators so the circuit includes a time- 11.zip.
out function (jumper selectable) which auto-
matically cancels the indicator after 120 blink The finished circuit is reliable, impervious to
cycles. vibrations, load current changes and best of
The circuit uses very few components and the all can be built for less than 7 pounds (approx.
finished circuit can usually be fitted into the 10 euros). As a final thought you should check
existing indicator relay housing with a space that traffic regulations allow the use of such
of around 20 mm × 30 mm. home-made designs to be fitted to the motor-
The output signal from the PIC controls the cycle before it is driven on the road.
driver (T1) which then switches the HEXFET (070090-I)
378
L
310 circuits
elektor international media bv – 089018/uk
pagina 378
BoeBot Upgrade
As you may know, Parallax is also the manu- It was only a matter of time before this robot
facturer of the BoeBot robot kit, a frame with was upgraded with a processor board for the
all the required hardware to make a mobile Propeller chip. Parallax has recently brought
robot that can be equipped with various sen- out a prototyping board that is made to
sors. All this is controlled by a processor measure for the BoeBot frame. It is noticeable
board using a Basic Stamp or Javelin Stamp. that part of this board now has an ordinary
prototyping area for the addition of extra
The BoeBot with the Basic Stamp was pre- electronics, whereas the ‘old’ Basic Stamp
viously covered extensively in a series of arti- board came equipped with a mini bread-
cles in Elektor Electronics, but that was quite board.
some time ago: end 1999/early 2000 to be
exact. On the Propeller board we therefore have to
solder any extra components, which is a bit
But it’s still going strong after all this time, more time consuming than simply inserting
since the BoeBot is even now widely used in them into a breadboard, but it does make the
education. That was the original purpose of robot more reliable. Despite being carefully
this robot, since ‘Boe’ stands for ‘Board of constructed and having well thought out soft-
Education’. ware a robot can still bump into something or
379
R
310 circuits
elektor international media bv – 089018/uk
pagina 379
380
L
310 circuits
elektor international media bv – 089018/uk
pagina 380
381
R
310 circuits
elektor international media bv – 089018/uk
pagina 381
Alexander Wiedekind-Klein
TR1
CTX50-4
1 4 STI
C1 C4 1
FB = 1V25 P S
47µ 100n D1 2
16V MBRA130LT3 Uout = 12V
2 3 750mA 3
C6
10µ
50V
R5
9 5 5 6 7 8
3k0
FB T1
10 8 4
SYNC/SHDN EXT R2
FDS6680
IC1
5k6
1 2 3
1 6
LDO CS+
MAX668
4 2
REF FREQ
PGND
R1 R4 R3
C2 C3 3 7 C5 C8 C9
1k
0Ω05
100k
070280 - 11
382
L
310 circuits
elektor international media bv – 089018/uk
pagina 382
it a simple replacement for conventional cuit can be modified for different output volt-
three-terminal voltage regulator ICs. The ages by changing the component values in
buck-boost switching circuit uses an SMD the voltage divider. For lower output voltages
power FET for T2, and to achieve high effi- the input voltage can also be reduced corre-
ciency (approximately 90 %) a Schottky swit- spondingly.
ching diode for D1. The most specialised Gerber files for the prototype printed circuit
component is the miniature transformer de- board are available for free download from
signed for use in this type of supply. For the the Elektor website, ref. 070280-1.zip. The
prototype we used a Coiltronics CTX50-4. SMD components used have the following
The current limit is set by R4. The output volt- outlines: R1, R2, R3, R5, C3, C4 and C5: 0603;
age is scaled by the voltage divider formed by C2: 0805; IC1: SSOP-12; T1: SO-8. All the SMD
R3 and the series combination of R5 and R2. capacitors are ceramic, and electrolytics C1
The output voltage is controlled so that a and C8 must have a low ESR. R4 is a 50 mΩ
voltage of 1.25 V appears across R3 and hence SMD resistor rated at 1 W.
on the feedback input (pin 5) of IC1. The cir- (070280-I)
383
R
310 circuits
elektor international media bv – 089018/uk
pagina 383
Pascal Choquet
220 Ω
10µ 100n 100n 10µ
menacing) voice.
D2
220 Ω
1k
quire a whole heap of ICs
4k7
4k7
4k7
100n 100n
sages.
3
10k
A2
100n
22µ 16V 21 2
PD Play/Rec Next ANAOUT A1
1
A0
Included on the IC is a
C1
17 14
MIC SP+
microphone preamp and MIC1
100n ISD2560 LS1
a loudspeaker, memory, an R3 R5
C6
VSSA XCLK VSSD
470k
4µ7
converter. 16V
070313 - 11
There are four basic mo-
dels; 2560, 2575, 2590 and
25120, the numbers follo-
wing 25 indicate the available recording time Recordings are made by following this se-
in seconds. The memory capacity of each ver- quence.
sion is actually the same but longer recording First switch S3 to record mode (a low on pin
times are achieved by using a lower sampling 27). A press of S2 now begins the recording
rate. The chip with the shortest recording which is ended by another press on S2; a third
time therefore offers the best audio quality. press of S2 starts the next recoding period
The circuit shown in the figure can be used and so on. This can continue until there is
for both recording and playback. A socket for nothing more to record or when LED D2
IC1 fitted in both circuits will allow the chip lights to show that the memory is full.
to be moved into the robot once the sounds Playback can be performed by momentarily
have been recorded. toggling S1 and switching S3 into ‘play’
384 384
L
310 circuits
elektor international media bv – 089018/uk
pagina 384
mode, now with each press of S2 the re- chip enters ‘fast forward’ mode where it ad-
corded messages will be sequentially played vances through the message at 800 times its
back. The recordings can be overwritten by normal playback speed.
toggling S1, switching S3 to record and then When the third message needs to follow the
using S2 to start recording from the begin- first for example, the processor sets A0 to ‘1’
ning again. and pulses /CE low to fast-forward through
the second message, waiting for the /EOM
Some flexibility in the playback mode allows flag to go low. Once this occurs A0 is reset to
individual messages to be linked together; ‘0’ and a low pulse on /CE plays back the third
each recorded message is terminated by an message.
EOM (End Of Message) flag when it is stored
in the chip. Instead of storing complete The /EOM output pulse can be less than 10 ms
phrases like ‘obstacle ahead’ for example it is wide so it is better to use it to interrupt the
more efficient to store ‘obstacle’ then ‘ahead’, processor rather than just poll its status. An
‘to the right’, ‘to the left’ and ‘behind’ and example C code listing has been written by
likewise for numbers ‘one’, ‘two’, ‘hundred’ the author for a 16-bit Texas MSP430 micro-
‘point’ etc allows voicing of the complete controller interfaced to this chip and is avail-
range of numbers from these basic elements. able for free download from the Elektor
website, ref. 070313-11.zip.
The minimum playback circuit shown in uses (070313-I)
the A0, PD, /CE and /EOM signals interfaced to
the robot microcontroller. For playback PD is Web Link
reset to ‘0’ and to play the first message a low www.winbond-usa.com/mambo/content/view/
pulse is given on /CE. With A0 at ‘0’ playback 153/283
occurs at normal speed but with A0 at ‘1’ the
385
R
310 circuits
elektor international media bv – 089018/uk
pagina 385
+5V
D1 RE1
+5V
+5V
1N4148
T1
R1
R5 R6 R7 R8
1k
D2 RE2
10k
3k3
10k
100k
BC547
5 1N4148
T2
8 4 R2
1 12
R B QA 1k
7 14
DIS A IC2 +5V
IC1 9 BC547
C2 QB
2 3 2 74LS90
TR OUT R0(1)
3 8
100n LM555C R0(2) QC D3 RE3
T5 6 6
C1 THR R9(1)
7 11
CV R9(2) QD
+5V
100n 1 5 1N4148
BC547 T3
MIC1 10 R3
C4 C3
1k
D4 RE4
10n 10n BC547
1N4148
T4
R4
1k
BC547
070092 - 11
The circuit can be tested in a simple manner. clock pulse test. Finally, connect four electri-
Power the circuit from a regulated 5 V (or 6 V) cal devices to the relay contacts.
supply. Temporarily disconnect the CLKA in-
put of the 7490 from the 555 output. Solder a The use of a 5 V regulated supply is rec-
wire on the CLKA input and use it to touch the ommended for this circuit. The relay contacts
positive supply rail. Each time a clock pulse is should be rated for 230 VAC as well as for the
applied in this way, RE1, RE2, RE3 and RE4 maximum current the electrical equipment is
should energise or de-energise in one of 16 likely to draw. All relevant electrical safety
different configurations. precautions should be observed when con-
Re-establish the connection between IC1 and necting mains powered loads to the relay
IC2 and clap your hands near to the micro- contacts.
phone. The relays should respond as with the (070092-I)
386
L
310 circuits
elektor international media bv – 089018/uk
pagina 386
47 Ω
today, an inclinometer was
a purely mechanical system,
with all the difficulties of C1 C4
220k
NC NC IC2 = OP284
impossible, at least very dif- 1
ADXL311
6 5
ficult. ST YOUT
7
Y
IC2.B
For a few years now, this
COM
6
3
has no longer been the 4
1
MCLR
11 18
C1 C4 RC0 RC7
12 17
RC1 IC3 RC6
100n 10n 13 16
RC2 RC5
2 8 14 15
8 RC3/SCL RC4/SDA
1
VDD IC2.A PIC16F876
2 7 3 9 21
BIAS XOUT OSC1 RB0
R1 10 22
IC1 OSC2 RB1 C5
4 5 2 23
220k
47n 47n 8 19
070305 - 12
387
R
310 circuits
elektor international media bv – 089018/uk
pagina 387
For our robotics application, we have decided where AX and AY are the analogue voltages
to adopt a relatively inexpensive accelero- supplied by the accelerometer when it is in-
meter in the form of the ADXL311 from Analog clined, and AX0 and AY0 the voltages supplied
Devices. Do note right away, however, that when it is perfectly horizontal.
this IC is no longer being produced, but is still As shown in Figure 1, the accelerometer ap-
widely available from retailers. If it should plication circuit doesn’t amount to very
eventually disappear completely, it could be much. The only important elements are in
replaced by the ADXL320, much more recent fact capacitors C2 and C3, which filter the ac-
and electrically compatible, only the pin-out celerometer output voltage. It actually has a
being different. passband of several kHz, and can therefore
The ADXL311 actually includes two highly react to very fast vibrations, not at all what we
sensitive accelerometers at right-angles, with want in an application as an inclinometer.
positioning better than 0.1E. Because of this, With the values chosen here, the passband is
and if it is placed parallel to the surface of the restricted to 100 Hz, easily enough.
Earth, it is influenced by the acceleration due The two opamps arranged as followers avoid
to the Earth’s gravity, and so can indicate any external influence on these filter capaci-
left/right inclination (roll) or forward/back- tors and allow the accelerometer to be con-
ward (tilt). In this way we create a dualaxis in- nected without special precautions to any
clinometer. microcontroller or ADC input.
These inclinations can be exploited in an ab- The only minor problem you might encounter
solute form if we want to know exactly the constructing this project is that the accelero-
angle between the inclinometer, hence the IC meter is in an SMD package, which is not al-
carrying it, and the ground, or in a relative ways easy for soldering onto an amateur PCB.
form, if we want just a limit indication of what There is now a module, ref. Accel, from Lex-
the robot can withstand before it topples tronic (www.lextronic.fr), that includes all the
over. components in Figure 1 mounted on a tiny
In the case of the ADXL 311 or the ADXL320, 15 × 20 mm PCB (see photo on next page).
the absolute inclination is given by the
equations: Using our accelerometer as an inclinometer
Tilt = arcsin (AX /AX0) and involves measuring its analogue output volt-
Roll = arcsin (AY /AY0) ages on both axes and subtracting from them
3 R2
47 Ω
21
C1 C4 +6V...+12V
1 24
SOUT VIN
100n 10n 2
SIN
2 8 3 22
8 ATN RES
1
VDD IC2.A IC3
2 7 3 5 20
BIAS XOUT P0 P15
R1 6 19
IC1 P1 P14
4 5 7 18
220k
4 23
47n 47n
070305 - 13
388
L
310 circuits
elektor international media bv – 089018/uk
pagina 388
the voltages at rest, that is, when the IC ‘ adjust according to the voltage output
socket is perfectly parallel to the ground. ‘ when the inclinometer is horizontal
Figure 2 shows an example of the use of this to recover the tilt information using a Cubloc
inclinometer with a PIC microcontroller with CB220. While you might write, for example,
a built-in ADC, while Figure 3 shows the same
type of circuit, this time with a Cubloc CB220. tilt = Adc _ Read(0)
We are not giving you a program for exploi- tilt = tilt - 512
ting the information supplied by the inclino- ‘ adjust according to the voltage output
meter as, in both cases alike, it takes just two ‘ when the inclinometer is horizontal
instructions to access the tilt or roll infor-
mation. So for example you would write to recover the tilt information with a PIC pro-
grammed in Basic (in this example, Mikro-
tilt = Adin(0) Basic compiler and 10-bit ADC).
tilt = tilt – 512
The same instructions will obviously be used
for roll, but using analogue channel 1 if you
have adopted the circuit diagrams of Figures
2 or 3.
389
R
310 circuits
elektor international media bv – 089018/uk
pagina 389
390
L
310 circuits
elektor international media bv – 089018/uk
pagina 390
In the circuit diagram, Sw2 is shown opera- P2 lets us set the latching point of the lever in
ted, corresponding to the catapult’s rearmed the re-armed position.
position. Referring to the drawing in Figure 1, Figure 1 shows two firing positions (greyed of
it’s easy to follow the operation of the cata- the lever, and the corresponding positions
pult. for the rubber stop (numbered 1 & 2).
To adjust the firing range, you simply need to
When the solenoid is briefly powered via the know that, logically enough, in position 1 the
‘FIRE’ input that controls transistor T1, the ball will go higher, and in position 2 the ball
lever L is released, pulled up by spring R. This will go less high. Everything depends on how
lever ends its travel up against the rubber it is being used: if you want to drop a ping-
stop G attached to the motor’s servo arm, pong ball in a pocket in the ground, it’s best
wheel P. to plan on getting there via successive boun-
In coming to rest against this stop the projec- ces, and so to fire higher. On the other hand,
tile is fired, and the lever also operates Sw1, if you are aiming for a basket high up, you
energizing the relay RE1, which in turn need to aim ‘spot on’ into it, and so allow the
latches via its contact re1B and microswitch lever to go higher.
Sw2 (by this time returned to its rest state). Once the adjustments have been set, you’ll be
amazed by the repeatability of this system.
The servo motor starts to turn clockwise and
the rubber stop forces the lever back to its re- Construction: electronics
armed position. At the end of the travel, the The electronic part is relatively simple and
lever hooks under the trigger catch; at the can be built on a small piece of prototyping
same time, Sw2 is operated, and unlatches board. The DIL relay RE1 can be fitted into a
the relay, which goes back to rest, comman- turned-pin DIP14 socket.
ding the servomotor to return to the firing The servomotor connector can be made using
position. three sections (a 10 mm length) of 2.54 mm
Preset P1 lets us adjust the upper position of (0.1") pitch SIL pinheader strip. Mark the
the stop and thereby the range of the shot, as signal pin, so as to avoid any mistakes when
explained in Figure 3. connecting the servomotor.
+4V8...+6V
R2
4k7
1RT
Sw1
re1A
RE1
Sw2 P2 P1
1RT 2RT-6V 8 4
R
7
DIS
R1
D1
IC1 K1
D2
68k
3
re1B OUT
6
NE555
fire button 1N4148 electromagnet THR
6V 2
T1 TR
S1 R3 Servo
1N4148 CV
4k7
1 5
R4 2N2219 C1 C2 C3
10k
391
R
310 circuits
elektor international media bv – 089018/uk
pagina 391
The IC can be fitted into an 8-pin socket. Pre- lowest position, which will slacken the sole-
sets P1 and P2 should preferably be multi- noid spring. Check that the catch hooks pro-
turns, horizontal or vertical. perly onto the lever by at least 1 mm. This
action must take place without forcing, the
Check your wiring carefully. Power the circuit solenoid spring must allow the catch to hinge
without IC1 or the relay fitted. Check the to the right before hooking into the tube.
supply rails to IC1 and to the commons of the Check that the solenoid is properly fitted
switches, which will be connected to the cir- with its return spring, which may be fitted be-
cuit via wires of around 10 cm or so. Check tween the coil and the armature, or actually
the presence of +VCC on the central pin of inside the coil, within the space where the ar-
the servomotor connector. mature moves.
Connect the ‘FIRE’ input briefly to +VCC and The spring must push the armature lightly so
check that the solenoid operates. that it comes back out of the coil once it has
been activated.
Construction: mechanics
Although not terribly complicated, the Adjustment
mechanics do require a little care all the Setting-up is easy. Don’t fit the relay into its
same. socket. Put the lever into the re-armed posi-
tion and check that the catch holds it properly
The drawing in Figure 2 details the key parts in the horizontal position. Release the catch
and elements of the system. The chassis is and make sure the lever is pulled up properly
made mainly from a piece of Lsection alu- by the firing spring.
minium angle, or an equivalent olded section.
The servomotor, fitted with an approximately Apply power; the servomotor will take up a
35 mm diameter wheel as its servo arm, is random position. Using P2, get the servo-
mounted on the vertical plane of this angle. motor, via the rubber stop, to position the
The pivot for the lever is slightly forward of lever horizontally until the catch engages.
the servomotor shaft. In my own case, I made Adjust the position of Sw2 so that it is opera-
this lever out of 5 mm square brass tube. This ted by the small bracket attached to the lever.
hollow section allows the little catch to hook If the servomotor fails to operate, check the
into the lever once it is re-armed. This catch is circuit, the soldering, and that the servomo-
operated by the solenoid via a small connec- tor connector is the right way round – i.e. that
ting rod. The solenoid is a 6 V type, mounted the signal and earth pins are not reversed.
under the horizontal plane of our aluminium Turn off the power. Fit the relay into its
angle. socket. Re-apply power. The servomotor
The positioning of the microswitches is im- should take up some random position. Adjust
portant, particularly that of Sw2, whose posi- P1 to bring the roller into any firing position
tion is set once the optimum re-arming (1, for example). Turn off the power and
position has been set. This setting can only be adjust Sw1 so it is operated by the lever in its
done once the electronics described above upper position.
have been built. Sw2 is mounted onto the Re-apply power. The catapult should re-arm
angle by way of a small bracket with two all by itself and the servomotor should then
oblongs fixing slots, to allow the microswitch return to the upper position as described
to be positioned. above. Everything is now working. That’s
For Sw1, two curved slots will need to be fine. Operate the solenoid to check that firing
made in the vertical plane, where the servo- takes place correctly.
motor is mounted, so as to be able to adjust You can now fit the lever with a support for
the firing range, in conjunction with preset the projectile (ball). It’s worth noting that the
P1. unused NC contact of Sw2 carries +VCC indi-
Once the mechanics have been completely cating the catapult is re-armed…
finished, the lever should be put into the (070210-I)
392
L
310 circuits
elektor international media bv – 089018/uk
pagina 392
330 Ω
10k
10k
R2
1 40
470 Ω MCLR/VPP RB7/PGD
39 R5
R3 JP1 RB6/PGC
2 38 470 Ω D5
470 Ω RA0/AN0 RB5/PGM
3 37 R4
P1 RA1/AN1 RB4/AN11
S1 4 36 470 Ω
C3 RA2/AN2 RB3/AN9 PWR
5 35 S2 S3
RA3/AN3 RB2/AN8
100n 6 34
10k RA4/T0CKI RB1/AN10
7 33
RA5/AN4 RB0/AN12
8 IC1
RE0/AN5
VDD 9
RE1/AN6
10
RE2/AN7
R8
PIC18F4550
15 30
1Ω
C4 C5
100n
20MHz
22p 22p
060342 - 11
393
R
310 circuits
elektor international media bv – 089018/uk
pagina 393
394
L
310 circuits
elektor international media bv – 089018/uk
pagina 394
C:\MCHPFSUSB\Pc\MCHPUSB Driver\Release\
C:\MCHPFSUSB\Pc\Pdfsusb\PDFSUSB.exe.
The same if you click the ‘/ Execute’ button in Having done this you can reload the Demo
the application. That’s why the first device de- project, or any project for that matter, and all
tected by the host was not the bootloader – it should work fine.
was a program to test with the other part of
the Pdfsusb tool (Demo mode), this is the Build it!
upper left tab behind the Bootload Mode tab. Now, it is time to explore the example appli-
cation. As before, reset the microcontroller
This mode is shown in Figure 4. It allows
reading an approximation of the position of
4
the potentiometer connected to RA0, control
the state of the LEDs connected to RD2 and
RD3 and measure a temperature of an SPI sen-
sor that’s not actually connected to the board
(so don’t pay attention to the temperature
readings).
395
R
310 circuits
elektor international media bv – 089018/uk
pagina 395
Listing 1
/** D E F I N I T I O N S *****************************************/
#define EP0_BUFF_SIZE 8 // 8, 16, 32, or 64
#define MAX_NUM_INT 1 // For tracking Alternate Setting
//#define USE_SELF_POWER_SENSE_IO
//#define USE_USB_BUS_SENSE_IO
C:\MCHPFSUSB\fw\Hid02/_outut/NICAPM.hex
The window of the demo application should Project ! Add to project ! hid.lib
look like Figure 5, showing the signals of
Channel 0 (AN0, pin 2) and Channel 1 (AN1, 2 Change the Data alignment from Quad
pin 3). There’s also the archive file called word to byte by doing:
project.zip if you want to modify something in
the PC project. Project ! Options ! Advanced Options !
If you want to make a new Builder project, Data alignment.
you only have to look after two things: (060342-I)
For enhanced operational reliability turns out to be empty at the most inoppor-
tune moment. As a user, you are unexpect-
Paul Goossens edly confronted with the fact that the circuit
suddenly doesn’t work any more. Sometimes
Using rechargeable batteries to power cir- this is only a minor inconvenience, but at other
cuits is a proven method for providing energy times it can be a catastrophe. For instance,
to mains-independent equipment. A major just imagine what happens to a model air-
disadvantage of this is that the battery usually plane if the radio receiver stops working in
396
L
310 circuits
elektor international media bv – 089018/uk
pagina 396
Solution
The solution to this prob-
lem is actually quite simple:
use two batteries! When
one of the batteries be-
comes discharged, the sec-
ond one can take over and
continue supplying power.
Of course, all this must hap-
pen automatically, so we need a handy circuit Simple
that takes care of everything for us. The operating principle is simple: IC2
The design presented here is intended to be measures the terminal voltage of battery A. If
used with circuits (such as receivers used in it drops below 4.38 V, the RESET output goes
models) that use NiCd batteries composed of low, and otherwise it remains high. IC4 does
four cells. the same thing, but for battery B.
The circuit is quite compact, and thanks to Both signals go to a flip-flop consisting of
the accompanying PCB populated with SMDs, IC1a and IC3d, which determines which of the
it is easy to fit into existing equipment. batteries is to be used.
397
R
310 circuits
elektor international media bv – 089018/uk
pagina 397
100%
If the voltage across battery A is too low, the
output of IC1a will always be high. As a conse-
quence, battery B will be active. The same Components list
thing applies in reverse to the output of IC3d. (all R and C: SMD 0805 case)
When both batteries are discharged, they will
both power the circuit, in keeping with the Resistors
motto ‘better a little bit of juice than no juice R1, R2, R5, R6 = 100 kΩ
at all’. R3, R7 = 1 MΩ
R4, R8, R9 = 10 kΩ
R10, R11 = 1 kΩ
Components D3, R8 and C3 provide a switch-
on delay that causes battery switch-on to be Capacitors
delayed somewhat. This is because it is unde- C1-C6 = 100 nF
sirable to have both batteries power the cir-
cuit at the same time during switchover from Semiconductors
one battery to the other. That would cause D1-D4 = BAT54 (SOT-23)
D5, D6 = LED red (SMD 1206)
large equalization currents to flow due to the IC1, IC3 = 4093 (SOIC-14)
difference between the terminal voltages of IC2, IC4 = LM809M3-4.38 (SOT-23)
the two batteries. T1, T2 = IRF7329 (SOIC-8)
T3-T6 = FDV301N (SOT-23)
Switch
The best choice for the switching device is a Miscellaneous
Connecting wires
FET instead of a bipolar transistor. This saves
PCB no. 070343-1
energy, since no base current is necessary. A (see www.elektor.com)
disadvantage of a MOSFET is that it always
has an intrinsic diode. This diode is quite an-
noying in this circuit, since the one battery
can charge the other battery via the diode. A
simple solution would be to wire a diode in FET conducts in both directions when it is
series to prevent this. switched on. This eliminates the effect of the
Unfortunately, a diode always has a voltage forward voltage of the internal diode.
drop (approximately 0.3 V with a Schottky LEDs D5 and D6 indicate which battery is in
diode). use.
398
L
310 circuits
elektor international media bv – 089018/uk
pagina 398
(K2 and K3). Then connect output K1 to the use. If things every get so far that both batte-
circuit to be powered. ries become deeply discharged (Heaven for-
bid!), this can be recognised by the fact that
Switch on the supply voltage with switch S1. both LEDs are lit.
The LEDs now indicate which battery is in (070343-I)
Abraham Vreugdenhil
Drive mechanism
To enable the robot to drive the ball, the
shafts of the motors are fitted with lengths of
bicycle valve tubing to give them grip. The
shafts rest directly on the inner surface of the
ball. The robot also has a single support
wheel made from a plastic bead. A round
hoop is fitted to the top of the robot so it will comparator. A 1-kΩ resistor is connected in
always land on its ‘feet’ (wheels) if it is thrown series with each BPW41 in order to limit the
with a swinging motion. current through the sensors if the light is
excessively bright. A 47-kΩ potentiometer is
Motors connected to the second comparator input.
The rotational speed of the motors is on the This is used to set the light sensitivity.
high side. If you were to let the robot run con-
tinuously, it would pass through the available The two eyes are formed by LEDs, which are
space rather quickly. To avoid this, the mo- connected to the microcontroller by a 470-Ω
tors are switched on for one second and then resistor. The two motors are driven by the
off for one second. After they are switched microcontroller via Darlington transistors.
off, the light level is measured and a new deci- The author did not have these on hand, so an
sion is made as to which direction the ball IC with an array of seven Darlington transis-
should roll for another second. tors (type ULN2003) was used for the proto-
type, with only two of the transistors actually
Electronics being used. If more power is needed, two or
The selected microcontroller is an 89C2051. more inputs and outputs can simply be con-
Among other things, it incorporates a com- nected in parallel to boost the power.
parator that is used in this design. Two
BPW41 photodiodes connected in series are The motors are powered by two AAA batte-
used as the light sensors. The junction of the ries in series, and the remaining electronics is
two diodes is connected to one input of the powered by a 9-V block battery.
399 399
R
310 circuits
elektor international media bv – 089018/uk
pagina 399
R3 R4 20 R M M L controller to be reset. To
D1
prevent this, it’s a good idea
470 Ω
470 Ω
BP41W
the two systems.
14 11
P1.2 IC1 P3.7 9
15
P1.3 DS
13 9 1 16
P1.1 P3.5 I1 O1
12 8 2 15
16
P1.0 P3.4
7 3
I2
IC2
O2
14
Behaviour
P1 P1.4 P3.3 I3 O3
17
P1.5
AT89C2051
P3.2
6 4
I4 O4
13 and/or extension
18
19
P1.6 P3.1
3
2
5
6
I5 O5
12
11
A possible extension would
be an RC5 receiver, so the
D2 47k P1.7 P3.0 I6 O6
7 ULN2003 10
X1 X2 I7 O7
BP41W 5
X1
4 10 GND robot could receive com-
R2 8
mands from a ‘standard’ re-
mote control unit. This
1k
12MHz
would make it possible to
070295 - 11
steer the ball in a particular
direction or select one of
2
+12V +5V
several different behaviour
R2 K1 patterns (such as sight
13 seeking, light avoiding, or
2k7
25
12
random).
T1
R1
24 There are many conceivable
10k
11
23
behaviour patterns for ro-
BC547 10 bots. The compiler used for
22
9
the microcontroller in this
20
21 robot, BASCOM-8051, pro-
vides a specific command
8
1 20
P3.2 P1.4 18
7 15
behaves as a light-seeking
9 13
P3.5 P1.1 4
11 12
P3.7 P1.0
robot.
16
5
AT89C2051 3
XL1
4 15
XL2
2
T2
10
14 Programming
The 89C2051 can be pro-
R3
1
10k
BC547 R5 DB25M
grammed using a simple
C1
1k programmer. BlowIt is a
programmer consisting of
just a few voltage regula-
1n
070295 - 12
tors, two transistors, and a
400
L
310 circuits
elektor international media bv – 089018/uk
pagina 400
few resistors and capacitors [1]. Of course, it This programmer can easily be driven by
also has a 20-pin IC socket and a 25-way D- BASCOM-8051 or BASCOM-LT. The software
sub connector. All of this can be assembled for Bolo can be downloaded free of charge
on a piece of perforated prototyping board. from the Elektor website (file no. 070295-11).
The author also added a transistor and an LED (070295-1)
to indicate when data is being written to the
microcontroller. Web Link
The schematic diagram for the BlowIt pro- [1] www.geocities.com/dinceraydin/
grammer and additional information are 8051/index.html
available on the Internet.
Peter Zirngibl
401
R
310 circuits
elektor international media bv – 089018/uk
pagina 401
IC4
+3V LP2950 +5V
3V
VCC C3 C2 C1
R4 R2 R3
+3V
220 Ω
4k7
1k
K1 R1 D6 RE1
2 1 D1 D2
1k
7 20
4 3
VCC AVCC
6 5 1 5
PC6(RESET) PD3(INT1) D3
6 1N4148
PD4(XCK/TO)
10
ISP IC1
SCK 19 23 1 +VS 18 OUT1
FB1 PB5(SCK) PC0(ADC0) I1 O1
MISO 18 24 2 17
FB2 PB4(MISO) PC1(ADC1) I2 O2 OUT2
MOSI 17 25 3 16
FB3 PB3(MOSI/OC2) PC2(ADC2) I3 O3 OUT3
16 26 4 IC2 15
FB4 PB2(SS/OC1B) PC3(ADC3) I4 O4 OUT4
15 27 5 14
FB5 PB1(OC1A) PC4(ADC4/SDA) I5 O5 OUT5
14 28 6 ULN2803 13
FB6 PB0(ICP) PC5(ADC5/SCL) I6 O6 OUT6
13 7 12
PD7(AIN1) I7 O7
8 11
ATmega8L I8 O8
4 21 VEE
PD2(INT0) AREF
11
PD5(T1) PD0(RXD)
2 +3V 9 Reset Bluetooth
12 3
PD6(AIN0) PD1(TXD)
D4
GND XTAL1 XTAL2 AGND
R7
8 9 10 22 9 8
X1 GND RESET 1k
S1 JP1 JP2 R5 10 7
ENV1 CTS
220 Ω
11 6
ENV0 RTS
C4 C5 12 5 +3V
LSTAT_0 TX
13 4
LSTAT_1 RX
22p 22p 14 3
Host_wu ISEL2
15 2
TX_LED ISEL1
7,3728MHz R6 16 1
VDD_DIGI VCC
220 Ω
IC3
Blue Nice Com III
RX D5
TX
070126 - 11
402
L
310 circuits
elektor international media bv – 089018/uk
pagina 402
Elektor Electronics, and further information is for use with a Smartphone). The two Blue-
provided on Atmel’s website. The sensor in- tooth devices, the Smartphone and the recei-
puts can be used for any desired purpose or ver board, now need to be ‘paired’ (which
simply left floating. only needs to be done once). The program
can now be started, and the COM port set
With the hardware built we next turn to the with a click or two of the mouse on the up-
accompanying Smartphone software. You ward- and downward- pointing arrows. The
will first need to install the appropriate ver- central square opens the interface, creating a
sion of Compact Framework 2.0 (available for connection with the receiver. The arrows
download from Microsoft): now allow the outputs on the receiver board
to be switched on and off; the sixth output is
à Windows Mobile 5.0 Pocket PC and switched by pressing the space key.
Smartphone: NETCFv2.wm.armv4i.cab;
Towards the top of the display the six sensor
à Pocket PC 2003 and 2003 SE: inputs are represented as LEDs. If you should
NETCFv2.ppc.armv4.cab; move out of range of the receiver, these LEDs
will be extinguished and a timeout bar will
à Windows XP: netcfsetupv2.msi. appear. If the timeout period should expire
without a valid signal being received the
Next, copy the file avrblueremote.exe to the interface will be closed.
target platform (for example onto an SD card (070126-I)
403
R
310 circuits
elektor international media bv – 089018/uk
pagina 403
The DC motor seems to be a standard type. It against potential overloads. This comprises
is located in the larger-diameter light-grey cyl- over-current protection in the form of a
indrical part, under the Lego logo. Powered resettable Polyswitch® fuse, and a 15 V surge
from 9 V, it draws 60 mA off load with a speed limiter.
of 170 rpm (360 rpm and around 3.5 mA for At one end of the block is the orange drive
an RCX motor). disc. At the other end is the RJ11 power input
The internal step-down gearing increases the and data output connecter. It has a key to
torque available at the output disc, which is avoid confusion with a standard telephone
great for power applications. On the other cable.
hand, the slower rotation will be seen as a Interested readers will find the character-
drawback for speed applications. istics and views of the innards of the block on
The data provided by the rotary optical en- Philo’s web pages [1], [2].
coder allow the NXT unit software to determine (070371-I)
the angle of rotation to the nearest degree.
Not having dissected the block, we can only
Web Links
surmise how this precision is obtained from Philo’s NXT motor internals:
the encoding disc that only has 12 slots. The www.philohome.com/nxtmotor/nxtmotor.htm
block contains two electronics assemblies: Lego 9 V Technic Motors compared:
one is the module that conditions the signal www.philohome.com/motors/motorcomp.htm
from the optical detector, the other protects
For robots and other control applications With each pulse the resistance of the LDR,
and hence the voltage at the input to opamp
Markus Bindhammer IC1.A, changes. The gain of the opamp is set
by potentiometer P1 in the feedback path.
This pulse sensor is designed to be used for The sensitivity of the circuit can be adjusted
communication between man and machine, using potentiometer P2 at the input to com-
giving a robot the ability to react to the pulse parator IC1.B.
rate of its human mentor. The digital output
of the circuit makes it useful in other applica-
tions as well. 15mm 21 mm
through the blood vessels, the finger be- heat shrink sleeve
comes slightly more opaque and so less light
reaches the LDR. This can be converted into
plastic tube 070006 - 12
an electrical pulse.
404
L
310 circuits
elektor international media bv – 089018/uk
pagina 404
10k
P1 8
powers up a standard
100k
R5
220 Ω
built around IC2, a 555
1 5 T1
470n IC1.A R6
2 7
IC1.B
timer. At its output this pro-
1k8
6
BD139
duces a signal modulated by R7
220 Ω
LED3 IC1 = LM358
1k
47k
P2
100k LED2
22k
8 4
R
to IR receiver module IC3. TSOP1136 C
B
E
E B T2
DIS
7
R8
6k8
1k8 OUT THR
100 Ω
1 5
2
10n 1n
TSOP1136
the receiver module can be 070006 - 11
405
R
310 circuits
elektor international media bv – 089018/uk
pagina 405
+5V
R2 R3 R4 R5 R6 R7
C5
10k
10k
10k
10k
10k
10k
20
10µ
16V
1
RST 9
IC2 DS
8 19 1 16
T0/P3.4 P1.7 I1 O1
13 18 2 15
P1.1/IN– P1.6 I2 O2
14 17 3 14
P1.2 P1.5 I3 IC3 O3 M1
15 16 4 13 M
P1.3 P1.4 I4 O4
AT89C2051 5 12
I5 O5
12 2 6 ULN2003 11
P1.0/IN+ RXD/P3.0 I6 O6
3 7 10
TXD/P3.1 I7 O7
9 6
T1/P3.5 INT0/P3.2 GND
11 7
P3.7 INT1/P3.3 8 R8 R9
X1 X0
10k
10k
M1 = 5V Stepper Motor
10 5 4
X1
R1
S1 S2 S3 S4 C4 C3
8k2
IC1
33p 12MHz 33p +9V 7805 +5V
47µ 100n
16V
070228 - 11
motor has one permanently magnetic axle schemes are available to drive the motor:
called the rotor. This is surrounded by a fixed ‘full-step’ or ‘half-step’. The two modes are
part called the stator. Usually, stepper motors summarized in Table 2 and Table 3 respect-
have four stator wires with two or one ively.
common wire, which is normally connected Applying half-step pulses to the motor will in-
to the positive supply voltage. crease the accuracy at which the spindle can
By applying a controlled sequence of pulses be turned. In the case of our 1.8-degree angle
to the individual stator windings, the rotor motor, half-step driving then requires 400
will start to rotate. Stepper motors may differ steps per revolution.
in size, shape, power, supply voltage, cost, Another important advantage of half-step
accuracy, and so on, but importantly in the pulsing is more motor power, which usually
number of steps that make up one complete translates in more torque.
spindle revolution. This property also deter-
mined the step angle as shown in Table 1. The circuit of the motor driver is designed
For example for a motor specified as having a around an Atmel microcontroller type
1.8-degree angle, 360 / 1.8 = 200 pulses for a AT89C2051 ticking at 12 MHz and one high
complete spindle revolution. Two pulsing voltage/high current Darlington transistor
array type ULN2003.
Table 1 The motor drive pulses generated by the
Step angle ( ) Staps per revolution microcontroller under firmware control are
0,72 500 fed to the ULN2003 via four port lines P1.4
1,8 200 through P1.7. The motor’s stator windings
2,0 180 are connected to the corresponding output
2,5 144 pins on the ULN2003. The ULN2003 can
5,0 72 supply up to 500 mA on each output pin. Note
7,5 48 that a 5-V stepper motor is used in this cir-
15 24 cuit.
406
L
310 circuits
elektor international media bv – 089018/uk
pagina 406
The source code file and the firmware (hex increased torque and accuracy, at the cost of
file) for the AT89 micro may be downloaded speed. That is why stepper motors powering
free of charge from the Elektor website as ar- wheels etc. are controlled such that they start
chive # 070228-11.zip. and end their operation in half-step mode,
with full step mode in between to achieve
After constructing your circuit, power it up. maximum speed.
Press the Full Step or Half Step button. Then (070228-I)
press Left or Right and you will see your
motor start to rotate using the mode selected.
You can change between full and half step at
any time.
All this is based on the assumption that you
have wired up your motor correctly. The
AT89 source code contains a number of direc-
tions to help you ‘change wires’ in software
rather than by soldering and getting confused
by the different wire colours.
Jürgen Wickenhäuser in the part number stands for ‘low pin count’:
the NXP (formerly Philips) LPC900 family [1]
The LPC900 family is the Swiss Army knife of consists of a range of small and easy-to-use
8051-compatible microcontrollers. The ‘LPC’ microcontrollers ideal for small-scale high-
407
R
310 circuits
elektor international media bv – 089018/uk
pagina 407
408
L
310 circuits
elektor international media bv – 089018/uk
pagina 408
Operation is straightforward.
100%
409
R
310 circuits
elektor international media bv – 089018/uk
pagina 409
An optimising C compiler is
also needed to write
programs for the LPC900 fa-
mily. There are various
commercial products avail-
able; here we will briefly Figure 5 The C/51 compiler uses a well-structured classical ‘make’
discuss how to use µC/51 system.
[4]. For practically all
LPC900 family devices the free demonstration For example, even with this very tiny CPU we
version of the compiler is entirely adequate. have a fully-featured ‘printf()’ function call.
The only restriction of the free version is the The system also includes a reliable and com-
8 kB code size limit, but this is already prehensive floating-point library.
enough to write very complex applications
for an 8051-compatible microcontroller, The µC/51 system was developed as a tool for
because the compiler produces very compact the company Geo-Precision [5], and has been
code. used and maintained there for years. The soft-
In particular, the compiler is very parsimoni- ware tools work very well together and make
ous with the limited internal RAM in the development very quick: there are just three
microcontroller, using a graph-based optimi- steps from source code to working program.
sation algorithm to enable multiple re-use of For demonstration purposes we used an
memory areas. 89LPC922 with an LED connected to port pin
410
L
310 circuits
elektor international media bv – 089018/uk
pagina 410
411
R
310 circuits
elektor international media bv – 089018/uk
pagina 411
2k49
6
when the output voltage BIAS
TPS74201
reaches regulation (‘power 1
SS
TPS74401
FB
2
4k99
*
1µ 4µ7 1µ
and has a TRACK pin which
allows the user to input a
ramp signal for the output * zie tekst
voltage to follow, effec- U IN
5 IC1 3
U OUT
2k49
sequencing. The relevant 6
BIAS
4k99
respectively, and have an SS 1µ 4µ7 * 1µ
Figure 2 Tracking LDO TPS74301 with simulta- Figure 3 Tracking LDO TPS74301with ratiome-
neous startup (R4 = 10k ). tric startup (R4 = 1.78k ).
Timebase: 2 mV/div. Timebase: 2 mV/div.
Figure 4 Soft-Start LDO TPS74201 and Figure 5 Soft-Start LDO TPS74201 and
TPS74401 with 1ms soft startup (C4 = 1nF). TPS74401 with 10ms soft startup (C4 = 10nF).
Timebase: 2 mV/div. Timebase: 2 mV/div.
412
L
310 circuits
elektor international media bv – 089018/uk
pagina 412
413
R
310 circuits
elektor international media bv – 089018/uk
pagina 413
Servo legs
Developing a nice mechan-
ical design for the legs is a
difficult task. There are
many conceivable possibili-
ties using rods and levers,
S4 +7V2
1
IC2
BT1
7805 +5V
7V2
D4 D6
D1 D2 D3
VCC D5 D7
R1 R2 R3 R4 R5
RST
470 Ω
470 Ω
470 Ω
470 Ω
470 Ω
20
L S3 1 11 Servo1
RST PD6
16
IC1 PB4
PIR sensors
17 Servo2
M PB5
18 2
PB6 PD0
19 3 Servo3
PB7 PD1
R 6
PD2
AT90S2313 7 Servo4
PD3
12
PB0
13 Servo5
PB1
MOSI MISO SCK
8 14
PD4 PB2
9 15 Servo6
PD5 PB3
XTAL1 XTAL2
Servo7
S1 S2 5 4 10
L R X1
Servo8
GND
8MHz
2 4 6 8 10
ISP connector
1 3 5 7 9
MISO
SCK
RST
MOSI
414
L
310 circuits
elektor international media bv – 089018/uk
pagina 414
each of which has its specific advantages and robot’s body must be inverted, since other-
disadvantages. In this case, we decided to use wise these legs would walk backward.
a very simple design. There are four legs, and the number of steps
per leg is 28. In order to obtain a stable wal-
Two servos are strapped together using cable king motion, the standard offset between the
ties. The housing of one servo is secured to a four legs is set to seven positions in the series
Plexiglas base plate, and an aluminium rod of numbers (e.g. left front 1, right rear 8, right
with a diameter of 6 mm is fitted to the shaft front 15, and left rear 22).
of the other servo. The first servo acts as a hip To enable the robot to turn, we retard the
joint, while the other one acts as a knee joint. motion of the two left legs and advance the
All four legs are build using this construction. motion of the two right legs.
If you look at the walking motion of a human When the robot is walking, all 28 steps of the
leg, you see than the knee joint cannot bend walking motion are always executed before
any further forward than the fully extended the sensor information is examined again,
state. The knee can bend backward much which means a complete stepping motion of
further, up to nearly 180 degrees. By contrast, the legs is executed each time.
the hip joint can bend forward as well as This simplifies the structure of the software
backward. The servos are fitted such that the and ensures that the legs are always in the
legs of the robot have the same freedom of same state when a new decision regarding
motion. the walking direction must be taken. The
feelers have sufficient range of motion that
The walking motion of each leg is divided into the robot can still manage to move after a full
28 steps. The leg moves backward slowly in step has been completed.
22 steps, and then forward quickly in 6 steps.
The positions of the knee and hip servos cor- Feelers
responding to these 28 steps are stored in a Two simple microswitches are used for the
table. By operating the servos at a fixed inter- feelers (i.e., antennae or whiskers). A steel
val using the values from this series of num- wire (bicycle spoke) is attached to each of the
bers, we obtain a nice walking motion of the microswitches. A sliding clip is fitted to the
leg. The servos on the other side of the spoke and then slid over the microswitch.
415
R
310 circuits
elektor international media bv – 089018/uk
pagina 415
Two nuts are fitted underneath one of the electronics necessary to generate a digital
switches so it is not at the same height as the signal at the output. All of this for less than 10
other one. Otherwise the two feelers would quid per sensor element!
interfere with each other too much. The In principle, each of the sensor elements has a
feelers are connected between two micro- detection field of view of 140 degrees. In
controller input pins and ground. No pull-up practice, the angle is larger than this due to
resistor is necessary, since the microcontrol- reflections and the like. Collimation and
ler has built-in resistors. The feeler switches screening by means of pieces of electrical
are closed when they are not activated. conduit with a length of 2 to 3 cm is thus not a
bad idea.
Eyes If the sensors are arranged so their fields of
The eyes of this robot do not function as sen- view overlap, we can distinguish five sensor
sors. They are purely decorative. The eyes regions.
consist of two 8-mm red LEDs connected in To make the activity of the PIR sensors visi-
series. They are powered from the 5-V supply ble, a LED is connected to the output of each
via a 150-Ω current-limiting resistor, and they PIR sensor. These LEDs are connected to the
are connected to an output line of the micro- 5-V supply via resistors. The LED is on if the
controller. The eyes switch from on to off af- PIR sensor does not detect anything, and it
ter each step, but they remain in a fixed state switches off if the associated PIR sensor de-
while the robot is moving backwards or tur- tects a moving warm object.
ning, depending on the motion that is being
performed. Microcontroller and compiler
The selected microcontroller is an Atmel
PIR sensor AT90S2313 (see the schematic diagram in
Various models of PIR are available commer- Figure 1).
cially, such as the Eltec 422 from Acroname. It has 2 kB of program memory, which provi-
The main disadvantage of this model is its des plenty of room to program intelligent be-
price. There’s also the HI-859 from Conrad. haviour. The AT90S2313 has 15 I/O pins, of
Its disadvantage is its inconvenient electrical which three can be used for ISP. An ISP port is
interface. The signal from this sensor must quite handy during testing and in case of fu-
first be amplified before it can be used. ture software extensions. This port is fitted to
As an alternative, we selected a wellknown the robot using a 10-way CANDA connector.
sensor that is relatively inexpensive: a motion You can program the device using the Sample
detector available in DIY
home improvement shops AT90S2313 pin assignments
for less than £ 10. Pin Function Connection
The first thing to do is to 2 PD0 Left front leg hip
remove the PCB with the 3 PD1 Left front leg knee
sensor from the motion de- 6 PD2 Left rear leg hip
tector, after which you can 7 PD3 Left rear leg knee
fit the sensor to a separate 8 PD4 Left feeler
PCB. Three sensors are 9 PD5 Right feeler
placed next to each other so 11 PD6 Right eye
the total field of view can be 12 PB0 Right front leg hip
divided into different re- 13 PB1 Right front leg knee
gions. This yields more in- 14 PB2 Right rear leg hip
formation that can be used 15 PB3 Right rear leg knee
to influence the robot’s 16 PB4 Left eye
behaviour. The circuit boards 17 PB5 – MOSI Left PIR sensor / ISP via jumper
18 PB6 – MISO Middle PIR sensor / ISP via jumper
for the sensor elements are
19 PB7 – SCK Right PIR sensor / ISP via jumper
still useful. They hold all the
416
L
310 circuits
elektor international media bv – 089018/uk
pagina 416
Electronics Programmer [1], among other op- 3 Check for obstacles after each step. If an
tions. Only three resistors are necessary to obstacle is detected, walk backward and
connect a printer port to this port. then turn away from the obstacle
(sight = 6)
Quite a few I/O lines are necessary for control- 4 If sight < 5, check the PIR sensors. If
ling the hardware, which comprises eight ser- something is detected, turn in the direction
vos, two feelers, two LEDs, and three PIR of the detected object. The options for
sensors. This makes a total of 15 devices. For the turning direction are: left, forward
this reason, the three PIR sensors are connec- left, straight ahead (no turn, with sight =
ted to the robot in parallel with the ISP port 6), forward right, and right (sight = 6)
via jumpers. In normal operation, the PIR sen-
sors are connected to the robot. If a new pro- Conclusion
gram must be downloaded to the robot, the The objective was to build a four-legged
jumpers must be switched over to make the robot with interesting behaviour. This objective
ISP port available. was ultimately achieved, and with a reasona-
bly limited budget. The microcontroller mem-
The robot software was programmed in Basic ory is pretty well filled by the current
and compiled using BASCOM-AVR [2]. This an software, but it would still be possible to de-
excellent compiler for Atmel AVR micro- vise a more efficient behaviour algorithm.
controllers. The freeware version of BASCOM- This means that there are plenty of options
AVR can easily handle the 2-kB program for experimenting with this robot. Thanks to
capacity of the AT90S2313. the onboard ISP port, programming the robot
The software for the Hunter can be down- is easy. This robot is a means, not an end.
loaded free of charge from the Elektor web- Let’s hunt!
site as item no. 070283-11.zip. (070283-I)
Power supply
Web Links
The robot is powered by a 7.2-V rechargeable [1] http://avrhelp.mcselec.com/
battery of the type used in models. An on/off Sample_Electronics_cable_programmer.html
switch is fitted to the battery. A regulated 5-V [2] www.mcselec.com
supply voltage for the electronics is gener-
ated by a an old friend in this area: a 7805 in a
TO220 package. The servos are powered di-
rectly from the battery via the switch.
Behaviour
The name of the robot says a lot about its be-
haviour. It hunts for something. Its job is to
detect and follow warm moving targets, such
as people and animals. As long as the robot
can see something, it will pursue it. If it can’t
see anything, it advances by five steps in the
hope of seeing something. After these five
steps it remains standing and waits for new
prey. The behavioural rules can be summar-
ised as follows:
417
R
310 circuits
elektor international media bv – 089018/uk
pagina 417
Radio equipment using the license-free 2.4- à a short piece of 50-Ω coax cable like
GHz ISM (industrial/scientific/medical) band is RG58(C)U with a crimpedon BNC plug
also rife among robotics fans, just think of (‘borrow’ a cable from the IT dept.);
what you can do with Bluetooth, wireless cam- à a sharp (hobby) knife;
eras, remote control, or even a WLAN client à a pointed tool like a strong needle or a
or access point fitted on a robot vehicle! watchmaker’s screwdriver;
à a ruler;
Point is, such homebrew applications typi- à a soldering iron (optional);
cally require an antenna that’s (1) omnidirec- à a hot glue gun;
tional, (2) ‘sort of’ flexible in view of the à common sense and about 30 minutes of
damage and bashing it may have to take and your time.
(3) low2 cost.
Here goes.
The antenna shown here fulfills all three re- reproduced with modifications
quirements brilliantly. See for yourself, the and extensions from CQ-TV issue 217
pictures say more than 1 kwords. (070142-I)
Figure 1 The raw material: a short piece of 50- Figure 2 Cut off about 40 mm of the outer insu-
coax cable. lation. This will expose the braid that forms the
cable shield.
Figure 3 Push down the braid to expose the Figure 4 Using the pointed tool, carefully
inner insulation. unweave the braid strands.
418 418
L
310 circuits
elektor international media bv – 089018/uk
pagina 418
Figure 5 Until your hairdressing looks some- Figure 6 Distribute the strands into four equally
thing like this… sized and likewise spaced bundles (wow, tresses!).
Figure 7 Now bend them into a 45-degree angle Figure 8 Cover the bundles with solder. Al-
with respect to the cable. This angle will result in though this step is optional, it does enable the
an antenna impedance of about 50 . ground plane elements to hold their shape better,
and prevents untwisting of the strands.
Figure 9 Done soldering! Figure 10 Apply a few drops of hot glue from
the glue gun…
Figure 11 … will help keep the proper shape. Figure 12 Cut the radials and the radiator to a
length of 30 mm (and yes, that’s exactly 0.25
lambda).
419
R
310 circuits
elektor international media bv – 089018/uk
pagina 419
150 Ω
150 Ω
1k
D1
420
L
310 circuits
elektor international media bv – 089018/uk
pagina 420
100 mA maximum collector current rating is by-eight. RO(0) and RO(1) can be used to reset
still below the limit with three LEDs. these two sections. We don’t need the reset
function for this application so we connected
We use R4 to define the logic level (low) on RO(0) and RO(1) to ground to prevent un-
the clock input when the switch is open. wanted behaviour. If need be, the clock input
\CKA could be connected to the power supply
The HCT7493 is a 4-bit binary ripple counter, rail to make this input insensitive to noise.
which internally consists of four master-slave (070025-I))
flipflops that form a divide-by-two and a divide-
C. Tavernier
421
R
310 circuits
elektor international media bv – 089018/uk
pagina 421
4k7
1 24
SOUT VIN
2 1
SIN
3 22 2
ATN RES
IC1
3
The first line enables the instruction PULSIN
to read the high duration of the pulse genera-
5 20 4
P0 P15 CMP03
6 19 5 of
P1 P14
7
P2 P13
18 6 CMPS03
ted by the CMP03 module.
The second line merely applies the above re-
8 17 7
P3 P12
9 16 8
P4 P11
10
P5
CB220
P10
15 9
lationship, given that the resolution of the
measurement performed by PULSIN is 2 µs in
11 14 SCL
P6 P9
12 13 SDA S1
P7 P8
the case of the Basic Stamp II. So we then
4 23
have the angle in degrees with respect to
magnetic North in the variable POSITION .
If you want greater precision, or if your micro-
070304 - 12
422
L
310 circuits
elektor international media bv – 089018/uk
pagina 422
To be in a position to
write the corresponding
program, all you then
need to know is that the
I2C address of the CMP03
module is C0 and that
four main registers are
accessible to us through
this address:
From that point on, reading this information Hence if you use this listing with a PIC pro-
via an I 2C bus is quite straightforward, as grammed in Basic, a slight adaptation might
shown in the very short listing below, written prove necessary, depending on the compiler
for the Basic language of the Cubloc: you are using.
Devantech
The first three instructions address the mod- www.robot-electronics.co.uk/shop/
Compass_CMPS032004.htm
ule and select the first register to be read. The
next instructions read the four previously- A little background reading
described registers in succession, thus ma- http://zedomax.com/blog/zedomax-diy-hack-lets-
king the software version number available in make-a-digitalcompass/
the variable Version, the 8-bit coded angle in http://zedomax.com/blog/2006/08/16/digital-
the variable Position8, and the 16-bit angle compassusing-cmps03/
in the 16-bit variable Position16.
423
R
310 circuits
elektor international media bv – 089018/uk
pagina 423
424 424
L
310 circuits
elektor international media bv – 089018/uk
pagina 424
Figure 1 Circuit diagram of Motobox, the ‘one size fits all’ controller for motors typically used in ro-
bots.
microcontroller is configured to use its inter- tor is also included in order to program the
nal 4 MHz oscillator, thus freeing the pins as- device in place. The PGC and PGD lines are de-
sociated with the crystal to be used as the coupled by a 100nF capacitor.
serial interface.
The module is powered by a 12-V supply
PORTB is used as an output to drive the motor which is regulated down to 5 V by means of
controllers, while PORTA is used for various an 78L05. Power-On status is shown by the
functions, to read the value of the current, green LED D16. The module has been
control the drivers and control the driver designed to operate from a maximum of
LED’s. The MCLR pin is held High by means of 13.8 V from a freshly charged lead-acid
R15 and D13. An ICSP programming connec- battery and down to 7 V. It is important for
425
R
310 circuits
elektor international media bv – 089018/uk
pagina 425
the module not to share the power source controller to detect a short-circuit and thus
used to drive the motor because of the stop the motor. The filter will smooth out any
current surges, spikes and noise induced by voltage spikes. In addition, an algorithm is
the motor. implemented in the microcontroller firmware
A MAX232 is used to interface the module to that detects an overcurrent condition for a
the serial port of a desktop computer or lap- specified time before switching off the affec-
top. It is imperative that the MAX232 be in- ted channel.
cluded in the circuit or else make sure that
RA7 (receive pin) is held Low when not used. Construction
A floating input will cause the microcontroller Good news: the project does not have exotic
to interpret noise as data and may result in er- components to source, with the possible ex-
roneous operation. The module can also be ception of the clip-on heatsink – but then
controlled by another microcontroller by that’s available from Mouser.
using connector K2. Through-hole components are used in the
project to simplify construction and all com-
The motors are driven by the power stages ponents are easy to obtain as well as mount
provided by the L298, each driving a single on the PCB, of which the component overlay
motor. The L298 is a dual half-bridge driver is shown in Figure 2.
capable of 2 A per channel, with separate
enabling and current sensing for each bridge. There’s little to say on the components used
It is suited to driving different types of except that the 0.22-Ω resistor is preferably
motors. In this project the L298 is enabled by not of the wirewound type and the bi-colour
the microcontroller and the Enable line is LEDs have two pins, not three! If you do not
pulled Low on power-up to ensure that the IC envisage interfacing the board to a PC, the
is disabled. Decoupling capacitors, 100 nF sub-D connector may be left out. However,
each are placed near the IC. the MAX232 should always be present. Like-
wise, IC4 and IC5 should always be soldered
A DC amplifier is built around the LM358 to the PCB.
which senses the voltage across the sense re-
sistor. It is followed by a lowpass filter and a Dry testing
buffer amplifier whose gain decreases with Once the circuit has been constructed it
frequency filters any noise. DC motors gene- should be tested for correct operation. Power
rate spikes when the armature makes contact up the circuit with none of the ICs inserted.
with the commutator, which is reflected as a D16 should light up. Check if there is 5 V on
current spike and appears across the sense the relevant socket pins for IC1, IC3, IC4, IC5
resistor. Current spikes may cause the micro- and IC6. The supply voltage should also be
426
L
310 circuits
elektor international media bv – 089018/uk
pagina 426
427
R
310 circuits
elektor international media bv – 089018/uk
pagina 427
ward direction the command ‘DC1FOR’ has to mand. The LEDs will turn light up when the
be typed in lowercase or uppercase. The soft- system is working correctly and red when the
ware will convert all letters to uppercase. motor driver has been turned off.
When the command has been sent it will be
executed, the character ‘A’ indicating that re- Stepper motor commands allow the spindle
ception is acknowledged and the actual com- to be turned cw (clockwise) and ccw (counter
mand is echoed. This is very useful when the clockwise) by a number of steps (maximum
board is used with a (dumb) terminal. If the 999 steps). When this command is selected, a
command has been sent incorrectly, the 3-digit number must provided, for example
letter ‘E’ will be sent back indicating an er- 050 to move 50 steps. Even if steps less than
roneous command. The command buffer is 100 will be done the leading zero must be
cleared and the board waits for a new com- provided.
428
L
310 circuits
elektor international media bv – 089018/uk
pagina 428
COMPONENTS LIST
The DC, servo motor and status commands mended. Overcurrent can cause the L298 to
are executed immediately, but the stepper overheat and get destroyed. A ‘RESUME’ com-
motor commands are subject to a delay (de- mand has to be sent after the motor driver
fault 20 ms) so the command will be acknowl- has been switched off to resume motor op-
edged after the stepper motor has been erations. A grace period is given to enable
actuated. another command to be sent and try to get
Sending a command within this interval will the motor unstuck from its current position.
cause it to get lost and will be not executed.
The type of motor in use can be read back at Software
any time using the command ‘MTYPEX’, The source code and hex code for the
which will return a character depending on PIC16F628A is available as a free download
the type of motor being used. from the Elektor Electronics website. The file
number is 070129-11.zip (July/August 2007).
Overloading, spikes, surges… (070129-I)
Through the analogue comparator, the soft-
ware section will continuously monitor the
current consumed. The board will switch off
the motors if the current consumption ex- Author’s websites and email address
ceeds the specifications for the motor type in http://telecomms.no-ip.org
use. www.mcast.edu.mt
jozamm@gmail.com
Simple filtering takes place so that the con- Web Links
troller will not switch off the motors at ‘just www.microchip.com
any’ current spike. Rapid on and off switching www.st.com/stonline/products/literature/
of DC motors will cause large current spikes, ds/1773.pdf
which may cause the controller to shut down
the particular motor driver. You can disable
the current monitoring but this is not recom-
429 429
R
310 circuits
elektor international media bv – 089018/uk
pagina 429
Ulli Sommer
A (frequently unfulfilled)
ambition of every robot buil-
der is to make their machine
capable of autonomous navi-
gation. This is an ideal appli-
cation for a GPS receiver
module: these have recently
become very cheap to buy.
Our GPS-based navigation
system is built around an AT-
mega32, programmed using
BASCOM BASIC. It communi-
cates with the outside world
using an I 2C bus.
Any robotics hobbyist would dream of being the heart both of the circuit diagram (Figure
able to build a robot which, like the famous 1) and of the prototype printed circuit board
Mars Sojourner Rover, can autonomously ne- (Figure 2). The microcontroller is program-
gotiate unknown terrain. Ideally one would med in a dialect of BASIC using the BASCOM
just program in the coordinates of the desi- development system, which is widely used
red destination and the little chap would and available for free (for the demonstration
make his own way there automatically. version at least) download from the manufac-
Although fully autonomous robots must re- turer [1].
main a pipe dream for now, a solution is avail-
able to the navigation problem, as we Also, the source and object files for the navi-
demonstrate here with a circuit board gation program are available for free down-
designed to be added to a domestic load from the Elektor Electronics website.
surveillance robot (see photograph). The file reference is 070350-11.zip. An ISP
cable is also required, obtainable for example
Rather than develop a navigation system from from [3].
scratch ourselves we make use of low-cost
receiver modules that receive and process Any commercial GPS ‘mouse’ receiver can be
signals from the GPS satellite positioning sys- used as long as it has an RS-232 interface. If
tem. To this we add a moderately powerful the interface uses TTL signal levels it can be
microcontroller that can be programmed connected directly to our printed circuit
using free software. board; if, on the other hand, it uses standard
RS-232 levels (up to ±15 V) a MAX232 level
ATmega at the helm shifter must be connected in between. Often
Our GPS-based navigation system is built a robot’s main circuit board will already have
around an Atmel ATmega32, which appears at a suitable level shifter IC on it.
430
L
310 circuits
elektor international media bv – 089018/uk
pagina 430
Figure 1 The ATmega32 communicates with the compass and the LCD over an I2C bus; the GPS mouse
is connected via RS-232. The PCF8574 I2C interface chip takes on the task of accepting a control byte
and making it available on pins 33 to 40 of the ATmega.
431
R
310 circuits
elektor international media bv – 089018/uk
pagina 431
A suitable compass module Figure 2 Prototype navigation system printed circuit board for au-
is, for example, the Devan- tonomous robots.
tech CMPS03, available
from [4]. This compass is connected to the drive the display also via the I2C bus. There do
I2C port on our printed circuit board. exist LCD modules with built-in I2C inter-
If we want to display the position and orienta- faces, but an alternative is to use an I2C inter-
tion we will also need an LCD module. The face chip such as the PCF8574 [5] (see Figure
microcontroller is rather lacking in I/O port 4). We will see another use of this device in
pins, and so the most practical solution is to our circuit later on.
The interface parameters must be set as for the mouse (i.e., to 4800 baud). When connection has been set
up, press the reset and programming buttons simultaneously. Then first release the reset button and then
the programming button around a second later. You should see a welcome message (which indicates how
to get help) and a prompt on the terminal.
***********************************
* GPS-Navigation Programmng Mode *
* use HELP for help *
* Sommer Robotics 2006 V1.0 *
***********************************
GPS-NAVI:\
The coordinates of the track points can be determined using a separate GPS system; alternatively, the ro-
bot can be moved manually to each track point in turn and the coordinates read off the LCD.
With the track point data programmed in, the robot can be left to its own devices!
432
L
310 circuits
elektor international media bv – 089018/uk
pagina 432
I 2C
compass I 2C track point
assignment
LEFT RIGHT
RST
Figure 3 Simplified block diagram of the navigation system. The buttons are used when programming.
Commands for the motors are output on two port pins.
Motor control
Of course we do not just want our robot to
GND
SDA
SCL
+5V
display where it is; we want it to make its way K8
15
14
13
1
2
3
SDA
A0
A1
A2
SCL
INT
Output pins Motor_l and Motor_r combined 16 IC4 8
P5
P6
P7
P0
P1
P2
P3
Motor-l Motor-r Function
10
11
12
9
4
5
6
7
10k
0 0 STOP
1 1 straight on
1 0 turn left
10
11
12
13
14
1
2
3
4
5
6
7
8
9
0 1 turn right
VDD
E
D0
D1
D2
D3
D4
D5
D6
D7
RS
VSS
R/W
VO
433
R
310 circuits
elektor international media bv – 089018/uk
pagina 433
Here ‘$GPGGA’ is the protocol type, ‘191410’ the time, ‘5212.9324,N’ the latitude, ‘00007.5930,E’ the long-
itude, ‘1’ indicates that the reading is valid and ‘04’ is the number of satellites in view. As you can see, this
covers all the information we need. All we need to do is switch the GPS mouse to the $GPGGA protocol and
set the communication speed to 4800 baud. Other protocols should be disabled, and the reporting interval
set to approximately 1 s. The settings are made using the software provided with the GPS mouse.
I2cstart
I2cwbyte &H7A
(address of PCF8574: see data sheet for
addressing scheme)
I2cwbyte 1 (track point number)
I2cstop
Web links
[1] www.mcselec.com
[2] www.elektor.com
[3] www.kanda.com
[4] www.robot-electronics.co.uk
[5] www.nxp.com/cgi-bin/pldb/pip/pcf8574
434
L
310 circuits
elektor international media bv – 089018/uk
pagina 434
Paul Goossens
435 435
R
310 circuits
elektor international media bv – 089018/uk
pagina 435
Markus Bindhammer
T1 T3
D3 D4
D1 RE1
BC557
R1 R6 R5 R9
180Ω
180Ω
1k8
4k7
1N4148
M1
C1 R2
1k8 M
1µ T4 D2
16V
T2
P1 1N4148
BC547
T5
BC547 10k R8 M
2k2
M2
R4 R7
C2 BC547
1k
560k
470µ
16V
070143 - 11
436
L
310 circuits
elektor international media bv – 089018/uk
pagina 436
2 3
UM1 UM2
T3 D3
plastic tube
protects against
ambient light
070143 - 12
070143 - 13
tor of T2 and R6 lights up the LED. During this LED so capacitor C2 acts as a reservoir capaci-
time capacitor C1 is charging up and when tor to ensure that once T4 begins to conduct,
the voltage level gets sufficiently high the sufficient energy is stored in C2 to ensure
base of T1 becomes reverse biased and T1 that T5 remains conducting continuously un-
turns off. til the obstacle is out of range and T4
T2 will also turn off along with the LED. C1 be- switches off. It takes a few seconds for C2 to
gins to discharge until the base of T1 is low discharge and during this time MOPs is per-
enough to begin conducting again. T2 forming its avoidance manoeuvre.
switches on which reinforces the low base
voltage on T1 via C1 and the cycle continues. T5 switches a double pole relay which has the
effect of performing this manoeuvre. In nor-
The LED light source for obstacle illumination mal forward motion the relay switches the
does not need to flash, it can be lit continu- positive and negative supplies to both motors
ously but there are two reasons for the flash- and diode D2 is conducting. When an obstacle
ing LED: firstly it conserves battery power, is detected the relay switches and reverses the
giving MOPS a longer range and secondly polarity of the motor connections. D2 now
(and more importantly) a flashing light looks becomes reverse biased and no current can
much more impressive than a boring old con- flow through motor M2 while M1 goes into
tinuous light source. reverse.
This gives MOPS the reverse and turn respon-
When reflected light falls on the phototran- se to obstacles. A few seconds after the ob-
sistor T3 a current flows through R5 to stacle is no longer detected the relay switches
ground which produces a voltage at the base back and MOPS carries on as before but in a
of T4 to make it conduct. The values of R5, P1 different direction.
and R7 affect the switching threshold so ad-
justment of P1 will help to reduce spurious Figure 2 shows a close up of MOPS’s eye
detections caused by external light sources. mounted in a tube which helps to make ob-
stacle detection more directional and reduces
Turning P1 (a preset could be used here in-
stead) so that it increases its resistance will Web Link
make T4 more sensitive and vice versa. T4 www.elexs.de/robo1.htm
conducts in synchronism with the flashing
437
R
310 circuits
elektor international media bv – 089018/uk
pagina 437
the effects of external light sources. With this microswitches connected to contact feelers
set-up it was possible to detect obstacles at a mounted on the front of MOPS this will help
distance of 10 cm. The range depends largely avoid collisions with matt black objects. Fig-
on the reflective properties of the obstacle so ure 3 shows the layout of the two motor and
darker objects will only be seen at shorter gearbox assemblies.
ranges. The circuit can be modified to read (070143-I)
Dominik Tewiele
VCC
100Ω
PD5(T1)
12
of ambient infrared light. Practically every PD6(AIN0)
13
modern microcontroller sports one or more
PD7(AIN1) D1
ATmega8
asynchronous serial interfaces (UARTs), which PB0(ICP)
14
Because of the open-collector output stage, it Here again, we can wire several IR LEDs in
is possible to connect several receiver modu- parallel to increase the transmit range and
les in parallel to increase the area covered. coverage angle.
The transmitter consists simply of an IR diode
and a couple of discrete components. The series current limiting resistor for the IR
LEDs should be chosen with consideration for
A timer in the microcontroller can be used to the desired range and the maximum pulse
provide modulation, or alternatively an exter- current that the LEDs can handle. This last fi-
nal NE555 can be used. In this example we are gure can be found on the LED’s datasheet,
using an ATMega8 with Timer1 configured so which will also help determine a suitable pul-
that the output compare registers OCR1A and se width to set in the software.
OCR1B control the frequency and pulse width
of the signal on output PB2. The NPN transis- The maximum baud rate that can be achieved
tor then applies the required modulation. will depend on the receiver chosen. Using a
438
L
310 circuits
elektor international media bv – 089018/uk
pagina 438
TSOP17xx around 1200 baud is possible, a transmitter circuit at each end of the link. It
which should be adequate for simple control is worth bearing in mind that because of the
commands. effect of reflections scope for full-duplex
For bidirectional communication it will be operation is rather limited.
necessary to build both a receiver circuit and (070170-I)
A low-cost robot –
not just for schools & education
Bart Huyskens,
St Joseph’s institute (Schoten, Belgium)
Out of Belgian schools has arrived an £ 85 science related activities – fail to attract young
(€ 125) robot buggy that the designer hopes can people. To people who have grown up with a
reverse the decline in the study of electronics and fascination for technology this is a great
technology across Europe and, potentially, shame and it really is very strange when you
wider. consider that young people are fascinated by
all things electronic – like i-pods, digital cam-
Like many in the engineering teaching frater- eras and mobile phones. But for some reason
nity, the author is increasingly aware that our schools fail to capitalise on this interest
electronics – and most engineering and and attract young people to technical careers.
439 439
R
310 circuits
elektor international media bv – 089018/uk
pagina 439
And here it is
Figure 1 shows a picture of Formula Flow-
code and a list of the components and fea-
tures on the buggy. But how does it all work?
440
L
310 circuits
elektor international media bv – 089018/uk
pagina 440
Driving DC Motors
The two DC motors with
separate gearboxes are
powered by a classic L293D
IC with two full H-bridges,
see Figure 3.
The direction and speed of
each motor can be pro-
grammed separately in
Flowcode and this makes
the buggy capable of perfor-
ming the craziest moves
you can imagine.
441
R
310 circuits
elektor international media bv – 089018/uk
pagina 441
Power supply
This section of the circuitry
is shown in Figure 8, using a
Figure 6 Distance measurement circuit on board the Formula Flow- combination of pictorial
code Buggy. elements and of course the
schematic. The small chas-
sis is powered from four
NiMH AA rechargeable bat-
teries which give between 4
and 6.2 V. The circuit board
also has space for additional
components that allow you
to connect larger batteries
to the chassis, using a 5 V
regulator.
Additional circuitry
In addition to the standard
circuitry discussed above,
Figure 7 Line follower circuit. the chassis is also fitted
with a fair number of expan-
sion connectors. These in-
clude I 2C expansion, wheel
encoder inputs, servo in-
puts, and much more.
442
L
310 circuits
elektor international media bv – 089018/uk
pagina 442
Courseware
for pole position
The new version of Flow-
code released with the
buggy includes a pulse-
width modulation (PWM)
component for controlling Figure 9 Typical line following exercise.
the motors. As Flowcode is
now available in around 10 languages (inclu- finish with full maze solving using a custom
ding Chinese) it will be usable by children as made chassis, using wheel encoders and what
young as 12 virtually anywhere in the world. have you.
This is the really clever idea behind Formula
This robot buggy is officially named ‘Formula Flowcode – it is great for complete beginners
Flowcode’, after the Formula Ford where the to robotics and electronics, and it will also
cars are all identical and winning only comes provide a considerable challenge to those
down to the driver’s skills. In this case, win- with relevant degrees in electronics and com-
ning comes down to the programming skills puter science.
of the user.
The courses include such subjects as:
As you might expect there are a number of
separate ‘courses’ that users have to complete à Light a single LED;
to increase their skills level. These courses à Make a ‘NightRider’ effect on the LEDs on
start with getting a single LED to light up, and the front of Formula Flowcode;
The Formula Flowcode robot buggy was purposely developed to motivate people to want to learn more
about robotics and electronics – from 12 year old pupils who have a curiosity about the subject, right up to
those enjoying retirement and still wanting to learn and keep mentally active. In the USA the First Robotics
programme (www.usfirst.org) has been quite successful at stimulating engineers in industry to collaborate
with young people to compete in robotic events. We hope to achieve something similar here; by providing a
low cost hardware software robot, providing online support and quality curriculum. By running workshops
and competitions we hope people will be captured by electronics. If you feel that our aims are worthwhile
and achievable, if you want to take part in this programme, or if you are interested in the competitions and
workshops then please let us know. If the level of interest is high then we can write more articles and issue
special ‘courses’ for Elektor readers.
The author and his colleagues can be contacted by email on barthuyskens@scarlet.be, or through Elektor.
You can purchase a Formula Flowcode buggy from the Elektor Shop at a cost of £ 85 or i 125 including
VAT.
443
R
310 circuits
elektor international media bv – 089018/uk
pagina 443
444
L
310 circuits
elektor international media bv – 089018/uk
pagina 444
445
R
310 circuits
elektor international media bv – 089018/uk
pagina 445
Rajkumar Sharma
446
L
310 circuits
elektor international media bv – 089018/uk
pagina 446
Features 2
à Motor supply voltage 12 V to 30 V DC
à Delivers up to 3 amps continuous output
à PWM frequency adjustable from 1.16 kHz
to 35.1 KHz
à PWM continuously adjustable by pot
à Duty cycle 0 to 100%
à Direction control by switch
à Shorted load protection
à Thermal shutdown
à No SMD components
à No microcontroller
100%
gives 5 V out. Resistor R1 feeds the supply
voltage to an internal open-collector transis-
tor for TTL-level PWM output. COMPONENTS LIST
447
R
310 circuits
elektor international media bv – 089018/uk
pagina 447
crucial locations in a robot. After all, most i.e., no SMDs in sight here. The copper track
forms of motion of a robot will require a layout and component mounting plan are
motor of some kind. contained in free download no. 060339-1.zip
The board has been designed for compact- from our website.
ness whilst using leaded components only, (060339-I)
Luc Lemmens
448
L
310 circuits
elektor international media bv – 089018/uk
pagina 448
COMPONENTS LIST
Resistors
R1, R2, R4, R5, R7 = 10 kΩ
R3 = 4kΩ7
R6 = 1 kΩ
Capacitors
C1 = 10 nF
Semiconductors
T1, T2 = BC547
T3 = BC557
Miscellaneous
K1 = 9-way sub-D socket (female), angled pins,
PCB mount
K2 = 5-way SIL socket
PCB, ref. 070276-1 from www.thepcbshop.com
200%
Tilman Küpper ment off. When the battery voltage drops be-
low a pre-set limit (9.5 V in this example) the
With this circuit built into the power supply circuit will automatically disconnect the bat-
of a battery powered device, it will prevent tery.
the rechargeable cells from being completely Power is re-connected when the voltage rises
drained when you forget to turn the equip- above an upper threshold level (10.5 V here),
449
R
310 circuits
elektor international media bv – 089018/uk
pagina 449
T1
IRLML6402
R1 R4
100k
100k
8
2
HYST1
R2 5 RL1
HYST2 1
OUT1
820k
BT1 IC1
ICL7665 7
3 OUT2
SET1
6
SET2
Web Links R3
130k
4
www.intersil.com/data/fn/fn3182.pdf
Data sheet IRLML6402:
www.irf.com/product-info/datasheets/ 070087 - 11
data/irlml6402.pdf
this will typically occur after the equipment resistor for R1 to R3. Increasing the value of
has been plugged into its recharging station. R3 to 300 kΩ will raise the upper threshold
The circuit is designed to use as little power level to 12.5 V. The ICL7665 data sheet gives
as possible. examples of suitable resistor values that can
be used here.
The ICL7665 from Intersil forms the heart of
the circuit. This IC contains two comparators The PCB layout uses SMD components so the
together with a voltage reference and con- finished circuit takes up very little space
sumes just 3 µA. The circuit only uses one of when installed in the equipment. A fine-
the comparators, the values of resistors R1 to tipped soldering iron should be adequate to
R3 shown in the diagram will cause the circuit mount the components and there shouldn’t
to switch at the levels mentioned above. The be any problems provided you do not choose
comparator output switches the P-channel to use very small resistor packages.
MOSFET T1 which in turn controls power to
the load RLOAD. Once the circuit has been tested the entire
PCB can be protected by encapsulating it with
The switching threshold levels and hysteresis a short length of heat shrink sleeving.
can be changed by using different values of (070087-I)
450
L
310 circuits
elektor international media bv – 089018/uk
pagina 450
S4
D1 D2 D3
R1 R2 R3 LDR1 LDR2 LDR3
C4
1k
1k
1k
10µ R5 R6 R7
16V
20 M1 M2 M3
1 19 M M M
RST P1.7
18
P1.6
12 IC1 11
BT1 P1.0 P3.7
13
P1.1
14 2
P1.2 P3.0
4V8 3
P3.1
4x 1V2 6
P3.2 9
AT89C2051 DS
15 9 1 16
P1.3 P3.5 I1 O1
16 7 2 15
P1.4 P3.3 I2 O2
17 8 3 14
P1.5 P3.4 I3 IC2 O3
S1 S2 S3 4 13
X1 X2 I4 O4
5 12
5 4 10 I5 O5
R4 X1 6 ULN2003 11
C1 C2 C3 I6 O6
7 10
10k
I7 O7
10µ 10µ 10µ GND
35V 35V 35V 12MHz
C5 C6
8
22p 22p
070289 - 11
S1 ... S3 = antenna
451
R
310 circuits
elektor international media bv – 089018/uk
pagina 451
LDR 1
To add some visual appeal we’ve added three
8-mm LEDs. When TriBot is powered up they motor 1 motor 2
Hesam Moshiri
1
A detector to flag missing pulses is among the VCC
Figure 2. 7
R
DIS
IC1
For the detector to operate, certain condi- 2
TR OUT
3
τ = 1.1⋅R⋅C BC558
452
L
310 circuits
elektor international media bv – 089018/uk
pagina 452
switched on!
(070099-I)
453
R
310 circuits
elektor international media bv – 089018/uk
pagina 453
We can see that the schematic also contains a symmetrical power supply, the converter will
relay that can be switched by the R8C to im- give an output value of 512 when the input
mediately stop the table movement. This is voltage is zero volts. We can display a minus
optional. sign on the LCD when the value is smaller
than 512.
Now we have to take special care when we In C code it looks like this:
have negative voltages. The resolution of the
10-bit A/D-converter in the R8C amounts to 5 if ( u < 512 ) // less than 0,
V/1024 = 0.00488 V per bit. Because of the then minus sign
454
L
310 circuits
elektor international media bv – 089018/uk
pagina 454
C. Tavernier
455
R
310 circuits
elektor international media bv – 089018/uk
pagina 455
To make it easier to follow our explanation, Even though these walking robot kits are also
we’re going to refer to ‘right’ and ‘left’, but available with electronics chassis included,
obviously this is purely relative. When the sometimes very elaborate as in the case of the
robot is at rest, both feet are flat on the Yeti with an ATMega8 processor from Atmel
ground alongside each other. Then the foot and its C compiler, a simple Basic Stamp II or
servo turns in a direction that will make the a Cubloc CB 220 is enough for taking your
robot’s body lean over onto the left foot, first steps (literally as well as figuratively!).
which obviously has the effect of lifting the
right foot off the ground. Then the leg servo As shown in the figure, which applies to both
turns too, making the right leg, free to move these microcontrollers that are, don’t forget,
as its foot is now off the floor, move forward. pin-compatible, apart from the microcontrol-
Then the foot servo turns in the opposite ler itself, no other active components are re-
direction, making the robot’s body lean over quired to make our robot walk.
onto the right foot, lifting now the left foot
off the floor. The leg servo rotates again to The servo control inputs are connected from
make the left leg, itself now free to move, two parallel ports which can be any ones in
advance – and thus ends the first step. the case of the Basic Stamp, but must be P5
456
L
310 circuits
elektor international media bv – 089018/uk
pagina 456
and P6 in the case of the Cubloc CB 220, as its complicated compared with the Cubloc ver-
PWM instructions only work on these two. sion.
Capacitors C1 and C2 call for a comment: C1 Lastly, let’s remember that a servo takes up
and C2 only need to be fitted if using a BS II. If the rest position when it receives 1.5 ms
using a CB 220, C1 will be replaced by a wire pulses, and moves towards its end positions
link, and C2 will not be fitted, its two pads in one direction or the other for pulses of
being simply left empty. 1.0 ms or 2.0 ms respectively.
All the rest is just a matter of programming, From this point on, it’s easy to follow one or
based essentially around the PWM instruc- other of the suggested listings. To put the
tion in the case of the Cubloc and around robot’s feet into the rest position, for the
PULSOUT in the case of the Basic Stamp. As Cubloc we write:
you will have gathered from the explanation
above, to make our robot walk, all we have to PWM 0, 3150, 32768
do is make the servos turn alternately in one PWM 1, 3150, 32768
direction or the other, in a well-defined se-
quence. And for the Basic Stamp II :
We are offering you two complete source FOR Pulses = 1 TO 100 STEP 5
listings for making our robot walk, one for PULSOUT TiltServo, 750
Basic Stamp II and one for Cubloc, on down- PULSOUT StrideServo, 750
load from the Elektor website or from the PAUSE 25
author’s own site (www.tavernier-c.com). Here NEXT
are just a few comments to prove to you how
simple they are and enable you to adapt them In both cases, this causes 1.5 ms pulses to be
easily to your own needs. generated for both servos, hence placing
Let’s start by recalling that in the Cubloc the them into the rest position. Note that, in the
instruction PWM is used as follows: case of the Cubloc, it is necessary to adjust
the 3150 parameters so that they take the
PWM port, ratio, period servos correctly to the rest position, while for
the Basic Stamp, it is necessary to adjust the
This generates on the corresponding port (0 two 750 parameters for the same purpose.
for P5 and 1 for P6) a PWM signal whose duty To lift one foot, we will therefore write for
cycle is defined jointly by ‘ratio’ and ‘period’. the Cubloc:
The advantage of the Cubloc is that this in-
struction lets us generate the relevant signal FOR Position = 3150 TO 2850 STEP -1
continuously, as soon as it has been called at PWM 0, Position, 32768
least once. DELAY 1
In the case of the Basic Stamp, the instruction NEXT
PULSOUT is used in the following way:
And for the Basic Stamp:
PULSOUT port, duration
FOR Pulses = 750 TO 620 STEP -5
This generates a pulse on the corresponding PULSOUT TiltServo, Pulses
port for a period equal to 2 µs multiplied by PULSOUT StrideServo, 750
the value of the ‘duration’ parameter. The NEXT
drawback to PULSOUT compared with PWM
is that this generation is not repetitive. So if Note the increase in ‘complexity’ created by
we want to generate repetitive pulses, we the fact that, unlike PWM, PULSOUT does not
need to employ loops, making the Basic operate continuously. So we need to add into
Stamp version of the program a little more the Basic Stamp’s ‘lift foot’ loop the genera-
457
R
310 circuits
elektor international media bv – 089018/uk
pagina 457
Seattle Robotics give BoeBot their distributors like Milford Instruments [5].
(and other robots) vision! The CMUcam1 BoeBot package includes
458
L
310 circuits
elektor international media bv – 089018/uk
pagina 458
459
R
310 circuits
elektor international media bv – 089018/uk
pagina 459
3 Track Colour – the robot moves forward, in response to the colour of the object
backward, right and left to follow the col- placed in front of it. This works well with
our of the object saved during function 2. 5-cm diameter coloured rubber ball or
plastic block.
4 Move & Avoid – the robot will move for-
ward and avoid objects using the vision For best performance with all of the above
sensor only. It works by sampling the functions, the tilt of the camera should be
colour range of the floor in front of the pointing down looking just in front of the
robot. robot.
5 Adaptive Tracking – the robot locks onto Basic Stamp2sx and Basic Stamp2p
the first colour it sees and tracks that col- This CMUcam1 AppMod and demo code will
our (it only goes fwd, right and left, not also work with the more powerful 2sx and 2p
bwd). If it loses the object for about five versions of the Basic Stamp. Separate ver-
seconds it then locks onto the next colour sions of the demo code for each Stamp can be
it sees and tracks that until it loses that, etc. found on the CDROM. The code changes are
minor and related to the 2.5 times faster ex-
6 Line Following – it is assumed a black line ecution speed.
about 1.2 cm (.5 in.) wide is present on a
white line tracking course. You can do more with the CMUcam1 and the
2sx and 2p Stamps due to their faster speed
7 Finger Point and Move – the robot will and larger memory. The Basic Stamp2 is limi-
backup, turn right and turn left in relation ted to 9600 baud serial interface speed to talk
to finger pointing. This is done with the to the CMUcam1 but the 2sx and 2p can both
CMUcam1 using the same downward fa- talk to the CMUcam1 at its maximum serial
cing angle as is used on all the other func- data rate of 115,200 baud. The CMUcam1 is
tions. switched to the 115,200 baud rate by re-
moving two jumpers that can be found on its
8 Show Colour – the robot will light up board. The higher baud rate means BoeBot
either all of the red, green or yellow LEDs can respond much faster to the vision system.
460
L
310 circuits
elektor international media bv – 089018/uk
pagina 460
461
R
310 circuits
elektor international media bv – 089018/uk
pagina 461
Serial comms and command sets à Display CMUcam1 tracking data on debug
The serial communication parameters are as screen. The first data packet displayed by
follows: 9600 baud, 8 data bits, 1 stop bit; no the Debug screen is the ‘S’ (Statistics)
parity, no flow control (no Xon/Xoff or hard- packet which tells you the colour of the
ware). object it is tracking. This will let you evalu-
ate the ability of your camera to track an
All commands are sent using visible ASCII object. Try different colour objects and
characters, i.e., 123 is three bytes ‘123’). different sizes to see the effects on the
Upon a successful transmission of a com- tracking data. This is an important pro-
mand, the ACK string should be returned. gram that you will re-use many times as
you as you find more and more interesting
If there was a problem in the syntax of the things to do with your CMUcam1 and
transmission, or if a detectable transfer error BoeBot. This program allows you to see
occurred, an NCK string is returned. and understand exactly what your BoeBot
can see with its CMUcam1 vision system.
After either an ACK or an NCK, an \r is retur-
ned. When a prompt (‘\r’ followed by a ‘:’ ) is A short video showing a CMUcamequipped
returned, it means that the camera is waiting BoeBot locating a red object may be found at
for another command in the idle state. White [8].
spaces do matter and are used to separate ar- (070132-I)
gument parameters. The \r (ASCII 13, carriage
return) is used to end each line and activate
each command. If visible character transmis- Weblinks
sion exerts too much overhead, it is possible
[1] www.parallax.com
to use varying degrees of raw data transfer
(‘Raw mode’). [2] www.stampsinclass.com
462 462
L
310 circuits
elektor international media bv – 089018/uk
pagina 462
operating sequence
1
1 2 3 4 5 6 7 8 8 1 2 3 4 5 6 7
I/O Don’t Care
CLOCK Access
Access tconv Sample
Cycle B Sample Cycle C Cycle C
tsu(CS) Cycle B (see Note A)
tsu(CS)
CS
twH(CS)
Hi-Z State
Hi-Z State
DATA A7 A6 A5 A4 A3 A2 A1 A0 B7 B6 B5 B4 B3 B2 B1 B0
OUT
A7 B7
Previous Conversion Data A Conversion Data B
MSB LSB MSB MSB LSB MSB
(see Note B) ten
ten
NOTES: A. The conversion cycle, which requires 36 internal system clock periods (17 µs maximum), is initiated with the eighth I/O clock pulse
trailing edge after CS goes low for the channel whose address exists in memory at the time.
B. The most significant bit (A7) is automatically placed on the DATA OUT bus after CS is brought low. The remaining seven bits (A6–A0)
are clocked out on the first seven I/O clock falling edges. B7–B0 follows in the same manner.
8051-compatible microcon- 3
REF- GND
4
troller.
070134 - 12
463
R
310 circuits
elektor international media bv – 089018/uk
pagina 463
a b
1 iron core
ABS rod
spring
coil
070316 - 12
THY1
2 TIC126D
R1
2k2
BT1 L1
charger circuit
from R2
330V
1V5 disposable
camera LDR
C1
120µ 400V
070316 - 11
kicker coil
464
L
310 circuits
elektor international media bv – 089018/uk
pagina 464
high voltage capacitor to 330 V in 16 s from a shop. If not, you can resort to do-ityourself:
1.5 V battery. the cores can be ordered from any metal
warehouse that can supply steel rounds.
Next we turn to the sewing box for inspira- Ensure that you do not buy vanadium steel or
tion. We need two cotton reels from which a non-ferrous metal. The size should be
we will fashion inductors using enamelled chosen so that the lengths of metal pass
copper wire. On the one hand it is advanta- through the cotton reels without too much
geous to use wire that is very thin so that we play. In each drill a hole in one end and fit a
can have as many turns as possible and hence small washer to prevent the light compres-
a high inductance, while on the other hand sion spring from sliding down. The spring en-
the high ohmic resistance of this arrang- sures that after each kick (Figure 1a) the foot
ement limits the maximum current that can will return smartly to its initial position (Fig-
be achieved; we need to find a good compro- ure 1b). The cores are fitted into the coils and
mise. To simplify making the windings with a plastic cylinder, which will be the part that
very fine wire, first wrap the coil former with actually makes contact with the ball, is at-
a layer of thin double-sided adhesive tape. tached to the free ends.
This will hold the wire in place as you wind
the first layer. Use adhesive tape again after Figure 2 shows how simple the drive circuit
each successive layer of wire. Finally, wrap can be. A type TIC126D thyristor wired be-
the finished coil in insulating tape so that just tween the high-voltage generator and the coil
the two connection wires (with extra insula- triggers the kick. The thyristor is in turn trig-
tion) protrude. gered optically via an LDR, which ensures iso-
lation between the high voltage electronics
The two iron cores can with a little luck be and the control circuit.
found in the clearance bin at an electronics (070316-I)
Paul Goossens
Charging
The charging of Lithium batteries is a very MAX745 such a charger can easily be con-
exact science. If the wrong method is used structed at home.
there is a real chance that they’ll burst into During the charging process the charge cur-
flames. rent should not rise above 1C. This means
For this reason it is only sensible that you al- that for a 1200 mAh battery it may not be
ways use a proper charger. With the use of a charged with a current of more than 1.2 A!
465
R
310 circuits
elektor international media bv – 089018/uk
pagina 465
Furthermore, the terminal voltage for this The battery voltage is measured via pin 14
type of battery may never rise above 4.25 V (BATT). The voltage difference between BATT
per cell. In principle a lithium charger is and CS is measured by the IC to control the
nothing more than a current source with a charging current. The IC tries to keep this po-
(precision!) maximum output voltage. tential difference to 185 mV.
Table 1
JP1 JP2 Number of cells
Closed Closed 1
Open Closed 2
Closed Open 3
100%
Open Open 4
466
L
310 circuits
elektor international media bv – 089018/uk
pagina 466
Bernhard Spitzer
1
While on the lookout for
low-cost drive solutions the
author‘s eye fell upon a
cheap battery-operated cord-
less screwdriver in an elec-
tronics shop (Figure 1).
These are available for just a
few pounds (for example,
Conrad order code 481576)
and include a powerful ‘380’
motor and a multiple-stage
planetary drive. The classifi-
cation of motors as ‘380’,
‘540’ and so on follows the
part numbers in the range
produced by Mabuchi
467
R
310 circuits
elektor international media bv – 089018/uk
pagina 467
2 30 8 3
11
15
35
20,3
10 10 M3 x 10 070347 - 11
468
L
310 circuits
elektor international media bv – 089018/uk
pagina 468
that the shaft will later be able to pass exactly with bearing mount fitted. Either wheels with
through it. The finished bearing mount with a 10 mm axle hole can be used, glued directly
bearing fitted is shown in Figure 4. The two to the shaft, or the wheel can be glued to a
M3×16 screws are used to fix the mount to screwdriver bit which is then fitted to the
the baseplate of the vehicle. Figure 5 shows motor.
the motor and gear box ready for installation, (070347-I)
Luc Lemmens
469
R
310 circuits
elektor international media bv – 089018/uk
pagina 469
470
L
310 circuits
elektor international media bv – 089018/uk
pagina 470
could be used together with ME, was intro- the years relatively intact, and you can regu-
duced in 1968. However, the end of the line larly find complete or practically complete
for these mechanical construction materials kits offered on Ebay and similar auction sites.
from Eindhoven came in 1970. They usually change hands for around twenty
to thirty pounds, naturally depending on
Incidentally, the first ME kit, the ME1200, had their general condition. Just as with all old
a very strong feature with regard to mechani- things, there are collectors who are inter-
cal engineering. The mechanical parts were ested in them, and there are various websites
housed in a wooden box with a sliding lid. where you can find more information.
Probably for this reason, they have survived (070277-1)
471
R
310 circuits
elektor international media bv – 089018/uk
pagina 471
b Interaural Time
Difference – ITD
With a sound originating
from one side the pressure
waves arrive at the ears
with a slight time differen-
ce. The brain interprets the
two signals, applying a type
of neural cross-correlation
function. The phase shift
between the two signals gi-
ves the angle of the sound
source (the azimuth α).
It can be seen from Figure 2
that sound emanating from
any of the points M(u,v) ly-
ing on the hyperbola given
by the equations
u2 v 2
- =1
a2 b2 Figure 2 A sound pressure wave from the side will not arrive at both
Dx ears at the same time. Points in space where a sound source produces
a= identical delays at the ears are on a hyperbola (red) approaching the
2 asymptote (white). The brain cannot identify the position but only ap-
b = k 2 - a2 proximate the direction of a sound source anywhere along this line.
472
L
310 circuits
elektor international media bv – 089018/uk
pagina 472
where k is the half distance between the ears. The limits of ITD for localising a continuous
These points produce exactly the same time tone are clear; a sound wave will take around
difference at the ears. The term ∆x is the dis- 500 µs to travel the distance between the
tance the sound travels in the time ∆t, with ears which equates to a half cycle or a 180E
∆x = c × ∆t. phase shift between the two signals. At fre-
The speed of sound c equals 343 m/s at 25EC. quencies of 1 kHz and above it is no longer
clear if the signal in one ear leads or lags the
The hyperbola approaches the asymptote other ear.
given by:
b c The Precedence effect
v= ´u Strong reflections and standing waves produ-
a ce localised highs and lows in sound pressure
where tan(β) = b/a. when a continuous tone is reproduced in an
acoustically reflective enclosed space,
æ 4k 2 1 ö making it almost impossible to pin-point the
β = arctan ç × - 1÷ sound source.
è c2 D t 2 ø
When the sound source is discontinuous
For R (right ear): α = 90E – β; for L (left ear) however it has been shown that the brain is
the corresponding α = –(90E – β). able to identify the source, using a modified
ITD measurement it gives precedence to the
The ear must also be able to determine if the arrival of the first sound pressure wave at the
sound emanates from in front of or behind ears and appears to open a ‘neural time win-
the ear and also either from above or below. dow’ of around 1 ms for this purpose, ignoring
The points in three-dimensional space where any subsequent echoes. The phase difference
a sound source will produce identical time of the two signals gives the azimuth bearing
differences in the left and right ear actually of the sound source.
form the surface of a hyperboloid.
The LEGO robot GASTON uses this technique
It is thought that the brain can resolve these but it is not of much use for continuous
spatial ambiguities by detecting subtle sounds.
changes in the signal spectrum caused by the
outer ear shape, absorption/scattering by the Cross-Correlation
torso and head, localising by turning of the When there are two identical signals shifted
head and possibly also by detecting Doppler in time, it is common practice to apply the
effects. cross-correlation operation to them. To-
gether with Fourier analysis these two opera-
Whatever processes the brain uses to resolve tions form the backbone of techniques used
the left-right direction problem it is interes- in digital signal processing.
ting to plug some values into the formula for
a sound source positioned in front and to the The digital cross-correlation is derived from
right of the head. At a bearing α = 20E and as- two continuous waveforms as follows: The
suming an ear separation of 17.5 cm, a time value at ∆t = 0 is found by sampling the
difference of 175 µs will be apparent at the waveforms at intervals t, multiplying the sam-
ears. At an azimuth of just 3E the time diffe- ples from the two waveforms together and
rence will only be 27 µs. It is difficult to ima- then summing them and normalising the re-
gine how the brain (with a neuron switching sult.
time in the millisecond range) can resolve The cross-correlation at another position, say
such short time differences and gives us some ∆t = 1 µs is then performed in the same way
insight into the complex processes it is except this time the second signal is shifted in
capable of. respect to the first by 1 µs. The maximum
473
R
310 circuits
elektor international media bv – 089018/uk
pagina 473
Figure 3 The circuit has two audio channels each with an electret microphone and two-stage amplifier.
The two amplifier outputs are connected to the two A/D converter inputs on the microcontroller.
474
L
310 circuits
elektor international media bv – 089018/uk
pagina 474
sampling rate is chosen to ensure that the (squared) can be transformed so that cross-
processor can perform the necessary calcula- correlation function γ(τ) in the equation
tions along with any other work it needs to 2
do within the sampling time constraints. f ( τ) =å[x(t ) - y(t + τ)]
= å[ x 2 ( t ) + y 2 ( t + τ) - 2x( t ) y( t + τ)]
It can be determined by the resultant cross-
correlation whether the two signals are ‘cor- = å x 2 ( t ) + å y 2 ( t + τ ) - 2å x( t ) y( t + τ )
related’ for example if the first signal is not in
phase with the second signal but otherwise = c1 - 2å x( t ) y( t + τ )
very similar the cross-correlation function = c1 - 2× N × γ( τ)
will show a marked peak corresponding to
the phase shift between the two signals. with γ(τ) = (2N)–1[c 1 – f(τ)]
Cross-correlation calculations involve many The value of c1 is constant for every phase
multiplications and additions; it is hardly sur- shift while the square of the values are added
prising that in the DSP world it has a reputa- in each case irrespective of which phase posi-
tion for being particularly processor hungry. tion it is. (N is the constant geometric mean of
all the signal values produced by normalising
Reducing computer loading γ(τ )).
In order to perform cross-correlation with a
general purpose microcontroller it is necess- It is evident that when the cross-correlation
ary to find ways of reducing the number of value is at maximum it corresponds to a mini-
computations that the processor is required mum of the deviation sum of f. The following
to make. For this application it is valid to limit expression is therefore valid for our applica-
the number of phase shifted operations tion and makes fewer demands on precious
taking into account the distance between the processor resources.
two microphones.
g( τ ) = å x( t ) - y( t + τ )
It can be shown also that maximising the pro-
duct sum (cross-correlation function) is equi- This expression is a close approximation to
valent to minimising another function which cross-correlation. The two measured samples
is much simpler to calculate. For each phase are subtracted (ignore the sign) to give the
shift the sum of the differences of both values absolute difference. Summing them produces
100%
Figure 4 Component layout of the binaural sensor PCB. The PCB files can be downloaded from [3].
475 475
R
310 circuits
elektor international media bv – 089018/uk
pagina 475
COMPONENTS LIST
476
L
310 circuits
elektor international media bv – 089018/uk
pagina 476
architecture is organised so
that data from the two
channels can be stored in
two 96-byte banks (banks 2
and 3) as quickly as possible
by switching a single bit and
using indirect addressing.
The PIC16F88 contains a 10-
bit A/D converter but for
this application the two
least significant bits are
ignored so that we use an 8-
bit value. The sampling rate
is 20 kHz. The values are
smoothed by an FIR-filter.
Any erroneous values detec-
ted by the program are
Figure 6 The binaural sensor prototype. over-written with the pre-
vious correct value.
Timing and resolution At a frequency of 1 kHz a 180E phase shift is
For this application we will consider the fre- measured after 0.5 ms i.e. the time taken for
quency range from 200 to 1000 Hz that the ten samples.
processor calculates the ITDs (signal delays) it The smallest detectable time difference cor-
requires a sufficiently high sampling rate responds to a minimum distance of:
which could only be achieved by careful opti-
mising of the program code. The PIC16F88 dmin = 50 [µs] q 343 [m/s] = 1.7 cm
R3 IC1 = LM358N
20k When the sound source is at
the extreme right or left of
R4
K2
+5V
5 Bit Digital IN
R5
20k
a time difference of ±10
R6
8 samples will be measured. A
minimum of 20 calculations
10k
IC1
R7 4 are made for the correlation
20k
R8 calculation.
10k
477 477
R
310 circuits
elektor international media bv – 089018/uk
pagina 477
it reaches the second microphone. Assuming troller can be ordered as an alternative from
a sphere with microphones mounted along an the SHOP section. The PCB layout and compo-
axis, the arc length is r × π, where r is the ra- nent placement is shown in Figure 4; the PCB
dius of the head and should be chosen so that artwork files are also available for download
the arc length is not greater than 17 cm. from [3].
The assembler and hex files for this project Web Links
Binaural_v132.asm and Binaural_v132.hex [1] www.convict.lu/Jeunes/RoboticsIntro.htm
can be freely downloaded from the Elektor [2] www.ultimaterobolab.com
[3] www.elektor.com
website [3] where a pre-programmed PIC con-
478
L
310 circuits
elektor international media bv – 089018/uk
pagina 478
Software
The standard Lego Mindstorms software is
NXT 4V3 4
+V
based in dragging graphical function blocks.
1
Only the parameters can be changed while
the functionality of the blocks is fixed.
+5V
CMPS03
82k
82k
Robot Compass
SCL
Module
GND SDA
Not Exact C (NXC) is a programming language
2 9 3 for the NXT that has a strong resemblance to
2
I C NXT SCL 5
SCL
SDA
C. This permits a much greater flexibility
when programming. In particular when it
2
I C NXT SDA 6
NXT GND 3
GND
concerns hardware that is not officially sup-
ported by Lego, such as this compass sensor.
070156 - 11
References
[1] Compass sensor for Lego RCX,
Elektor Electronics July/August 2002
[2] Devantec:
www.robot-electronics.co.uk/shop/
Compass_CMPS032004.htm
[3] BricX:
http://bricxcc.sourceforge.net/
479
R
310 circuits
elektor international media bv – 089018/uk
pagina 479
Standard servo
The purpose of a standard servo is to bring
the shaft into a certain position and to keep it
there. At the input the servo expects a train of
digital pulses. The duration of these pulses
determines the position that the shaft has to 2
assume.
Small adjustment
A standard servo is there-
fore not suitable to turn
wheels or similar things.
However, with a little bit of
tinkering we can make a
servo suitable for this job.
480 480
L
310 circuits
elektor international media bv – 089018/uk
pagina 480
Mechanical
This modification doesn’t mean much from
the electronics perspective. The skill is to do
this in the small housing of a servo. As an
example we use a cheap servo from Conrad
(Figure 1). On the bottom of the servo are the housing after all. The motor should have a
four screws that we remove first. After this, small gear. This will sometimes be caught by
the bottom cover can be removed. the housing. If that is the case you need to re-
trieve the gear and put it back on the motor
Carefully loosen the cover plate. This con- shaft.
tains a number of gears that can easy drop
out. We need to know exactly how these are The potentiometer and motor are easily rec-
placed in the enclosure, because we need to ognised. We now replace the potentiometer
put them back in the exact same place later with two resistors. The resistors are each
on! individually soldered to one of the outside
Taking a picture of the inner works including connections, where the potentiometer used
the gears can be a very handy reference later to be. The other connections for both resis-
one when putting the servo back together. tors are then soldered to the middle connec-
Once that is done the servo looks like Figure tion.
2. Voilà, the servo is now converted. If all is well,
your servo will look about the same as our
Remove the output shaft. This sits on the prototype in Figure 4.
shaft of the potentiometer. This shaft is fitted What’s left to do is to put the servo back to-
with a ridge, which together with 2 ridges in gether. Make sure that all the gears are in the
the housing forms the mechanical end-stop. correct position and everything is free to ro-
This is undesirable, therefore remove this tate. Also check that the little gear on the
ridge with a sharp knife (Figure 3). motor is still in the right place.
The next job is to remove the PCB from the Finally we screw the bottom cover back in
housing. Should this not come out easily, place. The servo is now ready for use, but
then a careful push on the shaft of the poten- now as a motor and no longer as a servo!
tiometer usually ensures that it comes out of (070358-I)
481
R
310 circuits
elektor international media bv – 089018/uk
pagina 481
R2
L1
47k
33µH
D1 R6 +U OUT
8 4
R1 R R = 0,6 / I
7 T2
18k DIS T1 R7
IC1 R5
1k
6 3 1k
THR OUT
1 5
220n 470µ T3 220n 47n 470µ
470µ ≥14V
R3
C3
BC547
470 Ω
220p
070023 - 11
482
L
310 circuits
elektor international media bv – 089018/uk
pagina 482
old computer power supply (just check for a maximum voltage the NE555 can handle is
forward voltage of 0.2 V on the diode range of 15 V.
your multimeter). Finally, this power supply is not short-circuit
The supply shown here can deliver approxi- proof. A slow-blow fuse on the 12-V side is re-
mately 200 W. The input supply voltage can commended.
range from 7 V to 15 V. Don’t forget that the (070023-I)
483
R
310 circuits
elektor international media bv – 089018/uk
pagina 483
the counter. The data bits at the outputs will When building the circuit it is a good idea to
be held until a new packet from the trans- fit a test point at the output of the NE555 so
mitter sets FF01 again, whereupon the out- that the 18 kHz clock can be set accurately.
put is cleared and the bits read in afresh. The All of the timing in the circuit depends on this
stop pulse on pin 11 of the CD4040 can be signal.
used to validate the output data. (070089-I)
484
L
310 circuits
elektor international media bv – 089018/uk
pagina 484
2k2
10k
lin. IC1
10n 7 100µ
15V IC1 = 74HC14
IC1.A IC1.B
R1 S2
C1 1 2 3 4
1 1
4k7
22n T3
C2 D2 R6
220k
R2 R4
560p 1N4148 S1
470k
470k
BC548B
T1 T2
D1 C3
470n
1N4148
BC548B BC548B
RXUS TXUS
070236 - 11
485
R
310 circuits
elektor international media bv – 089018/uk
pagina 485
Using a PIC programmed in Basic, a Basic Current radio-control servos are very com-
Stamp or a Cubloc pact, bearing in mind they contain not only
their own mechanism, but also dedicated
C. Tavernier drive electronics, which only need simple TTL
or CMOS logic signals as an input. The power
Through robotics, radio-control servos are cur- they are able to supply can be quite conside-
rently experiencing a new lease of life, thanks to rable, for the most powerful of them were
their characteristics, which although not origi- originally intended for ‘large’ model planes or
nally designed for such applications, turn out in boats; and lastly, they are usually supplied
fact to be well suited to it. with a host of accessories such as crank arms,
486
L
310 circuits
elektor international media bv – 089018/uk
pagina 486
1 2
1.5 ms
centred
10 ... 20 ms
2 ms
+45 °
070238- 12
10 ... 20 ms
070238 - 11
perforated wheels, etc., making it easier to Figure 1 illustrates both the coding principle
interface them with the elements to be opera- of these pulses and the effect they have on
ted. the position of the servo. Note first of all that
they must be repeated at such a rate that
There are currently two fundamental ways of there is not more than 10–20 ms separation
using a servo in a robot. The first, described between two successive pulses.
elsewhere in this book, consists of converting In theory, this repetition is not absolutely
the servo into a propulsion motor, which ad- vital; but with it, the servo will be able to
mittedly is rather taking it away from its origi- maintain the position set by the width of the
nal function. The second, which we’re going pulses received. If the pulses do not repeat,
to be looking at here, involves its use for posi- the servo will indeed go to the position dicta-
tioning. Whether in an arm, or to turn a plat- ted by the last pulse received, but, as soon as
form carrying a camera, a telemeter, or any that stops, the slightest force on its shaft will
other unit, our servo is ideal for this. cause it to lose the position attained.
We won’t insult you by telling you what a Notice from the figure:
servo is like, since even if you aren’t a radio-
control enthusiast, you’re bound to have à a 1.5-ms pulse places the servo in its posi-
come across them before. However, here are tion referred to as centred or rest;
just a few pieces of information that it’s im- à a 1-ms pulse makes the servo turn to its
portant to be aware of so as to be able to maximum anti-clockwise position, which
make use of them. usually represents an angle of 45E with
respect to its rest position;
In electrical terms, a servo has just three col- à a 2-ms pulse makes the servo turn to its
our-coded wires. The red and black wires are maximum clockwise position, which too
for powering it, at between 4.8 and 6 V. The usually represents an angle of 45E with
third wire, yellow or white (or in practice any respect to its rest position.
colour other than red or black), is used to
convey commands to the servo in the form of Intermediate positions can be obtained by va-
pulse-widthmodulated (PWM) signals. rying the pulse width between 1 ms and 2 ms.
487
R
310 circuits
elektor international media bv – 089018/uk
pagina 487
For use in robotics, it is even possible to go position on one side to its extreme position
further and apply pulses a little shorter than on the other side, and so on. In this way it
1 ms or a little longer than 2 ms to the servo, can, for example, move a sensor in one plane
thereby achieving a total angle of rotation of over a total amplitude of 90E, see Listing 1.
180E. But watch out! At this point, we have The instruction PULSOUT generates pulses
gone outside the specifications for the servo, with a variable duration from 100 × 10 µs to
which is in danger of jamming in these ex- 200 × 10 µs depending on the changing value
treme positions, destroying its motor, its of the loop variable b2, while the spacing be-
electronics – or if you’re lucky, both at once! tween these pulses is set at 15 ms by means of
the instruction PAUSE.
Connecting a servo to a microcontroller
(Basic Stamp, PIC, Cubloc) is very simple, as This program is written here in Basic Stamp I
shown in Figure 2. The only point to watch language, but transposing it for Basic Stamp II
out for is the servo power supply. Given the or for use with a PIC programmed in Basic
relatively high current drawn by the servo only requires modification of the end values
when it turns, it’s best to supply it off a sepa- and the loop variable b2 increment. The
rate voltage rail from the microcontroller. resolution of the instruction PULSOUT is now
Where this is not possible, you need to en- 2 µs instead of 10 µs, so the various values
sure excellent decoupling between them – for need to be multiplied by 5. Using a servo with
example, by supplying the servo and the a Cubloc from Comfile Technology is just as
microcontroller via two separate regulators. simple, but uses an instruction called PWM,
as per Listing 2.
As far as the software is concerned, control-
ling a servo using a Basic Stamp or a PIC pro- In this type of application, the advantage of
grammed in Basic requires only a very few the Cubloc over the Basic Stamp is that the
lines of program. In fact, all that’s needed is PWM command generates the pulses indefi-
to call up the two instructions PULSOUT and nitely, even if the program continues on to
PAUSE. something else. In the case of the Basic
Stamp, the instruction PULSOUT generates
Here, by way of an example, is a program that only one pulse, and so has to be called from a
makes a servo turn slowly from its extreme loop in order to produce them continuously,
Listing 1 Listing 2
488
L
310 circuits
elektor international media bv – 089018/uk
pagina 488
preventing the Basic Stamp from doing any- (which can control up to 8 servos simulta-
thing else. If you don’t want to use a Cubloc, neously in a stand-alone manner (if necessary,
another solution consists in using a special- refer to circuit 096 on page 161)).
ized IC, like the MIC 800 from Mictronics (070238-I)
24V DC
R5 C4
1k5
220µ
R1 D2 63V
1k
P1 R4
14
2x
20k
R6
47 Ω
T1 R3
C2 C3
0Ω047
R7
10n 3µ3
50V 25V BC547B 4W
4k7
070127 - 11
typ. 12V
489
R
310 circuits
elektor international media bv – 089018/uk
pagina 489
input threshold of IC1.B (half the supply volt- With the component values shown the circuit
age) is exceeded, the PWM signal once again is suitable for use with 12 V lamps at up to
starts to drive T2. Thus even if there is a conti- 60 W. The current limit, set by R3 (47 mΩ) is
nuous short circuit on the output there will around 12 A.
be occasional pulses of output current.
The current limit is essential because cold
R5, D1 and C1 reduce the input voltage of lamps present a very low resistance when
24 V to a value of 16 V more suitable for voltage is first applied. The mark-space ratio
powering the CMOS 4093 Schmitt trigger IC. is set to approximately 1:3 (25% on-time)
D4 and D5 protect T2 from voltage spikes, using P1. The circuit can be modified for use
which are practically unavoidable in this cir- at higher currents, and it can also be used as
cuit because of the inductance of the wiring. the basis of a simple and efficient speed con-
Any standard Nchannel FET able to withstand troller or light dimmer.
100 V can be used for T2. (070127-I)
VCC
1 2
R1
I photo
T1
070356 - 12
070356 - 11
490
L
310 circuits
elektor international media bv – 089018/uk
pagina 490
3 4
VCC
IN
070356 - 13 070356 - 14
and time measurement can be easily perfor- 2 The pin is configured as an input Pin (any
med using a single I/O pin of a microcontrol- pull-up resistor is disconnected) and the
ler and switching it between output mode time is measured until the input voltage
and high-impedance input mode. The meas- level falls below the lower input threshold
urement is performed in two stages: level (Figure 4).
1 The pin is configured as an output and set The Example program is a listing for an Atmel
to high to charge up the LED capacitance AVR processor which measures light inten-
(Figure 3). sity. The program toggles all the output bits
int main()
{
unsigned char cr=0,cb=0;
DDRB = 0x00; // PORTB input
DDRA = 0xff; // PORTA output for display LEDs
PORTA = 0; // off
PORTB = LEDPIN; // PB6 hi
sei();
while(1)
{
if((PINB & LEDPIN) == 0) // discharge complete
{
PORTB = LEDPIN; // PB6 hi
// multiple times to get enough charging time
DDRB |= LEDPIN; // PB6 output and hi, charges LED
DDRB |= LEDPIN; // PB6 output and hi, charges LED
DDRB |= LEDPIN; // PB6 output and hi, charges LED
DDRB |= LEDPIN; // PB6 output and hi, charges LED
491
R
310 circuits
elektor international media bv – 089018/uk
pagina 491
from port A after each cycle so that it pro- angle’ making them more directional which
duces an output square wave with approxi- may be beneficial in some applications. Diffe-
mately 50 % duty cycle at a frequency rent LEDs are sensitive to specific colours
proportional to the measured illumination. which can also be useful in some robotic
The frequency varies from millihertz (in a applications.
darkened room) up to several hundred kilo- (070356-I)
hertz when light shines directly onto the LED.
This measurement range would be difficult to Web Link
achieve using an A/D converter. Narrow beam [1] www.merl.com/publications/TR2003-035/
LEDs have a corresponding narrow ‘detection
Jens Altenburg
10 A, so we choose high-
current power MOSFETs for C11
10k
RFP30P06 RFP30P06
choose from. T4
D2 D1
T5
EN EN
10k
IC7.B
The schematic of the H- DIR 4
5 &
6
492
L
310 circuits
elektor international media bv – 089018/uk
pagina 492
few inverters, NAND gates and two tri- To control the DC motor, three signals are
stateable drivers. These logic functions are needed: DIR, PWM and STOP. DIR controls
very important as the easier way, i.e.., directly the direction of the motor revolution, PWM
controlling all four MOSFET has a fatal dis- the speed, and STOP brakes the motor.
advantage. The software module for the DC motor is
called dcm.c.
In case of a software crash it could happen (070172-I)
that two ore more MOSFETs are switched on
incorrectly, for example, T4 and T7. In that
case, the current through the transistors is li- [1] The complete document called Zbot — the Ro-
mited by the internal resistors of the bot Experimental Platform is available for free
MOSFETs (about 10 mΩ) only. Such a fatal downloading from the Elektor website. The file
error would destroy the MOSFETs. The logic number is 070172-11.zip (July/August 2007).
functions configured here effectively avoid il-
legal states.
Antoine Authier
& Karel Walraven
493
R
310 circuits
elektor international media bv – 089018/uk
pagina 493
parameters for the number of cells to be integrated circuit will not operate correctly
charged, the maximum charging period, as and may not correctly detect completion of
well as the method to detect when it is fully the fast-charge (entailing a risk of damage
charged (inflexion point or negative slope). that could affect the connected batteries).
You can refer to the datasheet to find out
more. The MAX712 is intended for NiMH bat- Setting the circuit parameters
teries, with charge completion at the in-
flexion point of the voltage curve (∂V/∂t = 0). à The PRGM0/PRGM1 pins are used to regu-
late the number of cells to be charged. A
The maximum power supply voltage is 15 V. note concerning the use of a battery crad-
The power supply voltage must be at least 2 V le: during recharging: each contact can re-
above the maximum charging voltage in present a 1-Ω series resistance, which is
order to compensate for
voltage fluctuations during
charging. Therefore, for a
maximum charging voltage
of 1.6 V per cell, a 15-V
power supply voltage is
used to charge 8 series-
connected batteries. A 12-V
voltage level (supplied, for
example, by a car battery) is
used to recharge six cells.
The power supply must be
able to supply 1 A. It is im-
portant to be certain of its
specification. If the require-
100%
494
L
310 circuits
elektor international media bv – 089018/uk
pagina 494
COMPONENTS LIST
seen as a 1-V potential difference at 1 A. L1 are not critical; a traditional 100 µH/5 A
The power supply voltage may not be ade- suppressor choke will work fine. The same
quate for this configuration – therefore, it holds true for diodes D2, D3 and the MOSFET
is preferable to verify this detail before transistor T5; they too are not critical in this
beginning the project. application. You can use any Schottky diode
à For security reasons, it is preferable to that can withstand 3 amps and include any
properly configure the maximum char- MOSFET with a lower drain resistance.
ging period with the PRGM2/PRGM3 pins.
à On this setup, the temperature control A compact PCB was designed for the circuit.
circuit for the batteries is deactivated. Mounting the components should be all plain
sailing, but do not forget the two wire links
At the end of the fast-charge, the circuit will on the board. Inductor L1 is a toroid ‘suppres-
power the batteries with a maintenance sor choke’ with a good size. Connectors K1-
charge (trickle). Let’s examine the circuit’s K4 allow different charging parameters to be
electronics. T1 is uses as a current source set up.
supplying the 8 mA necessary to power the
MAX712. D3 ensures that the battery does Since the calculation principle is the same as
not discharge into the circuit in case it is not for the NiCd charger with the MAX713 on
powered. page 517, we refer you to the calculation
example proposed there. Use the same tables
The LED D1 lights up when the circuit is in to set the parameters of this circuit as the
fast-charge mode. T5 may be mounted on heat- ones given in that article.
sink, if necessary. The characteristics of coil (070213-I)
495
R
310 circuits
elektor international media bv – 089018/uk
pagina 495
1k
14 2 electronic switches inside
IC2
7 16
IC2.B 3
R2
the 4066 and so the series
0
9 5 resistance effectively seen
1k
R6 R5 P1
CTR12 1
7 in the audio signal line.
6 4
The circuit should be powe-
10k
100k
1k
C1 T1
CT
6
4
consume a few milliamps
only.
10µ 4040 13 10
7
11 12
12V
CT=0 8
14
IC2.D 9
R4 Switch S1 allows the coun-
BC547 9
10
15 6 ter to be reset, switching all
1k
MIC1 S1 11
1
4066 switches to off, i.e.,
the highest attenuation will
8
8
RESET
IC2 = 4066 exist in the audio path as in
that case none of the 1-kΩ
070034 - 11
resistors are shorted out.
To calibrate the circuit, dis-
connect the 4040 clock in-
analogue switches connected to a resistive put (pin 10) from the wiper of P1, and
ladder network. temporarily ground it through a 100 kΩ resis-
Looking at the circuit diagram, the signal tor.
from electret microphone M1 is amplified by Now pulse the clock input by briefly connec-
T1 whose collector voltage appears across a ting it to the +9 V line; you will see the coun-
potentiometer. M1 gets its bias voltage ter outputs change state and with them, the
through R4. Depending on the setting of P1, bilateral switches in the 4066.
the 4040 counter will get a clock pulse when a (070034-I)
496
L
310 circuits
elektor international media bv – 089018/uk
pagina 496
R1
à High sensitivity and accuracy for CO Some potential applications for the sensor
à Linear relationship between CO concen- are:
tration and output voltage à Residential CO detectors
à Low sensitivity to ethanol à CO monitors for industrial applications
à Low sensitivity to other gasses that may à Ventilation control for indoor car parks
be present (070187-I)
497
R
310 circuits
elektor international media bv – 089018/uk
pagina 497
10k
7
or building a driver based around conven- GP0
GP1
6
GP0
498
L
310 circuits
elektor international media bv – 089018/uk
pagina 498
the R input has priority, and so the motor switching of the current in the motor wind-
turns in that direction. ings and protect the transistors.
The motor’s speed of rotation is fixed, but, However, if the motor used draws less than 500
since we are giving you the source listing of mA, and more importantly, if you need to drive
the software used for this application, it’s two motors of this type, an elegant and inge-
very easy for you to modify this if it doesn’t nious solution exists, as shown in Figure 3.
suit you, or indeed even to include the possi- This uses a standard ULN2803, usually used
bility of external adjustment if necessary. to drive relays, but which includes eight me-
The circuit of the ‘intelligent’ part of our con- dium-power Darlingtons along with their pro-
troller is shown in Figure 1, as you can see it tection diodes. So, this IC is able to properly
uses a PIC12C508 microcontroller from Micro- drive any kind of single-pole stepper motor,
chip. Used here in internal clock and reset cir- as long as the voltage required doesn’t
cuit mode, it needs no external components exceed 50 V and the current per winding is
for these functions, so all its port lines are under 500 mA.
available. In addition, as the ULN2803 contains eight
Parallel ports GP2 and GP3 are used as inputs, identical stages, it can be preceded by two
and as GP2 does not have an internal pull-up controllers like the one in Figure 1 and in this
resistor, this is performed
by R1. Parallel ports GP0, +U
3
GP1, GP4, and GP5 are used
as outputs for generating
the pulses for the motor
windings. These can be am-
plified by two types of L2 L1
IC2.
499 499
R
310 circuits
elektor international media bv – 089018/uk
pagina 499
way drive two robot propulsion motors: one served, other than to not exceed the IC’s
on the left and one on the right, marked MA maximum current capacity of 500 mA.
and MB in this figure.
As we are providing you with the full source
Constructing one or other of these versions is listing of the software programmed into the
very straightforward. The PIC 12C508 needs 12C508, you’ll be able to modify it to suit
to be programmed with the file that you’ll your needs. If you are unfamiliar with PIC
find in object form, as well as in source form, microcontroller assembler, here are the
in case you’d like to modify it, on the Elektor details you’ll need for the most important
website, as well as on the author’s own site. modification you might want to make:
If you build the transistor power amplifier, changing the speed of the control pulses to
note that T1–T4 don’t need a heatsink as long the motors, and thus, their speed of rotation.
as the motor consumption doesn’t exceed The control word may be found in Table 1.
1 A. Otherwise, bolt them onto a small alumi- To do this, all you have to do is modify the bi-
nium plate a few cm2. To simplify mechanical nary constant on the line:
construction, it can be common to the four
transistors, but in this case you’ll need to use MOVLW B’10010101’
the standard insulating accessories of mica
washers and shouldered washers, as the col- just above the line containing OPTION in the
lectors of these transistors are connected to source listing. With the original value, the
the metal parts of their cases. duration of one step is 8 ms, but the table
above indicates what constant to use accor-
If you construct the ULN2803-based version, ding to the step duration that you may want.
there are no special precautions to be ob- www.tavernier-c.com (070302-I)
Tilo Gockel
here. C
10n
A microcontroller produces a PWM (pulse
width modulated) digital output signal which -10V
500
L
310 circuits
elektor international media bv – 089018/uk
pagina 500
Guidelines to calculate values for the RC low- DC can also be handled by this circuit and in
pass filter are given in the application note. this case the low-pass filter corner frequency
Using the values suggested (3.9 kΩ and 10 nF) can be reduced further which will give better
gives a –3 dB corner frequency of around attenuation of the PWM fundamental and re-
4 kHz. When driven by a PWM frequency of duce ripple on DC output signals.
approximately 20 kHz the filter will be suit- One typical application of the circuit is speed
able for outputting audio tones and voice sig- control of a DC motor in accordance with the
nals with a bandwidth of 4 kHz. This simple industry standard ±10V. The circuit will con-
filter will attenuate the 20 kHz fundamental nect to the motor via a suitable power driver
PWM frequency by 14 dB which may not stage. In this case the electromechanical
sound like much but the human ear has its properties of the motor itself will act as a low
own high frequency roll-off (the characteris- pass filter.
tics of which change as we age) so frequen- (070133-I)
cies this high will be barely audible.
Web Link
Any standard operational amplifier, for exam- [1] http://ww1.microchip.com/downloads/en/
ple the TL071 can be used in this application. AppNotes/00538c.pdf
Lower frequency signals all the way down to
Pascal Choquet out the S/H the last element would show the
highest sensitivity.
Industrial production-line robots require high- The accompanying table lists the most impor-
resolution sensors to measure the position of tant properties of some common arrays. The
robotic actuators so that the tools can be ac- sensitivity is dependant on the active diode
curately guided onto the work piece. A photo surface area and the integration time.
diode array together with an external light
source is often used as a sensor in this appli- From the outside these arrays look very
cation. This chip contains a line of photo simple, apart from the two supply connec-
diodes together with a series of sample and tions there are only three signals for connec-
hold (S/H) circuits which take a snapshot of tion to a microcontroller: A clock input (CLK),
the readings of each photo diodes at the same a start impulse (SI) input and an analogue out-
instant and then outputs these integrated ana- put signal (AO). AO should be loaded with a
logue values serially from a single output. 330 Ω resistor to ground. To readout the
The S/ H circuits are important because the array values the controller firstly generates
sensitivity of each element to the light quanta the clock signal and then sets SI high (with
is dependent on the integration period; with- sufficient set-up time) before a rising clock
501
R
310 circuits
elektor international media bv – 089018/uk
pagina 501
+5V
R2
C6 C5
10k
100n 100n
20
K1
1
MCLR/VPP
IC3
7 C3
RA5/AN4/SS/LVDIN 1µ
6
RA4/T0CKI
5
RA3/AN3/VREF+ 25V
4 2
4 RA2/AN2/VREF-
3 1 V+ 16
RA1/AN1 C1 C1+
2
IC2 RA0/AN0
IC1
3 3
A OUT PIC18F242 1µ C1– K2
1 21 18 25V 12 13
SI RB0/INT0 RC7/RX/DT R1OUT R1IN RX
2 22 17 11 14
CLK RB1/INT1 RC6/TX/CK T1IN T1OUT TX
23 16 10 7
MLX90255 RB2/INT2 RC5/SDO T2IN T2OUT
24 15 9 8
RB3/CCP2 RC4/SDI/SDA R2OUT R2IN
25 14 4
5 RB4 RC3/SCK/SCL C2 C2+
26 13
RB5/PGM RC2/CCP1 MAX232
27 12 1µ 5 15
RB6/PGC RC1/T1OSI/CCP2 C2–
28 11 25V V-
RB7/PGD RC0/T1OSO/T1CKI
6
OSC1 OSC2 C4
8 9 10 19
R1 X1
1µ
25V
330Ω
C10 C9
15p 15p
4.9152MHz
070314 - 11
edge. On successive falling clock edges the carded. The integration time is equal to the
value of each individual pixel will be output at pixel count minus 18 divided by the clock fre-
AO. The microcontroller reads each level and quency. The sensitivity can be easily control-
stores its value. led by the microcontroller.
A feature of the MLX90255 type array is that
the first two values read out are dummies, the The circuit diagram shown here consists of
first of the 128 real values appears at the third the photodiode array together with a basic
clock edge. The two values after the 128th value PIC microcontroller and a driver chip for an
are also dummies, the read out therefore re- RS232 serial interface connection. The author
quires 132 clock edges in total to read all the has produced a program written in C which
data and the final 133rd edge reinitialises the can be used in the controller. The source files
shift register. The gain of the pixels at either (070314-11.zip) are available to download
end of the array is about 15 % greater than free of charge from the Elektor website. A
those in the centre (cosine weighting) this scan cycle is initiated using a terminal pro-
compensates for the light loss experienced at gram by entering ‘Strg S’. The values are sepa-
the edges when the array illumination is pro- rated with semicolons so they can be easily
vided by a single LED. used in an Excel table.
The integration period begins at the 18 th Photodiode arrays can be used in robotics for
clock edge and continues until the next SI sig- imaging based on the pinhole camera prin-
nal. The output values are the result of the ciple, they have also been used in line-
previous integration period so if the array is following applications where they offer good
not continuously scanned then it is necessary resolution and can be mounted relatively far
to make two complete scans to get meaning- away from the floor. Together with a prism or
ful results. The first scan cycle after power up optical grating the array can be used to per-
is used to initialise digital levels on the chip, form simple yet precise colour recognition.
the values read are invalid and should be dis- (070314-I)
502
L
310 circuits
elektor international media bv – 089018/uk
pagina 502
Jörg Schnyder
The LM3578 is a general-purpose switch- Network R4, C2 and C3 provides loop com-
mode voltage converter. Figure 1 shows its pensation. The current-sense resistor for the
internal block diagram. Here we use it as a
step-up converter. The circuit diagram in
1
Figure 2 shows the necessary components.
Voltage conversion is achieved by switching
on the internal transistor until it is switched
off by the comparator or the current-limiting
circuit. The collector current flows through
coil L1, which stores energy in the form of a
magnetic field.
503
R
310 circuits
elektor international media bv – 089018/uk
pagina 503
2 L2 L1
47µH 820µH
8
D1
K2 R4 1 UIN 6
1 -IN C
+5V R5 K1
220k
2 C3 IC1 SK34SMD
D– 2 7
82k
3 +IN I LIM
D+ C2 22p
GND
4 LM3578AM
3 5
OSC E
USB 2n2
R1 R2 R3 R6
C1 C9 C10 C5 C11 C8 C7 C6 C4
1Ω
1Ω
1Ω
10k
100n 47µ 47µ 1n5 68µ 68µ 68µ 68µ
16V 16V 20V 20V 20V 20V 100n
070119 - 11
current-limiting circuit is formed by three 1-Ω R5 and R6 for other output voltages
resistors in parallel (R1, R2 and R3), since 6V R5 = 47 k, R6 = 9,1 k
SMD resistors with values less than 1 Ω are 12 V R5 = 110 k, R6 = 10 k
hard to find. The output voltage ripple is de- 15 V R5 = 130 k, R6 = 9,1 k
termined by the values and internal resistan-
ces of capacitors C11, C8, C7 and C6.
3
The total effective resistance is reduced by
using several capacitors, and this also keeps
the construction height of the board low. L2,
C1, C9 and C10 act as an input filter. Ensure
that the DC resistance of coil L2 is no more
75%
504
L
310 circuits
elektor international media bv – 089018/uk
pagina 504
programmer functionality. 1 20 C1
R1
100k
14 IC1
100n
In case you did not know, AVR microcontrol-
26 2 10
15
505
R
310 circuits
elektor international media bv – 089018/uk
pagina 505
Jens Altenburg
2k
82k
BATT
7
rechargedischarge voltage 3
VCC
6
diagram, we know that the RG1 RG2
D8
V BATT IC6 SIGN
51k
506 506
L
310 circuits
elektor international media bv – 089018/uk
pagina 506
through R24//R26 as a proportional voltage at tor wirelessly. In this way, the independent
pin 8, and the current direction through the power source increases the security of the
resistors (SIGN). Both values allow calculation system.
of the charging (solar panel) or discharging of (070171-I)
the battery pack.
The auxilliary power is shown in the CPU unit.
The two alkaline batteries support the CPU,
the wireless radio modem and the navigation [1] The complete document called Zbot – the
system (compass) only. Robot Experimental Platform is available for free
downloading from the Elektor website. The file
number is 070172-11.zip (July/August 2007).
The reason for the division of the power sup-
ply is simple. With the help of the auxiliary
system, zBot communicates with the opera-
with a PIC or a Basic Stamp able, insofar as we wish to stick with products
at prices compatible with an ‘amateur’ robot.
C. Tavernier
This range, whose part numbers all begin
Although the simplest robots may be content with GP2…, includes telemeters that provide
to simply detecting obstacles, many robots on/off outputs (though these aren’t really
that require precision in their positioning telemeters as such!), information in analogue
need to be able to measure distances accu- form, and information in digital form. Though
rately. To achieve this, it is necessary to use a the versions providing analogue information
telemeter, which can be infrared or ultra- would appear to be the easiest to use, it’s ab-
sonic. IR is very suitable for measuring short surd to use them in a robot driven by a
distances (a few centimetres up to a few tens microcontroller, which will immediately con-
of centimetres), while ultra-
sound is more suitable for
1 VCC
distances from a few tens of
centimetres to several 3
metres. VCC
Regulator
Although it is still possible Reflective
object
VCC
to construct a telemeter
Signal
using standard resources, Control
12k
processing
circuit
these days it’s not really circuit
4 VOUT
worthwhile because of the Light detector (PSD)
availability of ready-to-use
integrated modules that are LED drive
circuit
2 VIN
all relatively accurate, cheap,
(Control
IR LED signal
VCC
at IR telemeters, the Sharp 1
507
R
310 circuits
elektor international media bv – 089018/uk
pagina 507
Output
508
L
310 circuits
elektor international media bv – 089018/uk
pagina 508
Read
BCF PortA.0 ' Validation of telemeter
NOP
Wait
BTFSS PortA,1 ' Wait until result is available
GOTO Wait
BSF PortA,0 ' Vin goes High
CLRF Measr ' Initialization of the variable « Measr »
MOVLW 8 ' Get ready to read 8 bits
MOVWF Count
BCF Status,C ' Zero the carry
NOP
Readbit
BCF Porta.0 ' Make clock Low
NOP
NOP
RLF Measr,f ' Rotation of preceding bit
BTFSC PortA.1 ' Read data bit
BSF Measr,0
BSF PortA.0 ' Make clock High
NOP
NOP
DECFSZ Count,f ' Count down number of bits to read
GOTO Readbit
The telemeter application circuit can be A glance at the timing diagram in Figure 3
summed up as shown in Figure 2, whether it’s shows us that this input is used not just for
with a PIC or a Basic Stamp. The GP2D02 or validating the measurement, but also as a
GP2D021 detector is powered all the time, clock for transferring the reading to the Vout
but because it has a control input, it con- terminal. Hence it needs to be controlled by
sumes virtually nothing when there is no the associated microcontroller, but as it must
measuring taking place. not be subjected to a voltage above 3 V, diode
509
R
310 circuits
elektor international media bv – 089018/uk
pagina 509
510
L
310 circuits
elektor international media bv – 089018/uk
pagina 510
+VS
2
OUT 1 OUT 2 OUT 3 OUT 4
100n
2 3 4 13 14
+VSS
9
Vref
A B
100n
1 2 3 4
IN 1 5 12 IN 4
IN 2 7 10 IN 3
EN A 6 11 EN B
1 8 15
SENSE A SENSE B
RSA RSB
070317 - 12
force).
OUT1(3)
511
R
310 circuits
elektor international media bv – 089018/uk
pagina 511
Table 1
EnA(B) In1(3) In2(4) M1 M2
H H H Braked Running
H L L Running Braked
L X X Freewheel stop Freewheel stop
M
ting safety by monitoring
the current drawn by the
D1 D2
D1 ... D2 =
BY252; 1N5402 motors. To do this, all that
you have to do is to fit a
very low value resistor be-
OUT OUT
tween the SENSE A or
1(3) 2(4)
SENSE B inputs and earth.
All the current drawn by the
+VSS +VS
IN1(3)
IN1(3) IN2(4) motor connected to the cor-
1
/2 L298 C1 responding amplifier will
ENA(B)
ENA(B) then pass through this resis-
GND
100n
tance, and by simply apply-
IN2(4)
ing Ohm’s law and
measuring the voltage at
these inputs, it is possible
070317 - 14 to monitor this current.
If you don’t wish to use this
monitoring, you are recom-
mended to protect the IC
5 D1 R1
10k against possible shorts of
1N4148 its outputs to earth, which
are the most likely to occur
1
/4 L298
C1
In x Out x in a robot (a motor terminal
1n5
touching the metal chassis,
070317 - 15 for example!) In this case,
STMicroelectronics recom-
mends the circuit in Figure
inputs of the L298, you can even have two op- 5. This circuit trips in 10 µs and resets by it-
tions for motor stopping, as indicated in the self when the short disappears.
table below: the ‘freewheel’ or unbraked The L298 is capable of withstanding a maxi-
mode, or the braked mode, as seen previous- mum supply voltage of 46 V and each of its
ly with the relay circuit. Table 1 shows the re- power amplifiers can supply a current of 2 A,
levant logic level combinations. already a more than comfortable value, even
If the direction of rotation of the motor has to for a relatively heavy mobile robot. If that
be able to be changed, it is necessary to use a isn’t enough for you, it is also possible to con-
bridge or H connection, as shown in Figure 4. nect the power amplifiers in parallel, as long
Note that it is possible to drive two motors in as you go about it the right way. You then
this way from one L298, since the IC contains have a maximum output current of 3.5 A. To
four amplifiers. So, a single L298 is usually do this, you must adhere to the circuit in Fig-
enough for the right and left propulsion ure 6 and no other; that is to say, you must
512
L
310 circuits
elektor international media bv – 089018/uk
pagina 512
+VSS
4
+VS
9 100n
Hesam Hoshiri
+5V...+12V
33k
1k8
home. C1
T1
2SC945
D1 RE1
The circuit can work from any 5–12 VDC regu-
0µ1
2SC945
MIC1
lated power supply provided a relay with the
suitable coil voltage is used. 1N4007
513
R
310 circuits
elektor international media bv – 089018/uk
pagina 513
of the effect of capacitor C2. Allow a few sec- side which requires a bias voltage to operate.
onds for the relay to be switched off. You can The optimum bias level for response to sound
increase or decrease the ‘on’ period by chang- has to be found by trial and error.
ing the value of C2. A higher value results in a (060379-I)
longer ‘on’ period, and vice versa. Do not use
a value greater than 47 µF.
All relevant electrical safety precautions
Biasing resistor R1 determines to a large ex- should be observed when connecting mains
powered loads to the relay contacts.
tent the microphone sensitivity. An electret
microphone usually has one internal FET in-
Abraham Vreugdenhil
1
When designing a robot, a
choice has to be made as to
the types of sensors that it
will have. This choice will be
determined mostly by the
purpose of the robot. But
the degree of complexity
required in using the sensor
and the cost of the sensor
also play a role, of course.
Sensors that are favourable
in these respects are for
example bumpers and feelers with micro- able from any builder’s market or hardware
switches, IR distance sensors from Sharp and store for a reasonable price. These are
ultrasonic sensors. If we want to detect mo- offered for sale at less than £ 7.00. After dis-
ving warm objects, such as people and ani- assembly of the sensor, the main board with
mals, then PIR (passive infrared radiation) its daughter board remain (Figure 1). The
sensors from Eltec, in particular, become a daughter board contains the PIR sensor and
consideration, such as the Eltec-442. accompanying electronics. The connection
This is a very nice sensor, but the price is a
problem unfortunately, more than 60 dollars. 2
Conrad Electronics also have a PIR sensor
available, the LHI958 (order number 178730)
for just over £ 2.50. The disadvantage of this
sensor is that an amplifier has to be added in
order to obtain a usable output signal. The
documentation for the sensor is not particu-
larly clear about this.
Another solution is a sensor that we often
meet in daily life: the well-known movement
detector for outdoor lighting, which is avail-
514
L
310 circuits
elektor international media bv – 089018/uk
pagina 514
points for the power supply and output signal field of view of 140 degrees, so the shielding
can be found on the back (Figure 2). The is definitely required. It is advantageous if the
sensor is normally powered from 8 V, but it fields of view of the sensors overlap. In this
still works well at 5 V. way three sensors can be used to make five
detection zones. It is of course also possible
A robot will often be fitted with multiple PIR to use more sensors so that a greater resolu-
sensors that are mounted at different angles. tion is obtained.
To achieve this, we can mount three sensors In this manner it is reasonably cheap to build
on a piece of prototyping board and limit the a nice PIR sensor unit. The one shown in the
view of each sensor with a short section of example (Figure 3) comprises three PIR sen-
electrical conduit. sors. This sensor unit is easy to build and
The length of the conduit determines the works well.
field of view. The sensors on their own have a (070189-I)
515
R
310 circuits
elektor international media bv – 089018/uk
pagina 515
1 8
IN1 IN1 OUT1 M1
IC1
The major drawback of the radio-control 3
VCONT NC
6
M
servo lies not so much in its pulse drive mode, 4
LB1630 5
for which various solutions are proposed
IN2 IN2 OUT2
516 516
L
310 circuits
elektor international media bv – 089018/uk
pagina 516
517
R
310 circuits
elektor international media bv – 089018/uk
pagina 517
T1
+VA TIP32A
LED1
R1
* see text R3
*
C1
R2
150 Ω
D1
680 Ω
10n
1N4002
V+
5 8 15
K1
THI FCHG V+
3 14
PGM0 DRV
K2 4
PGM1 +BATT
9 2
PGM2 BAT+
K3 10
PGM3
IC1
K4
1 BATT
VLIM
BATT- REF 16
REF
R4 MAX713
12
68k
BAT–
-BATT
7 11
TEMP CC
R5
C5 C2 TLO GND C3 C4
22k
6 13
10µ 1µ 10n 10µ
25V 25V 25V
R6
070301 - 11
batteries entrusted to them, which can seri- the temperature detection method, which re-
ously shorten their life. quires a thermal sensor (NTC or equivalent)
inside the battery. So resistors R4 and R5 in
So this article proposes building your own conjunction with the hard-wired links to in-
tailor-made charger, using an IC that’s already puts THI and TLO program the MAX713 into
old, but still very much current: the MAX713 the mode that detects end of charge by volt-
from Maxim. As all robots are different, we’re age variation.
not going to suggest a completely finished
circuit, but will instead explain how to adapt So now let’s see how to determine the other
it to suit the characteristics of the batteries elements that are still open to you, so you’ll
you’ll be wanting to recharge. be able to build a charger that’s just right for
The MAX713’s basic application circuit is your needs. Note right away that the
shown in the figure, but as you can see, cer- configuration links can either be hardwired
tain elements have no values shown. In addi- on the PCB that you’ll be designing for your
tion, there are various configuration links. Via charger, or else connected to multi-way
these various elements, the MAX713 lets you switches to create a multi-purpose charger.
charge from one to 16 cells (a cell is a basic You first need to decide Ifast, the charging
1.2 V element), define the charging current, current for your batteries, whose capacity C is
define the end-of-charge float current, and expressed in ampère-hours (Ah). This can be
lastly, select the mode for detecting end of calculated from:
charge. As far as the latter is concerned, and C
so as to be compatible with any batteries you I fast =
are likely to use in your robot, we’ve left out t
518
L
310 circuits
elektor international media bv – 089018/uk
pagina 518
where t is the desired char- Table 1: programming charge time via PGM2 & PGM3
ging time in hours. Maximum charge time (min.) PGM3 PGM2
Watch out! The MAX713 22 V+ REF
does not handle times over 33 V+ BATT–
4 hours. And take care not 45 NC REF
to pick a value for Ifast above 66 NC BATT–
4C, which is currently the 90 REF REF
maximum current permit- 132 REF BATT–
ted for fastcharging NiCad 180 BATT– REF
and NiMH batteries. If you 264 BATT– BATT–
are able to choose a lower
current, so much the better, Table 2: programming number of cells via PGM0 & PGM1
it will prolong battery life. Number of cells PGM1 PGM0
Program this charging time 1 V+ V+
by wiring pins PGM2 and 2 NC V+
PGM3 of the MAX713 as per 3 REF V+
Table 1. 4 BATT– V+
Then choose the number of 5 V+ NC
cells to be charged at the 6 NC NC
same time. 7 REF NC
For block batteries, you can 8 BATT– NC
find the number of cells by 9 V+ REF
dividing the nominal volt- 10 NC REF
age of the battery by 1.2 V. 11 REF REF
So a 9.6 V battery will con- 12 BATT– REF
tain eight cells. If the num- 13 V+ BATT–
14 NC BATT–
ber of cells is 11 or more,
15 REF BATT–
the circuit can’t be used as
16 BATT– BATT–
is, and in that case it’s
better to charge your
batteries in two goes. Program this number 20 mA, using the equation:
by wiring pins PGM0 and PGM1 of the V -5
MAX713 as per Table 2. R1 = A
Then choose the unstabilized DC supply volt- I
age for your charger (VA in the figure) so that where I is between 5 and 20 mA.
it is at least 1.5 V higher than the maximum
voltage of the battery to be charged. If your Lastly, determine the value of resistor R6 by
battery has less than four cells, this rule no using the equation:
longer applies, as the MAX713 supply has to 0,25
be a minimum of 6 V. R6 =
Then determine the maximum power dissi- I fast
pated in T1 using the following equation: and its power by using
where VBATTmin is the minimum voltage of the (theoretically 0.25⋅Ifast in fact, but it’s best to
battery to be charged. Choose T1 accor- use a safety factor of 2, hence the modified
dingly, if necessary fitting it with an appropri- equation). Your charger is now operational,
ate heatsink. and is extremely simple to use; but because of
Then determine the value of resistor R1 so the processors inside the MAX713, it is essen-
the current drawn by the MAX713 will be 5 to tial to make the connections to PGM0 to
519
R
310 circuits
elektor international media bv – 089018/uk
pagina 519
520
L
310 circuits
elektor international media bv – 089018/uk
pagina 520
521
R
310 circuits
elektor international media bv – 089018/uk
pagina 521
The complete circuit looks like Figure 1. The The calculation of the pulse lengths to be ap-
two ports P0 and P1 of the Basic Stamp I are plied to the servos can then be performed,
used to drive the right and left propulsion noting that RightStop and LeftStop are the
servos. The brightness is measured using two values making it possible to make the servos
photoresistors or LDRs (still called CdS cells stop, and that Move is a parameter intended
in some literature) connected to ports P6 and to set the basic speed of the servos, to which
P7 of the Basic Stamp I. The odd mode of con- is added or subtracted the result of the diffe-
nection used here makes it possible to use an rence in illumination.
instruction specific to the Basic Stamp I, the
instruction POT, which measures the charging Hence, for example, if LightDif has the value
time of a capacitor connected to one of its 50, b0 will be 150 + 30 – 50, i.e. 130, while b1
ports, i.e. thereby the resistance of the LDR will be 150 – 30 + 50, i.e., 170. Given that the
and thus the brightness falling on it. resolution of the PULSOUT pulse is 10 µs, the
program will thus generate 1.3 ms pulses for
For the robot to be able to head towards the one servo and 1.7 ms ones for the other, cau-
brightest part of the room where it is opera- sing the robot to turn towards the direction
ting, these two LDRs must be mounted poin- of the LDR that is receiving the most light. So
ting forwards, separated from each other by a this program is fully functional, but, given the
small piece of cardboard or opaque PCB in spread in the characteristics of both the
such a way they can’t both receive the same servos, with respect to their drive pulses, and
illumination. the resistance of the LDRs, it will undoubtedly
be necessary for you to tweak certain numeri-
The assembly can be powered by four 1.5 V cal parameters again to obtain satisfactory re-
batteries. This voltage is applied directly to sults. To do so, note that:
the servos and to the unregulated PWR input
of the Basic Stamp I. à RightStop and LeftStop are equal to 1/10
of the pulse width that makes the right
Watch out! Under no circumstances connect and left servos stop.
the servo supplies from the Basic Stamp I’s +
5 V output – its built-in 5 V regulator wouldn’t à Move lets you define the rotational speed
appreciate it! of the servos when the robot is going
straight ahead. It is equal to 1/10 of the
The software part of our robot is at least as difference between the pulse width for
simple as the hardware part, as you can judge stop and the pulse width desired for mo-
from the listing on the previous page. ving straight ahead.
This listing is very easy to analyse. After an à The coefficients 128 used in the POT in-
initial phase to define the labels used and the structions can also be adjusted between 1
reservation of the RAM in the Basic Stamp I, and 255 in order to obtain satisfactory be-
we go on to measure the light using the in- haviour of the robot, given the LDRs used
struction POT. This instruction returns, in the and the ambient light in the place where
variable LeftLDR (or RightLDR ), a number re- the robot is operating.
presenting the resistance of the LDRs connec-
ted to P6 and P7 divided by a constant called a Note too that if your robot seems to shy away
scaling factor. You may need to adjust this from the light instead of moving towards it,
parameter to suit the characteristics of the you’ve probably reversed the wiring between
LDRs you use. the right and left servos or right and left LDRs
(all this is relative, of course, depending on
The values thus obtained are subtracted one what you call front and back on the robot).
from the other to yield information about the Now it’s over to you...
difference in lighting between the two cells. (070306-I)
522
L
310 circuits
elektor international media bv – 089018/uk
pagina 522
Jens Altenburg
523
R
310 circuits
elektor international media bv – 089018/uk
pagina 523
+5V REG
R1 R3
C6
1k
10k
2x 100µ
BC 547 16V
T1 T2
C1
10µ 16V R4
1
IC2
12k
R2 5 R7
IC1 2 3 7 C5
12k
220k
LM35 6 4 8
2 R 47µ 16V
8
7
3 4 DIS
1
R8 IC3
CA3130
22k
LMC555
2 3
TP1 TR OUT
6
THR
CV BZ1
R5 R6
C3 C4 5 1
2k2
1M
P1
1µ 10k 10µ
16V 16V 5V
060349 - 11
524
L
310 circuits
elektor international media bv – 089018/uk
pagina 524
R5 C1
1 470k
150p
V+ P1
10k
R1
39k
IC1.A IC1.B IC1.C US TX
14 11 2 5 8
C5 (40kHz)
3 4 10
IC1 IC2 1 ≥1 6 ≥1 9 ≥1
7 4 100n +5V
US
+5V
IC1.D
12
R9 11
13 ≥1 STI
22k
IC1 = CD4001 1
+5V
IC2 = TL084 2
3
GND
4
C3 CONTROL
C6
R3 10p
56k R6 10p
C7 R7 100k
2 13
3k9 C2 R2
1 9 14
100n IC2.A 4k7 D1 IC2.D
3 8 12
100n IC2.C
US RX V+ 10
LL4448
(40kHz)
US R4
C4
6
180k
4µ7 7
IC2.B
25V 5
R8 R10
C8 C9
22k
180k
4µ7
25V 100n
070281 - 11
is connected to a microcon-
troller for subsequent sig- 2
nal processing. We will look
below at the factors that
need to be borne in mind
when considering the digi-
tal signal processing algo-
rithm to be used.
525
R
310 circuits
elektor international media bv – 089018/uk
pagina 525
526
L
310 circuits
elektor international media bv – 089018/uk
pagina 526
used at the time of writing, but it is likely that drive a hexapod, a robot with 6 legs. In this
it will be used in future updates of the firm- way there is no need to come up with an algo-
ware. rithm for the PC to let the robot walk, be-
The servos that are connected to the control- cause the functions are already there to make
ler can be controlled in a very simple way. the robot move its left or right side with a
Only the numbers of the servos to be control- single command.
led, the pulse width (position) and the speed The code is freely available since the micro-
or time need to be known in order to make a controller contains open-source software. As
servo move. If a speed is specified then the a result you can add, improve and remove
servo will move to the required position at functionality yourself. Not happy with the
that speed. If a time is specified then the hexapod code? You can then ‘easily’ rewrite
servo will take that amount of time to move it.
to the new position. In the same way you can also add function-
The introduction already mentioned that the ality. For example code to move a robot arm
servos can be controlled simultaneously. This to a particular location in a Cartesian coordi-
is possible by means of a ‘Group Move’ com- nate system. By doing so there is no need to
mand. This is done by setting the numbers of control individual servos from the PC but
the servos, the pulse width and the time that simply send one coordinate to move the arm
the movement should take to reach the new the correct way.
position all in one command. In this way all Because the controller is both easy to drive
servos move simultaneously. and easily modified by an experienced pro-
This Group Move feature can be especially grammer it is very suitable for anyone who
handy if, for example, you would like to make would like to spend some time with robotics.
a robot arm move with a fluid motion. The (070373-I)
controller carries out its own calculations,
such as the speed at which the servos have to Manufacturer of the controller:
turn. www.lynxmotion.com
The controller also contains functions to
527 527
R
310 circuits
elektor international media bv – 089018/uk
pagina 527
528
L
310 circuits
elektor international media bv – 089018/uk
pagina 528
529
R
310 circuits
elektor international media bv – 089018/uk
pagina 529
steal the ball from the robot of the opposing which means the robot has to leave the field.
team before it can score a goal. The robot shoots at the goal as soon as the
goal opening is large enough. However, win-
As the robots operate entirely autonomously, ning takes more than just firing off hard
their behaviour must be programmed in ad- shots; speed and tactics are at least equally
vance. A collision is punished by a yellow important.
card, and a repeat offence yields a red card, (070359-1)
Using a Basic Stamp or a PIC programmed trolling a stepper motor is a little more tricky.
in Basic They only turn when their various windings
receive pulses, which have to be presented in
C. Tavernier a quite specific order to make the motor turn
one way or the other.
When we want to motorize a robot, two main Because of this pulsed drive, these motors
solutions are open to us: the DC motor, used don’t turn continuously, but in fact advance at
alone or in a converted radiocontrol (RC) each pulse by one basic step – whence their
servo system, as explained elsewhere in this name. The size of these steps can vary be-
book; and the stepper motor. Although the tween 1.8 and 7.5E, depending on the type of
DC motor is very suitable for everything to do motor used. This stepped advance makes it
with propulsion, the stepper motor is more possible in principle for the program control-
suitable when it comes to performing precise ling the motor to know its position very accu-
positioning, as required for a robot arm, a rately. But for this to remain true, we have to
sensor moving in one plane, etc. take care not to exceed the motor’s maximum
allowable loading, as in that case the motor
But while controlling a DC motor is relatively might fail to advance for every pulse received,
simple (it turns as soon as it is powered), con- and thus ‘skip’ some steps.
+U motor
(50V max)
1k
or 9
Cubloc DS
1 16 M1
P0 I1 O1 L3 L1
2 15
P1 I2 O2
R3 R4 3 14 M
I3 O3
4 IC1 13
1k
1k
I4 O4 L2 L4
5 12
I5 O5
6 ULN2003 11
I6 O6
7 10
I7 O7
GND
8
070237 - 11
530
L
310 circuits
elektor international media bv – 089018/uk
pagina 530
There are numerous specialist ICs on the The first is to note that the status of windings
market for driving stepper motors, and var- 1 and 2 on the one hand, and windings 3 and
ious solutions are on offer in this issue of 4 on the other, is always opposite, as indica-
Elektor, but if your robot uses a Basic Stamp ted in the attached table. Because of this, the
or a PIC microcontroller programmed in motor can be driven using just two of the Ba-
Basic, there is an extremely simple and cheap sic Stamp outputs, as shown in the very
solution for making it drive this type of simple circuit we are suggesting.
motor.
All we actually need to do is use a perfectly or- Windings 1 and 3 are driven from two lines of
dinary ULN2003 or ULN2803, respectively the Basic Stamp port, after amplification by
seven-way or eight-way integrated power the ULN2003 (or 2803). Windings 2 and 4 re-
Darlingtons normally used to drive relay coils. ceive these signals after inversion, performed
531
R
310 circuits
elektor international media bv – 089018/uk
pagina 531
using two of the spare amplifiers in the The direction of rotation is determined by the
ULN2003 (or 2803), which is overkill but per- contents of b0. If b0 is anything other than 0,
fectly practical. Note the presence of the two the motor turns one way; if not, it turns the
essential 1 kS pull-up resistors, connected to other way. This program also lets us define
the outputs of the amplifiers in the ULN2003 the wait time between each step, by means of
(or 2803), as the Darlingtons are only open- the data used in the PAUSE instruction; the
collector. only proviso is not to reduce this delay too
much, taking into account the motor being
The second tip suggested by Parallax consists used and the load it is driving.
of directly calculating the sequence of signals
to be applied to the Basic Stamp’s P0 and P1 To be as general as possible, note that this
outputs, rather than getting these data from a example of code has been written in Basic
table. All that’s actually needed is a simple Stamp I language. So it is fully transposable,
XOR logic function, as shown in the program without restriction, to any other type of Basic
listing. Stamp, as well, of course, as to any PIC pro-
grammed in Basic, since the majority of Basic
This short example of code may be included compilers for PICs are compatible with the
as is into a more complete application. As can Basic Stamp I language. It can likewise be
be seen, it makes the stepper motor connec- easily migrated to a PicBasic or a Cubloc from
ted as shown in the figure turn through the Comfile Technology.
number of steps previously loaded into w1. www.tavernier-c.com (070237-I)
Marcus Bindhammer
hand…) is enough.
532
L
310 circuits
elektor international media bv – 089018/uk
pagina 532
Finally, fit a length of toothed rubber belt you remove the screws, all you have to do is
around the circumference of each disc (old fit the wheels on the axles and secure them
video recorders are a good source) or glue flat with a bit of superglue.
elastic bands to the running surfaces. After (070145-1)
Electronic CAD available to all KiCad was of course included on the free ‘Kal-
eidoscope’ DVD. It was developed by a pro-
Rémy Halvick fessor/researcher, Jean-Pierre Charras, from
the Joseph Fourier University in Grenoble,
For the month of November, 2005, we had elec- France, in order to learn programming in
tronic CAD as the theme of Elektor magazine. C++, as he claims. The first rough drafts
The issue came with a free DVD packed with soft- were begun in 1992 in DOS, the most recent
ware, most of it operating as a Windows demo versions are available as downloads on the
version. One of the programs stood out due to university website (see the links at the end of
several unique features. Actually, KiCad is a soft- this article).
ware package distributed for free under a GPL The supported OSs are numerous in addition
license, operating in Linux, Windows and Mac to Windows (2000, XP, and W98 with slight
OS X environments. As an added treat, this mar- restrictions), the others were delivered,
vel is available in a remarkable number of tested and ready to operate with Mandriva
languages! and CentOS distributions. It also was just
integrated into the Debian distribution,
Things have greatly changed since the time thanks to the efforts of a few dynamic volun-
when electronics hobbyists (professional teers. Users have also compiled sources in
and/or amateur), peered over schematic dia- numerous other OSs: Solaris, FreeBSD, etc.
grams for many hours, drawing circuits with Mac OS X remains an exception, because,
pencil and paper, then produced it all over even if KiCad can be compiled on these
again for a ‘clean’ version. Businesses were machines, its operation is currently still
the first to have the means
to utilise CAD software such
as Orcad or Protel, on
powerful systems with staff
especially trained for this
task. For a long time, this
was too expensive for ama-
teurs.
Electronics fans today are
much more spoiled — they
can utilise programs that
use little resources, at
reasonable prices; some
even come as ‘light’ version
for free, but with restric-
tions that seriously limit
would-be users.
533
R
310 circuits
elektor international media bv – 089018/uk
pagina 533
534
L
310 circuits
elektor international media bv – 089018/uk
pagina 534
KiCad
The KiCad project manager (Figure 1) allows
you to create or select a project; meaning
mainly schematics and a printed circuit. In
this way, you also have access to the language
selection options for the graphic interface Figure 4 CVPCB: choice of component case.
and online help.
EeSchema
EeSchema (Figure 2) lets you input a simple or
tree (hierarchical) structure. The screenshot
is used to get an idea of the simplicity of the
interface which does not, however, sacrifice
functionalities. The menu toolbar only has
three sections: File, Preferences, and Help. In
addition to the traditional open/save/print
options, the File menu allows you to generate
drawing files in PostScript, HPGL, and SVG
formats.
In Preferences, you can select which libraries
to be used (which will appear when adding Figure 5 Design PCBNew printed circuits.
components), as well as various options: col-
our, display and grid pitch (scale), orientation choose the page format (A4 to A0 and A to E,
and incremental values for repetitive tasks; all as well as a custom format defined by the
of these options may be modified, of course, user) and to fill in the various sections of the
if the need should arise, although the default of the schematic. The next version of KiCad,
options satisfy most needs. The help menu is which apparently is about to be released, will
very standard. add an Undo/Redo function to EeSchema. The
next two icons relate to the Libedit compo-
Three icon bars give you access to most of the nent display /editor (Figure 3); in fact, you can
tools which you will need. The one on the left create any special symbol that you might
lets you manage the graphic ‘look’: grid dis- need for your schematic. The CVPCB and
play, its pitch, measurement units (milli- PCBnew icons follow after the traditional edi-
metres or inches), cursor shape, orientation ting tools (cut, copy, paste) and print; we will
of the lines (by 45E increments or any orienta- examine their role a little later. The 4 fol-
tion); the icon (A) lets you display the hidden lowing tools deal with display: + and – zoom,
power connections to the parts. drawing refresh and auto zoom which lets
Due to their small size, we propose icons in a mag- you have a better look by reframing the entire
nified version in Figure 8 with the reference letter. schematic. These functions are also access-
The icon H is actually a double icon. ible from the F1 to F4 function keys. When
the diagram becomes cluttered, sometimes it
The upper bar has various tools: file manipu- is difficult to find R59 or U12; you can then
lation (open, save); button (B) allows you to use the search tool by clicking on (C).
535 535
R
310 circuits
elektor international media bv – 089018/uk
pagina 535
Figure 6 3D display of the capacitance meter as The rest of the required commands are
described in Elektor. accessible from the contextual menus, with
one right mouse click. That is one of the
strong points of Kicad, which, by proposing
the tools at the time they are needed, makes
it possible to preserve a clear and easy to
grasp interface. Nothing like those heavy-
weights with their dreadfully cluttered user
interface, almost impossible to master by
anyone who is not a specialist. These con-
textual commands are dependent on the part
you choose to click on, using the right button.
For example, clicking on a component opens
the following possibilities: move, orient, edit,
copy, or delete the component, front/rear
zoom, auto function, recalculate the drawing,
select the scale. The menu is adapted depen-
ding on whether you clicked on a component,
Figure 7 The rats’ nest in white lines. a wire, a text field, etc.
The following icon (D) allows you to generate The mouse also makes it possible to display a
a netlist in different formats; you can even zone that you will select by clicking with the
have yours by creating a plug-in! Before arri- wheel: without a doubt, efficient and practi-
ving at this point, you would have taken care cal!
to number the components, thanks to the
automatic annotation tool (E). The status bar, at the bottom of the window,
The next-to-the-last tool in the top toolbar (F) gives you the following information: zoom
is very useful: it deals with verifying that the factor, absolute and relative coordinate of the
electrical rules are respected or DRC (Design cursor and measurement units (inches or
Rules Check). The principle is the following: millimetres).
each component pin is defined while it is
being drawn as input, output, open-collector, CVPCB
3-state, etc. The DRC tool will carry out vari- CVPCB, accessible from EeSchema or KiCad,
ous plausibility checks: output connected to makes it possible to link a case to each com-
the power supply, unconnected gate input ponent from the net list that you will have
and others; you can define the checks as well created in EeSchema (Figure 4). There, also,
as their result: error, warning or no error in in addition to the print libraries that come as
the options tab. This is used to avoid gross er- standard (through-hole or SMC components),
rors and forgotten connections. you can download many others on the Inter-
536
L
310 circuits
elektor international media bv – 089018/uk
pagina 536
PCBNew
You gain access to PCBNew from the KiCad
project manager (recommended), or directly
using the icon (G) (Figure 5). This printed cir-
cuit design software is made in the image of
EESchema: simple, easy to get used to and Figure 8 The main icons on a large scale and in
easy to use; that does not mean its perfor- low resolution (the originals are a standard size,
mance is lagging, here are some examples: 16 16 x 16 pixels).
copper layers, 12 technical layers (lithograp-
hy, resist coating, dimensioning, etc.) compo- scrolling lists that allow you to easily change
nents, through-hole or SMC, work done to the width of the trace, dimensions of the vias,
one/ten-thousandth of an inch, dynamic rats- grid pitch number of the layer and zoom.
nest, Design Rules Check, ground plane, and
it has a very capable high-performance in- The icons located on the left of the window
ternal router that can operate in a single- are related mainly to what is represented on
sided layer! What more can an amateur ask the screen: display of the polar coordinates in
for? And a 3D view of the board surface just the status bar, measurement units, shape of
for the visual pleasure. It is shown in Figure 6! the cursor, display of the rats-nest (represen-
tation by segments of the connections to be
But let us begin by the beginning: PCBNew. routed), automatic erasing of traces that you
The general philosophy of this graphic inter- have re-routed, display of pads and traces in
face is the same as the one for EeSchema: full lines or in contours, in high-contrast dis-
simple, easy approach, but also as efficient, play.
thanks to an intensified utilisation of the
mouse and the contextual menus, and the de- The upper icon toolbar, just like in EESchema,
fining of the two operating modes: placement groups the file commands and the selection
(H left) and routing (H right). These two of the sheet format. The next icon allows you
modes will affect the contextual menus that to access the module editor (or footprints) of
will be shown. the components in the unlikely case that the
libraries supplied and those available on the
We will not insult you by reviewing file menus Internet are insufficient. Its operation very
and preferences, except to remind you of the much resembles the one of the LibEdit com-
output formats: PostScript, HPGL, Gerber ponent editor, which means you should feel
274X, and Excellon, in addition to your favo- more comfortable with it.
rite printer. The ‘Dimensions’ menu is used to
define... the dimensions by default of the We have no specific comment on the follow-
traces, vias, pads and texts. The ‘Miscellaneous’ ing print and tracing icons except that they
section groups IC detailing accessories. resemble the ones in EESchema.
The post processors enable the automatic (D) is the starting point for designing a prin-
placement file generation of components and ted circuit: reading the netlist. Your compo-
hole-making files. This gives you the possi- nents are found ‘in bulk’ next to your sheet.
bility of having your IC made by a professio- To spread out the components in order to be
nal, by sending him the necessary files. The able to then gather them, go to placement
‘3D’ and ‘Help’ menus speak for themselves. mode (I). With one right click, do global move
Under the different menu bars you will find and place → Move all of the modules: and all
537
R
310 circuits
elektor international media bv – 089018/uk
pagina 537
538
L
310 circuits
elektor international media bv – 089018/uk
pagina 538
In all mains-operated equipment certain im- supply voltage or energy level from user access
portant safety requirements must be met. must be protectively earthed regardless of
The relevant standard for most sound equip- whether the mains transformer is Class I or
ment is Safety of Information Technology Class II.
Equipment, including Electrical Business
Equipment (European Harmonized British Always keep the distance between mains-
Standard BS EN 60950:1992). Electrical safety carrying parts and other parts as large as
under this standard relates to protection possible, but never less than required.
from
If at all possible, use an approved mains entry
à a hazardous voltage, that is, a voltage with integrated fuse holder and on/off switch.
greater than 42.4 V peak or 60 V d.c.; If this is not available, use a strain relief (Fig-
à a hazardous energy level, which is defined ure, note 2) on the mains cable at the point of
as a stored energy level of 20 Joules or entry. In this case, the mains fuse should be
more or an available continuous power placed after the double-pole on/off switch un-
level of 240 VA or more at a potential of less it is a Touchproof® type or similar. Close
2 V or more; to each and every fuse must be affixed a label
à a single insulation fault which would stating the fuse rating and type.
cause a conductive part to become hazar-
dous; The separate on/off switch (Figure, note 4),
à the source of a hazardous voltage or en- which is really a ‘disconnect device’, should
ergy level from primary power; be an approved doublepole type (to switch
à secondary power (derived from internal the phase and neutral conductors of a single-
circuitry which is supplied and isolated phase mains supply). In case of a three-phase
from any power source, including d.c.) supply, all phases and neutral (where used)
must be switched simultaneously. A plugga-
Protection against electric shock is achieved ble mains cable may be considered as a dis-
by two classes of equipment. connect device. In an approved switch, the
contact gap in the off position is not smaller
Class I equipment uses basic insulation ; its than 3 mm.
conductive parts, which may become hazar- The on/off switch must be fitted by as short a
dous if this insulation fails, must be connec- cable as possible to the mains entry point. All
ted to the supply protective earth. components in the primary transformer cir-
Class II equipment uses double or reinforced cuit, including a separate mains fuse and sep-
insulation for use where there is no provision arate mains filtering components, must be
for supply protective earth (rare in electronics placed in the switched section of the primary
– mainly applicable to power tools). circuit. Placing them before the on/off switch
will leave them at a hazardous voltage level
The use of a a Class II insulated transformer is when the equipment is switched off.
preferred, but note that when this is fitted in
a Class I equipment, this does not, by itself, If the equipment uses an open-construction
confer Class II status on the equipment. power supply which is not separately protec-
ted by an earthed metal screen or insulated
Electrically conductive enclosures that are enclosure or otherwise guarded, all the con-
used to isolate and protect a hazardous ductive parts of the enclosure must be pro-
539
R
310 circuits
elektor international media bv – 089018/uk
pagina 539
tectively earthed using green/yellow wire Most risks can be eliminated by the use of
(green with a narrow yellow stripe – do not correct fuses, a sufficiently firm construction,
use yellow wire with a green stripe). The ear correct choice and use of insulating materials
th wire must not be daisychained from one and adequate cooling through heat sinks and
part of the enclosure to another. Each con- by extractor fans.
ductive part must be protectively ear thed by
direct and separate wiring to the primary ear The equipment must be sturdy: repeatedly
th point which should be as close as possible dropping it on to a hard surface from a height
to the mains connector or mains cable entry. of 50 mm must not cause damage. Greater im-
This ensures that removal of the protective pacts must not loosen the mains transformer,
earth from a conductive par t does not also re- electrolytic capacitors and other important
move the protective earth from other conduc- components.
tive parts.
Pay particular attention to the metal spindles Do not use dubious or flammable materials
of switches and potentiometers: if touchable, that emit poisonous gases.
these must be protectively earthed. Note,
however, that such components fitted with Shorten screws that come too close to other
metal spindles and/or levers constructed to components.
the relevant British Standard fully meet all
insulation requirements. Keep mains-carrying parts and wires well
The temperature of touchable parts must not away from ventilation holes, so that an intru-
be so high as to cause injury or to create a fire ding screwdriver or inward falling metal ob-
risk. ject cannot touch such parts.
540
L
310 circuits
elektor international media bv – 089018/uk
pagina 540
3-core mains cable to BS6500 1990 with three stranded conductors in thick PVC sheath
Max. current 3A 6A 13 A
Conductor size 16/0.2 mm 24/0.2 mm 40/0.2 mm
Nom. cond. area 0.5 mm2 0.75 mm2 1.25 mm2
Overall cable dia. 5.6 mm 6.9 mm 7.5 mm
541
R
310 circuits
elektor international media bv – 089018/uk
pagina 541
542
L
310 circuits
elektor international media bv – 089018/uk
pagina 542
543
R
310 circuits
elektor international media bv – 089018/uk
pagina 543
L
310 circuits
elektor international media bv – 089018/uk
pagina 544
ISBN 978-0-905705-78-1
Cover_310circuits_GB_rz.indd 1