Seminar Topics & Project Ideas On Computer Science Electronics Electrical Mechanical Engineering Civil MBA Medicine Nursing Science Physics Mathematics Chemistry ppt pdf doc presentation downloads and Abstract

Full Version: Pulse Counter using AT 89C4051
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pulse Counter using AT 89C4051
[attachment=22149]
Pulse counters are widely used in
our day-to-day life. Almost all
museums and theatres have a
visitor counter installed at entry/exit
to measure the visitor traffic. In industries,
counting is done for production
control. Market tests too are performed
by counting the sold goods.
A pulse counter could be roughly
divided into three parts: a pulse
source, an electronic device that
counts, stores and prepares outputs,
and a display to show the accumulated
count.
This pulse counter is based on
Atmel AT89C4051 microcontroller.
TTL-logic-compatible pulses generated
by the source are fed to the counter
for counting. The AT89C4051 is a
low-voltage, high-performance, 8-bit
microcontroller with 4 kB of Flash
programmable and erasable read-only
memory, 128 bytes of RAM, 15 input/
output (I/O) lines, two 16-bit timers/
counters, a five-vector, two-level interrupt
architecture, a full-duplex serial
port, a precision analogue comparator,
on-chip oscillator and clock circuitry.
System clock plays a significant
role in operation of the microcontroller.
An 11.0592MHz quartz crystal provides
basic clock to the microcontroller
(IC1) at its pins 4 and 5. Power-on reset
is provided by electrolytic capacitor C3
and resistor R1. Switch S1 is used for
manual reset.
Port pin P3.5 receives the input
pulse and the count is displayed on
the LCD as well as hyper terminal of
the PC. Pulse reception is indicated by
LED2, which is connected to port pin
Fig. 1: Circuit of microcontroller-based pulse counter
Parts List
Semiconductors:
IC1 - AT89C4051 microcontroller
IC2 - MAX232 RS-232 driver
IC3 - 7805, 5V regulator
D1-D4 - 1N4007 rectifier diode
LED1, LED2 - 5mm LED
LCD - 16-character × 2-line
Resistors (all ¼-watt, ±5% carbon):
R1 - 10-kilo-ohm
R2, R3 - 330-ohm
R4 - 33-ohm
Capacitors:
C1 - 1000μF, 25V electrolytic
C2 - 0.1μF ceramic disk
C3 - 10μF, 16V electrolytic
C4, C5 - 33pF ceramic disk
C6-C10 - 1μF, 16V electrolytic
Miscellaneous:
X1 - 230V AC primary to 9V,
500mA secondary
transformer
S1 - Push-to-on switch
XTAL - 11.0592MHz crystal
- 9-pin D-type female COM
port connector
- Heat-sink
Construction
w w w. e f y m a g . c o m electronics for you • October 2010 • 109
LED1 acts as the power indicator and
R2 limits the current through LED1.
Construction and testing
An actual-size, single-side PCB for the
microcontroller-based pulse counter
is shown in Fig. 2 and its component
layout in Fig. 3. Assemble the circuit
on a PCB as it minimises time and
assembly errors. Carefully assemble
the components and double-check
for any overlooked error. Connect the
assembled circuit to the COM port
of the computer. The accumulated
pulse count transferred is sent to the
PC through the COM port using the
HyperTerminal program. To open the
HyperTerminal program, go to Start →
Programs → Accessories → Communications
→ HyperTerminal. You will see
a window as shown in Fig. 4.
Type the desired name and click
‘ok.’ Select a COM port (refer Fig. 5)
while ignoring the other options and
click ‘ok.’
P3.7 of the microcontroller. Port pins
P1.0 through P1.7 of the microcontroller
are connected to data pins D0 through
D7 of the LCD, respectively. Port pins
P3.4, P3.3 and P3.2 are connected to
register-select RS, read-write R/W and
enable E of the LCD, respectively.
The data is sent to the LCD in
ASCII format for display. Only the
commands are sent in hex form to the
LCD. Register-select RS signal is used
to distinguish between data (RS=1)
and command (RS=0). Using preset
VR1, you can control the contrast of
the LCD. Resistor R4 limits the current
through backlight of the LCD.
Port pin P3.1 of the microcontroller
is used to interface with the
PC’s hyper terminal through RS-232
interface MAX232 IC (IC2). The microcontroller
provides a transmit channel
for serial data transfer. Transmit data
pin (TXD) is specified
at port pin P3.1.
The microcontroller
is connected to TIN
(pin 11) of MAX232.
TOUT (pin 14) of IC2
is connected to pin 2
of the COM port connector.
The signals
provided on these
pins are TTL-level
and must be boosted
and inverted through
a MAX232 converter
to comply with RS-
232 standard.
The MAX232 has
two internal charge
pumps that convert
+5V into ±10V (unloaded)
for RS-232
driver operation. The
first converter uses
capacitor C8 to double
the +5V input to +10V
on capacitor C10 at
pin 2. The second converter
uses capacitor
C7 to invert +10V to
-10V on capacitor C6
at pin 6.
All the serial communication
is controlled through
special-function register SCON. This
register contains mode-selection bits,
ninth data bit for transmit and receive
(TB8 and RB8), and serial-port interrupt
bits (TI and RI). Serial communication
requires standard baud rate. Timer-1
is configured in auto-reload mode to
generate baud rate. The baud rate is
determined as:
Baud rate =
(32×12×(256 - TH1))
(2SMOD × Oscillator frequency)
The 230V, 50Hz AC mains is
stepped down by transformer X1 to
deliver a secondary output of 9V, 500
mA. The transformer output is rectified
by a full-wave rectifier comprising
diodes D1 through D4, filtered by
capacitor C1 and regulated by IC 7805
(IC3). Capacitor C2 bypasses the ripples
present in the regulated supply.
Fig. 4: Hyperterminal window for name and icon
Fig. 2: An actual-size, single-side PCB for microcontroller-based
pulse counter
Fig. 3: Component layout for the PCB
Fig. 5: Hyperterminal window for COM port
selection
cONSTRUCTION
1 1 0 • October 2010 • electronics for you www. e f y m a g . com
to give the correct
speed (9600
bits per second).
SCON gives the
necessary UART
signal and your
data is sent serially.
When port
pin P3.5 (T1)
goes low, the
internal counter
increases by
one. This count
is displayed on the LCD as well as
hyper terminal of the PC.
EFY note. The source code of
this project has been included in this
month’s EFY-CD and is also available
on www.efymag.com website.
and serial interrupts. Then configure
the timer by mode and reload value
counter.C
Fig. 6: Hyperterminal window for selection of baud
rate, data bits, parity, stop bits and flow control
Fig. 7: Count on
hyperterminal screen
Now select the baud rate as ‘9600,’
data bits as ‘8,’ parity as ‘none,’ stop
bits as ‘1,’ flow control as ‘Xon/Xoff’
and click ‘ok’ (refer Fig. 6).
The microcontroller counts the
received pulses and sends the pulse
count to the hyper terminal and LCD.
You will see a message on the screen
as shown in Fig. 8. Simultaneously, the
pulse count appears on the LCD.
Software
The software for this project is given
at the end of this article. It is written in
‘C’ language and compiled using Keil
μVision4 compiler. Burn the generated
hex code into the microcontroller using
a suitable programmer.
In the software, first enable timer