You are on page 1of 216

An EFY Group Publication ISBN 978-81-88152-26-1 Price $ 10

Electronics
Projects VOLume
26
A Compilation of 21 tested Electronic Construction Projects and 71 Circuit Ideas for Electronics Professionals and Enthusiasts

216 Pages
6 Microcontroller-Based Projects
6 Microcontroller-Based Projects
Electronics Projects
Vol. 26
© EFY Enterprises Pvt Ltd
First Published in this Edition, November 2013

All rights reserved. No part of this book may be reproduced in any


form without the written permission of the publishers.

ISBN 978-81-88152-26-1

Published by Ramesh Chopra for EFY Enterprises Pvt Ltd,


D-87/1, Okhla Industrial Area, Phase 1, New Delhi 110020
Typeset at EFY Enterprises Pvt Ltd
Electronics Projects
Vol. 26

EFY Enterprises Pvt Ltd


D-87/1 Okhla Industrial Area, Phase 1
New Delhi 110020
About EFY Labs
EFY Group has modern lab setup for R&D and testing various electronics
projects for publications. All the projects published in EFY were tested at
EFY Labs. Apart from this online edition, all the print versions including
Microcontroller-Based Projects (First edition), Simple Projects You Can
Make At Home, Electronics Pojects Volume 1 through 25, Chip-Talk
and Learn to Use Microprocessors books were compiled by EFY Labs.

About EFY Group


Electronics For You, South Asia’s most popular electronics magazine is
one of the products of EFY Group. The Group currently offers a bouquet of
specialised publications which include Open Source For You, Electronics
Bazaar and Facts For You. The publications enjoy a huge readership and
have managed to attract non-technical readers with their simple language
and easy-on-the-eye design.

The Group also publishes directories and books, and organises several
leading technology events. Its web-portals, which include electronicsforu.
com, efytimes.com, eleb2b.com, linuxforu.com, electronicsb2b.com,
investinelectronics.in and electronicsofthings.com have become leaders
in their respective categories. The EFY Expo India, EFY Awards, Open
Source India, Electronics Rocks and ELCINA-EFY Awards are some of
the annual events organised by the group.
Foreword
This volume of Electronics Projects is the twenty sixth in the series
published by EFY Enterprises Pvt Ltd. It is a compilation of 21 con-
struction projects and 71 circuit ideas published in Electronics For You
magazine during 2005.

In keeping with the past trend, all modifications, corrections and


additions sent by the readers and authors have been incorporated in the
articles. It is a sincere endeavour on our part to make each project as
error-free and comprehensive as possible. However, EFY is not responsible
if readers are unable to make a circuit successfully, for whatever reason.

This collection of tested circuit ideas and construction projects in a


handy volume would provide all classes of electronics enthusiasts—be
they students, teachers, hobbyists or professionals—with a valuable
resource of electronic circuits, which can be fabricated using readily-
available and reasonably-priced components. These circuits could
either be used independently or in combination with other circuits
described in this and other volumes. We are confident that this volume,
like its predecessors, will generate tremendous interest amongst the
readers.
Table of Contents
Section A: Construction Projects

1. Microcontroller-based real-time clock........................................................................... 13


2. Standalone scrolling display using AT90S8515 AVR.................................................... 18
3. Remote-controlled digital audio processor.................................................................... 26
4. Device control through PC’s parallel port using visual basic....................................... 32
5. Auto changeover to generator on mains failure............................................................. 36
6. PC-based scrolling message display.............................................................................. 52
7. Low-cost energy meter using ADE7757........................................................................ 57
8. Two-wheeler security system......................................................................................... 63
9. Medium-power low-cost inverter................................................................................... 66
10. Programmable timer based on AT90S4433 AVR........................................................... 69
11. Manual AT89C51 programmer....................................................................................... 74
12. Computerised electrical equipment control.................................................................... 78
13. Remote-controlled stepper motor................................................................................... 82
14. Digital stopwatch............................................................................................................ 85
15. Infrared interruption counter.......................................................................................... 88
16. Audio mixer with multiple controls............................................................................... 91
17. Noise-muting FM receiver............................................................................................. 95
18. PC-based stepper motor controller................................................................................. 98
19. Automatic 3-Phase induction motor starter.................................................................. 103
20. Using AVR microcontrollers for projects..................................................................... 106
21. Speed checker for highways......................................................................................... 125

Section B: Circuit Ideas

1. Audio amplifier for personal stereo.............................................................................. 131.


2. Infrared object counter................................................................................................. 132
3. Long-range burglar alarm using laser torch................................................................. 133
4. Musical light chaser..................................................................................................... 134
5. Automatic soldering iron switch.................................................................................. 136
6. Versatile LED display................................................................................................... 137
7. Auto turn-off battery charger........................................................................................ 139
8. Pencell charge indicator............................................................................................... 140
9. Miser Flash................................................................................................................... 141
10. PC-based timer............................................................................................................. 142
11. Atmel AVR ISP dongle............................................................................................. 144
12. Digital frequency comparator....................................................................................... 146
13. Manual EPROM programmer...................................................................................... 148
14. Wireless stepper motor controller................................................................................ 150
15. Simple digital security system...................................................................................... 151
16. Multiple applications of high-power LEDs.................................................................. 152
17. Automatic bathroom light with back-up lamp............................................................. 153
18. Digital audio/video input selector................................................................................ 154
19. Accurate foot-switch.................................................................................................... 155
20. MicroMotor Controller................................................................................................. 156
21. Power-on reminder with LED lamp............................................................................. 157
22. Mains interruption counter with indicator.................................................................... 158
23. Simple low-power inverter........................................................................................... 159.
24. Solar bug...................................................................................................................... 160
25. Remote control for home appliances............................................................................ 161
26. Mock alarm with call bell............................................................................................. 162
27. Power-saver LED lamp................................................................................................ 163
28. Mains supply failure alarm........................................................................................... 164
29. Sound-operated switch for lamps................................................................................. 165
30. TV pattern generator.................................................................................................... 166
31. Rechargeable torch based on white LED..................................................................... 167
32. 16-way clap-operated switch........................................................................................ 168
33. Brake failure indicator.................................................................................................. 169
34. Battery charger with automatic switch-off................................................................... 170
35. Multidoor opening alarm with indicator...................................................................... 171
36. Safety guard.................................................................................................................. 172
37. White LED-based emergency lamp and turning indicator........................................... 173
38. Inexpensive car protection unit.................................................................................... 175
39. Dog caller..................................................................................................................... 176
40. Smart cellphone holder................................................................................................. 177
41. IC 555 timer tester........................................................................................................ 178
42. Fuel reserve indicator for vehicles............................................................................... 180
43. Medium-power FM transmitter.................................................................................... 182
44. Teleconferencing system.............................................................................................. 183
45. Light dimmer that doubles as voltmeter....................................................................... 184
46. Multicell charger.......................................................................................................... 185
47. Timer for geyser........................................................................................................... 186
48. 220V Live wire scanner............................................................................................... 187
49. Doorbell-cum-visitor indicator..................................................................................... 188
50. Smart switch................................................................................................................. 190
51. Stress meter.................................................................................................................. 191
52. Power failure and resumption alarm............................................................................ 192
53. Little door guard........................................................................................................... 193
54. Electronic fuse.............................................................................................................. 194
55. Digital dice................................................................................................................... 195
56. Bicycle guard................................................................................................................ 197
57. Liquid-level alarm........................................................................................................ 198
58. Remote-controlled power-off switch............................................................................ 199
59. Zener value evaluator................................................................................................... 201
60. Simple mosfet-based CFL........................................................................................ 203
61. Heat-sensitive switch.................................................................................................... 204
62. Transistor tester............................................................................................................ 205
63. Water-tank overflow indicator ..................................................................................... 206
64. Simple smoke detector................................................................................................. 207
65. Sensitive vibration detector.......................................................................................... 208
66. Soft switch.................................................................................................................... 209
67. Automatic-off timer for CD players............................................................................. 210
68. Automatic washbasin tap controller............................................................................. 211
69. Rear-view monitor........................................................................................................ 212
70. Over-speed indicator.................................................................................................... 213
71. Versatile water-level controller.................................................................................... 214
Section A:
Construction Projects
Microcontroller-based
Real-time clock
 K.S. Sankar (a powerful BASIC compiler), which Parts List
is capable of creating a hex file. The

I
Semiconductors:
n most applications, a microcon- hex file code can be burnt into the IC1 - 7805, 5V regulator
troller can satisfy all the system microcontroller using any commonly IC2 - AT89S8252 microcontroller
IC3 - 74LS244 octal line driver
requirements with no additional available programmer or kit. IC4 - ULN2803 octal transistor
integrated circuits. Due to their low IC AT89S8252 is a low-power, array
cost and a high degree of flexibility, high-performance CMOS 8-bit micro- DIS1-DIS6 - LTS543 commoncathode
7-segment display
microcontrollers are finding way into controller. It is manufactured using LED1 - Red LED
many applications that were previ- Atmel’s high-density non-volatile
Resistors (all ¼-watt, ±5% carbon):
ously accomplished by mechanical memory technology and is compatible R1 - 1-kilo-ohm
means or combinational logic. One with the industry-standard 80C51 in- R2 - 10-kilo-ohm
such application is a real-time clock. struction set and pin-out. The powerful R3-R11 - 100-ohm
Here’s a real-time clock using At- AT89S8252 microcontroller provides a Capacitors:
C1 - 100μF, 25V electrolytic
mel AT89S8252. The software for the highly flexible and cost-effective solu- C2 - 0.1μF ceramic
microcontroller is written in Bascom51 tion to many embedded control appli- C3, C4 - 22pF ceramic
cations. Its main features are: C5 - 10μF, 10V electrolytic
1. Compatibility with MCS-51 Miscellaneous:
products XTAL - 6MHz crystal
S1-S6 - Push-to-on switch
2. 8kB in-system reprogrammable
downloadable Flash memory with SPI
serial interface for program download- channel
ing and 12. SPI serial interface
3. 2kB EEPROM with endurance of 13. Low-power idle and power-
100,000 write/erase cycles down modes
4. 4V–6V operating range 14. Interrupt recovery from power-
5. Fully static operation: 0 Hz to down
24 Mhz 15. Programmable watchdog timer
6. Three-level program memory 16. Dual data pointer
lock 17. Power-off flag
7. 256×8-bit internal RAM Fig. 1 shows the pin assignments of
8. 32 programmable I/O lines AT89S8252.
9. Three 16-bit timer/counters Fig. 2 shows the block diagram of
Fig. 1: Pin assignments of AT89S8252 10. Nine interrupt sources the real-time clock using AT89S8252
11. Programmable UART serial microcontroller and a few exter-
nal components to
display the time in
HH.MM.SS format
on six 7-segment dis-
plays. Switches S2, S3,
S4 and S5 are used for
hour increment, hour
decrement, minute
increment and minute
decrement, respec-
tively, while switch
S6 is used for reset-
ting the clock display
Fig. 2: Block diagram of real-time clock using AT89S8252 microcontroller to all zeroes.

Electronics Projects vol. 26 13


Out of the three ports of the micro-
controller, one port is used for setting
the time and the other two ports are
used for displaying the time. Line
driver and Darlington driver array are
used to drive the segment data and
enable the 7-segment display, respec-
tively.

Ciruit discription
Fig. 3 shows the circuit of the real-time
clock built around AT89S8252 micro-
controller (IC2). The power supply
from the 9V battery is down converted
and regulated by IC 7805 (IC1) to pro-
vide regulated 5V to the circuit. Glow-
ing of LED1 indicates that power to the
circuit is switched on. Resistor R1 acts
as the current limiter.
Switch S1 is used to manually
reset the microcontroller, while the
power-on reset signal for the mi-
crocontroller is derived from the
combination of capacitor C5 and
resistor R2. EA/Vpp pin (pin 31) of
the microcontroller is connected to
Vcc to enable internal program ex-
ecution. Pins 19 and 18 are input and
output pins of the built-in inverting
amplifier, respectively, which can
be configured for use as an on-chip
oscillator. A 6MHz crystal is used to
generate the clock frequency for the
microcontroller.
AT89S8252 has four bidirectional
8-bit ports, of which only three ports
Fig. 3: Circuit of the real-time clock built around AT89S8252 microcontroller

(0 through 2) have been used in this


circuit. Port 0 is an 8-bit open-drain
bidirectional I/O port. As an output
port, each pin can sink eight TTL in-
puts. Port 0 can also be configured as
the multiplexed low-order address/
data bus during accesses to the ex-
ternal program and data memory.
External pullups are required during
data outputs.
Port 0 is used to drive the seg-
ments of all the 7-segment common-
cathode displays. Pin 1 of the RNW1
resistor network is connected to Vcc
and pins 2 through 9 are connected
to port-0 pins 39 down through 32
of IC2 as external pull-ups. Pins 39
down through 32 of port 0 are also
connected to the input pins of octal

14 Electronics projects Vol. 26


rent level. Resistors R5 through R11
limit the current through the 7-seg-
ment displays. Each display com-
prises seven light emitting diodes
(LEDs) with their common cathodes
connected together, hence termed
as the common-cathode, 7-segment
display.
Port 2 acts as the multiplexer to
select a particular 7-segment display
using octal Darlington transistor array
ULN2803 (IC4). Pins 21 through 26
of port 2 are pulled up by the RNW2
resistor network and also connected to
pins 1 through 6 of IC4. IC4 outputs a
low signal to light up the segments of
the 7-segment display selected by the
port-2 data.
Ports 0 and 2 provide the segment
data and enable signal simultaneously
for displaying a particular number on
the 7-segment display. Decimal-point
pin 5 of displays DIS2 and DIS4 is ena-
Fig. 4: Actual-size, single-side PCB for the real-time clock using AT89S8252 microcontroller bled by Vcc through resistors R3 and
R4, respectively, to differentiate the
hour, minute and second.
Port 1 detects pressing of the
switches to increment/decrement
hours and minutes and reset the dis-
play to ‘00:00:00’ by pulling the port
pins to ground. The software detects
pressing of the switches and sets the
time accordingly. Pull-up resistors
on port 1 have been avoided since the
port already has internal pull-ups.
An actual-size, single-side PCB for
the real-time clock is shown in Fig. 4
and its component layout in Fig. 5.

Software
The software for the real-time clock
is written in Bascom51 version. Those
who have knowledge of Basic, Basic-A,
GW-Basic or QBasic language (used to
run on the good old 286 and 386 PCs
with DOS 2.x to 6.2) can understand
the program easily. The demo version
of Bascom-8051 is available on Website
‘www.mcselec.com/ download_8051.
Fig. 5: Component layout for the PCB htm.’
Fig. 6 shows the flow-chart of
line driver IC 74LS244 (IC3). pins of IC3 via resistors R5 through the program. Step-wise explanation
Segments ‘a’ through ‘g’ of 7-seg- R11, respectively. IC3 acts as an octal of how the program works is given
ment displays DIS1 through DIS6 are buffer between the microcontroller below:
joined and connected to the output and the displays to increase the cur- 1. Define the port pins and where

Electronics Projects vol. 26 15


these are connected. mand of Bascom’s key debounce state-
2. Include the header ment.
file for the microcon- 11. Check when second, minute
troller and hour variables exceed their limits
3. Define the crystal and increment them accordingly.
speed. 12. Activate the digits one by one
4. Declare the vari- through port 2 and show the corre-
ables as bits, bytes and sponding number on the display using
words. port 0.
5. Initialise all ports 13. Declare subroutines for detec-
to 0, except port 1, which tion of the switches pressed to adjust
is turned high to act as hours and minutes.
an input port. 14. Declare the main display sub-
6. Run a diagnos- routine. Since we have not used a 7seg-
tic subroutine to test ment converter IC, a quick table check
the segments of all the using read and data concept in Basic is
digits. performed to get the correct byte value
7. Configure the in- for the digit to be displayed.
ternal timer as an inter- 15. Declare the internal timer inter-
rupt generator to get rupt subroutine. This subroutine is
a one-second-activity called 2000 times in a second using a
source. 6MHz crystal, and to generate an ac-
8. Initialise hour, curate one-second variable, we set the
minute and second vari- flag only once every 2000 times. This
ables to zero. variable is used to detect the seconds
9. Get into a perpet- change and increment the time in the
ual Do loop to display main Do loop routine. The accuracy
the time in ‘HH:MM:SS’ of the clock depends on the timer sub-
format. (Since there are routine.
no BCDto-7-segment
converter ICs and no Other possible uses
latch ICs, it is up to the The circuit and the software can be im-
software to show the proved to convert this real-time clock
clock display without into an alarm clock. With port 3 acti-
being interrupted.) vated, it can be used as a multichannel
10. Set the input industrial timer.
switches to activate the Download source code: http://
respective subroutines www.efymag.com/admin/issuepdf/
Fig. 6: Flow-chart of the program using the built-in com- Real%20Time%20Clock.zip

EFYclk11.bas
‘-------------------------------------------------------------- ‘dp= p0.7 As Byte
‘ EFYclk.bas 18-10-04 ‘ Dim Red As Byte , Green As Byte
‘ REAL TIME CLOCK DISPLAY ON six 7-SEG Dim Count As Byte , X As Byte , Segment As Byte
DISPLAYS ‘88 88 88 Dim Number As Byte , Digit_select As Byte
‘ BY k.s.sankar www.mostek.biz for EFY ‘hh mm ss port-2 (green) p2.0 /1 : 2/3 : 4/5 Dim Del As Byte , Diagdelay As Byte
‘ written using BASCOM-51 from MSC electron- ‘12 34 56 digit number Dim Large As Word
ics Netherlands
‘-------------------------------------------------------------- ‘ yellow port-1 set switches Del = 1
‘P1.0=H+ P1.1=H- ‘ delay variable in milliseconds
‘P1.2=M+ P1.3=M- ‘ all ports 0
‘Connect common cathode LED displays as ‘P1.4= 00 00 00 ( reset to 00 00 00) P0 = 0
following : ‘red
‘ port-0 (red) ‘-------------------------------------------------------------- P1 = 255
‘a = P0.0 $regfile = “89s8252.dat” ‘yellow all high for sw inputs
‘b = P0.1 $crystal = 6000000 P2 = 0
‘c = P0.2 ‘6 mhz crstal ‘green
‘d = P0.3 P3 = 0
‘e = P0.4 Dim Once_a_sec As Bit ‘blue not used
‘f = P0.5 Dim Clock_word As Word
‘g = P0.6 Dim Hours As Byte , Minutes As Byte , Seconds Config Debounce = 30

16 Electronics projects Vol. 26


‘ key debounce time in milli seconds Number = Minutes Mod 10 P0 = 1
Config Timer0 = Timer , Gate = Internal , Mode P2 = 8 For Red = 0 To 7
=2 Gosub Disp Debounce P1.4 , 0 , Zero
‘Timer0 use timer 0 Waitms Del Waitms Diagdelay
‘Gate = Internal no external interrupt P0 = 0 Rotate P0 , Left
‘Mode = 2 8 bit auto reload ‘-------
Next Red
‘SECONDS
Gosub Diag Rotate P2 , Left
‘ diagnostic routine Number = Seconds / 10 Next Green

‘ set t0 internal interrupt P2 = 16 Next Seconds


On Timer0 Timer_0_int Gosub Disp
Load Timer0 , 250 Waitms Del ‘ next diag show 000000 to 999999 on all digits
Priority Set Timer0 P0 = 0 ‘ - - - - - - - -- - - - - -- - - - - - - -- - - -
Enable Interrupts ‘-------
Enable Timer0 For Number = 0 To 9
Start Timer0 Number = Seconds Mod 10 P2 = 1
P2 = 32
Gosub Disp For Large = 1 To 50
Hours = 0 Waitms Del
Minutes = 0 P0 = 0 ‘ approx 1 second time loop with 200 in large
Seconds = 0 ‘------- For Green = 0 To 5
Clock_word = 0 Loop Debounce P1.4 , 0 , Zero
‘------------------ Gosub Disp
Waitms Del
‘ set keys below Rotate P2 , Left
Do Next Green
‘ yellow port-1 key inputs for setting Hup: Next Large
Debounce P1.0 , 0 , Hup , Sub Incr Hours
Debounce P1.1 , 0 , Hdown , Sub If Hours >= 24 Then Next Number
Debounce P1.2 , 0 , Mup , Sub Hours = 0
Debounce P1.3 , 0 , Mdown , Sub Return
Debounce P1.4 , 0 , Zero , Sub End If
Return
‘Displaying routine
If Once_a_sec = 1 Then Hdown:
‘ once_a_sec=calculation every second Decr Hours Disp:
Once_a_sec = 0 If Hours = 255 Then
‘update hh mm ss Hours = 23 Restore Tabela
End If
inc seconds Return
If Seconds = 60 Then ‘ scan 7-seg table to get byte for the digit to
Seconds = 0 Mup: display
inc minutes Incr Minutes For X = 0 To 9
If Minutes = 60 Then If Minutes >= 60 Then Read Segment
Minutes = 0 Minutes = 0 If X = Number Then
inc hours ‘if X = value to display
If Hours = 24 Then End If P0 = Segment
Hours = 0 Return ‘then set this value to Port0-red
End If Exit For
End If Mdown: ‘and exit FOR loop
End If Decr Minutes End If
End If If Minutes = 255 Then Next
Minutes = 59
‘ display time constantly Return
‘ hours End If
Return
Number = Hours / 10
P2 = 1 Zero: ‘ int subroutine -----------------
Gosub Disp Timer_0_int:
Waitms Del Hours = 0 : Minutes = 0 : Seconds = 0 Incr Clock_word
P0 = 0 Return
‘------- If Clock_word > 2000 Then
Number = Hours Mod 10 ‘ - - - - - - - - -- - - - - - - -- - - - - - Clock_word = 0
P2 = 2 Diag: Once_a_sec = 1
Gosub Disp ‘diagnostics End If
Waitms Del Return
P0 = 0 ‘if zero button pressed then goto zero label and
‘------- return
Diagdelay = 121 ‘---- data for 7-seg LED display ------
‘minutes Tabela:
Number = Minutes / 10 For Seconds = 1 To 5 Data 63 , 6 , 91 , 79 , 102 , 109 , 125 , 7 , 127 , 111
P2 = 4 ‘ end of program
Gosub Disp Diagdelay = Diagdelay - 20 ‘ -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Waitms Del 
P0 = 0 P2 = 1
For Green = 0 To 5
‘-------

Electronics Projects vol. 26 17


standalone scrolling
display using at90S8515 AVR
Shubhika taneja, deepa into regulated 5V DC. Parts List
chawla 4. The string of characters entered
Semiconductors:
through the keyboard is stored in the

M
IC1 - AT90S8515 AVR micro-
icrocontrollers are being EEPROM. The stored message can be controller
extensively used in many displayed on the dot-matrix display IC2-IC6 - ULN2803A Darlington
array LED driver
industrial and household just by clicking the scud button on the IC7 - MAX232 RS-232 serial
applications. Here, we’ve used an terminal program while it is connected interface
AVR microcontroller (AT90S8515) to the PC. T1-T7 - SK100B pnp transistor
from Atmel Corp. for controlling four 5. Any message entered from the Resistors (all ¼-watt, ±5% carbon):
R1 - 220-ohm
5x7 dot-matrix displays. The micro- PC’s keyboard gets stored in the EE- R2-R8 - 1-kilo-ohm
controller is based on true reduced PROM of the AVR and can be scrolled R9-R15 - 220-ohm
instruction set computer (RISC) ar- at any time without the use of a PC, i.e. R16 - 620-ohm
chitecture. Any message entered by you just need to switch on the embed- Capacitors:
C1 - 100μF, 16V electrolytic
the user through the keyboard of a PC ded system.
capacitor
C2, C3 - 22pF ceramic capacitor
C4 - 0.1μF ceramic capacitor
C5-C9 - 1μF, 16V electrolytic
capacitor
Miscellaneous:
XTAL - 8MHz crystal
DIS1-DIS4 - 5×7 dot-matrix (column
common cathode) display
LED1 - Red power indicator
S1 - SPST on/off switch
S2, S3 - Tactile switch

Circuit description
Fig. 1: Block diagram of standalone scrolling display using AT90S8515 AVR Fig. 2 shows the circuit of AVR
AT90S8515-based scrolling display
scrolls elegantly through the displays 6. RXD and TXD pins of the mi- system.
even after disconnection of the circuit crocontroller are used to communi- AT90S8515 AVR microcontroller.
from the PC. cate with the PC through MAX-232 AT90S8515 is a 40-pin, 8-bit microcon-
This display can be used in public IC and TX and RX pins of COM port. troller from Atmel. It has 512 bytes of
places such as railway stations and All the four ports (ports A, B, C and SRAM, 512 bytes of EEPROM and 8kB
restaurants to convey messages to D) of the AVR are programmed as Flash with 32 programmable input/
the public. The microcontroller is in- output ports. output (I/O) lines. AVR microcon-
terfaced to the PC keyboard through Fig. 1 shows the block diagram trollers are in-system programmable
its serial port. The embedded system of the AT90S8515-based standalone through RS-232C serial port (COM
software is written in ‘C.’ scrolling display system. It consists of port) of the PC. The programmable
The circuit has the following fea- an AVR microcontroller, row display Flash memory and EEPROM of the
tures: drivers, column display drivers, four AVR can be programmed using a
1. It accepts any message entered 5x7 dot-matrix displays and power simple software and just four wires
through the keyboard of the PC for supply section. The AVR compiler, in- from parallel port of the PC to your
display. system programmer (ISP) and terminal target board containing AVR. Easy
2. User interface is provided program are installed in the computer. in-circuit programmability combined
through the PC’s RS-232 serial port The display control program, written with Flash memory makes it easy to
(COM port). in ‘C’ using AVR C compiler, is loaded update the code during development.
3. The circuit derives power from into the microcontroller by using paral- Since we require a minimum of 27
230V AC mains, which is converted lelport pins of the PC. output pins (20 columns and 7 rows),

18 Electronics projects Vol. 26


AT90S8515 suits this application as it 8PC indicates the value of the crystal following relationship:
has 32 programmable I/O lines. Pin to be used, which in this case is 8 MHz. fCLK
details of this AVR are shown in Fig. 4. The baud rate in the communication Baud rate =
16(VBRR+1)
The AVR marked on the IC with 8PI or software should be selected as per the
where fCLK is crystal
frequency and VBRR is the
value of contents of the
UART baud rate register.
Serial interface. The
serial interface comprises
9-pin D-type female con-
nector, IC MAX-232, five
1μF electrolytic capaci-
tors and 3-core cable as
shown in Fig. 3.
Display drivers.
Seven SK100B transis-
tors along with 220-ohm
(output current limitor)
and 1k-ohm resistors
(base current limiter) are
used for controlling the
rows of LED array, and
five ULN2803 ICs (IC2
through IC6) are used for
controlling the columns
of dot-matrix displays.
Dot-matrix displays.
Four 5x7 dot-matrix
LEDs (with common
cathodes as the columns)
such as KLP2057 from
Kwality Electronics (In-
dia) are used for the dis-
play. The displays need
seven row drivers and
20 column drivers. These
displays are identical,
with cathodes shorted
Fig. 2: Circuit for standalone scrolling display using AT90S8515

along the column and


anodes shorted along the
row (refer Fig. 5).
Since the human eye
cannot perceive changes
carried out at frequen-
cies greater than 20 Hz,
each column must be
refreshed at a minimum
rate of 20 Hz. Here, we
have set the refresh rate
(the rate at which the
display from one column
to the next) at about 400
Hz. In case only one LED
glows in a particular col-

Electronics Projects vol. 26 19


2803 are connected and receiver (RXD) pins of the AVR,
in parallel to increase respectively.
the current sinking The transmitter (TX) and receiver
capability. The tran- (RX) pins of the PC’s Com port are con-
sistors are turned nected to the RIN (RS-232 input) and
on by the TTL volt- ROUT (RS-232 output) pins of MAX232,
ages applied by the respectively. A 9-pin D-type male con-
input/output ports nector is attached to the PCB board,
of the AVR to their whose pins 2, 3 and 5 are soldered to
bases through 1-kilo- ROUT, RIN and ground of IC7, respec-
ohm resistors. tively.
Power source. Two 9-pin D-type female con-
A 5V DC regulated nectors are required for connection
power supply is used between the PCB board and the PC’s
in this circuit, which serial port. The communication be-
Fig. 3: RS-232 interface circuit has to be supplied tween the PC and the circuit board
for display is done through a terminal
program software such as ‘Terminal
v1.9b,’ which can be downloaded for
free from the Website ‘bray.velenje.
cx/avr/terminal.’ Using this software,
up to 130 characters can be typed in at
a time for transmission to the display
circuit for the scrolling display.

Programming the AVR


Getting started with the AVR requires
nothing more than the free assembler/
compiler, a simple programmer such
as the one by Jerry Meng (available
on ‘www.qsl.net/ba1fb/’) and a tar-
Fig. 5: Column common cathode get board. The target board can be as
Fig. 4: Pin details of AT90 simple as a few parts since the AVR
externally. is highly integrated. Since it is easy
umn, that particular data line will have to reprogram the flash memory, you
to handle 20mA current. Connecting the AVR to the can develop code and test without the
Since there are 20 LEDs in a row, PC's serial port need for an expensive in-circuit emula-
400mA current could flow through The microcontroller needs to com- tor. This is done by a built-in interface
a particular column at a particular municate with the PC’s RS-232 port to in the AVR chip, which enables you
instant. The circuit has to be designed scroll the string entered through the to write and read the contents of the
keeping the value of this peak current keyboard of the PC. AT90S8515 has programmed Flash and the built-in-
in mind. Since 400mA current cannot a built-in serial port. The processor EEPROM. This interface works serially
be sourced by the port pin of AVR takes care of serialising and shifting and needs mainly three signal lines
(maximum current sourced or sinked out of the data on the output pin from the AVR to PC’s printer port for
by the AVR’s I/O ports is 20 mA), the and assembling of the incoming data programming:
display cannot be directly connected into a byte. Since the RS-232 signals 1. SCK: A clock signal that shifts
to the AVR port. We thus use SK100B are bipolar in nature, they cannot the bits to be written to the memory
pnp transistors along with 220-ohm be fed directly to the controller. We into an internal shift register, and that
current-limiting resistors. have used a very popular RS-232 line shifts out the bits to be read from an-
For obvious reason, we’ve used five driver and receiver MAX232 (IC7) for other internal shift register.
ULN2803 ICs to increase the current converting the PC’s RS-232 compat- 2. MOSI: The data signal that sends
sinking capacity. These ICs are con- ible signals into TTL levels for AVR the bits to be written to the AVR.
nected to the columns of the displays. and vice versa. TIN (TTLinput) and 3. MISO: The data signal that re-
Each IC has eight Darlington pairs. TOUT (TTL output) pins of MAX232 ceives the bits read from the AVR.
Pairs of input and output pins of ULN are connected to the transmitter (TXD) The connections for program-

20 Electronics projects Vol. 26


The flow-chart of the program is
shown in Fig. 6.
The 8-bit timer/counter of the AVR
is used to implement refreshing of the
display. As the minimum refresh rate
for flicker-free view is 20 Hz, we have
chosen prescale as Clk/64, thus giving
us the refresh rate in kilohertz, where
‘Clk’ is the oscillator clock frequency of
the crystal used.
Wait interrupt has been imple-
mented by the 16-bit timer/counter
with clk/1024 as the pre-scaler and
output-compare register (OCR). This
gives us an initial wait period of 17
seconds.
Sub-modules of the code. During
the 17-second waiting period, the
program waits for the user to send
data through the UART. Hence, the
program waits in while loop ‘While
(! (USR&(1<<RXC))&& (q! =0));’ and
keeps checking the RXC bit (UART
Receiver Complete) of the UART sta-
tus register (USR) until either the user
enters a data byte (RXC bit will be set)
or the 16-bit timer/counter output
compare interrupt is generated and
the while loop terminates. The 16-bit
Fig. 6: Flow-chart of the program timer/ counter is initialised as ‘TC-
CR1B=5; OCR1AH=10;’ which defines
ming are simple but there are various next issue. the prescaler of ‘clk/64.’
standards adopted by the industry. To receive data from UART
In this project, the ISP10 standard Software Program sent from the serial port of the
is used on the STK200 programmer The software has the following fea- PC, first the UART baud rate and
board (from KANDA Systems) for tures: UART control register (UCR)
programming. The STK200 board 1. Initially waits for 17 seconds for are set to enable the receiver and
consists of the zif socket for the the user to enter the string. the transmitter as ‘UBRR=25;
AVR and a 10-pin header box. The 2. Receives data from UART sent UCR=(1<<RXEN)|(1<<TXEN);’ where
dongle is used to connect the port through the serial port of the PC con- UBRR is the UART baud rate register.
of the PC to the 10- in header con- nected to MAX232 by a 9-pin connec- If the user sends a new string, it
nector on the STK200 board. Along tor. will first be received from the UART
with this STK200 board, you need a 3. Stores the string entered by the data register (UDR) and stored in
compiler/assembler such as AVREdit user. Else, retrieves the previously SRAM, then it will be written into the
3.5 and Atmel AVR ISP 2.65 software stored string from the EEPROM. EEPROM, which, in turn, overwrites
to be installed into your system 4. Stores the byte-patterns of char- the previously stored string. The fol-
for programming the AVR chip. acters ‘A’ through ‘Z,’ ‘a’ through ‘z’ lowing lines enable storing of the
The required software tools can be and ‘0’ through ‘9’ in the 16-bit pro- string in SRAM:
downloaded from the Website ‘www. grammable flash memory. While ((count1<100) && (str1 [k]! = 63))
avrfreaks.net.’ The STK200 dongle is 5. Initialises the interrupts for re- {
available on the Website ‘elm-chan. fresh rate and scroll rate. if(USR & (1<<RXC))
org/works/avrx/report_e.html.’ 6. Maps the byte pattern of each flag=1;
EFY note. A simple dongle circuit character from the program memory If the string entered is in the cor-
used in EFY Lab for programming as a function of the scroll parameter rect format, the flag is set to ‘1.’ Else,
the AVR will be published in the and then sends the values to the ports. the flag remains ‘0’ and the previously

Electronics Projects vol. 26 21


stored string will be displayed. To
store the string in EEPROM, the string
is written character-by-character in
the EEPROM starting from location
‘0x0001.’
If the previously stored string is to
be scrolled, the same routine is execut-
ed, except that data is only ‘read from’
instead of ‘written to’ the EEPROM.
The following program lines perform
these actions:
address = 0x0001;
EEREAD( address, str+x);
EEWRITE(address,str1[x]);
//Store the string
in EEPROM
To store the byte patterns of char-
acters ‘a’ and ‘b’ in the 16-bit program-
mable flash memory, an extract from
the program is reproduced below:
typedef unsigned char u08;
u08 __attribute__ ((progmem)) leds[]={
0xe0, 0xd7, 0xb7, 0xd7, 0xe0, //a
0x80, 0xb6, 0xb6, 0xb6, 0xc9, //b
The program lines “t = str[i]; addr
= (t-’A’)*5;” are used to retrieve the
starting address of the byte-pattern
of any character, where ‘A’ is the base
address.
Initialisation of interrupts for re-
fresh rate and scroll rate is as follows:
TCNT0 = 200;
TIMSK |= 1<<TOIE0 ;
TCCR0=3;//Timer/Counter Control Register
An 8-bit timer/counter (TCNT0) is
used in the program, whose value can
be changed to increase the intensity of
the display. The scroll rate has been
taken as a multiple of refresh rate. This
multiple is taken as ‘2000.’ When the
string to be scrolled is known, first the
input/output ports are set by the fol-
lowing instructions:
outp(0xff,DDRA);
outp(0xff,DDRB);
outp(0xff,DDRC);
outp(0xff,DDRD);
To map the byte pattern of each
character of the string from the pro-
gram memory as a function of the
scroll parameter (named as offset
here) and then send the values to the
ports, the following section of the
program is a critical section. As we
Fig. 7: Combined actual-size, single-side PCB layout for Figs 2 and 3 don’t want the interrupts to occur

22 Electronics projects Vol. 26


during their execution, we use cli ()
and sei ():
“cli();//disable interrupt in
critical section
if( j == 2000
t = str[i];
if(t>=65&& t<=91);// Characters
between A
and Z
addr=(t-’A’)*5;//i is being
incremented in interrupt
else if(t>=97&& t<=‘122);
// Characters between a and z
else if(t>=48&& t<=57);
// Characters between 0 and 9
curr_col_temp=(curr_col<5)?
curr_col:curr_col%5;
m = offset + curr_col_temp;
if(m>=5) m=m-5;
addr = addr + m;
value = PRG_RDB(&leds[addr]);
outp( value, PORTC);
setcol(curr_col);
sei();//enable interrupt”
The function ‘setcol(int col)’ is
called to send appropriate values to the
ports to drive the column LEDs.

Construction
The circuit can be constructed on any
general-purpose PCB. A 3-core serial ca-
ble is used for communication with the
PC’s keyboard. The 9-pin male connec-
tor is soldered on the PCB to interface
with the cable. 5V DC regulated power
supply is required for the circuit as well
as programming the circuit, which can
be constructed on a separate PCB.
An actual-size, solder-side com-
bined PCB layout for the display
and interface circuits (Figs 2 and 3)
is shown in Fig. 7 and its component
layout in Fig. 8.

Testing procedure
After having mounted all the compo-
nents, except AVR on the PCB, you
have to perform the initial test (option-
al) to check the connections of the 5x7
dot-matrix displays. The ‘check.c’ pro-
gram given below can be programmed
into the AVR for this checking. The
various steps involved are:
1. Download the ‘AvrEdit3.5’
Fig. 8: Component layout for the PCB software and Atmel AVR ISP and

Electronics Projects vol. 26 23


load the ‘Check. 9. Switch on the power to the
Rom’ file from circuit and run ‘Terminal’ from the
the ‘AvrEdit’ desktop. Choose the baud rate of this
folder. application as 9600 and parity bit as
6. From ‘Pro- none (refer to the screenshot).
gram’ menu bar 10. Click ‘Connect’ button and type
of the ISP, select ‘*New Year 2005?’ in the transmit box.
‘Program De- Note that the message should always
vice’ to program be enclosed between ‘*’ and ‘?’ before
the AVR. transmission.
Remove the 11. Click ‘Send’ button to transmit
programmed the characters for display on the dot-
AVR from the matrix displays.
STK200 board. 12. To enter new characters for
The AVR, when display, click ‘Disconnect’ button,
Screenshot of terminal program inserted into the press reset switch S2 and type new
populated PCB, message in the transmit/edit box.
install in your system. The ‘AvrEdit’ will light up all the LEDs in the display Click ‘Connect’ button followed by
and ‘Avrtools’ folders automati- devices if the circuit connections are ‘Send’ button.
cally get created in the respective correct. 13. If a particular string is to be
software. Now, to program the main pro- scrolled again and again, disconnect
2. Create another folder, say, ‘Dis- gram ‘ScrollD.c’ into the AVR chip, the circuit from the PC. Whenever
check,’ under the ‘AvrEdit’ folder and create a folder, say, ‘Scroll’ under the the circuit is switched on, the display
copy the ‘check.c’ file into the ‘Dis- ‘AvrEdit’ folder. Copy ‘ScrollD.c’ into system will wait for 17 seconds and the
check’ folder. the ‘Scroll’ folder, run ‘AvrEdit’ and previous string stored in the EEPROM
3. Run ‘AvrEdit’ from the desktop, follow steps 2 through 6 as mentioned will scroll on the displays without the
open the ‘check.c’ program and click above. After programming the AVR, need of serial cable, Terminal program
‘Run’ in the menu bar for compilation. remove it from the STK200 board and and PC. This feature makes this em-
After compilation, the ‘Check.Rom’ file insert into the main circuit. bedded system a standalone system.
is automatically generated under the 7. Connect the 9-pin D-type female EFY note. 1. It was observed that
‘Discheck’ folder. connector from the main circuit to the a momentary low pulse is required
4. Now, connect the STK200 (don- COM port of your PC. to be provided at pin 10 (RXD) of the
gle) to the parallel port of the PC and 8. Download the ‘Terminalv1.9b’ AVR through switch S3 to initiate the
insert the AVR into the zip socket of communication software and install display without PC.
the STK200 board. it in your PC. An application file icon Download source code: http://
5. Run the Atmel AVR ISP from named ‘Terminal’ will be created on www.efymag.com/admin/issuepdf/
the desktop, select ‘New Project’ to the desktop. SCROLL%20DISPLAY.zip

scrolld.c
// Code for AVR PROJECT of Scrolling Dis- j++; int x = (curr_col<5)? curr_col: curr_col%5 ;
play if ( curr_col==20) if( (x!=0&&(x+offset)%5==0) ||(offset==0 && (
#include <eeprom.h> { curr_col==5 || curr_col==10 ||curr_col==15 ||
// Offset b/w 0 and 4 curr_col=0; curr_col==20)))
#include <io.h> if( offset ==0) i++;//char shift
#include <progmem.h> { if(i==count ) i=0;
#include<interrupt.h> if( i>=3) i=i-3; }
#include<sig-avr.h> else i=i+count-3; if(i==count)//added now
#include<ina90.h> //offset++; i=0;
//offset is the beginnig pointer } TCNT0 = 230;
// global varables else }
int curr_col,i=0,j=0,offset=0,temp=0,q=1; if(offset==4 && j== 2000)
unsigned char str[100], str1[100]; {i=temp+1; typedef unsigned char u08;
int count=0, address,x,x1 ; temp=i; u08 __attribute__ ((progmem)) leds[]={
void EEWRITE( int address,char value); } 0xe0, 0xd7, 0xb7, 0xd7, 0xe0,
void EEREAD( int address,char *val); else 0x80, 0xb6, 0xb6, 0xb6, 0xc9, //b
void setcol(int col); { i--; 0xc1, 0xbe ,0xbe, 0xbe, 0xdd, //c
SIGNAL(SIG_OUTPUT_COMPARE1A) k = 20 - offset; 0x80, 0xbe ,0xbe, 0xbe, 0xc1, //d
{q=0;} while( k>=5){ k=k-5; i--; if(i<0) i=i+count; } 0x80, 0xb6, 0xb6, 0xb6, 0xbe, //e
SIGNAL(SIG_OVERFLOW0) } 0x80, 0xb7, 0xb7, 0xb7, 0xbf, //f
{ } 0xc1, 0xbe, 0xba, 0xba, 0xd9, //g
int k; 0x80, 0xf7, 0xf7, 0xf7, 0x80, //h
setcol(-1); else 0xbe, 0xbe, 0x80, 0xbe, 0xbe, //i
curr_col++; {

24 Electronics projects Vol. 26


0xb9, 0xbe, 0xbf, 0x81, 0xbf, //j {
0x80, 0xf7, 0xeb, 0xdd, 0xbe, //k while((count1<100) && (str1[k] != 63)) // t = str[i];
0x00, 0xfe, 0xfe, 0xfe, 0xfe, //l enter not pressed if( t>=65 && t<=91)
0x80, 0xdf, 0xe7, 0xdf, 0x80, //m { addr = (t-’A’)*5;//i is being incremented in
0x80, 0xef, 0xf7, 0xfb, 0x80, //n if(USR & (1<<RXC)) interrupt
0xc1, 0xbe, 0xbe, 0xbe, 0xc1, //o { else
0x80, 0xb7, 0xb7, 0xb7, 0xcf, //p str1[count1]=UDR; if( t>=97 && t<=122) // c b/w a and z
0xc1, 0xbe, 0xba, 0xbc, 0xc0, //q k=count1; addr = (t-71)*5;
0x80, 0xb7, 0xb3, 0xb5, 0xce, //r count1++; else
0xce, 0xb6, 0xb6, 0xb6, 0xd9, //s if( t>=48 && t<=57) // c b/w 0 and 9
0xbf, 0xbf, 0x80, 0xbf, 0xbf, //t } addr = (t-48+52)*5;
0x81, 0xfe, 0xfe, 0xfe, 0x81, //u }
0x83, 0xfd, 0xfe, 0xfd, 0x83, //v flag=1;//if string entered in correct format ok else
0x00, 0xfd, 0xfb, 0xfd, 0x00, //w else flag remains 0 & prevoiusly stored string will addr = -325;
0x1c, 0x6b, 0x77, 0x6b, 0x1c, //x be displayed curr_col_temp=(curr_col<5)?curr_col:curr_col%5;
0xbf, 0xdf, 0xe0, 0xdf, 0xbf, //y } m = offset + curr_col_temp;
0xbc, 0xba, 0xb6, 0xae, 0x9e, if(str1[k] == 63) if(m>=5) m=m-5;
0xf0,0xee,0xee,0xf1,0xfe,//a str1[k]=’\0’; addr = addr + m;
0x00,0xf6,0xf6,0xf6,0xf6,//b address = 0x0001; value = PRG_RDB(&leds[addr]);
0xf1,0xee,0xee,0xee,0xff,//c x=0; outp( value, PORTC);
0xf0,0xf6,0xf6,0xf6,0x00,//d if(flag==1) // curr_col = curr_col+1;
0xe1,0xd6,0xd6,0xd6,0xe6,//e {do setcol(curr_col);
0xf7,0x00,0x37,0x37,0xdf,// { sei();
0xcf,0x37,0x31,0x36,0xc0,//g EEWRITE(address,str1[x]); }
0xff,0x00,0xf7,0xf7,0xf8,//h EEREAD( address, str+x); }
0xff,0xff,0xd0,0xff,0xff,//i address++;
0xfd,0xfa,0x20,0xff,0xff,//j x1=x; void setcol( int col)
0xff,0x00,0xfb,0xf5,0xee,//k x++; {
0xfb,0x00,0x2e,0xdd,0xff,//l }
0xf0,0xef,0xf0,0xef,0xf0,//m while( str1[x1] !=’\0’); //initially switch off all coloumns
0x6f ,0x70 ,0x6f ,0x6f ,0x70,//n count = x; switch (col)
0xf9,0xf6,0xf6,0xf6,0xf9,//o }//end of if flag==1 {
0x00, 0x6d, 0x6b, 0x77, 0x7f,//p case -1: PORTA=0x00;PORTB=0x00;PORTC=0xF
0x4f, 0x37, 0x37 ,0x00 ,0x7b,//q if(flag==0) F;PORTD=0x00;break;
0xf7 ,0xf4 ,0xfa ,0xf4 ,0xf7,//r {do case 0: PORTA = 0x01; break;
0xf5 ,0xea ,0xea ,0xf4 ,0xff,//s {EEREAD( address, str+x); case 1: PORTA = 0x02; break;
0xf7 ,0xf7, 0x00, 0xf6, 0xf5,//t address++; case 2: PORTA = 0x04; break;
0xf1, 0xfe ,0xfe, 0xfe, 0xf1,//u x1=x; case 3: PORTA = 0x08; break;
0xef ,0xf1 ,0xfe ,0xf1 ,0xef,//v x++; case 4: PORTA = 0x10; break;
0xe1, 0xfe, 0xf9 ,0xfe, 0xe1,//w } case 5: PORTB = 0x01; break;
0xee, 0xed ,0xf3 ,0xed, 0xee,//x while(str[x1]!=’\0’); case 6: PORTB = 0x02; break;
0xcf ,0xf7, 0xf5, 0xf2, 0xc0,//y count = x; case 7: PORTB = 0x04; break;
0xee ,0xec ,0xea ,0xe6 ,0xee,//z }//end of flag==0 case 8: PORTB = 0x08; break;
0x00,0x3e,0x3e,0x3e,0x00,//0 case 9: PORTB = 0x10; break;
0xff,0xff,0x00,0xff,0xff,//1 TIFR = TIFR; case 10: PORTD = 0x04; break;
0xb0,0xb6,0xb6,0xb6,0x86,//2 TCNT0 = 230; case 11: PORTD = 0x08; break;
0xb6,0xb6,0xb6,0xb6,0x00,//3 TIMSK |= 1<<TOIE0 ; case 12: PORTD = 0x10; break;
0x87,0xf7,0xf7,0xf7,0x80,//4 TCCR0 = 3; case 13: PORTD = 0x20; break;
0x06, 0x36 ,0x36 ,0x36 ,0x30,//5 case 14: PORTD = 0x40; break;
0xf1, 0xee, 0xd6 ,0xb8, 0x7f,//6 int addr, curr_col_temp,m; case 15: PORTA = 0x80; break;
0xbd, 0xbb ,0xb7 ,0xaf ,0x9f,//7 u08 value; case 16: PORTA = 0x40; break;
0xc9 ,0xb6 ,0xb6 ,0xb6 ,0xc9,//8 outp(0xff,DDRA); case 17: PORTA = 0x20; break;
0xcd ,0xb6, 0xb6, 0xb6, 0xc1//9 outp(0xff,DDRB); case 18: PORTB = 0x40; break;
outp(0xff,DDRC); case 19: PORTB = 0x20; break;
}; outp(0xff,DDRD); default : break;
char t; }
/* interrupts 1. refresh rate 2. scroll rate */ curr_col=0; }
/* End of interrupts */ setcol(-1);
int main(void) while(1) void EEWRITE(int address, char value)
{ { {
unsigned char first_byte,count1,k=0,flag=0; cli(); while(EECR&(1<<EEWE));
count1=0; if( j == 2000) eeprom_wb(address, value);
UBRR=25; { EECR |=(1<<EEMWE);
UCR= (1<<RXEN)|(1<<TXEN); //if( offset == 4 ) temp= offset; EECR|=(1<<EEWE);
TIFR=TIFR; offset++; }
TIMSK=1<<OCIE1A; j=0;
TCCR1B=5; }//multiple of refresh(19),make para 1900 or 2000 void EEREAD (int address,char *val)
OCR1AH=10; {
// OCR1AL=0; if(offset >=5) while(EECR&(1<<EEWE));
_SEI(); {offset=0; EEAR=address;
while( !(USR&(1<<RXC))&& (q!=0 ));//timer1 // temp++; EECR=(1<<EERE);
will count till 2^16-1 if(temp>=count) *val= EEDR;
first_byte=UDR; temp=0; }
if(first_byte == 42) //is * }

check.c
// Program for checking Dot matrix Display // DDRA=0xFF; PORTD=0XFF;
#include<io.h> DDRB=0xFF; PORTC=0X00;
#include<sig-avr.h> DDRC=0XFF; for(; ;)
#include<ina90.h> DDRD=0xFF; {
int main(void) PORTA=0XFF; }
{ PORTB=0XFF; } 

Electronics Projects vol. 26 25


Remote-Controlled
Digital Audio Processor
 Kulajit Sarma 15-step control for bass, midrange and Parts List
treble

T
Semiconductors:
IC1 - AT89C51 microcontroller
hese days most audio systems 6. Settings displayed on two 7-seg- IC2, IC3 - CD4543 7-segment decoder/
come with remote controllers. ment light-emitting diode (LED) dis- driver
IC4 - TDA7439 audio processor
However, no such facility is plays and eight individual LEDs IC5 - MC24C02 I2C EEPROM
IC6 - KA2281 2-channel level
provided for normal audio amplifiers. 7. Stereo VU level indication on 10- meter driver
Such audio controllers are not available LED bar display IC7 - TSOP1238 IR receiver
module
even in kit form. This article presents 8. Full-function keys on-board for IC8 - 7809 9V regulator
IC9 - 7805 5V regulator
an infrared (IR) remote-controlled audio amplifier control IC10 - LM317 variable regulator
digital audio processor. It is based on a 9. All settings stored on the EE- T1 - BC558 pnp transistor
T2, T3, T5 - BC547 npn transistor
microcontroller and can be used with PROM T4 - BD139 pnp transistor
BR1 - W04M bridge rectifier
any NEC-compatible full-function IR 10. Standby mode for amplifier D1-D6 - 1N4004 rectifier diode
remote control. power control DIS1, DIS2 - LTS543 7-segment display
DIS3 - 10-LED bargraph display
This audio processor has enhanced LED1-LED8 - Red LED
features and can be easily customised Circuit description LED9 - Green LED
Resistors (all ¼-watt, ±5% carbon):
to meet individual requirements as it Fig. 1 shows the block diagram of R1 - 8.2-kilo-ohm
is programmable. Its main features are: the remote-controlled digital audio R2-R24,
R40-R49 - 1-kilo-ohm
1. Full remote control using any processor. The system comprises At- R25, R28,
R50, R53 - 10-kilo-ohm
NEC-compatible IR remote control mel’s AT89C51 microcontroller (IC1), R26, R29,
handset TDA7439 audio processor from SGS- R30, R34 - 2.7-kilo-ohm
R27 - 100-ohm
2. Provision for four stereo input Thomson (IC4) and I2C bus compat- R31, R35 - 5.6-kilo-ohm
R32, R33 - 4.7-kilo-ohm
channels and one stereo output ible MC24C02 EEPROM (IC5). The R36-R39 - 22-kilo-ohm
3. Individual gain control for each microcontroller chip is programmed R51 - 220-kilo-ohm
R52 - 2.2-kilo-ohm
input channel to handle different to control all the digital processes of Capacitors:
sources the system. The audio processor con- C1, C2 - 33pF ceramic disk
C3, C10 - 10µF, 16V electrolytic
4. Bass, midrange, treble, mute and trols all the audio amplifier functions C4-C6,
attenuation control and is compatible with I2C bus. All the C39-C41 - 100nF ceramic disk
C7 - 4.7µF, 16V electrolytic
5. 80-step control for volume and commands from the remote control are C8, C9 - 2.2µF, 16V electrolytic
C11, C20 - 5.6nF polyester
received through the C12, C19 - 18nF polyester
IR sensor. The audio C13, C18 - 22nF polyester
C14, C17 - 100nF polyester
amplifier can also be C21-C28 - 0.47µF polyester
C29-C32 - 4.7µF, 25V electrolytic
controlled using the C33, C34 - 10µF, 25V electrolytic
on-board keys. C35 - 1000µF, 25V electrolytic
C36 - 4700µF, 25V electrolytic
Microcontroller. C37, C38 - 0.33µF ceramic disk
C42 - 470µF, 25V electrolytic
The function of the
Miscellaneous:
microcontroller is to X1 - 230V AC primary to 12V, 1A
receive commands secondary transformer
RL1 - 9V, 160Ω, 2 C/O relay
(through port P3.2) Xtal - 12MHz crystal
S1- S7 - Push-to-on switch
from the remote S8 - On/Off switch
handset, program Remote - Creative’s remote (NEC-
compatible format)
audio controls as per
the commands and the value of a parameter continuously
update the EEPROM. until he is satisfied.
A delay in updating The 40-pin AT89C51 microcontroller
the EEPROM is de- has four 8-bit input/output (I/O) ports.
liberately provided Port 0 is used for indicating
because normally the through LEDs the various functions
Fig. 1: Block diagram of the remote-controlled digital audio processor listener will change selected via the remote/on-board keys.

26 Electronics projects Vol. 26


Electronics Projects vol. 26
27
Fig. 2: Circuit diagram of the remote-controlled digital audio processor
Fig. 3: Power supply

Port 1 drives the 7-segment display as 256×8-bit that can retain data for can control volume, treble, bass, at-
using 7-segment latch/decoder/driver more than ten years. Various param- tenuation, gain and other functions
IC CD4543. eters can be stored in it. of each channel separately. All these
Port 2 is pulled up via resistor To obviate the loss of latest set- parameters are programmed by the
network RNW1 and used for manual tings in the case of power failure, the microcontroller using SCL and SDA
key control. microcontroller stores all the audio lines, which it shares with the memory
Pins P3.0 and P3.1 of the microcon- settings of the user in the EEPROM. IC and the audio processor.
troller are used as serial data (SDA) The memory ensures that the micro- Data transmission from the micro-
and serial clock (SCL) lines for the I2C controller will read the last saved set- controller to the audio processor (IC
bus for communicating with the audio tings from the EEPROM when power TDA7439) and the memory (MC24C02)
processor (TDA7439) and EEPROM resumes. Using SCL and SDA lines, and vice versa takes place through the
(MC24C02). These two lines are con- the microcontroller can read and write two-wire I2C-bus interface consisting
nected to pull-up resistors, which are data for all the parameters. of SDA and SCL, which are connected
required for I2C bus devices. P3.2 re- For more details on I2C bus and to P3.0 (RXD) and P3.1 (TXD) of the
ceives the remote commands through memory interface, please refer to the microcontroller, respectively. Here,
the IR receiver module. Pin P3.4 is MC24C02 datasheet. Audio parameters the microcontroller unit acts as the
used for flashing LED9 whenever a can be set using the remote control master and the audio processor and
remote command is received or any handset or the on-board keys as per the memory act as slave devices. Any
key is pressed. the details given under the ‘remote of these three devices can act as the
The microcontroller also checks the control’ section. transmitter or the receiver under the
functioning of the memory (MC24C02) Audio processor. IC TDA7439 is a control of the master.
and the audio processor (TDA7439). If single-chip I2C-bus compatible audio Some of the conditions to commu-
it is not communicating with these two controller that is used to control all the nicate through the I2C bus are:
ICs on the I2C bus, it flashes the vol- functions of the audio amplifier. The 1. Data validity: The data on the
ume level on the 7-segment displays. output from any (up to four) stereo SDA line must be stable during the
Memory. IC MC24C02 is an I2C-bus preamplifier is fed to the audio pro- high period of the clock. The high and
compatible 2k-bit EEPROM organised cessor (TDA7439). The microcontroller low states of the data line can change

28 Electronics projects Vol. 26


only when the clock signal on the SCL
line is low.
2. Start and Stop: A start condition
is a high-to-low transition of the SDA
line while SCL is high. The stop condi-
tion is a low-to-high transition of the
SDA line while SCL is high.
3. Byte format: Every byte trans-
ferred on the SDA line must contain
eight bits. The most significant bit
(MSB) is transferred first.
4. Acknowledge: Each byte must be
followed by an acknowledgement bit.
The acknowledge clock pulse is gener-
ated by the master. The transmitter
releases the SDA line (high) during the
acknowledge clock pulse. The receiver
must pull down the SDA line during
the acknowledge clock pulse so that it
remains low during the high period of
this clock pulse.
To program any of the parameters,
the following interface protocol is used
for sending the data from the micro-
controller to TDA7439. The interface
protocol comprises:
1. A start condition (S)
2. A chip address byte containing
the TDA7439 address (88H) followed
by an acknowledgement bit (ACK)
3. A sub-address byte followed by
an ACK. The first four bits (LSB) of this
byte indicate the function selected (e.g.,
input select, bass, treble and volume).
The fifth bit indicates incremental/
non-incremental bus (1/0) and the
sixth, seventh and eighth bits are ‘don’t
care’ bits.
4. A sequence of data followed by
an ACK. The data pertains to the value
for the selected function.
5. A stop condition (P)
In the case of non-incremental
bus, the data bytes correspond only
to the function selected. If the fifth bit
is high, the sub-address is automati-
cally incremented with each data byte.
This mode is useful for initialising the Fig. 4: Combined actual-size, single-side PCB for the remote-controlled digital audio processor
(Fig. 2) and power supply (Fig. 3)
device. For actual values of data bytes
for each function, refer to the datasheet Power supply. Fig. 3 shows the output is rectified by full-wave bridge
of TDA7439. power supply circuit for the remote- rectifier BR1 and filtered by capacitor
Similar protocol is followed for controlled digital audio processor. C42. Regulators IC8 and IC9 provide
sending data to/from the microcon- The AC mains is stepped down by regulated 5V and 9V power supplies,
troller to MC24C02 EEPROM by using transformer X1 to deliver a secondary respectively. IC10 acts as the variable
its chip address as ‘A0H’. output of 9V AC at 1A. The transformer power supply regulator. It is set to pro-

Electronics Projects vol. 26 29


Relay RL1 is normally energised to
provide mains to the power amplifier.
In standby mode, it is de-energised.
Switch S2 is the ‘on’/‘off’ switch.

Software
The software was assembled using
Metalink’s ASM51 assembler, which
is freely available for download. The
source code has been extensively com-
mented for easier understanding. It
can be divided into the following seg-
ments in the order of listing:
1. Variable and constant definitions
2. Delay routines
3. IR decoding routines
4. Keyboard routines
5. TDA7439 communication
6. MC24C02 communication
7. I2C bus routines
8. Display routines
9. IR and key command processing
10. Timer 1 interrupt handler
11. Main program
On reset, the microcontroller ex-
ecutes the main program as follows:
1. Initialise the microcontroller’s
registers and random-access memory
(RAM) locations.
2. Read Standby and Mute sta-
tus from the EEPROM and initialise
TDA7439 accordingly.
3. Read various audio parameters
from the EEPROM and initialise the
audio processor.
4. Initialise the display and LED
port.
5. Loop infinitely as follows, wait-
ing for events:
• Enable the interrupts.
• Check the monitor input for AC
power-off. If the power goes off, jump
to the power-off sequence routine.
• Else, if a new key is pressed,
call the DO_KEY routine to process
the key. For this, check whether the
NEW_KEY bit is set. This bit is cleared
Fig. 5: Component layout for the PCB of Fig. 4 after the command is processed.
• Else, if a new IR command is
vide 3V regulated supply by adjusting Walkman. received, call the DO_COM routine
preset VR1. Capacitors C39, C40 and As capacitors above 10 µF are con- to process the remote command. For
C41 bypass any ripple in the regulated nected to the outputs of regulator ICs, this, check whether the NEW_COM
outputs. This supply is not used in the diodes D3 through D5 provide protec- (new IR command available) bit is set.
circuit. However, the readers can use tion to the regulator ICs, respectively, This bit is cleared after the command
the same for powering devices like a in case their inputs short to ground. is processed.

30 Electronics projects Vol. 26


• Jump to the beginning of the Compare the received byte with the plays, except LED9, turn off to indicate
loop. custom code (C_Code). If these don’t the standby status.
6. Power-off sequence. Save all the match, return error. 3. Input Select: To select the audio
settings to the EEPROM, and turn off 6. Receive the next byte and com- input source, press ‘Channel’ key until
the display and standby relay. pare with the custom code. If these the desired channel is selected. The LED
Since the output of the IR sensor don’t match, return error. corresponding to the selected channel
is connected to pin 12 (INT0) of the 7. Receive the next byte and store turns on and the input gain setting
microcontroller, an external interrupt in ‘Command.’ for that channel is displayed for five
occurs whenever a code is received. The 8. Receive the next byte and check seconds. Thereafter, the volume level
algorithm for decoding the IR stream is whether it is complement value of is displayed on the 7-segment display.
completely implemented in the ‘external ‘Command.’ Else, return error. 4. Input Gain set: Press ‘Gain’ key.
interrupt 0’ handler routine. This routine 9. Receive ‘Stop’ bit. The LED corresponding to the channel
sets NEW_COM (02H in bit memory) 10. Set NEW_COM and return from will start blinking and the gain value
if a new command is available. The interrupt. is displayed. Use Vol+/Vol- key to in-
decoded command byte is stored in Other parts of the source code are crease/decrease the gain for that chan-
‘Command’ (location 021H in the in- relatively straightforward and self- nel. Note that the gain can be varied
ternal RAM). The main routine checks explanatory. from ‘1’ to ‘15.’ If you press ‘Gain’ key
for NEW_COM bit continuously in a Remote control. The micro-con- once more, and no key is pressed for
loop. Timer 0 is exclusively used by this troller can accept commands from any five seconds, it will exit the gain setting
routine to determine the pulse timings. IR remote that uses NEC transmission mode and the volume level is displayed.
Decoding the IR stream involves format. These remote controllers are 5. Audio: Press ‘Audio Set’ (Menu)
the following steps: readily available in the market and use key to adjust bass, middle, treble and
1. Since every code is transmitted µPD6121, PT2221 or a compatible IC. attenuation one by one. Each time
twice, reject the first by introducing a Here, we’ve used Creative’s remote ‘Audio Set’ key is pressed, the LED
delay of 85 milliseconds (ms) and start handset. corresponding to the selected func-
timer 0. The second transmission is All the functions of the system can tion turns on and the function value is
detected by checking for no-overflow be controlled fully using the remote displayed. Once the required function
timer 0. In all other cases, timer 0 will or the on-board keys. By default, the is selected, use Vol+ and Vol- to adjust
overflow. display shows the volume setting and the setting. Bass, middle and treble
2. For second transmission, check LEDs indicate the channel selected. can be varied from ‘07’ to ‘7.’ Values
the timer 0 count to determine the LED9 glows momentarily whenever a ‘0’ through ‘7’ indicate ‘Boost’ and ‘00’
length of the leader pulse (9 ms). If the command from the remote is received through ‘07’ indicate ‘Cut.’ Attenuation
pulse length is between 8.1 ms and 9.7 or any key is pressed. can be varied from ‘0’ to ‘40.’
ms, it will be recognised as valid. Skip Function adjustments are detailed
the following 4.5ms silence. below: Construction
3. To detect the incoming bits, 1. Volume: Use Vol+/Vol- key to The circuit can be easily assembled on
timer 0 is configured to use the strobe increase/decrease the volume. The any PCB with IC base. Before you install
signal such that the counter runs be- volume settings are shown on the two- the microcontroller, memory and audio
tween the interval periods of bits. The digit, 7-segment display. Steps can be processor in their sockets and solder
value of the counter is then used to varied between ‘1’ and ‘80.’ the IR receiver module, make sure that
determine whether the incoming bit is 2. Mute and Standby: Using ‘Mute’ the supply voltage is correct. All parts,
‘0’, ‘1’ or ‘Stop.’ This is implemented in and ‘Standby’ buttons, you can toggle except the audio processor (TDA7439),
the RECEIVE_BIT routine. the mute and standby status, respec- require 5V DC supply. The audio pro-
4. If the first bit received is ‘Stop,’ tively. If ‘Mute’ is pressed, the display cessor is powered by 9V DC.
repeat the last command by setting the will show ‘00.’ In ‘Standby’ mode, the Download source code: http://
NEW_COM bit. relay de-energises to switch off the www.efymag.com/admin/issuepdf/
5. Else, receive the rest seven bits. main amplifier. All the LEDs and dis- Audio%20Processor.zip 

Electronics Projects vol. 26 31


Device Control
Through PC’s Parallel
Port Using Visual Basic
 Adeeb Raza Here, we are concerned only with lel port using Visual Basic. The data
data lines D0 through D7 terminated output port of the PC’s parallel port is

H
ere is a Windows-based pro- at pins 2 through 9. These data lines used for controlling the devices or ap-
gram developed in Microsoft are the primary means of sending pliances. The interface circuit requires
Visual Basic programming information out of the port. Pins regulated 6V DC to drive the loads.
language for controlling eight devices 18 through 25 of the connector are Eight MCT2E opto-osolator ICs are
through the PC’s parallel port or Line grounded. used to prevent damage to the parallel
Printer Port (LPT). The program ac- Control lines of the parallel port port from short-circuit that may occur
cepts the input in decimal number are used to provide control signals across the interface circuit. Darlington
and outputs in binary form across the such as ‘form feed’ and ‘initialise’ to array IC ULN2803 is used to drive the
data pins of the PC’s parallel port for the printer. relays for controlling the devices.
controlling the connected devices/ The five status lines are the only in- Fig. 2 shows the circuit for device
appliances. put lines of the standard parallel port. control using the PC’s parallel port
These allow the printer to send signals programmed in Visual Basic. To get the
PC’s parallel port such as ‘error,’ ‘paper out’ and ‘busy’ power supply for the circuit, 230V AC
The standard parallel port comprises to the PC. mains is stepped down by transformer
four control lines, five status lines X1, rectified by bridge rectifier R3151
and eight data lines (refer to the table). Circuit description and filtered by capacitor C1 (1000µF,
It is found on the back of the PC as Fig. 1 shows the block diagram for 25V). The filtered output is fed to
a D-type 25-pin female connector. device control through the PC’s paral- input pin 1 of regulator IC 7806. The
regulated 6V DC is used to power the
interface circuit comprising ICs MCT2E
(IC2 through IC9) and ULN2803 (IC1).
Optocoupler MCT2E can be replaced
with 4N35.
LED1 through LED8 connected
across data output pins 2 through 9,
respectively, are used to indicate the

Parts List
Fig. 1: Block diagram of device control through PC’s parallel port using Visual Basic Semiconductors:
IC1 - ULN2803 relay driver
IC2-IC9 - MCT2E optocoupler
IC10 - 7806 voltage regulator
Parallel-Port Pin Details BR1 - 1A bridge rectifier
Pin number Traditional use Port name Read/Write Port address Port bit Resistors (all ¼-watt, ±5% carbon):
R1-R16 - 220-ohm resistor
2-4 Data out Data port W Base D0-D2
Capacitors:
5-9 Data out — W Base D3-D7 C1 - 1000µF, 25V electrolytic
1 Strobe Control port R/W Base+2 C0 capacitor
14 Auto feed — R/W Base+2 C1 C2 - 0.1µF ceramic type
capacitor
16 Initialise — R/W Base+2 C2
Miscellaneous:
17 Select input — R/W Base+2 C3 X1 - 230V AC primary to 0-9V,
15 Error Status port R Base+1 S3 250mA secondary trans-
former
13 Select — R Base+1 S4
S1 - On/Off switch
12 Paper end — R Base+1 S5 RL1-RL8 - 6V, 100-ohm, 1C/O relay
10 ACK — R Base+1 S6 - 25-pin, D-type parallel-port
11 Busy — R Base+1 S7 male connector

32 Electronics projects Vol. 26


The relays are used
to switch on or off
the appliances.

Software
program
Before going into de-
tails of the program,
let us figure out some
limitations of Visual
Basic programming
for interfacing the
circuit. Visual Basic
cannot directly ac-
cess the computer
hardware to control
the external world.
All the hardware
requests must go
through the sup-
ported file format of
Windows operating
system.
So the best way
to manipulate the
parallel port is the
printer object. The
printer object allows

Fig. 2: Circuit for device control through PC’s parallel port using Visual Basic
text and graphics to
be printed on the
printer through the
parallel port of the
PC. While all is well
with this option, it
is useless when you
want a direct con-
trol of the hardware.
In order to control
the port directly, we
must use something
external to our pro-
gram. A dynamic
link library (DLL)
file called ‘WIN95IO.
DLL’ is used for that
purpose.
The WIN95IO.
DLL file is meant
for a 32-bit machine,
status of the loads. Glowing of any of relays. Since IC ULN2803 has an inter- supported by Visual Basic Versions
these LEDs indicates that the device nal freewheeling diode to quench the 4, 5 and 6. No matter which version
connected to that specific output line inductive kick, no external freewheel- you are using, the DLL file must be
is ‘on.’ ing diodes are required across the in the Windows\system directory of
IC ULN2803 (Fig. 3) is a Darlington relay coils. The devices are connected your machine. The interface control
array relay driver that can drive eight through the relay contacts to mains. software program can be developed

Electronics Projects vol. 26 33


Fig. 5: Actual-size, single-side PCB layout for device control through PC’s parallel port
Fig. 3: Pin details of ULN2803 using Visual Basic

Fig. 4: Screen that appears when program is run

Fig. 6: Component layout for the PCB


thereon. No matter which DLL you
use, it won’t work under Windows NT Visual Basic. Pick the required compo- ment is used to send a bit to a port, for
due to security reasons. nents as shown in the screenshot (Fig. example, ‘vbOut [port],[number]’
The program code is given at the 4) from the toolbox on the left-hand When you are done with coding,
end of this article. It is assumed here side of the screen. The properties of compile and run the program. You’ll
that Microsoft Visual Basic 6 is in- each component can be set from the get the screen as shown in Fig. 4. Save
stalled on your PC and you have the right-hand side of the screen. the project file with ‘.vbp’ extension.
basic programming knowledge. The coding starts by declar- Make the executable file from ‘File’
The program coding is simple and ing ‘WIN95IO.DLL’ in the first line menu.
you can write it yourself. Launch Vi- “Private Declare Sub vbOut Lib EFY note. Form 1 is named as ‘Ar-
sual Basic from the desktop and open a ‘WIN95IO.DLL’ (ByVal AEPPort As port’ and Project 1 file as ‘Arport.vbp.’
new project by selecting the ‘Standard Integer, ByVal AEPData as Integer).”
EXE’ option. By default, it will open an The computer port is defined as ‘AEP- Construction
empty project window on the screen Port.’ Its base address is assigned Construct the circuit for device con-
with ‘Form 1’ as the file name. The as 378 (in hex) by the program line trol on any general-purpose PCB. Use
form is one of the supported files of the “AEPPort=&H378.” The ‘vbOut’ state- eight flexible wires for data bus (D0

34 Electronics projects Vol. 26


through D7) by connecting their one in Fig. 5. ‘5’ and click ‘On’ button using mouse.
end to the PCB and the other end to 3. Connect the 8-data line male The indicator on the screen will turn
the respective data pins of the 25-pin, connector to the female connector on ‘red.’ Then LED7 and LED5 connected
D-type parallel-port male connector. the PC. across the parallel port will glow, which
This male connector connects to the 4. Launch Visual Basic from the corresponds to binary output ‘00000101.’
female connector on the PC. An actual- desktop and develop the application The appliances connected to the respec-
size, single-side PCB for the circuit and as explained in the software program tive output lines will turn on.
its component layout are shown in section. Save the project file with ex- 6. To turn off the appliances, click
Figs 5 and 6, respectively. tension ‘.vbp.’ Alternatively, you can ‘Off’ button on the screen.
copy the executable file ‘Arport’ from 7. To exit the application, click
Testing procedure the EFY-CD to your system. ‘Quit’ button.
1. Install Microsoft Visual Basic 6 on 5. Open ‘Arport’ and click ‘Input Download source code: http://
your system. Edit’ box. You’re prompted to input the www.efymag.com/admin/issuepdf/
2. Fabricate or get the PCB shown data in decimal form. For example, input Device%20Control.zip

Source Code (Arport)


Private Declare Sub vbOut Lib “WIN95IO.DLL” AEPPort = &H378 AEPOut (Data)
(ByVal AEPPort As Integer, ByVal AEPData as pat = Text1.Text Shape1.Visible = False
Integer) AEPData = Val(pat) Shape2.Visible = True
Dim AEPPort As Integer AEPOut (Data) End Sub
Dim AEPData As Integer If pat = “” Then GoTo y Else GoTo x
x: Private Sub Command3_Click()
Sub AEPOut(Data As Integer) Shape1.Visible = True AEPPort = &H378
vbOut AEPPort, AEPData Shape2.Visible = False pat = 0
End Sub y: AEPData = Val(pat)
Private Sub Form_Load() End Sub AEPOut (Data)
Shape1.Visible = False Private Sub Command2_Click() End
pat = 0 AEPPort = &H378 End Sub
End Sub pat = 0 
Private Sub Command1_Click() AEPData = Val(pat)

Electronics Projects vol. 26 35


AUTO CHANGEOVER TO
generator on MAINS FAILURE
 GP CAPT. (RETD) K.C. BHASIN the systems supplied by AMF panel 4. The maximum number of crank-
designers. ing (starting) attempts is presettable

A
n auto-changeover on mains by the user.
failure (AMF) system compris- System features 5. For indicating the mode of op-
ing mains and standby sources 1. The original configuration/operation eration, selected source of supply, low-
of power supply continuously moni- of the DG set as also its control panel battery condition, etc, status-indication
tors the incoming mains and in case is not disturbed. That means manual LEDs have been provided on the logic
of its interruption, starts the standby start/stop operation of the DG set and control panel.
diesel generator (DG) set, monitors its its control panel functions of monitor- 6. A buzzer warns the operator of
output and then transfers the load to ing its 3-phase output are still avail- low-battery state and over-cranking
the DG set. able. attempts. It can be reset/disabled by
Here is a construction project 2. Before changeover either to the the operator. However, the low-battery
that utilises off-the-shelf readily DG set or to mains, the selected source indication LED will remain lit as long
available switchgear and integrates is checked for single-phasing, phase as the battery voltage remains low.
it with the indigenously designed reversal, and under- and over-voltage 7. When manual mode is selected,
logic control circuitry to automatically conditions. If the conditions are not ful- the DG set can be electrically started
start the standby supply source filled, changeover to the faulty source from the logic panel itself via push-
on failure of the mains 3-phase is inhibited. buttons. Latching relays ensure that
supply and stop the DG set on 3. Suitable delays have been pro- either the start or the stop operation is
resumption of mains. This system vided in start and stop control of the performed at a time.
costs about 40 per cent less than DG set. 8. Use of the industrial change-
over switchgear ensures
preferential selection of
mains, in case both the DG
set supply and mains are
available. Mechanical inter-
locking and tripping before
selection arrangements en-
sure that the two sources are
never paralleled.
9. The system is capable
of flawless operation under
potentially noisy (electrical)
environments due to the use
of a hardware debounce and
feedback circuitry.
10. The logic panel has
been designed using discrete
ICs, relays and other passive/
active devices. Hence under-
standing the logic is easy and
the changes required to meet
the peculiarities of the indi-
vidual standby supply source
can be easily implemented.
Fig. 1: Line/block diagram of the manual changeover system that existed before changeover to AMF 11. The logic circuit con-

36 Electronics projects Vol. 26


sumes minimal power, as most of the the DG set. The starter assembly com-
ICs used are CMOS. prises a starter, solenoid assembly as
well as shift lever and drive assembly.
Manual changeover It is housed inside a metallic body
system with cut near the drive assembly for
Fig. 1 shows the block diagram of engaging its geared pinion with the
the manual changeover system. The flywheel ring gear of the DG set when
3-phase, 4-wire output of the DG set the solenoid is energised. The body
is terminated on the control panel of the starter assembly is grounded/
via the 4-way isolator (moulded-case connected to the negative terminal of
circuit breakers (MCCBs)). The control the battery.
panel has the usual voltage and ampere Fig. 3(b) shows the complete starter
meters with current transformers (CTs) motor assembly. It is similar to the
and selector switches for monitoring starter assembly fitted on your car.
all the three phases. (Some panels may When the key switch is shifted to
have a power factor meter as well.) The ‘Start’ position, the starter solenoid
3-phase output of the control panel is energises to cause the solenoid plunger
routed to a 4-way manual changeover to move the shift lever, which engages
Fig. 2: Schematic block diagram of the DG set’s
switch. The mains 3-phase power is also electrical system its pinion with the engine flywheel
terminated on the manual changeover
switch via an isolator switch and energy
meter. The source (mains or DG set out-
put) selected by the manual changeover
switch is routed via MCCBs to feed the
desired loads.
The AMF system has been de-
signed around a Kirloskar HA series
engine with a 3-phase, 4-wire, 415V
AC, 50Hz alternator capable of deliv-
ering a maximum of 87.6 amperes per
phase at a power factor (PF) of 0.8. The
alternator uses 300V DC excitation at
4.2A.
The DG set is equipped with:
1. Flywheel with starter ring
2. 12V electric starter
3. Mechanical shutdown lever
4. Battery charging dynamo
5. Engine instrument panel consist- ring gear. The movement
ing of: of the plunger also closes
 Off/on/start key the main solenoid contacts,
 Lube-oil pressure gauge applying +12V battery
 Battery charging ammeter voltage to the starter mo-
 Hour meter tor through solid contacts
Fig. 2 shows the block diagram of the to allow the starter motor
electrical system of the DG set. It differs Fig. 3: The DG set starting system (above) and starter motor to draw 150-200 amperes
slightly from the diagram printed on the assembly (below) of current for overcoming
DG set’s instrument panel. the inertia of the engine.
The DG set is shut off by mechani- necessary for proper understanding Once the engine starts, the pinion
cally pulling a lever, which cuts off the design of AMF logic system (to be will overrun, protecting the armature
the fuel supply to the injectors and the described later). from excessive speed and the flywheel
engine comes to a halt in eight to ten from damage. When the key switch
seconds. The knowledge of function- DG set starting/cranking is released, the plunger-return spring
ing of starting circuit/components circuit disengages the pinion.
and charging circuit/components is Fig. 3(a) shows the circuit for starting Caution. Never operate the starter

Electronics Projects vol. 26 37


lator. Since the dynamo output is a
function of the engine speed, the aver-
age DC output may vary. A voltage/
current regulator combined with a re-
verse-current cut-out is used to regulate
the output between 13.8V and 14.2V,
which is considered to be appropriate
for charging a 12V lead-acid battery.
The cut-out prevents battery discharge
into the generator when its output volt-
age is below that of the battery.
Fig. 4 shows a typical 3-unit exter-
nal electromechanical regulator used
‘generator’). A generator for the purpose. It comprises three
is like a motor in reverse. relays. Two of the relays have a shunt
Instead of supplying the and series windings, respectively,
current to rotate the motor’s while the third (used for cut-out func-
shaft, we rotate or spin the tion) employs mixed series and shunt
dynamo’s shaft to generate windings. The regulator may also be
electricity. The dynamo installed within the dynamo housing
rotor is mechanically cou- itself. A full description of its working
pled to the engine’s shaft principle is given inside the box on the
through a V-belt and pulley next page.
(b) arrangement. The current Solidstate (electronic) regulator.
generated in its armature is Some newer versions employ solid-
Fig. 4: Schematic diagram of a typical three-unit
electromechanical regulator (above) and photograph of a AC and not DC. state regulators with reverse-current
typical 3-unit electromechanical regulator (below) Commutators on its protection. A typical solidstate regu-
shaft are used to lator circuit is shown in Fig. 5. The
rectify the AC output voltage of this regulator is held
current. Two constant by 13V zener diode ZD1 in
spring-loaded series with potmeter P1. P1 is adjusted
brushes slide on such that when the battery is fully
the commutators. charged to roughly 13.8V, the field
One brush is con- current of the generator is adequate
nected to ground to maintain a trickle charge current of
and the other 50 to 100 mA (through armature via
is connected to 0.1-ohm resistor R5) to replenish the
the main output battery charge.
of the genera- Initially, when a battery in dis-
tor (the positive charged state is connected to the
terminal marked circuit, and if the charging current
‘A’ for armature). exceeds 4A, transistor T1 conducts to
As the armature/ forward bias transistor T3 and transis-
Fig. 5: A typical solidstate electronic regulator with reverse current protection
for 12V battery commutator as- tor T2, in turn, stops conducting, which
sembly rotates, results in reduced field current of the
for more than 15 seconds at a time as the brushes touch different contacts on generator. The net effect is that the
excessive cranking can cause overheat- the commutator such that the polarity output current through the armature
ing of the starter. After each cranking of the current moving into and out of and resistor R5 is reduced to maintain
attempt, allow the starter to cool for at the armature commutators is always the output current from the generator
least a minute. connected to the correct brushes. The below 4 amperes.
net effect of this operation is that the Key-switch operation. Referring
Battery charging circuit generator output is DC even though back to Fig. 2, when we shift the key
and components the current inside the armature wind- switch to ‘on’ position, the warning
The charging current for the battery is ings is AC. bulb glows to indicate that the engine is
supplied by the dynamo (also called Three-unit electromechanical regu- stationary. One terminal of the warning

38 Electronics projects Vol. 26


bulb is connected to the battery via ‘on’ 2, 5 and 6 (existing DG set control manual changeover system.
position of the key switch and the other panel, mains supply via 3-phase iso- The DG set has been modified by
terminal is connected to the armature lator and energy meter, and 3-phase installing an additional solenoid puller
(point ‘A’), which is grounded through load connections via MCCBs, respec- along with a contactor (high-current
commutator brushes. tively) have already figured in the capacity relay) and another identical
The switch motion from ‘on’ to contactor for elec-
‘start’ position works against the ten- trically starting the
sion of a spring inside the key-switch. engine by making
After the engine starts and you release use of the DG set’s
the key switch, it automatically comes solenoid-starter
back and rests at ‘on’ position. With combination. Fur-
the engine running, the armature ther explanation
terminal ‘A’ builds up a voltage of of the modification
around 14V DC and as such the bulb Fig. 6: Block diagram of the proposed AMF system is given under the
stops glowing as the current through
the bulb reduces considerably.
The key switch works like the Three-unit Electromechanical Regulator
ignition key switch of your car. The Three units control charging. On the left are the cut-out contacts, which connect and
warning bulb also works the same way disconnect the dynamo armature from the battery.  When the output voltage of the
generator exceeds 11.8V, the contacts are pulled together and the armature’s A terminal
as the battery indicator light on the
is connected via thick wires to the current limiter section. The cut-out section also has a
dashboard of your car. The lighting of fine wire winding. This winding is connected to ground (also called shunt connected) and
the battery indicator while the car is provides the magnetic energy to pull the contacts together. 
running indicates that your car battery The contacts have a specific air gap and there is a spring trying to pull the contacts
is not charging and hence something is open.  The spring tension is adjusted to allow the contacts to come together from 11.8
wrong. The same goes for the warning to 13 volts.  The thick winding around the outside provides additional pull to the contacts
bulb on the DG set. In ‘on’ position of when the current is flowing to the battery to prevent arcing when the voltage output of the
dynamo armature is quite close to pull-in voltage. 
the key switch, the hour-meter starts
At the point where the voltage at the armature is below the battery voltage, the current starts
working. Any other ancillary equip- flowing from the battery to the armature. This reverse flow of current reverses the polarity of the
ment that you wish to run with the magnetic field produced by the thick current winding. This magnetic field opposes the field created
engine could also be connected to the by the small shunt winding, resulting in a clean release of the contacts.
‘on’ terminal of the key-switch. The centre pole is the current regulator. This section regulates the maximum current
Once the DG set engine is running that the generator is able to put out without destroying itself. It has a pair of contacts that
at the correct speed and the alternator are normally closed (NC). When the generator voltage starts to flow through the cut-out
section, all of the current flows through the current regulator coil.
is working, it generates 3-phase, 415V
When the current exceeds a predetermined level (8 to 10 amperes normally), spring
AC at 50 Hz, which is routed to its tension on the contacts allows the contacts to break. When the contacts open, it removes
control panel for monitoring and its the hard ground on the dynamo’s field (F) terminal. Now, only a parallel path for the field
further extension to the changeover winding to ground is available via a resistor, which causes a reduced-current ground path
switch. for the field winding. This reduces the output of the generator.
Now, if you are satisfied with When the generator output drops, the spring pulls the current contacts back together and
manual operation of the DG set but bypasses the resistor to ground. The generator again runs to provide the full output and the cycle
repeats.  If the load is too high, the contacts will be continuously vibrating to limit the current
wish only to automate the operation of
to the preset level. This allows the charging current to be limited to the maximum safe limit.
the changeover switch function, it is a On extreme right is the third unit forming the voltage control section. It consists of a pair of
rather simple affair. Automatic change- NC contacts connected in series with the current control contacts to ground and to the field (F)
over switches (also called automatic terminal.  Under these contacts is a coil of very fine wire wound around a metal pole piece, as
transfer switches (ATS)) are available the coils on the other two units are.  The air gap and the spring tension on these terminals are
from a number of electrical switchgear adjusted to control the voltage output of the dynamo armature from 14 to 14.5 volts. 
makers. Since this coil is connected in parallel across the armature terminal to ground, its magnetic
field is directly proportional to the armature output voltage. When the voltage reaches the
The AMF system preset level, the contacts break to open the direct ground path for the field current and leave
the resistor across the F terminal to ground. As a result, the dynamo armature output voltage
Fig. 6 shows the block diagram of the drops. The contacts close and the full dynamo armature output becomes available again. 
proposed AMF system. The system It works exactly like the current section, except that it responds only to the voltage output.
incorporates automatic switching There is an additional resistor between the F terminal the armature contact of the cut-out
operation of the DG set and its inte- to provide a damping effect when the control contacts open and reduce the arcing of the
gration with the automatic transfer contacts. It plays no part in the ‘controlling’ operation of the regulator. The relay contacts
are made of tungsten for long life.
switch from Havell. Blocks marked

Electronics Projects vol. 26 39


description of the modified wiring contacts under constant pressure with to the standby supply side when both
diagram of the DG set. the back-up spring. Main contacts are supplies are present. Tripping coil TC,
Block 3 contains the main logic cir- made of silver-tungsten to ensure anti- when energised, brings the automatic
cuitry for controlling the start/stop of weld characteristics. The Arc Chute transfer switch to off/neutral position.
the DG set by making use of sense sig- plates, placed in the path of contacts, Closing onto the standby supply side
nals picked up from the DG set as well quench the arc and thereby enhance is achieved through selective coil SC.
as from block 4. In addition, it includes the life of contacts. The energisation of selective coil SC
audio/visual status and warning indi- The main mechanism independent- disengages the main mechanism and
cators, which prompt the operator’s ly actuates two sets of cam linkages, prevents closing onto the mains supply
intervention during emergency/mal- which, in turn, operate the two inde- side. The solenoid coil can then close
functioning of equipment. Block 3 also pendent moving-contact assemblies. the second set of moving contacts onto
allows you to manually start/stop the Fig. 7(b) shows the line diagram the standby supply.
DG set, if required. of Havell’s ATS with essential relays. The moving contact mechanisms
Block 4 shows use of the industry- The contact closing command is ef- of mains and standby supplies are
standard automatic transfer switch. fected through solenoid closing coil C inherently mechanically interlocked
We’ve used Havell’s ATS due to its supplied with 230V AC. The operating through a double-throw arrangement
relative merits for developing this AMF mechanism always responds by clos- that ensures that at no point of time the
system. Certain additional circuitry has ing onto the mains supply side and not two supplies are paralleled.
been incorporated for monitoring both During au-
the mains and the DG set supply sources tomatic switch
for single-phasing, phase reversal, and operation, the
under- and over-voltage conditions closure of its
before permitting changeover of the contacts to-
supply source. The additional circuitry wards mains
also senses various operations such as or standby side
tripping of mains and its resumption, as and tripping of
well as the mode of operation of the ATS the switch to
(auto or manual). These status signals neutral state
serve as sense signals for the AMF logic are effected
panel (block 3) in starting and stopping by certain
the DG set appropriately. mechanically-
The components used for automat- operated con-
ing the system are detailed below. tacts as well as
relay-operated
Havell’s automatic contacts. All
transfer switch
Havell’s automatic transfer switch used
for this AMF system comprises four
symmetrical poles coupled to the main
operating mechanism. The switching
mechanism is ‘quick make, quick break’
type. A brief description of its contact
mechanism in association with the relay
panel (supplied as essential part of the
ATS) is given below.
Contact mechanism (Fig. 7(a)).
Each pole has two independent sets
of moving-contact assemblies for
main and standby supply and one
fixed-contact assembly for the com-
mon outgoing load terminals. Cams,
when rotated by the main operating
mechanism, mechanically operate the
moving-contact assemblies.
Fig. 7: Contact mechanism of Havell’s ATS (above) and schematic line diagram of Havell’s ATS with
Moving contacts make onto fixed essential relays (below)

40 Electronics projects Vol. 26


Fig. 8: Line diagram of Havell’s integrated ATS

relays/coils operate off 230V AC. For 230V AC between the affected termi- achieved manually by pressing ‘Trip’
transfer of load onto mains or standby nals AT1 and AT2, or BT1 and BT2, button momentarily.
side, 230V AC is applied between will energise trip coil TC to bring the Caution. Before the emergency op-
terminals A1and A2, or B1 and B2, switch to neutral position. eration, isolate the load from the ATS.
respectively. For tripping of mains or 3. TC: Trip coil, when energised, Integrated ATS operation. The
standby, the 230V AC is applied be- trips the switch to neutral position. Havell’s ATS now comes as an in-
tween terminals AT1 and AT2, or BT1 4. SC: Selective coil, when energised, tegrated unit. A line diagram of the
and BT2, respectively. disengages the main mechanism and integrated unit is shown in Fig. 8.
Function of some of the relays for prevents closing towards the mains Apart from the components shown in
operation of the ATS has already been supply side by pulling limit switches Fig. 7(b), it comprises selector switch,
given under the description of its con- marked LS (Fig. 7) towards B1 and B2 pushbuttons, indicator lamps and re-
tact mechanism. However, operation of contacts. SC coil is used along with lays including timers.
all contacts/relays (coils) used within closing coil C to close towards the The mode-selector switch is a
the ATS, as shown in Fig. 7(b), is sum- standby side. 3-way, double-changeover switch. The
marised below: Emergency operation of ATS. In an three poles in the circuit are marked as
1. Auxiliary contacts AX and BX: emergency, the ATS can be operated SS1, SS2 and SS3. The auto position is
When ATS switch is in off (tripped/ manually, as an off-load switch only, marked ‘A,’ while manual position is
neutral) state, auxiliary mechanical as follows: marked ‘M.’ Pushbutton switches PB1,
contacts AX and BX are in closed state. 1. Closing onto mains supply: A PB2 and PB3 are used for selection of
When the ATS energises via closing manual handle rotates the operating mains and standby (DG set) supplies
coil C towards mains or standby side shaft by 45° in anticlockwise direc- and tripping of the selected source
by operation of selective coil SC, in tion to achieve closure under off-load (mains/standby), respectively, in
association with closing relay C, the conditions. manual mode of operation. Pushbutton
respective auxiliary contacts break and 2. Closing onto standby supply: PB3 has two mechanically interlinked
the supply to closing coil is cut off. Closure onto the standby supply side sections as shown in the figure. The
2. ATS1 and ATS2, and BTS1 and is achieved when ‘Selective’ mode controlling voltage is derived from Red
BTS2: These two pairs of mechani- (through selective command hole) is phase and Neutral of the respective
cal contacts for mains and standby continuously pressed and the manual supply sources connected to the circuit
sources, respectively, close when the handle rotates the operating shaft by via fuses rated at 6 amperes each.
respective supply has been switched 45° in anticlockwise direction. The ATS operates in auto and
on via the ATS. The application of 3. Tripping: Tripping can be manual modes as follows:

Electronics Projects vol. 26 41


1. Auto mode. For operation in auto able to the load. Modifications in the ATS
mode, the switch is to be kept in auto However, if mains does not resume Havell’s ATS does not monitor all the
(A) position. Let’s assume that initially within the delay period of timer T3, three phases for under-voltage protec-
the ATS is in neutral (tripped) position C2 will energise and it will trip mains tion, nor does it have over-voltage or
and mains supply is available. Relay from the load via SS2 section of the single-phasing or phase-sequence-
R1 energises almost instantaneously, selector switch (and AT1 and AT2 con- change prevention arrangement. We
opening its NC contacts marked R1 tacts) before closing towards standby have therefore used an industry-stan-
to ensure that even if standby supply side due to energisation of B1 and B2 dard Minilec make SPP relay (VMR
becomes available subsequently, it will contacts via SS1 section of the selector D2) that incorporates all these pro-
not be able to reach timer T3 and con- switch and closed contacts of T2. The tections. Its normally-opened (N/O)
tactor C2 (which ultimately controls load is switched to standby supply contacts energise only when all the
the SBY source selection). Even if both and L2 indicator bulb glows. conditions are satisfied.
supplies (mains and standby) become Now, if mains resumes, it will open We have used a VMR D2 relay
available simultaneously, the standby the path for C2 due to energisation of for each of the two 3-phase supply
supply will be cut off from reaching R1. Once C2 de-energises, C1 will en- sources, i.e., mains supply as well as
contactor C2 (because of the delay in- ergise via T1. Now, via SS2 section of the DG set supply. The red-phase input
troduced by timer T3), while no timer the mode switch and C1 contacts, the from the respective sources is extended
comes in the path of relay R1. ATS will trip via BT1 and BT2 contacts to the fuse and neutral point of each
The mains’ red phase becomes before switching the load to mains control supply to the Havell’s ATS
available to timer T1, which connects source once again. when the conditions are fulfilled. The
the phase to contactor C1 after the pre- 2. Manual mode. For manual- under-voltage limits (80 to 95 per cent)
set delay. Once contactor C1 energises mode operation, the selector switch and over-voltage limits (105 to 120 per
and closes its two contacts, it extends is to be kept in manual (M) position. cent) of the auxiliary supply are adjust-
mains’ red phase and neutral to A1 It is advisable to press the trip button able via screwdriver controls.
and A2 points of the ATS assembly before changing from one source to We have used a 4-way (three N/O
(shown within dotted lines). The phase another in manual mode. and one N/C contacts), 9A rated con-
supply is routed to A1 terminal via In manual mode, both pairs of trip tactor in conjunction with VMR D2
SS1 and NC contact T2 of UV (under- contacts (AT1 and AT2, and BT1 and relays (one each for mains and standby
voltage relay) initiated timer, which BT2) are paralleled via SS3 section source) to detect the healthy supply
remains closed unless it encounters of the mode switch when trip button status of the available supplies to the
prolonged under-voltage condition. (PB3) is pressed. Pressing of trip button logic control panel and to extend the
This sequence ensures switching of ensures that whatever source is pres- red phase of supplies to Havell’s ATS.
load to mains as explained earlier. The ently connected to the load, it trips the The connections to VMR D2 relay for
mains indicator bulb lights via ATS-1 ATS and brings it to neutral position. 415V AC 3-phase (with 415V AC aux-
contact of the ATS. As an additional The red phase of any of the available iliary supply), and associated 4-way
safety, the NC contact C1 in series with supplies (mains when both supplies contactor, are made as under:
R1 contact also opens during energisa- are available) can be used to switch the 1. 415V AC 3-phase supply is con-
tion of C1 contactor to break the path load towards mains (using pushbutton nected to terminals marked 1, 2 and 3
for standby supply. PB1) or standby supply (using PB2). (in top row).
When mains is not available (trips), The automatic operation of the ATS is 2. Auxiliary voltage terminals 7
relay R1 and contactor C1 de-energise. inhibited by SS1 and SS2 sections of the and 8 (middle row) are connected to
Now, if standby supply from the DG mode-selector switch. Before changing any two phases (we used ‘R’ and ‘Y’
set is made available, its red phase over the source again, press trip switch phases).
reaches timer T3 via closed R1 and C1 PB3 before pressing PB1 or PB2. 3. N/O terminals 13 and 14 (bottom
contacts and, after preset delay of T3, we had explained the working row) are used for energising the 4-way
contactor C2 energises to open the NC of the manual changeover system/ (three N/O and one N/C) contac-
contact in the path of mains’ red-phase components as well as the components tor. The contacts close only when the
supply to timer T1. Switching of the utilised for the automatic changeo- 3-phase supply is healthy.
standby supply’s red phase to control ver system. Next section covers the 4. Red phase and Neutral of the
the ATS operation is feasible only after modifications effected in the Havell’s respective supplies are extended via
the delay introduced by timer T3. automatic transfer switch (ATS) and two N/O contacts to Havell’s ATS for
In case mains resumes before T3’s the Kirloskar 62.5kVA DG set, as well control.
delay period is over, R1 will energise as design of the logic control circuitry 5. The remaining two contacts
to open the control circuit for standby for automating the operation of the (one N/O and one N/C) are used for
supply and mains will become avail- changeover system. conveying the healthy supply status of

42 Electronics projects Vol. 26


the source to the logic
control panel.
Further, we have
replaced the 3-way,
double-changeover
mode-selector rotary
switch with a similar
4-way, double-change-
over rotary switch
(Kaycee make 4F46D).
The fourth section (SS4)
has been used to con-
vey the selected mode
information to the logic
control panel.
The Havell’s in-
tegrated ATS with
the modified wiring is
shown in Fig. 9.

Modifications
in DG set
Fig. 10 shows the
modified wiring dia-
gram of the standby
DG set.
For automating the
start, stop and run
operations of the DG
set, we need to sense
its present operational Fig. 9: Havell’s integrated ATS showing modifications
status. Two signals
are used for knowing the status of the was attached to the lever (used for seven lines carrying sense signals are
DG set. These are 230V AC alternator manually stopping the engine) using a routed from the ATS cubicle to the
output (across R-phase and Neutral) thin wire rope, similar to the one used logic control panel. Fig. 11 shows the
and dynamo-induced voltage of about in scooters for clutch/gear operation. interconnection diagram. The arrows
+14.5V DC. Both these voltages become As the solenoid arm had no tension, a indicate the direction of signals.
available after the DG set is running. spring of suitable tension and length It is desirable that each wire-end
(Note: For +14.5V to be available, +12V was used so that it returned to its origi- bears proper marking, so that after a
from the DG set battery needs to be nal position along with the stop lever disconnection for any fault rectification,
extended to ‘On’ terminal of the key- once the solenoid was de-energised. the wires are connected back to their
operated start switch.) A relay in the The battery supply and ‘IND’ ter- original points. For this purpose, num-
logic panel was used to extend the +12V minal of the dynamo are extended to bered plastic ferrules are available from
supply to ‘Run’ terminal. the indigenously designed logic control electrical switchgear dealers, which can
For starting the DG set, we have to panel via TB1, while for energising the be inserted in the cable ends to mark
switch +12V to the solenoid (forming ‘stop’ and ‘start’ relays, and for extend- the wire numbers. The wiring conven-
inbuilt part of the starter) of the starter ing +12V to ‘Run’ terminal, pin 5 of tions proposed in Fig. 11 can be used
using a relay with contact rating in ex- TB1 is used. The AC sample (R-phase for identification. Use of multicolour
cess of 20 amperes. Also, for stopping and neutral) from the DG set alternator leads (with resistor-type colour code)
the DG set, we use a similar relay for is extended to the logic control panel can further eliminate the risk of wrong
energising a solenoid puller. via pins 1 and 2 of TB2. connections during/after any servicing.
The solenoid puller (purchased A total of eight lines carrying DC
from the local market in Delhi) was and AC power, and sense and control Logic control panel
secured to rails on which the DG set signals are routed from the DG set to A summary of signals carried from/to
rests. Its free-moving central rod end the logic control panel, and another the logic control panel tag blocks (TBs)

Electronics Projects vol. 26 43


to/from the DG set and the ATS cubicle, Once condi-
along with their direction with respect to tions 1 through 4
the logic control panel, is given in Table have been satis-
above. These signals are used to control fied, the engine
the start and stop logic for the DG set. stopping action
Specifications. The conditions gov- is initiated and
erning the automatic start and stop unless the engine
operation of the DG set and the related comes to a dead
timings need to be specified for design- stop, the control-
ing the logic control circuitry. Some of ling solenoid
the conditions and timing requirements should not be re-
will vary for individual systems depend- leased; else, the
ing on the power rating, battery voltage, engine will tend
and built-in facilities of the DG set. The to restart because
system design must also take into account of inertia.
the operational requirements/constraints Engine-
of the system, including whether the DG cranking logic.
set is required to feed the load on 24-hour This logic func-
basis (in case of mains failure) or from tions in asso-
dawn to dusk, etc. The auto-start and ciation with the
stop logic used by us for our specific auto-start logic
system is explained below. for the DG set. Fig. 10: Modified wiring diagram of the standby DG set
Auto-start logic for the DG set.
For the DG set to start, the conditions
required are:
1. The mode-selector switch is in
‘auto’ mode.
2. The DG set is not already run-
ning.
3. A transition from ‘mains avail-
able’ to ‘mains not-available’ has been
detected.
4. Mains (healthy) is not available
even after 3-second wait, while condi-
tions 1 and 2 are still applicable.
Once conditions 1 through 4 have
been satisfied and the engine has
gained about 80 per cent speed (as
evidenced by the dynamo/alternator
output), the starter can be deactivated.
Auto-stop logic for the DG set. For
initiating the stop action for the DG set,
the following conditions must be met:
1. The mode selector switch is in
‘auto’ mode.
2. The DG set is running.
3. A transition from ‘mains not
available’ to ‘mains available’ has
been detected. Fig. 11: Interconnections between the logic control panel and the dg set as well as the ats cubical
4. Mains (healthy) is available even
after 30-second wait, while conditions 1 Once conditions governing the ‘DG set practically adequate for the engine to pick
and 2 are still applicable. The 30-second auto-start logic’ have been satisfied, and up the speed without excessive draining
is off-load cooling period for the DG set. continue to remain satisfied, engine- of the battery.
(Note: A higher cooling period must be cranking (starting) is attempted for During winter when the engine re-
taken for engines of higher rating.) around twelve seconds. This period is mains idle during the whole of night, the

44 Electronics projects Vol. 26


Signals Carried to and from the Logic Control Panel
TB Tag No. Signal Direction Description
TB-1 Tag No. TB-1 is used for carrying the DC supply and control signals.
1 Bat. - In It carries BAT- (Gnd.) from the battery in the DG set.
2 Bat.+ In It carries +12V from the battery in the DG set.
3 +IND. In This wire carries +14.5V generated by the dynamo.
4 Stop Out This output is active-low (Gnd) for energising ‘Stop’ relay RL5 in the DG set (see Fig. 11).
5 On Out This output is active-high (+12V). Once the engine starts, it extends +12V to ‘On’ terminal of the keyswitch.
6 Start Out
TB-2 Tag No. TB-2 is used for carrying the alternator output (red phase and neutral) sample for initiating activation of
‘On’ relay RL1, which extends +12V to ‘On’ point of the keyswitch.
1 R.Ph. In With the engine running, it carries the red phase from the alternator to energise relay RL1 in the logic
control panel.
2 N In This terminal extends neutral from the alternator.
TB-3 Tag No. TB3 brings in active-low (Gnd) signals (via terminals 1, 3 through 7) from the control cubical under
different conditions.
1 Auto In BAT- (Gnd) return when the mode-selector switch in the ATS cubical is kept in ‘auto’ position.
2 Pole Out BAT- (Gnd) is extended to the ATS cubical via the pole of mode-selector section SS4.
3 Man. In BAT- (Gnd) return when the mode-selector in the ATS cubical is in ‘manual’ position.
4 C3 (N/O Mains) In BAT- (Gnd) return when (healthy) mains is available.
5 C4 (N/C Mains) In BAT- (Gnd) return when (healthy) mains is not available.
6 C3 (N/O SBy) In BAT- (Gnd) return when (healthy) SBy is available.
7 C4 (N/C SBy) In BAT-(Gnd) return when (healthy) Sby is not available.

viscosity of lube oil is high, which puts a panel performs quite a few additional and around 2.5V across capacitor C36
higher load on the starter and as such the functions as well, which will become after bridge rectifier BR1.
starter may not be able to start the engine clear when we go through its circuit Considering a voltage drop of 1.25V
at first attempt. Under these circum- details. The schematic diagram of the across the LED of the optocoupler,
stances, it is advisable to start the engine logic control circuit is shown in Fig. 12. resistor R36 (120 ohms) is used to limit
manually (after switching off the logic The connections to/from the DG set the current to about 10 mA through
control panel), two/three times so that are terminated on TB-1 (shown split in the optocoupler LED. The collector of
the starter is able to function smoothly in two sections) and TB-2, while TB-3 is the optocoupler is in low state with the
auto position, in one attempt itself. used for terminating connections to/ engine/alternator running.
If the engine fails to start in the from the ATS cubicle. The description The output of the alternator serves
first attempt (of 12 seconds), it waits of the signals on these TBs is given in as one of the two inputs to NAND
for 70 seconds before making the next the table. The ground (battery nega- gate IC2B, and is also used for energis-
attempt. This period is essential for tive) connection from pin 1 of TB-1 is ing ‘Run’ relay RL1 via NAND gate
the battery to accumulate charge for extended to the modified ATS circuit IC2D (wired as an inverter) and driver
subsequent cranking attempts. The via pin 2 of TB-3. This ground connec- ULN2004A (IC8).
maximum number of cranking attempts tion is returned via other pins of TB-2 On energisation, RL1 contacts
can be preset (between two and five) by to indicate the state of mode switch and extend +12V to ‘on’ contact of the key-
the operator. A higher number of crank- mains and standby supply sources. The switch via pin 5 of TB-1. As a result,
ing attempts indicates that the high- status is displayed through LEDs (LED1 the hour meter of the DG set starts
viscosity lube oil has been used, the through LED6). Three of these six signals running and also the dynamo output
battery terminals/leads to the starter (auto mode ‘on,’ mains ‘on’ and mains becomes available for charging the
need cleaning/tightening, the starter ‘off’) are used for logic control. battery of the DG set. The dynamo IND
pinion is not meshing properly with the Detection of the DG set engine terminal brought to pin 3 of TB-1 goes
engine flywheel gear, or the starter itself status. For detecting the ‘on/running’ high (about +14.5V). The output from
needs servicing. If the engine fails to status of the DG set, initially the AC pin 3 of TB-1 is inverted by NAND
start within the preset attempts, audio- output from its alternator is monitored gate IC2A and extended to NAND gate
visual warning is activated. by the circuit built around MCT2E IC2B, which acts as a NOR gate (nega-
optocoupler (IC15). The value of re- tive logic). Thus when the engine is
Logic control circuit sistors R38 (33 kilo-ohms, 0.5W) and running, output pin 4 of IC2B is high.
Apart from implementing the above- R39 (390 ohms, 0.25W) is selected to Else, it is low.
mentioned logic, the logic control develop around 3.8V peak across R39 Two alternate signals have been

Electronics Projects vol. 26 45


46
Electronics projects Vol. 26
Fig. 12: The logic control circuit
used to indicate the status of the DG a differentiating network comprising
Parts List
set so that if one of the two signals Semiconductors:
capacitor C12, resistor R20 and diode
(alternator output or dynamo output) IC1 - CD4002 dual four-input NOR D6. Resistor R19 is used for pulling pin
gate
gets disconnected, the other one is IC2, IC3, IC6 - CD4011 quad two-input 1 of TB-3 high before transition.
NAND gate
available. The output of IC2B is used as IC4 - CD4044 quad NAND R-S latch The detected negative-going pulse
the sense signal for 4-input NOR gate IC5, IC9-IC13 - 7555 timer is coupled to trigger pin 2 of monos-
IC7 - CD4017 decade counter
IC2A and as a gate (enable signal) for IC8 - ULN2004A relay driver table IC9 employing CMOS timer IC
IC14 - LM239 quad differential
NAND gate IC2C. comparator 7555, which produces a 3-second wide
IC15 - MCT2E optocoupler pulse at its output pin 3. The pulse
IC CD4044B. Quad RS latch CD4044 T1 - 2N2907 pnp switching
(IC4) with 3-state outputs has been em- transistor width can be changed by varying ei-
D1-D18 - 1N4007 rectifier diode,1A
ployed as the core IC for developing the D19-D22 - 1N5408 rectifier diode, 3A ther the value of the resistor between
BR1 - 1A bridge rectifier
engine start and stop logic. Therefore, LED1-LED8 - Red/green LEDs Vcc and pin 7/6 or the capacitor be-
before we examine implementation of ZD1 - 3.9V, 1W zener diode tween pin 7/6 and ground as per the
ZD2 - 5.1V, 0.5W zener diode
the logic, let us have a look at the func- Resistors (all ¼-watt, ±5% carbon):
following relationship:
tional block diagram and truth table R1-R6, R45, Time (seconds) = 1.1R (ohms) × C
R47, R50 - 1-kilo-ohm
of CD4044B as shown in Fig. 13. We R7-R10, R15, (Farads).
R16, R18,
observe that with Eo pin tied to H (Vcc), R43, R44 - 10-kilo-ohm The trailing end of this pulse trig-
the ‘on’ output will follow: R11 - 270-kilo-ohm gers the next monostable (IC10), which
R12, R13, R17,
1. High logic state of Rn only when R20, R22, R23, is wired the same way as IC9 but pro-
R25, R28, R29,
Sn input pin is held low. Subsequently, R31, R32, R49 - 100-kilo-ohm duces a much shorter (10-12ms) low-
even if Sn input goes high, the output R14, R35 - 3.3-kilo-ohm to-high going pulse at its output. This
R19, R21, R24,
‘on’ will continue to stay high (latched). R27, R30, R37 - 4.7-kilo-ohm pulse is inverted by NAND gate IC3C
R26 - 820-kilo-ohm
2. Low state of Rn input irrespec- R33 - 3.3-mega-ohm before application to S0 input (pin 3) of
R34 - 560-kilo-ohm
tive of Sn input. This implies that Rn R36 - 120-ohm CD4044 (IC4). This results in transfer-
input can be used to reset the ‘on’ R38 - 33-kilo-ohm, 0.5W ring and latching of the high logic state
R39 - 390-ohm
output. R40, R41 - 47-kilo-ohm of R0 (pin 4) to O0 output (pin 13), pro-
R42 - 2.2-kilo-ohm
Implementation of the engine start R46 - 22-kilo-ohm vided pin 4 continues to be held high
logic. With mode-selector switch in R48 - 33-kilo-ohm even after the 3-second delay. That will
Capacitors:
‘auto’ position, and mains tripping, we C1-C4, C6, be true as long as all the inputs of IC1A
have all the four inputs of NOR gate C11, C17, remain low, fulfilling the engine-start
C23, C25 - 0.1µF ceramic disk
IC1A low, since: C5 - 100µF, 35V electrolytic logic conditions.
C7, C13, C16,
1. Pin 1 of TB-3 is low when mode C19, C22, C24 - 0.01µF ceramic disk Engine start circuit. The engine
switch is in ‘auto’ position. This is con- C8, C20 - 33µF, 25V tantalum start circuit comprises IC5 through
C9, C27 - 0.47µF polyester
nected to pin 2 of IC1A. C10, C12, C14, IC8, start control relay RL3 and high-
C15, C18, C21 - 10µF, 25V tantalum
2. When the DG set is not running, C26 - 100µF, 63V electrolytic current start relay RL7 (refer Fig. 10)
the output of NAND gate IC2B is low Miscellaneous: in the DG set, and associated compo-
(since its both inputs are high). This is ATS - Havell’s 100A ATS with nents. As soon as O0 output (pin 13)
enclosure (220V AC tripping)
connected to pin 3 of IC1A. VMRD2 - Minilec VMR D2 single-phase of IC4 is latched to high state, the same
preventer with U/V, O/V and
3. Pin 5 of TB-3 goes from high 1C/O contacts (415V AC is buffered by IC6C and IC6D NAND
auxiliary supply)
(when mains is available) to low (when Contactor - 6/9A with 3 N/O and 1 N/C gates (before application to reset pin
mains becomes unavailable). This is contacts, 230V AC coil rating 4 of IC5), one of the two inputs of
S1, S2 - Push-to-on tactile switches
connected to pin 4 of IC1A. S3 - 4-way DIP switch NAND gate IC6B as well as the base of
S4, S5 - Push-to-on switch for man-
4. The output of monostable IC3 is ual start and stop operations pnp switching transistor T1 (2N2907)
low in steady state. This is connected (BCH/Vaishno brand) via 1-kilo-ohm resistor R50.
S6, S7 - Toggle switch
to pin 5 of IC1A. BZ1 - 12V piezobuzzer CMOS timer IC5 is configured
RL1 - 12V,150- to 200-ohm, 1C/O
Thus the output of IC1A at pin 1 relay (OEN R series/PLA as an astable flip-flop controlled
MPC series or equivalent)
goes high and the same is connected RL2, RL3 - 12V, 150- to 200-ohm, 2C/O by the logic state of its reset pin 4.
to R0 input pin 4 of CD4044B (IC4) relay (OEN R series/PLA Its ‘on’ period is 12.4 seconds and
MPC series or equivalent)
via resistor R35. The resistor-capacitor RL4 - 12V, 0-30 sec. timer relay with ‘off’ period is 73 seconds. (‘On’ peri-
N/C contacts
combinations at the inputs of IC1A RL5, RL7 - 12V, 2C/O, 20-30A contact od=0.67(560×103×33×10-6) sec.≈12.4 sec.
absorb any transients. rated relay and ‘off’ period=0.67 (3.3×106×33×10-6)
RL6 - 12V, 25mm displacement
Transition detection and delay solenoid puller sec.≈73 sec.) For as long as reset pin 4 is
- Tag blocks, ferrules, spade/eye
circuit. As stated earlier, pin 5 of TB-3 ends, connectors, multicolour held high, transistor T1 remains cut-off,
cable, enclosure for logic con-
undergoes a high-to-low-to-high tran- trol circuit, etc but once the reset pin goes low, timing
sition. This transition is detected by capacitor C8 discharges rapidly to keep

Electronics Projects vol. 26 47


the timer in complete reset state. In the timer circuit. The
absence of transistor T1, the output at ORing function
its pin 3 diminishes very slowly inspite is realised using
of holding the reset pin low. NAND gates IC3A
The output from pin 3 of astable and IC3B.
IC5 is coupled to input pins 1 and 2 of The mains
high-current Darlington driver array ‘off’-to-‘on’ transi-
ULN2804 (IC8) as well as clock pin tion (occurring at
14 of decade counter CD4017 (IC7) pin 2 of TB-3) de-
through isolating diodes D4 and D5, tection and 30-sec-
respectively. ond delay for al-
During positive clock period of IC4, Fig. 13: Functional block diagram and truth table of CD4044b lowing the DG set
output pins 15 and 16 of ULN2004A to cool down (off-
(shorted for augmenting the driving causes latching of O1 output (pin 9) of load running) are accomplished by the
current capacity of IC8 output) energise IC4 to high state and, in turn, activation of edge-detection and delay mono circuit
‘start’ relay RL3 to extend +12V battery cranking indicator LED8 as well as buzzer comprising IC11 (7555).
supply to high-current relay RL7 (in the BZ1 via ULN2004A. Once the operator After 30 seconds, the trailing edge
DG set) via pin 6 of TB-1 to energise has noted the warning, he can reset the of the output of IC11 triggers IC12 to
the starter. At the same time, the high LED and the buzzer by pressing ‘Reset produce an 11ms pulse, which is passed
output of CD4017 (IC7) shifts from Q0 Buzzer’ tactile switch S2, which causes to pin 9 of NAND gate IC3C, while its
(pin 3) to Q1 (pin 2). resetting of O1 output (pin 9) to low state. pin 10 is enabled (gated) by the engine
If the DG set starts within 12.4 sec- In case you want to allow up to start/stop sensor output of IC3B. Thus
onds, it will cause pin 3 of NOR gate three cranking attempts, you need to S2 input (pin 11) of CD4044 receives a
IC1A to go high. This, in turn, will flip the third switch of DIP switch S3 to low-going pulse only if the engine is
cause output pin 1 of the IC to go low ‘on’ position. The audio-visual warn- still running. As a result, O2 output
to reset O0 output of CD4044 (IC4). ing will not activate if the engine starts of CD4044 is latched high. This high
The low output at pin 13 of IC4 will within the preset attempts. output is applied to pins 6 and 7 (tied
reset the astable flip-flop as well as de- Implementation of the engine stop together) of ULN2004A and its output
cade counter IC7 via NAND gate IC6B. logic. Quad NOR gate IC1B is used for pins 10 and 11 go low to energise timer
Also, timer capacitor C8 will quickly detecting some of the stop conditions. relay RL4 as well as ‘stop’ control relay
discharge into pin 7 of IC4 because of The first conditions of start and RL3 (via NC contacts of timer relay).
the conduction of transistor T1. stop logic are identical, i.e., the mode- The timer is set for 12 to 15 sec-
In case the engine doesn’t start selector switch in the ATS cubical must onds. This time duration is appropriate
within the first 12.4 seconds, reset pin be in ‘auto’ position. Therefore pin 2 of for bringing the engine to a dead stop.
4 of astable flip-flop IC5 stays high, IC1A is shorted to pin 10 of IC1B. Energisation of RL3 extends ground
while timing capacitor C8 starts slowly The second condition is that the for activation of high-current ‘stop’
discharging through 3.3-mega-ohm DG set is already running. When the relay RL5 in the DG set, which, in turn,
resistor R33 into pin 7 of IC4. DG set is running, pin 3 of TB-1 is at activates ‘stop’ solenoid RL6 in the DG
After 73 seconds, output pin 3 of around +14.5 V and hence the output set for the set period.
IC4 again goes high for another 12.4 of NAND IC2A at its pin 3 goes low, As mentioned earlier, the engine
seconds, provided the DIP switch part which is connected to pin 9 of quad must come to a dead stop before releas-
connected to pin 4 (Q2) of IC7 is not NOR gate IC1B. ing the engine-stop solenoid. For this,
closed. If the switch is closed, the high The third condition is the avail- we have to ensure that O2 output at pin
output at pin 4 of IC7, after passing ability of healthy mains and its transi- 10 of IC4 (CD4044) remains latched (to
through the pulse stretcher network tion from ‘not-available’ to ‘available’ ‘high’ state) for the preset delay of the
comprising resistor R16 and capacitor status. When mains becomes available, timer. Therefore the low output from
C9 and inversion by NAND gate IC6A, pin 2 of TB-3 goes from ‘high’ to ‘low’ pins 10 and 11 of ULN2004 (via N/C
will cause pin 4 (R0 input) of IC4 to (mains ‘on’ LED4 also lights up). This contacts of timer relay and diode D11)
reset its output pin 13 and thus the low output is extended to pin 11 of is applied to pin 6 of NAND gate IC3B.
astable flip-flop (IC5) as well as decade IC1B via R18. As a result, the output of IC3B or R2
counter IC7 will also be reset. Once these three conditions are input (pin 12) of CD4044 goes high for
The negative pulse at the output of satisfied, the output of IC1B goes the preset period of timer relay RL4.
NAND IC3A is also directly connected to high. This high output is applied to After the set period is over, the N/C
S1 input (pin 7) of IC4, while its R1 (pin 6) R2 input (pin 12) of CD4044 (IC4) after contacts of the timer relay open up and
is pulled high through resistor R15. This ORing it with another input from the Vcc (via the coil of relay RL3) is extended

48 Electronics projects Vol. 26


Fig. 14: Single-side, actual-size PCB for the logic control circuit

to pin 6 of IC3B, while pin 5 also goes voltage developed across zener ZD2. the engine picks up speed.
high since, with the DG set in ‘off’ condi- The output of the comparator is high as Start-control relay energises via the
tion, pin 9 of quad NOR gate goes high long as the battery voltage exceeds 10V. de-energised contacts of stop-control
and its output pin 13 goes low. The same When the battery voltage falls be- relay RL3. Similarly, energisation of
output after inversion by NAND gate low 10V, the comparator output goes stop-control relay RL3 is possible via
IC3A is applied to pin 5 of IC3B. As a low to light LED7. Switch S6 is nor- the de-energised contacts of relay RL2.
result, the output of IC3B goes low to mally kept closed. As a result, when This provides a safety against any
reset O2 output of CD4044 and ‘ engine the battery voltage goes below 10V, erroneous pressing of a button while
stop’ control signal comes to an end. the output of NAND gate IC3D goes the automatic mode is in operation,
Battery-low warning circuit. When high to sound piezobuzzer BZ1 via and avoids simultaneous operation of
the battery voltage falls below 10V, the ULN2004A and diode D15, which acts ‘start’ and ‘stop’ solenoids.
auto start/stop circuit may not func- as an OR gate here. (In case you need The rest of ‘start’/‘stop’ opera-
tion satisfactorily. It is a sure indica- to activate a high-power siren, in place tion is similar to that of the automatic
tion of one or more of the following of the buzzer, you can use a 12V relay operation, with the exception of timer
conditions: to connect supply to the siren.) Once relay RL4, which is bypassed during
1. Charging circuit is non-functional. the operator has taken cognizance the manual stop operation. (Caution:
2. The battery is not holding charge of the warning, he may turn off the Don’t release ‘Stop’ pushbutton until
due to sulphation or the electrolyte buzzer using ‘buzzer defeat’ switch S6. the engine comes to a dead stop. Else,
needs to be topped up. Manual start/stop operation. Push- the engine will tend to restart because
3. Dynamo pulley belt is slipping. button switches S4 and S5 in conjunction of its flywheel inertia.)
4. The battery has some load when with relays RL2 (start control) and RL3 ‘Reset start’ tactile switch S1 has
the engine/dynamo is not ‘on.’ (stop control) are used to manually con- been provided for resetting the start
The warning circuit comprises trol the DG set when the mode switch operation prematurely during circuit
comparator IC14A (LM239), which in the ATS is kept in ‘manual’ mode. testing. For detecting the manual-to-
compares a 50 per cent sample of the For starting the DG set, ‘start’ button auto mode transition at the ATS, tran-
battery voltage against the 5V reference is kept pressed and released as soon as sition-detection mono IC13 has been

Electronics Projects vol. 26 49


Fig. 15: Component layout for the PCB

used, which provides a reset pulse for remaining external control signals, a via TB-2 are concerned, we are merely
start and stop latches of CD4044 (IC4). 0.25-sq.mm flexible wiring will suffice. carrying negative DC supply via its
Cartridge fuse holder for fuse F1 and pin 2 for return via other pins of TB-2.
PCB and assembly toggle switch S7 may also be mounted Hence there is no danger unless you
A single-side, actual-size PCB for the on the rear panel, close to TB1. mix up the wires with 415/230 AC
logic circuit (Fig. 12) is shown in Fig. Mount all the relays (RL1 through voltages present in the ATS cubicle.
14 and its component layout in Fig. RL4) horizontally on the chassis of the
15. The front panel of the proposed panel. DC supply (±12V) to the relay Things to remember
enclosure for the logic control PCB contacts is provided directly from TB-1 1. Many a times, the power supply
including all the components (to be terminals using 0.5mm2 flexible wires. (mains 3-phase) maintenance person-
mounted externally on its chassis) is Mark all the external wires using fer- nel inadvertently interchange the
shown in Fig. 16. rules as shown in the interconnection phases during reconnection after ser-
All the status LEDs, buzzer and diagram. vicing. The resulting phase reversal
switches shown in Fig. 12 (except can have very serious repercussions in
tactile switch S1) are mounted on the Testing organisations employing 3-phase mo-
front panel. Suitable Bergstick connec- Test each part of the circuit elaborately tor operated machinery due to reverse
tors (male/females) should be used by making use of the status-indication rotation of the motors.
for extending the connections for the lamps and logic explained for various The Minilec phase-reversal preven-
LEDs, switches and the buzzer. For parts of the circuit without extending tion relay (VMR D2) installed in the ATS
the purpose, SIP connectors have been connections from TB-1 terminals 4, 5 cubicle senses this reversal and trips to
provided on the PCB. and 6 to the DG set. Use 12V lamps (of prevent the control voltage (red phase)
All the cable entries to various TBs 2 to 3 watts) or even LEDs connected from exercising automatic changeover
should be made from the rear. Use a to these terminals for testing the circuit control. Tripping is indicated by an LED
1-sq.mm flexible conductor wire for operation before connecting them to on the VMR D2 relay.
supplying the DC voltage from the DG the corresponding terminals of the DG Tripping can also be caused by sin-
set to the logic control panel. For the set. As far as connections to the ATS gle-phasing or under-/over-voltage of

50 Electronics projects Vol. 26


the 3-phase supply. Hence check that all DG set instrument panel when the
the three phase voltages are within lim- engine is running and the keyswitch
its. Once you are satisfied that 3-phase is in ‘on’ position. If the filament
voltages are alright, the most probable of the bulb in the charging path is
cause is loss of phase sequence. If you open-circuited, then also the battery
have a phase-sequence indication meter, charging will not take place.
you can verify the same. 3. Use good-quality contactors,
To correct the phase sequence, first relays and timers from companies like
isolate mains and interchange any two L&T, BCH, Siemens, Minilec, Havell,
of its phase wires going to the ATS— English Electric, PLA, OEN or Omron.
preferably, Y- and B-phase wires since Fig. 16: Front panel of the proposed enclosure
the red-phase wire is used for control for assembling the logic control pcb Conclusions
in the ATS. In case you are not using Users may modify the circuits ap-
any phase-sensitive load, simply inter- DG set, ensure that all the phase propriately for meeting the specific
change the y and B phase wires on the wires are connected correctly. Else, requirements of their standby supply
Minilec relay itself, ensuring (in both changeover to the DG set supply sources. It is also possible to reduce
cases) that the trip LED goes off when will not take place for the reasons the AMF control panel circuitry to
all the three phases of the supply are explained above. Also make sure that just the use of peripheral components
available. This will enable automatic the dynamo terminals are properly by employing a microcontroller to
changeover when mains is available. plugged and battery charging is be- implement the basic logic. So good
2. After any maintenance of the ing indicated by the ammeter on the luck!

Electronics Projects vol. 26 51


PC-based Scrolling
Message Display
 SURESH KUMAR Parts List lel port are connected to the input pins
of the first flip-flop (IC2). The output

C
Semiconductors:
ontrolling electronic devices IC1 - 7805C 5V regulator of IC2 is fed to the next flip-flop IC in-
from a PC is fun. Here is a IC2-IC8 - 74174 hex D-type flip-flop put as well as LED. Data line D6 is fed
D1-D4 - 1N4007 rectifier diode
scrolling message display that to IC8, while data line D7 is connected
LED1-LED42 - Red LED
makes use of the PC’s parallel port. to the clock inputs of IC2 through IC8.
Resistors (all ¼-watt, ±5% carbon):
The message typed from the key- Clock pins of all the flip-flop ICs are
R1- R42 - 150-ohm
board of the PC is displayed on the connected together. Master reset pin 1
Capacitors:
light-emitting diodes arranged as 5×7 of all the flip-flops is connected to Vcc.
C1 - 470µF, 16V electrolytic
dot-matrix display in moving message Miscellaneous: Pins 18 through 25 of the parallel port
format. X1 - 230V AC primary to 7.5V, are grounded. As data present on lines
LED-based scrolling message 1A secondary transformer D0 through D6 shifts from the first
displays are increasingly being used stage to the next stage, and so on, the
at railway stations, public places, three ports, namely, data port, status message appears as scrolling on the
colleges, universities, hospitals, port and control port. Here, only data dot-matrix LED display.
general stores, etc for disseminating port is used for this scrolling message The present circuit supports a
information. However, most displays display. display made of 42 LEDs comprising
lack in storage capacity and cannot Pins 2 through 9 form the 8-bit seven rows and six columns. Up to 30
display a large number of characters data output port. This is purely a such units can be added with no change
at a time. write-only port, which means it can in the circuit. However, to add these
This PC-based LED scrolling only output data. The base address of units, you need to amplify the clock
message display has the following the first parallel port (LPT1) is ‘378H’ pulse output. Note that each character
features: or ‘888’ (decimal). is displayed in a matrix of 5 columns
1. The message to be displayed is Parallel-input parallel-output and 7 rows (explained later), hence the
stored in a file and the message length (PIPO) registers are used to shift the sixth-column LEDs form part of the next
to be displayed is limited only by free signal from right to left. The clock character (column 1).
memory space on the hard disk of the pulse and code signal are generated Fig. 2 shows the power sup-
computer. by the computer program and output ply circuit. The AC mains is
2. The number of characters dis- from the parallel port (base address stepped down by transformer X1
played at a time can be as high as 30. 0×378). Theoretically, we can add infi- to deliver a secondary output of
3. The message stored in the file nite number of PIPO registers but the 7.5V AC at 1A. The transformer
can be changed using any text editor maximum number of registers is actu- output is rectified by a full-wave
including Notepad. ally limited to the current triggering bridge rectifier comprising diodes
4. The running speed of the mes- value of the clock pulse. To add a large D1 through D4, filtered by capacitor
sage displayed can be increased or number of PIPO registers, amplify the C1, then regulated by IC 7805C (IC1) to
decreased by pressing a few keys. clock pulse prior to connecting it to the provide regulated 5V DC to the circuit.
Here, the circuit is designed for PIPO ICs. An actual-size, single-side PCB for
displaying English characters on a 35 the circuits in Figs 1 and 2 is shown
(5×7) LED dot-matrix display. Circuit description in Fig. 5 and its component layout in
The PC’s parallel port (LPT port) Fig. 1 shows the circuit for the scroll- Fig. 6.
is used to output the display code and ing message display. IC 74174 has been EFY note. Commercially 7×5 dot-
the clock signal for the scrolling mes- used as PIPO register, which compris- matrix displays with discrete LEDs
sage display. es high-speed, hex D-type flip-flops. It may not be easily available in the mar-
The parallel port is terminated into is used as a 6-bit edge-triggered stor- ket, therefore a perforated board with
a 25-pin D-type female connector at age register. The data on the inputs of holes for the LED leads may be used.
the back of the PC. IBM PCs usually the flip-flop is transferred for storage The layout of such a board is shown in
come with one or two LPT ports. Each during high-to-low transition of clock. Fig. 7. The holes are used for passing
parallel port is actually made up of Data lines D0 through D5 of the paral- the LED leads.

52 Electronics projects Vol. 26


The software
The software for the scrolling
message display has been de-
veloped in ‘C’ language and
compiled in ‘Turbo C.’ When
you run the scroll.exe file,
the program tries to open the
message.txt file. If this file is
not present in the same direc-
tory, it creates one with text
“Welcome! You are watching
running led display...” and
starts sending this message to
the circuit via the parallel port
for display on 5×7 dot-matrix
pattern.
To increase the running
speed of the message, press
‘I’ key, and to decrease the
speed, press ‘D’ key. Press ‘R’
key for displaying the message
from the beginning. When the
program reaches the end of
the message, it starts from the
beginning again. To change the
text being displayed, exit the
program by pressing ‘Esc’ and
edit the message.txt file using
Notepad. After making changes
to the message.txt file, save it
and execute the scroll.exe file.
The program makes use of
the outportb() function, which
works perfectly only on Win-
dows 95/98. However, the pro-
gram may not work with the
latest Window versions such as
Windows 2000/XP .
When you try to save
changes in the message.txt file,
Fig. 1: Circuit of LED-based scrolling message display

the window shows an error


saying “Can’t save message.txt.
It is being used by some other
application.” This is because
the scroll.exe file is running.
So exit the program by press-
ing ‘Esc’ key, then save your
changes made to the message.
txt file and run the scroll.exe
file. Now you can view your
changes in the message being
displayed.
The program does not show
special characters like ‘/,’ ‘\,’

Electronics Projects vol. 26 53


‘~,’ ‘@,’ ‘#,’ ‘$,’ ‘%,’ ‘+’ and ‘_.’
‘^,’ ‘(,’ ‘),’ ‘{,’ ‘},’ and Other special characters can be
‘;.’ It has been de- added as follows: Suppose you want
veloped for display- to display character ‘A.’ Draw ‘A’
ing alphabets (‘A’ on the 5×7 LED display as shown in
through ‘Z’), digits Fig. 3. First, ‘7CH’ data is available at
(‘0’ through ‘9’) and the input of IC2 and the first flip-flop of
some special charac- IC8. When a clock pulse is received, this
Fig. 2: Power supply
ters like ‘.,’ ‘,,’‘!,’ ‘–,’ data (7CH) is
output by IC2
and the first
flip-flop of IC8
and new data
‘12H’ arrives
at the input
pin of IC2 and
the first flip-
flop of IC8.
The output
Fig. 7: Perforated board for
data of IC2
Fig. 3: Design of character ‘A’ Fig. 4: Design of character ‘<’ 5×7 LEDs and the first

Fig. 5: Actual-size, single-side PCB for the LED-based scrolling message display including power supply

Fig. 6: Component layout for the PCB

54 Electronics projects Vol. 26


flip-flop of IC8 becomes the input for Now let’s assume that you want to ;str1[3]=0x14;str1[4]=0x8;
IC3 and the second flip-flop of IC8. display ‘<.’ For this, first draw this symbol break;
When the next clock pulse is received, on the 5×7 matrix as shown in Fig. 4. As- Save the file and compile the pro-
‘7CH’ data becomes available at the suming glowing LED as ‘1,’ convert the gram again. On executing the program,
output of IC3 and output of second binary column sequence into hexadeci- you can watch ‘<’ being displayed on
flip-flop of IC8, ‘12H’ is available at the mal for all the five columns as shown in the message display.
output of IC2 and the first flip-flop of the figure. Finally, add the following lines Other special characters can be
IC8 and new data ‘11H’ is available at in the software program where the com- added in the same way.
the input of IC2 and the first flip-flop ment “Add your codes here” appears: Download source code: http://
of IC8. This process continues until the Case ‘<’ : www.efymag.com/admin/issuepdf/
message completes. str1[0]=0x00;str1[1]=0x41;str1[2]=0x22 PC%20Scroll%20Display.zip

SCroll.c
/************************************ DELAY-=1; case ‘g’:
SCROLLING MESSAGE DISPLAY } case ‘G’:
DEVELOPED BY : SURESH KUMAR if(DELAY<0) str1[0]=0x3A;str1[1]=0x49;s
FINAL YEAR, IITT COLLEGE OF ENGINEER- { tr1[2]=0x41; str1[3]=0x41;str1[4]=0x3E;
ING, PUNJAB DELAY=0; break;
THANX TO ALL TEACHERS AND MY PAR- } case ‘h’:
ENTS printf(“\nSCROLLING case ‘H’:
**********************************/ MESSAGE DISPLAY : Speed Increased”); str1[0]=0x7F;str1[1]=0x08;st
#include<stdio.h> break; r1[2]=0x08; str1[3]=0x08;str1[4]=0x7F;
#include<dos.h> case ‘d’: break;
#include<conio.h> case ‘D’: case ‘i’:
#include<process.h> DELAY+=10; case ‘I’:
unsigned char str1[5],str2[13],str[5]; printf(“\nSCROLLING str1[0]=0x41;str1[1]=0x41;st
int DELAY=100; MESSAGE DISPLAY : Speed Decreased”); r1[2]=0x7F; str1[3]=0x41;str1[4]=0x41;
void setcode(); break; break;
void sendcode(); case ‘r’: case ‘j’:
void getcode(char); case ‘R’: case ‘J’:
void main() rewind(fp); str1[0]=0x7F;str1[1]=0x41;st
{ printf(“\nSCROLLING r1[2]=0x41; str1[3]=0x41;str1[4]=0x21;
FILE *fp; MESSAGE DISPLAY : Started from Begining”); break;
char line[150],ch; break; case ‘k’:
clrscr(); case 27: case ‘K’:
fp=fopen(“message.txt”,”r”); clrscr(); str1[0]=0x41;str1[1]=0x22;st
if(fp==NULL) printf(“\nSCROLLING r1[2]=0x14; str1[3]=0x08;str1[4]=0x7F;
{ MESSAGE DISPLAY : Exiting “); break;
fp=fopen(“message. fclose(fp); case ‘l’:
txt”,”w”); delay(1000); case ‘L’:
if(fp==NULL) printf(“. “); str1[0]=0x40;str1[1]=0x40;st
{ delay(200); r1[2]=0x40; str1[3]=0x40;str1[4]=0x7F;
printf(“\n\ printf(“. “); break;
nCAN’T CREATE MESSAGE.TXT CREATE A FILE delay(200); case ‘m’:
UNDER NAME MESSAGE.TXT YOURSELF”); printf(“. “); case ‘M’:
exit(0); delay(200); str1[0]=0x7F;str1[1]=0x02;st
} printf(“. “); r1[2]=0x04; str1[3]=0x02;str1[4]=0x7F;
fputs(“ Welcome! You are delay(200); break;
watching running led display... “,fp); exit(0); case ‘n’:
fclose(fp); } case ‘N’:
fp=fopen(“message. goto startagain; str1[0]=0x7F;str1[1]=0x08;st
txt”,”r”); } r1[2]=0x04; str1[3]=0x02;str1[4]=0x7F;
if(fp==NULL) void getcode(char ch) break;
{ { case ‘o’:
printf(“\ switch(ch) case ‘O’:
nCAN’T FIND OR OPEN \”message.txt\””); { str1[0]=0x3E;str1[1]=0x41;st
exit(0); case ‘a’: r1[2]=0x41; str1[3]=0x41;str1[4]=0x3E;
} case ‘A’: break;
} str1[0]=0x7c;str1[1]=0x12; st case ‘p’:
clrscr(); r1[2]=0x11;str1[3]=0x12;str1[4]=0x7c; case ‘P’:
startagain: break; str1[0]=0x06;str1[1]=0x09; st
while(!kbhit()) case ‘b’: r1[2]=0x09;str1[3]=0x09;str1[4]=0x7F;
{ case ‘B’: break;
ch=fgetc(fp); str1[0]=0x36;str1[1]=0x49; st case ‘q’:
if(ch==EOF) r1[2]=0x49;str1[3]=0x49;str1[4]=0x7F; case ‘Q’:
{ break; str1[0]=0x3E;str1[1]=0x61; st
rewind(fp); case ‘c’: r1[2]=0x51;str1[3]=0x41;str1[4]=0x3E;
continue; case ‘C’: break;
} str1[0]=0x22;str1[1]=0x41; st case ‘r’:
printf(“\nSCROLLING r1[2]=0x41;str1[3]=0x41;str1[4]=0x3C; case ‘R’:
MESSAGE DISPLAY : Sending \’%c\’”,ch); break; str1[0]=0x46;str1[1]=0x29; st
getcode(ch); case ‘d’: r1[2]=0x19;str1[3]=0x09;str1[4]=0x7F;
setcode(); case ‘D’: break;
sendcode(); str1[0]=0x1C;str1[1]=0x22;s case ‘s’:
} tr1[2]=0x41; str1[3]=0x41;str1[4]=0x7F; case ‘S’:
ch=getch(); break; str1[0]=0x32;str1[1]=0x49; st
switch(ch) case ‘e’: r1[2]=0x49;str1[3]=0x49;str1[4]=0x26;
{ case ‘E’: break;
case ‘i’: str1[0]=0x41;str1[1]=0x41;st case ‘t’:
case ‘I’: r1[2]=0x49; str1[3]=0x49;str1[4]=0x7F; case ‘T’:
if(DELAY>10) break; str1[0]=0x01;str1[1]=0x01; st
{ case ‘f’: r1[2]=0x7F;str1[3]=0x01;str1[4]=0x01;
DELAY-=5; case ‘F’: break;
} str1[0]=0x01;str1[1]=0x01;st case ‘u’:
else r1[2]=0x09; str1[3]=0x09;str1[4]=0x7F; case ‘U’:
{ break; str1[0]=0x3F;str1[1]=0x40; st

Electronics Projects vol. 26 55


r1[2]=0x40;str1[3]=0x40;str1[4]=0x3F; str1[0]=0x31;str1[1]=0x4B; st str1[0]=0x08;str1[1]=0x08; st
break; r1[2]=0x45;str1[3]=0x49;str1[4]=0x21; r1[2]=0x08;str1[3]=0x08;str1[4]=0x08;
case ‘v’: break; break;
case ‘V’: case ‘4’: case ‘+’:
str1[0]=0x1F;str1[1]=0x20; str1[0]=0x10;str1[1]=0x7F; st str1[0]=0x08;str1[1]=0x08; st
str1[2]=0x40;str1[3]=0x20;str1[4]=0x1F; r1[2]=0x12;str1[3]=0x14;str1[4]=0x18; r1[2]=0x3E;str1[3]=0x08;str1[4]=0x08;
break; break; break;
case ‘w’: case ‘5’: case ‘_’:
case ‘W’: str1[0]=0x31;str1[1]=0x49; st str1[0]=0x40;str1[1]=0x40;st
str1[0]=0x7F;str1[1]=0x20; r1[2]=0x49;str1[3]=0x49;str1[4]=0x27; r1[2]=0x40; str1[3]=0x40;str1[4]=0x40;
str1[2]=0x10;str1[3]=0x20;str1[4]=0x7F; break; break;
break; case ‘6’: ////// ADD YOUR CODES HERE////////
case ‘x’: str1[0]=0x32;str1[1]=0x49; st default:
case ‘X’: r1[2]=0x49;str1[3]=0x51;str1[4]=0x3A; str1[0]=0x0;str1[1]=0x0;str1
str1[0]=0x63;str1[1]=0x14; break; [2]=0x0; str1[3]=0x0;str1[4]=0x0;
str1[2]=0x08;str1[3]=0x14;str1[4]=0x63; case ‘7’: break;
break; str1[0]=0x07;str1[1]=0x79; st }
case ‘y’: r1[2]=0x01;str1[3]=0x01;str1[4]=0x01; }
case ‘Y’: break; void setcode()
str1[0]=0x03;str1[1]=0x04; case ‘8’: {
str1[2]=0x78;str1[3]=0x04;str1[4]=0x03; str1[0]=0x36;str1[1]=0x49; st int i,k;
break; r1[2]=0x49;str1[3]=0x49;str1[4]=0x36; for(i=0,k=0;i<10;i+=2,k++)
case ‘z’: break; {
case ‘Z’: case ‘9’: str2[i]=str1[k];
str1[0]=0x03;str1[1]=0x04; str1[0]=0x3E;str1[1]=0x49; st str2[i+1]=str1[k]+128;
str1[2]=0x08;str1[3]=0x11;str1[4]=0x61; r1[2]=0x49;str1[3]=0x49;str1[4]=0x26; }
break; break; str2[i]=0;
case ‘0’: case ‘.’: str2[i+1]=128;
str1[0]=0x1C;str1[1]=0x22 str1[0]=0x60;str1[1]=0x60; st }
;str1[2]=0x41; str1[3]=0x22;str1[4]=0x1C; r1[2]=0x00;str1[3]=0x00;str1[4]=0x00; void sendcode()
break; break; {
case ‘1’: case ‘ ‘: int i;
str1[0]=0x40;str1[1]=0x40; str1[0]=0x00;str1[1]=0x00; st for(i=0;i<12;i++)
str1[2]=0x7F;str1[3]=0x42;str1[4]=0x44; r1[2]=0x00;str1[3]=0x00;str1[4]=0x00; {
break; break; outportb(0x0378,str2[i]);
case ‘2’: case ‘!’: delay(DELAY);
str1[0]=0x46;str1[1]=0x49; str1[0]=0x67;str1[1]=0x7F; st }
str1[2]=0x51;str1[3]=0x61;str1[4]=0x42; r1[2]=0x00;str1[3]=0x00;str1[4]=0x00; }
break; break; 
case ‘3’: case ‘-’:

56 Electronics projects Vol. 26


Low-cost Energy Meter
Using ADE7757
 sunil kumar The meter is designed based on Parts List
Analog Devices’ application notes. Its

E
Semiconductors:
lectromechanical energy meters salient features are: IC1 - ADE7757 metering IC
have been the standard for me- 1. It can read up to 999,999 units IC2, IC5 - 7805 5V regulator
tering the electricity since bill- (kWh) with a resolution of 0.01 unit. IC3, IC4 - MCT2E optocoupler
IC6, IC7 - MM74926 7-segment driver
ing began. But these are now being 2. It is designed for nominal 230V T1-T8 - BC548 npn transistor
gradually replaced by digital signal AC, 45-65 Hz and maximum line cur- D1-D3 - 1N4007 rectifier diode
processor (DSP)-based energy meters, rent of 30 amps. (The metering IC can ZD1 - 15V, 1W zener diode
BR1 - W04M bridge rectifier
or kilowatt-hour (kWh) meters. be used with a maximum current of
DIS1- DIS8 - LTS543 common cathode,
More accurate energy measure- 120 amps.) 7-segment display
ment and additional features are in 3. The dynamic range is 400 (i.e., 75 LED1 - Red LED
fact accelerating the adoption of DSP- mA to 30A). Resistors (all ¼-watt, ±5% carbon, unless
based meters. Their additional features 4. The meter count is 100 impulses/ mentioned otherwise):
include power quality monitoring, re- kWh, i.e., 100 impulses will be required R1, R3, R7,
R8 - 500-ohm
cording of current/voltage peaks and to register one unit. R2 - 6.2-kilo-ohm
voltage sags, registering of digitised 5. The accuracy level is better R4 - 470-ohm
waveforms for analysis, and monitor- than Class 2 defined in international R5, R6 - 680-ohm
ing of active and reactive power and standard IEC1036 (1996-09). The maxi- R9 - 350-micro-ohm (shunt)
R10 - 1.8-mega-ohm
power factor information. mum error limit for various current R11 - 2.2-kilo-ohm
Some metering chips have a se- values as per this standard is shown R13 - 470-ohm, 1W
rial port interface (SPI) that can be in Table I. R14 - 1-kilo-ohm
used for establishing communication R12, R15- R28 - 220-ohm
with a microcontroller-based mobile IC ADE7757 VR1 - 470-kilo-ohm trimpot
Capacitors:
gadget to control the functionality of Fig. 1 shows the functional block
C1, C3, C7,
the metering chip, perform calibration diagram of metering IC ADE7757. It is C8-C10 - 0.1µF ceramic disk
and transfer the recorded data. Analog available in 16-lead SOIC narrow-body C2, C6 - 10µF, 25V electrolytic
Devices offers an extensive range of package. In our PCB layout, it is to be C4, C5, C11,
C12 - 0.068µF ceramic disk
metering ICs to serve various needs. soldered on the conductor side of the C13 - 0.47µF, 630V polyester
Here’s an energy meter using Ana- PCB. The IC has an on-chip oscillator, C14 - 470µF, 35V electrolytic
log Devices’ ADE7757 chip for single- so it requires no external crystal or C15 - 1000µF, 16V electrolytic
phase, 2-wire (phase and neutral) sys- resonator, thus reducing the overall Miscellaneous:
L1, L2 - Ferrite bead inductor
tems used in households. IC ADE7757 cost of building a watt-hour meter. It Battery - 4.5V rechargeable battery
is a low-cost, single-chip solution for operates off a 5V power supply. X1 - 230V AC primary to 7.5V,
electrical energy measurement. In operation, the chip directly 500mA secondary trans-
interfaces with former
a shunt resis-
tor (used as the ‘current channel’) is used for current
current sensor) sensing and channel V2 (also called
and AC ana- ‘voltage channel’) is used for voltage
logue voltage sensing.
sensing input. The differential output from the
It has two ana- current-sensing resistor is connected
logue input between V1P and V1N inputs, while the
channels des- differential output signal proportional
ignated as V1 to the AC line voltage, obtained through
and V2, respec- a resistor divider, is connected between
tively. Channel pins V2P and V2N.
Fig. 1: Functional block diagram of IC ADE7757 V1 (also called IC ADE7757 also has a reference

Electronics Projects vol. 26 57


circuit and a fixed power signal is achieved by a direct
DSP function for cal- multiplication of the current and volt-
culation of the real age signals. In order to extract the real
power. A highly sta- power component (referred to as the
ble oscillator integrat- DC component), the instantaneous
ed into the chip pro- power signal is low-pass filtered. This
vides the necessary scheme correctly calculates the real
clock for the chip. IC power for sinusoidal current and volt-
ADE7757 supplies the age waveforms at all power factors. All
average real-power the signal processing is carried out in
information on the F1 the digital domain for superior stability
and F2 low-frequency over temperature and time.
outputs. These out- Fig. 2 shows the block diagram for
Fig. 2: Block diagram for signal processing along with the waveforms at puts may be used to signal processing along with the wave-
the output of the multiplier and the low-pass filter (LPF) directly drive a step- forms at the output of the multiplier
per motor-based elec- and after the low-pass filter (LPF). It is
tromechanical counter or any observed that this method of extract-
other suitable counter. ing the real power information holds
IC ADE7757 also provides good even when the current is not in
a high-frequency output at phase with the voltage. The real power
the calibration frequency component (DC component) of the
(CF) pin for a selected me- instantaneous power for sinusoidal
ter constant (here, it is 3200 voltage/current waveforms with a
Fig. 3: Typical mains current sampling
impulses/kWh). This high- power factor of 0.5 (current lagging the
frequency output provides voltage by 60°) is:
instantaneous real-power
V×I
information, which is used × cos 60°
2
to speed up the calibration
process. It also provides a The real power calculation holds
means for quickly verifying good even for non-sinusoidal current
the meter’s functionality and and voltage waveforms.
accuracy in a production en- Mains current sampling (channel
vironment. V1). The voltage output from the cur-
Fig. 4: Typical mains voltage sampling
rent sensor (proportional to the load
Theory of operation current) is connected to channel V1
Table I The two analogue-to-digital of IC ADE7757, which is a fully dif-
Accuracy Requirements converters (ADCs) used in ferential voltage input. The V1P input
the chip digitise the output of is positive with respect to V1N. The
Percentage error limits3
current and voltage sensors. maximum peak differential signal on
Current value PF
1 2
Class 1 Class 2
The ADCs are 16-bit, sigma- channel V1 should be less than ±30
0.05 lb < l < 0.1 lb 1 ±1.5% ±2.5%
delta type with an oversampling mV (i.e., 21mV rms for a pure sinusoi-
0.1 lb < l < lMAX 1 ±1.0% ±2.0%
rate of 450 kHz. These work dal signal) with reference to analogue
0.1 lb < l < 0.2 lb 0.5 lag ±1.5% ±2.5%
with oversampling so that the ground (AGND) for the specified op-
0.8 lead ±1.5%
bandwidth of the input signal is eration. Typical sampling connections
0.2 lb < l < lMAX 0.5 lag ±1.0% ±2.0%
much less than fs/2, where ‘fs’ are shown in Fig. 3.
0.8 lead ±1.0%
Notes. 1. The current ranges for the specified accuracy are expressed in
is the sampling frequency. In its Mains voltage sampling (channel
terms of the basic current (Ib), which is defined as the value of the current most basic form, the sigma-delta V2). The output of the line voltage
in accordance with which the relevant performance of a direct connec-
tion meter is fixed. IMAX is the maximum current at which the accuracy is converter contains a one-bit sensor is connected to IC ADE7757
maintained. At these frequencies we have taken the value of basic current
Ib as 5 amp.
ADC and DAC. It produces a at this analogue input. Channel V2,
2. Power factor (PF) gives the phase relationship between the fundamental higher-resolution digital word like channel V1, is a fully differential-
voltage (45 to 65 Hz) and current waveforms. Here, it can be simply defined
as PF = cos f, where f is the phase angle between the pure sinusoidal output by averaging several voltage input channel with maximum
current and the voltage. one-bit samples. peak differential signal of ±165 mV ref-
3. The percentage error =
(Energy registered by the meter–True energy)×100
The real power is derived erenced to analogue ground (AGND).
True energy from the instantaneous pow- Typical connections for mains voltage
er signal. The instantaneous sampling channel V2 are shown in Fig.

58 Electronics projects Vol. 26


4. It is quite convenient to adjust the in the applica-
ratios of Ra and VR for adjusting the tion note, i.e., 350
gain of the meter. µΩ. At 30 amps,
Phase matching between channels. its power dis-
It is important that the relative phase sipation would
difference between voltage and cur- be 30 2×350×10 –6
rent waveforms at the inputs of V1 watts = 315 mW.
and V2 channels is not disturbed since This is reasonably
any phase mismatch between channels low.
will translate into significant measure- The chosen
Fig. 5: Output signal timing diagram
ment error at low power factors. IC shunt must:
ADE7757 is internally phase-matched 1. Provide the
over the frequency range of 40 Hz to Table II necessary dynamic range (400 to 500).
1 kHz between the two channels, F1-4 Frequency Selection 2. Dissipate less power.
which ensures that the relative phase S1 S0 F 1-4 (Hz) 3. Be small-size, so that it can be
relations of the two channels are main- installed within the meter case to avoid
0 0 0.85
tained throughout the useful range of tampering.
0 1 1.7
frequencies. 4. Have low temperature coeffi-
1 0 3.4
Power supply monitor. The on-chip cient. (Manganin has low temperature
1 1 6.8
power supply monitor of IC ADE7757 coefficient.)
continuously monitors the power sup- For experimental purposes, we
ply (VDD). If the supply is less than Table III used 24mm long 18SWG copper wire,
4V, IC ADE7757 is reset. This ensures Output Frequency on CF Pin which gave a shunt resistance of
proper device operation at power-up SCF S1 S0 CF Signals around 350 µΩ.
and power-down. The power supply (Hz)
monitor has built-in hysteresis and Design example
1 0 0 128×F1, F2
filtering that provides a high degree 0 0 0 64×F1, F2 For designing a meter with 100 pulses/
of immunity to false triggering due to 1 0 1 64×F1, F2 kWh count, proceed as follows:
noisy supply. 0 0 1 32×F1, F2 Step 1. Select the shunt as dis-
Transfer function. The transfer 1 1 0 32×F1, F2 cussed above. The shunt selected is 350
function refers to the relation between 0 1 0 16×F1, F2 µΩ. The sense voltage V1rms at constant
the true power into the load and its 1 1 1 16×F1, F2 basic current (Ib) of 5 amps would be
representation in terms of the equiva- 0 1 1 2048×F1, F2 1.75 mV.
lent frequency at F1 and F2 output Step 2. With nominal mains volt-
points. The transfer function of IC Table IV age of 230V AC rms and constant
ADE7757 is quite linear, and as such, Approximate Timings for the basic current (Ib) of 5 amps, the energy
a one-point calibration (at Ib) at unity consumed in one hour is 230×5 = 1150
Outputs (Fig. 5)
power factor is all that is needed to watt-hour or 1.15 kWh.
calibrate the meter. If precautions are Parameter Time duration Units Since we have selected 100 pulses/
taken at the design stage, no calibra- t1 550 ms kWh, for consumption of 1.15 kWh,
tion is necessary at power factors as t2 1.428 (min.) sec the output should be 115 pulses. The
low as 0.5 (i.e., phase difference of 60°). t3 0.714 (min.) sec equivalent frequency (cycles per sec.)
The output frequency or pulse rate t4 180 ms is 115/3600 = 0.0319443 Hz.
is related to the input voltage signals t5 44.65 (min.) ms Step 3. Assuming S0 = 0 and S1 =
as follows: t6 165 (min.) ms 1, read F1-4 value from Table II, which
515.84×V1rms×V2rms×F1-4 cies selected by using the S0 and S1 is 3.4 Hz.
Freq = logic inputs (see Table II). Step 4. From the transfer function
Vref2
Shunt selection. In order to arrive equation, calculate V2rms by substitut-
where Freq is the output frequency at the values of V1rms and V2rms we ing Vref=2.5V and the other values:
on F1 and F2 (Hz), V1rms is the differ- must select the size/power dissipation 0.0319443 Hz = (515.84x1.75x10-3
ential rms voltage signal on channel rating of shunt for developing V1rms xV2rmsx3.4)/2.52
V1 (volts), V2rms is the differential rms (proportional to line current), which or V2rms = 65 mV
voltage signal on channel V2 (volts), is the most critical part of the design. Thus an rms voltage sample of
Vref is the reference voltage (2.5V ± 8%) We have chosen the maximum current 65 mV measured between V2P and
and F1-4 is one of four possible frequen- as 30 amps and the shunt size as given AGND, and V2N and AGND, in

Electronics Projects vol. 26 59


conjunction with
rms voltage sample
of 1.75 mV (refer
step 1) measured
between V1P and
AGND, and V1N
and AGND, should
produce 115 puls-
es per hour, or
0.0319443 Hz (refer
Step 2), at F1 and
F2 outputs of IC
ADE7757. Now, if
we set the select cal-
ibration frequency
(SCF) to logic 1, the
output pulses at CF
will be 32 times the
pulse rate at either
F1 or F2 output (see
Table III).
As stated ear-
lier, the CF output
is used for calibra-
tion. Since this fre-
quency is compara-
tively high, the real
power information
is accumulated very
fast and hence less
averaging is car-
ried out for the CF
output. That means
the meter is more
responsive to pow-
er fluctuations. The
CF output can
also be used for in-
terfacing with mi-
crocontrollers.
Timing of out-
puts. The timing
Fig. 6: Circuit of the energy meter using ADE7757

diagram for F1, F2


and CF pulse out-
puts is shown in
Fig. 5 and the ap-
proximate timings
for the selected pa-
rameters are given
in Table IV.

The circuit
By following the
aforementioned de-
sign principles, we
arrive at the energy meter circuit shown multiplexing circuit has its own free-
Soldering of SMT ICs
in Fig. 6. IC ADE7757 (IC1) is at the running oscillator, it does not require
 Apply flux to the pads where the IC is to be
heart of the energy meter. It directly soldered.
external clock. The counter advances
interfaces with the shunt resistor and  Add a small amount of solder to one of the on the negative edge of the clock pulse.
operates off the AC input. The only ana- corner pin pads. The high input at the latch-enable pin
 Line up the IC with the pads on the PCB.
logue circuitry used in IC ADE7757 is displays the counter outputs.
Double check the IC orientation.
in the sigma-delta ADCs and reference  Melt the solder with your iron and move
IC6 drives the first four 7-segment
circuit. All the other signal processing is the IC into position with tweezers. Let the displays (DIS1 through DIS4), while
carried out in digital domain. solder solidify. IC7 drives the remaining four displays
 Solder the diagonally opposite pin. Check
The power supply for IC ADE7757 (DIS5 through DIS8). IC6 is cascaded
under magnification that all pins line up with
is derived directly from mains using their respective pads. to IC7 by connecting the ‘Carry’ output
the capacitor divider network compris-  Solder the rest of the pins and check under of IC6 to the clock input of IC7.
ing C13 and C14. Most of the voltage magnification. Transistors T1 through T8 drive the
Note. Special techniques may be needed for
is dropped across C13 (0.47µF poly- respective digit displays DIS1 through
some packages.
ester capacitor rated for 630V), while DIS8.
resistor R13 (470-ohm, 1W) is used as Since F1 output comprises 100
a current limiter. The
output across C14 is
limited to 15V DC,
which serves as an in-
put to regulator 7805
(IC2). The regulated
5V is fed to IC1 at its
VDD pin 1. In this ap-
plication, the phase
line is connected to
AGND (pin 6) and
DGND (pin 13) and
hence to the common
terminal of regulator
IC2.
Two MM74926
ICs (IC6 and IC7) are
cascaded to act as an
8-digit ripple counter,
in conjunction with
eight 7-segment dis-
plays (DIS-1 through
DIS-8), which require
additional 5V reg-
ulated and isolated
supply (to avoid ex-
tension of live mains Fig. 7: Actual-size, single-side PCB layout for the energy meter using ADE7757
to the counter sec-
tion). A conventional 5V regulator using diode D2 in series with the com- pulses for each energy unit (kWh), a
circuit incorporating a bridge rectifier mon terminal of regulator 7805 (IC5). decimal point is permanently placed
(BR1), smoothing capacitor (C15) and The F1 output of IC1 is coupled between DIS2 and DIS3. Thus the dis-
regulator IC 7805 (IC5) has been used to 8-digit ripple counter IC MM74926 play can show up to 999999.99 units
for the purpose. A 4.5V rechargeable via optocoupler IC3, while LED1 in- and then restart from 000000.00.
battery is used to provide back-up so dicates that IC1 is working. CMOS IC The meter and the PCB layout
that the counter does not reset when MM74926 consists of a 4-digit counter, must be designed such that the con-
mains fails. Diode D3 prevents battery internal output latch, npn output ducted/radiated electromagnetic
discharge through the regulator during source drivers for the 7-segment dis- disturbances and the electrostatic
mains interruption. The voltage drop play and internal multiplexing circuit- discharge do not damage the meter or
across diode D3 is compensated by ry with four multiplexed outputs. As disturb its working. Other disturbanc-

Electronics Projects vol. 26 61


nents and design tech-
niques (ferrite beads,
capacitor line filters,
large SMD resistors
and grounding of the
PCB layout) contrib-
ute to protect the me-
ter circuitry from all
forms of electromag-
netic disturbances.
Ferrite beads play a
more important role
against RF and fast
transience burst.
This being a non-
commercial educa-
tional project, all the
laid down design prin-
ciples have not been
adhered to. A simple
single-side PCB has
been used for assem-
bling the energy meter
circuit and testing it.
The PCB track layout
is shown in Fig. 7 and
Fig. 8: Component layout for the PCB in Fig. 7
its component layout
es to be considered are electromagnetic power line surge. in Fig. 8. The method for soldering the
HF fields, fast transience burst and All of the precautionary compo- surface mount ICs is given in the box. 

62 Electronics projects Vol. 26


Two-Wheeler
Security System
 Vinay Uday Prabhu IR transmitter with you and hide the Parts List
receiver module at a secure place in

I
Semiconductors:
ndia is the world’s largest market your bike. IC1, IC2 - NE555 timer
IC3 - CD4027 dual J-K flip-flop
for two-wheelers. Newer models Whenever you leave the bike,
IC4 - 7805, 5V regulator
with improved fuel efficiency and switch on the security circuit by IC5 - CD4081 quad two-input
power ratings keep hitting the market pressing the transmitter switch while AND gate
IC6 - CD4071 quad two-input
off and on. Sadly, the security aspect directing the transmitter towards the
OR gate
of two-wheelers remains neglected. sensor module such that the trans- T1 - BC558 pnp transistor
This fallibility inspired us to devise mitted IR rays fall on it directly. The T2, T3, T5 - BC547 npn transistor
T4 - TIP122 npn transistor
a foolproof yet cost-effective security received signal activates the security
D1-D7 - 1N4001
system to safeguard bikes against theft. circuit to blow the horn when subse- IR LED1 - Infrared LED
Any attempt to move the bike or force quently someone tries to steal your IRX1 - TSOP1738 IR receiver
module
the ignition key to start the bike will set bike by moving the bike or by using a
off the bike’s horn. duplicate key. The turbulence-sensing Resistors (all ¼-watt, ±5% carbon, unless
stated otherwise):
mechanism detects manhandling of the R1, R3, R8,
The concept bike to trigger the alarm. R10, R18 - 1-kilo-ohm
The two-wheeler security system (Fig. When you return back, switch off R2 - 1.2-kilo-ohm
R4 - 27-ohm, 0.5W
1) comprises a handheld infrared (IR) the sensor mechanism before starting R5, R11 - 100-ohm
transmitter, IR receiver/sensor, switch- the bike. Else, you may be caught off R6, R13 - 10-kilo-ohm
ing circuit, power supply, turbulence guard as this again will trigger the R7 - 220-kilo-ohm
R9, R12 - 470-ohm
detection unit, alarm and ignition alarm. R14-R16 - 22-kilo-ohm
switch. You have to keep the handheld In case the transmitter unit is not R17 - 100-kilo-ohm
working or you Capacitors:
have misplaced C1, C2, C6 - 0.01µF ceramic disk
C3 - 100µF, 25V electrolytic
it, you can still C4 - 1µF, 25V electrolytic
activate the secu- C5 - 10µF, 25V electrolytic
rity circuit sim- C7 - 0.1µF ceramic disk
C8 - 100µF, 25V electrolytic
ply by flipping
its switch S3 to on Miscellaneous:
S1 - Push-to-on switch
position.
S2 - Motor bike switch
S3 - On/off-switch
Circuit LS1 - 12V horn
description E1-E3 - Thin steel rod
- Plastic bottle
Transmitter cir- - 9V battery
Fig. 1: Block diagram of the two-wheeler security system RL1 - 12V, 285-ohm, 1C/O relay
cuit. The trans-
mitter circuit
(Fig. 2) works off a 9V battery. It is IR LED1. Make sure that IR LED1
built around timer IC NE555, which is is properly oriented towards the IR
wired in astable multivibrator mode sensor module of the receiver circuit.
to generate around 38kHz frequency. Its transmission wavelength of 900
The timer output is amplified by pnp to 1100 nm (near-IR range) lies in the
transistor BC558 to drive the IR LED peak receptivity range of TSOP1738
(LED1). Resistor R4 limits the current receiver module.
flowing through LED1. Receiver circuit. The receiver cir-
When you press switch S1 momen- cuit (Fig. 3) comprises power supply,
tarily, the astable multivibrator starts sensor module, switching, turbulence
oscillating and the 38kHz frequency detection and alarm sections.
Fig. 2: Transmitter circuit generated is transmitted through Power supply. The receiver cir-

Electronics Projects vol. 26 63


Fig. 3: Circuit of the two-wheeler security system

cuit excluding IR receiver module T2 conducts to energise relay RL1 and


TSOP1738, timer NE555 (IC2) and J-K the +12V supply energises electrode
flip-flop CD4027 (IC3) works off the E1, turbulence-detection section (com-
12V battery of the bike. The 12V sup- prising AND gate CD4081 (IC5) and
ply is down-converted to 5V by regu- OR gate CD4071 (IC6)) and the alarm
lator IC 7805 (IC4) to drive TSOP1738, section. The red LED (LED2) glows to
IC2 and IC3. indicate enabling of these sections.
Sensor. IR receiver module When the transmitter switch is Fig. 4: Pin configurations of tip122, tsop1738
TSOP1738 is sensitive to the IR radia- pressed again, the relay gets de- and bc558/bc547
tion modulated at 38 kHz. Its normally energised by the toggling action of the
high output goes low when any IR flip-flop and electrode E1, turbulence- When the bike is moved, water
radiation is detected. detection section (built around IC5 and inside the bottle shakes to short all
Switching. The high-to-low IC6) and the alarm section (comprising the three electrodes inside the bottle
transition of the receiver output Darlington pair transistors T3 and T4) together momentarily and the inputs
triggers timer IC2, which is rigged are disabled. The red LED now goes of AND gate N1 go high. The inputs of
up in the monostable mode, and the off. A free-wheeling diode (D6) used AND gate N2 also go high and its high
green LED (LED1) glows to indicate in parallel to the relay prevents the output makes output pin 3 of OR gate
signal reception and it also generates transistor from damage when the relay N3 high. This causes forward biasing
a positive-going clock pulse for the de-energises. of Darlington pair of transistors T3 and
flip-flop. Turbulence detection. The turbu- T4 and the horn blows.
The output of IC2 is fed to the lence-detection section detects sudden At the same time, npn transistor T5
clock input of IC3. Here IC3 is wired in bike jerks, provided relay RL1 is in gets forward biased to charge capacitor
toggle mode by connecting its J and K energised state. It consists of a small, C8. As a result, pin 6 of AND gate N2
inputs to +5V, and Set and Reset pins watertight bottle with three electrodes remains high for some time even after
to ground. IC3 is triggered by the clock inserted into it to detect the turbulence the electrodes are no longer shorted by
pulse received from IC2 and transistor caused. the splash of water in the bottle. Hence,

64 Electronics projects Vol. 26


power transistor TIP122,
IR sensor module
TSOP1738 and npn tran-
sistor BC558 (or BC547).
The combined actual-
size, single-side PCB
for the transmitter and
receiver circuits (Figs 2
and 3) is shown in Fig.
5 and its component
layout in Fig. 6. You can
separate the two PCBs
by cutting along the
vertical line of the PCB.
Make sure that manual
Fig. 5: Actual-size, single-side PCB layout for two-wheeler security system switch S3 in the PCB is
easily accessible, so that
you may use it to switch
on/off the security cir-
cuit in case the transmit-
ter is not working or
you’ve lost it.

Demerits
1. Two logic gates of
CD4081 and three logic
gates of 4071 are left un-
utilised.
2. TSOP1738 may get
triggered by a TV re-
mote.
3. Short range of the
Fig. 6: Component layout for the PCB transmitter (4 to 5 me-
tres).
the horn blows until capacitor C1 dis- Alarm. The alarm section com-
charges below the threshold level of prises a high-current gain Darlington Precautions
CMOS gate via resistor R13. pair of transistors pumping current 1. Make sure that electrode E1 is al-
The basic aim of the turbulence into the bike’s horn. The emitter of ways dipped into the water.
detection module is to activate the horn transistor T4 is directly connected to 2. Hang the two electrodes (E2 and
when the bike is moved or ignition the positive terminal of 12V horn. A E3) to rest just above the water level
key is forced to start the bike. This is heat-sink is used to dissipate the ex- so that they easily get shorted by the
achieved by using two-input OR gate cessive heat generated by npn power shaking water when the bike is moved.
N3 (IC CD4071), which is connected to: transistor TIP122. 3. Make sure the bike’s battery is
1. The output of AND gate N2, fully charged.
which is virtually the output of the Fabrication 4. Keep the circuit protected from
turbulence detection module Assemble the transmitter and receiver water and high temperature.
2. A lead from the ‘on’ terminal of circuits on separate general-purpose
the bike key PCBs as you have to carry the trans- Other applications
When either or both the inputs mitter unit with you and install the 1. Turbulence detection.
of N3 are high, its output goes high receiver unit in the bike. The lid of the 2. The circuit can be modified to
to provide sufficient current to drive water-filled plastic bottle should be function as an overflow indicator in
the Darlington pair transistors of the tight enough so that the water does water tanks.
warning-indication section and the not leak out. 3. The receiver unit itself can be
horn blows. Fig. 4 shows pin configurations of used as an infrared toggle switch. 

Electronics Projects vol. 26 65


medium-power
low-cost inverter
 T.K. Hareendran cillator-cum-divider and driver while Parts List
the centre terminal of the inverter

T
Semiconductors:
his medium-power inverter is transformer primary is connected to IC1 – 7805 5V regulator
IC2 – LM555 timer
capable of generating approxi- the positive terminal of the car battery
IC3 – 7473 dual J-K flip-flop
mately 300VA power. You can through high-currrent carrying wires. IC4 – LM358 dual operational
power the inverter from your car bat- Capacitor C1 functions as a reservoir amplifier
tery to generate 50Hz AC supply. The capacitor. T1, T2 – BD139 npn transistor
T3-T8 – IRFZ44 power MOSFET
inverter provides enough back-up Low-battery indicator. For long D1, D2 - 1N4148 diode
power to light up up to three 100W life of the battery, it should not be al- LED1, LED2 – 5mm red LED
bulbs for up to two hours, provided lowed to discharge to a voltage below LED3 – 5mm green LED
ZD1, ZD2 - 5.1V zener diode
the car battery is fully charged. 10V. Even a single event of deep dis-
Fig. 1 shows the block diagram charge can reduce the charge-holding Resistors (all ¼-watt, ±5% carbon, unless
mentioned otherwise):
of the medium-power inverter. The capacity of the battery permanently. R1-R3, R5, R6
power house comprises car battery, For audio-visual indication of the R9-R12 – 1-kilo-ohm
power supply, oscillator-cum-divider, low-battery level, a dual operational R4 - 1-ohm, 0.5W
R7 - 220-ohm
driver, inverter transformer, power amplifier IC LM358 has been used. A R8 - 15-kilo-ohm
amplifier, buzzer and battery-level fixed reference voltage of 5.1V is ap- VR1 - 470-kilo-ohm preset
indicator sections. To keep the plied to its positive input, while the Capacitors:
C1, C3 – 0.1µF ceramic disk
C2 – 1000µF, 35V electrolytic
C4 – 100µF, 25V electrolytic
C5 – 0.47µF ceramic disk
C6 – 0.01µF ceramic disk
Miscellaneous:
S1 – On/off switch
PZ1 – Piezobuzzer
X1 – 12V-0-12V primary to
Fig. 1: Block diagram of medium-power inverter 300VA inverter transformer
- Crocodile clips (red and
black)
cost low, the charger circuit has sensing voltage is applied to its nega- - Multistrand high-current
not been included here. The car tive input. Set preset VR1 such that the carrying wires
battery can be charged through the piezobuzzer sounds when the on-load
car battery charger circuit whenever battery voltage falls below 10V DC. with 50% duty cycle. When the invert-
it discharges. When the battery voltage drops er is switched on using switch S1, IC2
below 10V, the sense input voltage starts producing 100 Hz, while the J-K
The circuit drops below 5.1V and output pin 1 of flip-flop produces 50 Hz at its output
Connect the car battery to the circuit IC4 goes high to sound the buzzer and pins 8 and 9. The output of timer IC2
using crocodile clips. The red clip light up LED2. can be checked using the oscilloscope
should be connected to the positive Oscillator-cum-divider. The os- at test point (TP).
terminal of the battery and the black cillator-cum-divider section is built Driver circuit. The flip-flop output
clip should be connected to the nega- around timer IC LM555 (IC2) and is fed to MOSFET driver transistors
tive terminal of the battery. If croco- dual J-K flip-flop 7473 (IC3). Only one T1 and T2 via a diode-resistor combi-
dile clips are connected to the wrong flip-flop of the dual JK flip-flop is used nation. At any instant, if the voltage
terminals of the battery, LED1 glows here. of pin 8 of IC3 is +5V, the voltage at
to alert you. Timer LM555 is wired as an astable its pin 9 will be 0V, and vice versa.
Now flip switch S1 towards ‘on’ multivibrator, whose time period is Therefore when transistor T1 conducts,
position to enable the circuit. LED3 decided by resistors R7 and R8 and transistor T2 is cut off, and vice versa.
glows to indicate power-‘on’ and 12V capacitor C5. It produces 100 Hz at Whenever output pin 8 of IC3 goes
DC reaches regulator IC 7805 (IC1). output pin 3, which is given to pin 5 high, npn transistor T1 conducts and
The regulated output is fed to the os- of the J-K flip-flop to produce 50 Hz the corresponding set of MOSFETs (T3

66 Electronics projects Vol. 26


through T5) remains
cut off while the col-
lector of transistor
T2 is at 5V. Thus cur-
rent flows through
half of the inverter
transformer’s pri-
mary winding. Simi-
larly, when output
pin 9 of IC3 goes
high, npn transis-
tor T2 conducts and
the corresponding
set of MOSFETs (T6
through T8) remains
cut off while the col-
lector of transistor T1
is at 5V. Thus current
flows through the in-
verter transformer’s
primary winding.
Power amplifier. Fig. 3: Actual-size, single-side PCB for medium-
The power ampli- power inverter
fier section compris-
es two sets of three
power MOSFETs
(IRFZ44) connected
in parallel for opera-
tion of the inverter.
The output of IC3
drives the MOSFETs
(T3 through T5, and
T6 through T8) via
transistors T1 and
T2 to generate 50Hz,
230V AC at the out-
put of inverter trans-
former X1.

Fabrication
You can assemble the
circuit on any gen-
eral-purpose PCB.
However, an actual-
size, single-side PCB
Fig. 2: Circuit of medium-power inverter

Fig. 4: Component layout for the PCB


for the medium-pow-
er inverter circuit is After construction, enclose the
shown in Fig. 3 and entire circuit in a portable box (see
its component layout Fig. 6). The first MOSFET set comprises
in Fig. 4. Pin configu- T3, T4 and T5, and the second MOS-
rations of MOSFET FET set comprises T3, T4 and T5. Use
IRFZ44, regulator IC separate heat-sinks for each MOSFET
7805 and npn transis- set. Since MOSFETs T3 through T5,
tor BD139 are shown and T6 through T8, are connected
in Fig. 5. in parallel, connect the drains of the

Electronics Projects vol. 26 67


1. On full
load, the cur-
rent drawn
from the battery
could be as high
as 30 amperes.
Therefore the
ground track
Fig. 5: Pin configurations of MOSFET IRFZ44,
regulator IC 7805 and npn transistor BD139 around source
terminals of the
MOSFETs (internally connected to the M osfet s o n
backplate having a through hole) us- the PCB may be
ing a copper/brass nut/bolt onto the strengthened by
respective common heat-sink. Mount Fig. 6: Proposed portable box depositing ad-
all the status LEDs, piezobuzzer and ditional solder.
switches on the front panel. Use heavy- bolt (provision for the same is made 2. You may add a resistor
gauge, multistrand battery wires (2.5 on the PCB). (0.5-ohm rated at 20W) in series with
sq. mm or more) for the following DC 3. From each heat-sink set (where positive battery lead going to the
connections: the drains of the Mosfets have been middle terminal of transformer X1
1. From positive battery terminal to connected using nuts and bolts) to the primary. In the case of excessive cur-
the middle of transformer X1 primary. respective primary terminals of trans- rent being drawn by any of the Mos-
2. From the negative terminal of former X1. fets (due to shorting, etc), only the
the battery to the common ground on EFY. Following additional precau- resistor will burn, which can be easily
the PCB using copper/brass nut and tions may also be taken: replaced. 

68 Electronics projects Vol. 26


Programmable Timer
based on AT90S4433 AVR
D.S. OBEROI and harinder microcontroller is being operated at their common-anode terminals are
dhingra 4.000MHz frequency and this serves separately driven by four transistors
as the basis for all the timings, i.e., for (T1 through T4), which are interfaced

A
programmable timer finds nu- generating an interrupt every second to Port B (PB0 through PB3) outputs
merous applications in the in- of the microcontroller.
dustry for efficient operation of Multiplexing of
machines in the desired sequence and displays reduces not
for precise time durations. Such timers only the number of
form part and parcel of all program- input/output (I/O)
mable logic controllers (PLCs), which lines required but
control the switching on and switching also the mean current
off functions of appliances like fans/ required for operat-
blowers, heaters and airconditioners, Fig. 1: Block diagram of programmable timer ing the display units.
as desired. Whenever some data
Here’s an AVR AT90S4433 micro- and controlling the LED display, etc. is to be displayed, it is first latched on
controller-based programmable timer The circuit uses four 7-segment dis- Port D and then that particular display
that can switch on/off an appliance plays (DIS1 through DIS4). During unit is enabled by switching on the
after a certain time. This time can normal operation of the timer, DIS1 respective controlling transistor via
be set through the pushbuttons pro- and DIS2 display hours, while DIS3 Port B. The data is displayed without
vided in the circuit. After the set time and DIS4 display minutes. However, flickering with the help of the software.
elapses, the microcontroller-based logic during setting/programming opera- The SIGNAL(SIG_OVERFLOW0) inter-
generates the desired on/off signal tion of the timers, they display certain rupt service routine (ISR) is used to
to activate/deactivate the appliance. alphanumeric characters as stated control the display units in different
With this timer, you can program time earlier. The seven segments and the operational modes of the timer.
periods from one minute to 99 hours decimal point of all the displays are For manual setting and control
and 59 minutes. wired in parallel and fed via port D of the timer, three dual-function
The circuit uses four 7-segment (PD0 through PD7) outputs, while pushbutton switches S1 through S3
displays for displaying the time dur- labeled as Mode/End, On/Minute
ing normal operation of the timer and Parts List and Off/Hour, respectively, have been
certain alphanumeric characters during Semiconductors: provided. Their functions have been
IC1 - AT90S4433 AVR
setting/programming of the timers. microcontroller explained under the software subhead-
These operations have been covered in T1-T5 - BC548 npn transistor ing. The pushbuttons are interfaced to
the software part and the accompany- D1 - 1N4007 rectifier diode the microcontroller via Port C. Their
DIS1-DIS4 - LTS542 common-anode,
ing flow-charts. After the programmer 7-segment display status is repeatedly checked by the
has been set and is running, it can be LED1 - Red LED getKeyStatus() routine, which returns
immediately reset through switch S1 Resistors (all ¼-watt, ±5% carbon, unless information about the pushbutton
(Mode/End) in the case of an emer- stated otherwise): pressed and then an appropriate ac-
R1-R8, R14 - 220-ohm
gency. R9-R12 - 1-kilo-ohm tion is initiated by the software. The
The circuit uses the internal timer R13 - 10-kilo-ohm pushbutton functionality is dual in
of AT90S4433 microcontroller for R15-R17 - 150-ohm nature, i.e., each button will perform a
R18-R21 - 4.7-kilo-ohm
generating an interrupt every second, different function in a different mode
which, in turn, is used for computing Capacitors: of timer operation.
C1, C2 - 27pF ceramic disk
the ‘on’/‘off’ time period. C3 - 0.1µF ceramic disk For activating/deactivating an
C4 - 47µF, 16V electrolytic appliance, an output interface signal
The hardware Miscellaneous: marked DEVICE_CTRL (in Fig. 2)
Fig. 1 shows the block diagram of the XTAL - 4.000 MHz crystal is available from Port B (PB4). The
programmable timer, while the circuit RL1 - 5V, 150Ω, 1C/O relay software will control the logic of this
S1-S3 - Push-to-on switch
is shown in Fig. 2. Here AT90S4433 signal to switch on or switch off an

Electronics Projects vol. 26 69


Fig. 2: Circuit of programmable timer using AT90S4433

appliance through energisation or from ‘www.avrfreaks.net/AVRGCC’ refreshed with the respective data fast
de-energisation of relay RL1 via relay for Windows OS and from ‘ftp:// enough so that a flicker-free display
driver transistor T5. gatekeeper.dec.com/pub/GNU/’ is achieved, and for this reason, timer
The ports are configured as follows: for Linux OS free of cost), along with 0 is preloaded with an appropriate
1. Port-B: It is configured in out- AVR STUDIO version 3.0, is used for value. In this ISR, the operation status
put mode and used for activating/ programming (in ‘C’ language syn- is checked by checking the value of
deactivating an external appliance tax), debugging and generating the DISPLAY_MODE and then the desired
and controlling the transistors of the compatible hex code for AT90S4433 data is latched to Port D. After the ISR
display units. microcontroller. completes its operation, timer 0 is once
2. Port-C: It is configured in input The software uses both the 8- and again loaded with the desired refresh
mode and used for interfacing the 16-bit internal timers of the microcon- value (REFRESH_VAL).
pushbutton switches. troller. The 8-bit timer (timer 0) is used The particular display unit that is
3. Port D: It is configured in output for displaying the information without to be made active with the desired data
mode. All the segments of the display flickering and the 16-bit timer (timer will depend upon the value of the DIS-
units are interfaced to this port. 1) is used for generating an interrupt PLAY_ON variable. The two left-most
every second, which is used for com- display units are used for displaying
The software puting the elapsed time during both the hours, while the remaining two
Two separate software are provided. The the ‘on’ and ‘off’ periods of the cycle. display units are used for displaying
first software (labeled Timer-A) provides The SIGNAL (SIG_OVERFLOW0) minutes (in countdown mode of opera-
cyclic on/off functionality, while the sec- ISR of timer 0 is used for flicker-free tion). This functionality is achieved by
ond software (labeled Timer-B) provides display of the information. Timer-0 is the showNormalDisplay() subroutine.
switch-on functionality after a preset initially configured to operate in timer In countdown mode, the displayed
elapsed time. The following explanation mode with prescaling factor of ‘256’ information changes in last 60 min-
relates to Timer-A, however the setting and preloaded with a desired value. utes of the operation. Now the two
and operation of Timer-B have been Whenever timer 0 overflows, its ISR left-most display units are used to
briefly explained later in the article. is initiated to latch the desired display display minutes and the two right-
The desired functionality is data on Port D and also switch on the most display units are used to display
achieved by controlling the hardware corresponding transistor of that par- seconds. This is achieved with the help
through software. The AVR-GCC 3.2 ticular display unit. of the showLast60MinutesDisplay()
software (which can be downloaded All the display units have to be subroutine.

70 Electronics projects Vol. 26


ters of the microcontroller, which
are preloaded with the desired value
of 0x3D09. While in operation, as
soon as the contents of timer-1
equal that of the compare register,
a compare interrupt (SIGNAL(SIG_
OUTOUT_COMPARE1A)) is generat-
ed. This ISR computes the elapsed time
and controls the output signal (DE-
VICE_CTRL) at the end of ‘on’/‘off’
time periods. It is also used to switch
from ‘on’ period to ‘off’ period, and
vice versa, after the lapse of the respec-
tive time period. The ISR sets the val-
ues of the DISPLAY_MODE variable,
which, in turn, is used by timer-0 ISR
for displaying the correct information
(particularly in normal mode and last
60 minutes of the timer operation). Fig.
4 shows the flow-chart of timer-1 ISR.
Once the ports and internal tim-
ers of the microcontroller have been
configured by the software, the main
operational loop of the software is
initiated, which basically checks the
status of pushbutton switches with
the help of the getKeyStatus() sub-
routine. Depending upon the mode
of the operation, each pushbutton
Fig. 3: Flow-chart of timer-0 ISR
switch has a specific function. The
Similarly, the dis- status of the pushbutton switches is
plays for mode setting checked in conjunction with the value
and the end message of the DISPLAY_MODE variable. The
are achieved with the DISPLAY_MODE variable at any
help of showMode given moment indicates the status
Display() and show of operation and its value is used
EndModeDsiplay() for displaying the correct information
subroutines, respec- with the help of timer-0 ISR. The push-
tively. While setting button switch functioning will also
the ‘on’ and ‘off’ time depend upon the value of this variable.
periods, the show Set- In the time period setting mode,
tingTime() subroutine the hour_minSettingChange() subrou-
is used for displaying tine is used to set on_hour, off_hour,
the desired informa- on_min and off_min values. This sub-
tion. Fig. 3 shows the routine also checks for the maximum
flow-chart of timer-0 limits of hours (99) and minutes (59).
ISR. Once the settings have been made, the
The 16-bit timer 1 modeSettingChange() subroutine is
is used for time keep- initiated from this main operational
ing. It is configured loop, which will now start the circuit’s
to work in compare operation and the countdown process.
mode with presca- In operational mode, the main
ling factor of ‘256’ loop mainly checks the status of Mode
in conjunction with pushbutton switch (S1). When Mode
Fig. 4: Flow-chart of timer-1 ISR two compare regis- pushbutton switch is pressed, the out-

Electronics Projects vol. 26 71


or reset, the follow- active and the message of Step 6 is
ing message is dis- displayed.
played: 8. By pressing the Off/Hour push-
button, you can set the ‘off’ time period
which indicates that in the same manner as for ‘on’ time
none of the ‘on’ and period in Steps 3, 4, 5 and 7.
‘off’ time periods has 9. Now the following information
been set. is displayed:
2. On pressing
the Mode/End push- The decimal point in the two right-
button, there is no most display units indicates that ‘off’
change in the display time period has been set.
status and software 10. Once the settings have been
operation. made, the time period settings can be
3. Now by press- changed again by repeating the afore-
ing the On/Min mentioned steps.
pushbutton, you 11. In Step 3, if Off/Hour pushbut-
can set/change the ton is pressed first for setting the ‘off’
‘on’ time period. By time period, the display will be:
continuously press-
ing the Hour or Min In the setting mode, any of the ‘on’
Fig. 5: Actual-size, single-side PCB for programmable timer pushbutton, you can and ‘off’ time periods can be set first.
set any value from 12. To start the timer, press Mode/
‘0’ to ‘99’ for hours End pushbutton for around 1.5 sec-
and ‘0’ to ‘59’ for onds. The countdown starts from ‘on’
minutes. Release the time period and the DEVICE_CTRL
respective buttons af- output control signal becomes high.
ter the desired value The circuit operation is indicated by
is displayed. blinking of the decimal point on DIS2
4. The value can every second. The output signal will
be changed by press- change with the respective active pe-
ing the respective riod (‘on’ or ‘off’) one after the other.
pushbutton once In case you need to switch off the
again. external appliance immediately, stop
5. Press Mode/ the working of the timer by pressing
End pushbutton to Mode/End pushbutton for one second.
set the ‘on’ time pe- The output control signal goes low and
riod. the following message is displayed:
6. Now the fol-
lowing information which indicates that the process has
is displayed: been aborted.
The circuit will remain in this state
The decimal until you set new values. For setting
point in the two left- the new values, follow the procedure
Fig. 6: Component layout for the PCB most display units from Step 1 onwards.
indicates that the ‘on’ Setting and operation of timer-B
put control signal immediately deacti- time period has been set. are given below:
vates the appliance and message 7. Now by pressing the On/Min 1. ‘0.0.0.0.’ is displayed at start-up,
is displayed. To resume the normal pushbutton, you can again change with decimal points flashing.
operation, the Mode pushbutton switch the ‘on’ time period. In this state, the 2. Press Min and Hour keys to set
has to be pressed once again, which will already set value is displayed first and minutes and hours for the activity.
take the user to mode setting. the change made will be in count-up 3. Press Mode key to start the
Settings and operation of timer-A mode from this time onwards. On timer.
are as follows: pressing the Mode/End button, the 4. Now display the countdown
1. Immediately after power-on new value of ‘on’ time period becomes mode.

72 Electronics projects Vol. 26


5. At the end of the countdown cyclic ‘on’/‘off’ functionality, while activity.
mode, ‘End’ will be displayed and software Timer-B is used for switching 4. Controlling multiple app-
device will switch off. on the appliance after a set time period liances. 
6. At any time if Mode key is has elapsed. Download source code: http://
pressed, End message will be displayed www.efymag.com/admin/issuepdf/
and by pressing Mode key, the system Further improvements Timer.zip
will be at Step 1 of the operations. The software can be modified for:
The actual-size, single-side PCB 1. Changing the sequence of ‘on’ Ms Dhingra, B.E., has worked with Punjab Com-
for the programmable timer using and ‘off’ time period activation. munications Ltd and is now a lecturer at Govt.
College of Engineering & Technology, Jammu.
AT90S4433 is shown in Fig. 5 and its 2. Operation of ‘on’ and ‘off’ time Mr Oberoi, M.Tech, has worked with Electronics
component layout in Fig. 6. periods for a definite number of times. System Punjab Ltd and is now principal design
Software Timer-A is used for the 3. Synchronisation with external engineer at DOEACC Centre in Jammu/Srinagar

Electronics Projects vol. 26 73


Manual AT89C51
Programmer
 R. Jeyaraman and connected to pins 1 through 7 of port 1 Parts List
R. Lakshmanan and pins 21 through 24 of port 2 of the Semiconductors:
microcontroller. These pins act as the IC1, IC3 – NE555 timer

F
or hand coding of AT89C51 address pins (A0 through A11) of the IC2 – CD4040 12-bit binary
counter
microcontroller, here is a simple microcontroller. The outputs of IC2 IC4 – 7812 12V regulator
programmer to program binary are also connected to LED1 through IC5 – 7805 5V regulator
data into the microcontroller. It doesn’t LED12 via current-limiting resistors IC6 – AT89C51 microcontroller
T1-T3 – BC548 npn transistor
require use of a computer and all the R4 through R15, respectively. LED1 D1-D4 – 1N4007 rectifier diode
control signals and data are entered through LED12 indicate address loca- D5 – 1N4148 switching diode
manually. The programmer can erase, tion for the microcontroller IC. Switch LED1-LED12,
LED22-LED29 – Red LED
read and write data into the flash S2 is used to reset the counter (IC2).
LED13-LED20 – Green LED
memory of the microcontroller. It can Port 0 receives code bytes dur- LED21 – Yellow LED
also read the signature byte of the mi- ing flash programming and outputs Resistors (all ¼-watt, ±5% carbon, unless
crocontroller. them during program verification. mentioned otherwise):
Port-0 pins 39 down to 32 are used as R1-R3,
Circuit description data pins for the microcontroller, and R31-R33 – 10-kilo-ohm
R4-R23 – RNW1, RNW2, RNW3
Fig. 1 shows the circuit of the manual connected to pins 1 through 8 of DIP R35-R42 – 220-ohm
programmer. It uses timer NE555 (IC1) switch SW1 as well as LED13 through R24, R26 – 1-kilo-ohm
wired as a monostable to increment the LED20 via current-limiting resistors R27, R29 – 2.7-kilo-ohm
R28 – 15-kilo-ohm
address location one by one in conjunc- R16 through R23. The LEDs indicate R30 – 100-ohm
tion with counter CD4040. data at/for the addressed location of R34 – 4.7-kilo-ohm
When switch S1 is pressed, IC1 the microcontroller. Port pins 16, 17, 27 R25 – 12-kilo-ohm
RNW4 – 4.7-kilo-ohm×8 (SIP9)
generates a clock pulse, which is given and 28 are controlled by slide switches
to clock pin 10 of 12-bit binary coun- S6, S7, S8 and S9, respectively, as per Capacitors:
C1 – 0.47µF, 16V electrolytic
ter CD4040 (IC2). The 12-bit counter the table given below. C2, C8 – 0.01µF ceramic disk
is used for generating the 12-bit Programming pulse (ALE/PROG) C3, C4, C12,
binary address for AT89C51 micro- and programming voltage (EA/Vpp) C13 – 33pF ceramic disk
C5, C9, C10 – 0.1µF ceramic disk
controller IC. The microcontroller to are derived with the help of IC3 and
C6 – 10µF, 16V electrolytic
be programmed is inserted into the transistors T1 through T3. Timer IC3 C7 – 1µF, 16V electrolytic
ZIF socket for programming, reading generates and determines the pro- C11 – 1000µF, 35V electrolytic
and erasing. During flash program- gramming and erasing pulse time. It Miscellaneous:
ming and verification, port 1 receives is configured as a monostable whose X1 – 230V AC to 15V, 300mA
secondary transformer
low-order address bytes, while port 2 time period is decided by resistor R24
XTAL – 4MHz crystal
receives high-order address bits and and capacitors C6 and C7. Capacitors S1-S3 – Push-to-on switch
some control signals. C6 and C7 are selected by slide switch S4-S9 – Slide switch
Q0 through Q11 outputs of IC2 are S4 for programming and erasing, SW1 – 8-way DIP switch
– 40-pin ZIF socket

Flash Programming Modes respectively. The triggering pulse


Mode Pin 9 Pin 29 Pin 30 Pin 31 Pin 27 Pin 28 Pin 16 Pin 17 is applied through a high-pass R-C
WR RD network (comprising C5 and R28) and
RST PSEN ALE/PROG EA/VPP P2.6 P2.7 P3.6 P3.7
diode D5.
Output pin 3 of IC3 is connected
Write code data H L H/12V L H H H
to the base of transistor T1 via resis-
Read code data H L H H L L H H
tor R27. The high pulse output of IC3
Chip erase H L (1) H/12V H L L L
drives transistor T1 and provides low
Read signature byte H L H H L L L L
pulse to pin 30 of the microcontroller.
Note: 1. Chip erase requires a 10ms PROG pulse LED21 glows to indicate application

74 Electronics projects Vol. 26


Electronics Projects vol. 26
Fig. 1: Circuit diagram of manual AT89C51 programmer

75
of the programming/erasing pulse.
IC3 also determines the time period
for application of the programming/
erasing voltage (12V) to the micro-
controller. When its output goes high,
npn transistor T2 conducts and its col-
lector goes low. As a result, transistor
T3 is cut off and its collector voltage
rises to around 12V. Slide switch S5
is used for selecting 12V or 5V as
required.
The AC mains is stepped down by
transformer X1 to deliver a second-
ary output of 15V at 300 mA. The
transformer output is rectified by a
full-wave bridge rectifier comprising
diodes D1 through D4, filtered by
capacitor C11, and regulated by IC4
and IC5 to provide regulated 12V and
5V supplies, respectively. Capacitors
C9 and C10 bypass any ripple in the
regulated outputs.

Programming
The AT89C51 microcontroller is pro-
grammed byte by byte. Before pro-
gramming, the flash memory must be
Fig. 2: Actual-size, single-side PCB layout for manual AT89C51 programmer of Fig. 1
erased completely and control signals
should be set according to the table for
erasing, programming and reading the
microcontroller as follows.
Chip erase. Move slide switch
S4 towards Erase position. The high
output at pin 3 of IC3 provides a low
pulse of around 10 milliseconds (ms)
available at pin 30 of the microcon-
troller (ALE/PROG). Now move slide
switch S5 towards Prog/Erase posi-
tion for programming voltage (12V).
The entire flash array can be erased
electrically by setting pins 28, 16 and
17 to low level using switches S9, S6
and S7, respectively, and pin 27 at
high level using switch S8. Insert the
microcontroller into the ZIF socket
and press switch S3 (LED21 glows to
indicate application of the program-
ming pulse) to erase the flash array
(reset to all 1’s).
Write code. Press switch S2 to reset
the address counter to address ‘0000H.’
In this state, LED1 through LED12 are
off. Move slide switch S4 towards Prog
position and switch S5 towards Prog/
Fig. 3: Component layout for the PCB in Fig. 2 Erase position. Make control signal

76 Electronics projects Vol. 26


press switch S1 momentarily to
increment the address (indicated
ring.LST
Addr. OPCode Line Mnemonics
by LEDs). Set the code data using 1 $MOD52
DIP switch SW1 and program it 0000 2 ORG 0000H
0000 747F 3 MOV A , #07FH
by pressing switch S3. Repeat this 0002 F580 4 MOV 80H,A
process until the program code 0004 1140 5 ACALL DELAY
0006 74BF 6 MOV A , #0BFH
completes. 0008 F580 7 MOV 80H,A
Read/verification. Move slide 000A 1140 8 ACALL DELAY
000C 74DF 9 MOV A , #0DFH
switch S5 towards Read position 000E F580 10 MOV 80H,A
and DIP switch SW1 towards Off 0010 1140 11 ACALL DELAY
0012 74EF 12 MOV A , #0EFH
position. Make control signal pins 0014 F580 13 MOV 80H,A
27 and 28 low using switches S8 0016 1140 14 ACALL DELAY
0018 74F7 15 MOV A , #0F7H
and S9, and pins 16 and 17 high 001A F580 16 MOV 80H,A
using switches S6 and S7, respec- 001C 1140 17 ACALL DELAY
001E 74FB 18 MOV A, #0FBH
tively. Reset the counter using 0020 F580 19 MOV 80H,A
switch S2 and read/verify data at 0022 1140 20 ACALL DELAY
0024 74FD 21 MOV A, #0FDH
location ‘0000H.’ Increment the
0026 F580 22 MOV 80H,A
address counter using switch 0028 1140 23 ACALL DELAY
S1. The data at the incremented 002A 74FE 24 MOV A, #0FEH
002C F580 25 MOV 80H,A
location (say, 0001H) can be seen 002E 1140 26 ACALL DELAY
on LED13 through LED20. Again 0030 0100 27 AJMP 0000H
28
press switch S1 and see the data 0040 29 ORG 0040H
at the incremented address on 0040 7FFF 30 DELAY: MOV R7, #0FFH
0042 7DFF 31 LOOP1: MOV R5, #0FFH
the LEDs. 0044 1D 32 LOOP: DEC R5
Fig. 4: Circuit of the example ring counter
Reading the signature bytes. 0045 ED 33 MOV A, R5
0046 70FC 34 JNZ LOOP
0048 1F 35 DEC R7
0049 EF 36 MOV A, R7
004A 70F6 37 JNZ LOOP1
004C 22 38 RET
39 END
VERSION 1.2k ASSEMBLY COMPLETE, 0 ERRORS
FOUND

(032H) = FFH indicates ‘12V pro-


gramming’
(032H) = 05H indicates ‘5V pro-
gramming’
Note. The present circuit is meant
for 12V programming.

Construction
A single-side PCB layout for the manu-
al programmer (Fig. 1) is shown in Fig.
Fig. 5: Actual-size, single-side PCB layout for Fig. 6: Component layout for the PCB in Fig. 5 2 and its component layout in Fig. 3.
the ring counter
Signature bytes can be read using the Sample program
pins 28, 16 and 17 high using switches same procedure as used for normal To test the working of the programmer
S9, S6 and S7, respectively, and pin verification of locations 030H, 031H kit, here’s a program (RING.LST) for
27 low using switch S8. Set the code and 032H, except that all the control a continuously running ring counter:
data using DIP switch SW1. The data pins (pins 27, 28, 16 and 17) must be The circuit of the ring counter is
(D0 through D7) being set is indicated pulled low using switches S8, S9, S6 shown in Fig. 4. Its PCB layout is shown
by LED13 through LED20. Program and S7, respectively. The values re- in Fig. 5 and component layout in Fig. 6.
the code data by pressing switch S3. turned would be: Download source code: http://
(LED21 glows to indicate application (030H) = 1EH indicates ‘manufac- www.efymag.com/admin/issuepdf/
of the programming pulse.) tured by Atmel’ Manual%2089c51%20Programmer.
For programming the next data, (031H) = 51H indicates ‘89C51’ zip 

Electronics Projects vol. 26 77


COMPUTERISED ELECTRICAL
EQUIPMENT CONTROL
 V. Mariyappan the standard parallel port (SPP) and 0278 (hex) in place of 0378 (hex).
their traditional usage. The base ad- Fig. 1 shows the circuit for interfac-

C
ontrolling electrical devices dress of the first parallel port (LPT1) ing the PC’s parallel port to the devices
from a PC is great fun. Here is 378 (hex) or 888 (decimal). The data to be controlled. The parallel port out-
is a Windows-based program port of the parallel port can be accessed puts the control signals generated by
written in ‘C’ language for controlling at its base address. The status port can the software. The control signals are
up to eight devices from the PC’s par- be accessed at base address + 1, i.e., not continuous but a single clock pulse.
allel port termed as printer port (LPT). 0379 hex (or 889 decimal). The control For every ‘on’ or ‘off’ control, only a
The program accepts the input in deci- port can be accessed at base address single clock pulse is sent from the par-
mal numbers and outputs at the data + 2, i.e., 037A hex (or 890 decimal). allel port to the circuit.
output pins of the PC’s parallel port In case you are using LPT2 port, then Data pins D0 through D7 of the
for controlling the connected devices. substitute the base address of LPT2 as parallel port are connected to pin 1
of optocouplers IC5 through IC12 via
PC’s parallel port Parts List resistors R1 through R8, respectively.
The parallel port is made up of three Semiconductor: Optocouplers ensure complete isola-
IC1-IC4 - CD4013 D-type flip-flop
ports, namely, data port, status port IC5-IC12 - MCT2E optocoupler tion of the parallel port’s data pins
and control port. It is found on the IC13 - 7805 5V regulator from the relay driver circuit.
back of the PC as a D-type, 25-pin T1-T8 - BC548 npn transistor Each optocoupler consists of an
D1-D8 - 1N4007 rectifier diode
female connector. Here, we are con- BR1 - 1A, bridge rectifier
infrared light-emitting diode (LED)
cerned only with data lines D0 through and an npn phototransistor. When a
Resistors (all ¼-watt, ±5% carbon, unless
D7 terminated at pins 2 through 9. stated otherwise): high going pulse is available on the
The data port is a write-only port, R1-R8 - 100-ohm data pin, the internal LED drives
which means it can be used only to R9-R17 - 10-kilo-ohm the phototransistor of optocoupler
output data. Pins 18 through 25 of the Capacitors: MCT2E and it provides a clock pulse
connector are grounded. Control port C1 - 1000µF, 25V electrolytic to the corresponding flip-flop (IC
C2 - 0.1µF ceramic
is read/write capable, which means CD4013) section.
Miscellaneous:
it can be used both for outputting and IC CD4013 is a dual D-type flip-
RL1-RL8 - 5V, 100-ohm, 1C/O relay
inputting some data to/from the ex- S1 - Push-to-on switch flop with independent set, clear and
ternal hardware. Status port is a read- X1 - 230V AC primary to 9V, clock inputs and a single output. It
only port, which means it can be used 250mA secondary trans- accepts data when its clock pin is low
former
only to read data from the external and transfers it to the output on the
- 25-pin D-type parallel-port
hardware. male connector positive-going edge of the clock. The
Table below shows pin details of high Q output of the flip-flop drives
the corresponding transistor to ener-
gise the relay and switch on/off the
Pin Details of the Parallel Port device.
Pin number Traditional use Port name Read/Write Port address Port bit The flip-flops are set up for toggle
2-4 Data out Data port W Base D0-D2 mode by connecting their D inputs to
5-9 Data out — W Base D3-D7 Q outputs. Set inputs of all the flip-
1 Strobe Control port R/W Base+2 C0 flops are grounded. Switch S1 is used
14 Auto feed — R/W Base+2 C1 to reset the flip-flops manually.
16 Initialise — R/W Base+2 C2 Fig. 2 shows the circuit of the pow-
17 Select input — R/W Base+2 C3 er supply. The AC mains is stepped
15 Error Status port R Base+1 S3 down by transformer X1 to deliver
13 Select — R Base+1 S4 secondary output of 9V at 250 mA. The
12 Paper end — R Base+1 S5 transformer output is rectified by full-
10 ACK — R Base+1 S6 wave bridge rectifier BR1, filtered by
11 Busy — R Base+1 S7 capacitor C1 and regulated by IC13 to

78 Electronics projects Vol. 26


Fig. 1: Circuit diagram for computerised electrical equipment control

Electronics Projects vol. 26 79


provide regulated 5V the toggle flip-flop switches from ‘off’
supply. Capacitor C2 state to ‘on’ state to energise the relay
bypasses any ripple in and switch on the device. The status
the regulated output. of the corresponding device on screen
Before attempt- changes automatically.
ing to control the de- Similarly, to turn the device ‘off,’
vices, the program press the device number on the key-
(Control.exe) is to board. This again makes a high con-
be run. A screen as trol pulse available on the data pin
shown in Fig. 3 ap- and the corresponding toggle flip-flop
Fig. 2: Power supply circuit
pears which shows switches from ‘on’ state to ‘off’ state
the current status of to de-energise the relay and turn the
each device (on=1, device ‘off.’
off=0). To switch on The program can be terminated
a device, press the simply by pressing the ‘E’ key, but
corresponding device before that you should turn all the
number on the key- devices ‘off.’ If you try to terminate
board. This makes the program without shutting down
a high control pulse any of the devices, the message “Please
available on the data shutdown all the equipment” will ap-
Fig. 3: Screenshot of the main screen for computerised
pin of the respective pear on the screen for a short period
electrical equipment control parallel-port pin and followed by the main screen.

Fig. 4: Combined actual-size, single-side PCB layout for computerised Fig. 5: Component layout for the PCB
electrical equipment control and power supply circuits

80 Electronics projects Vol. 26


In case you press any invalid main screen. and and its component layout in Fig. 5.
key (not used in the software), the The combined single-side PCB Download source code: http://
message “Invalid key pressed wait 2 layout for the equipment control and www.efymag.com/admin/issuepdf/
seconds” is displayed followed by the power supply circuits is shown in Fig. 4 Equipment%20Control.zip

control.c
/*COMPUTERISED ELECTRICAL EQUIPMENT CON- tone(); printf(“\n\n\n\nPress any key”);
TROL*/ outportb(p,16); getch();
#include<stdio.h> delay(500); outportb(p,0);exit(0);
#include<conio.h> outportb(p,0); }
#include<dos.h> break;
void main() case ‘E’:
{ case ‘6’: if((a|b|c|d|e|f|g|h)==1)
void tone(void); f=!f; {
int p=0x0378; tone(); clrscr();
char ex[23]={“Created by V.MARIYAPPAN”}; outportb(p,32); textcolor(10);gotoxy(20,12);
int j; delay(500); cprintf(“PLEASE SHUT DOWN ALL THE EQUIP-
char ex1[34]={“For Further Details & Improvements”}; outportb(p,0); MENTS”);
int k; break; sound(200);
char ex2[40]={“Contact: Email-marietech2003@yahoo. delay(500);
co.in”}; case ‘7’: nosound();
int l; g=!g; delay(3000);
char ex3[23]={“Programming Language: C”}; tone(); break;
int m; outportb(p,64); }
int u[10]; delay(500); else
int i; outportb(p,0); {
static a,b,c,d,e,f,g,h; break; clrscr();
char no; for(j=0;j<23;j++)
clrscr(); case ‘8’: {
textcolor(15);gotoxy(20,6); h=!h; textcolor(10);gotoxy(20+j,12);
cprintf(“COMPUTERISED ELECTRICAL EQUIPMENT tone(); cprintf(“%c”,ex[j]);
CONTROL”); outportb(p,128); sound(2500+j);
textcolor(11);gotoxy(20,7); delay(500); delay(30);
cprintf(“-----------------------------------------”); outportb(p,0); nosound();
textcolor(11);gotoxy(10,10); break; }
cprintf(“EQUIPMENT NO: 1 2 3 4 5 6 7 for(m=0;m<23;m++)
8”); case ‘e’: {
textcolor(11);gotoxy(10,12); if((a|b|c|d|e|f|g|h)==1) textcolor(10);gotoxy(20+m,13);
cprintf(“STATUS: %d %d %d %d %d %d { cprintf(“%c”,ex3[m]);
%d %d”,a,b,c,d,e,f,g,h); clrscr(); sound(3500+m);
textcolor(10);gotoxy(9,16); textcolor(10);gotoxy(20,12); delay(30);
cprintf(“FOR ‘ON’ AND ‘OFF’ AN EQUIPMENT PRESS cprintf(“PLEASE SHUT DOWN ALL THE EQUIP- nosound();
CORRESPONDING EQUIP.NO.”); MENTS”); }
textcolor(11);gotoxy(28,18); sound(200); for(k=0;k<34;k++)
cprintf(“STATUS 0=OFF STATUS 1=ON”); delay(500); {
textcolor(12);gotoxy(32,20); nosound(); textcolor(10);gotoxy(20+k,14);
cprintf(“FOR EXIT PRESS ‘E’\n”); delay(3000); cprintf(“%c”,ex1[k]);
no=getch(); break; sound(3000+k);
switch(no) } delay(30);
{ else nosound();
case ‘1’: { }
a=!a; clrscr(); for(l=0;l<40;l++)
tone(); for(j=0;j<23;j++) {
outportb(p,1); { textcolor(10);gotoxy(20+l,15);
delay(500); textcolor(10);gotoxy(20+j,12); cprintf(“%c”,ex2[l]);
outportb(p,0); cprintf(“%c”,ex[j]); sound(3500+l);
break; sound(3000+j); delay(30);
delay(30); nosound();
case ‘2’: nosound(); }
b=!b; } printf(“\n\n\n\nPress any key”);
tone(); for(m=0;m<23;m++) getch();
outportb(p,2); { outportb(p,0);exit(0);
delay(500); textcolor(10);gotoxy(20+m,13);
outportb(p,0); cprintf(“%c”,ex3[m]); }
break; sound(1800+m); default:
delay(30); clrscr();
case ‘3’: nosound(); sound(500);
c=!c; } delay(100);
tone(); for(k=0;k<34;k++) nosound();
outportb(p,4); { textcolor(11);gotoxy(30,12);
delay(500); textcolor(10);gotoxy(20+k,14); cprintf(“INVALID KEY PRESSED”);
outportb(p,0); cprintf(“%c”,ex1[k]); textcolor(11);gotoxy(33,14);
break; sound(2000+k); cprintf(“WAIT 2 SECONDS”);
delay(30); delay(3000);
case ‘4’: nosound(); break;
d=!d; } }
tone(); for(l=0;l<40;l++) main();
outportb(p,8); { }
delay(500); textcolor(10);gotoxy(20+l,15); void tone(void)
outportb(p,0); cprintf(“%c”,ex2[l]); {
break; sound(2500+l); sound(1000);
delay(30); delay(100);
case ‘5’: nosound(); nosound();
e=!e; } } 

Electronics Projects vol. 26 81


Remote-Controlled
Stepper Motor
 N.C. Raghav Anand generated by alternately magnetising Parts List
the stator teeth electrically, and the

H
Semiconductors:
ere is a stepper motor system permanent magnet rotor teeth try to IC1 - TSOP1738 IR receiver
module
wherein the direction of ro- align up with the stator teeth. IC2 - CD4013 dual D-type flip-
tation of the stepper motor The coils are arranged around the flop
(in clockwise and anticlockwise direc- circumference of the stator in such a way IC3, IC8 - NE555 timer
IC4 - CD4029 up/down
tions) can be controlled remotely. Be- that if they are driven with square waves counter
sides, the speed can also be controlled which have a quadrature phase relation- IC5 - CD4028 BCD-to-decimal
locally. ship between them, the motor will rotate. decoder
IC6 - ULN2803 Darlington pair
A transition of either square wave causes driver
Stepper motor basics the rotor to move by a small angular IC7 - CD40106 NOT gate
A stepper motor converts electrical ‘step,’ hence the name ‘stepper motor.’ IC9 - 7805C 5V regulator
T1 - BC547 npn transistor
pulses into specific rotational move- The size of this angular step is de- D1-D10 - 1N4148 switching diode
ments. The movement created by each pendent on the teeth arrangement of BR1 - 500mA bridge rectifier
pulse is precise and repeatable. the motor, but a common value is 1.8 LED1 - Red LED
LED2 - Green LED
Stepper motors have teeth on both degrees, or 200 steps per revolution. - IR LED
the rotor and the stator. Torque is Speed control is achieved by sim-
Resistors (all ¼-watt, ±5% carbon):
ply varying R1, R6, R7, R10 - 330-ohm
the frequency R2 - 1-kilo-ohm
R3-R5 - 10-kilo-ohm
of the square
R8 - 3.3-kilo-ohm
waves. R9 - 5.6-kilo-ohm
R11 - 12-ohm
System VR1 - 100-kilo-ohm preset
overview VR2 - 4.7-kilo-ohm preset
Capacitors:
Fig. 1 shows C1 - 1µF, 16V electrolytic
the block dia- C2-C4 - 0.01µF ceramic disk
gram of the IR C5 - 1000µF, 16V electrolytic
C6 - 0.1µF ceramic disk
remote control
Fig. 1: Block diagram of IR remote control system for stepper motor system for the Miscellaneous:
X1 - 230V AC primary to 3V-
stepper motor. 0-3V, 350mA secondary
The pulse generator provides clock transformer
pulse to the up/down counter. The S1, S2 - Push-to-on switch
Battery - 6V battery
four parallel BCD outputs of the - Stepper motor
counter are converted into one-of-
ten active-high outputs by the BCD-
to-decimal decoder. The decoded circuit of the IR transmitter. The
outputs are fed to the stepper motor transmitter circuit, powered by a 6V
driver to drive the stepper motor. battery, is built around timer NE555
The 38kHz infrared signal (IC8), which is wired as an astable
transmitted by the IR transmitter multivibrator having a frequency of
is received by the IR receiver to around 38 kHz.
control the direction of rotation The frequency of the astable is de-
of the stepper motor. The pulse cided by resistor R10, preset VR2 and
generator can control the speed of capacitor C3. Preset VR2 is used to set
the motor. the frequency to 38 kHz. The output
of IC8 is fed to an infrared LED via
Circuit description current-limiting resistor R11. When
Fig. 2: IR transmitter IR transmitter. Fig. 2 shows the switch S3 is pressed, the IR LED trans-

82 Electronics projects Vol. 26


Fig. 4: Power supply

mits 38kHz modulated low with the help of switches S2 and


infrared signal. S1, respectively.
Receiver-cum-step- Set and Reset pins (pins 4 and 6)
per motor driver. Fig. are normally pulled down by resis-
3 shows the circuit of tors R4 and R5, respectively. These are
the receiver-cum-stepper also connected to switches S1 and S2,
motor driver. The trans- respectively. LED1 and LED2 indicate
mitted 38kHz modulated the clockwise and anticlockwise direc-
signal is received by tion of rotation of the stepper motor.
infrared receiver module The Q output of IC2 controls the up/
TSOP1738 (IC1) and it down pin and parallel input pins P0
outputs a clock pulse to and P3 of IC4 (CD4029).
D-type flip-flop CD4013 Timer NE555 (IC3) is configured
(IC2) via transistor T1. as an astable multivibrator whose
IC2 accepts data frequency is determined by resistors
when its clock input is R8 and R9, preset VR1 and capacitor
low and transfers it to C1. Preset VR1 is used to vary the fre-
the output on the pos- quency and consequently the speed of
itive-going edge of the the stepper motor.
clock. IC2 is configured IC3 provides clock input to up/
as a toggle flip-flop as down counter IC CD4029 (IC4). IC
its Q output is connected CD4029 is a presettable up/down
to ‘D’ input. Thus when counter that counts in either binary or
TSOP1738 receives a sig- decade mode depending on the volt-
nal from the transmitter, age level applied at its B/D pin. The
it clocks IC2 and its Q B/D input (pin 9) of IC4 is grounded to
output changes from configure it as decade counter.
high to low and vice Counter IC4 advances one count
versa on alternate clock for low-to-high transition of the clock
inputs. Consequently, pulse when its CE and PL pins are low.
Fig. 3: IR receiver-cum-stepper motor driver circuit

the state of Q output of It counts up when its up/down input is


IC2 controls the direction high, and vice versa. The count-enable
of the stepper motor. input (pin 5) and preset inputs P1 and
When Q output is high P2 are grounded, while the parallel-
the stepper motor rotates load input pin (PL) is controlled by Q4
in clockwise direction, and Q5 output pins of IC5. Q0 through
and when Q output is Q3 outputs of IC4 are connected to A0
low the stepper motor through A3 inputs of IC5 (CD4028).
rotates in anti-clockwise IC CD4028 is a 4-bit BCD-to-one-
direction. The direction of-ten active-high output decoder.
of rotation can also be BCD inputs A0 through A3 make the
controlled manually by selected output high, while the other
setting Q output high or nine outputs remain low.

Electronics Projects vol. 26 83


W h e n
the Q output
of IC2 goes
high, the
counter (IC4)
is enabled for
up counting
Fig. 5: Actual-size, single- with paral-
side PCB for IR transmitter
lel inputs P0
and P3 going
low. Decoder
(CD4028)
outputs Q0
through Q3
go high one Fig. 7: Actual-size, single-side PCB for IR receiver-cum-stepper motor driver circuit
after another
according to
Fig. 6: Component layout for
the transmitter PCB IC4 outputs.
When Q4
output of IC5
goes high, the 0000H parallel input
data at P0 through P3 pins is loaded
into the CD4028 (IC4). The counter
starts counting afresh in up mode.
When Q output of IC2 goes low,
the counter (IC4) is configured for
down counting and its parallel inputs
P0 and P3 become high. In down
counting mode, Q9 down through
Q6 outputs of the decoder (IC5) go
high one after another. As soon as
Fig. 8: Component layout for the receiver-cum-driver PCB
Q5 output of the decoder goes
high, the 1001H parallel input is rectified by bridge rectifier
data is loaded into the counter and it BR1, filtered by capacitor C5 and
again starts counting down from Q9 regulated by IC9 to provide 5V
through Q6. regulated supply. Capacitor C6
The four outputs Q0 through Q3, bypasses any ripple in the regu-
and Q6 through Q9, of IC5 are ORed lated output.
via diodes D1 through D8 driving the
stepper motor in clockwise or anti- Construction
clockwise direction. The four ORed out- Actual-size, single-side PCB
puts of IC5 are connected to eight input layouts for the IR transmitter
pins (two each in parallel) of IC ULN and receiver-cum-stepper motor
2803. The combined waveforms for Fig. 9: Combined waveforms for clockwise and anti-
driver circuits (Figs 2 and 3) are
clockwise and anti-clockwise rotation clockwise rotation shown in Figs 5 and 7, and their
are shown in Fig. 9. component layouts in Figs 6 and
IC ULN2803 consists of eight The low output of IC ULN2803 provides 8, respectively.
Darlington-pair driver transistors. It path for the current and the coils ener- Mount bases for the ICs on the PCB
is basically an inverter that when fed gise one by one to rotate the stepper mo- so that these can be removed easily
with positive input generates negative tor in clockwise/anticlockwise direction. when required. Normally, six wires
output. Stepper motor coils A, B, C and Power supply. Fig. 4 shows the of different colours are available for
D are connected to output pins 17-18, circuit of the power supply. The AC connection to the stepper motor. The
15-16, 13-14 and 11-12 of ULN2803, re- mains is stepped down by transformer colour code for connecting the stepper
spectively, with their common terminal X1 to deliver a secondary output of 3V- motor coils to the driver outputs is
E connected to the 5V power supply. 0-3V, 350 mA. The transformer output shown in Fig. 3. 

84 Electronics projects Vol. 26


Digital Stopwatch
 Raj K. Gorkhali NAND gate IC CD4011B, presettable 3.579545 MHz. An internal pulse is
divide-by-‘n’ counter IC CD4018B, bi- generated by mask programming the

T
his digital stopwatch can count nary coded decimal (BCD) up-/down- combinations of stages 1 through 4,
up to 99.9 seconds with a reso- counter IC 4510B, BCD-to-7 segment 16 and 17 to set or reset the individual
lution of 0.1 second (or in steps latch/decoder/driver IC 4511B and stages.
of 0.1 second) or up to 999 seconds common-cathode display IC LTS543. IC MM5369 advances by one count
with a resolution of 1 second. This Fig. 2 shows internal connections on the positive transition of each clock
has been made possible by employing and block diagram of IC MM5369, pulse. Two buffered outputs are avail-
clock frequency options of 10 Hz and 1 which is commonly used for gen- able: the crystal frequency for tuning
Hz, respectively. erating clock pulses in digital time- purposes and the 17th-stage output.
The stopwatch can be used to ac- pieces. The MM5369 is a CMOS IC The IC is available in an 8-lead as well
curately measure short time intervals. with 17 binary divider stages that as 14-lead dual-in-line epoxy package
It is portable and operates off four 1.5V can be used to generate a precise and features:
rechargeable Ni-Cd cells. reference from commonly available 1. Crystal oscillator
high-frequency quartz crystals of 2. High speed (4 MHz at 10V Vdd)
Circuit description 3. Wide supply
Fig. 1 shows the block diagram of the range of 3V to 15V
digital stopwatch. It comprises clock 4. Low power
generator IC MM5369, quad 2-input 5. Fully static
operation
Parts List
6. Low current
Semiconductor:
IC1 - MM5369 17-stage Fig. 3 shows
oscillator/divider the circuit of the
IC2 - CD4011B quad 2-input
digital stopwatch.
NAND gate
IC3, IC4 - CD4018B presettable IC MM5369 (IC1)
divide-by-‘n’ counter along with resistor
IC5, IC6, IC7 - CD4510B BCD up-/down- Fig. 1: Block diagram of digital stop watch R1, capacitors C1
counter
IC8, IC9,
IC10 - CD4511B BCD-to-7
segment latch/decoder/
driver
DIS1-DIS3 - LTS543 common-cathode,
7-segment display
LED1 - Red LED
Resistors (all ¼-watt, ±5% carbon):
R1 - 2.2-mega-ohm
R2, R27 - 1-kilo-ohm
R3, R4 - 22-kilo-ohm
R5-R25 - 330-ohm
R26, R28 - 680-ohm
Capacitors:
C1, C2 - 33pF ceramic disk
C3 - 0.0022µF ceramic disk
Miscellaneous:
XTAL - 3.579545MHz crystal
S1-S3 - Miniature pushbutton
microswitches
S4 - SPDT switch
S5, S6 - On/off switch
- 14- and 16-pin IC bases
- Nickel-cadmium cells
1.5V (4 Nos)
- Multistrand wires
- Solder metal
- Suitable mounting
cabinet
Fig. 2: Internal connections and block diagram of IC MM5369

Electronics Projects vol. 26 85


Fig. 4: Pin configuration of
IC LTS543

and C2, and 3.579545MHz


crystal generates a 60Hz
clock signal at its output
pin 1. This 60Hz clock sig-
nal is fed to IC CD4018B
(IC3) via an arrangement
of NAND gates.
Whenever the start
switch is pressed momen-
tarily, pin 4 and therefore
pin 2 of IC CD4011B (IC2)
goes high to enable NAND
gate N1 and the clock
signal is passed onto IC
CD4018 (IC3). When stop
switch S2 is pressed mo-
mentarily, NAND gate
N1 is disabled due to pin
4 of IC2 going low and the
clock pulses don’t reach
IC3.
IC3 and IC4 (each
CD4018B) are presettable
divide-by-‘n’ counters,
where ‘n’ could be 2, 3, 4,
5, 6, 7, 8, 9 or 10. IC3 has
been wired as a divide-by-6
counter by feeding its O2
output back to data input
pin 1. IC4 has been wired as
a divide-by-10 counter by
feeding its O4 output back
Fig. 3: Circuit of the digital stop watch

to data input pin 1.


For 60Hz clock input,
IC3 outputs a 10Hz clock
signal. This clock signal is
fed to IC4 and it outputs a
1Hz clock signal. Switch
S4 is used to select the re-
quired frequency.
IC5, IC6 and IC7

86 Electronics projects Vol. 26


Fig. 7: Proposed display panel box

(each CD4510B) are presettable up/


down BCD decade counters. These
counters are connected in a cascade
arrangement and can count up to
999 clock pulses. Therefore, when
fed with a 1Hz clock, the maximum
time delay achieved between start
and stop operations is 999 seconds.
Similarly, when the clock frequency
is chosen to be 10 Hz and decimal-
point switch S5 is flipped to ‘on’ po-
sition, the maximum attainable time
delay is 99.9 seconds.
Fig. 5: Actual-size, single-side PCB layout for the digital stop watch Reset switch S3 can be used to
reset the counter to all zeros before
start. Usually, the reset terminal is
connected to ground via resistor R27.
It is connected to +5V when you mo-
mentarily press reset switch S3 to reset
the counter.
IC8, IC9 and IC10 (each CD4511B)
are BCD-to-7-segment latch/decoder/
driver ICs. These can directly drive
7-segment, common-cathode LED
displays.
DIS1, DIS2 and DIS3 (each IC
LTS543) are 7-segment displays of
common-cathode type. Pin configura-
tion of IC LTS543 is shown in Fig. 4.
R5 through R25 are current-limiting
resistors.

Construction
A single-side, actual-size PCB for the
digital stopwatch is shown in Fig. 5
and its component layout in Fig. 6. The
proposed display panel box is shown
in Fig. 7. All the 7-segment displays,
LED1 and switches are mounted on the
Fig. 6: Components layout for the PCB front panel. 

Electronics Projects vol. 26 87


Infrared Interruption
Counter
 Pradeep G. on the IR sensor (receiver). IC 7805 (IC1) to provide regulated 5V
When somebody crosses the path supply for the transmitter and infrared

M
ost optical interruption of the IR beam falling on the sensor, receiver-cum-counter stages. Capacitor
counters make use of a light the triggering circuit activates to trig- C5 bypasses any ripple in the regulated
bulb with light-dependent ger the monostable multi-
resistor (LDR) or ordinary phototrans- vibrator. The output of the
istor as the sensor. These interruption monostable advances the
counters work satisfactorily in dark- count of the 4-digit coun-
ness only and cannot be used outdoors ter-cum-display driver to
because of the chances of false count- display the count on 7-seg-
ing due to light sensed from other light ment, common-cathode
sources like sun, light bulb, etc. displays.
The interruption counter described
here uses an infrared (IR) sensor that Circuit description
can sense a particular modulated The infrared interruption
frequency of infrared beam. A small counter circuit consists of
transmitter circuit employing an IR power supply, transmitter
LED is used to emit modulated IR and infrared interruption Fig. 3: IR transmitter circuit
signals. counter stages.
Parts List
The block diagram of the infrared Power supply. Fig. 2 shows the
Semiconductors:
interruption counter providing an power supply circuit. The AC mains
IC1 - 7805 5V regulator
overview of the system is shown in Fig. is stepped down by transformer X1 to IC2, IC3 - NE555 timer
1. The astable multivibrator produces deliver secondary output of 9V at 500 IC4 - 74C926 display driver
36kHz frequency and npn transistor mA. The transformer output is rectified IR LED1 - IR transmitting LED
BC547 drives the IR LED to transmit by a full-wave bridge rectifier compris- IRX1 - TSOP1736 IR receiver
T1-T7 - BC547 npn transistor
the modulated infrared signal. The ing diodes D1 through D4, filtered by D1-D4 - 1N4007 rectifier diode
transmitted IR signal continuously falls capacitors C3 and C4, and regulated by D5 - 1N4148 switching diode
Resistors (all ¼-watt, ±5% carbon):
R1-R2 - 1-kilo-ohm
R3-R4 - 47-ohm
R5 - 2.2-kilo-ohm
R6, R8, R22 - 10-kilo-ohm
R7, R9, R10 - 100-kilo-ohm
R11-R17 - 1-kilo-ohm
R18-R21 - 1.5-kilo-ohm
VR1 - 4.7-kilo-ohm
Fig. 1: Block diagram of infrared interruption counter Capacitors:
C1, C2 - 0.22µF ceramic disk
C3 - 1000µF, 25V electrolytic
C4, C5,
C10, C11 - 0.1µF ceramic disk
C6, C7, C12 - 0.01µF ceramic disk
C9 - 47µF, 16V electrolytic
Miscellaneous:
X1 - 230V AC primary to
0-9V, 500mA secondary
transformer
S1 - Push-to-on switch
- IC bases
- Wires
Fig. 2: Power supply circuit

88 Electronics projects Vol. 26


Fig. 4: Circuit of infrared interruption counter

(Fig. 4) is built around IR receiver


TSOP1736 (IRX1) utilising timer NE555
(IC3), 4-digit counter-cum-display
driver IC 74C926 with multiplexed
7-segment output drivers (IC4), 7-seg-
ment common-cathode displays DIS1
through DIS4, BC547 npn transistors
and some discrete components.
IR sensor TSOP1736 is readily
available in the market. It is commonly
used in TV sets as a miniaturised re-
ceiver for IR remote control systems.
Fig. 5 shows the internal functional
block diagram and pin configuration
of IC 74C926.
Fig. 5: Internal pin configuration of IC 74C926 IR receiver module TSOP 1736 is
meant for pulsed
operation. When it
is exposed to con-
tinuous 36kHz mod-
ulated IR beam, its
output remains high
and the collector of
Fig. 7: Actual-size, single-side PCB Fig. 8: Component layout for the transistor T2 is held
for IR transmitter PCB in Fig. 7 low. During a brief
interruption of the
Fig. 6: Audible beeper (optional) Timer NE555 is wired as an astable IR beam, a low-to-high-to-low pulse
multivibrator whose frequency is set appears at the collector of transistor
output. at 36 kHz by adjusting preset VR1. The T2 to trigger the monostable formed
Transmitter stage. The transmitter npn transistor (T1) is used to drive IR by IC3. The monostable multivibra-
circuit (see Fig. 3) works off 5V regu- LED1, which can transmit modulated tor is set for a time delay of nearly
lated supply. It is built around timer IR signals up to around 7 metres with- half second. The 4-digit counter with
NE555 (IC2), npn transistor BC547, IR out any lense arrangement. multiplexed 7-segment output driv-
LED1 and some resistors and capaci- Infrared interruption counter stage. ers (IC 74C926) advances by one digit
tors. The IR interruption counter circuit for every clock pulse received from

Electronics Projects vol. 26 89


Fig. 9: Actual-size, single-side combined PCB layout for infrared Fig. 10: Components layout for the PCB in Fig. 9
interruption counter, power supply and beeper

the multivibrator. It can count up to output pulse from monostable IC3, 6) is shown in Fig. 9 with its components
‘9999.’ The counter can be reset to generated during an interruption, layout in Fig. 10.
zero at any time by pressing the reset will activate transistor T7 to drive the For easy servicing, use IC bases
microswitch. piezobuzzer for duration of the mono- to mount the ICs on the PCB. After
Thus the display, at any time, stable pulse. assembling the PCB, place it near the
shows the count of interruption of entry gate. Use long wires for connec-
the IR beam since the last reset. The Construction tions to the IR transmitter LED and IR
interruption counter can be employed An actual-size, single-side PCB layout receiver TSOP1736 so that these can be
as visitor counter or object counter in for the IR transmitter (Fig. 3) is shown taken out of the PCB and mounted on
industrial applications. in Fig. 7 and its components layout in the opposite pillars of the entry gate.
You can add a beeper circuit, as Fig. 8, while the combined PCB layout The transmitter should be oriented such
shown in Fig. 6, to provide an audible for the interruption counter (Fig. 4), that the transmitted IR ray directly falls
indication of each interruption. The power supply (Fig. 2) and beeper (Fig. on the receiver module. 

90 Electronics projects Vol. 26


Audio Mixer With
Multiple Controls
 Malay Banerjee IC 747 (IC3) is used for mixing several The overall gain of individual ampli-
inputs without any mutual interaction. fiers can be adjusted with the help of

W
hen recording sound from The two internal amplifiers share a
several orchestral instru- common bias network and power sup- Parts List
ments being played by dif- ply. The IC has short-circuit protection
Semiconductor:
ferent musicians using a single mi- and wide common-mode and differen- IC1 - 7812 +12V DC regulator
crophone, the only way to adjust the tial voltage ranges. IC2 - 7912 –12V DC regulator
sound balance is to change the posi- In this application, +12V and IC3 - 747 dual operational
amplifier
tion of the musicians relative to the –12V regulated DC supplies are used IC4 - TDA1524A stereo tone
microphone. When recording direct to for operation of IC 747. The micro- controller
stereo master tape, it’s crucial to make phone output signals M1 through IC5 - LM386 low-power audio
sure that all the voices and instruments M4, after their individual level ad- amplifier
D1-D4 - 1N4001 rectifier diode
sound right before you hit the record justments, are mixed and applied LED1, LED2 - 5mm light-emitting diode
button. across the differential input terminals
Resistors (all ¼-watt, ±5% carbon):
Here is an eight-input audio mixer (pins 1 and 2). Similarly, micro- R1-R8, R18,
circuit with bass, treble, volume and phone outputs M5 through M8 are R19 - 1-kilo-ohm
balance controls, which you can use applied across the differential in- R9-R11, R14 - 10-kilo-ohm
to balance sounds from all the sources put terminals (pins 7 and 6) of the R12, R15 - 33-kilo-ohm
R13, R16 - 4.7-kilo-ohm
until you have the desired mix. For second amplifier inside op-amp R17 - 2.2-kilo-ohm
capturing the sound from various IC 747 after their individual level ad- R20 - 10-ohm
sources, the audio mixer employs up justments. VR1-VR8,
to eight microphones. For level adjustment, logarithmic VR15 - 10-kilo-ohm log potmeter
VR9, VR10 - 10-mega-ohm linear
variable resistors VR1 through VR4 potmeter
Circuit description and VR5 through VR8, respectively, VR11-VR14 - 47-kilo-ohm linear
Fig. 1 shows the block diagram of are employed while feeding the potmeter
the audio mixing system along with output from respective microphones Capacitors:
the audio power amplifier, while the to the input of the two amplifiers C1-C8,
circuit of the audio mixer along with inside IC 747. The outputs of the C22-C25,
C31, C33-C35,
tone controller is shown in Fig. 2. The two amplifiers taken from pins 12 C38 - 0.1µF ceramic disk
power supply and audio power ampli- and 10, respectively, are combined at C9-C12, C41 - 10µF, 25V electrolytic
fier circuits are shown in Figs 3 and 4, the junction of resistors R9 and R10 C13, C14 - 15nF ceramic disk
C15, C39 - 100µF, 25V electrolytic
respectively. before feeding to the next stage (tone
C16, C19, C20,
Here, dual operational amplifier controller) via capacitor C12 (10 µF). C21 - 2.2µF, 25V electrolytic
C17, C18 - 56nF ceramic disk
C26-C29 - 47nF ceramic disk
C36 - 220µF, 25V electrolytic
C37 - 3.3µF, 25V electrolytic
C30, C32 - 1000µF, 25V electrolytic
C40 - 33nF ceramic disk
Miscellaneous:
X1 - 230V AC primary to
12V-0-12V, 1A secondary
transformer
S1-S3 - SPST on/off switch
Loud-
speaker - 8Ω, 1W loudspeaker
M1-M8, J1 - Audio input jack
RCA1,
RCA2 - Audio output RCA
connector
Fig. 1: Block diagram of the audio mixer with bass, treble, volume and balance controls

Electronics Projects vol. 26 91


for better bass response, a
12V supply can be used. A
good heat-sink is necessary
for longer life and better
performance of the IC.
Features of TDA1524A
are:
1. Simple construction
2. Low noise and distor-
tion
3. Switchable contour
(for quick changing of the
tonal response)
4. Its output can drive
most power amplifiers.
5. Bass emphasis can be
increased by incorporating a
double-pole, low-pass filter
6. Wide power supply
voltage range
General specifications
are:
1. DC input: 12V (typi-
cal)
2. DC battery: 35 mA
3. Maximum output: 3V
RMS
4. Maximum input: 2.5V
5. Maximum gain: 21.5
dB
6. Volume control range:
–80 to +121.5 dB
7. THD at 1 kHz: 0.3%
8. Ripple rejection at 100
Hz: 50 dB
Potmeters VR11, VR12,
VR13 and VR14 are meant for
adjustment of volume, bal-
ance, bass and treble, respec-
tively. Switch S2 is contour
switch, which can be used to
change the tonal response of
the of the IC. The outputs are
available at pins 8 and 11 for
right and left channel, respec-
Fig. 2: Circuit of audio mixer with bass, treble, volume and balance control tively. (EFY note. Since both
the left- and right-channel
potmeters VR9 and VR10, respectively. functions for bass and treble control, input pins 15 and 4 have been shorted
The amplified mixed signal output volume control with built-in contour in this application, the IC acts as a mono
of IC 747 is applied to shorted input (can be switched off) and balance. All volume/tone control circuit.)
pins 15 and 4 of stereo tone controller these functions can be controlled by Audio power amplifier. The audio
IC TDA1524A (IC4). TDA1524A is de- DC voltages or by single linear poten- amplifier circuit shown in Fig. 4 is
signed as an active stereo-tone/volume tiometers. This IC serves as an efficient optional. One can use much higher-
control for car radios, TV receivers tone controller. Although it may work power audio amplifier along with the
and mains-fed equipment. It includes reasonably well with 9V DC supply, audio mixer circuit.

92 Electronics projects Vol. 26


nation of a resistor
and a capacitor. If
only a capacitor is
put between pins 1
and 8 using switch
S3 as shown in Fig.
4, the gain would
increase to 200 (46
dB). The amplified
output is taken from
pin 5 and fed to the
loudspeaker through
electrolytic capacitor
Fig. 3: Power supply circuit
C39 (100 µF). The
higher the value of
of 1 watt. It gets +12V C39, the higher the pitch of the audio
DC supply at its pin 6. frequency response in the speaker.
The audio input from Power supply. The power supply
sources like Walkman section for the circuit is shown in Fig.
and audio mixer can 3. It consists of a step-down transform-
be fed to pin 3 of IC5 er (230V AC primary to 12V-0-12V, 1A
through volume con- secondary), bridge rectifier, filter net-
trol VR15. work and regulator ICs 7812 and 7912
The gain of LM386 to provide +12V and –12V regulated
is internally set to 20 DC outputs, respectively. When switch
to keep the external S1 is closed, the presence of power is
part count low. How- indicated by the glowing of LED1.
ever, to make LM386
a more versatile am- Construction
Fig. 4: Low-power audio amplifier circuit
plifier, pins 1 and 8 Assemble the circuit on any general-

Fig. 5: Combined actual-size, single-side PCB for audio mixer and power Fig. 6: Components layout for the PCB in Fig. 5
supply circuits

The low-power audio amplifier em- are provided for setting the gain—ex- purpose PCB. Mount IC bases on the
ploying IC LM386 (IC5) shown in Fig. ternally to any value between 20 and PCB. There is no soldering method that
4 can output a maximum audio power 200—by using an appropriate combi- is ideal for all IC packages. The use of

Electronics Projects vol. 26 93


circuit connections before switching on
the power supply.
2. Use a standard microphone at
the first input point M1 and then keep
it near an audio source. You can use
the power amplifier circuit given here
for testing or another higher-output
power amplifier.
3. Vary VR1 slowly until a clear
and distortion-free amplified output
Fig. 7: Solder-side PCB layout for the audio Fig. 8: Components layout for the PCB in Fig. 7
amplifier circuit
is obtained.
4. If the sound output is not clear
IC bases prevents damage to the ICs Note. If you are not using IC base and VR1 does not help, vary gain con-
while soldering and also makes it easy for TDA1524A, the maximum permis- trol VR9.
to replace them. Use audio input jack sible temperature of the solder is 260 5. If the problem still persists,
connectors for M1 through M8 input °C; solder at this temperature must not check volume, balance, bass and treble
points. Also use audio output connec- be in contact with the joint for more controls.
tors at the outputs of IC4. than five seconds. The total contact 6. Check the various controls in
A combined actual-size, single-side time of successive solder waves must your audio power amplifier section.
PCB layout for Figs 2 and 3 is shown not exceed five seconds while using 7. Repeat steps 2 through 5 for the
in Fig. 5 and its components layout in wave soldering. rest of the inputs. Having checked all
Fig. 6. The solder-side PCB layout for the inputs, now the audio mixer is
Fig. 4 is shown in Fig. 7 and its compo- Testing procedure ready for use. 
nents layout in Fig. 8. 1. After assembling the PCB, check the

94 Electronics projects Vol. 26


NOISE-MUTING FM RECEIVER
 Turjasu Pyne Parts List
Semiconductors:

T
IC1 - CXA1619S FM receiver
he tuning of a frequency- IC2 - 7806 +6V regulator
modulated (FM) receiver to IC3 - CD40106 hex inverter
IC4 - LM386 audio power
an FM radio station frequency amplifier
involves a lot of ‘hissing’ noise in T1 - BC548 npn transistor
BR1 - 1A bridge rectifier
between the stations, which is very D1 - 1N4148 switching diode
irritating for the operator and as D2- D4 - 1N4001 rectifier diode
such undesirable. Resistors (all ¼-watt, ±5% carbon):
Fig. 2: Internal circuit schematic around
Digital FM receivers are free pin 20 of CXA1619S R1 - 150-ohm
R2, R3 - 330-ohm
from this problem, because in them the R4 - 100-kilo-ohm
output is automatically clipped during frequency. In other words, this circuit R5 - 1-kilo-ohm
off-station gaps. However, digital FM mutes the output from an analogue R6 - 33-kilo-ohm
R7 - 68-kilo-ohm
receivers are comparatively much cost- FM receiver when its tuner circuit is R8 - 4.7-kilo-ohm
lier than their analogue counterparts. sweeping in between FM stations. R9 - 4.7-ohm
Analogue FM receivers employ Capacitors:
an LC tuning system that generates Circuit description C1 - 4.7µF, 16V electolytic
C2, C8, C9 - 22pF ceramic disk
‘hiss’ noise at the output, which re- The FM muting circuit has been config- C3 - 0.047µF ceramic disk
mains unclipped during off-station ured around a Sony CXA1619S AM/ C4 - 47nF ceramic disk
tuning. However, when the received FM receiver chip, which is available C5, C6 - 10µF, 16V electolytic
C7 - 3.3pF ceramic disk
signal level is adequate (i.e., when the in a 30-pin PDIP package. Sony FM C10, C11 - 0.02µF ceramic disk
receiver frequency is very close to an receiver chips are known for their su- C12 - 100µF, 25V electolytic
C13, C15, C17 - 0.1µF ceramic disk
FM transmitting station frequency), perior features and cost-effectiveness. C14 - 1000µF, 16V electolytic
the limiter circuit preceding the ratio The functional block diagram of the C16 - 0.04µF ceramic disk
detector circuit in an analogue FM re- chip is shown in Fig. 1. C18 - 1000µF, 35V electolytic
VC1, VC2 - 77pF trimmer
ceiver will clip/limit any noise riding A complete circuit of the FM re-
Miscellaneous:
the FM carrier. ceiver including the muting circuit X1 - 230V AC to 6V-0-6V,
The simple FM muting circuit de- and power supply is shown in Fig. 500mA secondary
scribed here eliminates this ‘hissing’ 3. Most of the FM kits available in transformer
RL1 - 5V, 500-ohm, open-type
noise from the output of an analogue the market also make use of Sony reed relay (PLA make)
FM receiver circuit when it is not reso- CXA1619S, which is a complete AM/ S1 - On/Off switch
CR1 - 10.7MHz, 2-pin ceramic
nating to any FM transmiting station’s FM receiver IC with very few external resonator
CR2 - 10.7MHz, 3-pin ceramic
resonator
LS1 - 8-ohm, 1W loudspeaker
- Headphone
- Battery 1.5V×4
J1 - Shorting jumper

components. It can operate at voltages


as low as 3V. Here, we have used a 6V
supply so that we can feed the output
of the receiver directly to a 32-ohm
headphone or to a low-power AF am-
plifier built around IC LM386. A 3-pin
jumper has been provided to enable
the desired selection.
The muting circuit makes use of
the tuning meter output at pin 20 of
CXA1619S. The internal circuit around
Fig. 1: Functional block diagram of Sony CXA1619S pin 20 of the chip is shown in Fig. 2.

Electronics Projects vol. 26 95


Normally, this pin is used for tuning
indication using a light-emitting diode
(LED). The cathode of the tuning indi-
cator LED is connected to pin 20, while
the anode of the LED is connected to
positive supply through a current-
limiting resistor.
When the receiver is tuned to
the centre of FM carrier, pin 20 of
CXA1619 goes very low and the LED
lights up the brightest.
Instead of connecting an LED, we
have coupled pin 20 of CXA1619S to
the input of a CMOS inverter gate via
diode D1. In ‘off’ tuning condition (when
the receiver is not tuned to any FM
station), input pin 1 of CMOS inverter
gate N1 (1/6 CD40106) is biased to
2/Vcc using a potmeter arrangement
comprising resistors R6 (33 kilo-ohms)
and R7 (68 kilo-ohms). Thus, in between
the FM stations, output pin 2 of the in-
verter gate remains low and therefore
transistor T1 (BC548) remains cut off
and the 5V inverter relay connected at
its collector remains de-energised.

Fig. 3: Complete circuit of the FM receiver including the muting circuit and power supply
However, when the receiver is
tuned to an FM station, its output
pin 20, as also input pin 1 of the CMOS
inverter gate, go low. As a result, the
output of the inverter gate goes high
to energise the relay via transistor T1.
The audio output from CXA1619S,
available at its pin 28, is passed via
100µF capacitor C12 and the contacts
of reed relay to either the headphones
or the AF amplifier circuit only when
the relay is energised, which happens
only when the receiver is tuned to the
carrier frequency of an FM station.
Thus the annoying noise output of
the receiver during ‘off’ station tun-
ing is not heard in the headphones or
the loudspeaker. In other words, the
circuit configured around the CMOS
inverter gate acts to mute the noise
output when the receiver is not tuned
to any FM transmitting station.
Power supply. The supply voltage
for inverter gate N1 (IC3), transistor T1 portable applications, four 1.5V cells use either a 75cm telescopic antenna or
and the FM receiver chip/kit has been may be used. Diode D3 in the power simply a wire of similar length.
derived from the output of IC 7806 so supply circuit ensures that when mains
that a regulated voltage is maintained is available, the battery output remains Circuit operation
across the entire circuit. Alternatively, isolated/not used. When no FM station is being received,
in the event of mains failure, and for Antenna. For antenna, you may diode D1 does not conduct and as

96 Electronics projects Vol. 26


Fig. 4: Actual-size, single-side PCB of noise-muting FM receiver Fig. 5: Component layout for the PCB

such, pin 1 of inverter gate N1 is held circuit needs no adjustments as the Construction
high while the output at pin 2 of the inverter gate has been kept biased to An actual-size, single-side PCB layout for
inverter remains low. Thus transistor 2/Vcc, and when a station is being the noise muting circuit for FM receiver
T1 does not conduct and relay RL1 re- tuned into the output at pin 20 of is shown in Fig. 4 and its component
mains cut off. So, whether the load is a CXA1619S starts falling, and when layout in Fig. 5. Provision for a jumper
headphone or an audio power amplifier the input of the CMOS gate goes be- has been made in the PCB so that either
stage driving a loudspeaker as shown low ½Vcc the logic state of the CMOS a headphone or AF amplifier circuit with
in Fig. 3, no audio will be heard in the changes abruptly and the FM station speaker may be used as desired.
headphones/speaker. In other words, can be heard via headphones or speak- This PCB can be fitted with a Phil-
when the receiver is not tuned to an FM er of the power amplifier. ips make miniature gang condenser or
station’s frequency, the audio output In case the receiver circuit uses equivalent for VC1 and VC2. For power
from CXA1619S is muted. only a headphone as load, you can do ‘on’/‘off’ switch S1 and volume control
This muting circuit may be incor- away with the audio power amplifier VR1, a switch-cum-volume control is
porated into any readily available FM circuit including the loudspeaker. Pot- used in the PCB. The terminals of this
receiver kit as long as the FM receiver meter VR1 serves as volume control switch-cum-volume control need to be
chip used in the kit has a metering pin for the headphones or the AF power directly soldered over the corresponding
for connecting an LED. The muting amplifier, whichever is in use. pads on the PCB. 

Electronics Projects vol. 26 97


PC-Based Stepper
Motor Controller
 Ashutosh M. Bhatt Specifications of the through T8.
stepper motor Transistors T1 through T8 are
BD139 type and should be used with

T
his stepper motor controller is Stepper motors of various ratings/ heat-sinks. Pin details of BD139 and
perhaps the cheapest, smallest specifications are available in the mar- regulator IC 7805 are shown in Fig. 2.
and simplest. A pair of H-bridg- ket for different applications. Here, the The bases of all the eight transistors are
es with a software program written stepper motor is taken from an 8.9cm connected to data pins (D0 through D7)
in ‘C++’ is used to control the bipolar (3.5-inch) floppy drive. It’s a bipolar of the 25-pin, D-type male connector
stepper motor with a step resolution of stepper motor rated at 5V through 1-kilo-ohm current
18 degree per pulse. DC with step resolution of limiting resistors R1 through
The controller is a combination 18o per pulse. The motor R8.
of driver and switching circuits. has two coils inside and The bases of transistors
The driver is the actual circuit that four terminals (colour- T1 and T4 are connected to
drives the stepper motor and the coded, but not always) for parallel-port pins 2 (D0) and
switching circuit decides how the mo- external connections. Step- Fig. 2: Pin details of 3 (D1) through resistors R1
tor should be driven. So, it is basically per motors rated at 5V and BD139 transistor and and R2, respectively, and the
regulator IC 7805
the switching circuit that controls the up to 1 ampere of current bases of transistors T2 and T3
motor. The transistors (T1 through and different step size (e.g., are connected to parallel-port
T8) act as switches. The switching of 1.8º per pulse) may also be used with pins 4 (D2) and 5 (D3) through resis-
these transistors is controlled by the this circuit and control software. tors R3 and R4, respectively. The red
software via data pins D0 through D7. and orange terminals of the first coil
You can control three parameters of Circuit description (COIL1) are connected to the first H-
the stepper motor: speed, direction and H-Bridge driver. H-Bridge is a stan- bridge section as shown in Fig. 1.
number of steps. To vary the speed of dard, well-known circuit widely used The bases of transistors T5 and
the motor, you have to vary the pulse as stepper motor driver. It is a bridge T8 are connected to pins 6 (D4) and
repetition frequency (PRF). To change connection of four transistors (see Fig. 7 (D5) through resistors R5 and R6,
the direction of the motor, you have to 1). Because there are two coils in the respectively, and the bases of transis-
change the sequence of pulses applied bipolar stepper motor, two H-bridge tors T6 and T7 are connected to pins
to its coils. By limiting the number of circuits, one for each coil, have been 8 (D6) and 9 (D7) through resistors
applied pulses, you can restrict the used. One H-bridge is formed by tran- R7 and R8, respectively. The yellow
motor to complete the desired number sistors T1 through T4 and the other and green terminals of the second
of steps. bridge is formed by transistors T5 coil (COIL2) are connected to the
second H-bridge section
as shown in Fig. 1.
Power supply. The
power supply section is
shown in Fig. 3. It consists
of a 230V AC to 9V AC,
1A secondary transformer
(X1), filter, bridge recti-
fiers and 5V DC regulator
7805 (IC1). The regulated
5V DC is connected to
the H-bridge circuits. The
circuit ground is shorted
to pins 18 through 25 of
the D-type parallel-port
connector. When switch
Fig. 1: Circuit of PC-based stepper motor controller S1 is closed, LED1 glows

98 Electronics projects Vol. 26


to indicate the presence of power in
the circuit.

Operation
Specific sequence of pulses are given
to the red and orange terminals of
COIL1 and yellow and green terminals
of COIL2 to rotate the motor either in
clockwise or anticlockwise direction as
explained in the following paragraph.
Fig. 3: Power supply for the circuit
Direction control. In Tables I and
II, ‘0’ indicates low logic and ‘1’ indi- terminals should be high, while orange
cates high logic. We know that the cur- Table I and yellow terminals should be low.
rent flows from high to low. Changing Pulse Sequence to Rotate To achieve this, transistors T1, T4, T5
the direction of rotation is nothing but the Motor Clockwise and T8 should conduct. For this, hex
changing the direction of current that Data bit D7 D6 D5 D4 D3 D2 D1 D0 data word will be ‘33’ (0011 0011).
flows through the coils. Port pin 9 8 7 6 5 4 3 2 In the next phase, red and yellow
Speed control. To vary the speed, Phase 1 1 1 0 0 1 1 0 0 terminals should be low, while orange
you have to vary the pulse repetition Phase 2 0 0 1 1 1 1 0 0 and green terminals should be high. To
frequency (PRF). The PRF of 20 Hz Phase 3 0 0 1 1 0 0 1 1 achieve this, transistors T1, T4, T6 and
means 20 pulses will be given to the Phase 4 1 1 0 0 0 0 1 1 T7 should conduct. For the purpose,
stepper motor in one second. Since 1= High, 0 = low hex data word ‘C3’ (1100 0011) has to
the step resolution of the motor is 18o/ be output from the LPT port.
pulse, the motor will rotate 20x18o = Table II Thus the data sequence to be fed to
360o (one complete revolution) in one Pulse Sequence to Rotate the port for clockwise rotation of the
second. So the speed of the motor is the Motor Anti-clockwise motor is CC-3C-33-C3.
one revolution per second (RPS) or Anticlockwise rotation. To rotate
Data bit D7 D6 D5 D4 D3 D2 D1 D0
60 RPM. Now if you increase the PRF Port pin 9 8 7 6 5 4 3 2 the motor in anti-clockwise direction,
from 20 Hz to 40 Hz, the RPS will also the sequence of hex data to be output
Phase 1 1 1 0 0 1 1 0 0
double to 2 RPS (120 RPM). from the LPT port will be CC-C3-33-
Phase 2 1 1 0 0 0 0 1 1
Number of rotations. The step reso- 3C.
Phase 3 0 0 1 1 0 0 1 1
lution of 18°/pulse means if you apply Phase 4 0 0 1 1 1 1 0 0
only one pulse, the motor will rotate by The software
1= High, 0 = low
18°. If you apply 10 pulses sequentially, All the controlling actions are per-
the motor will rotate 180o (half of a tables. The current will flow into/out formed by the software program. The
revolution). So if you limit the number of the coils through the four terminals program is written in ‘C++’ language
of pulses applied to the motor, you can of the motor (red, orange, green and and compiled in Turbo C++ Version
stop it at any angular position (multi- yellow). 3. The complete software program
ple of 18°) after completing the desired Clockwise rotation. In the first (STEPCNT.CPP) is given at the end
number of full revolutions. Thus if you phase, orange and green terminals of this article along with necessary
apply only 25 pulses, the motor will should be high and red and yellow comments. You require the egavga.bgi
complete one full revolution and rotate terminals should be low. To achieve graphic file to be in the same directory
further by 90º (¼ revolution) and stop. this, out of the eight transistors, four as the application program to run the
H-bridge. The transistors in the transistors (T2, T3, T6 and T7) should program. The output of the program is
circuit act as switches. When high logic conduct. For this, you have to output shown in Fig. 4.
(3.49V) is applied to any data pin of hex data word ‘CC’ (1100 1100) from The main functions of the software
the port, the transistor connected to it the LPT port. are:
conducts and acts as a closed switch, In the second phase, red and yel- 1. Change the direction of rotation
allowing the current to pass through it. low terminals should be high, while of the stepper motor by switching the
When low logic (0.09V) is applied, the orange and green terminals should be eight transistors in proper manner.
transistor stops conducting and acts as low. To achieve this, only transistors 2. Vary the RPM of the stepper mo-
an open switch, so the current cannot T2, T3, T5 and T8 should conduct. For tor accurately.
pass through it. this, you have to output hex data word 3. Stop the motor at a given angular
The pulse sequences to be given ‘3C’ (0011 1100) from the LPT port. position after the desired number of
to switch the transistors are shown in In the next phase, red and green complete rotations

Electronics Projects vol. 26 99


The software is divided into three out of this bound-
parts: graphics, stepper motor control ary.
and mouse interfacing. The showmptr(
Graphics. The graphics part gener- ) function displays
ates complete view of the control panel. mouse pointer on
It draws buttons like clockwise, anti- the program screen.
clockwise and RPM increase/decrease, For this, you just
displays instructions, draws borderline, have to pass value
writes text like ‘RPM,’ ‘rotations,’ ‘num- ‘1’ through input
ber of rotations,’ etc. Graphic functions union REGS to the
are used to make the program output int86( ) function.
screen visually appealing. The showmptr( )
Stepper motor control. To change function will now
the direction of rotation of the motor, show mouse pointer
the program generates the desired Fig. 4: Screenshot of the program output on the screen.
pulse sequence, either CC-3C-33-C3 (to The getmpos(int
rotate the motor in clockwise direction) a factor of ‘0.5.’ The minimum limit is *t, int *u, int *v) function performs two
or CC-C3-33-3C (to rotate the motor in 0.25 (quarter revolution), but there is tasks: determines whether the mouse
anticlockwise direction), on the parallel no maximum limit. button is pressed or not, and captures
port with appropriate delay. The delay Mouse interfacing. This is the the current mouse pointer position
adjustment is done depending upon most interesting part of the program. from the screen. You have to pass
the RPM. It enables you to perform a task at a value ‘3’ through input union REGS to
To vary the RPM, the program var- click of mouse. To understand how the int86( ) function. This function will
ies the PRF. First, the current RPM (S) the mouse is interfaced, you have to go return ‘x’ and ‘y’ coordinates of the
is converted into RPS (S1) by dividing through the entire theory of hardware mouse pointer and also return value
it by ‘60’ as follows: interfacing using ‘C++.’ Here, only ‘1’ if the mouse button (left) is pressed
S1 = S some references have been made. For or ‘0’ if the button is not pressed.
60 details, refer to the ‘Mouse Interfac-
Now for one complete revolution, you ing’ chapter of ‘Let Us C’ book by How the program works?
have to apply 20 pulses. So the RPS Kanitkar. The program output screen includes
factor (S1) multiplied by ‘20’ will give In this program, the functions that the control panel for speed, direction
you the desired PRF. handle the mouse event are initmouse( and number of rotations of the step-
The delay (d) between the pulse ), resmptr(int p, int q, int r, int s), per motor.
sequences is given by: showmptr( ) and getmpos(int *t, int The program continuously checks
*u, int *v). for mouse-click event. Whenever
The initmouse( ) function loads
d = 1000 = 50 milliseconds there is a mouse click, the getmpos( )
20×S1 S1 mouse driver into the program. You’ve function instantly captures ‘x’ and ‘y’
to pass ‘0’ value through input union coordinates of the mouse pointer and
When RPM is greater than ‘10,’ you can REGS to the int86( ) function. This passes them to the main program.
increase or decrease the RPM by a factor function will return some non-zero The main program decides on
of ±10. For RPM less than ‘10,’ you can value through output union REGS to which position the click event has oc-
increase or decrease it by ±1 only. There the main program. If this function cured. If the click event occured on any
is no limit on the maximum RPM but the returns ‘0,’ it means the mouse driver button (clockwise, anti-clockwise, etc),
minimum limit is 1 RPM. is not loaded. So the program displays it performs the desired task. For exam-
As stated earlier, 20 sequential the message “mouse driver is not ple, if you click the ‘RPM increase’ but-
pulses are required for a complete loaded” and shuts the screen off using ton, the program gets the coordinates
revolution of the stepper motor. Since the exit( ) function. and directly switches them to ‘if’ loop,
a sequence of four pulses is repeated The resmptr(int p, int q, int r, int increases the RPM and also displays it
(for clockwise or anticlockwise move- s) function restricts mouse movement on the screen.
ment), we may say that a revolution of within the boundary specified by the
the stepper motor involves five identi- four variables passed to it. Pass all Construction and
cal sequences of four pulses. You can these boundary limits through input operation
increase or decrease the number of union REGS to the int86( ) function. Construct the hardware on a bread-
rotations linearly by ±1. For ‘N’ below So the resmptr(int p, int q, int r, int s) board or on a PCB. An actual-size,
‘1,’ you can decrease or increase ‘N’ by function will restrict mouse movement single-side PCB layout is shown in

100 Electronics projects Vol. 26


Fig. 5 and its component layout in Fig. program will now
6. Connect the bases of the transistors display the PRF
to the respective data pins of the port (=20 Hz) and the
DB25 (25-pin, D type male connector) current RPM (=60)
as shown in Fig. 1. Insert DB25 into the with a melodious
PC’s LPT-port female connector. Con- sound output.
nect all the coil terminals (red, orange, If the motor
green and yellow) to respective points doesn’t rotate, it
as shown in the schematic. means you have
Apply 5V DC supply to the circuit connected its four
and connect the 5V stepper motor terminals wrongly.
with its terminals as shown in Fig. 1. Fig. 5: Actual-size, single-side PCB layout for PC-based You can correct
stepper motor controller
Now run the program on a computer this using trial-
powered by Windows 95/98 operating and-error method.
system. You will see the control panel If the motor runs
on the computer screen. Switch on the in a direction op-
5V supply and LED1 will glow. Move posite to that you
the mouse pointer to any of the buttons have selected, just
as desired. reverse one pair of
To rotate the motor clockwise, the coil terminals.
press and hold ‘clockwise’ button with Because you
left mouse button on the control panel. have entered
Similarly, for anticlockwise rotation, one rotation
press and hold ‘anticlockwise’ button. with 60 RPM,
The motor will rotate in the desired Fig. 6: Component layout for the PCB the motor will
direction along with the beep sound complete only
as long as the button is kept pressed. ber of rotations by the same amount. one rotation in one second. If
When you release the button, the beep The RPM and the number of rota- it doesn’t, your stepper motor
sound as well as the motor will stop. tions are perfectly calibrated for this has some different specification.
If the motor rotates in anticlock- particular stepper motor and you will To check the specifications of the
wise direction when you press ‘clock- get the accurate result for the RPM. stepper motor, in the sample pro-
wise’ button, just reverse any pair of That means if you choose 1 RPM, the gram select RPM as ‘5’ and change
terminals of the motor coils. motor will complete one revolution the number of rotations (like 1.25,
Run the stepcnt.exe file on your in one minute exactly. For the num- 1.5, etc) to get the step resolution.
computer. You will see the control ber of rotations also, if you choose The delay factor (d) can be changed
panel for the stepper motor control- one rotation, the motor will complete in the software. When you are satis-
ler on your screen. Default RPM and only one rotation. If you choose 0.25, fied with the result, switch to main
number of rotations are 60 RPM and 1, the motor will complete only quarter program ‘stepcnt.exe’
respectively. If you press ‘clockwise’ or revolution (90o). In case you wish to use the step-
‘anticlockwise’ button, the motor will Note. The stepper motor you per motor with a step size of 1.8º per
rotate until the desired rotations com- choose should have the same specifi- pulse, the software program for the
plete. You can increase or decrease the cations as given in this project. In the same will differ. The same is included
RPM or even the number of rotations program, first enter RPM as ‘60’ and in the source code download folder.
by simply left-clicking that button once. then the number of rotations as ‘1.’ Download source code: http://
Pressing these buttons more than once Select clockwise or anticlockwise di- www.efymag.com/admin/issuepdf/
will increase/decrease the RPM/num- rection and then press ‘Enter’ key. The Stepper%20Motor%20Control.zip

Stepcnt.cpp
#include<graphics.h> driver = DETECT; rotations = 1
#include<conio.h> int initmouse(); // to load mouse driver float r=1,n=5;
#include<dos.h> int resmptr(int p,int q,int r,int s); //restric mouse initgraph(&driver, &mode, “C:\\tc\\bgi”); //initial-
#include<process.h> pointer within boundry ize graphics mode
#include<iostream.h> int showmptr(); // shows mouse pointer outport(0x0378,0x00); // clear parallel port
union REGS i,o; int getmpos(int *t,int *u, int *v); // captures the cur- if(initmouse() == 0)
void main() rent position of mouse pointer { // load mouse driver if not
{ int text(int e,int f); // changes the size and color closegraph(); // exit the
int driver,mode,x,y,but; //intialitions of all vari- of text program
ables and functions float s1,d=50,s=60; // default RPM=60 and no. of restorecrtmode();

Electronics Projects vol. 26 101


cout<<”\nMouse driver not loaded”; { if(r<1) r=r*2;
exit(1); text(6,13); // when this button is pressed
} outtextxy(360,140,”Anticlockwise”); else r++; // increase no. of rota-
gotoxy(14,10); for(int i=1;i<=n;i++) tion
cout<<s; // display current RPM { gotoxy(71,10); // if rotations are <
gotoxy(71,10); // and no. of rotations sound(750); 1 then
cout<<r; outport(0x0378,0xcc); cout<<r; // double it every
showmptr(); delay(d); time
resmptr(30,30,635,460); outport(0x0378,0xc3); n=r*5; // otherwise increase it
setcolor(LIGHTRED); delay(d); linearly
rectangle(30,30,635,460); //Border line outport(0x0378,0x33); text(6,4);
rectangle(70,135,160,165); //RPM Box delay(d); outtextxy(390,245,”Increase”);
rectangle(520,135,610,165); //No.of Rotation box outport(0x0378,0x3c); } // fifth if ends
setfillstyle(SOLID_FILL,YELLOW); delay(d);
rectangle(180,130,320,170); nosound(); else if(x>=500 && x<=590 && y>=240 &&
floodfill(202,132,LIGHTRED); //clockwise button } // for loop ends y<=270 && (but & 1) == 1)
rectangle(80,240,170,270); text(6,4); {
floodfill(82,242,LIGHTRED); //RPM inc button outtextxy(360,140,”Anticlockw gotoxy(67,10);
rectangle(350,130,490,170); ise”); cout<<” “;
floodfill(352,132,LIGHTRED); //anticlockwise } //second if ends text(6,2);
button outtextxy(510,245,”Decrease”);
rectangle(200,240,290,270); else if(x>=80 && x<=170 && y>=240 && y<=270 && sound(1000);
floodfill(202,242,LIGHTRED); //RPM dec button (but & 1) == 1) delay(200);
rectangle(380,240,470,270); { nosound();
floodfill(382,242,LIGHTRED); //rotation inc button gotoxy(10,10); if(r>1)
rectangle(500,240,590,270); cout<<” “; {
floodfill(502,242,LIGHTRED); //rotation dec button text(6,2); r--; // when this button
line(125,220,245,220); outtextxy(90,245,”Increase”); is pressed
line(425,220,545,220); sound(1000); gotoxy(71,10); // decrease No. of
line(185,220,185,210); delay(200); rotations
line(485,220,485,210); nosound(); cout<<r; // till r=0.25 if r<0.25
line(245,220,245,240); if(s>=10) s=s+10; stop decreasing
line(545,220,545,240); else s++; // when this button } //and display a massage
line(125,220,125,240); is pressed else
line(425,220,425,240); s1 = s/60; // increase current {
text(8,13); RPM and also if(r>0.25)
outtextxy(195,60,”-: Control Panel :-”); d = 50/s1; // change delay {
text(6,4); gotoxy(14,10); r=r/2;
outtextxy(60,290,”Instructions :-”); cout<<s; gotoxy(71,10);
outtextxy(210,140,”Clockwise”); text(6,4); cout<<r;
outtextxy(360,140,”Anticlockwise”); outtextxy(90,245,”Increase”); }
outtextxy(90,245,”Increase”); } // third if ends else
outtextxy(210,245,”Decrease”); {
outtextxy(390,245,”Increase”); else if(x>=200 && x<=290 && y>=240 && gotoxy(67,10);
outtextxy(510,245,”Decrease”); y<=270 && (but & 1) == 1)
setcolor(10); { cout<<”Ooppps...”;
outtextxy(175,190,”RPM”); gotoxy(10,10); }
outtextxy(445,190,”Rotations”); cout<<” “; }
outtextxy(60,110,”Current RPM”); text(6,2); n=r*5;
outtextxy(495,110,”No.of Rotations”); outtextxy(210,245,”Decrease”); text(6,4);
text(5,10); sound(1000); outtextxy(510,245,”Decrease”);
outtextxy(70,310,”# Press ‘Clockwise’ button to rotate delay(200); } // last if ends
Stepper Motor clockwise”); nosound(); } // while loop ends
outtextxy(70,330,”# Press ‘Anticlockwise’ button to if(s>10) } // main ends
rotate Stepper Motor anticlockwise”); {
outtextxy(70,350,”# Press ‘increase’/’decrease’ button s=s-10; // when getmpos(int *but,int *x,int *y)
to change the RPM”); this button is pressed {
outtextxy(70,370,”# Press ‘increase’/’decrease’ button gotoxy(14,10); // i.x.ax = 3;
to change the No. of rotations”); decrease it till s>1 int86(0x33,&i,&o);
setcolor(13); cout<<s; // if *but = o.x.bx;
outtextxy(95,400,”Stepper Motor control using C++ s<=1 stop decreasing *x = o.x.cx;
design and developed by”); } // and *y = o.x.dx;
outtextxy(250,420,”Ashutosh Bhatt”); display massage }
setcolor(YELLOW); else initmouse()
outtextxy(200,440,”Press any key to exit program”); { {
while(!kbhit()) // loop until any key is pressed if(s>1) i.x.ax = 0;
{ { int86(0x33,&i,&o);
getmpos(&but,&x,&y); // capture s--; return(o.x.ax);
current pointer position when click event happens gotoxy(14,10); }
if(x>=200 && x<=300 && y>=130 && y<=170 && (but cout<<s; showmptr()
& 1) == 1) // and switch to that if loop } {
{ else i.x.ax = 1;
text(6,13); { int86(0x33,&i,&o);
outtextxy(210,140,”Clockwise”); gotoxy(11,10); }
for(int i=1;i<=n;i++) cout<<”min limit”; resmptr(int a,int b,int c,int d)
{ } {
sound(500); } i.x.ax = 7;
outport(0x0378,0xcc); s1 = s/60; i.x.cx = a;
delay(d); d = 50/s1; i.x.dx = c;
outport(0x0378,0x3c); text(6,4); int86(0x33,&i,&o);
delay(d); outtextxy(210,245,”Decrease”); i.x.ax = 8;
outport(0x0378,0x33); } // forth if ends i.x.cx = b;
delay(d); i.x.dx = d;
outport(0x0378,0xc3); else if(x>=380 && x<=470 && y>=240 && int86(0x33,&i,&o);
delay(d); y<=270 && (but & 1) == 1) }
nosound(); { text(int e,int f)
} //for loop ends gotoxy(67,10); {
text(6,4); cout<<” “; setcolor(f);
outtextxy(210,140,”Clockwise”); text(6,2); settextstyle(SMALL_FONT,HORIZ_DIR,e);
} // first if ends outtextxy(390,245,”Increase”); } 
sound(1000);
else if(x>=350 && x<=490 && y>=130 && y<=170 delay(200);
&& (but & 1) == 1) nosound();

102 Electronics projects Vol. 26


Automatic 3-pHASE iNDUCTION
mOTOR sTARTER
 R. Lakshmanan windings in star configuration. Under Parts List
this connection, the voltage across the Semiconductors:

S
IC1 - NE555 timer
tarters for 3-phase squirrel-cage windings is 1/√ 3 of line-to-line sup- T1 - BC557 pnp transistor
induction motors often use star- ply voltage and so the current flowing T2 - BC547 npn transistor
to-delta converters. The stator through each winding is also reduced D1- D16 - 1N4007 rectifier diode
D17 - 1N4148 switching diode
coils of the motor are connected in star by this factor. Compared to delta con- LED1 - Green LED
configuration at the time of power-on nection, the resultant current flowing LED2 - Red LED
and switched to delta configuration from the supply, as also the torque, Resistors (all ¼-watt, ±5% carbon):
when the motor reaches 3/4th of its is reduced by a factor of 1/3 in star R1 - 56-kilo-ohm
R2-R5 - 1-kilo-ohm
full speed, after the stator coils have configuration. The relevant equations VR1 - 470-kilo-ohm preset
developed sufficient back electromag- for star and delta connections are given Capacitors:
netic force (emf). in the box. C1 - 1000µF, 25V electrolytic
The starter circuit presented here As soon as the moment of inertia C2, C3 - 10µF, 25V electrolytic
C4 - 470µF, 25V electrolytic
offers two main advantages: single- is overcome, and sufficient back emf C5 - 0.01µF ceramic disk
phase prevention and automatic star- is induced in the stator windings, the Miscellaneous:
to-delta conversion. It can be used only star connection is opened and the ends X1-X3 - 230V AC primary to
12V, 300mA secondary
with those motors which are rated for of the windings are connected to the transformer
connection in delta configuration at the 3-phase supply in a fashion to create a RL1, Rl2 - 12V, 200-ohm, 1c/o
given line voltage and which have both delta connection. relay
RL3, RL4 - 12V, 250-ohm, 3c/o, 30A
ends of each of the three stator wind- relay
ings available individually. Induction motor basics
At start, the line voltage is applied The AC induction motor, also called field produced by the AC line current
to one end of each of the three wind- the squirrel cage motor, comprises a in the stator induces a current in the ro-
ings, with the other ends bridged simple cage-like rotor and a stator con- tor, which interacts with the field and
together, effectively connecting the taining three windings. The changing causes the motor to rotate.
The base speed of the AC motor
is determined by the number of poles
built into the stator windings and the
frequency of the AC input voltage. A
load on the motor causes the motor to
slip in proportion to the load.

Circuit description
Fig. 1 shows the circuit of the automatic
star-to-delta converter comprising a
single-phase preventer and a timer.
Three single-phase transformers
are used to step-down the 3-phase sup-
ply separately. Phases R, Y and B are
stepped down by transformers X1, X2
and X3 to deliver the secondary output
of 12V at 300 mA. The transformer out-
put is rectified by a full-wave rectifier
and filtered by a capacitor.
The three 12V DC supplies drive
relays RL1, RL2 and RL3, respectively.
When all the three phases are present,
the 12V DC supply derived from the R

Electronics Projects vol. 26 103


104
Electronics projects Vol. 26
Fig. 1: Circuit of automatic 3-phase induction motor starter
is connected to R1 end of R windings,
Y phase is connected to Y1 end of Y
windings and B phase is connected to B1
terminal of B stator windings. The other
ends of all the stator windings (i.e., R2,
Y2 and B2) get bridged together to form
star connection.
After the specified delay, which
is provided for the speed of the mo-
tor to 3/4th of its full speed value,
the monostable output goes low to
cut off transistor T2 and de-energise
relay RL4. The motor stator coils now
switch to delta configuration. Now
you will observe that R phase gets
connected to the junction of R1 and
B2 terminals, Y phase is connected to
Y1 and R2 terminals and B phase is
connected to B1 and Y2 terminals of
Fig. 2: Actual-size, single-side PCB layout of Fig. 1 the stator winding. This connection
conforms to delta configuration. Since
the output of IC1 is low in this state,
pnp transistor T1 is forward biased
to light up LED1 and indicate delta
configuration.
Relay ratings. RL1 and RL2 are
normal control relays, which are used
to energise relay RL3. PCB-mounted
OEN Type 57 relays rated for 12 volts
(or equivalent) may be used for the
purpose. RL3 and RL4 are required
to support the complete line current
during star as well as delta configu-
rations. Hence the contacts must be
rated to withstand full line-to-line
voltage and expected full current of
the motor in delta configuration. Thus
heavy-duty power relays of appropri-
ate voltage and current rating for 12V
coils must be used. The relays are to be
mounted outside the PCB on the chas-
Fig. 3: Component layout for the PCB sis of a suitable metal cabinet, which
must be earthed properly to avoid any
phase is fed to the coil of relay RL3 and for IC1 is provided by the combination risk of shock.
the timer circuit through the contacts of resistor VR1, R1 and capacitor C4. Before connecting the motor to the
of relays RL1 and RL2. As a result, The timer output at pin 3 is connected circuit, proper operation of the relays
relay RL3 energises. to the base of transistor T2 via resistor must be checked. The windings must
Simultaneously, timer NE555 (IC1), R2. As a result, transistor T2 is driven be connected as shown in the circuit
which is configured as a monostable to saturation and relay RL4 energises diagram.
multivibrator, is also triggered. Its time (indicated by glowing of LED2). Thus
period is determined by capacitor C4, at power-on, relay RL3, as also RL4, Construction
resistor R1 and preset VR1. Preset VR1 energises (if all three phases are pres- An actual-size, single-side PCB for the
is used to set the time period required ent) to connect the stator windings in automatic 3-phase induction motor
to reach 3/4th of the full speed of the star configuration. On tracing the con- starter circuit is shown in Fig. 2 and its
motor. The negative triggering pulse nections you will observe that R phase component layout in Fig. 3. 

Electronics Projects vol. 26 105


Using Avr Microcontrollers
For Projects
 K. Padmanabhan,
which can compare an external ana-
P. Swaminathan & S. AnanthI
logue voltage and take control action.

T
he AVR 8535 microcontroller 8. Reset is possible through the
and its new version ATme- software, and a watchdog is provided.
ga8535 are versatile, high- Power-down or sleep modes are avail-
performance but low-cost chips. This able.
article series covers typical applications 9. An additional serial interface,
of this processor illustrating its power known as the SPI bus, with three wires:
and cost-effectiveness in an embedded data (2) and clock (1). These pins can
system. be used for programming or loading
The AVR family comprises several the code from a PC through the printer
chips, all with almost the same instruc- port or serial port. For programming
tion set. Of them, the 90S8515, 90S8535 the internal flash memory locations,
and ATmega8535 chips are low-cost and just 5V supply is enough.
readily available with the complete set of 10. Two PWM output pins, which
port pins. The Atmega8535-16 is more are useful for power control applica-
powerful and available for around Rs tions.
250. Capable of running at 16 MHz and 11. Several timers as in other mem-
achieving almost 16 million instructions Fig. 1: Pin configuration of ATmega8535 bers of the 8051 family, but with much
per second (MIPS), it is one of the fastest better time resolution.
devices available in the market today. 12. Additional
Using ATmega8535, you can build features like input
a microcontroller-based project with capture and output
following features: compare.
1. Four ports, of which one of them Here, we shall
has eight analogue-to-digital converter delve into the chip’s
(ADC) channels operations with typi-
2. ADC conversion time is as little cal programs and cir-
as 60 microseconds. Imagine adding cuits. All the develop-
an external ADC to 8051 or any other ment tools including
microcontroller chip—that would have ‘C’ compiler are avail-
taken the cost to over four digits. And able for free from the
mind you, it is a 10-bit ADC, not just Internet.
8-bit. Fig. 2: A simple LED display circuit using ATmega8535 The features of
3. If an 8MHz crystal is connected, ATmega8535 make it
each instruction executes in 1/8th of receive terminals much like the 8051 the right candidate for various embed-
a microsecond. The 89C51 at 12MHz family, but it can support even higher ded control applications. Even a digital
clock had its internal division by baud rates. filter can be implemented on the de-
twelve, so it ran at just one microsec- 5. It has quite a few internal regis- vice, provided you are fully conversant
ond. Thus, ATmega8535 chip is eight ters, RAM, EEPROM and CODE mem- with its hardware and software fea-
times faster with an 8MHz crystal. ory (flash memory in excess of 4kB). tures. You can download the databook
However, you can also use a higher- 6. The instruction set is versatile, of ATmega8535 from the ‘ATMEL.com’
frequency crystal. The chip is basically complete with several arithmetic, logic Website to understand its features and
a RISC processor that executes most and transfer instructions and related work out simple applications.
instructions in one clock cycle itself. jump instructions, etc. The sample programs given here
4. The chip has RS-232 transmit and 7. An analogue comparator pin, can be used to yield a powerful con-

106 Electronics projects Vol. 26


troller for many applications like a
filter or motor controller.

Programming the chip


The AVR source code file with ‘.asm’
extension can be written using either
the EDIT, Wordpad or notebook pro-
grams.
As with all microprocessor or mi-
crocontroller programs, for the source
code, one has to enter the program by
mnemonics and assembler directives
and then convert the same into a code
list for the program. (Directives are
assembler commands used to control
the input, output and data allocation
of the assembler. These are, however,
not translated into op-codes directly.)
This is done using the cross-assembler Fig. 3: Circuit diagram of AVR programmer (Pod)
software ‘avrasm.exe.’
To describe the modus of writing delay: clr r19 used in the program:
of an Assembly language program, a ldi r17,$ff (a) Words in upper-case letters are
simple program (led.asm) for AVR loop1: inc r17 used for command directive words of
processors is given below: brne loop1 the Assembly language or predefined
LED.ASM inc r19 ports of the processor.
.NOLIST brne r19,loop1
.INCLUDE “m8535def.inc” ret Parts List
.LIST This program helps you under- Parts list for LED display circuit (Fig. 2)
Semiconductors:
.DEF mp = R16 stand: IC1 - ATmega8535
.org $0000 ; Reset address 1. Access to the output port (here LED1-LED8 - Red LED
Resistors (all ¼-watt, ±5% carbon):
rjmp main port B, where LEDs are connected) R1 - 4.7-kilo-ohm
main: 2. The different parts of a typical R2-R8 - 470-ohm
Capacitors:
ldi R16,low(RAMEND); Load low byte assembler program C1 - 1µF, 10V electrolytic
address of the end of the RAM 3. Different conventions like use C2, C3 - 22pF ceramic disk
into register R16 of semicolon, upper-/lower-case let- Miscellaneous:
XTAL - 8MHz
out SPL,R16 ; Initialise stack ters, etc
Parts list for AVR Programmer (Fig. 3)
pointer to the end of the Semiconductors:
internal RAM
Explanatory notes for IC1 - 7805 5V regulator

ldi R16,high(RAMEND) ; Load high byte


LED.ASM D1-D4 - 1N4007 rectifier diode
Resistors (all ¼-watt, ±5% carbon):
address of the end of the RAM 1. In Assembly language, all the text on R1, R2 - 1-kilo-ohm
into register R16 a line after a semicolon (;) is treated by Capacitors:
C1 - 1000µF, 16V electrolytic
out SPH, R16 ; Initialise high the cross-assembler as comments and C2 - 0.1µF ceramic disk
byte of stack pointer ; to the it does not use it for code formation. Miscellaneous:
X1 - 230V AC primary to 6V,
end of the internal RAM 2. Including the m8535def.inc 250mA secondary transformer
ldi mp,0b11111111 processor-specific file in Assembly pro- - 40-pin ZIF socket
- 25-pin D-type male connector
out DDRB,mp gram means all the I/O register names, Parts list for message display on the LCD (Fig. 6)
loop: ldi mp,0x00 I/O register bit names, etc appearing Semiconductors:
IC1 - ATmega8535
out PORTB,mp in the datasheet can be used. Failure to
Resistors (all ¼-watt, ±5% carbon):
Rcall delay include this file may result in a num- R1 - 4.7-kilo-ohm
ldi mp,0xFF ber of error messages. Ensure that this VR1 - 10-kilo-ohm preset
Capacitors:
out PORTB,mp file is placed in the same directory as C1 - 1µF, 10V electrolytic
Rcall delay your source code file (LED.asm in this C2, C2 - 22pF ceramic disk
ldi mp,0xFF case). Else, give complete path for the Miscellaneous:
XTAL - 8MHz
out PORTB,mp m8535def.inc file. - 16x1-character Hitachi make
LCD or 16×2-character LCD
rjmp loop 3. Following conventions have been

Electronics Projects vol. 26 107


used, will turn off the listing output. as ‘load immediate (ldi) into register
5. DEF directive is used to define ‘mp’’, loads binary value ‘11111111’
a text-substitution label for a string. into the ‘mp’ register. The second line
A label/name is easy to remember. transfers the contents of ‘mp’ (11111111)
Here, register R16 is replaced with to the data direction register of port B
‘mp’ name. Thus whenever ‘mp’ is (DDRB). DDRB is already defined in
encountered in the source code, it will the m8535def.inc file. (If you want to
be automatically replaced with ‘R16.’ set port-B pins as input, load binary
6. ‘.org $0000’ defines the reset ‘00000000’ into ‘mp’ and output it to
address. When power is switched on, DDRB.) Incidentally, ‘0b’ precedes a
the program starts from this location. binary number. Similarly ‘0x’ precedes
A restart from the reset address can a hex number. Numbers without these
Fig. 4: Screenshot of AVR-Programmer be activated by resetting the respec- prefixes denote decimal numbers
tive hardware pin of the chip (pin 9) by default. Hence you may replace
or upon watchdog timer reaching its ‘0b11111111’ with either ‘0xFF’ or sim-
zero count. A relative jump command ply ‘255’ to achieve the same results.
(rjump) at this reset location directs the 9. The rest of the program starting
program execution to label (main)—as at label ‘loop:’ and ending with ‘rjmp
long as the label is within 2k locations loop’ achieves switching on and off
from the reset address (0000). Inci- of the LEDs with a delay. The delay
dentally, ‘rjmp main’ is the first code- subroutine starting at label ‘delay:’ and
generating instruction. ending with return instruction ‘ret’ is
7. It is essential to set up the stack called from within the loop.
pointer before being able to call any Initially, ‘mp’ is loaded with hex
subroutine, since stack is required value ‘00’ and output through port-
for saving the return address, where B pins, making them low. Since the
Fig. 5: Screenshot of AVR-Programmer showing the next program execution is to start cathodes of all the eight LEDs are con-
activity window
from. The program lines starting with nected to these port pins via current-
limiting resistors, the LEDs light up.
Thereafter, the delay subroutine (Rcall
delay) is called and ‘mp’ is loaded with
hex value ‘FF’ and transferred to the
port-B output to turn off the LEDs. The
loop is repeated as long as the power is
switched on.
10. The internal R-C clock of AT-
mega8535 is 1 MHz by default. In the
absence of ‘Rcall delay’ instruction,
each of ‘ldi’ and ‘out’ instructions re-
quires 1000 ns, while ‘rjmp’ instruction
requires 2000 ns. Thus loop execution
would take 4000 ns. This amounts to
LED switching rate of 250 kHz.
Introduction of delay between
switching on and off reduces this
frequency to around 0.5 Hz by decre-
menting registers ‘r19’ and ‘r17’ from
‘255’ to ‘0,’ thereby making the elapsed
Fig. 6: Circuit for message display on the LCD time slower by 256×256 (which works
out to around 0.5Hz rate).
(b) Mnemonic words are written in ‘ldi R16,low(RAMEND)’ and ending After assembling the LED.asm
lower case. with ‘out SPH, R16’ do just that. source file, the program will have eight
4. LIST directive turns on the listing 8. The ‘ldi mp, 0b11111111’ and words. The LED.LST file stores the
output if it had been previously turned ‘out DDRB, mp’ lines set port-B pins result of the assembly process in the
off. Similarly, NOLIST directive, if as the output. The first line, interpreted form of a listing.

108 Electronics projects Vol. 26


Fig. 7: Actual-size, single-side PCB layout for AVR programmer (Pod) Fig. 8: Component layout for the PCB in Fig. 7

Fig. 9: Actual-size, single-side PCB layout for message display on LCD Fig. 10: Component layout for the PCB in Fig. 9

Once a program has been written Upon Dos prompt, enter ‘copy program. The ‘.asm’ is not to be typed.
using any editor, wordpad or notepad, con avr.bat.’ In the following line, type In our LED.asm program, we have
it is assembled using the avrasm.exe ‘Avrasm -i %1.asm %1.lst %1.hex.’ included the m8535def.inc file. This
AVR assembler, available on the down- Pressing ‘F6’ key in the following line file is required along with the avrasm.
load link given at the end of this article. displays ‘Control-Z.’ Now pressing the exe cross-assembler. For other AVR
Of course, the AVRSTUDIO 4.0 inte- ‘Enter’ key displays “1 file copied.” processors like 90S8515, 90S8535 and
grated development environment (IDE) Now the avr.bat file has been pre- at-Tiny 26, the files to be included are
is more versatile and user-friendly soft- pared. This simple batch file is invoked 8515def.inc, 8535def.inc and tn26def.
ware for development, but the avrasm. to assemble this (or any) program inc, respectively.
exe assembler is simpler and direct. by typing ‘Avr LED’ upon the DOS The next task is to burn the code
Simply typing ‘avrasm -i LED. prompt and pressing the ‘Enter’ key. into the chip. Note that a chip previ-
asm LED.lst LED.hex’ under the DOS This assembles the program, and ously programmed or erased is auto-
prompt makes the cross-assembler forms both the list file (that contains matically erased when a new program
generate code for the LED.hex file and the code-cum-Assembly listing) and is burnt into it using the device pro-
also provide a text file giving both the the hex file (the actual Intel-format hex grammer as described below.
code and the program together in LED. file for use by the programmer).
lst. Thus, you get the LED.lst listing file Likewise, any other assembly pro- The AVR device
and the LED.hex Intel hex code file. gram ‘xxx.asm’ can be coded into the hex programmer
Alternatively, you can prepare a file by simply typing ‘avr xxx’ on DOS The AT-PROG programmer software
batch file as follows: prompt. ‘xxx’ denotes the name of the is used for programming ATmega8535.

Electronics Projects vol. 26 109


This menu-drive programming soft- three wire connections: code for message display on the LCD
ware is simple to use and invoked (i) Master output and slave input module along with suitable comments
from command prompt. (MOSI) wherever needed.
The software uses a simple pod (ii) Master input and slave output LCD_CHAR.ASM
connected to the printer port of a com- (MISO)
puter. The circuit of the pod (shown in (iii) Serial clock (SCLK) ;***************************************
Fig. 3) is very simple. It just connects Using these wires, the SPI interface ; * This program writes a message on to
the IC to be programmed to the pins of does the serial transfer of data (i.e., our the LCD *
the PC’s printer port. program codes) into the chip, which ;***************************************
This circuit is assembled on a small is configured as a slave. The data and .NOLIST
PCB with a D25 male-female plug clock are connected via MOSI and SCLK .INCLUDE “m8535def.inc”
at one end. The IC base is a 40-pin pins of the chip, respectively. Upon re- ;device =ATmega8535
zero-insertion-force socket (ZIF). This ception of each byte, the chip acknowl- .LIST
enables easy insertion and removal of edges it by sending a byte (53hex). ;
the IC to be programmed. In ‘Check’ mode, the IC is enquired ; Constants
The AT_PROG.exe is a simple pro- about its name by the computer (Mas- ;
gramming software that can be run un- ter), which it replies with its signature ; Used registers
der DOS prompt by typing AT-PROG. code embedded in the chip memory ;
The files At-prog-hlp.htm, At-prog.exe, by the manufacturer. Each IC has its .DEF rmpr = R16
At-prog.cfg and At-prog.ini should be specific signature code. Thus, by not- .DEF temp = R14
placed in one directory before running ing the code itself, what IC is being .DEF result=R12
the AT-PROG. These files have been programmed will be known to the com- .DEF mpr =R16
included in this month’s EFY-CD as puter. So the small window under the ; Code starts here
part of this article. device-select rectangular window can ;
The menu-driven window of the be clicked to show ‘autodetect’ the IC. .CSEG
AT-PROG programmer has the follow- 4. Options menu. In this menu, the .ORG $0000
ing menu items: speed of the clock used for transferring ;
1. File menu. This menu is used data from the computer can be selected ; Reset-vector
to select or open the LED.hex file, or as ‘slow,’ ‘normal’ or ‘fast.’ With pres- rjmp Start ; Reset-vector
whatever, which is to be programmed ent high-speed PCs, choose ‘normal’
into the device. or ‘slow.’ In the same menu, the ‘read ;******** various subroutines for LCD
Pull down the menu by clicking it. signature bytes’ option is to be enabled display********
Under ‘Open’ option, enter the file name and it is so by default. ;cmd is the LCD module’s command entry
as ‘LED.hex’ and press ‘Enter.’ The IC 5. Port menu. The port menu, subroutine. Command value in R16
to be programmed is selected from the which is next to the file menu, is useful cmd: cbi portc,2
AVR-Programmer window by click- if a different printer port is available. cbi portc,3
ing the edge of the small rectangular The program automatically selects the cbi portc,4
window and choosing the IC as shown available printer port. out portb,r16
in Fig. 4. Now connect the printer-port When the ‘Activity’ window shows sbi portc,4
connector to the programming pod, ‘ok’ after clicking the ‘Write’ menu, nop
whose circuit is shown in Fig. 3. remove the programmed chip from nop
2. Write menu. On clicking the ‘Write’ the programmer circuit board and fix it nop
menu, the ‘Activity’ window at the bot- onto the target circuit for the LED.asm nop
tom whitens and shows ‘Connecting’ program (shown in Fig. 2). Now apply nop
(refer Fig. 5). Then, the data is transferred 5V and press the switch connected to cbi portc,4
to the IC and verified after programming, Reset pin, if needed. (The circuit resets rcall delay1
showing ‘ok’ in the same window. at power-on.) The LEDs start blinking ret
3. Check menu. This menu is used to fast and the waveform can be observed ;lcdwr is the LCD module’s data entry
find out whether the IC is inserted in the on the CRO for any of the pins at the subroutine.
socket and whether the connector con- output to the LEDs. It will be around ASCI code value in R16
nections are okay. It will indicate an error 600 Hz. lcdwr: cbi portc,2
if the IC is not there or not responding. cbi portc,3
In this mode of programming, the Message display on the cbi portc,4
serial-peripheral interface (SPI) of the
LCD module sbi portc,2
AVR chip is used. This interface has Method I. Given below is the source out portb,r16

110 Electronics projects Vol. 26


sbi portc,4 ; Load the high byte address of the end
nop of the RAM into register R16 rcall lcdwr
nop out SPH, R16
nop ; Initialise the high byte address of the ldi R16,$73 ;”s”
nop stack pointer to the end of the rcall lcdwr
nop internal RAM ldi R16,$20 ;” “
cbi portc,4 rcall lcdwr
rcall delay1 LCD: ldi R16,$46 ;”F”
ret ldi r16,$ff rcall lcdwr
;init_lcd is the LCD module’s initialise out ddrb,r16 ;ff makes all bits as the ldi R16,$6f ;”o”
LCD routine for cursor, etc. output on port B rcall lcdwr
init_lcd: out ddrc,r16 ;PORT C BITS USED FOR ldi R16,$72 ;”r”
ldi R16,$38 ;function_set command for LCD WIRING rcall lcdwr
8-bit data ldi r16,$55
drive out portb,r16;then alternate bits are ldi R16,$55 ;”U”
rcall cmd ;write this in the command low and high rcall lcdwr
register for LCD ($01010101) here: RJMP HERE; Test of the serial
rcall delay1 ; wait since this takes some ;the above is a test which one interface
milliseconds for LCD can find if the program works! This program displays ‘Electron-
rcall delay1 ics ForU’ on the LCD module (Fig.
ldi R16,$0e ; command for entry mode set rcall init_lcd 6). The message may be displayed
rcall cmd ; cursor active, display on, ldi R16,$80 on the LCD in a single or two rows
no blink. rcall cmd depending on the LCD module. In
rcall delay1 ; simply observe pins 1-8 for alternate some LCD modules, the first eight
ldi R16,6 ; command for cursor shift high and low outputs! characters are written consecutively,
right after each write ldi R16,$45 ;”E” while for display of the next eight
rcall cmd characters, the program needs to
ldi r16,1 ;command for clear display rcall lcdwr restart the cursor at address $C0. But
rcall cmd Hitachi-make single-row types do not
rcall delay1 ldi R16,$6c ;”l” need to restart the cursor’s address
ret rcall lcdwr after the eighth entry; the characters
ldi R16,$65 ;”e” can be written consecutively up to
delay1:clr result rcall lcdwr ‘16,’ i.e., in a single row.
ldi R16,$a0 ; a suitable number for the ldi R16,$63 ;”c” The program is named as ‘LCD_
required delay rcall lcdwr CHAR.asm’ and assembled into the
loop2: inc R16 ; increments from 160 ldi R16,$74 ;”t” ‘.hex’ file by typing ‘avr lcd_char’ and
($a0) to 256 brne loop2 rcall lcdwr invoking the cross-assembler AVR.
inc result ; increments result register ldi R16,$72 ;”r” Now the lcd_char.hex file is generated.
from 0 to 255 brne loop2 rcall lcdwr The AT-PROG programmer burns
ret ;got 256 times 95 for loop this code into the flash memory of the
ldi R16,$6f ;”o” ATmega8535.
; ********* End of the subroutine section rcall lcdwr Note that while assembling this
******** ldi R16,$6e ;”n” program using ‘avr lcd_char’ com-
; rcall lcdwr mand, the definition file for IC AT-
; ********** Main program ********** mega8535 (m8535def.inc) should be in
; ldi R16,$c0 ; this command is to set to the same directory.
; Main program routine starts here the next half of the LCD Method II. This message display
; rcall cmd ;because 8 characters have program uses look-up table. In the
Start: ldi R16,low(RAMEND) filled the first half message display program described
; Load the low byte address of the end ;omit the above two lines if a two-row in Method I, ‘Call lcdwr’ instruction
of the RAM into register R16 LCD display or a Hitachi 1-row was written for each character. Here,
out SPL,R16 ; display is used. instead, if we enter all the bytes for
; Initialise the stack pointer to the end ldi R16,$69 ;’i’ ‘Electronics ForU’ in a table, they can
of the internal RAM rcall lcdwr be picked up one by one until the end
ldi R16,high(RAMEND) ldi R16,$63 ;”c” and shown on the LCD screen. For the

Electronics Projects vol. 26 111


purpose, there is an instruction called out portb,r16 ; Load low byte address of end of RAM
load program memory (LPM). sbi portc,4 into register R16
The table, as also the name, is nop out SPL,R16
stored in the program memory. Here nop ; Initialize stack pointer to end of
is the program along with necessary nop internal RAM
comments. nop ldi R16,high(RAMEND)
LCD Table.ASM nop ; Load high byte address of end of RAM
;——————————————————————— cbi portc,4 into register R16
; rcall delay1 out SPH, R16
.INCLUDE “m8535def.inc” ret ; Initialize high byte of stack pointer
;device =ATmega8535 ;init_lcd is the LCD module’s initialize to end of internal RAM
.LIST LCD routine for cursor etc. LDI R16,$FF
; init_lcd: OUT DDRB,R16
; Constants ldi R16,$38 ;function_set command for OUT DDRC,R16 ; MAKE PORTS B AND C AS
; 8 bit data drive OUTPUT PORTS (WIRED TO lcd)
; Used registers rcall cmd ;write this in the command rcall init_lcd
; register for LCD clr r17
.DEF rmpr = R16 rcall delay1 ; wait since this takes some clr r18 ; required in the table fetch
.DEF temp = R14 milliseconds for LCD routine LCD:
.DEF result=R12 rcall delay1 ldi ZH, high(table*2) ; Set up Z to
.DEF mpr =R16 ldi R16,$0e ; command for entry mode set point to the beginning of table
; Code starts here rcall cmd ; cursor active, display on, ldi ZL, low(table*2)
; no blink. add ZL, r17
.CSEG rcall delay1 ; Offset Z by r18:r17
.ORG $0000 ldi R16,6 ; command for cursor shift adc ZH, r18
; right after each write lpm
; Reset-vector rcall cmd ; Load
rjmp Start ; Reset-vector ldi r16,1 ;command for clear display
rcall cmd mov r16,r0 ;get loaded value into r16
;********* various subroutines for LCD rcall delay1 cpi r16,$ff ;table end?
display********* ret breq idle
;cmd is the LCD module’s command entry rcall lcdwr ;write on lcd display
;subroutine.Command Value in R16 delay1: inc r17
cmd: cbi portc,2 clr result rjmp LCD
cbi portc,3 ldi R16,$a0 ; a suitable number for the ; use Hitachi LCD display module if 1
cbi portc,4 required delay row type is used; or else use ; ;any
two-row type LCD.
out portb,r16 loop2: inc R16 ; increments from 160 Otherwise, this above program sequence
sbi portc,4 ($a0) to 256 will ;work only for 8 characters. The
nop brne loop2 rest will not be seen:
nop inc result ; increments result “Electron “ ;only will be visible.
nop register from 0 to
nop 255 idle:
nop brne loop2 ldi r16, (1<<SE) ; Enable sleep
cbi portc,4 ret ;got 256 times 95 for loop out MCUCR, r16
rcall delay1 sleep
ret ;************ End of the subroutine rjmp idle
;lcdwr is the LCD module’s data entry section *********** table:
subroutine. ; .db $45,$6c,$65,$63,$74,$72,$6F,
Asci codeValue in R16 ; ********** Main program ************ $6e,$69,$63,$73,$72,$6f,$72,$55,$
lcdwr: cbi portc,2 ; The actual-size PCB for program-
cbi portc,3 ; Main program routine starts here ming and LCD message display are
cbi portc,4 ; given in Figs 7 and 9, while their com-
sbi portc,2 Start: ldi R16,low(RAMEND) ponent layouts are shown in Figs 8 and
10, respectively.

112 Electronics projects Vol. 26


In the first part of this article, we
had described the main features of
the AVR microcontroller and the
hardware/software required for an
AT-PROG programmer board inter-
faced to the printer port of a PC. Fur-
ther, we explained the methods for
message display on a liquid crystal
display (LCD).
This part dwells on the architecture
of ATmega8535 along with application
programs exploiting its important fea-
tures for embedded control.

Architecture of
ATmega8535
Pin configuration of ATmega8535 was
shown in Fig. 1 of Part 1. The device
has ports for input/output, interrupts,
serial communication and various oth-
ers functions. There are a total of 32
pins, which are arranged as ‘A,’ ‘B,’ ‘C’ Fig. 11: Circuit diagarm of real-time clock
and ‘D’ ports for various functions as
shown in Table I. Programming the on-chip structions are built into the AT-PROG
A crystal of maximum 16MHz code/program memory program (explained in Part I), which is
or 8MHz frequency can be con- The on-chip flash memory is run on the host PC.
nected across pins 12 and 13 of AT- programmed by pulling up the reset Selection of clock. There are some
mega8535 or its low-voltage version pin and sending data through pins additional fuse bits, which can be
ATmega8535(L), respectively. Pin 9 6 (MOSI) and 7 (MISO), and pin 8 programmed for some extra op-
serves as the active-low reset pin. (SCK), which is used for clocking the erational functions. Note that the
The non-volatile program and data the code data into the flash memory. AVR device, as shipped, is preset to
memories built into ATmega8535 are: This is accomplished by the host work at 1 MHz with its internal oscil-
1. 8 kB of self-programmable flash computer by sending appropriate lator. If you want to use an external
for storing the software code of the ap- instructions and the code bytes; data crystal, say, of 8MHz frequency, you
plication program. verification is done by reading the have to exercise this option by pro-
2. 512 bytes of SRAM, which is a flash memory and comparing it with gramming the fuse bits accordingly. A
read/write memory. the original code data. Writing the lock fuse bit is just like a flash code memo-
3. 512 bytes of EEPROM for storing bits to prevent reading of the code in ry location.
the data. Unlike the flash memory, it the chip is accomplished through the The CKSEL fuse bits can be pro-
can be accessed in a program for writ- instructions and the relevant data. grammed to select the desired crystal.
ing and reading. For using the AVR device, these in- The device clocking options are select-
able by Flash Fuse bits as shown in
Table I Table II. The clock from the selected
Port Description source is input to the AVR clock gen-
Port description Pin Nos. Usage erator and routed to the appropriate
Port A (PA0-PA7) 40 to 33 Bidirectional I/O pins with 20mA sink capability and active modules.
internal pull-ups; alternately used as ADC input as well as data Since the default oscillator is
lines to external RAM 1MHz, unless we set the CKSEL bits
Port B (PB0-PB7) 1 to 8 Input or output port, also used for additional functions as T0, to an appropriate value, the external
T1, AIN0, AIN1, SS, MOSI, MISO and SCK pins
crystal on pins 12 and 13 will not func-
Port C (PC0-PC7) 22 to 29 Used for address output if external RAM is attached; four pins
are alternately used as SCL, SDA for I2C, TOSC1 and TOSC2,
tion for ATmega8535.
respectively Programming the fuse bits. The
Port D (PD0-PD7) 14 to 21 Bidirectional, as for port A. Also serve as pins for serial fuse bit programming option is avail-
communication, interrupts 0 and 1, and PWM 1 and 2 output able on the screen when the AT-PROG
comparison, etc. is run on the PC. When this option is

Electronics Projects vol. 26 113


Table II Instruction set tine calls, the return address value is
Device Clocking Options Select* for ATmega8535 stored in the stack space, which is to be
defined by the user at the beginning of
Device clocking option CKSEL3.0
The instruction set com- every program in SRAM space.
External crystal/ceramic resonator 1111-1010
prises several arithme- 3. The 16-bit stack pointer is read-/
External low-frequency crystal 1001
tic, logical, branch and write-accessible in the I/O space.
External RC oscillator 1000-0101
bit-test type instruc- 4. The 512-byte data RAM is eas-
Calibrated internal RC oscillator 0100-001
tions. You can down- ily accessed through five different ad-
External clock 0000
load a 150-page user dressing modes supported.
*For all fuses, ‘1’ means unprogrammed, while ‘0’ means programmed
manual for the AVR 5. A flexible interrupt mod-

Table III
Some Registers in the I/O Space of ATmega8535
DDRB data direction reg. of port B $37 DDRA $3A DDRC $34 DDRD $31 UDR Uart data reg. $2C
PINB input reg. of port B $36 PINA $39 PINC $33 PIND $30 UCSR Uart control reg. A=$2B B=$2A
PORTB output reg. port B $38 PORTA#3B PORTC $35 PORTD$32 UBRR Uart baud rate reg.
ADMUX adc channel sel. $27 ADCSRA ADC control/ ADCH adc value ADCL: adc value low- ACSR analogue comparator control/
status register* $26 high reg. $25 byte reg. $24 status reg. ($28)
*ADC in ATmega8535 is named ‘ADCSRA’

ule has its control registers in


the I/O space with an addi-
tional global interrupt en-
able bit in the status register.
Every interrupt has a sepa-
Fig. 12: Bit description for status register; I-global interrupt-enable bit, T-T bit copy storage, H-half carry flag,
S-sign bit, V-overflow in 2’s complement arithmetic, N-negative number flag (2’s complement arith.), Z-zero rate address for vectoring,
flag, C-carry flag where the instruction caus-
ing it to jump to the memory
selected, it pops up a menu of its own. instruction set from Atmel’s site ‘www. area of that particular interrupt
On this menu, you can write the neces- atmel.com/dyn/resources/prod_doc- has to be kept stored by the program-
sary code for CKSEL programming. uments/doc0856.pdf.’ A summary of mer.
Internal registers. Six of the 32 the instruction set is given on pages There are many interrupts available
registers can be used as three 16-bit 299 through 301 of the Atmega8535(L) in ATmega8535. In order to use any
indirect address register pointers for datasheet. interrupt, you need to place the ad-
data space addressing, enabling ef- Some of the important instructions dress of the program of the respective
ficient calculations. One of three ad- are given in Table IV. interrupt service routine at the vector
dress pointers (X, Y and Z registers, address.
described under ‘register operations’ Points to be noted From location ‘001H’ to ‘014H,’
section) is also used for table look-up. 1. When the relative call or jump in- there are 20 such interrupt vector
The I/O memory space contains 64 struction is executed, the entire memo- locations in the order of their prior-
addresses for CPU peripheral functions ry address space can be accessed. ity. Address ‘000H’ is used for the
like control registers, timers/counters 2. During interrupts and subrou- reset vector. A reset may be caused by
and analogue-to-digital converter power-on reset, brownout reset and
(ADC). It can be accessed directly or Parts List watchdog reset, or externally by mak-
as the data space locations following Parts list for real-time clock (Fig. 11) ing pin 9 low. Table 19 on page 45 of
those of the register files, i.e., after Semiconductors: the datasheet lists the details of reset
IC1 - ATmega8535
‘20H’ and up to ‘5FH.’ Resistors (all ¼-watt, ±5% carbon): and interrupt vectors.
The memory space contains im- R1 - 4.7-kilo-ohm Note that here we are dealing with
R2, R3 - 5-kilo-ohm
portant registers for use in interrupt VR1 - 10-kilo-ohm preset word addresses, so each location is ac-
selection, timer control, UART, SPI Capacitors: tually two bytes long. In this two-byte
C1 - 1µF, 10V electrolytic
interface, watchdog and reset selection C2, C3 - 22pF ceramic disk location, if you place a RETI (return
modes, etc. Table III shows the exact Miscellaneous: from interrupt) instruction, nothing
addresses of these I/O registers. XTAL - 8MHz will be done upon that interrupt. For
S1, S2 - Push-to-on switch
The bit description for the status - 16x1-character Hitachi make example, if you place a jump instruc-
LCD or 16×2-character LCD
register (SREG) is shown in Fig. 12. tion to the required routine, you can

114 Electronics projects Vol. 26


Table IV
Instruction Set for ATmega8535
1. Arithmetic and logical instructions
ADD rd, rs SUB (rd-rs) AND rd, rs OR rd, rs EOR rd, rs
ADC SBC ANDI ORI rd, K COM rd
Add with carry Subtract with carry AND with immediate data One’s complement
ADIW (Word) SBCI rd=rd-Carry-K INC rd CLR rd NEG rd
Add immediate to word Increment reg. Clear register ; 2’s complement
SBIW DEC rd SER rd SBR rd,n
Subtract immediate from word decrement reg. Sets register ; sets nth bit in rd
Note: K-immediate data, rd-destination register, rs-source register
2. Data movement instructions
MOV rd,rs LDI rd, K ST X, rs LPM R0 ← [Z] PUSH rs
Immediate load Stores rs into [X] Load from prog. mem. Pushes to stack the value of
register Rs
LD rd, X* ST X+, rs IN rd, port# POP rs
Load indirectly ; store indirectly and incr. X As PORTB for reg. Pops into Rs from stack
LD rd, X+ ST –X, rs Out Port, rd
Indirect, post incr. address Decr. after storing
LD rd, -X STD Z+disp, rs STS k, rs
Dec. X by 1 and then Stores indirect with added Stores direct to SRAM
read indirectly displacement addr. k
*X denotes register pair R26-R27. Likewise, Y and Z are also usable for these instructions. # Port B should be entered as ‘PINB’ for inputs for the assembler;
The notation PORTB used for output.
3. Boolean logic BIT based instructions
SBI P, b CBI P, b LSL rd ROL rd SEC
Sets bit P=addr, bit no. Clear bit in I/O register Logical left shift Rotate left through carry Sets carry flag
LSR rd ROR rd CLC
Logical right shift Rotate right through carry Clears carry
CLI ASR SWAP rd SEZ, CLZ
Interrupts disabled. Arithmetic shift right Swaps nibbles in Rd Set/clear zero flag
SEI Bst/BLd reg, b NOP
Global interrupt enable Stores loads a bit in No operation
SREG(b) (status register)
Note. Bits can be in any I/O register or bits of any register Rd. P means an I/O address register.
4. Frequently used test and skip as well as jump and call instructions
RJMP k RCALL k CP Rd, Rs BREQ K
Jumps k (-2047 to +2048) Calls relative Compares Rd-Rs Branches to K relative
if zero flag is set
Ljmp ICALL CPSE Rd, Rs BRNE K
PC ← Z Calls to [Z] indirectly Compares, skips the Does the opposite of
next instruction if equal the above
RET CPI Rd, K BRCS k
Subroutine return Immediate data compared Branch if carry is set
RETI BRCC k
Interrupt service return Branch if carry not set
Note. Most of these instructions are relative branching, except some, which need a full address of destination for jumping.
5. Additional multiply instructions
MUL Rd, Rr Multiply unsigned R1:R0←Rd×Rr
MULS Rd, Rr Multiply signed R1:R0←Rd×Rr
MULSU Rd, Rr Multiply signed with unsigned R1:R0←Rd×Rr
FMUL Rd, Rr Fractional multiply unsigned R1:R0←(Rd×Rr)<<1
FMULS Rd, Rr Fractional multiply signed R1:R0←(Rd×Rr)<<1
FMULSU Rd, Rr Fractional multiply signed with unsigned R1:R0←(Rd×Rr)<<1

write: As mentioned above, the inter- addresses, defined by the labels, is


rjmp timer_routine rupt vectors follow the reset address placed. For example, the instruction:
Then you can use that interrupt to at ‘000H,’ wherein a jump instruction RJMP Int0
jump to the timer_routine. to the corresponding actual memory It means that the external interrupt

Electronics Projects vol. 26 115


with add-on features
2. Pulse-width modulated out-
put
3. Analogue-to-digital converter
Fig. 13: Bit details for TCCR0 register; bits 0, 1 and 2 are defined in Table IV reproduced from the original 4. Serial RS-232 interface
datasheet
Timers and their applications.
Both timer 0 and timer 1 are
8-bit timers, while timer 1 is a
16-bit timer. The clock inputs to
the timers can have a variety of
Fig. 14: Bit details for TIMSK register selections. The CPU clock itself,
divided by a prescaling divider with
Table V divisors of 8, 64, 256 and 1024, can be
Clock-Select Bit Description chosen. Further, it can also count an
CS02 CS01 CS00 Description externally applied clock at T1 pin (for
0 0 0 No clock source (timer/counter stopped) timer 1).
0 0 1 clkI/O/(no prescalling) We shall use these timers for de-
0 1 0 clkI/O/8 (from prescaler) veloping a real-time clock with time
0 1 1 clkI/O/64 (from prescaler) display on the LCD (see Fig. 1). For
1 0 0 clkI/O/256 (from prescaler) the purpose, the registers to be used in
1 0 1 clkI/O/1024 (from prescaler) timer 0 are:
1 1 0 External clock source on T0 pin. Clock on falling edge 1. TCCR0: Timer counter control
1 1 1 External clock source on T0 pin. Clock on rising edge register 0
2. TIMSK: Timer interrupt mask
routine has the label ‘Int0,’ to which pairs R26-R27, R28-R29 and R30-R31 register
the processor jumps upon pin 17 get- serve as 16-bit registers, which are TCCR0 register bits. Fig. 13 shows
ting a high logic signal. Also, at the used for indirect addressing of the data the bit details for TCCR0 register. Bits
label ‘Int0,’ if a simple return instruc- memory space. These three 16-bit reg- WGM01, COM00, COM01, WGM00
tion is entered as: isters are known as ‘X’ (R27:R26), ‘Y’ and FOC0 (bits 3 through 7) of TC-
Int0: reti (R29:R28) and ‘Z’ (R31:R30) registers, CRO register are used with the timer-
This instruction simply ignores respectively. The last 16 registers in the based comparators for waveform and
such an interrupt and returns to the register file (R16 through R31) cannot pulsewidth-modulated output genera-
main program. In case you need to be used with the first 16 registers (R0 tion. Since these bits are not required
process the interrupt, enter the neces- through R15). for the normal timing operation of the
sary code starting at label ‘Int0.’ The operating instructions for timer, they have not been used here.
After the interrupt processing registers have direct and single-cycle The timer clock is selected by using
instructions, the various subroutines access to the registers. The following the remaining three bits (CS00, CS01
are entered. Then comes the main pro- instructions—constant arithmetic in- and CS02). We will set these bits to
gram. In the main program, the first structions—use the second half of the ‘0,’ ‘1’ and ‘1,’ respectively, for divid-
thing to write is the stack initialisation registers in the register file and cannot ing the 1MHz default internal clock
instructions. Here, the stack pointer is be used with the first half: of ATmega8535 k (with no external
set to the highest end of the internal sbci, subi, cpi, andi, ori and ldi crystal) by ‘64.’ This division gives
RAM, for which a temporary register The following general instruc- 65 microseconds per clock. Then we
is used, and the high and low ad- tions that use two registers or only a accumulate the counts for getting one
dresses are written to the stack pointer single register can use the entire reg- second and divide it by ‘60’ to get
using an instruction at the Ext_Int0 ister file: minutes and again by ‘60’ to get hours,
vector address (0x001) such as: Sbc, sub, cp and & or which are counted up to ‘12’ and the
ldi temp,low(RAMEND) process is repeated.
out spl,temp
Embedded control TIMSK register bits. Fig. 14 shows
ldi temp,high(RAMEND)
functions and their the bit details for TIMSK register. Bit
out sph,temp
applications 0 refers to ‘timer-overflow interrupt
Register operations. Each register Here we’ll use the following four enable.’ It must be set to enable the
is assigned a data memory address, functions of ATMega8535 for typical interrupt action on overflow. The
mapping it directly into the first 32 control applications: TIMO_OVF interrupt ($0009 address)
locations of the data space. Register 1. Timers; two 8-bit and one 16-bit is used to direct a vector at this ad-

116 Electronics projects Vol. 26


dress to the respective interrupt service counter 0) crosses ‘255’ (decimal). So program with suitable explanations
routine, where we will perform the in the software program for real-time and comments is given at the end of
relevant action that is needed upon clock, we initialise TIMSK to ‘01.’ this article. The programmed IC can be
timer-0 overflowing, i.e., when the Software program for real-time fixed to the RTC circuit board to show
number in its TCNT0 register (timer clock (8535clk.asm). The 8535clk.asm real-time clock on the LCD.

8535clk.asm
; Things to learn here: internally itself brlt SecRet ; jump if less than 60
; - Timer in interrupt mode rcall init_lcd ;initialise LCD module ldi mp,256-$60 ; Load mp to add sec to zero
; - Interrupts, Interrupt-vector ldi R16,$80 add sec,mp ; Add mp to reset sec to zero
; - BCD-arithmetic rcall cmd rcall incmin
.LIST ; Software-Counter-Register reset to zero SecRet:
.NOLIST ldi mp,0 ; z1 cannot be set to a constant ret ; return to the main program loop
.INCLUDE “m8535def.inc” value, so we set mp incmin: ;subroutine for minutes incrementing
;device =ATMEga8535 mov z1,mp ; to zero and copy that to R0=z1 sec ; Setze Carry-Flag for adding an additional
.LIST mov sec,mp ; and set the seconds to zero one to the seconds
; Universal register definition mov min,mp ;and minutes also ldi mp,6 ; provoke overflow of the lower nibble
.DEF mp = R16 ldi mp,$12 by adding 6
.DEF result=R18 mov hour,mp adc min,mp ; add 6 + 1 (Carry)
; Counter for timer timeouts, MSB timer driven ; Prescaler of the counter/timer = 64, that is 1 brhs Chk60_m ; if overflow of the lower nibble
by software MHz/64 = 15625 Hz = $3D09 occurred go to 60 check
.DEF z1 = R0 ldi mp,0x03 ;Initiate Timer/Counter 0 Prescaler sub min,mp ; subtract the additional 6 as no
; Working register for the Interrupt-Service- as /64 overflow occurred
Routine out TCCR0,mp ; to Timer 0 Control Register Chk60_m:
; Note that any registers used during an inter- ; enable interrupts for timer 0 ldi mp,$60 ; 60 minutes already reached?
rupt, including the status-register with all the ldi mp,$01 ; set Bit 0 but for 8515 this was bit 1! cp min,mp
flags must either be reserved for that purpose out TIMSK,mp ; in the Timer Interupt Mask brlt minRet ; jump if less than 60
; or they have to be reset to their initial Register ldi mp,256-$60 ; Load mp to add min to zero
; value at the end of the service routine! Oth- ; enable all interrupts generally add min,mp ; Add mp to reset min to zero
erwise sei ; enable all interrupts by setting the flag in RCALL INCHOUR
; nearly unpredictable results will occur. the status-register minRet:
.DEF ri = R1 ; The 8-bit counter overflows from time to time ret ; return to the main program loop
; Register for counting the seconds as packed and the interrupt service INCHOUR:
BCD ; routine increments a counter in a register. The sec
.DEF sec = R2 main program loop reads this ldi mp,6
.DEF min = R3 ; counter register and waits until it reaches 3D adc hour,mp
.DEF hour=R4 hex. Then the timer is read until brhs chk12hour
.DEF count=R5 ; it reaches 09 (one second = 15625 (dec)= sub hour,mp
.DEF count1= R6 3D09(hex) timer pulses). The timer chk12hour:
.CSEG ; and the register are then set to zero and one ldi mp,$13
.ORG $0000 second is incremented. The seconds cp hour,mp
; Reset- and Interrupt-vectors ; are handled as packed BCD-digits (one digit = brlt houret
rjmp Start ; Reset-vector four bits, one byte represents ldi mp,256-$12
.org ovf0Addr ; two digits). The seconds are refreshed. The add hour,mp
rjmp tc0i seconds houret: ret
; Reset-vector to address 0000 ; are displayed on the LCD module, as well. lookupdate:
.org $30 ldi mp,0x31 ;just show a “1” to begin with k2: sbic pinc,0
start: rjmp main rcall lcdwr ret ;if key is not closed, return
; Be sure that the jump loop: ;if closed, wait for key-debounce and
; to the interrupt service routine tc0i is exactly ldi mp,$3D ; compare value for register counter check again
at the adress “ovf0”,otherwise the interrupt fails. loop1: rcall lookupdate ; check if user adjusts rcall delay1
; The following sequence takes place : If the time- Inc count1
timer overflows minutes ldi mp,80
; (transition from 255 to 0) the program run is rcall lookupdatehr ; check if user adjusts time- cp count1,mp
interrupted, the current address in the program hours brlt dd
counter cp z1,mp ; compare with the register RCALL incmin
; is pushed to the stack, the instruction at ad- brlt loop1 ; z1 < mp, wait Ldi mp,0
dress ovf0 loop2: Mov count1,mp
; is executed (the jump instruction). After fin- in mp,TCNT0 ; read LSB in the hardware dd: rcall display
ishing execution of the interrupt service routine counter ret
; the program counter value is restored from the cpi mp,$09 ; compare with the target value lookupdatehr:
; stack and program execution proceeds from brlt loop2 ; TCNT0 < 09, wait k3: sbic pinc,1
that point. ldi mp,0 ; set register zero and ... ret ;if key is not closed, return
tc0i: out TCNT0,mp ; reset hardware-counter LSB ;if closed, wait for key-debounce and check
in ri,SREG ; save the content of the flag mov z1,mp ; and software-counter MSB again
register rcall IncSec ; call the subroutine to increment rcall delay1
inc z1 ; increment the software counter the seconds inc count
out SREG,ri ; restore the initial value of rcall Display ; call subroutine to display the ldi mp,80
the flag register seconds cp count, mp
reti ; Return from interrupt rjmp loop ; once again the same brlt dd
.org $50 ; subroutine increment second counter RCALL inchour
; The main program starts here ; in BCD-arithmetic! Lower nibble = Bit 0..3, up- Ldi mp,0
main: per nibble = 4..7 mov count, mp
ldi mp,LOW(RAMEND) ;Initiate Stackpointer IncSec: rjmp dd
out SPL,mp ; for the use by interrupts and sec ; Set Carry-Flag for adding an additional one ; subroutine for displaying the time on the LCD
subroutines to the seconds Display: push r16
ldi mp,HIGH(RAMEND) ldi mp,6 ; povoke overflow of the lower nibble ldi r16,$80
out SPH,mp ; Port b (pin 1-8) output-port, by adding 6 rcall cmd
port c all output except bit 0,1 adc sec,mp ; add 6 + 1 (Carry) pop r16
ldi mp,0xFF ; all bits are output brhs Chk60 ; if overflow of the lower nibble mov r16,hour
out DDRb,mp ; to data direction register occurred go to 60 check andi r16,0xf0
ldi mp,0xFc ;bits 0,1 input; pin22 for minutes sub sec,mp ; subtract the additional 6 as no ror r16
set; pin23 hour set; overflow occurred ror r16
out DDRC,mp Chk60: ror r16
LDI MP,03 ldi mp,$60 ; 60 seconds already reached? ror r16
OUT PORTC,MP ;pull up port C bits 0- 1 cp sec,mp ori r16,0x30

Electronics Projects vol. 26 117


rcall lcdwr mov r16,sec nop
mov r16,hour andi r16,0b00001111 nop
andi r16,0b00001111 ori r16,0x30 cbi portc,4
ori r16,0x30 rcall lcdwr rcall delay1
rcall lcdwr ldi r16,32 ret
ldi r16,$3A rcall lcdwr init_lcd: ; initialise LCD module
rcall lcdwr ret ldi R16,$38
mov r16,min cmd: cbi portc,2 ; command entry to LCD rcall cmd
andi r16,0xf0 subroutine rcall delay1
ror r16 cbi portc,3 rcall delay1
ror r16 cbi portc,4 ldi R16,$0e
ror r16 out portb,R16 rcall cmd
ror r16 sbi portc,4 rcall delay1
ori r16,0x30 nop ldi R16,6
rcall lcdwr nop rcall cmd
mov r16,min nop ldi r16,1
andi r16,0b00001111 nop rcall cmd
ori r16,0x30 nop rcall delay1
rcall lcdwr cbi portc,4 ret
ldi r16,$3A ; For : display rcall delay1 delay10:
rcall lcdwr ret ldi R16,$f0
mov r16,sec lcdwr: cbi portc,2 ; write to LCD routine del_lp: inc R16
andi r16,0xf0 cbi portc,3 brne del_lp
ror r16 cbi portc,4 ret
ror r16 sbi portc,2 delay1:
ror r16 out portb,R16 clr result
ror r16 sbi portc,4 loop22: inc result
ori r16,0x30 nop brne loop22
rcall lcdwr nop ret
nop

let’s now examine the use of inbuilt Principle of pulse-width modula- When the number stored in the
functions of AVR ATmega8535 (such as tion. To generate different analogue output-compare register (OCR) match-
output compare, ADC and UART) for levels, the duty cycle and thereby the es the loaded count value, pin 19 (out-
various applications. pulse-width of the digital signal (base put-compare action pin) becomes high
frequency) is changed. If a high ana- or low, as programmed. For example,
PWM operation of logue level is needed, the pulse width if the OCR is loaded with a value of
ATmega8535 is increased and vice versa (see Figs 15 ‘l00,’ the logic state of OCR pin will be:
When the AVR is configured for pulse- and 16).
width modulated (PWM) operation, A digital pulse train with a constant Count value OCR pin
the PWM outputs become available at period (fixed base frequency) is used 0 to 100 Low logic
output-compare pins 18 (OC1A) and as the basis. The base frequency, which 100 to 255 High logic
19 (OC1B) of ATmega8535. PWM, in can be programmed suitably, should 255 to 100 High logic
conjunction with an analogue filter, be much higher than the frequency of 100 to 0 Low logic
can be used to generate analogue the output analogue signal obtained
output signals and thus it serves as a after filtering out the base frequency Thus, for the total time taken to
digital-to-analogue converter. component. For example, to generate count 255×2=510 clock ticks, the output
a sinewave signal of low fre- pin (pin 19) will be high for (2×155)/
quency (say, 10 Hz, as used (2×256) or 60.5 per cent of the total tri-
for drives or controls), the angular wave time of one PWM pulse
base frequency of rectangular (or the PWM pulse will have a duty
pulses (with varying duty cycle of 60.5 per cent). Thus, effectively
cycle) may be of the order of 1 the voltage transmitted in this period is
kHz or more. 60.5 per cent of the maximum, because
Pulse generation method. the pulse is high only for this period
Fig. 15: Variation of pulse width (constant period) with time of a
typical PWM wave
The scheme for pulse gen- of time.
eration is as follows: Timer/ The following program (avrsine.
counter 1 is used to count asm) will generate a 1Hz sine wave
clock ticks. If 8-bit PWM (after filtering) on pin 19 using PWM:
is selected, after the timer
counts up to ‘255,’ its count AVRSINE.ASM
;———————————————————————
is decremented with each ; File: avrsine.asm
clock tick. Thus, the number ; Description: Example of how to use the fast PWM
; of the Avr to generate “sine-wave” signal. The PWM
increases up to ‘255’ and then ; output requires filtering to shape the sine wave
; form.
Fig. 16: View of filtered low-frequency sine wave and unfiltered
decreases, resembling a trian- ;———————————————————————
.include “m8535def.inc”
PWM output on an oscilloscope gular pattern.

118 Electronics projects Vol. 26


rjmp init
can be directly observed at pin 19.
;Interrupt vector table
In the avrsine.asm program,
.org OVF1Addr ;OC1Aaddr for each of the triangle wave periods,
; Interrupt vector for timer1 output compare match A
rjmp TOF_isr we read a table of sine values (multi-
;Main code plied by ‘256’) and load these values
init:
ldi R16,low(RAMEND) one by one into the OCR. Since the
; Load low byte address of end
of RAM into register R16
values vary in a sinusoidal pattern,
out SPL,R16 the pulses that come out are also
; Initialize stack pointer to end of internal RAM
ldi R16,high(RAMEND) pulse-width modulated as per these
; Load high byte address of end of RAM into
register R16 values (see the oscilloscope pattern
out SPH, R16
; Initialize high byte of stack pointer to end of shown in Fig. 16).
internal RAM To do the table look-up (as given
ldi r16,$ff
out ddrb,r16 in the example program ‘LCD Table.
ldi r16,$55
out portb,r16 ASM’ of Part 1), the LPM instruction
ldi r16, (1<<PD5) ; Set Pd5 as output is used. The Z register is used as an
out DDRd, r16 ;since that is the PWM Fig. 17: Circuit for PWM-based sinewave
output pin 19 generation indirect indexed register. As stated
;SELECT CLOCK SOURCE VIA TCCR1B
earlier, the LPM
LDI R16,$81 instruction fetches
from the table one
;8 BIT PWM NON-INV.
; Set PWM mode: toggle OC1A on compare byte into r0. The
out TCCR1A, r16
; Enable PWM Fig. 18: ADCH and ADCL registers actual loading of
ldi r16, 0xFF
the OCR value is
.db 79,77,74,71,68,65,63,60,57,55,52,50,47,45,43,40 done by the instruction:
; Set PWM top value: OCR1C = 0xFF .db 38,36,34,32,30,28,26,24,22,21,19,17,16,15,13,12
out OCR1AL, r16 .db 11,10,8,7,6,6,5,4,3,3,2,2,2,1,1,1 out OCR1AL, r0
LDI R16,0 .db 1,1,1,1,2,2,2,3,3,4,5,6,6,7,8,10
OUT OCR1AH, R16 .db 11,12,13,15,16,17,19,21,22,24,26,28,30,32,34,36
; Enable Timer/Set PWM clock prescaler
.db 38,40,43,45,47,50,52,55,57,60,63,65,68,71,74,77 where OCR1AL refers to pin 19.
.db 79,82,85,88,91,94,97,100,103,106,109,112,116,119,
LDI R16,02 122,125 (OCR1BL refers to pin 18, which is not
OUT TCCR1B,R16 ;ck/8 as pwm clock
(1MHz/8 = 125 kHz) used here.)

ldi r16, (1<<TOIE1) ; Enable Timer1 For observation of the sine wave The program contains suitable
Ovrflow interrupt
out TIMSK, r16 on an oscilloscope, use a low-pass comments for easy understanding. The
clr r17 filter comprising a 1-kilo-ohm resistor table in the program has 256 elements
clr r18
sei (series element) and a 1µF capacitor (corresponding to the samples in one
; Enable global interrupts
idle: (shunt element). However, with an complete sinewave period), while each
ldi r16, (1<<SE) ; Enable sleep
out MCUCR, r16 analogue multimeter, the sine wave sample period = pulse period (high and
sleep
rjmp idle low parts) = 510 clock ticks. Thus 256
Parts List (samples) × 510 (clock ticks) = 130,560
TOF_isr: Parts list for Figs 17 and 21
ldi ZH, high(sine_table*2)
Semiconductors: clock ticks will produce one sinewave
; Set up Z to point to the beginning of
sine_table IC1 - ATmega8535 microcontroller cycle. Thus for producing exactly 1Hz
ldi ZL, low(sine_table*2) IC2 - LM35 temperature sensor
add ZL, r17 IC3 - Max 232, RS-232 level converter frequency, the base frequency should
; Offset Z by r18:r17 Resistors (all ¼-watt, ±5% carbon):
adc ZH, r18 be 130.56 kHz (the nearest value of 125
R1 - 4.7-kilo-ohm


lpm
; Load sine_table[Z] into OCR1A
R2 - 100-ohm kHz has been used here).
R3 - 1-kilo-ohm
out OCR1AL, r0 VR1, VR3 - 10-kilo-ohm preset The circuit for realising the PWM-
inc r17 VR2 - 10-kilo-ohm trim potentiometer based sinewave generator is shown in
reti Capacitors:
C1, C6 - 1µF, 10V electrolytic Fig. 17.
sine_table: ; 256 values C2, C3 - 22pF ceramic disk The avrsine.asm file and the
.db 128,131,134,137,140,144,147,150,153,156,159,162, C4, C5, C7-C10 - 10µF, 16V electrolytic
165,168,171,174 C11 - 22µF, 16V electrolytic assembled .hex file are given in the
.db 177,179,182,185,188,191,193,196,199,201,204,206,
Miscellaneous:
209,211,213,216
XTAL - 8MHz crystal CD. Using the AT-PROG programmer,
.db 218,220,222,224,226,228,230,232,234,235,237,239,
240,241,243,244 L1 - 100µH inductors load the program into an ATmega8535.
.db 245,246,248,249,250,250,251,252,253,253,254,254, - 16x1-character Hitachi make
254,254,254,254 LCD or 16×2-character LCD Then fix it in a breadboard and make
.db 254,254,254,254,254,254,254,253,253,252,251,250, - 9-pin female D-connector
250,249,248,246
connections as per Fig. 17. Connect the
Parts list for power supply
.db 245,244,243,241,240,239,237,235,234,232,230,228,
Semiconductors: circuit to 5V power supply and observe
226,224,222,220
.db 218,216,213,211,209,206,204,201,199,196,193,191, IC4 - 7805 regulator approximately 1Hz sine wave at pin
188,185,182,179 D1-D4 - 1N4007 rectifier diode
.db 177,174,171,168,165,162,159,156,153,150,147,144, Capacitors: 19 using an analogue multimeter. The
140,137,134,131
.db 128,125,122,119,116,112,109,106,103,100,97,94,91,
C12 - 4700µF, 16V electrolytic needle on the multimeter will move
C13 - 0.1µF ceramic disk
88,85,82 with the sine wave as a pendulum.

Electronics Projects vol. 26 119


.EQU xyz = 12345
.EQU fq=1000000; clock freq. of
internal oscillator
.EQU baud=9600; Baudrate of SIO comm.
.EQU bddiv=(fq/(16*baud))-1; Baudrate
divider
.DEF rmpr = R16
.DEF temp = R14
Fig. 19: ADMUX register bits .DEF result=R12
.DEF mpr =R16
.CSEG
.ORG $0000
; Reset- and Interrupt-vectors
rjmp Start ; Reset-vector
.org OVF0Addr ; timer-0 overflow
interrupt vector
address
rjmp timer0prg
Fig. 20: ADCSRA register bits timer0prg: ;here take ADC sample
at every 64 µs
Bits 6 and 7 (REFS0 and REFS1) are ldi r16,$cc
Using the ADC reference-selection bits. With bit 7 as ‘0’
out portc,r16
push r16
in r16,SREG
The inbuilt analogue-to-digital converter and bit 6 as ‘1,’ the external reference PUSH R16
here2:in r16,adcsra
(ADC) of ATmega8535 is an 8-channel voltage is applied to pin Aref (32). andi r16,0b01000000
brne here2 ;value got
device with 10-bit resolution and maxi- We write E0 (1110 0000b) to ADMUX in r16,adcl
mum conversion time of 65 µs. The ref- register in the ADC_LCD.ASM program. in r17,adch
rcall lcddisp
erence voltage for the ADC is connected That means we choose channel-0 (pin 40) POP R16
out SREG,R16
across pins 32 (positive) and 31 (ground). for the signal input, ADCH to give us the POP R16 ;restart adc
ldi r16,0b11000101 ;prescale /32
The 5V Vcc supply (either directly or most significant eight bits and external (1x32=32 µs)
;adc enable,adc start,adc
through a potmeter) can be used as refer- 5V reference at pin 32 for analogue-to- freerun,adcflag,adcno int,
ence voltage, but a capacitor at pin 32 is digital conversion. adcprescale/32
out adcsra,r16
to be used for decoupling. ADCSRA register. This is the con- RETI ;End of ISR
cmd: cbi portc,2 ;command entry to
To access the ADC, you need to trol-and-status register for the ADC. LCD routine
cbi portc,3
select the ADC channel; while the use of Its bit positions are shown in Fig. 20. cbi portc,4
out portb,r16
ADC interrupt is left to the discretion of The bits of the ADCSRA stand for sbi portc,4
the programmer. The ADC is read after the following signals: ADC enable nop
nop
conversion of a sample via the ADCH (bit 7), ADC start (bit 6), ADC auto- nop
nop
and ADCL registers (8 bits from the trigger enable for free-running (bit nop
cbi portc,4
ADCL register and only two bits from 5), ADC interrupt flag set on comple- rcall delay1
the ADCH register) as shown in Fig. 18. tion of conversion (bit 4), ADC in- ret
lcdwr:cbi portc,2; wrtite to LCD
ADMUX and ADCSRA are the oth- terrupt enable when set (bit 3) and routine
cbi portc,3
er registers used in conjunction with ADC prescaler for speed (bits 0, 1 cbi portc,4
sbi portc,2
the ADC. Functions of various bits of and 2). Bits 0, 1 and 2 determine the out portb,r16
sbi portc,4
these registers are explained below. division factor between the clock nop
ADMUX register. The ADMUX frequency and the input clock to nop
nop
register bits are shown in Fig. 19. the ADC. The division factor can be nop
nop
Bits 4 through 0 of ADMUX select selected from ‘2’ to ‘128’ as per cbi portc,4
rcall delay1
the ADC channels for single-ended Table 86 of the datasheet. ret
busy: cbi portc,2
or differential operation including sbi portc,3 ;read/write high?
channels with gain. (For full selec- Program for displaying the cbi portc,4 ;chip select low

tion details, see Table 85 of the ADC output on the LCD nop
nop
sbi portc,4 ;chip select high
ATmega8535(L) datasheet.) The following program (adc_lcd. busy1:lds R16,pinb
rol R16
Bit 5 (ADLAR, or AD left adjust asm) takes the ADC data, converts brcs busy1
cbi portc,4
result) affects selection of results in the 10-bit data into five decimal digits ret
ADCH and ADCL registers. If this bit and then shows it continuously on the init_lcd: ;initialise LCD
ldi R16,$38
is made ‘0,’ the ADCL contains the LCD screen: rcall cmd
rcall delay1
least eight bits and the ADCH con- rcall delay1
ldi R16,$0e
tains the remaining two high-order ADC_LCD.ASM rcall cmd
; ************************************************* rcall delay1
bits in its D1:D0 bit positions. When ; *This program uses channel -0 ADC of ATmega8535 ldi R16,6
the ADLAR bit is set to ‘1,’ the ADCH ; It reads the ADC and outputs the five-digit
; number on LCD.
rcall cmd
ldi r16,1
contains the most significant eight ; Program authored by Prof. K. Padmanabhan rcall cmd
; ************************************************* rcall delay1
bits, while the ADCL contains the least .NOLIST ret
.INCLUDE “m8535def.inc” delay1:clr result
two significant bits in bit positions ;device =ATMega8535 loop22:ldi R16,$f0
.LIST loop2:inc R16
7 and 6.

120 Electronics projects Vol. 26


Fig. 21: Circuit for temperature display on either the LCD or the PC

brne loop2 .def tBCD1 =r14 out SPH, R16; Initialize high byte of stack
inc result ;BCD value digits 3 and 2 pointer to end of internal RAM
brne loop22 .def tBCD2 =r15 ldi rmpr,0b00000001;TIMER 0 INTERRUPT ENABLE
ret ;BCD value digit 4 out TIMSK,rmpr
lcddisp: push r16 .def fbinL =r16 ldi rmpr,05 ; So, we get once 1x10^6/1024=1000 Hz
ldi r16,128 ;cursor to left end ;binary value Low byte out TCCR0,rmpr ;prescalar 1024 so that timer
rcall cmd .def fbinH =r17 interrupt occurs at 1KHz rate
pop r16 ;binary value High byte ldi r16,$c0 ;c0 for int. ref, e0 with adch
rcall binbcd .def cnt16a =r18 alone used.
mov r16,r15 ;loop counter out admux,r16 ;channel 0 is selected
andi r16,0x0f .def tmp16a =r19 ldi r16,0b11000101 ;prescale /32 (1x32=33 usec)
ori r16,0x30 ;temporary value ;adc enable,adc start,adc freerun,adcflag,adcno int,
rcall lcdwr ; 1 bin2BCD16: adcprescale/32
mov r16,r14 ldi cnt16a,16 ;Init loop counter out adcsra,r16
andi r16,0b11110000 clr tBCD2 ldi r16,0
ror r16 ;clear result (3 bytes) out sfior,r16 ;write 0-0-0 to bits d7-d5 for
ror r16 clr tBCD1 free run
ror r16 clr tBCD0 adc
ror r16 clr ZH here1:in r16,adcsra
ori r16,0x30 ;clear ZH (not needed for AT90Sxx0x) andi r16,0b01000000
rcall lcdwr ;2 bBCDx_1:lsl fbinL ;shift input value breq here1 ;value got
mov r16,r14 rol fbinH ldi R16,255
andi r16,0x0f ;through all bytes out ddrb,R16 ; port b is all bits output
ori r16,0x30 rol tBCD0 ; out ddrc,R16 ; so is port c
rcall lcdwr ;3 rol tBCD1 ldi r16,0
mov r16,r13 rol tBCD2 out ddra,r16 ;port a input
andi r16,0b11110000 dec cnt16a init: sei ;enable global interrupt
ror r16 ;decrement loop counter LCD: rcall init_lcd
ror r16 brne bBCDx_2 ;if counter not zero ldi R16,$80
ror r16 ret ; return rcall cmd
ror r16 here3:in r16,adcsra
ori r16,0x30 bBCDx_2:ldi r30,AtBCD2+1 andi r16,0b01000000
rcall lcdwr ;4 ;Z points to result MSB + 1 brne here3 ;value got
mov r16,r13 bBCDx_3: ld tmp16a,-Z ;get (Z) with in r16,adcl
andi r16,0x0f pre-decrement in r17,adch
ori r16,0x30 subi tmp16a,-$03 ;add 0x03 rcall lcddisp
rcall lcdwr ;5 sbrc tmp16a,3 ;if bit 3 not idle: ldi r16,(1<<SE)
ret clear out mcucr,r16
binbcd: st Z,tmp16a ;store back sleep
;* “bin2BCD16” - 16-bit Binary to BCD conversion ld tmp16a,Z ;get (Z) rjmp idle
;* converts 16-bit number (fbinH:fbinL) to a 5-digit subi tmp16a,-$30 ;add 0x30 restrt:ldi r16,$80 ;point to first cursor
;* packed BCD number represented by 3 bytes sbrc tmp16a,7 ;if bit 7 not rcall cmd ; command to lcd to position cursor
(tBCD2:tBCD1:tBCD0). clear rcall delay1
;* MSD of 5-digit number is placed in lowermost st Z,tmp16a ;store back ldi r16,0b11000101 ;prescale /32 (4.43/32=138
nibble of tBCD2. cpi ZL,AtBCD0 ;done all three? usec)=7.2Khz
;* Number of words :25 brne bBCDx_3 ;loop again if ;adc enable,adc start,adc freerun,adcflag,adcno int,
;* Number of cycles :751/768 (Min/Max) not adcprescale/32
;* Low registers used :3 (tBCD0,tBCD1,tBCD2) rjmp bBCDx_1 out adcsra,r16
;* High registers used :4(fbinL,fbinH,cnt16a,tmp16a) here4: in r16,adcsra
;* Pointers used :Z ; Main program routine starts here andi r16,0b01000000
Subroutine register variables Start:ldi R16,low(RAMEND);Load low byte address brne here4 ;value got
.equ AtBCD0 =13 of end of RAM into register R16 in r16,adcl
;address of tBCD0 out SPL,R16; Initialize stack in r17,adch
.equ AtBCD2 =15 pointer to end of internal RAM sbi adcsra,6 ;restart adc
;address of tBCD1 ldi R16,high(RAMEND);Load hh: rcall lcddisp
.def tBCD0 =r13 high byte address of end of RJMP restrt ; Test of the serial interface
;BCD value digits 1 and 0 RAM into register R16

Electronics Projects vol. 26 121


baud rate register loop21:inc R16
Note. The adc_lcd.asm pro- ldi rmpr, 0 brne loop21
out ubrrh,rmpr inc result
gram together with the .hex file, for LDI rmpr,(1<<Rxen)|(1<<Txen)| brne loop221
directly programming into the chip, is (1<<RXCIE) pop r16
out UCsRB,rmpr ret
provided in the EFY-CD. LDI ZL,0 ; Wait some time delay: clr result
LDI ZH,0 ld: inc result
Fig. 21 shows the circuit for view- InitSio1: brne ld
SBIW ZL,1 ret
ing the analogue temperature (°C) BRNE InitSio1 lcddisp:push r16
ldi r16,(1<<Ursel)|(1<<USBS)| ldi r16,128 ;cursor to left end
output of an LM35 temperature sensor (3<<UCSZ0) rcall cmd
IC connected to ADC Ch.0 (pin 40) of out ucsrc,r16 pop r16
RET rcall delay1
the AVR on the LCD screen in 5-digit USART_RXC: rcall delay1
push r16 rcall binbcd
decimal format after analogue-to-digi- in R16,udr mov r16,r15
andi R16,07 andi r16,0x0f
tal conversion using the ATmega8535 mov r1,r16 ori r16,0x30
chip with the adc_lcd program. The ori r16,$c0 rcall tout
out admux,r16 rcall lcdwr ; 1
same circuit with addition of MAX232 ldi r16,$43 mov r16,r14
rcall tout ; intimate new channel to host andi r16,0b11110000
chip and ATmega8535 can be used ldi r16,$48 ror r16
rcall tout ror r16
for interfacing to a PC for viewing the mov r16,r1 ror r16
ori r16,$30 ror r16
temperature data on the PC screen. rcall tout ori r16,0x30
However, for that you have to program pop r16
reti
rcall tout
rcall lcdwr ;2
the AVR with the firmware as de- cmd: cbi portc,2 mov r16,r14
cbi portc,3 andi r16,0x0f
scribed in the succeeding paragraphs. cbi portc,4 ori r16,0x30
out portb,r16 rcall tout
sbi portc,4 rcall lcdwr ;3
Using the UART in the nop mov r16,r13
ATmega8535 nop
nop
andi r16,0b11110000
ror r16
nop ror r16
Serial communication between the mi- nop ror r16
nop ror r16
crocontroller and a PC is essential for nop ori r16,0x30
nop rcall tout
data transfer to the microcontroller and nop rcall lcdwr ;4
cbi portc,4 mov r16,r13
reading of its ADC output by the PC. rcall delay1 andi r16,0x0f
The universal asynchronous receiver rcall delay1 ori r16,0x30
rcall delay1 rcall tout
transmitter (UART) built into the mi- ret rcall lcdwr ;5
lcdwr:cbi portc,2 ldi r16,$0a
crocontroller can be programmed to cbi portc,3 rcall tout
cbi portc,4 ldi r16,$0d
operate at certain baud rates. sbi portc,2 rcall tout
The adc_ch.asm sample pro- out portb,r16 ret
sbi portc,4 binbcd:
gram given below is useful for UART nop ;* “bin2BCD16” - 16-bit Binary to BCD conversion
nop ;* convert 16-bit number (fbinH:fbinL) to a 5-digit
applications: nop ;* packed BCD number represented by 3 bytes
nop (tBCD2:tBCD1:tBCD0).
nop ;* MSD of 5-digit number is placed in the lowermost
nop nibble of tBCD2.
ADC_CH.ASM nop ;* Number of words :25
; ************************************************* nop ;* Number of cycles :751/768 (Min/Max)
; This program read one of ADC channels (0 to 7). nop ;* Low registers used :3 (tBCD0,tBCD1,tBCD2)
The Channel can be selected by sending Channel cbi portc,4 ;* High registers used :4(fbinL,fbinH,cnt16a,tmp16a)
number. rcall delay1 ;* Pointers used :Z
; ATmega8535 receives the Channel no. and outputs ret
the five digit ADC value init_lcd: ; Subroutine Register Variables
; on RS232 port for reading by a PC’s XTALK ldi R16,$38 .equ AtBCD0 =13 ;address of tBCD0
program or a VB project. rcall cmd .equ AtBCD2 =15 ;address of tBCD1
; Software features: It is possible to read the ADC rcall delay1 .def tBCD0 =r13 ;BCD value digits 1 and 0
value and also rcall delay1 .def tBCD1 =r14 ;BCD value digits 3 and 2
; transmit to the PC for data logging. ldi R16,$0e .def tBCD2 =r15 ;BCD value digit 4
; ************************************************* rcall cmd .def fbinL =r16 ;binary value Low byte
.NOLIST rcall delay1 .def fbinH =r17 ;binary value High byte
.INCLUDE “m8535def.inc” ldi R16,6 .def cnt16a =r18 ;loop counter
;device =ATMega8535 rcall cmd .def tmp16a =r19 ;temporary value
.LIST ldi r16,1
.EQU xyz = 12345 rcall cmd bin2BCD16:
; Constants for Sio properties rcall delay2 ldi cnt16a,16 ;Init loop counter
.EQU fq=1000000; clock frequency of m8535 with ret clr tBCD2 ;clear result (3 bytes)
internal oscillator tout: sbis UcSRa,UDRE ;TX COMPLETE check clr tBCD1
.EQU baud=4800; Baudrate for SIO communication RJMP tout clr tBCD0
.EQU bddiv=(fq/(16*baud))-1; Baudrate divider OUT UDR,R16 clr ZH ;clear ZH (not
.DEF rmpr = R16 Ret needed for AT90Sxx0x)
.DEF temp = R14 delay1:push r16 bBCDx_1:lsl fbinL ;shift input value
.DEF result=R12 clr result rol fbinH ;through all bytes
.DEF mpr =R16 loop22:ldi R16,$f0 rol tBCD0
.CSEG loop2:inc R16 rol tBCD1
.ORG $0000 brne loop2 rol tBCD2
rjmp Start ; Reset-vector inc result dec cnt16a ;decrement loop counter
.org $000b brne loop22 brne bBCDx_2 ;if counter not zero
rjmp USART_RXC pop r16 ret ; return
.org $0100 ret bBCDx_2:ldi r30,AtBCD2+1 ;Z points to
InitSio: delay2:push r16 result MSB + 1
LDI rmpr,bddiv ; Init baud generator clr result bBCDx_3:
OUT UBRRL,rmpr ; set divider in UART loop221:ldi R16,$f0 ld tmp16a,-Z ;get (Z) with pre-decrement

122 Electronics projects Vol. 26


subi tmp16a,-$03 ;add 0x03
sbrc tmp16a,3 ;if bit 3 not ; Main program routine starts here
clear Start:ldi R16,low(RAMEND);Load low byte address
st Z,tmp16a ;store back of end of RAM into
register R16
ld tmp16a,Z ;get (Z) out SPL,R16 ; Initialize stack pointer to
subi tmp16a,-$30 ;add 0x30 end of internal RAM
sbrc tmp16a,7 ;if bit 7 not clear ldi R16,high(RAMEND);Load high byte
st Z,tmp16a ; store back address of end
cpi ZL,AtBCD0 ;done all three? of RAM into
brne bBCDx_3 ;loop again if not register R16
Fig. 22: Screenshot of ADC_CHSEL application rjmp bBCDx_1 ;End of the subroutine out SPH, R16 ;Initialize high
section byte of stack pointer
to end of internal RAM
ldi r16,$c0 ; c0 for int. ref, e0 with adch alone
used.
out admux,r16 ; channel 0 is selected
ldi r16,0b11000101 ;prescale /32 (1x32=33 usec)
;adc enable,adc start,adc freerun,adcflag,adcno
int,
adcprescale/32
out adcsra,r16
ldi r16,0
out sfior,r16 ; write 0-0-0 to bits d7-d5 for
free
run adc
here1:in r16,adcsra
andi r16,0b01000000
breq here1 ;value got
ldi R16,255
out ddrb,R16 ; port b is all bits output
out ddrc,R16 ; so is port c
ldi r16,0
out ddra,r16 ;port a input
init: rcall initsio
sei ;enable global interrupt
LCD: rcall init_lcd
lcd1: ldi R16,$80
rcall cmd
rcall delay1
rcall delay1
rcall delay1
rcall delay1
here3:in r16,adcsra
andi r16,0b01000000
brne here3 ;value got
in r16,adcl
IN R17,adch
push r16
ldi r16,0b11000101 ;prescale /32 (1x32=32
usec)
;adc enable,adc start,adc freerun,adcflag,adcno int,
adcprescale/32
out adcsra,r16
Fig. 23: Integrated actual-size PCB layout (including the 5V power supply circuit given in Part 1) for all pop r16
the applications described in this 3-part article rcall lcddisp
rjmp lcd1
in r16,udr
andi r16,07
mov r14,r16
ori r16,$c0
out admux,r16
ldi r16,$43
rcall tout ; intimate new channel to host
ldi r16,$48
rcall tout
mov r16,r14
ori r16,$30
rcall tout
rjmp lcd1

The above program reads the ADC


output data, whose decimal value is
output to pin 15 (TX) of ATmega8535 at
4800 bauds in 8-bit ASCII data format.
If a MAX232 is wired to pin 15, it can
be directly connected to the receive pin
of the RS-232 com port of a PC. Then,
by using any terminal program (such as
XTALK), it can be received by the PC.
The program (adc_ch.asm) may
be tested as follows:
1. Wire ATmega8535 to the LCD
and the serial port through a MAX232
IC as shown in Fig. 21.
Fig. 24: Component layout for the PCB
2. Connect an analogue signal (e.g.,

Electronics Projects vol. 26 123


a DC voltage in the 0-5V range tapped to change (by altering the value of the of coefficients when implementing
from a potmeter or the output of LM35 bits in the ADMUX register of the chip) algorithms on fixed-point ar-
used in the preceding application) to the ADC channel currently chosen. chitectures, actual implementation
ADC Ch. 0 (pin 40). Thus all the following data will pertain examples and possible ways to optimise/
3. Program the adc_ch.asm file into to this channel only and the same will modify the implementations suggested.
the flash memory of ATmega8535 after be informed to the PC terminal also by 3. AVR240: 4x4 Keypad-Wake Up
compilation. sending CH3 followed by data stream. on Keypress. This application note
4. Place the IC on the breadboard The XTALK terminal program is describes a simple interface to a 4×4
and press reset. given only for testing purposes. The keypad designed for low-power bat-
5. Connect the RS-232 connector of Visual Basic program (ADC_CHSEL) tery operation.
the PC through a 3-wire cable to the provided in the EFY-CD of this month Also there are application notes for
MAX232 pins on the board. The TXD does the same. It has two windows, interfacing the AVR to an IR detector
output from ATmega8535 should go to one of which is a Combo box for select- much like the TV remote. Other topics
RXD pin of the PC’s com port and the ing the channel and the other shows of interest relating to the AVR are use
PC’s TXD output should go to RXD pin the 5-digit data continuously. Selec- of watchdog, power idle modes, SPI
of ATmega8535. tion of the channel is possible via the interfacing for communication, etc.
6. Run the XTALK program on the Combo box (Fig. 22). Many have tried out the SPI interface
PC and set the baud rate as ‘4800,’ data for data communication, but it is
as ‘8 bits,’ parity as ‘none,’ stop as ‘1,’ Application notes with found to be more complex compared
and com as ‘1’ or ‘2,’ type ‘go low,’ programs to the RS-232 protocol. The RS-232
then press ‘Enter’ key. You may visit Atmel’s Website ‘www. link for ADC data, which is described
7. Observe the ADC data continu- atmel.com/dyn/products/app_notes. above, makes a really useful serial
ously on the screen. asp?family_id=607’ for the following data-acquisition system.
The PC terminal program can application notes. An integrated actual-size PCB
be used to select one of the eight 1. AVR100: Accessing the EE- layout (including the 5V power
desired channels. For this, type any PROM. This application note supply circuit given in Part 1) for
number from ‘0’ to ‘7.’ For example, contains assembly routines for all the applications described in this
to select channel-3 ADC, type ‘3.’ accessing the EEPROM for all AVR 3-part article is shown in Fig. 23.
Remember you need not press Enter devices. It includes the code for The component layout for the same
key thereafter. reading and writing EEPROM addresses is shown in Fig. 24. Suitable pads
The data from the PC terminal is sequentially and at random addresses. (not shown in the component layout)
received by the USART_RX subrou- 2. AVR223: Digital Filters with have been provided for wiring the
tine in the interrupt mode. The main AVR. This document focuses on components. 
program configures the received data the use of the AVR hardware multi- Download source code: http://
to interrupt the processor. In the inter- plier and general-purpose registers www.efymag.com/admin/issuepdf/
rupt routine, the number sent is used for accumulator functionality, scaling Application%20AVR%20Part%20II.zip

124 Electronics projects Vol. 26


Speed Checker
for Highways
 Dipanjan Bhattacharjee Circuit description Parts List
Fig. 2 shows the circuit of the speed Semiconductors:

W
IC1-IC5 - NE555 timer
hile driving on highways, checker. It has been designed assuming IC6- IC9 - CD4026 decade
motorists should not exceed that the maximum permissible speed counter/7-segment
decoder
the maximum speed limit for highways is either 40 kmph or 60 IC10 - CD4011 NAND gate
permitted for their vehicle. However, kmph as per the traffic rule. IC11 - 7812 12V regulator
D1, D2 - 1N4148 switching diode
accidents keep occurring due to speed The circuit is built around five D3-D6 - 1N4007 rectifier diode
violations since the drivers tend to ig- NE555 timer ICs (IC1 through LED1 - Green LED
LED2, LED3 - Red LED
nore their speedometers. IC5), four CD4026 counter ICs (IC6 DIS1-DIS4 - LTS543 common-cath-
This speed checker will come through IC9) and four 7-segment ode, 7-segment display
handy for the highway traffic police displays (DIS1 through DIS4). IC1 Resistors (all ¼-watt, ±5% carbon):
R1, R4 - 100-kilo-ohm
as it will not only provide a digital through IC3 function as monostables, R2, R5, R6,
display in accordance with a vehicle’s with IC1 serving as count-start mono, R8, R10,
R11, R14 - 10-kilo-ohm
speed but also sound an alarm if the IC2 as count-stop mono and IC3 as R3, R7, R13,
vehicle exceeds the permissible R16-R19 - 470-ohm
R9 - 470-kilo-ohm
speed for the highway. R12, R15 - 1-kilo-ohm
The system basically com- VR1, VR2 - 100-kilo-ohm preset
VR3 - 20-kilo-ohm preset
prises two laser transmitter-LDR
Capacitors:
sensor pairs, which are installed C1 - 100µF, 25V electrolytic
on the highway 100 metres apart, C2, C4, C6,
C8, C11 - 0.01µF ceramic disk
with the transmitter and the LDR C3, C13, C15 - 0.1µF ceramic disk
sensor of each pair on the oppo- C5 - 10µF, 25V electrolytic
C7 - 0.47µF, 25V electrolytic
site sides of the road. The installa- C9 - 0.2µF ceramic disk
tion of lasers and LDRs is shown C10 - 1µF, 25V electrolytic
C12 - 47µF, 25V electrolytic
in Fig. 1. The system displays the C14 - 1000µF, 35V electrolytic
time taken by the vehicle in cross- Miscellaneous:
ing this 100m distance from one Fig. 1: Installation of lasers and LDRs on highway X1 - 230V AC primary to
pair to the other with a resolution 0-15V, 500mA secondary
transformer
of 0.01 second, from which the speed of speed-limit detector mono, controlled PZ1 - Piezobuzzer
the vehicle can be calculated as follows: by IC1 and IC2 outputs. Bistable set- LDR1, LDR2 - LDR
S1, S2 - Push-to-on switch
Distance reset IC4 is also controlled by the S3 - On/Off switch
Speed (kmph) = outputs of IC1 and IC2 and it (IC4), in - Pointed laser light
Time
turn, controls switching on/off of the
0.1 km 100Hz (period = 0.01 second) astable keeps falling on the LDR sensor con-
=
(Reading×0.01)/3600 timer IC5. tinuously and thus the LDR offers a
or, The time period of timer NE555 (IC1) low resistance and pin 2 of IC1 is high.
36000
Reading (on display) = count-start monostable multivibrator is Whenever light falling on the LDR is
Speed
adjusted using preset VR1 or VR2 and interrupted by any vehicle, the LDR
As per the above equation, for a capacitor C1. For 40kmph limit the time resistance goes high and hence pin 2 of
speed of 40 kmph the display will read period is set for 9 seconds using preset IC1 goes low to trigger the monostable.
900 (or 9 seconds), and for a speed of VR1, while for 60kmph limit the time As a result, output pin 3 goes high for
60 kmph the display will read 600 (or 6 period is set for 6 seconds using preset the preset period (9 or 6 seconds) and
seconds). Note that the LSB of the dis- VR2. Slide switch S1 is used to select LED1 glows to indicate it. Reset pin 4
play equals 0.01 second and each suc- the time period as per the speed limit is controlled by the output of NAND
ceeding digit is ten times the preceding (40 kmph and 60 kmph, respectively). gate N3 at power-on or whenever reset
digit. You can similarly calculate the The junction of LDR1 and resistor R1 is switch S2 is pushed.
other readings (or time). coupled to pin 2 of IC1. For IC2, the monostable is triggered
Normally, light from the laser in the same way as IC1 when the vehicle

Electronics Projects vol. 26 125


126
Electronics projects Vol. 26
Fig. 2: Circuit of speed checker for highway
multivibrator whose time period is de-
cided by preset VR3, resistor R12 and
capacitor C10. Using preset VR1, the
frequency of the astable multivibrator
is set as 100 Hz. The output of IC5 is
fed to clock pin 1 of decade counter/7-
segment decoder IC6 CD4026.
IC CD4026 is a 5-stage Johnson
decade counter and an output decoder
that converts the Johnson code into a
Fig. 3: Power supply
7-segment decoded output for driving

Fig. 4: Actual-size, single-side PCB layout for the speed checker Fig. 5: Component layout for the PCB

intersects the laser beam incident on Resistor R9 and capacitor C5 decide the DIS1 display. The counter advances by
LDR2 to generate a small pulse for stop- time period for which the piezobuzzer one count at the positive clock signal
ping the count and for use in the speed sounds. transition.
detection. LED2 glows for the duration The output of IC1 triggers the The carry-out (Cout) signal from
for which pin 3 of IC2 is high. bistable (IC4) through gate N2 at the CD4026 provides one clock after every
The outputs of IC1 and IC2 are fed leading edge of the count-start pulse. ten clock inputs to clock the succeed-
to input pins 2 and 1 of NAND gate When pin 2 of IC4 goes low, the high ing decade counter in a multidecade
N1, respectively. When the outputs of output at its pin 3 enables astable clock counting chain. This is achieved by
IC1 and IC2 go high simultaneously generator IC5. Since the count-stop connecting pin 5 of each CD4026 to pin
(meaning that the vehicle has crossed pulse output of IC2 is connected to pin 1 of the next CD4026.
the preset speed limit), output pin 3 of 6 of IC4 via diode D1, it resets clock A high reset signal clears the de-
gate N1 goes low to trigger monostable generator IC5. IC5 can also be reset via cade counter to its zero count. Pressing
timer IC3. The output of IC3 is used for diode D2 at power-on as well as when switch S2 provides a reset signal to pin
driving piezobuzzer PZ1, which alerts reset switch S2 is pressed. 15 of all CD4026 ICs and also IC1 and
the operator of speed-limit violation. IC5 is configured as an astable IC4. Capacitor C12 and resistor R14

Electronics Projects vol. 26 127


generate the power-on-reset signal. ies may be used. high for the time set to cross 100 metres
The seven decoded outputs ‘a’ with the selected speed (60 kmph) and
through ‘g’ of CD4026s illuminate Construction and working LED1 glows during for period. When
the proper segment of the 7-segment Assemble the circuit on a PCB. An the vehicle crosses the second laser
displays (DIS1 through DIS4) used actual-size, single-side PCB layout for light, the output of IC2 goes high and
for representing the decimal digits ‘0’ the speed checker is shown in Fig. 4 LED2 glows for this period.
through ‘9.’ Resistors R16 through R19 and its component layout in Fig. 5. Piezobuzzer PZ1 sounds an alarm if
limit the current across DIS1 through Before operation, using a multime- the vehicle crosses the distance between
DIS4, respectively. ter check whether the power supply the laser set-ups at more than the se-
Fig. 3 shows the circuit of the pow- output is correct. If yes, apply power lected speed (lesser period than preset
er supply. The AC mains is stepped supply to the circuit by flipping switch period). The counter starts counting
down by transformer X1 to deliver the S3 to ‘on.’ In the circuit, use long wires when the first laser beam is intercepted
secondary output of 15 volts, 500 mA. for connecting the two LDRs, so that and stops when the second laser beam
The transformer output is rectified by you can take them out of the PCB and is intercepted. The time taken by the
a bridge rectifier comprising diodes install on one side of the highway, vehicle to cross both the laser beams
D3 through D6, filtered by capacitor 100 metres apart. Install the two laser is displayed on the 7-segment display.
C14 and regulated by IC11 to provide transmitters (such as laser torches) on For 60kmph speed setting, with timer
regulated 12V supply. Capacitor the other side of the highway exactly frequency set at 100 Hz, if the display
C15 bypasses any ripple in the regu- opposite to the LDRs such that laser count is less than ‘600,’ it means that the
lated output. Switch S3 is used as the light falls directly on the LDRs. Reset vehicle has crossed the speed limit (and
‘on’/‘off’ switch. In mobile applica- the circuit by pressing switch S2, so the simultaneously the buzzer sounds). Re-
tion of the circuit, where mains 230V display shows ‘0000.’ Using switch S1, set the circuit for monitoring the speed
AC is not available, it is advisable to select the speed limit (say, 60 kmph) of the next vehicle.
use an external 12V battery. For acti- for the highway. When any vehicle Note. This speed checker can
vating the lasers used in conjunction crosses the first laser light, LDR1 will check the speed of only one vehicle at
with LDR1 and LDR2, separate batter- trigger IC1. The output of IC1 goes a time. 

128 Electronics projects Vol. 26


Section B:
Circuit Ideas
Audio Amplifier for
personal stereo
 M. Venkateswaran pushpull amplifier, each transistor (T2 tor T2 and R5 and R7 for transistor
or T3) gets double the voltage when T3) so that the acceptable output

I
n the output stages of most broad- activated. without overheating is obtained.
cast receivers and some amplifiers, Connect the low audio signal from You can also replace these transistors
there is a limit up to which maxi- the stereo system at input terminals with another pair of suitable high-
mum power can be developed with- A and B of the audio amplifier and power transistors.
out distortion. In the widely accepted provide mains AC to activate the cir- For driving transistors T2 and T3,
output circuit, two output transistors cuit. During the first half cycle of an a 9V audio driver transformer having
are connected in series between the AF cycle, transistor T2 conducts and six leads is used. It is readily available
positive and ground and biasing is ad- the current flows from positive rail to in the market and reasonably matches

justed so that each transistor gets half ground rail (centre tap of transformer the output and input impedances of
the supply voltage. X1) via the loudspeaker coil (connected the preceeding and succeeding stages.
The circuit presented here is a between the emitter of transistor T2 To test the quality of the audio
simple audio amplifier for a personal and ground) in one direction. While output, connect the stereo’s outputs
stereo system. In this, supply voltage in the second half cycle, transistor T3 to the respective terminals A and B.
to each transistor can be enhanced to conducts and the current flows from Now increase the volume level of
produce a larger output. The audio ground rail to negative rail via the the stereo slowly. If you get a
driver transformer drives the transis- loudspeaker coil (connected between high-level, high-quality sound across
tors adequately. ground and the collector of transistor loudspeaker L1, the amplifier is
A 9V-0-9V, 300mA transformer T3) in a direction opposite to the previ- working well. If the sound quality is
has been used in the set-up. Out of ous flow. not good, decrease the volume level
the four diodes (D1 through D4), two Transistors T2 and T3 of the until the audio amplifier gives good
are used for developing the posi- pushpull audio amplifier should results.
tive voltage rail (+9V) and the other be matched correctly. If these transis- Note that this audio amplifier
two are used for developing the tors get heated, change the bleeding works well for low-level audio
negative voltage rail (–9V). In the resistor pairs (R3 and R4 for transis- signals. 

Electronics Projects Vol. 26 131


Infrared Object Counter
 Rambir Singh of about 38 kHz, and two infrared calculator to advance the count by one.
light-emitting diodes (LEDs). The Both the transmitter and the receiv-

T
his infrared object counter can receiver circuit (see Fig. 2) is powered er can be assembled on any general-
be installed at the entry gate to by a 5V regulated power supply built purpose PCB. Place the transmitter and
count the total number of people around transformer X1, bridge recti- the receiver around one metre apart.
entering any venue. For example, it can fier comprising diodes D1 through D4 For calibration, press switches S1
be used at the railway stations or bus and regulator IC2. It uses an infrared and S2 followed by ‘on’ key of the
stands to count the people arriving per receiver (IR) module (RX1), optocoupler calculator. Now press ‘1’ and ‘+’ keys
day or week. (IC3) and a simple calculator. sequentially to get ‘1’ on the screen of
The counter uses an infrared When switch S1 is in ‘on’ position, the calculator. Then, place a piece of
transmitter-receiver pair and a simple, the transmitter circuit activates to cardboard between the transmitter and
low-cost calculator. It works even in the produce a square wave at its output the receiver to interrupt the IR rays two
pin 3. The two infrared LEDs (IR times. If the calculator counts ‘2,’ the
LED1 and IR LED2) connected at counter is working properly for that
its output transmit modulated IR range. Repeat this procedure for higher
beams at the same frequency (38 ranges as well. If there is any problem,
kHz). The oscillator frequency can adjust VR1.
be adjusted using preset VR1. For installation, switch off the
In the receiver circuit, IR re- transmitter, receiver and calculator,
ceiver module TSOP1738, which and mount the transmitter and the
is commonly used in colour tele- receiver on the opposite pillars of the
Fig. 1: Transmitter circuit visions for sensing the IR signals main entry gate such that they are

Fig. 2: Receiver-cum-counter circuit

presence of normal light. The maximum transmitted from the TV remote, is properly orientated towards each
detection range is about 10 metres. That used as the sensor. other. Mount the calculator where you
means the transmitter and the receiver The IR beams transmitted by IR can read it easily. Connect pins 4 and 5
are to be installed (at the opposite pil- LED1 and LED2 fall on infrared re- of IC3 across ‘=’ key connections on the
lars of the gate) not more than 10 metres ceiver module IR RX1 of the receiver PCB of the calculator.
apart. No focusing lens is required. If an circuit to produce a low output at its Now switch on the transmitter and
8-digit calculator is used the counter can pin 2. This keeps transistor T1 in non- the receiver by pressing switches S1
count up to 99,999,999 easily, and if a conduction mode. and S2, respectively. Thereafter, switch
10-digit calculator is used the counter Now when anyone enters through on the calculator and press ‘1’ followed
can count up to 9,999,999,999. the gate to interrupt the IR beam, the IR by ‘+’ key of the calculator to initialise
Powered by a 9V battery, the trans- receiver module produces a high output it. Now your counter is ready to count.
mitter circuit (see Fig. 1) comprises IC pulse at its pin 3. As a result, transis- The calculator reads ‘1’ after one
555 (IC1), which is wired as an astable tor T1 conducts to activate IC3 and its interruption, ‘2’ after second interrup-
multivibrator with a centre frequency internal transistor shorts key ‘=’ of the tion and so on. 

132 Electronics Projects Vol. 26


Long-Range Burglar Alarm
Using Laser Torch
 Pradeep G. your big compounds, etc. The alarm The transmitter circuit is powered
comprises laser transmitter and re- by 3V DC. The astable multivibrator

L
aser torch-based burglar alarms ceiver units, which are to be mounted built around timer 7555 (IC1) produces
normally work in darkness only. on the opposite pillars of the entry gate. 5.25kHz frequency. CMOS version
But this long-range photoelectric Whenever anyone enters to interrupt of timer 7555 is used for low-voltage
alarm can work reliably in daytime the transmitted laser beam falling on operation. The body of the laser torch
also to warn you against intruders in the receiver, the buzzer in the receiver is connected to the emitter of npn tran-
circuit sounds an alarm. sistor T1 and the spring-loaded lead
The range of this burglar protruding from inside the torch is
alarm is around 30 me- connected to the ground.
tres, which means you can The receiver circuit is powered by
place the transmitter and 12V DC. It uses photoDarlington 2N5777
the receiver up to 30 metres (T2) to sense the laser beam transmitted
apart. Since the laser torch from the laser torch. The output beam
can transmit light up to a signals from photoDarlington are given
distance of 500 metres, this to the two-stage amplifier followed by
range can be increased by switching circuit, etc. As long as the
orienting the phototransistor laser beam falls on photoDarlington
sensor properly. To avoid T2, relay RL1 remains un-energised and
false triggering by sunlight, the buzzer does not sound. Also, LED1
mount the phototransistor doesn’t glow.
sensor such that it doesn’t When anyone interrupts the
Fig. 1: Circuit of laser torch based transmitter directly face sunlight. laser beam falling on photoDarling-
ton T2, npn transistor T6 stops
conducting and npn transistor T7
is driven into conduction. As a
result, LED1 glows and relay RL1
energises to sound the buzzer
for a few seconds (determined
by the values of resistor R15 and
capacitor C10). At the same time,
the large indication load (230V AC
alarm for louder sounds or any
other device for momentary indi-
cation) also gets activated as it is
connected to 230V AC mains via
normally opened (N/O) contact of
Fig. 2: Receiver circuit
relay RL1. 

Electronics Projects Vol. 26 133


Musical light chaser
 Debaraj Keot No electrical connection is to be made regulator 7809, triac BT136 and level
between the music system and the meter IC LB1403.

T
his music-operated lighting ef- lighting effect generator circuit. You The circuit is powered by regu-
fect generator comprises five just need to place the gadget near the lated 9V DC. The AC mains is stepped
sets of 60W bulbs that are ar- speakers of the music system. down by transformer X1 to deliver a
ranged in zig-zag fashion. The bulb Fig. 1 shows the complete circuit secondary output of 12V AC at 250
sets glow one after another depending of the musical light chaser, while mA. The transformer output is recti-
on the intensity of the audio signal. Fig. 2 shows pin configurations of 9V fied by a full-wave rectifier compris-

Fig. 1: Circuit diagram of musical light chaser

134 Electronics Projects Vol. 26


LB1403 (IC3) at its input pin 8. IC3 is VR2 and capacitor C7. Here, variable
a five-dot LED level meter commonly resistor VR2 is used for varying the re-
used in stereo systems for LED bar- sponse speed of the chaser light as de-
graph displays. It has a built-in ampli- sired. When VR2 is set in the minimum
fier, comparators and constant current resistance position, the response is very
source at its output pins. fast, and when it is set at the maximum
Depending on the intensity of the resistance, the response is slow.
input audio signals, all or some out- The complete circuit including the
Fig. 2: Pin configuration
puts of IC3 go low to drive transistors power supply can be constructed on
ing diodes D1 and D2 and filtered T1 through T5, which, in turn, fire the any general-purpose PCB or a small
by capacitors C1 and C2. Regulator corresponding triacs TR1 through TR5 Vero board. Triacs TR1 through TR5
IC 7809 (IC1) provides regulated 9V via their gates and multicoloured zig- should be kept away from the op-amp
power supply to the circuit. Closing zag bulb sets comprising ZL1 through and its related components. The metal-
switch S1 provides power to the cir- ZL5 glow. lic parts of the triacs should not touch
cuit and LED1 glows to indicate that When the audio level is low, only each other and the other parts of the
the circuit is ready to work. triac T1 is fired and the zig-zag bulb circuit. After assembling the circuit,
When you put your music system set ZL1 turns on and off sequentially. house it in a suitable shockproof plastic
in front of the condenser microphone When the audio level is high, triacs cabinet. Make some holes in the cabi-
of the light chaser, the sound pressure TR1 through TR5 get fired and all the net for heat dissipation.
variation is converted into electrical bulb sets (ZL1 through ZL5) turn on Note. 1. Some zig-zag lights have
signals by the condenser microphone. and off sequentially. a special bulb called ‘master bulb’
These weak electrical signals are am- Pin 7 of IC3 is used for selecting for automatic flickering. It should be
plified by op-amp µA741 (IC2), which the response speed of the lighting. The removed and replaced with a simple
is configured as an inverting amplifier. larger the time constant, the slower the non-flickering colour bulb.
Using preset VR1 you can set the sensi- response, and vice versa. The time con- 2. Never touch any naked part of
tivity of the circuit. stant can be changed by changing the the circuit when it is connected to the
The amplified output is fed to IC values of resistor R6, variable resistor mains. 

Electronics Projects Vol. 26 135


Automatic Soldering
Iron Switch
 T.A. Babu no power when it is inactive. The cir- triggered and its output pin 3 goes high
cuit can also be used for controlling for around 18 minutes to keep relay

Q
uite often, we forget to turn the electric iron, kitchen timer or other RL1 energised via transistor T1. At the
off the soldering iron. This re- appliances. same time, capacitor C3 charges and
sults in not only a smoking At the heart of the circuit is a mo- AC supply is provided to switch on
oxidised iron but also waste nostable multivibrator built around the soldering iron via normally opened
of electricity. To solve this problem, timer IC 555. When the circuit is in (N/O) contacts of relay RL1.
The soldering iron
remains ‘on’ for the
time period prede-
termined by resistor
R1 and capacitor C2.
Here, this time is set
for 18 minutes. Flash-
ing of LED1 indicates
the heating progress
of the soldering iron.
When the predeter-
mined time is over,
relay RL1 de-ener-
gises to turn off the
soldering iron and
the buzzer sounds
until capacitor C3 gets
discharged.
For switching on
here’s a circuit that automatically sleep mode, to switch on the solder- the circuit, use either a bell push
switches off the soldering iron after a ing iron, you should push switch S1 switch or a similar switch with ap-
predetermined time. The circuit draws momentarily. The multivibrator gets propriate current carrying capacity. 

136 Electronics Projects Vol. 26


Versatile LED Display
 Priyank Mudgal three colours (green, red and amber). EPROM IC 2716 (IC3). IC3 contains the
The circuit is powered by 5V DC. code (see Table I) for the display.

T
his circuit uses an erasable pro- IC 555 (IC1) is wired as an astable The high logic at any data pin
grammable read-only memory multivibrator, whose oscillation fre- causes the corresponding LED to glow.
(EPROM) to display various quency can be varied using preset VR1. When the data at address location 00H
light patterns on LEDs. Since bicolour The output of IC1 clocks 12-stage bi- is addressed, the red LED of LED1
LEDs (comprising green and red LEDs) nary counter IC CD4040 (IC2), which, glows. The data byte 44H at address
have been used, display is possible in in turn, provides address data to location 09H causes both the green
and red LEDs of LED2 to glow (refer
the table).
The binary outputs of IC2 compris-
ing Q0, Q1, Q2, Q5, Q6, Q7, Q8 and Q9
have been connected to address pins
A0 through A7 of EPROM IC3 (2716).
Q3 and Q4 outputs of IC2 have not
been used. This causes each display
pattern to be repeated eight times be-
fore the next pattern is displayed. You
can adjust the number of times a dis-
play pattern repeats by changing the
output lines of IC2 connected to the
EPROM’s address pins A0 through A7.

Binary Code for EPROM


Address Data Address Data
00 01 20 F0
01 02 21 F0
02 04 22 F0
03 08 23 F0
04 10 24 0F
05 20 25 0F
06 40 26 0F
07 80 27 0F
08 88 28 FF
09 44 29 FF
0A 22 2A FF
0B 11 2B FF
0C F8 2C F0
0D F4 2D 0F
0E F2 2E FF
0F F1 2F F0
10 8F 30 0F
11 4F 31 87
12 2F 32 C3
13 1F 33 E1
14 87 34 F0
15 4B 35 E1
16 2D 36 C3
17 1E 37 87
18 78 38 F0
19 B4 39 78
1A D2 3A 3C
1B E1 3B 1E
1C 84 3C 0F
1D 42 3D 1E
1E 21 3E 3C
1F 18 3F 78

Electronics Projects Vol. 26 137


The circuit uses a total of four shown in the figure). For this, you’ll You can also create other display
bicolour LEDs. However, more LEDs have to connect them in parallel to patterns by coding the EPROM ac-
in pairs of four can be added in the LED1 through LED4, respectively. The cordingly. Note that the code should
dotted lines (see the figure). Suppose speed of the display can be changed by be burnt into the EPROM (by using a
you want to connect four more bico- varying preset VR1, which changes the programmer kit) before it is inserted
lour LEDs (LED5 through LED8, not clock frequency. into the circuit. 

138 Electronics Projects Vol. 26


Auto Turn-Off Battery Charger
 Y.M. Anandavardhana to energise electromagnetic relay RL1. Pushing switch S1 latches relay
Relay RL1 is connected to the collector RL1 and the battery cells start charg-

T
his charger for series-connected of transistor T1. Transistor T1 is driven ing. As the voltage per cell increases
4-cell AA batteries automatically by pnp transistor T2, which, in turn, is beyond 1.3V, the voltage drop across
disconnects from mains to stop driven by pnp transistor T3. Resistor R4 resistor R4 starts decreasing. When
charging when the batteries are fully (10-ohm, 0.5W) is connected between it falls below 650 mV, transistor T3
charged. It can be used to charge par- the emitter and base of transistor T3. cuts off to drive transistor T2 and, in
tially discharged cells as well. When a current of over 65 mA turn, cuts off transistor T3. As a result,
The circuit is simple and can be flows through the 12V line, it causes a relay RL1 de-energises to cut off the

divided into AC-to-DC converter, relay voltage drop of about 650 mV across charger and red LED1 turns off.
driver and charging sections. resistor R4 to drive transistor T3 and You may determine the charging
In the AC-to-DC converter section, cut off transistor T2. This, in turn, turns voltage depending on the NiCd cell
transformer X1 steps down mains 230V transistor T1 ‘on’ to energise relay specifications by the manufacturer.
AC to 9V AC at 750 mA, which is recti- RL1. Now even if the pushbutton is Here, we’ve set the charging voltage
fied by a full-wave rectifier comprising released, mains is still available to the at 7.35V for four 1.5V cells. Nowadays,
diodes D1 through D4 and filtered by primary of the transformer through its 700mAH cells are available in the mar-
capacitor C1. Regulator IC LM317 (IC1) normally open (N/O) contacts. ket, which can be charged at 70 mA for
provides the required 12V DC charg- In the charging section, regulator 10 hours. The open-circuit voltage is
ing voltage. When you press switch S1 IC1 is biased to give about 7.35V. Pre- about 1.3V.
momentarily, the charger starts operat- set VR1 is used for adjusting the bias The shut-off voltage point is deter-
ing and the power-on LED1 glows to voltage. Diode D6 connected between mined by charging the four cells fully (at
indicate that the charger is ‘on.’ the output of IC1 and battery limits the 70 mA for 14 hours). After measuring the
The relay driver section uses pnp output voltage to about 6.7V, which is output voltage, add the diode drop (about
transistors T1, T2 and T3 (each BC558) used for charging the battery. 0.65V) and bias LM317 accordingly. 

Electronics Projects Vol. 26 139


Pencell charge indicator
 D. Mohan Kumar ing inputs. The non-inverting input When a partially discharged battery
(pin 3) of IC1 is supplied with a volt- (with a terminal voltage of less than 1.4

S
mall-size AA cells and button age obtained from the battery under V) is connected to the test terminals, the
cells used in electronic devices test, while its inverting input pin 2 is output of IC1 goes low to switch off
providing a terminal voltage of provided with a reference voltage of transistor T1. This allows transistor T2
1.5V are normally rated at 500 mAh. 1.4V derived by resistor R4 and series to forward bias by taking bias voltage
As the cells discharge, their internal combination of diodes D1 and D2. through resistor R5 and the red LED
impedance increases to form a poten- Resistors R1 and R2 provide a loading within bicolour LED1 glows.
tial divider along with
the load and the battery
terminal voltage reduces.
This, in turn, reduces the
performance of the gad-
get and we are forced to
replace the battery with
a new one. But the same
battery can be used again
in some other application
that requires less current.
Here’s a simple tester
for quick checking of
discharged pencells and
button cells before throw-
ing them away. The tester detects the of 10 mA and 100 mA, respectively, for Slide switch S2 is used to check
holding charge of the battery and the checking the charge capacity. whether the battery is holding suf-
terminal voltage to indicate whether When a new battery is connected to ficient current to drive a load of 10
the battery is suitable for a particular the test terminals, the non-inverting input mA or 100 mA. If the discharged bat-
gadget or not. of IC1 gets 1.5V, which exceeds the voltage tery holds more than 100mA current,
A 9V battery can power the circuit of the inverting input and the output of the green LED within bicolour LED1
with sufficient voltage and current. IC1 goes high. This high output provides glows, indicating that the battery can
When you close switch S1, it provides forward bias to transistor T1 through be used again in a low-drain circuit.
stable 6V DC to the circuit. resistor R4 and it conducts to light up the The circuit can be easily con-
The circuit uses op-amp CA3140 green half of the bicolour LED (LED1). structed on a perforated board using
(IC1) as a voltage comparator. It can Simultaneously, the base of transistor T2 readily available components. Enclose
sense even a slight voltage variation is pulled down and it turns off and the red it in a small case with probes or battery
between its inverting and non-invert- half of bicolour LED1 remains off. holder for testing. 

140 Electronics Projects Vol. 26


Miser Flash
 T.A. Babu vice is battery-powered. In this
circuit, the energy consumed

A
flashing LED at the doorstep by the LED is a small fraction
of your garage or home will of the normal value.
trick the thieves into believing Capacitor C2 charges
that a sophisticated security gadget through resistor R2 and diode
is installed. The circuit is nothing but D1. When the voltage across
a low-current drain flasher. It uses a C2 reaches two-third of the
single CMOS timer that is configured supply voltage, threshold pin 7
as a free running oscillator using a few of IC1 switches on as a current
additional components. As the LED sink. The capacitor discharges
flashes very briefly, the average cur- through LED1 into pin 7
rent through the LED is around 150 µA rapidly. Diode 1N4148 (D1)
with a high peak value, which is suf- is constantly charged through resistor provides the one-way charging path
ficient for normal viewing. This makes R1. As capacitor C1 delivers power to for capacitor C2 via resistor R2. LED1
it a real miser. IC1, it saves the battery from drain. illuminates briefly for a while with the
The 9V battery source is connected Most LEDs consume a current of 20 accumulated charges in C2. Again, the
via ‘on’/‘off’ switch S1 to the circuit. mA, which in many instances is higher charging cycle repeats. This way, LED
When switch S1 is closed, the IC re- than the power consumed by the rest of continues flashing. A 9V PP3 battery
ceives power from capacitor C1, which the circuit. This is undesirable if the de- can perfectly handle this job. 

Electronics Projects Vol. 26 141


PC-based Timer
 Akshay Mathur

T
imers are very useful both for
industrial applications and
household appliances. Here is
a PC-based timer that can be used for
controlling the appliances for up to
18 hours. For control, the timer uses a
simple program and interface circuit.
It is very cost-effective and efficient for
those who have a PC at workplace or
home. The tolerance is ±1 second.
The circuit for interfacing the PC’s
parallel port with the load is very
simple. It uses only one IC MCT2E,
which isolates the PC and the relay required timing, press any key from it can hold 216–1=65,535 seconds or 18
driver circuits. The IC prevents the PC the keyboard. hours at the maximum. The sleep()
from any short circuit that may occur Suppose you input the total duration function in the program is used to hold
in the relay driver circuit or appliance. as ‘x’ minutes, of which ‘on’ and ‘off’ the appliance in ‘on’ or ‘off’ condition
The glowing of LED1 indicates that durations are ‘y’ and ‘z’ minutes, respec- for the ‘on’ and ‘off’ periods as entered
the appliance is turned on. Transistor tively. The program will repeat the on-off by the user against prompts. The
BC548 is used as the relay driver. cycle for x/(y+z) number of times. After sound() function is used to give a beep
The program code is written in ‘C’ completion of the total time, to repeat the during ‘on’ condition of the appliance.
language and compiled using ‘Turbo cycle, you will have to reset the time in the EFY note. The source code and
C’ compiler. When the program is run, program to activate the circuit. executable file of this program can
it prompts the user to input the time The program uses two bytes for be downloaded from: http://www.
duration in seconds or minutes to con- storing integer type data. So when input efymag.com/admin/issuepdf/pc%20
trol the appliance. After entering the is given in terms of seconds or minutes, Based%20Timer.zip

Timer.c
#include <stdio.h> gotoxy(1,5); minutes): “);
#include <conio.h> printf(“How do you want to enter the time dura- scanf(“%d”,&c);
#include <dos.h> tion ?”); a=a*60;
#include <stdlib.h> printf(“\n\n\n1.Enter time duration in minutes b=b*60;
void main() (press m)”); c=c*60;
{ printf(“\n\n2.Enter time duration in seconds printf(“Press any key to start the program”);
int PORT=0x0378,a,b,c,d=0; (press s)\n”); getch();
clrscr(); gotoxy(1,15); do
_setcursortype(_NOCURSOR); switch(getch()) {
gotoxy(1,15); { outportb(PORT,1);
textcolor(2); case ‘m’: printf(“\nYour circuit is on”);
printf(“This is the Program to use PC Parallel { sound(330);
port as Timer for external circuits”); printf(“Enter the total time duration (in min- sleep(b);
gotoxy(1,17); utes): “); nosound();
printf(“\nWith this program you can time the scanf(“%d”,&a); outportb(PORT,0);
circuits for precision upto a second\n”); printf(“Enter the time to keep the circuit on (in printf(“\nYour circuit is off”);
printf(“\nPress any key to continue....\n”); minutes): “); sleep(c);
getch(); scanf(“%d”,&b); d=d+b+c;
clrscr(); printf(“Enter the time to switch off the circuit (in }

142 Electronics Projects Vol. 26


while(d<a); scanf(“%d”,&b); outportb(PORT,0);
printf(“\n Your program completed succes- printf(“Enter the time to switch off the circuit printf(“\nYour circuit is off”);
fully”); (in sec): “); sleep(c);
outport(PORT,0); scanf(“%d”,&c); d=d+b+c;
sleep(5); printf(“Press any key to start the program”); }
exit(0); getch(); while(d<a);
} do printf(“\nYour program completed succesfully”);
case ‘s’: { outportb(PORT,0);
{ outportb(PORT,1); sleep(5);
printf(“Enter the total time duration (in sec): “); printf(“\nYour circuit is on”); exit(0);
scanf(“%d”,&a); sound(330); }
printf(“Enter the time to keep the circuit on (in sleep(b); }
sec): “); nosound(); } 

Electronics Projects Vol. 26 143


Atmel AVR ISP Dongle
 EFY Lab 3. SCK (Shift Clock): Serial clock not in programming mode. In idle mode,
generated by the programmer from all the outputs are tristated so as not to

A
tmel’s AVR microcontroller the PC. affect the operation of the target system.
chips are in-system program- 4. RST (Reset): Reset (low pulse) When the AVR’s ISP mode is se-
mable (ISP), i.e. these can be generated by the program. The AVR is lected, the lower half of IC 74LS244
programmed directly in the target cir- programmed while in reset state. is enabled, pulling the target sys-

cuit. A special programmer software is Here’s a dongle circuit for in- tem’s Reset line low. Once the target
used to download the program from system programming of Atmel’s AVR system is in Reset mode, the SCK,
the PC into the AVR’s flash memory. chip AT90S8515 using such software MISO and MOSI lines are no longer
Atmel offers a software package called packages as Atmel ISP 2.65 and Pony- loaded by the peripheral circuitry,
the Atmel AVR ISP that allows pro- Prog2000. Though not exactly the same, if any, on the target system. Now,
gramming of the AVR microcontrollers a similar dongle circuit can be found it is safe to enable the upper half of
in the circuit using a simple dongle. A at the Website ‘www.iready.org/proj- 74LS244, driving the MOSI, LED and
dongle is nothing but an adaptor cable ects/uinternet/ispdongle.pdf.’ SCK lines of the dongle. The RST pin
that connects the PC’s parallel port The PC’s parallel-port pins 4 and becomes high after the AVR is pro-
with the ISP pins of the AVR chip for 5 drive buffer IC 74LS244 by enabling grammed. Glowing of LED2 indicates
programming. its pins 19 and 1, respectively. A low that the AVR is in programming mode.
For programming, the four lines pulse on these pins will allow the pass- There are two standard connectors
required from the AVR chip to the ISP ing of the serial clock and data during for in-system programming of Atmel
adaptor (dongle) are: programming. MOSI, LED, SCK and AVR microcontroller. One is the 10-pin
1. MOSI (Master Out, Slave In): RST outputs are buffered from the par- header (dual-in-line (DIL) connector))
Data being transmitted to the AVR allel port’s pins 7, 8, 6 and 9, respec- used on the Atmel STK kits. The other
being programmed is sent on this pin tively. The MISO input from the AVR is a 6-pin header (DIL connector) used
2. MISO (Master In, Slave Out): is fed into pin 10 of the parallel port. in Atmel ISPs. The two loop-back
Data received from the AVR being IC 74LS244 (IC1) acts as a buffer as connections, pin 2-to-pin 12 and pin
programmed is sent on this pin well as an isolator circuit when the AVR is 3-to-pin 11 of the parallel port, are

144 Electronics Projects Vol. 26


used to identify the dongle. With only 6-pin SIL connector for the Atmel pro- (dongle) to the target circuit.
pin 2-to-pin 12 link, the dongle is called gramer circuit. With the buffer and the If the AVR is not on the target cir-
STK300 or AVR ISP dongle. With only 40-pin ZIF socket in this circuit, it can cuit, you can insert the AVR into the
pin 3-to-pin 11 link, the dongle is called be used as a standalone programmer. ZIF socket and program it. Regulated
STK200 or old Kanda ISP dongle. With The 6-pin SIL male connector is used for 5V DC is required for the AVR and
both links in place, the dongle is identi- connection between the dongle and the the associated dongle circuit, whose
fied as a value-added pack dongle. AVR on the target board. Thus, another terminals are also provided in connec-
Here, we’ve used an 8-pin single-in- 6-line cable of about 30cm length is re- tor CON4. LED1 is used as the power
line (SIL) connector and an additional quired for connecting this ISP adaptor indicator for the circuit. 

Electronics Projects Vol. 26 145


Digital Frequency Comparator
 V. Gopalakrishnan reset flip-flop (IC4), 74LS00 NAND gate one-third of the power supply (Vcc).
(IC8) and two 7-segment displays (DIS1 The output of NE555 is high during

H
ere’s a digital frequency com- and DIS2). The astable free-running os- charging and low during discharging
parator for oscillators that in- cillators built around the timers are the of capacitor C1.
dicates the result through a frequency sources for the correspond- The other oscillator (IC5) works
7-segment display and a light-emitting ing counters. similarly. The oscillator frequency can
diode (LED). When the frequency When power supply to the circuit be varied by the potentiometer (VR1 or
count of an oscillator is below ‘8,’ the is switched on, timing capacitor C1 VR2). Output pins (pin 3) of the oscilla-
corresponding LED remains turned starts charging through resistor R1 tors (IC1 and IC5) are connected to the
off. As soon as the count reaches ‘8,’ and potmeter VR1. When the ca- respective decade counters (IC2 and
the LED turns on and the 7-segment pacitor voltage reaches 2/3Vcc, the IC6) through the DPDT switch.
display shows ‘8.’ internal comparator of IC1 triggers IC2 and IC6 count the initial eight
This demo circuit uses two NE555 the flip-flop and the capacitor starts cycles. IC 74LS90 is a 4-bit ripple
timers configured as astable free- discharging towards ground though decade counter. It consists of a divide-
running oscillators, whose frequencies VR1. When the capacitor voltage by-two section and a divide-by-five
are to be compared. reaches 1/3Vcc, the lower comparator section counter. Each section has a
The circuit of the digital frequency of IC1 is triggered and the capacitor separate clock input. The input of
comparator portion comprises two starts charging again. The charge- the divide-by-five section (CP1) is
74LS90 decade counter ICs (IC2 and discharge cycle repeats. That means, externally connected to the P output
IC6), two 74LS47 7-segment display the capacitor charges and discharges (pin 12) of the divide-by-two section
driver ICs (IC3 and IC7), 74LS74 set/ periodically between two-third and (CP0). When the divide-by-two sec-

146 Electronics Projects Vol. 26


tion receives clock pulse, it becomes a connected to Vcc to disable the ripple- gate N2 of IC8, the flip-flop is reset
divide-by-ten counter. blanking input (RBI), blanking input and its Q output goes high. On receiv-
Decade counter 74LS90 is reset by (BI)/ripple-blanking output (RBO) and ing a clock pulse, the Q and Q outputs
a high pulse at its pins 2 and 3. Ini- lamp test (LT). of the flip-flop go high and low, re-
tially, pins 2 and 3 are pulled down by IC3 provides segment data to the spectively, and the LED turns on. The
resistor R2. The P through S outputs 7-segment display through current- low output of IC4 resets the oscillators.
of IC2 are connected to the A through limiting resistors R3 through R9 (each The reset signal is derived with the
D inputs of IC3. Pin 11 (S) of IC2 is 220 ohms). help of NAND gates N3 and N4.
also connected to pin 3 of IC4(A) for IC 74LS74 (IC4) controls the reset When switch S2 is pressed, both the
providing the clock pulse. The count pin (RST) of NE555. It is a dual D-type oscillators and the respective counters start
is displayed on the 7-segment display. flip-flop with direct clear and set in- working. As soon as any of the counters
The 7-segment decoder/driver puts and complementary outputs. The counts ‘8,’ the corresponding display
(74LS47) accepts four binary-coded input data is transferred to the outputs shows ‘8’ and LED glows. This means that
decimals (8421), generates their com- on the positive edge of the clock pulse. oscillator has a higher frequency. Now
plements internally and decodes the Since the Q output is connected to the both the counters stop counting because
data with seven AND/OR gates hav- data input D, the flip-flops work in the flip-flop output goes low to reset both
ing the open-collector output to drive toggle mode. the astable oscillators.
the display segments directly. Each Initially, reset pins 1 and 13 of the In case the frequencies of both the
segment-driver output is capable of flip-flops are pulled high via resistor astable oscillators are same, both the
sinking 40mA current in the ‘on’ state. R10. When the reset pin of any flip- displays show ‘8’ and LED1 and LED2
Pins 3, 4 and 5 of the display driver are flop receives a low pulse from NAND glow at the same time. 

Electronics Projects Vol. 26 147


Manual EPROM Programmer
 Priyank Mudgal wired as a monostable. When push-to- voltage (25V, 21V or 12.5V, as specified
on switch S1 is pressed, IC2 generates by the manufacturer) applied to pin 21

T
he programmer devices re- a 50ms pulse, which is given to the pro- of the ZIF SOCKET by using jumper
quired for programming the gram pin 18 of the ZIF SOCKET through J1. The programming voltage required
electrically programmable read- switch S2. EPROM is inserted into the for an EPROM is sometimes written on
only memories (EPROMs) are general- ZIF SOCKET for programming. LED1 its body. The address and data for the
ly expensive. Here is a low-cost circuit glows to indicate the application of the EPROM (ZIF SOCKET) are set by using
to program binary data into 2716 and programming pulse to the EPROM. DIP switches SW1 and SW2, respec-
2732 EPROMs. Before applying the programming pulse tively, whose pins are initially pulled
The circuit uses timer NE555 (IC2) to the EPROM, select the programming high via 10-kilo-ohm resistors.

148 Electronics Projects Vol. 26


The AC mains is stepped down by +5V regulated supply to the circuit. gramming voltage using jumper J1 and
transformer X1 to deliver 30V, 250 mA To begin with, first read the pro- set the programming address and data
from the secondary. The secondary out- gramming voltage written on the value using switches SW1 and SW2, re-
put is rectified by diode D1 and filtered EPROM. Now insert the EPROM chip spectively. After providing the required
by capacitor C1. The programming volt- into the 24-pin ZIF socket and slide programming voltage, press switch
ages of 25V, 21V and 12.5V are gener- switch S2 as per EPROM. Then connect S1 to program the data at the desired
ated with the help of zener diodes ZD1, the power supply to provide regulated address. Repeat this procedure for the
ZD2 and ZD3. IC1 is used to provide 5V DC to the circuit. Select the pro- next address and corresponding data. 

Electronics Projects Vol. 26 149


Wireless Stepper
Motor Controller
 Jaydip Appasaheb Dhole

H
ere is a low-cost and sim-
ple wireless stepper motor
controller using infrared
signals. Using this circuit you can
control the stepper motor from a
distance of up to four metres.
The circuit comprises transmit-
ter and receiver sections. The com-
munication between the transmitter
and receiver sections is achieved
through infrared signals.
In the transmitter section, timer
NE555 ICs (IC1 and IC2) are config-
ured as astable multivibrators with
frequencies of around 1 Hz and 38
kHz, respectively. The output of IC1
is given to reset pin 4 of IC2, so the
38kHz carrier signal is modulated by
1Hz modulating signal. The modu-
lated signal from pin 3 of IC2 is trans- Fig. 2: Infrared receiver and stepper motor driver circuit
mitted by the infrared LED. Resistor
R5 limits the current through the IR LED. of the receiver section and its output gets shifted to the second flip-flop.
The transmitted signal is sensed at pin 3 is used as clocks for dual flip- Thus on reception of every clock pulse,
by IR receiver module TSOP1738 (IC6) flop 74LS74 ICs (IC3 and IC4), which the high output keeps shifting in a ring
are configured as a fashion.
ring counter. The outputs of flip-flops are amplified
When the power by the Darlington transistor array inside
is switched on, the ULN2003 (IC5) and connected to the step-
first flip-flop is set per motor windings marked ‘A’ through
and its Q1 output ‘D.’ The common point of the windings is
goes high, while connected to +12V DC supply.
the other three flip- To stop the motor, the flip-flops
flops are reset and can be reset manually by pressing
their outputs go reset switch S1. On releasing the reset
low. On receiving switch, the stepper motor again starts
the first clock pulse, moving. If any interruption occurs be-
the high output of tween the transmitter and the receiver,
Fig. 1: Infrared transmitter the first flip-flop the motor stops. 

150 Electronics Projects Vol. 26


Simple Digital
Security System
 Pherdaus Islam nected as shown in Fig. 1. If you don’t
want to use a buzzer, switch it off by

Y
ou can use this simple and reli- opening switch S2.
able security system as a watch- The circuit works off a 9V regu-
dog by installing the sensing lated power supply. However, battery
loops around your building. You have back-up is recommended. A common-
to stretch the loop wires two feet above cathode, 7-segment display (LTS543) is
the ground to sense the unauthorised used for displaying whether the loops
entry into your premises. are intact or not.
Wire loops 1, 2 and 4 are connected If loop 1 is broken, the display will
to the A, B and C inputs of 7-segment show ‘1’. If two or all the three loops
decoder 4511 (IC1), respectively, while are broken, the display will show the
Fig. 2: The proposed wiring diagram of loops
the D input of IC1 is grounded perma- sum of the respective broken loop

Fig. 1: The digital security system circuit

nently. The loops are also connected to numbers. For example, if loops 1 and transistor T1 in cut-off position and the
a dual 3-input NOR gate and inverter 4 are broken, the display will show piezobuzzer does not sound.
CD4000 (IC2) to activate the alarm. 5(1+4). When any loop is broken, the
Fig. 1 shows the circuit of the digi- When all the three loops are intact, output of NOR gate N1 goes low,
tal security system, while Fig. 2 shows the display will show ‘0.’ All the three while the output of gate N2 goes high.
the proposed wiring diagram for the inputs of gate N1 remain low to give Transistor T1 conducts and the buzzer
loops around the premises. Before a high output. This high output is fur- sounds to alert you. You can mute the
using this security system, make sure ther given to gate N2 and, as a result, buzzer by switching off power to the
that loops shown in Fig. 2 are con- its output remains low. This keeps circuit through switch S1. 

Electronics Projects Vol. 26 151


Multiple Applications
of High-Power LEDs
 N.S. Hari Sankar-Vu3nsh for other systems
as well. You just

N
owadays, high-power light- need to remove
emitting diodes (LEDs) the LED section
LXHLMW1C are available in from the circuit
the market. These white LEDs contain and connect the
indium-gallium-nitrogen (InGaN). switching sec-
The LEDs’ emitting capacity is 20 can- tion to the de-
dela (Cd). We can use these LEDs for sired system. So
automatic garden lighting and wide the system will
voltage operation by applying differ- now automati-
ent voltages. cally switch on in
Fig. 1 shows the circuit for auto- the evening and
matic garden lighting. Switch S1 con- Fig. 1: Circuit for automatic garden lighting switch off in the
nects 12V to the circuit built around morning.
transistors T1 and T2. Light-dependent Fig. 2 shows a wide-
resistor LDR1 is used to sense the light voltage operation circuit.
intensity and preset VR1 is used to Here, the high-power LED61
adjust the threshold of light. The resis- (LXHLMW1C) gives a power
tance of LDR remains low in daylight equivalent of 20 Cd. This
and high at night (in darkness). LED has a metallic back for
In the morning, light falls on LDR1 mounting on a heat-sink. Its
and transistors T1 and T2 are cut-off. rated maximum input DC
As a result, 12V supply is not avail- voltage and current are 3.6V
able to the LEDs. In the evening, when Fig. 2: Circuit for wide-voltage operation and 350 mA, respectively.
no light falls on LDR1, transistors T1 Regulator IC LM317 (IC1)
and T2 conduct to provide 12V to provides a constant voltage of 4.7V.
the LEDs. This turns on all the LEDs Resistors R3 and R4 limit the current
(LED1 through LED60). The on/off through the LED. The LED is very
switching level can be adjusted by sensitive to voltage inputs. In the 2.5V-
220-kilo-ohm preset according to the 3.5V region, each millivolt variation
intensity of the light. changes the current through the LED
The emitting capacity of LEDs logarithmically. Transistors BC549
(UW-510CWH) used here is 8 Cd. Since Fig. 3: Pin configuration and D882 (T3 and T4) and resistor R6
a total of 60 of these LEDs have been provide a constant current to LED61.
used, this unit will provide luminous The entire circuit, except LDR1, can The unit gives a constant lighting for
intensity equivalent of 480 Cd. The be assembled on any general-purpose voltages ranging from 7V to 25V.
LEDs are arranged in twenty rows, PCB. House the PCB in a box and, us- Fig. 3 shows pin configuration of
with each row having three LEDs ing two long wires, mount LDR1 at a regulator LM317 and transistors D882
in series. The input voltage is ap- place where light falls on it directly. and BC549. Use heat-sinks in regula-
proximately 12V and all the LEDs are Now place the unit in your garden. tor LM317 and transistor D882 before
spaced 1 to 1.5 cm apart. You can use the switching section soldering them onto the PCB. 

152 Electronics Projects Vol. 26


Automatic Bathroom
Light with Back-up Lamp
 D. Mohan Kumar When the SCR gets gate drive, it When power fails, pin 2 of IC3
fires to energise relay RL1. The latch- gets triggered via capacitor C8 and the

S
ometimes we forget to switch off ing function of the SCR keeps the relay monostable output goes high to switch
the bathroom light and it re- energised until the power to the circuit on the white LEDs (LED3 and LED4).
mains on unnoticed for long peri- is switched off using switch S1. When Resistor R9 limits the current through
ods. This circuit solves the problem of the relay energises, its normally closed the LEDs to a safe level. Diode D7 is
electricity wastage by switching off the (N/C) contacts break and light turns forward biased to give full voltage to
lamp automatically after 30 minutes off. LED1 indicates that the oscillator the monostable when power fails.
once it is switched on. The back-up is working. The power supply for the circuit

LED lamp provided in the circuit turns The back-up white-LED lamp com- is derived from a 15V AC, 250mA
on for three minutes when mains fails. prising LED3 and LED4 gives ample transformer. The secondary output
This is helpful especially when you are light in the event of mains failure. It is is rectified by a full-wave rectifier
taking a shower at night. powered by a 9V rechargeable battery, comprising diodes D1 through D4.
The circuit is built around binary which is charged at around 200mA cur- Capacitor C1 smoothes the resulting
counter CD4060 (IC2), which has a built- rent via diode D6 and resistor R7 when DC. Regulator IC 7812 (IC1) and ca-
in oscillator and 14 cascaded bistable the circuit is switched on. pacitors C4 and C5 provide stabilised
multivibrators. The oscillator generates The back-up lamp circuit is built 12V for the circuit.
clock pulses based on the values of resis- around timer NE555 (IC3) designed as Assemble the circuit on a Vero
tors R3 and R4 and capacitor C3. a monostable. The output of IC3 goes board and enclose it in a watertight
For the given values, Q11 output of high for three minutes based on the plastic case. Connect the bathroom lamp
IC2 goes high after 30 minutes of power- values of preset VR1 and capacitor C9. (either 25-watt bulb or 11-watt CFL
on. Resistor R2 resets the IC for proper When the circuit is switched on, IC3 gets tube) to the circuit via N/C contacts of
operation. The output of IC2 is fed to the power supply via diode D6 and its trig- the relay, so that it turns on when switch
gate of the SCR via resistor R6 and LED2, ger pin 2 remains high due to resistor S1 is pressed. For easy access, fix switch
which function as a voltage dropper as R8. As a result, its output remains low S1 along with the neon indicator outside
well as output status indicator. as long as mains is present. the bathroom. 

Electronics Projects Vol. 26 153


Digital Audio/Video Input Selector
 T.K. Hareendran To select the first AV signal, press connected to the second AV signal (not
switch S1 once. To select the second shown in the figure). LED4 (not shown

N
eed to connect more than one AV signal, press switch S1 twice. In in figure) glows to indicate this.
audio-video (AV) source to the same way, you can select the other Similarly, pressing switch S1 thrice
your colour television? Don’t two signals. makes the Q3 output of IC1 high. Con-
worry, here’s an AV input expander Momentarily pressing of switch S1 sequently, 2C/O relay RL3 (not shown
for your TV. It is inexpensive and easy once results in clocking of the decade in the figure) energises and the televi-
to construct. counter and relay driver transistor T1 sion inputs are connected to the third
The working of the circuit is simple conducts to energise relay RL1. Now AV signal source. LED5 (not shown
in the figure) glows to
indicate this.
Again, pressing
switch S1 four times
makes the Q4 output of
IC1 high. Consequently,
2C/O relay RL4 ener-
gises and the TV in-
puts are connected to the
fourth AV signal source
(marked as Video-in 4
and Audio-in 4). LED6
glows to indicate this.
Further pressing of
switch S1 resets the de-
cade counter and LED2
glows again. Thereafter,
and straightforward. Whenever 12V normally opened (N/O) contacts of the cycle repeats. The circuit is wired
DC is applied to the circuit, power-on two-changeover relay RL1 connect the for four-input selection, therefore the
LED1 glows. Now reset the decade television set’s inputs to the first AV Q5 output of IC1 is connected to reset
counter by momentarily pressing signal (marked as Video-In 1 and Au- pin 15 of IC1.
switch S2 to make Q0 output of IC1 dio-in 1). LED3 glows to indicate this. Enclose the assembled PCB along
high. LED2 glows to indicate that the When you press switch S1 twice, the with the relays in a cabinet with the
circuit is ready to work. Q2 output of IC1 goes high. Consequent- input/output sockets and indicators
Switch S1 is used for selecting a ly, 2C/O relay RL2 (not shown in the cir- mounted on the body of the cabinet. 
particular audio-video (AV) signal. cuit) energises and television inputs are

154 Electronics Projects Vol. 26


Accurate Foot-Switch
 Kaushik Hazarika

C
ertain industrial controls re-
quire accurate switching opera-
tions. For example, in case of a
foot-switch for precise drilling work,
even a small error in switching may
cause considerable loss. This low-cost
but accurate foot-operated switch can
prevent that.
IC NE555 is wired in one-shot
mode. Its output pin 3 goes high only
when both switches S1 and S2 are
pressed simultaneously. You can release
any one of the switches without chang-
ing the output state. When you release
Fig. 1: Circuit of the foot-switch
both the switches, the output goes low.
The switches are placed under a no effect on the state of the flip-flop.
foot paddle as shown in Fig. 2. LED1 is Releasing both the switches brings
used as a warning indicator. If either S1 the input level with respect to ground
or S2 gets pressed erroneously, LED1 below the low trigger level, and thus it
blinks to warn the operator. The opera- resets the output.
tor can then withdraw his foot in case Use of the voltage divider results in
of a mistake or depress the other switch stable operation over the entire permis-
also to trigger the circuit. LED1 is to be Fig. 2: Foot paddle switch sible supply voltage range. The R-C cir-
mounted on the operator’s desk. cuit at pin 4 provides power-on reset.
The circuit operation is simple. the state of the internal flip-flop of When only S1 is pressed, R3 (1 kilo-
Resistors R2, R3 and R4 form a IC NE555. Pressing the two switches ohm) is less than R5 (1.5 kilo-ohms) and
voltage divider. IC NE555 has two simultaneously sets the flip-flop IC1 is not triggered. However, transistor
comparators, a flip-flop and power and the output of NE555 goes high. T1 (BC548) gets forward biased and
output section built into it. Pressing Transistor T2 energises relay RL1 for LED1 glows. When both S1 and S2 are
either S1 or S2 puts the input volt- driving the load. pressed, the effective resistance between
age between the upper comparator Releasing any of the switches +Vcc and pin 2 of IC1 is about 500
(2/3Vcc) and the lower comparator brings the comparator voltage back to ohms, which is less than R5 (1.5 kilo-
(1/3Vcc). Thus, it has no effect on the initial level inside NE555 and it has ohms), and IC NE555 gets triggered. 

Electronics Projects Vol. 26 155


MicroMotor Controller
 V. David connected between the outputs (pin 3) ward and reverse motion of the motor
of IC1 and IC2. in conjunction with switch S1. If you

U
sing this circuit, you can con- Closing switch S5 provides power to press switch S3 after pressing switch
trol the rotation of a DC the circuit. Now, when you press switch S1, pin 3 of IC3 goes high, while its pin
micromotor simply by pressing S1 momentarily, pin 10 of IC3 goes high, 4 goes low. The motor now starts rotat-
two push-to-on switches momentarily. while its pin 11 goes low. Since pin 10 ing in the forward direction. However,

The circuit is built around two of IC3 is connected to reset pin 4 of IC1 if you press switch S4 after pressing
NE555 ICs (IC1 and IC2) and a quad- and IC2, the high output at pin 10 of switch S1, the motor will rotate in re-
NAND IC CD4011 (comprising NAND IC3 will enable IC1 and IC2 simultane- verse direction.
gates N1 through N4). The NE555 ICs ously. When switch S2 is pressed, pin Note. The complete kit of
(IC1 and IC2) are configured as invert- 10 of IC3 goes low, while its pin 11 goes this circuit can be obtained from
ing buffers. IC CD4011 (IC3) NAND high. The low logic at pin 10 disables Kits‘n’Spares, 303, Website: www.
gates are configured as bistable flip- both IC1 and IC2. kitsnspares.com; E-mail: info@kitsns-
flop. The DC motor to be controlled is Switches S3 and S4 are used for for- pares.com. 

156 Electronics Projects Vol. 26


Power-On Reminder
with LED Lamp
 D. Mohan Kumar a light-dependent resistor (LDR) and a secondary output of 15V AC at
two npn transistors. The LDR offers a 500 mA. The transformer output is

M
any a times equipment at very high resistance in darkness, i.e., rectified by a bridge rectifier
workstations remain when no light falls on it. Therefore comprising diodes D1 through D4,
switched on unnoticed. In when power fails, transistor T1 gets re- filtered by capacitor C5 and regulated
this situation, these may get dam- verse biased to drive transistor T2 and by IC 7812 (IC3) to provide regulated
aged due to overheat-
ing. Here is an add-on
device for the work-
bench power supply
that reminds you of the
power-on status of the
connected devices every
hour or so by sounding
a buzzer for around
20 seconds. It also has
a white LED that pro-
vides good enough light
to locate objects when
mains fails.
Fig. 1 shows the cir-
cuit of power-on re-
minder with LED lamp.
Here, IC NE555 (IC1) Fig. 1: Circuit of power-on reminder with LED lamp
is wired as an astable
multivibrator, whose time period is set the white LED
to around six minutes using resistors (LED2) glows.
R1 and R2, preset VR1 and capacitor The lamp circuit
C1 for sounding the buzzer every hour. is powered by a
The output of IC1 is fed to the clock 9V rechargeable
input of IC CD4017 (IC2). Capacitor C3 battery, which is
and resistor R3 provide power-on-reset charged via re-
pulse to IC2. sistor R5 when
When power to the circuit is mains is present.
switched on, pin 3 of IC2 goes high. Af- Thus in darkness,
ter around one hour, its output pin 11 the LED remains Fig. 2: Power supply circuit
(Q9) goes high and the buzzer sounds. ‘on.’
This cycle repeats until the power to Fig. 2 shows the power supply 12V to the circuit. Capacitor C6
the circuit is switched off. circuit. The AC mains is stepped bypasses any ripple in the regulated
The automatic lamp is built around down by transformer X1 to deliver output. 

Electronics Projects Vol. 26 157


Mains Interruption
Counter with Indicator
 T.K. Hareendran

T
his circuit counts mains supply
interruptions (up to 9) and shows
the number on a 7-segment dis-
play. It is highly useful for automobile
battery chargers. Based on the number of
mains interruptions, the user can extend
the charging time for lead-acid batteries.
Fig. 1 shows the circuit of the inter-
ruption counter with indicator. A 9V
(PP3 or 6F22) battery powers the entire
circuit. Fig. 2 shows the block diagram
of the mains interruption counter cir-
cuit along with the battery charger and
lead-acid battery as used in automobile
battery charger shops. Fig. 1: Circuit of mains interruption counter with indicator

When 9V is applied to the circuit,


IC2 is reset by the power-on-reset the display.
signal provided by capacitor C3 and When mains fails for the
resistor R5 and the 7-segment display first time, clock input pin 1 of
(DIS1) shows ‘0.’ The 230V AC mains IC2 again goes high and display
is fed to mains-voltage detection opto- DIS1 shows ‘1.’ When mains
coupler IC MCT2E (IC1) via capacitor resumes, pin 1 of IC2 goes low
C1 and resistors R1 and R2 followed and DIS1 continues to show
by bridge rectifier BR1, smoothing ‘1.’ When mains fails for the
capacitor C2 and current-limiting resis- second time, clock input pin 1
Fig. 2: Block diagram of the arrangement used in
tor R2. Illumination of the LED inside automobile battery charger shops
of IC2 goes high and display
optocoupler IC1 activates its internal DIS1 shows ‘2.’ When mains re-
phototransistor and clock input pin 1 clock input pin 1 and clock-enable pin 2 sumes, pin 1 of IC2 again goes
of IC2 is pulled down to low level. is held low to enable the counter. low and DIS1 continues to show ‘2.’
IC CD4033 (IC2) is a decade Seven-segment, common-cathode This way, the counter keeps increment-
counter/7-segment decoder. Its pin 3 display DIS1 (LTS543) indicates the ing by ‘1’ on every mains interruption.
is held high so that the display initially mains interruption count. Capacitor Note that this circuit can count up to
shows ‘0.’ Clock pulses are applied to C2 provides a small turn-on delay for nine mains interruptions only. 

158 Electronics Projects Vol. 26


Simple Low-Power Inverter
 Pradeep G.

H
ere is a simple low-power in-
verter that converts 12V DC
into 230-250V AC. It can be
used to power very light loads like
window chargers and night lamps, or
simply give shock to keep the intrud-
ers away. The circuit is built around
just two ICs, namely, IC CD4047 and
IC ULN2004.
IC CD4047 (IC1) is a monostable/
astable multivibrator. It is wired in
astable mode and produces symmetri-
cal pulses of 50 to 400 Hz, which are
given to IC2 via resistors R1 and R2.
IC ULN2004 (IC2) is a popular R3 and R4. Resistors R3 and R4 are used to limit
7-channel Darlington array IC. Here, Transformer X1 (9V-0-9V, 500mA the output current from the ULN to
the three Darlington stages are secondary) is an ordinary step-down safe values. The 230-250V AC output
paralleled to amplify the frequencies transformer that is used here for the is available across the high-imped-
received from IC1. The output of IC2 reverse function, i.e., step up. That ance winding of the transformer’s
is fed to transformer X1 via resistors means it produces a high voltage. primary windings. 

Electronics Projects Vol. 26 159


Solar Bug
 D. Somnath across capacitor C2, a slow build-up
of voltage can be observed when the

H
ide this solar-powered circuit panel is exposed to light. Transistors
suitably and see the reaction T1 and T2 form a relaxation oscillator.
of your friends to the chirpy When C1 charges to 0.6V, transistor T1
sound produced by it every few min- conducts and the charge built up in C2
utes. In all probability, it will coax is discharged through the piezobuzzer
them to find out where the sound is to produce a short beep.
coming from. While testing the circuit, the value
The circuit runs off a miniature of resistor R1 can be reduced to, say, 1
solar power panel, which can be taken kilo-ohm. Use a good-quality buzzer
out from an old calculator such as can work properly from a panel as to ensure that the sound produced is
Citizen CT-500. A panel giving 1.5V to small as 3 cm2. loud enough. 
2.5V is required. Note that the circuit If a digital voltmeter is connected

160 Electronics Projects Vol. 26


Remote Control for
Home Appliances
 S. Mohan The amplified signal is fed to clock pliance. Transistor T2 (BC548) connected
pin 14 of decade counter IC CD4017 to pin 2 of IC1 drives relay RL1. Diode

C
onnect this circuit to any of (IC1). Pin 8 of IC1 is grounded, pin 16 1N4007 (D1) acts as a freewheeling
your home appliances (lamp, is connected to Vcc and pin 3 is con- diode. The appliance to be controlled is
fan, radio, etc) to make the nected to LED1 (red), which glows to connected between the pole of the relay
appliance turn on/off from a TV, VCD indicate that the appliance is ‘off.’ and neutral terminal of mains. It gets
or DVD remote control. The circuit can The output of IC1 is taken from its connected to live terminal of AC mains
be activated from up to 10 metres. pin 2. LED2 (green) connected to pin 2 via normally opened (N/O) contact
The 38kHz infrared (IR) rays is used to indicate the ‘on’ state of the ap- when the relay energises. 
generated by the re-
mote control are re-
ceived by IR receiver
module TSOP1738 of
the circuit. Pin 1 of
TSOP1738 is connected
to ground, pin 2 is con-
nected to the power
supply through resis-
tor R5 and the output
is taken from pin 3.
The output signal is
amplified by transistor
T1 (BC558).

Electronics Projects Vol. 26 161


Mock Alarm with Call Bell
 D. Mohan Kumar

H
ere is a fully automatic
mock alarm to ward
off any intruder to
your house. The alarm be-
comes active at sunset and
remains ‘on’ till morning. The
flashing light-emit ting diodes
(LEDs) and beeps from the
unit simulate the functioning
of a sophisticated alarm sys-
tem. Besides, the circuit turns
on and off a lamp regularly
at an interval of 30 minutes
throughout the night. It also
has a call bell facility.
The circuit is built around
CMOS IC CD4060B (IC1),
which has an internal oscillator
and a 14-stage binary divider
to provide a long delay with-
out using a high-value resistor
and capacitor.
Press switch S2 to provide oscillating. The O3 output (pin 7) of IC1 a positive trigger from the positive rail
9V power supply to the circuit. During goes high every five seconds to light (reduced by zener diode to 3.3V) via
daytime, light-dependent resistor LDR1 up the LEDs (LED1 and LED2) and resistor R10 and IC2 starts producing a
offers little resistance and transistor T1 activate the buzzer. Resistor R8 limits melody. Resistor R10 limits the current
conducts. This drives transistor T2 into the tone produced from the buzzer. to the trigger pin of IC2 and resistor
the cut-off mode, as its base is pulled to At the same time, O13 output of R12 prevents any false triggering.
ground via transistor T1. Reset pin 12 of IC1 (pin 3) goes high every 30 minutes Zener diode ZD1 provides the 3.3V
IC1 remains high as long as transistor to forward bias transistor T3 to ener- required for IC 4822.
T2 is cut off. This keeps the oscillator of gise relay RL1 and lamp L1 connected The circuit works off 9V regulated
IC1 (comprising resistors R5 and R6 and to the normally opened (N/O) contacts power supply. Assemble the circuit on
capacitor C1) disabled and its outputs of relay RL1 glows. This cycle repeats any general-purpose PCB and enclose
remain low. The sensitivity of LDR1 can till morning. it in a waterproof plastic box with
be adjusted using preset VR1. The call bell is built around IC 4822 holes for mounting LEDs on the rear
When the sunlight decreases in (IC2). Its inbuilt musical tone generator and the LDR on the top of the box.
the evening, the resistance of LDR1 generates different tones at each trig- Place the LDR such that sunlight falls
increases to cut off transistor T1. This ger. The frequency of the tone can be on it directly. Mount the unit on the
drives transistor T2 into conduction controlled through external compo- pillar of the entrance gate. To avoid
mode and its collector voltage goes nents R11 and C2. The output at pin unnecessary illumination of the LDR,
low. At the same time, reset pin 12 11 of IC2 is amplified by transistor T4. install lamp L1 away from the unit
of IC1 goes low to enable the oscil- When push-to-on switch S1 is in the porch of the house. Keep the
lator of IC1 and the oscillator starts pressed once, trigger pin 4 of IC2 gets speaker inside the room. 

162 Electronics Projects Vol. 26


Power-Saver LED Lamp
 K.N. Ghosh the capacitor dis-
sipates negligible

T
his high-intensity, energy-effi- power).
cient, long-lasting and durable The forward-
lamp can withstand input volt- conduction volt-
age fluctuation of up to ±25 per cent age drop required
without change in the light output. for the LED chain
The lamp consumes only 0.5W power (LED1 through
compared to conventional 15W lamps, LED7) is provided
significantly reducing the energy by C1 alone. C1 dis-
costs, and can be used as night lamp, Fig. 1: Circuit diagram of power-saver LED lamps charges through R1
path lamp or mandir lamp. Also, it immediately after
has a life of 100,000 hours (11 years the circuit is disconnected from mains,
of continuous use) against 1000 which prevents a fatal shock due to any
hours for conventional lamps, thus voltage remaining on the input termi-
requiring no replacement for a long nals. The AC mains voltage is rectified
time, once fitted. by diodes D1 through D4 and filtered
At the heart of this lamp are seven by capacitor C2. Resistor R2 acts as a
light-emitting diodes (LEDs). Unlike bleeder.
ordinary incandescent lamps, LEDs You can make lamps in
don’t have a filament that can burn other colours as well by simply
out and are illuminated solely by the disconnecting all the red LEDs (LED1
movement of electrons in a semicon- Fig. 2: Proposed enclosure for the lamp through LED7) between points A and
ductor material. So they last much B and instead connecting yellow LEDs
longer. Small size and use of plastic directly to light generation, which cuts for yellow lamp, blue LEDs for blue
material make them more durable. down the electricity bill considerably. lamp, green LEDs for green lamp and
But the main advantage of LEDs is Fig. 1 shows the circuit for red white LEDs for white lamp, as desired.
efficiency. In traditional incandescent LED-based lamp. The LEDs (LED1 Capacitor C1 should be rated for
lamps, light is produced by heating through LED7) are powered from at least 440V AC, while mains applica-
the tungsten filament. This results in mains without the use of a transformer. tions also require use of an X2-class ca-
wastage of energy, as a huge portion Here, capacitor C1 is used as the ‘AC pacitor. The circuit may be assembled
of the available electricity isn’t used voltage dropper’—the well-known on a circular PCB and housed in a
for producing the visible light. LEDs transformerless solution. It results in bulb-shaped enclosure as shown in Fig.
generate little heat. A much higher the advantages of a smaller size of 2. Mount capacitors C1 and C2 on the
percentage of the electrical power goes the circuit and no heat generation (as track side of the PCB to save space. 

Electronics Projects Vol. 26 163


Mains Supply Failure Alarm
 T.K. Hareendran

W
henever AC mains supply
fails, this circuit alerts you
by sounding an alarm. It also
provides a backup light to help you
find your way to the torch or the gen-
erator key in the dark.
The circuit is powered directly
by a 9V PP3/6F22 compact battery.
Pressing of switch S1 provides the
9V power supply to the circuit. A red
LED (LED2), in conjunction with zener
diode ZD1 (6V), is used to indicate the
battery power level. Resistor R9 limits
the operating current (and hence the
brightness) of LED2.
When the battery voltage is 9V,
LED2 glows with full intensity. As the
battery voltage goes below 8V, the inten-
sity of LED2 decreases and it glows very CD4538 (IC2) is used here. goes low and pnp transistor T2 gets
dimly. LED2 goes off when the battery When mains goes off, IC2 is trig- forward biased to light up the white
voltage goes below 7.5V. gered after a short duration deter- LED (LED1). Light provided by this
Initially, in standby state, both the mined by components C1, R4 and back-up LED is sufficient to search the
LEDs are off and the buzzer does not C3. Output pin 10 of IC2 goes high to torch or generator key.
sound. The 230V AC mains is directly forward bias relay driver transistor T1 During the mono time-out pe-
fed to mains-voltage detection opto- via resistor R7. Relay RL1 energises to riod, the circuit can be switched off by
coupler IC MCT2E (IC1) via resistors activate the piezobuzzer via its N/O opening switch S1. The ‘on’ period of
R1, R2 and R3, bridge rectifier BR1 contact for the time-out period of the the monostable multivibrator may be
and capacitor C1. Illumination of the monostable multivibrator (approxi- changed by changing the value of resis-
LED inside optocoupler IC1 activates mately 17 minutes). At the same time, tor R5 or capacitor C2.
its internal phototransistor and clock the N/C contact removes the positive If mains doesn’t resume when
input pin 12 of IC2 (connected to 9V supply to resistor R4. The time-out pe- the ‘on’ period of the monostable
via N/C contact of relay RL1) is pulled riod of the monostable multivibrator is lapses, the timer is retriggered after a
low. Note that only one monostable determined by R5 and C2. short delay determined by resistor R4
of dual-monostable multivibrator IC Simultaneously, output pin 9 of IC2 and C3. 

164 Electronics Projects Vol. 26


Sound-Operated Switch for Lamps
 Pradeep G.
T4 and T5, which conduct only when The regulated 12V DC power supply
the circuit senses sound signals. for the circuit is derived from AC mains

T
his inexpensive, fully transis- Transistor T5 supplies sufficient gate by using resistor R14, diode D1 and
torised switch is very sensitive voltage to the triac to drive the 230V zener diode ZD1. The circuit can be as-
to sound signals and turns on lamp. sembled on any general-purpose PCB. 
a lamp when you clap within 1.5
metres of the switch. One of its
interesting applications is in dis-
cotheques, where lights could be
turned on or off in sync with the
music beats or clapping.
The condenser microphone
senses the sound and converts
it into electrical variations. The
electrical signals are amplified
by the two-stage direct-coupled
(DC) amplifier formed by tran-
sistors T1 and T2 and fed to the
switching circuit. The switching
circuit comprises transistors T3,

Electronics Projects Vol. 26 165


TV Pattern Generator
 S. Anantha Narayanan speakers. You can also adjust the width VR3, the end position of the lines
of vertical lines. using potmeter VR4, and the line

T
his single-IC TV pattern genera- The circuit uses hex Schmitt in- width and the number of lines using
tor is useful for fault finding in verter IC CD40106 (IC1). NOT gate N1 potmeter VR5.
TV sets. You can correct the generates horizontally synchronised If you don’t have an oscilloscope,
alignment of the timing circuits of the (Hsync) pulses for the PAL video set presets VR1 and VR2 to 150k and
TV set with the help of this circuit. The signal. Presets VR1 and VR2 are used 22k, respectively, to get the required
vertical stripes (bars) produced by the to control the ‘on’ and ‘off’ time dura- ‘on’ and ‘off’ periods for the oscilla-

pattern generator on the TV screen tions of the oscillator, respectively. For tor and see the vertical line pattern
help you align the vertical scanning PAL, you need to adjust VR2 for ‘off’ on the TV.
synchronisation circuit of the receiver. duration of 4.7 µs, while VR1 needs The audio frequency oscillator
To test the TV set, you need to con- to be adjusted for ‘on’ duration of is built around NOT gate N6. Its
nect the video and audio outputs of around 60 µs. oscillation frequency is decided by
the circuit to the respective inputs of If vertical lines appear on the TV resistor R6 and capacitor C5. Con-
the TV set one by one. If the video sec- screen on connecting the video output nect the audio output of the circuit
tion of the TV set is working the circuit of the circuit to the video input of the to the audio input of the TV. If you
generates vertical white lines on the TV, the video section of the TV set is hear sound from the TV’s speakers,
TV screen, and if the audio section is working. You can control the starting the audio section of the TV set is
working you hear sound from the TV’s position of the lines using potmeter working. 

166 Electronics Projects Vol. 26


Rechargeable torch
based on White LED
 T.A. Babu AC) limits the current to the charger 1.2V, 225 mAH. A normal recharge
circuit. The resistor across the capaci- will take at least 12 hours. Each full

R
echargeable torches don’t tors provides a discharge path for the recharge will give a continuous op-
come without problems. You capacitors after the battery is charged. erational time of approximately 2.5
need to replace the bulbs and The red LED1 indicates that the circuit hours. Recharge the battery to full
charge the batteries frequently. The is active for charging. capacity immediately after use to en-
average incandescent light-emitting The torch uses three NiMH re- sure its reliability and durability. The
diode (LED) based torch, for instance, chargeable button cells, each of charging current is around 25 mA.
A voltage booster cir-
cuit is required for power-
ing the white LEDs (LED2
through LED4). An invert-
er circuit is used to achieve
voltage boosting. Winding
details of the inverter trans-
former using an insulated
ferrite toroidal core is given
in the schematic. The num-
ber of 35 SWG wire turns
in the primary and second-
ary coils (NP and NS) are 30
and 3, respectively. If the
Fig. 1: Circuit diagram of rechargeable torch
inverter does not oscillate,
swap the polarity of either
consumes around 2 watts. Here’s a (but not both) the primary or the
rechargeable white LED-based torch secondary winding. A reference
that consumes just 300 mW and has voltage from resistor R5 provides
60 per cent longer service life than an a reflected biasing to the transistor,
average incandescent torch. and keeps the output constant and
Fig. 1 shows the circuit of the re- regulated.
chargeable white LED-based torch. The suggested enclosure for the
The reactive impedance of capaci- torch is shown in Fig. 2. 
tors C1 through C3 (rated for 250V Fig. 2: Suggested enclosure for the torch

Electronics Projects Vol. 26 167


16-way Clap-operated Switch
 Raj K. Gorkhali the monostable circuit wired around ohm resistors to drive relays RL1, RL2,
IC 555. Output pin 3 of the timer is RL3 and RL4 connected to appliances

C
ontrol your home appliances connected to the clock input of divide- 1 though 4, respectively. Freewheel-
without getting out of your by-16 IC 74LS93. ing diodes D1 through D4 connected
bed. You just have to clap The outputs of IC2 are fed to npn across the relays protect the transistors
in the vicinity of the microphone transistors T2, T3, T4 and T5 via 100- from the back electromagnetic field

used in this circuit, which you can (e.m.f.) produced by the relays.
keep by the bedside. You can switch Output of 74LS93 The output states of IC 74LS93 (Q0
on/off up to four different electrical Number of claps Q0 Q1 Q2 Q3 through Q3) for different numbers of
equipment (TV, fan, light, etc) in 16 0 0 0 0 0 claps are shown in the table.
1 1 0 0 0
different ways. The circuit is powered from regu-
2 0 1 0 0
This circuit is built around timer IC 3 1 1 0 0 lated 5V DC. For testing the circuit,
555 (IC1), CMOS IC 74LS93 (IC2) and 4 0 0 1 0 disconnect the resistors from the out-
5 1 0 1 0
five BC547 npn transistors (T1, T2, T3, 6 0 1 1 0
puts of IC2 and connect four LEDs in
T4 and T5). Transistor T1 is used as the 7 1 1 1 0 series with 220-ohm resistors between
preamplifier and the rest are used for 8 1 0 0 1 the outputs and ground. Now switch
9 1 0 0 1
driving the relays. 10 0 1 0 1 on the power supply and clap near
A small condenser microphone 11 1 1 0 1 the microphone. You can see the four
is connected at the base of transistor 12 0 0 1 1 LEDs glowing in the manner shown in
13 1 0 1 1
T1, which is biased from resistor R1 14 0 1 1 1 the table. A reset push switch is pro-
(10 kilo-ohms). The clapping sound is 15 1 1 1 1 vided to switch off all the ‘on’ devices.
Note:1. ‘1’ indicates high logic.‘0’ indicates low logic.
converted into electrical energy by the 2. At high logic, the corresponding transistor conducts
Now you can connect the desired
microphone and amplified by transis- to energise the corresponding relays and activate the appliances to the relays and control
load.
tor T1. The transistor output is fed to them with your claps. 

168 Electronics Projects Vol. 26


Brake failure indicator

 D. Mohan Kumar by monitoring the brake switch and ments R7 and C4 make the output high
reminds you of the condition of the for one second to activate the buzzer

D
o you want to get an early brake every time the brake is applied. and LED2. Usually, the trigger pin of
warning of brake failure The circuit uses an op-amp IC IC3 is high due to R6 and the buzzer
while driving? Here is a brake CA3140 (IC2) as voltage comparator and LED2 remain ‘off.’
failure indicator circuit that constantly and timer NE555 (IC3) in monostable When the brake pedal is pressed,
monitors the condition of the brake configuration for alarm. Voltage com- pin 2 of IC2 gets a higher voltage from
and gives an audio-visual indication. parator IC2 senses the voltage level the brake switch and its output goes
low to switch off
the red LED. The
low output of
IC2 gives a short
negative pulse to
the monostable
through C2 to trig-
ger it. This acti-
vates the buzzer
and LED2 to indi-
cate that the brake
system is working.
When there is pres-
sure drop in the
brake system due
When the brake is applied, the green across the brake switch. Its non-invert- to leakage, LED1 remains ‘on’ and the
LED blinks and the piezobuzzer beeps ing input (pin 3) gets half the supply buzzer does not sound when the brake
for around one second if the brake voltage through potential divider re- is applied.
system is intact. If the brake fails, the sistors R3 and R4 of 10 kilo-ohms each. The circuit can be assembled on
red LED glows and the buzzer stops The inverting input (pin 2) of IC2 is any general-purpose PCB or perfo-
beeping. connected to the brake switch through rated board. Connect point A to that
The circuit will work only in ve- diode D1, IC 7812 (IC1) and resistor R2. terminal of the brake switch which
hicles with negative grounding. It also It receives a higher voltage when the goes to the brake lamps. The circuit can
gives an indication of brake switch brake is applied. be powered from the vehicle’s battery.
failure. Normally, when the brake is not The circuit requires well-regulated
In hydraulic brake systems of ve- applied, the output of IC2 remains power supply to avoid unwanted
hicles, a brake switch is mounted on high and the red LED (LED1) glows. triggering while the battery is charg-
the brake cylinder to operate the rear The output of IC2 is fed to trigger pin ing from the dynamo. IC4, C6 and C7
brake lamps. The brake switch is fluid- 2 of the monostable through coupling provide regulated 12V to the circuit.
operated and doesn’t function if the capacitor C2. Resistor R1 is used for The power supply should be taken
fluid pressure drops due to leakage. the input stability of IC2. IC1 and C1 from the ignition switch and the cir-
The fluid leakage cannot be detected provide a ripple-free regulated supply cuit ground should be clamped to the
easily unless there is a severe pressure to the inverting input of IC2. vehicle’s body. A bicolour LED can
drop in the brake pedal. This circuit IC3 is wired as a monostable to give be used in place of LED1 and LED2
senses the chance of a brake failure pulse output of one second. Timing ele- if desired. 

Electronics Projects Vol. 26 169


Battery Charger with
Automatic Switch-Off
 V. Gopalakrishnan three Ni-Cd batteries that are to be of pnp transistor T1. The base of tran-
charged. sistor T1 is held at 2.9V by adjusting

T
his smart charger automati- Normally, the full charge potential potmeter VR2. The output of transistor
cally switches off when your of an Ni-Cd cell is 1.2V. Trigger the T1 is inverted twice by npn transistors
re-chargeable batteries reach the bistable by pressing switch S1 and T2 and T3.
full charge. adjust potmeter VR1 for 60mA current Thus when the batteries are fully
The circuit comprises a bistable through the ammeter. charged to 3×1.2V=3.6V, a voltage
multivibrator wired around timer Now remove the ammeter and con- higher than this makes transistor T1
IC 555. The bistable output is fed nect a jumper wire between its points to conduct. Transistor T2 also con-
to an ammeter (via diode D1) ‘a’ and ‘b.’ Connect the positive output ducts and transistor T3 goes off. The
and potmeter VR1 before it goes to terminal of the batteries to the emitter threshold level of timer 555 reaches
6V, which is more than
2/3×V CC = 2/3×6=4V, to
turn off the timer.
During charging, the
threshold level of the timer
is held low. The green LED
(LED1) glows during charg-
ing of the batteries and goes
off at the attainment of full
charge.
Note that this cir-
cuit can be used only for
1.2V, 600mAH Ni-Cd re-
chargeable batteries that
require 60 mA of current for
15 hours to charge fully. 

170 Electronics Projects Vol. 26


Multidoor opening alarm
with indicator
 Pradeep G. ing door such that the magnet aligns second to the negative terminal and
with the reed switch when the door is third to the output of the unit.

T
his door-opening alarm alerts you closed. A separate unit incorporating When the door is closed, the reed
of intruders. You can use it for up the power supply, three LEDs and a switch terminals are shorted and the
to three doors. buzzer is to be kept by your side inside alarm does not sound.
You simply need to fit a small unit your room. A three-core ribbon cable When door 1 is opened by someone,
including reed switch on each door- from this unit goes to each door unit. transistors in the corresponding door
frame and fix a magnet on the mov- One core goes to the positive terminal, unit conduct and the buzzer sounds.
LED1 glows to indicate opening of door
1. Due to diode latching ac-
tion, the alarm will sound
continuously even after the
door is closed. It can be
stopped only by pressing the
reset switch of the door unit.
Regulated 9V to 12V DC
for operating the circuit is
derived from AC mains and
fed to the three units mount-
ed on the doors. Battery-
backup is also provided.
When all the three doors are
simultaneously opened, all
the three LEDs will glow.
This arrangement can
be extended for more
doors by increasing the
number of door units con-
nected to the audio-visual
indication unit. 

Electronics Projects Vol. 26 171


Safety Guard
 A. Ramesh Babu the clock oscillations are governed to the relay coil. The other pin of the
by resistor R1 and capacitor C1. In relay coil is connected to the negative

P
rotect your home appliances this circuit, only two outputs of the IC supply, while its contacts are used for
from voltage spikes with this (Q5 and Q14) have been used. Q5 is switching on the appliances.
simple time delay circuit. connected to an LED (LED1) and Q14 Whenever power to the appliances is
At the heart of the circuit is IC is used to trigger the gate of the SCR switched on or resumes after mains failure,
CD4060, which consists of two in- through D4 as well as reset the counter. the oscillator starts oscillating and LED1 blinks.
verter gates for clock generation and The anode of the SCR is connected This continues for three minutes. After that,
a 14-bit binary ripple counter. Here to +9V and the cathode is connected Q14 output of IC CD4060 goes high to trigger
the gate of the SCR
through D4. At this
moment, the voltage
is available at the cath-
ode of the SCR, which
energises the relay coil
to activate the appli-
ance and LED2 glows.
Switch S1 is used for
quick start without
waiting for delay. 

172 Electronics Projects Vol. 26


White LED-based emergency
lamp and turning indicator
 Anantha Keshava I. and be used for
Shireen M. Baretto two-wheelers
and draws lim-

W
hite LEDs are replacing the ited power from
conventional incandescent the dynamo/
and fluorescent bulbs due battery. At low
to their high power efficiency and low revolutions,
operating voltage. These can be utilised headlight dims
optimally for emergency lamp and because of the
vehicle turning indication. The circuits increase in load.
for the purpose are given here. The white LED-
Fig. 1 shows the circuit of a white- Fig. 1: White LED based emergency lamp based turning
LED based emergency lamp. You can indicator circuit
also use arrays of white LEDs as day- draws a fraction of the
time running lamps in automobiles. power drawn by con-
In the emergency lamp, seven 1.2V ventional bulbs, and
AA-size Ni-Cd cells giving 8.4V have may last longer than
been used as the power source. The the vehicle itself.
brightness is controlled by duty-cycle The circuit com-
variation of an astable multivibrator prises two identical
working at 1 kHz. The astable multivi- sections for left and
brator is built around IC1. Its output is right turn indications.
connected to LED-driver transistor T1. The right turn indi-
Fig. 2: Battery charger
Up to six branches of white LEDs cator circuit is built
can be connected in parallel, with each
branch containing two LEDs in series
(only three branches are used here).
Depending on the application, differ-
ent combinations of battery voltages
and the number of LEDs in series can
be made such as to keep the resistive
losses low.
The charger circuit for a Ni-Cd bat-
tery is shown in Fig. 2. When the battery
voltage is less than 9.8V, charging takes
place since the voltage at the emitter of
transistor T2 (VE) is 9.8V. The value of
resistor R8 is chosen such that the bat-
tery charges at a rate of 70 mA per hour. Fig. 3: Turning indicator
The full charge voltage of the battery is
9.8V. When the battery reaches full volt- spective points of the battery charger around transistors T3 through T5 and
age, the current reduces to approach the circuit. Now your emergency lamp is white/yellow LEDs (LED8 through
tickle charge value of few milliamperes. ready to work. LED13). Similarly, the left turn indica-
Assemble both the circuits shown To use the emergency lamp, switch tor circuit is built around transistors
in Figs 1 and 2 on a general-purpose on the circuit using switch S1. All the T4, T6 and T7 and white/yellow LEDs
PCB. LEDs can also be mounted on LEDs (LED1 through LED6) will glow (LED15 through LED20). Transistor T4
the reflector of a lamp. After assem- to provide sufficient light. and the piezobuzzer are common for
bling, connect points A and GND of Turning indicator shown in Fig. 3 is both-side indicators.
the emergency lamp circuit to the re- another application of the LEDs. It can When you slide switch S2 towards

Electronics Projects Vol. 26 173


right, blinking LED7, right-front LEDs Transistor T3 acts as the buf- mind that the forward drop voltage is
(LED8 through LED10) and rear LEDs fer, while transistor T4 drives the around 1.8V for a single yellow LED
(LED11 through LED13) start blinking. buzzer. Transistors T5 and T7 drive and therefore the value of the resis-
Similarly, when you slide switch S2 the LEDs. tance should be changed in accordance
towards left, blinking LED14, left- The LED array can be built using with the increase in the number of
front LEDs (LED15 through LED17) white LEDs or yellow LEDs depending LEDs in series.
and rear LEDs (LED18 through on the colour of the indicator’s cover. Three white LEDs produce the light
LED20) start blinking. In case you use yellow LEDs, keep in intensity of six yellow LEDs. 

174 Electronics Projects Vol. 26


Inexpensive Car Protection Unit
 M. Venkateswaran and but a good car cover. Normally, the protector operates off
T.E. Parthasarathy Place the circuit at your bedside AC mains and the battery takes over
and bring the two wires from the unit only when mains fail. As the battery

F
or car protection, custom-made to the car (parked outside your home) current is not high, the battery will
units are available but they are and connect one wire-end to the cover last long.
costly. and the other to the ground, with both As long as the two wires remain
Here’s a circuit to protect car ste- wire-ends shorted by some weight shorted, transistor T1 remains cut
reo, etc from pilferage that costs less such as a brick. So outwardly the off. When shorting is removed, tran-
and requires no adjustments in the car mechanism is not visible. sistor T1 gets forward biased and
its collector
voltage drops
to trigger
IC2 and the
piezobuzzer
starts sounding.
If mains
fails, the bat-
tery-takeover
indicator
(shown in Fig.
2 and connected
to points A, B
and C in Fig.
Fig. 1: Circuit of car protection unit with alarm 1) immediately
gets triggered at
If someone tries to remove the pin 2 of IC3. Its high output activates
cover, the alarm of the circuit starts the battery-operation alarm for a couple
sounding to alert you. The alarm of seconds. IC1 draws power from the
can be switched off by resetting it battery to activate the protection unit.
using switch S1. After setting up the unit properly
The car protection circuit com- and shorting both the wires, press
prises two timer ICs: one for the test switch S2. If there is no fault
alarm circuit (see IC2 in Fig.1) in the circuit, the alarm will sound.
and the other to indicate that Now release test switch S2 and mo-
the battery has taken over as the mentarily press reset switch S1 to
power source (see IC3 in Fig. 2). switch off the alarm. 
Fig. 2: Battery takeover indicator

Electronics Projects Vol. 26 175


Dog Caller
 Pradeep G.
adjusting the preset, ultrasonic
sound of 21-22kHz frequency

D
og trainers use a whistle to call can be generated. Whistle effec-
dogs. But why blow that irri- tiveness depends on the speaker
tating, loud whistle when used. Use of a low-wattage
the dog can hear a sound inaudible tweeter is recommended. (Don’t
to the humans? We the humans can use an ultrasonic transducer,
hear up to 20 kHz, but dogs can hear because it is designed for 40 kHz
ultrasound (sound ranging between only.)
20 and 30 kHz) also. The circuit works off 9V. For
Here’s a circuit that generates call your pets by generating ultrasonic portability, use a 9V PP3 battery
21 to 22 kHz (frequencies just above sound. and house the unit inside a pocket ra-
the audible range), so it can be used to IC 555 is used as an oscillator. By dio cabinet. 

176 Electronics Projects Vol. 26


Smart Cellphone Holder
 T.K. Hareendran driver transistor T2
towards ground to

T
his smart cellphone holder disable the visual
makes sure that you don’t for- indicator (LED2).
get to carry your mobile phone. If you’ve forgot-
Fitted in the car, it keeps searching for ten to carry your
the mobile phone within the holder cellphone, LED2
using infrared (IR) rays and alerts you fitted in the cell-
through a flashing LED when it doesn’t phone holder will
find one. You can attach the circuit to stop flashing to in-
your existing cellphone holder or, with dicate that the mo-
a little skill, construct one as per your bile phone is not in
requirement. the cell holder of
The circuit, wired around IC the case. Resistor
LM555 (IC1), derives power from the R1 limits the current
12V DC automobile battery. Diode D1 flowing through IR
is an accidental wrong-polarity input LED1 and resistor
guard. Resistor R7 limits the inrush R6 limits the oper-
Fig. 1: Circuit of smart cellphone holder
current to IC1. ating current and
When power is applied to the cir- hence luminance of
cuit, the low-frequency astable multi- LED2. Variable resistor VR1 deter-
vibrator built around IC1 is activated mines the detection sensitivity of
and LED2 at its output pin 3 flashes phototransistor T1. The blinking
briefly. rate of LED2 can be changed by
When ignition switch S2 is flipped changing the value of capacitor C1
to ‘on’ position, the +12V DC from (or R3-R4 resistor combination).
the car’s battery disables the astable Fig. 2: Pin configurations Fig. 3: Proposed Pin configurations of BC547
multivibrator via diode D2 and LED2 of BC547 and 2N5777 cellphone holder and phototransistor 2N5777, and
turns off. the proposed cellphone holder
When the ignition is turned off and phone holder is empty, IR rays from are shown in Figs 2 and 3, respec-
the mobile phone is in its holder, LED2 IR LED1 fall on phototransistor T1 tively. 
again starts blinking. In case the cell- and it conducts to pull the base of LED

Electronics Projects Vol. 26 177


IC 555 Timer Tester
 Raj K. Gorkhali S2 is in position 2-2, the timer gets tiometer VR3 have been connected for
configured for the astable mode of this purpose.

T
his simple and easy-to-use operation. The output is a pulse train The pulse width in the monoshot
gadget not only tests the IC 555 with the high time period determined mode is given by:
timer in all its basic configura- by the series combination of resistors 1.1×total charging resistance×
tions but also tests the functionality of R8, potentiometer VR2, resistor R9 and charging capacitance
each pin of the timer. Once a timer is capacitor C4, whereas the low time This expression is valid when there
declared fit by this gadget, it will func- period is determined by resistor R9 is no external resistor connected at pin
tion satisfactorily in whatever mode or and capacitor C4. 5. The pulse width can be reduced by
configuration you may try it. The reset terminal of timer IC connecting an external resistor.
The two basic configurations in (pin 4) should be tied to Vcc normally. The high and low time periods in
which a timer IC 555 can be used are More precisely, the voltage at pin 4 the astable mode are:

the astable and the monostable modes should be greater than 0.8V. A volt- High time period = 0.69×charging
of operation. age less than that resets the output. resistance×charging capacitance
When the DPDT switch (S2) is Whether you have connected the timer Low time period = 0.69×discharge
in position 1-1, the timer under test in the monoshot or astable mode of resistance×capacitance
automatically gets wired as a mono- operation, the output goes low the Again the expressions are true with
stable multivibrator. In this case, the moment you bring the reset terminal no external resistor at pin 5. The high
monoshot can be triggered by the mi- below 0.8V. time period can be made to decrease
croswitch (S1). The debouncing circuit The control terminal (pin 5) can by connecting an external resistor be-
constituted by the two NAND gates of be used to change the high time tween pin 5 and ground.
IC1 (N1 and N2) produces a clean rect- (‘on’ time) of the output pulse train The circuit can thus be used to
angular pulse when the microswitch is in the astable mode and the output check:
pressed. Resistor R3, capacitor C1 and pulse width in the monoshot mode 1. The timer IC in astable configu-
diode D1 ensure that the trigger termi- by applying an external voltage. This ration.
nal of timer IC 555 (pin 2 is the trigger external voltage basically changes 2. The timer IC in monostable con-
terminal) gets the desired positive-to- the reference voltage levels of the figuration.
ground trigger pulse. This differentia- comparators inside the IC. The levels 3. The capability of the reset termi-
tor circuit also ensures that the width are set by three identical resistors of nal to override all functions and rest
of the trigger pulse is less than the usually 5 kilo-ohms inside the IC con- the output to low.
expected monoshot output pulse. nected from Vcc to ground, at 2/3Vcc 4. The function of the control
The monoshot output pulse width for pin 5 and 1/3Vcc for pin 2. These terminal to change the ‘on’ or the
is a function of the series combination levels can be changed by connecting ‘high’ time of the output waveform
of resistor R8 and potentiometer VR2, an external resistor between pin 5 in astable mode of operation and the
and capacitor C4. When DPDT switch and ground. Resistor R10 and poten- output pulse width in monostable

178 Electronics Projects Vol. 26


mode of operation. the monoshot has gone high. After the shot using switch S1. You’ll observe
The circuit operates off a 9V bat- predetermined time period, LED2 goes its output going high for a time period
tery, which makes the gadget portable. off and LED1 again glows. Vary preset that is much less than that determined
You can construct it easily on any VR2 and trigger the monoshot again from the series combination of R8 and
general-purpose PCB along with the through switch S1. You will find that VR2, and capacitor C4. In fact, for any
8-pin socket. LED2 glows this time for a longer or a fixed setting of this series combina-
To test an IC 555: smaller time period depending upon tion, the output pulse width can be
1. Insert it into the socket. whether you increased or decreased observed to vary for different values of
2. Set switch S2 in position 1-1. VR2 resistance. potmeter VR3 resistance—by trigger-
3. Switch on the power supply by 6. For checking the reset function of ing the monoshot several times, once
flipping switch S3 to ‘on’ position. the timer, trigger the monoshot again, for each setting of VR3.
Power-indicator LED (LED3) glows to and before the expected time is over, 8. Now set the DPDT switch in
indicate that the circuit is ready to test quickly decrease the potmeter VR1 position 2-2. LED1 and LED2 glow
the IC timer. resistance so as to bring the voltage at alternatively with the timing determined
4. If the IC is okay, LED1 glows pin 4 below 0.8V. You will observe the by the resistances in the charge and dis-
because the IC is wired as a monoshot output going low (indicated by glow- charge paths. This means the timer IC is
and in the absence of any trigger, its ing LED1 and extinguished LED2). okay and wired in astable mode.
output is low. 7. For checking the control function 9. The functions of reset and con-
5. Apply the trigger pulse by mo- of the timer IC, set potmeter VR1 again trol pins can be checked in astable
mentarily pressing switch S1. LED1 in the maximum resistance position. configuration too in the same way
stops glowing and, in turn, LED2 Also set preset VR3 in the minimum as discussed above for the monoshot
glows. This confirms that the output of resistance position. Trigger the mono- configuration. 

Electronics Projects Vol. 26 179


Fuel Reserve Indicator
for Vehicles
 D. Mohan Kumar give a higher reading. time based on the values of R5 and C2.
The fuel monitoring circuit works With the given values, the ‘on’ time
by sensing the voltage variation de- will be around four minutes.

H
ere is a simple circuit for moni- veloped across the meter and activates The output of IC2 is used to power
toring the fuel level in ve- the beeper when the fuel tank is almost the astable circuit consisting of timer
hicles. It gives an audiovisual empty. Its point A is connected to the 555 (IC3) via diode D2. Oscillations

indication when the fuel level drops input terminal of the fuel meter and of IC3 are controlled by R6, R7, VR2
alarmingly below the reserve level, point B is connected to the body of the and C4. With the given values, the ‘on’
helping you to avoid running out of vehicle. and ‘off’ time periods are 27 and 18
petrol on the way. The circuit consists of an op-amp seconds, respectively. The pulses from
Nowadays vehicles come with a IC CA3140 (IC1), two 555 timer ICs IC3 are given to the clock input (pin 14)
dash-mounted fuel gauge meter that (IC2 and IC3) and decade counter of decade counter CD4017 (IC4) and its
indicates the fuel levels on an analogue CD4017 (IC4). outputs go high one by one.
display. The ‘reserve’ level is indicated Op-amp IC CA3140 is wired as a When the circuit is switched on,
by a red marking in some vehicles, voltage comparator. Its inverting input LED1 and LED2 glow if your ve-
but the needle movement through the (pin 2) receives a reference voltage con- hicle has sufficient petrol in the tank.
red marking may be confusing and trolled through VR1. The non-inverting When the fuel goes below the reserve
not precise. This circuit monitors the input (pin 3) receives a variable voltage level, the output of IC1 goes low, LED1
fuel tank below the reserve level and tapped from the input terminal of the turns off and a negative triggering
warns through LED indicators and fuel meter through resistor R1. pulse is received at pin 2 of IC2. The
audible beeps when the danger level is When the voltage at pin 3 is higher output of IC2 goes high for around
approaching. than at pin 2, the output of IC1 goes four minutes and during this time
The fuel sensor system consists high and the green LED (LED1) glows. period, clock pin 14 of IC4 receives
of a tank-mounted float sensor and a This condition is maintained until the the clock pulse (low to high) from the
current meter (fuel meter), which are voltage at pin 3 drops below that at output of IC3.
connected in series. The float-driven pin 2. When this happens, the output For the first clock pulse, Q0 output
sensor attached to an internal rheostat of IC1 swings from high to low, send- of IC4 goes high and the green LED
offers high resistance when the tank ing a low pulse to the trigger pin of the (LED2) glows for around 50 seconds.
is empty. When the tank is full, the monostable (usually held high by R3) On receiving the second clock pulse,
resistance decreases, allowing more via C1. The monostable triggers and its Q1 goes high to light up the yellow
current to pass through the meter to output goes high for a predetermined LED (LED3) and sound the buzzer for

180 Electronics Projects Vol. 26


around 45 seconds. This audio-visual indicate that the vehicle will run out of than 12V.
signal warns you that the vehicle is fuel very shortly. The circuit can be assembled on a
running out of fuel. On receiving the Q6 output of IC4 is connected to its perforated board. Adjust VR1 until the
third clock pulse, LED3 and the buzzer reset pin 15 via diode D3. This means voltage at pin 2 of IC1 drops to 1.5V.
go off. There is a gap of around two- that after ‘on’ state of Q5, the count When point A is connected to the fuel
and-a-half minutes before Q5 output will always start from Q0. Capacitor meter (fuel gauge) terminal that goes
goes high. C5 provides power-on reset to IC4 to the fuel sensor, green LEDs (LED1
By the time Q5 goes high and the when switch S1 is closed. The output of and LED2) glow to indicate the normal
red LED (LED4) glows, four minutes IC1 is also connected to reset pin of IC4 fuel level. VR2 can be varied to set the
elapse and the power supply to IC3 is via diode D1 (1N4148). So when your ‘on’ time period of IC3 at around 20
cut off. The output state at Q5 will not vehicle is refueled above the reserve seconds.
change unless a low-to-high clock input level, LED2 glows to indicate that the Enclose the circuit in a small case
is received at its pin 14. Thus LED4 will tank has sufficient fuel. and mount on the dashboard using
glow continuously along with the beep. IC5 provides regulated 12V DC for adhesive tape. The circuit works only
The continuous glowing of the red LED proper functioning of the circuit even in vehicles with negative grounding of
(LED4) and the beep from the buzzer when the battery is charged to more the body. 

Electronics Projects Vol. 26 181


medium-power FM Transmitter
 Pradeep G. But these also work fine in RF stages as os- For the maximum
cillator.) The third stage is a class-A tuned range, use a sensi-

T
he range of this FM transmitter amplifier that boosts signals from the tive receiver. VC1 is
is around 100 metres at 9V DC oscillator. Use of the additional RF ampli- a frequency-adjust-
supply. fier increases the range of the transmitter. ing trimpot. VC2
The circuit comprises three stages. The Coil L1 comprises four turns of 20SWG should be adjusted
first stage is a microphone preamplifier enamelled copper wire wound to 1.5cm for the maximum
Fig. 2: Pin
built around BC548 transistor. The next length of a 4mm dia. air core. Coil L2 com- configurations of range. The transmit-
stage is a VHF oscillator wired around prises six turns of 20SWG enamelled copper transistors BC548 and ter unit is powered
C2570
another BC548. (BC series transistors are wire wound on a 4mm dia. air core. by a 9V PP3 battery.
generally used in low-frequency stages. Use a 75cm long wire as the antenna.

Fig. 3: Walkie-talkie arrangement

It can be combined with a readily avail-


able FM receiver kit to make a walkie-
Fig. 1: FM transmitter talkie set as shown in Fig. 3. 

182 Electronics Projects Vol. 26


Teleconferencing System
 Prince Phillips transformer consist of 500 turns of no telephone on that line is present.
40SWG insulated copper wire. At the Here, transistor T1 acts like a resis-

H
ere is a low-cost teleconferencing secondary side, a small circuit is used tor to DC and as high impedance for
system that lets you talk to two for DC holding. This circuit is built audio signals. The high impedance of
persons at a time in any part of the around transistor T1 (BC547), resistors the circuit is provided by condenser
world over two telephone lines. The circuit R2 and R3 (15 kilo-ohms and 100 ohms, C3, which prevents any audio signal
makes use of a coupling transformer and respectively), condenser C3 (22µF, 63V) from appearing at the base of T1.
some passive components. and two LEDs as indicators for both the Thus any audio voltage appearing
The circuit is connected between the primary and secondary sides. It provides across telephone line No. 2 will not
two telephone lines. It works like this: proper DC characteristic to hold second cause a corresponding current in the
When ‘X’ calls ‘A’ on the first telephone telephone line in operation even though transistor. 
line, ‘A’ puts this call on hold, di-
als ‘Y’ on the other telephone line
(which is free) and keeps this call
too on hold, and slides switches
S1 and S2 to ‘on’ position. Now
‘X,’ ‘A’ and ‘Y’ can talk to one
another simultaneously over the
two telephone lines.
Both the primary and sec-
ondary coils of the coupling

Electronics Projects Vol. 26 183


Light Dimmer That Doubles
As Voltmeter
 G.D. Sekhri ible, that point can be used as the reference the tolerance
point for measuring the voltage. is of the or-

M
easure AC mains voltage First, remove the old knob and fix a der of 1 per
without using a multi- circular white paper around the shaft. cent ±5 volts.
meter. All you need to do is to Now put back a skirted knob with a The diameter
slightly modify the light dimmer fitted at the cursor as close to the paper as possible of the knob of
base of a table lamp for use as a voltmeter. and mark two extremities of the pot on potmeter and
When the dimmer is turned anticlockwise to the paper as CW and ACW (see Fig. 2). Fig. 2: AC volts scale marking
fineness of
a point where the filament glow is just vis- Switch on the lamp via a variac and cursor can be
feed 50 volts. Rotate the potmeter knob of help in getting better
anticlockwise until the filament glow is accuracy and tolerance.
just visible and mark that point against An ordinary fan
the cursor as 50V. Keep on increasing regulator can be used
the voltage to 100, 150, 180, 200 and with a lamp of 40,
220 using the variac and calibrating 60 or 100 watts and
the scale for all the voltages. Now a calibrated accord-
voltage scale is created. The only snag ingly. The minimum
Fig. 3: Pin
is that the voltage is increasing in anti- configuration of measurable voltage
clockwise direction, which should not BT134 is naturally limited to
be a problem. The scale will not how- the one required for
ever be linear unlike the one shown ‘just visible’ condition. With R1 open
in the sketch. Accuracy will depend circuited the maximum scale voltage
Fig. 1: Light dimmer
on the calibration standard used and will be around 220 volts. 

184 Electronics Projects Vol. 26


Multicell Charger
 T.K. Hareendran When the battery
reaches full charge,

U
sing this charger, you can SCR2 conducts to pull
safely charge up to two pieces down the gate of SCR1.
of Ni-Cd cells or Ni-MH cells. This state is indicated
The circuit is compact, inexpensive and by LED2. Now remove
easy-to-use. the cells from the char-
The 230V AC mains is down- ger. Normally, Ni-Cd
converted to 12V AC (at 500 mA) by cell with a rating of 500
step-down transformer X1, converted mAH will take around
into pulsating DC voltage by diodes 2.5 hours to reach full
D1 and D2, and fed to the battery charge, while the charg-
charger terminals via current-limiting ing time for Ni-MH cell with a rating output terminals, which should be
resistor R1 and silicon-controlled rec- of 1500 mAH will be around 7 hours. around 5V DC. Now insert the two
tifier SCR1. Charging time may vary depending on cells into the holder and connect it
SCR1 is at the heart of the charger. the settings of the charger and input sup- to the charger output terminals for
Normally, it conducts due to the gate ply line conditions. charging. LED1 instantly lights up
biasing voltage available through resis- After construction, a minor ad- to indicate the charging process. If
tor R2 and diode D3, and the battery is justment is required for ensuring LED1 glows dimly, readjust VR1 for
in charging mode, which is indicated by proper performance: Power on the proper glowing of LED1. Now the
LED1. Resistor R2 limits the charging circuit without cells and adjust circuit is ready for use.
current to a safe value. Charging current VR1 such that LED2 lights up. Now Use of a small heat-sink is recom-
of this circuit is about 250 mA. measure voltage across the charger mended for SCR1. 

Electronics Projects Vol. 26 185


Timer for Geyser
 V. Gopalakrishnan

T
his timer circuit for gey-ser
sounds an alarm after the
set timing of 22 minutes
when the water is heated up.
The circuit comprises a timer IC
555 wired as an astable multivibra-
tor with adjustable time period of
15 seconds. The astable output after
inversion by an inverter drives de-
cade counters IC3 and IC4 (each IC
7490) connected in cascade. The de-
cade counters output is connected
to decoders IC5 and IC6 (each IC
7442), respectively. The decoder
outputs (Q8 outputs of IC5 and IC6)
are fed to inverters and the inverter
outputs, in turn, are fed to an AND
gate. The AND output is connected
to the reset pin of the astable multi-
vibrator built around another timer
IC 555 to sound the alarm. Now
you can turn off the geyser.
A green LED (LED1) has been
used as the power supply indicator. switched on simultaneously. puts of IC5 and IC6 using dip switches
Switch on the timer and the gey- After the siren sounds, if required, (S3 and S4) while keeping in mind IC5
ser at the same time. When the alarm we can increase the time by another outputs (Q0 through Q9) are spaced
sounds, it means that the water in the 22 minutes for geyser by resetting the 15 seconds apart and IC6 outputs are
geyser has heated up and can be used. circuit by pushing reset switches S1 spaced 150 seconds (2.5 minutes) apart.
You can assemble the timer circuit and S2 momentarily. Caution. Please note that the
on a general-purpose PCB and install If you want to change the preset timer circuit has no connection with the
it near your bathroom so that both time of the geyser, the same can be eas- geyser circuit. The geyser works off 220V
the timer circuit and the geyser can be ily done by combining appropriate out- AC, while the timer works off 5V DC. 

186 Electronics Projects Vol. 26


220V Live Wire Scanner
 T.A. Babu
The circuit can be used to find
stray leakage from electrical appli-

T
his simple circuit lets you scan a ances like fans, mixers, refrigera-
220V live wire. The clock input tors, etc. It can be easily assembled
of the IC is connected to a wire, on any general-purpose board or
which acts as the sensor. Here, we have the discrete components can be
used 10cm length of 22SWG wire as directly soldered on the IC.
the sensor. A 9V PP3 battery powers
When you hold the sensor (metal- the circuit. If you use a mains
lic conductor or copper wire) close adaptor, make sure that it is well
to the live wire, electric field from regulated and isolated; otherwise,
mains activates the circuit. As the even the stray electric field from
input impedance of the CMOS IC drives the LED. Flashing of the LED mains transformer will clock the circuit.
is high, the electric field induced in (LED2) indicates the presence of Caution. Use insulated wire as sen-
the sensor is sufficient to clock it. The mains, while LED1 indicates that the sor to avoid risk of exposure to live AC
output obtained at pin 11 of CD4017 scanner is active. mains. 

Electronics Projects Vol. 26 187


Doorbell-Cum-Visitor Indicator
 V. Gopalakrishnan

T
his doorbell circuit can also
give identification of the visitor
to your home in your absence.
When you’re home, you can use it
simply as a normal doorbell.
The circuit (see Fig. 1) comprises a
monostable built around timer IC 555
(IC1), relay driver transistor BC548
Fig. 3: Suggested LED display to be kept near
(T1), inverter section built around Fig. 2: Switch panel to be mounted on the gate the owner’s desk
IC 7404 (IC2), latching section built
around IC 555 (IC3) and LED display S2. The output of IC3 at its pin 3 is fed reset switch S3 once. When somebody
driver transistor BC548 (T2). to LED1 (visitor-out indicator) and visits your home and presses doorbell
The monostable output drives the LED2 through LED16 via LED driver switch S1, it will trigger the monostable
relay through transistor amplifier T1. transistor T2. (IC1) and also energise the relay to ring
The normally-opened (N/O) contact The switch panel shown in Fig. the bell. The monostable output through
of the relay connects an electric bell 2 is to be mounted on the entry gate inverter N1 will enable the latching cir-
with mains supply as shown in Fig. 1. or door, while the LED display panel cuit and LED1 will glow continuously
The output of the monostable also goes shown in Fig. 3 is to be kept inside the to indicate that you’re out of the house.
to inverter N1, which, in turn, enables house near the owner’s desk. The message “Please indicate the
the latching circuit built around IC3 in Before you leave your house, slide first letter of your name (single alphabet
conjunction with DPDT slide switch switch S2 (Out) to ‘on’ position and press in English only) by flipping switches S4
through S18 to
‘on’ position,”
as required, is
written just be-
low LED1 indi-
cator as shown
in Fig. 2.
Suppose the
visitor’s name is
Tina Chopra. As
the initial alpha-
bet of her first
name is ‘T,’ she
has to flip the
topmost-row
and middle-col-
umn switches
towards ‘on’
position. The
position of the
switches for
this example is
shown in Fig. 2.
When you
return home,
just flip switch
S19 to ‘on’ po-
Fig. 1: Circuit diagram of doorbell-cum-visitor indicator sition to check

188 Electronics Projects Vol. 26


the visitor’s initial. The topmost-row the red LEDs. and thus prevent unnecessary continu-
and middle-column LEDs will glow to Now you can slide switch S2 to ous drain of power. Now the rest of the
indicate the alphabet ‘T,’ so you know ‘off’ position or press reset button S3 circuit will work as a doorbell only.
that one of your friends having name once. When the indicator is not in use, The rows and columns may be in-
starting with ‘T’ had visited your place slide DPDT switch S2 to ‘off’ position creased to accommodate a 5×7 display
in your absence. The status of the LEDs to bypass the latching and LED display matrix. The circuit can be used for a
for this example is shown in Fig. 3 by sections by cutting off the power supply single visitor only. 

Electronics Projects Vol. 26 189


Smart Switch
 T.A. Babu shown here, offers a better alternative. ple of Schmidt trigger
It is nothing but an ‘on’/‘off’ control- gates that control a

T
o switch on the mains voltage, ler and uses an electronic circuit that triac. The load can be
either a mechanical switch or a behaves like a normal switch. A flat switched on/off by
relay offers a simple solution. pushbutton control provides an aes- simply pushing the
However, the relay and its associated thetic look to your switch panel. pushbutton switch
components occupy a lot of space and The switching circuit comprises an for a brief period.
cannot be accommodated in a standard optocoupler circuit that receives input Every time the switch
Fig. 2: Pin
switch box. The ‘smart switch’ circuit, from a bistable switch formed by a cou- configuration of
receives a push, the
triac BT136 optocoupler toggles
the triac. A special ze-
ro-crossing detector in the optocoupler
supresses radio interference, unlike the
arbitrary phase switching.
Since mains is not isolated, use
a good-quality pushbutton switch
with proper insulation to avoid lethal
shock. Make sure that the triac can
handle the current you are going to
draw through it. If required, several
pushbuttons can be wired in parallel
to allow toggling of the triac from dif-
Fig. 1: Circuit of the smart switch ferent locations. 

190 Electronics Projects Vol. 26


Stress Meter
 D. Mohan Kumar cuit. The circuit is very sensitive and ten LEDs one by one in the dot/bar
detects even a minute voltage variation mode for each increment of 125 mV

T
his stress monitor lets you across the touch pads. in the input.
assess your emotional pain. If The circuit comprises signal am- Here, we’ve used only five LEDs
the stress is very high, it gives plifier and analogue display sections. connected at pins 14 through 18 of IC1.
visual indication through a light-emit- Voltage variations from the sens- LED1 glows when input pin 5 of IC1
ting diode (LED) display along with ing pads are amplified by transistor receives 150 mV. LED5 glows when
a warning beep. The gadget is small BC548 (T1), which is configured as a the voltage rises to 650 mV and LED5
enough to be worn around the wrist. common-emitter amplifier. The base flashes and piezobuzzer PZ1 beeps
The gadget is based on the prin- of T1 is connected to one of the touch when the stress level is high.
ciple that the resistance of the skin var- pads through resistor R1 and to the Resistors R4 and R5 and capacitor
ies in accordance with your emotional ground rail through potmeter VR1. By C2 form the flashing elements. Resis-
states. If the stress level is high the skin varying VR1, the sensitivity of T1 can tor R3 maintains the LED current at
offers less resistance, and if the body is be adjusted to the desired level. Diode around 20 mA. Capacitor C3 should
relaxed the skin resistance is high. The D1 maintains proper biasing of T1 and be placed close to pin 3 for proper
low resistance of the skin during high capacitor C1 keeps the voltage from functioning of the IC. Zener diode
stress is due to an increase in the blood the emitter of T1 steady. ZD1 in series with resistor R6 provides
supply to the skin. This increases the The amplified signal from tran- regulated 5V to the circuit.
permeability of the skin and hence the sistor T1 is given to the input of The circuit can be assembled on
conductivity for electric current. IC LM3915 (IC1) through VR2. IC a small piece of perforated board.
Use transparent
3mm LEDs and a
small piezobuzzer
for audio-visual
indications. En-
close the circuit in
a small plastic case
with touch pads
on the back side.
Fig. 2: Display panel
Two self-locking
straps can
be used to
tie the unit
around
your wrist.
After
Fig. 3: Self-locking straps tying th e
Fig. 1: Circuit of the stress meter unit around
your wrist (with touch pads in contact
This property of the skin is used LM3915 is a monolithic integrated with the skin), slowly vary VR1 until
here to measure the stress level. The circuit that senses analogue voltage LED1 glows (assuming that you are in
touch pads of the stress meter sense levels at its pin 5 and displays them relaxed state). Adjust VR2 if the sensi-
the voltage variations across the touch through LEDs providing a logarithmic tivity of IC1 is very high. The gadget is
pads and convey the same to the cir- analogue display. It can drive up to now ready for use. 

Electronics Projects Vol. 26 191


Power Failure and
Resumption Alarm
 Seemant Singh colour. connected to ground, a positive out-
When power fails, pnp transistor put pulse is generated according to

T
his circuit gives audio-visual in- T1 starts conducting and bicolour the following relationship:
dication of the failure and re- LED1 glows in red colour. Due to T = 1.1×R5×C3.
sumption of mains power. The non-availability of Vcc voltage at pin This positive output is present at
circuit is built around dual timer IC 14 of IC2, its output pin 9 remains low pin 5 of IC2. Since IC2 is a dual-timer
LM556. When mains is present the bi- and transistor T3 does not conduct. IC, its first output is directly fed to re-
colour LED glows in green colour, and However, capacitor C7 (4700µF) holds set pin 10 of second section. Therefore
when mains fails it turns red. adequate charge and hence transis- the second timer of IC2 starts oscillat-
The AC mains is stepped down tor T4 conducts and piezobuzzer PZ1 ing. Its frequency of oscillations (F0)
by transformer X1 to deliver the sec- sounds continuously for around eleven is determined by resistors R6 and R11
ondary output of 12V at 250 mA. The seconds until capacitor C7 discharges and capacitor C6 as follows:
transformer output is rectified by a completely. F0=1.4/(R6+2R11)×C6.

full-wave bridge rectifier comprising When power resumes, bicolour IC LM556 outputs frequencies
diodes D1 through D4, filtered by LED1 glows in green colour and the in the form of pulses at its pin 9.
capacitor C1 and regulated by IC 7809 buzzer beeps for around 14 seconds. These pulses are coupled to npn
(IC1) to give regulated 9V DC to oper- Dual timer IC LM556 (IC2) sections transistor T3, which conducts and
ate the circuit. have been used here in monostable and cuts off depending on the output at
9V battery and pnp transistor T1 astable modes, respectively. pin 9 of IC2. Red LED2 is connected
have been used here as the power In the monostable section, loca- to pin 9 via current-limiting resis-
source for red light indication of the tion of the external timing capacitor tor R7 (270-ohm) to indicate power
absence of power. Transistor T1 can be determines whether a positive or resumption.
made to conduct or cut-off easily by negative output pulse is gener- The collector output of transistor
varying preset VR1. ated. Diode D7 ensures that even a T3 is directly fed to the base of pnp
Initially, when mains is present, momentary power loss will cause transistor T4, due to which base bias-
pnp transistor T1 is in cut-off state and a pulse to be generated when the ing of T4 varies and the buzzer beeps
therefore bicolour LED1 glows in green power resumes. With capacitor C3 for around 14 seconds. 

192 Electronics Projects Vol. 26


Little Door Guard
 T.K. Hareendran Assemble the unit on a general-
purpose PCB as shown in Fig. 4

I
f some intruder tries to open the and mount the same on the door as
door of your house, this circuit shown in Fig. 3. Now mount a piece
sounds an alarm to alert you of mirror on the doorframe such that
against the attempted intrusion. it is exactly aligned with the unit. Pin
The circuit (Fig. 1) uses readily configurations of IC UM3561 and tran-
available, low-cost components. For sistors 2N5777 and BC547 are shown
compactness, an alkaline 12V battery is in Fig. 2.
used for powering the unit. Input DC Initially, when the door is closed,
supply is further regulated to a steady the infrared (IR) beam transmitted
DC voltage of 5V by 3-pin regulator IC by IR LED1 is reflected (by the mir-
7805 (IC2). ror) back to phototransistor 2N5777 Fig. 3: Back view of the door assembly

Fig. 4: Suggested enclosure with major


components layout

When the door is opened, the ab-


sence of IR rays at phototransistor T1
forward biases npn transistor T2, which
provides positive supply to IC1. Now
3-siren sound generator IC UM3561
Fig. 1: Circuit of the door guard (IC1) gets power via resistor R5. The
output of IC1 at pin 3 is amplified by
(T1). The IR beam falling Darlington-pair transistors T3 and T4
on phototransistor T1 re- to produce the alert tone via the loud-
verse biases npn transistor speaker.
T2 and IC1 does not get Rotary switch S2 is used to select
positive supply at its pin 5. As the three preprogrammed tones of
a result, no tone is produced IC1. IC1 produces fire engine, police
at its output pin 3 and the and ambulance siren sounds when its
loudspeaker remains silent. pin 6 is connected to point F, P or A,
Fig. 2: Pin configurations of UM3561 and transistors
Resistor R1 limits the operat- respectively. 
2N5777 and BC547 ing current for the IR LED.

Electronics Projects Vol. 26 193


Electronic Fuse
 T.A. Babu application, which is a resettable fuse
by itself.

A
n absolute necessity of every Initially, when the circuit is pow-
electronics lab is a workbench ered, silicon-controlled rectifier SCR1
power supply. The power is ‘off.’ Relay RL1 energises through Fig. 2: Reed relay with coil winding
supply should be regulated and pro- the polyfuse and the load is con-
tected against short circuit. nected through the normally opened
Most power-supply protection cir- (N/O) contact of the relay. When the
Reed Relay Winding Details
current drawn
for Different Load Currents
by the load in- Current (amperes) Turns SWG
c re as e s ab o v e 10 5 13
5 10 16
a certain level 2.5 20 18
(which depends 1.25 4 21
on the number
of turns in the cates that the power supply is work-
winding on reed ing normally. LED1 indicates that the
relay, see Fig. 2 power supply unit is under the protec-
and the accompa- tion mode and the buzzer sounds to
nying table), the warn the user.
contacts of reed The turns of reed relay wind-
relay RL2 close ing are based on the current drawn
to trigger SCR1. through the load, so refer to the table
Fig. 1: Electronic fuse As a result, relay for winding details for your load cur-
RL1 de-energises rent requirements. At EFY, testing
cuits use a low-value, high-wattage re- and the load gets disconnected. The was done for approximately 1.85A
sistor connected in series with the load polyfuse remains in high-resistance AC load current at 230V AC mains
for current sensing. The voltage drop state until SCR1 is turned off. and accordingly 16 turns of 22SWG
across the sensor resistor is weighed The circuit can be reset either by copper-enamelled wire were wound
to activate the protection circuit. The switching off the power supply or by on the reed relay. 
given circuit is based on a polyfuse pushing reset switch S1. LED2 indi-

194 Electronics Projects Vol. 26


Digital Dice
 Sagar G. Yadav are required for operation. This is done NAND and NOR gates in the circuit
with the help of diodes D1 and D2 and we make use of two NAND gates and

T
he digital dice presented here resistor R3, which are connected such a NOR gate (with A+BC output) to
acts just like a normal dice. It that they generate an AND logic. perform this function.
has six faces (refer Fig. 2) like From the table it can be noticed that LED2 and LED5 glow only at the first
the normal dice and uses four different at the sixth count, the counter outputs and fifth counts. In other words, they
logic gate combinations to bring out the A and B hold logic 1 simultaneously glow only when the complement of B
six faces of the dice. for the first time, so by ANDing A and and C outputs goes high. This function
At the heart of the circuit is a B outputs you can give logic 1 to the can be obtained by using two NAND
14-stage ripple-carry binary counter reset terminal of the counter at the sixth gates such that their output corresponds
IC CD4060BC (IC1) with built-in os- count, thereby resetting the counter. to the Boolean expression BC or B+C ac-
cillator. The logic section is designed LED2 and LED5 always glow at cording to De Morgan’s theorem.
around CMOS quad 2-input NOR gate the same count, as do LED1 and LED6, LED7 glows at even counts like 0,

Fig. 1: Digital dice

IC CD4001BC (IC2) and quad 2-input and LED3 and LED4. Using
NAND gate IC CD4011BC (IC3). The these three pairs of LEDs
display section is formed by a group of and LED7, four logical com-
seven LEDs. binations have been made in
The circuit is divided into three sec- the circuit. LED1 and LED6
tions: counter, logic and display. glow at all counts, except
The counter section is built around ‘0’ and ‘1.’ Further, it can be
binary counter IC CD4060BC (IC1). The noticed that they glow when
counter frequency (f) is decided by the ‘A’ or ‘B’ is high, hence a
in-built oscillator formed by resistor R1 NOR gate whose output is
and capacitor C1 as follows: A+B according to Boolean
f=1/2.2R1C1. algebra will perform the job Fig. 2: Different faces of dice
Here, the frequency is fixed at around of operating these LEDs.
2056 Hz. LED3 and LED4 glow at all counts, 2 and 4. In other words, it glows when
Only the first three outputs of the except for the first three counts, i.e., the C output is low. This function can
counter (designated as A, B and C, they glow when either A, or B and C be achieved easily by inverting the C
respectively) have been used in the cir- are high. This logic function can be output twice using the remaining two
cuit. The counter is designed to reset at obtained by using an OR gate and an NAND gates. The output will also be
the sixth count (110) as only six counts AND gate, but since we are using only buffered by these two inverter gates.

Electronics Projects Vol. 26 195


ing will make the dice foolproof. When
Dice Score and LEDs Lit at Different Counts you remove your finger from the touch
Count Dice A B C LEDs lit
score
pad, the counter will stop counting and
the display section will show any one
0 1 0 0 0 — — — LE D7
1 2 0 0 1 — — LED2 — LED5 of the six possible faces with a prob-
2 3 0 1 0 LED1 — — LED7 — — LED6 ability of 1/6.
3 4 0 1 1 LED1 LED3 — — — LED4 LED6 The entire circuit can be powered
4 5 1 0 0 LED1 LED3 — LED7 — LED4 LED6
5 6 1 0 1 LED1 LED3 LED2 — LED5 LED4 LED6
by a 9V battery as the inbuilt oscillator
6 — 1 1 0 — — — — — — — of the counter IC will not work prop-
erly below 7V. Use of CMOS ICs means
The display section comprises sev- When you place your finger on the less power consumption.
en LEDs. LED1 and LED6 have com- touch pad, the oscillator starts oscillat- The circuit can be constructed on a
mon cathodes, as do LED2 and LED5, ing. The counter will start counting at general-purpose PCB and housed in-
and LED3 and LED4. The anodes of all the rate of 2056 Hz and all the LEDs of side a plastic case with the LEDs array
the LEDs are tied together to the posi- the display section will appear to glow mounted on the top as shown in Fig. 2.
tive terminal of the battery via resistors simultaneously due to the high counter The touch pad can be mounted beside
R4 through R10, respectively. frequency. This high-frequency count- the array. 

196 Electronics Projects Vol. 26


Bicycle Guard
 T.K. Hareendran existing dynamo assembly. forward or reverse rotation of the DC
Power supply switch S1 should be motor induces a small voltage at its DC

T
his antitheft device for bicycles kept ‘on’ when you are using this bi- input terminals and the internal LED of
is inexpensive and can be con- cycle guard. When it is flipped towards 4-pin DIP AC input isolator optocou-
structed easily using a few ‘on’ position, the circuit gets power pler IC3 (PS2505-1 or PC814) glows.
components. from the miniature 12V battery. Now As a result, the internal transistor of
At the heart of the circuit is a wheel LED1 lights up and resistor R4 limits IC3 conducts and pin 2 of IC1 is pulled
rotation detector, realised using a DC the LED current. Next, the monostable low by the optocoupler and the mo-
micro motor. For the purpose, you can built around IC1, which is CMOS ver- nostable built around IC1 is triggered.
use the micromotor (spindle motor) of sion of timer LMC555, is powered The output at pin 3 of IC1 now
a discarded local CD deck mechanism. through a low-current, fixed-voltage drives piezobuzzer-driver transistor
With a little skill and patience, you can regulator IC2 (78L05). T1 via resistor R3 and the buzzer starts
easily attach a small metallic pulley Initially, when the bicycle is stand- sounding to alert you. In this circuit,
covered with a rubber washer to the ing still, the monostable output at pin the buzzer remains ‘on’ for around two
motor spindle. Thereafter, fix the unit 3 of IC1 is low and the circuit is in idle minutes. You can change this time by
in the back wheel of the cycle, like the state. In the event of a theft attempt, changing the values of resistor R2 and
capacitor C1.
Zener diodes ZD1 and ZD2
(each 5.1V) act as a protector
for optocoupler IC3. The costly
GP12V/27A battery is used here
due to its compact size and reli-
ability. 12V active buzzers with
high-pitched tone output may be
used with this circuit. These are
readily available in the market.
Note. The specific optocoupler
is used here deliberately, instead
of a bridge rectifier, to increase
the circuit’s detection sensitivity.
Never replace the same with a DC
optocoupler. 

Electronics Projects Vol. 26 197


Liquid-level Alarm
 Pradeep G. signal is passed through the probes, so tank is empty, pnp transistor T1 does not
there will be no electrolysis and there- get negative base bias. But as water fills

I
n water-level controllers or tanks, fore the probes last longer. up in the tank, it receives 1kHz signal
a DC current is passed through the The block diagram for the liquid- from IC1 via the probes immersed in
metallic probes fitted in the water level alarm is shown in Fig. 1. The water and conducts during the nega-
tank to sense the water level. This causes signal generator sends the generated tive half cycle of 1kHz signals. Due to
electrolysis and corrosion of probes, signal to the first metallic probe. The the presence of capacitor C7 (2.2µF),
inhibiting the conduction of current and second metallic probe is connected npn transistor T2 continues to get base
degrading its performance. As a conse- to the sensing circuit followed by the bias and conducts to provide 3.3V DC
quence, probes have to be replaced regu- alarm circuit. to melody generator IC UM66 (IC2).
larly to maintain proper current flow. The complete circuit for the liquid- Pin configuration of IC UM66 is shown
The liquid-level alarm given here level alarm is shown in Fig. 2. The in Fig. 3. Preset VR1 acts as the output
overcomes this problem. A 1kHz AC astable multibrator built around IC loudness controller. It can
555 (IC1) generates be varied to set the alarm
1kHz square wave sound from the speaker at
signal, which is fed the desired level.
to one of the probes The circuit works off
via a DC blocking 12V unregulated power
capacitor. Fig. 3: Pin and can be used to detect
configuration
Fig. 1: Block diagram of liquid level alarm When the water of UM66 any conductive liquid. 

Fig. 2: Liquid level alarm

198 Electronics Projects Vol. 26


Remote-controlled
Power-Off Switch
 Debaraj Keot from mains using the remote for the ergises. The relay de-energises if both
audio or video systems. the inputs to transistor T2 go low.

R
emote controllers for various The circuit consists of a timer IC Initially, to switch on mains supply
audio/video systems are usu- NE555, a decade counter IC HCF4017, for the audio/video system and the
ally provided with a power three BC548 transistors, an infrared (IR) circuit itself, pushbutton switch S1 is
‘on’/‘off’ or standby-mode selector sensor IC TSOP1738 and a few discrete pressed momentarily.
button. But turning the system off from components. Transformer X1, diodes Normally, the output of IR receiver
the remote handset actually does not D1 and D2, and capacitor C1 form module IC3 is high when it is not being
cut off the whole system from mains. power supply for the circuit. Zener activated by a remote, and the relay
Some circuitry inside the system con- diode ZD1 provides regulated voltage energises to close the N/O contact and
tinues to get power from mains even to IR sensor TSOP1738 (IC3). place a short across switch S1. This cir-
when the power is turned off using the Timer IC NE555 (IC1) is configured cuit and the load continue to get power

remote handset. One needs to turn off as an astable multivibrator that produces through the N/O contact of relay RL1
the mechanical switch provided on the a clock pulse every two seconds. The even when pushbutton S1 is released.
system’s front panel or wall outlet in clock pulse is fed to decade counter IC At the same time, the output of IC2
order to turn off the entire system. HCF4017 (IC2), whose Q7 output is in- starts scrolling around its output pins,
Also, accessories like TV boost- verted by transistor T1 and applied to the i.e., pins 5 and 6 go high and low al-
ers, stabilisers and additional ampli- base of transistor T2 to drive the relay. ternately for the clock pulses received.
speaker systems cannot be turned off The output of sensor IC3 is used When Q6 output goes high the ‘warning’
from the remote handset. And it is very to drive transistor T3 and activate the LED (yellow) glows, and when Q7 out-
annoying to get out of bed to switch off relay via transistor T2. put goes high the ‘off’ LED (red) glows.
mains after watching some programme The outputs of transistors T1 and Yellow LED (LED1) indicates that
on TV or listening to music. T3 are ORed and the resultant is ap- it’s time to switch off the audio or
The circuit given here can discon- plied to transistor T2. Thus if any one video system.
nect the entire system along with the or both the inputs connected to the base The entire system can be turned
accessories, including the circuit itself, of transistor T2 are high, relay RL1 en- off by pressing any key on the hand-

Electronics Projects Vol. 26 199


set once when the red LED (LED2) Since both the inputs connected to the former’s primary winding.
is glowing. The reason is that red base of transistor T2 become low at Any normal operation (increas-
LED2 glows when the Q7 output of this time, the transistor stops conduct- ing/decreasing volume, changing
IC2 is high. Due to this, the output of ing and the relay de-energises. As a channels, etc) can be performed when
transistor T1 is low. Now if any key result, the N/O contact of the relay either both the LEDs are ‘off’ or the
on the remote handset is pressed, the opens to switch off the circuit and remote is not oriented towards IR re-
sensor output goes low for a while. the load connected across the trans- ceiver module IC3. 

200 Electronics Projects Vol. 26


Zener Value Evaluator
 V. Gopalakrishnan as the ramp output of IC1 is high. frequency applied on clock pin 14 of
The display unit comprising decade IC3 from pin 3 of IC2.

U
sing this simple circuit and a counter ICs 74LS90, decoder/driver ICs IC 74LS90 is a 4-bit ripple decade
known-value zener diode, you 74LS47 and 7-segment common-anode counter. When the output of IC3 is ‘10’
can find the breakdown volt- displays LTS542 is shown in Fig. 2. (1001), it provides clock at pin 14 of IC4
age value of any zener diode. The cir- Decade counters IC3 and IC4 count the (via AND gate N1) for further counting.
cuit is divided into two
sections: zener evalu-
ator and display unit.
Regulated 12V and 5V
are required to power
the zener evaluator sec-
tion, while the display
section works off only
5V. Connect +5V, point
A and ground of the ze-
ner evaluator section to
the respective terminals
of the display section.
The zener evaluator
circuit (Fig. 1) comprises
a linear ramp genera-
tor built around timer Fig. 1: Circuit diagram of zener evaluator section
NE555 and an astable
multivibrator built around another
NE555. The resistor of the monostable is
replaced with a constant-current source
formed by transistor T1. Capacitor C2 is
charged linearly by the constant-current
source formed by transistor T1.
The time period T of the linear
ramp generated by IC1 at its pin 6
across capacitor C2 is given by:
(2/3)×VCC×R5 (R6+VR2)×C2
T= .......Eq. (1)
R6×VCC—VBE (R6+VR2)

On substituting the values shown


in Fig. 1, you get:
T= 0.15 second (approx.)
This value is equal to Ton of the
monostable without connecting the
zener at the control voltage terminal
pin 5.
Now connect the zener to the
control voltage terminal and trigger
the monostable (IC1) by momentarily
pressing switch S1. The output pulse
width of IC1 is fed to the astable mul-
tivibrator (IC2). The time period of the
astable multivibrator is around 7 mil-
liseconds (ms) and it oscillates as long Fig. 2: Display section

Electronics Projects Vol. 26 201


For resetting IC3 and IC4, simply press N1 for the known zener diode break- tion marked ‘ZUT’ of Fig. 1 and press
reset switch S3 momentarily. down voltage value X1 and up to N2 trigger switch S1 momentarily. The
The outputs of decade counters IC3 for the unknown zener diode value counter counts up to, say, ‘29’ (N1),
and IC4 are connected to 7-segment X2. Now, you can calculate the value which is shown on the display. Now
decoders/drivers IC6 and IC5, respec- of the unknown zener diode from the remove the 6.8V zener and insert the
tively, which, in turn, are connected to following relationship: zener of unknown value (X2). The dis-
common-anode displays DIS1 and DIS2 play now shows, say, 15 counts (N2).
X1 x N2
for displaying the frequency of astable X2 = ................................. Eq. (2) From Eq. (2), the value of the un-
N1
multivibrator IC2 used to evaluate the known zener (X2) can be calculated as
unknown value of the zener diode. Suppose you have a zener diode 3.5V. 
Let’s say the counter counts up to rated at 6.8V (X1). Insert it at the posi-

202 Electronics Projects Vol. 26


Simple mosfet-based CFL
 N.S. Harisankar, vu3nsh The recommended frequency for Frequencies for Different
a ferrite transformer-based CFL is 18

T
R-C Combinations
his CFL circuit uses only two to 35 kHz. To vary the frequency, you
R1 C1 F
semiconductor devices and can change the value of resistor R1
20kΩ 1 kpF 25 kHz
few passive components, which in the R-C oscillator (see the table).
15kΩ 1 kpF 35 kHz

oscillations.
The n-channel enhancement-mode
MOSFET IRFZ44 (T1) is readily avail-
able in the market. Transformer X1 is
built around an EE-type, 25×13×7mm
ferrite core. Use good insulation be-
tween the primary and secondary
windings. After winding the transform-
er coils, put some insulating sheet or
paper at the edges (tips) of the EE-cores
as shown in Fig. 2. This insulation gap
between the two cores helps to achieve
maximum brightness with minimum
current drain.
Fig. 1: Circuit of MOSFET-based CFL High-tension (HT) coupling capacitor
C4 limits the current
keeps the cost low and simplfies the to the lamp. Capaci-
circuit. Low power consumption is its tor C2 between drain
another advantage. and ground clips any
The circuit works off a 12V, 7AH ripple voltage to give
battery and is built around CMOS a linear waveform.
hex-inverter IC CD4069 (IC1). Using The performance
CMOS IC, the power consumption of of this CFL depends
the main stage (oscillator) is limited to on the type of the
a few microwatts. The IC is configured CFL, EE core, oscil-
as an R-C oscillator with four of its lation frequency,
gates connected in parallel to enhance ferrite core gap, etc.
its output drive capability. Its high Never use a Schmitt
output can drive TTL loads. inverter (40106) for
Gates N1 and N2 form an Fig. 2: EE ferrite dimensions this circuit. Use a
R-C oscillator and the remaining four base for the IC and
gates (N3 through N6) are connected For R1 (15 kilo-ohms) and C1 (0.001 handle the MOSFET carefully. Before
in parallel to provide a high output µF) used in this circuit, the selected soldering the MOSFET, make sure
current to the MOSFET switch. The frequency is 35 kHz. that the R-C oscillator is oscillating
R-C oscillator has only two external Resistor R1 connected between properly. Connect the MOSFET only
components and its output frequency pins 1 and 2 of gate N1 provides a if the oscillations are proper. In case
(f) can be roughly calculated using the negative DC feedback and biases the you don’t use an IC base, make sure
following equation: inverter to a linear region where it the soldering iron is earthed properly
0.5 works as an amplifier. Capacitor C1 while soldering the IC.
f = R1×C1 connected between pins 1 and 4 of IC1 Lab Note. A Philips 9W CFL was
provides a positive feedback to enable used for testing the circuit. 

Electronics Projects Vol. 26 203


Heat-Sensitive Switch
 M.K. Chandra Mouleeswaran formed by potmeter VR1. load is turned on as soon as the ambient
and Miss Kalai Priya Since the wiper of potmeter VR1 temperature rises above the set level.
is connected to the inverting input of Capacitor C3 at this pin helps iron out

A
t the heart of this heat-sensi- IC2, the voltage presented to this pin is any ripple that passes through the posi-
tive switch is IC LM35 (IC1), linearly variable. This voltage is used tive supply rail to avoid errors in the
which is a linear temperature as the reference level for the compara- circuit operation.
sensor and linear temperature-to-volt- tor against the output supplied by IC1. By adjusting potmeter VR1 and
age converter circuit. So if the non-inverting input of thereby varying the reference volt-

The converter provides accurately IC2 receives a voltage lower than age level at the inverting input pin
linear and directly proportional output the set level, its output goes low (ap- of IC1, the temperature threshold
signal in millivolts over the tempera- proximately 650 mV). This low level is at which energisation of the relay is
ture range of 0°C to 155°C. It develops applied to the input of the load-relay required can be set. As this setting is
an output voltage of 10 mV per degree driver comprising npn transistors T1 linear, the knob of potmeter VR1 can
centigrade change in the ambient tem- and T2. The low level presented at the be provided with a linear dial caliber-
perature. Therefore the output voltage base of transistor T1 keeps it non-con- ated in degrees centigrade. Therefore
varies from 0 mV at 0°C to 1V at 100°C ductive. Since T2 receives the forward any temperature level can be selected
and any voltage measurement circuit bias voltage via the emitter of T1, it is and constantly monitored for external
connected across the output pins can also kept non-conductive. Hence, relay actions like turning on a room heater
read the temperature directly. RL1 is in de-energised state, keeping in winter or a room cooler in summer.
The input and ground pins of this mains supply to the load ‘off’ as long The circuit can also be used to activate
heat-to-voltage converter IC are con- as the temperature at the sensor is low. emergency fire extinguishers, if posi-
nected across the regulated power Conversely, if the non-inverting tioned at the probable fire accident site.
supply rails and decoupled by R1 and input receives a voltage higher than The circuit can be modified to oper-
C1. Its temperature-tracking output the set level, its output goes high (ap- ate any electrical appliance. In that case,
is applied to the non-inverting input proximately 2200 mV) and the load is relay RL1 must be a heavy-duty type
(pin 3) of the comparator built around turned ‘on.’ This happens when IC1 is with appropriately rated contacts to
IC2. The inverting input (pin 2) of IC2 at a higher temperature and its output match the power demands of the load
is connected across the positive sup- voltage is also higher than the set level to be operated. 
ply rails via a voltage divider network at the inverting input of IC2. So the

204 Electronics Projects Vol. 26


Transistor Tester
 V. Gopalakrishnan
Transistor Assessment from Glowing of LEDs

Y
ou can test both npn and pnp Switch S3 npn transistor LED1 LED2
transistors using this circuit. Kept pressed Good Flickers Flickers
The circuit indicates whether Pressed momentarily to Collector-emitter Glows Doesn’t glow
the transistor is good, open or shorted trigger IC2 short
through two light-emitting diodes Pressed momentarily to Collector-emitter Remains ‘off’ for two Glows for the set time
(LEDs). trigger IC2 open seconds, then glows (say, two seconds)
and then turns off
The circuit comprises two NE555
Switch S3 pnp transistor LED1 LED2
timer ICs: one (IC1) is wired in the Kept pressed Good Flickers Flickers
astable mode and the other (IC2) in the Pressed momentarily to Collector-emitter Remains ‘off’ for two Glows for the set time
monostable mode. The time period of trigger IC2 short seconds, then glows (say, two seconds),
the astable multivibrator is around 0.5 then turns off
second. Its output goes to the base of Pressed momentarily to Collector-emitter Glows Remains ‘off’
trigger IC2 open
the npn/pnp transistor under test via

time period of
the monostable mul-
tivibrator is around
two seconds.
To test a transis-
tor, insert it at the
appropriate place
shown within dot-
ted lines and slide
switch S2 towards
the transistor type
(npn or pnp) being
tested. From glowing
of LED1 and LED2
on triggering of the
DPDT switch S2. pnp transistor can be tested. The collec- monostable via switch S3, you can
Switch S2 selects the npn/pnp tor of npn or pnp transistor goes to reset infer whether the transistor is good,
transistor you are going to test, which pin 4 of the monostable (IC2). Switch S3 short or open-circuited, as shown in
means that at a time only an npn or a is used to trigger the monostable. The the table. 

Electronics Projects Vol. 26 205


Water-Tank Overflow Indicator
 C.H. Vithalani and filtered by capacitors C1 and C2 and therefore LED1 doesn’t glow and the
to provide +9V at ‘+B’ point and –9V loudspeaker remains silent.

W
ater is a vital but scarce at ‘–B’ point. Connect ‘+B,’ ‘–B’ and When water in the tank touches the
natural resource. To prevent ‘GND’ terminals of the power supply metal plate sensors, it extends ground
water wastage, this water- unit to the respective terminals of the to pin 2 of IC1. Now pin 3 of IC1 is at
tank overflow indicator comes in handy. water-tank overflow indicator circuit. a higher potential than pin 2. The high
It gives audio as well visual alarm when- The circuit is built around op-amp output of the op-amp generates 3.1V
ever the water tank overflows. LM741 (IC1), which is used as a com- across zener diode ZD1. Melody gen-
Fig. 1 shows the water-tank over- parator. The pin configuration of melody erator IC2 produces a melody, which

Fig. 1: Circuit of the water-tank overflow audio-visual indicator Fig. 2: Power supply circuit

flow indicator circuit and Fig. 2 shows generator IC1(UM66) is shown in Fig. 3. drives the transistor to
the power supply circuit. When water in the tank is below the light up LED1 and sound
In the power supply unit, mains metal plate sensors, inverting pin 2 of IC1 an alarm from the loud-
AC is stepped down by transformer X1 is at a higher potential than non-invert- speaker. Rectifier diode
to deliver secondary output of 9V-0-9V ing pin 3. Output pin 6 of the op-amp is D5 is used to prevent
AC at 300 mA. The transformer output low and there is no music from program- negative polarity to the
Fig. 3: Pin
is rectified by a full-wave bridge recti- mable melody generator IC UM66 (IC2). configuration
cathode of the zener
fier comprising diodes D1 through D4 Transistor BC547 (T1) remains cut-off of UM66 diode. 

206 Electronics Projects Vol. 26


Simple Smoke Detector
 Pradeep G. phototransistor in a plastic housing. tor are obstructed. As a result, the pho-
The slot (gap) between the infrared totransistor stops conducting and the

T
his simple smoke detector is diode and the transistor (see Fig. 1) Darlington-pair transistors conduct to
highly sensitive but inexpensive. allows interruption of the signal with activate the buzzer and light up LED1.
It uses a Darlington-pair ampli- smoke, switching the module output When the smoke in the gap is
fier employing two npn transistors and from ‘on’ to ‘off’ state. cleared, light from the IR LED falls on
an infrared photo-interrupter module as The circuit of the smoke detector is the phototransistor and it starts conduct-
the sensor. The circuit gives audio-visual shown in Fig. 2. ing. As a result, Darlington-pair transis-
alarm whenever thick smoke is present in When the smoke enters the gap, tors stop conducting and the buzzer and
the environment. the IR rays falling on the photo-transis- LED1 turn off.
The photo-interrupter module For maximum
(H21A1) consists of a gallium-arsenide sensitivity, ad-
infrared LED coupled to a silicon just presets VR1
and VR2. VR1 is
used to control the
sensitivity of the
photo-interrupter
module, while
VR2 is used to
control the sensi-
tivity of Darling-
Fig. 1: Top and bottom views of the photo- ton-pair transis-
Fig. 2: Schematic of the smoke detector
interrupter module (H21A1) tors. 

Electronics Projects Vol. 26 207


Sensitive Vibration Detector
 T.K. Hareendran result, Q0 output (pin
3) of IC1 goes high and

T
his vibration detector is realised the entire circuit is in
using readily available, low-cost idle state. LED1 indi-
components. One of its many cates the power status.
applications is in a rolling shutter In the event of
guard for offices and shops. The de- vibrations, IC2 is
tector will sense vibration caused by clocked by the pulses
activities like drilling and switch on the from the piezoceram-
connected load (bulb, piezobuzzer, etc) ic element connected
to alert you. to its clock pin 14. Q1
Fig. 2: Pin
The circuit works off a 6V battery configuration of through Q9 outputs
or 6V regulated power supply and SCR1 BT169 and of IC2 are fed to re- Fig. 3: Arrangement for rolling shutter guard for
back view of the shops, offices and banks
uses a piezoceramic element as the piezo element lay-driver switching
vibration detector. The same is easily transistor T1 through its gate. This, in turn, energises relay
available from electronics/telephone diodes D1 through D9 connected in RL1. The relay contacts can be used
component vendors or you can take it OR mode. to switch any alarm device to indicate
out from an active buzzer. Immediately after clocking, any of vibration detection. The circuit can
Initially, when the power is switched the outputs Q1 through Q9 would go be reset by momentarily pressing
on, decade counter IC1 is reset by power- high and npn transistor T1 would con- switch S1.
on-reset components C2 and R1. As a duct. As a result, SCR1 is fired through Zener diodes ZD1 and ZD2 at the
clock input of IC1
are used for protec-
tion against high
voltage input. In
the case of repeated
false triggering of
IC1, add a 100nF
capacitor in parallel
to the piezoceramic
element.
The pin con-
figuration of SCR
BT169 and the
back view of the
piezo element are
shown in Fig. 2. Fig.
3 shows suggest-
ed location of the
vibration detector
for rolling shutters
of banks, shops,
Fig. 1: Circuit of the sensitive vibration detector etc. 

208 Electronics Projects Vol. 26


Soft Switch
 Pradeep G. toggles between high and low states. switches in parallel and fix one switch
These digital variations are amplified at the top of the staircase and the other

T
his circuit lets you switch on/off by an npn transistor to drive a triac. at the bottom. When any of the micro-
an AC lamp or any other load by The triac directly activates the AC switches is pressed, the lamp will turn
pressing a normally open micro- lamp. on and off alternately.
switch. The current passing through The 12V DC required for the circuit Since this circuit is not isolated
the switch is very small. is derived from AC mains. BT136 is a from AC mains, don’t touch it after
For each press of the microswitch, general-purpose triac. connecting the power supply.
the output of the IC, which is a The circuit can be used as a stair- Note. Use of a Texas or ST make IC
CMOS J-K master-slave flip-flop, case light switch. Connect two micro- 4027 is recommended. 

Electronics Projects Vol. 26 209


Automatic-Off Timer
for CD Players
 Suresh Kumar K.B. and resistor R8 connected to pins 9 and power fails momentarily, capacitor
10 of IC1, respectively, as follows: C2 (1000µF) will provide the neces-

A
re you in the habit of falling t=2.3RC sary power backup for IC1. That is,
asleep while listening to where ‘R’ is the value of resistor R8 during the period, pin 3 of IC1 is low.
music? If yes, you’ll love this and ‘C’ is the value of capacitor C3. When output pin 3 of IC1 goes high,
circuit. It will automatically start When transistor T2 is cut-off, its col- the relay is energised through transis-
functioning when you switch off your lector voltage is high. So pin 12 of IC1 is tors T3 and T4 and, at the same time,
bedroom light and shall turn your CD high and IC1 is in reset condition. counting is disabled by the feedback
player ‘off’ after a predetermined time. When light is switched off, the from pins 3 through 11 (clock input)
In the presence of ambient light, or resistance of LDR1 increases, driving of IC1 via signal diode D7. That is, due
when you switch on light of the room transistor T1 into cut-off state. The col- to the feedback, output pin 3 remains
in the morning, the CD player will lector voltage of transistor T1 goes high high unless another high-to-low pulse
again start playing. Unlike the usual to light up LED2 (indicating that the is received at its reset pin 12.
timers, you don’t have to set this timer timer circuit is enabled) and transistor After the relay is energised, there
before sleeping. T2 starts conducting. As the collector will be no AC power in the socket. The
The circuit derives its power di- voltage of transistor T2 goes low to glowing of LED5 indicates that your

rectly from the bridge rectifiers. When LDR1 Timer LED2 Reset pin 12 Count LED3 CD player has been switched off.
‘on’/‘off’ switch S1 is closed, LED1 Light Off High Off The desired ‘off’ time period for
glows to indicate that the circuit is Dark On Low Blink the timer circuit can be set by choosing
powered ‘on.’ proper values of resistor R8 and capaci-
In the presence of light, the resis- around 0.2V, ground potential becomes tor C3. If R8 is 680 kilo-ohms and C3 is
tance of the light-dependent resistor available at reset pin 12 of IC1. The low 0.22 µF, the ‘off’ time period is around
(LDR1) is low, so transistor T1 conducts state at pin 12 enables the oscillator and 45 minutes.
to drive transistor T2 into cut-off state it starts counting. LED3 at pin 7 of IC1 The glowing of LED4 gives the
and the timer circuit remains inactive. starts blinking. Its blinking frequency warning that your CD player is going
The collector of transistor T2 is depends on the R-C components con- to be switched off shortly. In case you
connected to reset pin 12 of IC CD4060 nected between its pins 9 and 10. want to extend the timer setting for
(IC1) via signal diode D5. IC CD4060 is The status of LED2 and LED3 in the another round, just press reset switch
a 14-stage ripple counter with a built-in circuit with light falling and not falling S2 momentarily. LED4 stops glowing
oscillator. The time period of oscilla- on LDR1 is given below: and counting starts again from the
tions (t) is determined by capacitor C3 During counting, in case the initial stage. 

210 Electronics Projects Vol. 26


Automatic Washbasin
Tap Controller
Akshay Mathur and wavelength of 900 to 1100 nm lies in The time period for which the timer
Abhay Mathur the peak receptivity range of TSOP1738 goes high can be calculated as follows:
receiver module. Ton=1.1 R6C5

M
ake your washbasin tap The receiver circuit comprises the =1.1×100×103×100×10–6
work automatically when sensor module, monostable timer and =11 seconds
you put your hands just be- relay driver circuit (see Fig. 2). The sen- Use shielded wires or leads for
low the water tap outlet. This infrared- sor module TSOP1738 is sensitive to IR installing the IR LED and the IR sensor
based system detects any interruption radiation modulated at 38 kHz. Its nor- at opposite sides of the washbasin. In-
of the IR rays by your hands or utensil mally high output goes momentarily stall the IR LED and IR sensor around
and water automatically starts flowing low when any IR radiation is detected half a metre apart such that the IR rays
out of the tap. or interrupted. transmitted by the IR LED directly fall

Fig. 1: Transmitter circuit

The circuit is built around 555


timers and comprises transmitter and
receiver sections. Both the transmitter
and the receiver work off 5V DC. The Fig. 2: Receiver circuit
IR rays continuously emitted by the
transmitter fall on the receiver. As soon When IR rays falling on the receiv-
as an obstacle comes in between the re- er are interrupted, the sensor output
ceiver and the transmitter, interrupting goes low momentarily to trigger timer
the IR rays, the output of the IR sensor IC2. The output of the timer goes high
goes low momentarily to trigger the for eleven seconds and the relay drives
timer circuit in the receiver and water the solenoid. During this time period,
comes out for eleven seconds through energisation of the solenoid lifts up the
the tap. valve fitted in the pipe to let water flow
The transmitter is built around out of the tap. Solenoid valves used
Fig. 3: Mains 230V AC 2/2-way semi-pilot,
timer IC 555, which is used as an specifically for this purpose are shown diaphragm type, solenoid valves
astable multivibrator to generate in Fig. 3.
around 38 kHz frequency (see Fig. 1). The relay driver circuit consists of on the IR sensor. Now switch on the
The timer output is fed to transistor resistor R8, transistor BC548 (T2) and power supply to the circuit.
T1, which drives the IR LED (LED1). free-wheeling diode D1. Diode D1 When you put your hands between
Note that IR LED1 must be properly protects the relay from damage by high the IR LED and IR sensor, the relay ener-
oriented towards the IR sensor module voltages generated by the back emf gises to make the solenoid open up the
of the receiver circuit. Its transmission when the relay is de-energised. valve and water flows out of the tap. 

Electronics Projects Vol. 26 211


Rear-View Monitor
 T.K. Hareendran and camera (see Figs 2 and 3) through the master power-‘on’/‘off’ switch
the phono plug and phono socket. (S1) of the car TV to enable the TV

C
MOS colour micro-cameras are When the car is moving forward, even if its indicator LED2 is switched
readily available from com- transistor T1 doesn’t conduct and relay off by the relay contacts. Power sup-
ponent vendors at reasonable RL1 remains de-energised. As a re- ply for the CMOS camera is provided
prices. Using such a camera (model sult, external video from the car’s AV by the car battery through IC1. LED3
FQY888C), you can make a rear-view system connects to the car’s TV video raises the output voltage of IC1 to
monitor for your car as described here. input, allowing you to enjoy your fa- near 11.2V and indicates that the cam-
The circuit works off the DC sup- vourite programmes. LED2 glows to era is working.

Fig. 4: Front layout of control


panel

For safety, you can


feed the camera supply
through the third contacts
of relay RL1 (not shown
in the circuit) or use an
‘on’/‘off’ switch between
pin 1 of IC1 and the cath-
ode of diode D1.
The circuit can be
Fig. 1: Rear-view monitor easily assembled on a
medium-size veroboard.
indicate that the car TV is You can make it compact by using
showing the external AV a PCB-mountable relay. Fixing the
programme. camera in the car and focusing it need
When reversing the some patience.
car, the reverse-lamp sup- The FQY 888C CMOS camera
ply is turned on as per the used here was procured from a
Fig. 2: Car TV Fig. 3: Camera mechanical arrangement component vendor called Eastern En-
of the gear lever (not terprises, Chennai. Since it operates
ply directly available from the car’s shown in the figure) and positive sup- off 6 to 12V DC (120 MW), around
battery. Resistor R1 limits the inrush ply from the lamp terminal is fed to 11.2V is applied to it. The camera has
current and diode D1 protects against the base of relay-driver transistor T1 three leaded outputs: a yellow RC
wrong polarity. Capacitors C1 and C3 via diode D2 and resistor R3. As a re- socket (marked ‘D’) for video output,
act as the noise suppressor and reser- sult, relay RL1 energises and the video a white RC socket (marked ‘E’) for
voir filter, respectively. signal output from the camera con- audio output and a red RC socket
Before connecting the circuit to the nects to the car TV via normally-open (marked ‘C’) for DC supply. If you
car battery and switching on the car contact N/O2 of relay RL1 and the TV are using a different model, carefully
TV, connect points A through E of Fig. starts showing rear view of the car. study the product catalogue before
1 to the respective points of the car TV N/O1 contacts of relay RL1 bypass final wiring. 

212 Electronics Projects Vol. 26


Over-Speed Indicator
 V. David the rotating part of the appliance with When the voltage developed at pin 3 of
a suitable fixing arrangement. When IC1 is higher than the reference voltage

T
his circuit is designed for indi- the motor rotates, it develops a voltage. at pin 2, output pin 6 of comparator
cating over-speed and direction This over-speed indicator is built IC1 goes high to sound piezobuzzer
of rotation of the motor used in around operational amplifier CA3140 PZ1 and light up LED3.
mini hand tools, water pump motors, (IC1). Set the reference voltage (de- The rotation indicator circuit
toys and other appliances. pending on the desired speed) by is built around AND gate 74LS08
A 12V DC motor (M1) is coupled to adjusting preset VR1 at pin 2 of IC1. (IC2). Pin 2 of gate N1 goes high
when the motor rotates
in forward direction,
while pin 1 of gate N1 is
pulled high via resistor
R2. When both pins 1
and 2 are high, output
pin 3 of gate N1 goes
high to light up LED1.
Similarly, pin 5 of gate
N2 goes high when the
motor rotates in reverse
direction. When both
pins 4 and 5 are high,
output pin 6 of gate N2
goes high to light up
LED2. 

Electronics Projects Vol. 26 213


Versatile Water-Level Controller
 A. Shafeek Ahamed motor through the inverter and driver energises. The motor pump now starts
circuits. The transistor switch circuitry running to fill the tank with water.

T
his simple, economical and ver- monitors the flow of water and raises Freewheeling diode D5 prevents chat-
satile circuit switches on the an alarm if the pump runs dry. tering of the relay due to the back emf
motor pump when water in the Power supply is obtained through produced by the relay coil.
overhead tank falls below the lowest step-down transformer X1, diodes D1 When the water level rises to
level and turns it ‘off’ when the tank through D4, capacitor C1, series current- bridge the electrodes, because of the
is full. Moreover, if the pump is run- limiting resistor R1, regulator IC1, and conductivity of water, pin 6 (E1) is
ning dry due to low voltage, it sounds noise-filtering capacitors C2 and C3. pulled down to ground (E2). This does
an alarm to alert you to switch off the The set-up for the water-level not alter the output state of IC2, which

Fig. 1: Circuit of water-level controller

sensing electrodes maintains its previous state, and the


is shown in Fig. motor keeps running.
2. Electrodes are When water rises to the overflow
suspended into the level L2 and touches electrode E3,
tank such that they point U (pin 2 of IC2) is connected to
Fig. 3: Dry pump
sensor set-up don’t touch each already sunken ground electrode E2,
other. Points B, L thereby triggering it. IC2 resets to give
and U of the water- a high output at pin 3. This is inverted
level controller circuit are connected by transistor T1 to cut off transistor T2
to the respective points of the sensor and de-energise relay RL1. The mo-
electrodes assembly. tor pump now stops to prevent water
Fig. 2: Water-level electrodes set-up for over- When water in the tank is below overflow.
head tank the lowest level L1, all the electrodes As water is consumed, the water
are electrically separated and hence level comes down leaving electrode
controller circuit (and hence the motor points L and U (pins 6 and 2 of IC2, E3 isolated from ground electrode E2.
pump) to avoid coil burn and power respectively) are pulled up to the sup- Now point U (pin 2 of IC2) is pulled
wastage. ply voltage through resistors R2 and up to the supply voltage. This does not
The water-level controller circuit R3, respectively. Therefore, to reset IC2 change the output state of IC2 and the
(see Fig. 1) is built around IC 555 (IC2) the output of IC2 at pin 3 goes low. As motor remains switched off.
to monitor the water level in the over- a result, transistor T1 stops conducting When water level again falls be-
head tank and ‘on’/‘off’ status of the to drive transistor T2 and relay RL1 low electrode E2, IC2 resets to cut off

214 Electronics Projects Vol. 26


transistor T1. Transistor T2 conducts B of the dry-running sensor (see Fig. 3) the tank is below the lowest limit). The
to energise relay RL1 and the motor is are bridged by water being delivered energised relay indicates ‘on’ status of
powered to run. This is how the pro- by the pipe, transistor T3 conducts to the motor.
cess continues. LED1 glows whenever drive transistor T4 into cut-off state 3. Immerse points A and B in
the relay energises, indicating that the and therefore the DC buzzer remains water. The buzzer stops sounding to
motor pump is running. silent. indicate that water is flowing out of
As the values of resistors R2 and R3 When the pump runs dry, points the pipe to short points A and B. This
are very high, corrosion of electrodes is A and B are electrically apart causing confirms no dry run.
very little. Capacitors C2 through C7 fil- transistor T3 to cut off because of pull- 4. Immerse points B and L in water,
ter out unwanted noise. Switches S2 and up resistor R6. Transistor T4 conducts as would be the case when the water
S3 can be used to manually switch on due to the emitter drop of transistor level rises. Momentarily touch point U
and off the motor pump, respectively, T3, which activates the DC buzzer to to water. LED1 goes off and the relay
when water is in between the upper sound an alarm indicating dry running de-energises to turn the pump ‘off.’
and lower levels. Switch S1 is used to of the pump. This would be the case when water
disable the unit during dry pump run The alarm circuit is enabled only touches the overflow limit.
or while flushing the tank. when transistor T2 conducts, i.e., only 5. Remove points A and B from
For the sensor electrodes, use a when the motor pump runs. Diode D6 water assuming that the flowing water
moulded-type AC chord (used for tape isolates the relay driver circuitry to that was shorting points A and B has
recorders) with its pair of wires sleeved prevent transistor T3 from extending stopped. Now, although water is not
at the end and connected together to ground to the relay through transis- flowing, the buzzer does not sound as
form the electrode. Other electrodes tor T3 and water being delivered. As the relay is already de-energised.
can be made similarly. These three AC soon as the pump is switched on, the 6. Remove points U and B from
chords are suspended inside the tank alarm sounds until water reaches the water, assuming that water has fallen
from a longitudinally cut PVC pipe delivery port. below the lowest limit because of con-
(used for electrical wiring). House the controller circuit (includ- sumption. Two seconds later, LED1
The arrangement for the dry pump ing the power supply) in a cabinet. Use glows and the relay energises.
sensor is shown in Fig. 3. A moulded- a four-core shielded cable for wiring Precautions. 1. Make sure that wa-
type AC chord with its pair of wires the tank electrodes to the controller ter being delivered from the water pipe
sleeved at the end can be attached unit fixed near the motor switch. doesn’t touch any of the suspended
firmly to the delivery pipe such that wa- To test the circuit, proceed as fol- water-level sensors.
ter falls onto the plug leads. The sleeved lows: 2. Mount the alarm sensor firmly
ends are connected to points A and B of 1. Switch on power to the circuit. onto the water pipe such that elec-
the water-level controller circuit. 2. LED1 glows and relay RL1 trodes A and B are shorted by water
The circuit for dry-run alarm energises to produce an alarm from flowing out of the pipe.
comprises transistors T3 and T4, piezobuzzer PZ1, indicating that none 3. Use a properly shielded cable
piezobuzzer PZ1, resistors R6 and R7, of the circuit points A, B, U and L is to carry signals from the tank to the
and capacitor C7. When points A and shorted through water (i.e., water in water-level controller unit. 

Electronics Projects Vol. 26 215


TOP 20 Projects (Out of 92)
• Standalone Scrolling Display Using • Digital Dice
AT90S8515 AVR • Programmable Timer Based on
• Remote Controlled Digital Audio Processor AT90S4433 AVR
• Using AVR Microcontroller for Projects • Auto Turn-off Battery Charger
• Simple Digital Security System • Wireless Stepper Motor Controller
• Remote Control for Home Appliances • Audio Mixer with Multiple Controls
• Long Range Burglar Alarm Using Laser Torch • Automatic Bathroom Light with Backup Lamp
• Medium Power FM Transmitter • Automatic Washbasin Tap Controller
• Simple Smoke Detector • 16-way Clap-operated Switch
• Speed Checker for Highways • Inexpensive Car Protection Unit
• Multiple Applications of High-power LEDs • Smart Cell Phone Holder

About Electronics For You Magazine


Started in 1969, the magazine (print edition) is read by over half-a-million electronics professionals
and enthusiasts in India. Another half-a-million professionals, from all across the globe, access its
Web portal, www.electronicsforu.com, every month. And now the e-zine version of the magazine,
which is available on tablets, mobile devices, smartphones, desktops and laptops, is gaining
popularity. The magazine is adored for its focus on technology trends, coupled with a lot of
Do-It-Yourself content.

EFY Enterprises Pvt Ltd


D-87/1, Okhla Industrial Area, Phase 1, New Delhi 110020 ISBN: 978-81-88152-26-1
Ph: 011-26810601/2/3; E-mail: info@efyindia.com Published by EFY
Website: www.efyindia.com

You might also like