You are on page 1of 48

INTRODUCTION

A frequency counter is an electronic instrument, or component of one, that is used


for measuring frequency. Frequency is defined as the number of events of a
particular sort occurring in a set period of time. Frequency counters usually
measure the number of oscillations or pulses per second in a repetitive electronics
signal.
Most frequency counters work by using a counter which accumulates the number
of events occurring within a specific period of time. After a preset period (1
second, for example), the value in the counter is transferred to a display and the
counter is reset to zero. If the event being measured repeats itself with sufficient
stability and the frequency is considerably lower than that of the clock oscillator
being used, the resolution of the measurement can be greatly improved by
measuring the time required for an entire number of cycles, rather than counting
the number of entire cycles observed for a pre-set duration (often referred to as the
reciprocal technique). The internal oscillator which provides the time signals is
called the timebase, and must be calibrated very accurately.

1
COMPONENTS USED

AT89C2051
8-bit Microcontroller with 2K Bytes Flash

Features

• Compatible with MCS-51™ Products


• 2K Bytes of Reprogrammable Flash Memory
– Endurance: 1,000 Write/Erase Cycles
• 2.7V to 6V Operating Range
• Fully Static Operation: 0 Hz to 24 MHz
• Two-level Program Memory Lock
• 128 x 8-bit Internal RAM
• 15 Programmable I/O Lines
• Two 16-bit Timer/Counters
• Six Interrupt Sources
• Programmable Serial UART Channel
• Direct LED Drive Outputs
• On-chip Analog Comparator
• Low-power Idle and Power-down Modes

Description

The AT89C2051 is a low-voltage, high-performance CMOS 8-bit


microcomputer with 2K bytes of Flash programmable and erasable read only
memory (PEROM). The device is manufactured using Atmel’s high-density
nonvolatile memory technology and is compatible with the industry-standard
MCS-51 instruction set. By combining a versatile 8-bit CPU with Flash on a
monolithic chip, the Atmel AT89C2051 is a powerful microcomputer which
provides a highly-flexible and cost-effective solution to many embedded control
applications.

The AT89C2051 provides the following standard features: 2K bytes of


Flash, 128 bytes of RAM, 15 I/O lines, two 16-bit timer/counters, a five vector

2
two-level interrupt architecture, a full duplex serial port, a precision analog
comparator, on-chip oscillator and clock circuitry. In addition, the AT89C2051 is
designed with static logic for operation down to zero frequency and supports two
software selectable power saving modes. The Idle Mode stops the CPU while
allowing the RAM, timer/counters, serial port and interrupt system to continue
functioning. The power-down mode saves the RAM contents but freezes the
oscillator disabling all other chip functions until the next hardware reset.

3
4
Pin Description

VCC
Supply voltage.

GND
Ground.

Port 1

Port 1 is an 8-bit bi-irectional I/O port. Port pins P1.2 to P1.7 provide
internal pullups. P1.0 and P1.1 require external pullups. P1.0 and P1.1 also serve as
the positive input(AIN0) and the negative input (AIN1), respectively, of the on-
chip precision analog comparator. The Port 1 output buffers can sink 20 mA and
can drive LED displays directly.

When 1s are written to Port 1 pins, they can be used as inputs. When pins
P1.2 to P1.7 are used as inputs and are externally pulled low, they will source
current (IIL) because of the internal pullups. Port 1 also receives code data during
Flash programming and verification.

Port 3
Port 3 pins P3.0 to P3.5, P3.7 are seven bi-irectional I/O pins with internal
pullups. P3.6 is hard-wired as an input to the output of the on-chip comparator and
is not accessible as a general purpose I/O pin. The Port 3 output buffers can sink 20
mA. When 1s are written to Port 3 pins they are pulled high by the internal pullups
and can be used as inputs. As inputs, Port 3 pins that are externally being
pulled low will source current (IIL) because of the pullups.

Port 3 also serves the functions of various special features of the


AT89C2051 as listed below:

5
Port 3 also receives some control signals for Flash programming and verification.

RST

Reset input. All I/O pins are reset to 1s as soon as RST goes high. Holding
the RST pin high for two machine cycles while the oscillator is running resets the
device.

Each machine cycle takes 12 oscillator or clock cycles.

XTAL1

Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.

XTAL2

Output from the inverting oscillator amplifier.

Oscillator Characteristics

XTAL1 and XTAL2 are the input and output, respectively, of an inverting
amplifier which can be configured for use as an on-chip oscillator, as shown in
Figure 1. Either a quartz crystal or ceramic resonator may be used. To drive the
device from an external clock source, XTAL2 should be left unconnected while
XTAL1 is driven as shown in Figure 2. There are no requirements on the duty
cycle of the external clock signal, since the input to the internal clocking circuitry
is through a divide-by-two flip-flop, but minimum and maximum voltage high and
low time specifications must be observed.

6
Special Function Registers

A map of the on-chip memory area called the Special Function Register
(SFR) space is shown in the table below. Note that not all of the addresses are
occupied, and unoccupied addresses may not be implemented on the chip. Read
accesses to these addresses will in general return random data, and write accesses
will have an indeterminate effect.

User software should not write 1s to these unlisted locations, since they may
be used in future products to invoke new features. In that case, the reset or inactive
values of the new bits will always be 0.

7
8
Programming Algorithm: To program the AT89C2051,the following sequence
is recommended.

1. Power-up sequence: Apply power between VCC and GND pins Set RST and
XTAL1 to GND

2. Set pin RST to “H” Set pin P3.2 to “H”

3. Apply the appropriate combination of “H” or “L” logic levels to pins P3.3, P3.4,
P3.5, P3.7 to select one of the programming operations shown in the PEROM
Programming Modes table. To Program and Verify the Array:

4. Apply data for Code byte at location 000H to P1.0 to P1.7.

5. Raise RST to 12V to enable programming.

6. Pulse P3.2 once to program a byte in the PEROM array or the lock bits. The
byte-write cycle is self-timed and typically takes 1.2 ms.

7. To verify the programmed data, lower RST from 12V to logic “H” level and set
pins P3.3 to P3.7 to the appropiate levels. Output data can be read at the port P1
pins.

8. To program a byte at the next address location, pulse XTAL1 pin once to
advance the internal address counter. Apply new data to the port P1 pins.

9. Repeat steps 5 through 8, changing data and advancing the address counter for
the entire 2K bytes array or until the end of the object file is reached.

10.Power-off sequence: set XTAL1 to “L” set RST to “L”


Turn VCC power off

9
LIQUID CRYSTAL DISPLAYS (LCD)

Certain organic large size molecule types of liquids possess properties,


which cause them to interfere with light passage in them. One type, called the
twisted nematic type, is becoming more useful in today’s LCDs. In this, the liquid
crystals have thread-like shapes: the units join head to tail for million molecules to
form lengthy chains. Moreover each plane is twisted a few degrees from the next.
Some of the recent chemicals of this variety are made of pyrimidines, phenyl
cyclohexanes, bicyclohexane and 4-(4’ methoxy benzylidine) -n-butylaniline. They
exhibit a crystalline structure even in liquid form at ordinary temperatures.

The property of the liquid is anisotropic in the two perpendicular directions.


The cell thickness is so designed that there is a 900 turn of the molecules between
the top and the bottom faces. The twisted nematic has the property that twists light,
which passes through it. Polaroid filters are fitted above and below the cell so that
light is polarized as it enters, and is twisted through 900, exiting through a filter
kept at 900 to the one at top. The light is then reflected via a mirror at the back and
returns via the same pathway.

It has just a 12 m thin layer of liquid between two or more sheets of glass
cum polarizer filters. One glass plate has the 7 segment electrodes etched on it and
a conductive coating of tin oxide or Tin cum Indium oxide. The other plate has the
common electrode. The conductive coat is treated further for good surface contact
to liquid. The cell when assembled appears as clear glass: the segments are not
visible.

When a voltage is applied between the plates, the molecules move with the
dipoles aligned in the cell axis. Thus those regions under the segments, which have
the electric field, have a contrasty appearance when viewed in light, while other
unexcite segments are invisible.

The voltage needed is preferable 2-20 V A.C. The cathode (or front plane)
voltage input to the LCD goes through an ‘analog switch’ that is on at any time so
that a.c. voltage is applied to the appropriate segment. The anode (back plane)
receives the a.c. supply. The display driving switches are from a set of MOSFET

10
switches, which also form part of Integrated circuit. For eg. C 1200 clock LSI I.C.
chip from Computer Syst. Inc, USA, is a digital clock chip with the LCD display
driver. Turn on time for the LCD displays vary form 0.2-100 millisecs, depending
on voltage applied. Turn of time is 30-100ms. So these displays are not suitable for
very fast changing numbers. The power consumption is 1to 10 micro watt/cm2. The
voltage threshold for watch type LCD display is 1 to 2V. The operating a.c.
frequency is 50-100 KHz.
In another method dc pulses of identical amplitude are used: One pulse to
the back electrode and another to the display segment via and exclusive OR gate.
In the OFF state, the pulses are in-phase; in the ON-state, they are out of phase.
The frequency is 30-32 Hz. The power consumption for a LCD watch is roughly
45 W, which is 1/1000th of that for LED displays.

A sample photo of the LCD module is shown in Fig. 1. These modules are
available in 14- and 16-pin configurations. The 16-pin module has a back light
option. Popular brands are Lampex and Hantronix. Note the pin numbers before
soldering to the circuit.

Fig. 1 : A typical LCD module

In this project, the LCD module used is Lampex LM16200 with 16 alphanumeric
characters and two lines with back light option. Pin details of this module are given
in Table I. A functional diagram of the module is shown in fig. 2.

11
TABLE I
Pin details of LM16200
Pin No. Description Pin No. Description
1 Gnd 5 R/W
2 Vcc 6 E
3 Vo 7 to 14 DB0 to DB7
4 RS 15 & 16 LED BL A & K

12
Fig. 2 : Functional diagram of the LCD module

However, you may use any branded or unbranded 2-line, 16-character LCD
module for this project. The 10k potentiometer, which controls the contrast of the
LCD module, works best when its wiper contact is nearer to ground potential.

13
THE ADAPTING 3-TERMINAL VOLTAGE
REGULATORS FOR CONSTANT HIGH
VOLTAGE POWER SUPPLIES

One can get a constant high-voltage power supply using inexpensive 3-terminal
voltage regulators through some simple techniques described below. Depending
upon the current requirement, a reasonable load regulation can be achieved. Line
regulation in all cases is equal to that of the voltage regulator used.

Though high voltage can be obtained with suitable voltage boost circuitry
using ICs like LM 723, some advantages of the circuits presented below are:
simplicity, low cost, and practically reasonable regulation characteristics. For
currents of the order of 1A or less, only one zener and some resistors and
capacitors are needed. For higher currents, one pass transistor such as ECP055 is
needed.
Before developing the final circuits, let us first understand the 3-terminal type constant voltage regulators.
Let us see the schematic in Fig. where 78XX is a 3-terminal voltage regulator.
Schematic for obtaining low-voltage regulated output using 3-terminal voltage regulators.

Rectified
and filtered

unregulated voltage is applied at VIN and a constant voltage appears between pins
2 and 2 of the voltage regulator. *The distribution of two currents in the circuit
(IBIAS and ILOAD) is as shown.

14
It is highly recommended to use the two capacitors as shown. Electrically
regulator will be at a distance from the rectifier supply. Thus, a tantalum grade
capacitor of 5mf and rated voltage is good.
Electrolytic capacitor is not suitable for it is poor in response to load transients,
which have high frequency components. At the output side a 0.22mf disc ceramic
capacitor is useful to eliminate spurious oscillations, which the regulator might
break into because of its internal high gain circuitry.

These voltage regulators have a typical bias current of 5 mA, which is


reasonably constant. By inserting a small resistor Rx between pin 2 and ground, the
output voltage in many cases. By this method voltage increment of 5 to 10 per cent
is practically feasible. However, if a high-value resistance is used to obtain a
higher output voltage, a slight variation in bias current will result in wide variation
of the output voltage.

Now let us see that what can be done to get a higher but constant output
voltage. If to the circuit of Fig. resistor RY and zener Vz are added as shown in
Fig., the output voltage is now given by

VOUT=VR+VZ + IBIAS RX

A constant current flows through RY** because VOUT is constant, and


small variations in IBIAS do not change practically the operating point of Vz. This
situation is like constant current biasing of zener, which results in a very accurate
setting of the zener voltage.
** As long a sVIN>VOUT+2 volts, VOZ is constant from the reasoning of
Fig, and thus current through RY is constant.

VOZ=VR + IBIAS Rx

Here the pin 2 of the regulator is raised above ground by Vz + IBIAS Rx.
Thus, any combination of zener with a proper selection of RY can be used.

For example, Let VR=+15 V for 7815

IBIAS=5mA
VZ=39V (standard from ECIL)

15
For a standard 400mW zener of ECIL make, IZ MAX=10 mA. Thus, if we
let pass 5mA through RY to make a 55-volt supply.

55 - 39
RY = ---------------=3.2k»3.3k
5 x 10-3

55 - 39 - 15 1
RX = ---------------------= ---------- = 200 ohm
IBIAS 5 x 10-3

Schematic for constant high-voltage power supplies

It should be noted here that the maximum input voltage allowed for 78XX
regulators is 35V between pins 1 and 2. We see that the actual voltage betweens
pin 1 and 2 of the regulator in this circuit is
VIN - VZ - IBIAS RX
It is therefore necessary that VIN be so chosen that voltage between pins 1
and 2 of the IC does not exceed the maximum rating. Also, a high input-output
differential voltage VIN-VOUT means more power dissipation in the series-pass
element, the regulator. Thus, with proper selection of the input transformer voltage
and capacitor, this should be minimized.

For example, if 7805 is used, VR equals + 5V and VZ is 40V, so VOUT=45


volts. For 7805, the maximum input voltage is 35 V and the minimum 7V.
Therefore,
VIN MAX = 45 + 35 - 5 = 75 VOLTS

16
VIN MIN = 45 + 7 - 5 = 47 VOLTS
Thus, from no-load to full-load condition, the unregulated input voltage-
including peak ripple-should be within these limits. This gives a margin of 75-47,
i.e. 28 volt. Hence, the designer can work out the maximum transformer voltage
from the no-load input voltage chosen on the upper side.
The capacitor's value can be determined from the full load unregulated
voltage chosen. Roughly, per 100mA current, 100mf capacitor gives 1-volt peak-
to-peak ripple. Hence, capacitor's value can be determined for the desired current.
This circuit will have an excellent load and line regulation. For shot-circuit
protection, it is recommended to use a fast-blow fuse of suitable value. Although
the regulator has inherent short-circuit protection, the maximum current differs
from device to device. Adequate heat sink should be used with the regulator.

Schematic for constant high-voltage power supplies providing currents in excess of one ampere

Now if currents in excess of 1A are needed, the circuit shown in fig. is useful. This
circuit is similar to that in Fig. except that a pass transistor ECP055 is added
17
besides a 0.5-ohm or more resistor. This transistor bypasses the excessive current.
By selecting proper Rz the ratio of two currents passing through the regulator and
transistor can be altered.
This circuit will show load and live regulation within 1% and will function
properly for VIN-VOUT as low as 4 volt. For short-circuit protection, a fast blow
fuse is recommended as this circuit does not have inherent short-circuit protection.
Adequate heat sink is to be used for the pass transistors. For negative voltages,
use 79XX series regulators and ECN055 as the pass transistor. Some advantages of
the circuits described above are: the lowest cost among comparable performance
circuits, ability to work at low input-output differential, and flexibility in design for
various applications.

So audio enthusiasts, if you are troubled by hum emanating from your power
amplifier, try this inexpensive alternative for power supply.

555 INTEGRATED CIRCUIT


(TIMER OPERATION)

The 555 integrated circuit is an extremely versatile timer that can be used in
many different applications. This IC is a monolithic timing circuit that is a highly

18
stable controller capable of producing accurate time delays or oscillations.
Additional terminals are producing are provided for triggering or resetting if
desires. In the time delay mode of resistance and a capacitor. For a stable operation
as an oscillator, the free running frequency and the duty cycle are both accurately
controlled with two external resistors and one capacitor. The circuit may be
triggered and reset on falling waveforms, and the output structure can source or
sink up to 200ma or drive TTL Circuits.

This integrated circuit contains nearly 25 transistor, a diode or two, and


more than 10 resistors. Obviously, if you built this IC from separate components, it
would be many, many times larger than on a monolithic chip.

The 555 timer offers timing from microseconds through hours and operates
in both astable and monostable modes. It has an adjustable duty cycle, and the
output can drive TTL devices. Its output can operate in normally on and normally
off modes and the IC offers a frequency stability of 0.005% per degrees centigrade.

Applications for the 555 chip include precision timing, pulse generation,
pulse width modulation, pulse position modulation, sequential timing, and missing
pulse detection.

19
555-INTEGRATED CIRCUIT

IC 555-ASTABLE OPERATIONS: -

If the circuit is connected as shown in figure (pins 2 and 6 connected). It will


trigger itself and free run as a multivibrator. The external capacitor charges through
20
Ra and Rb and discharges through Rb only. Thus, the duty cycle may be precisely
set by the ratio of these two resistors. In this mode of operation the capacitor
charges and discharges between 1/3 Vcc and 2/3 Vcc. As in the triggered mode,
the charge and discharges times, and therefore, the frequency are independent of
the supply voltage. Figure shows the actual waveforms generated in this mode of
operation.

The charge time (output high) is given by:


t1 = 0.685 (Ra + Rb) C

And the discharge time (output low) by:


t2 = 0.685 (Rb) C

Thus, the total period is given by:


T = t1 + t2 = 0.685 (Ra + 2Rb) C

The frequency of oscillation is then:

f= 1.46
(Ra + 2Rb) C

21
IC 555-MONOSTABLE OPERATIONS: -

In the monostable mode of operation, the timer functions as a one shot.


Referring to figure the external capacitor is initially held discharged by a transistor
inside the timer. Upon applications of a negative trigger pulse to pin 2, the flip-flop
is set, which releases the short circuit across the external capacitor and drives the
output high. The voltage across the capacitor increases exponentially with the time
constant.

t = Ra C

When the voltage across the capacitor equals 2/3 Vcc. The comparator resets
the flip-flop, which, in turn, discharges the capacitor rapidly and drives the output
to its low state. Figure shows the actual waveforms generated in this mode of
operation.

The circuit triggers on a negative going input signal when the level reaches
1/3 Vcc. Once triggered, the circuit will remain in this state until the set time is

22
elapsed, even if it is triggered again during this interval. The time that the output is
in the high state is given by: t= 1.1 Ra C

Applying a negative pulse to the reset terminal (pin 4) during the timing
cycle discharges the external capacitor and causes the cycle to start over again. The
timing cycle will now commence on the positive edge of the reset pulse. During
the time the reset pulse is applied, the output is driven to its low state.

TRANSISTOR

The name is transistor derived from ‘transfer resistors’ indicating a solid


state Semiconductor device. In addition to conductor and insulators, there is a third
class of material that exhibits proportion of both. Under some conditions, it acts as
an insulator, and under other conditions it’s a conductor. This phenomenon is
called Semi-conducting and allows a variable control over electron flow. So, the
transistor is semi conductor device used in electronics for amplitude. Transistor has

23
three terminals, one is the collector, one is the base and other is the emitter, (each
lead must be connected in the circuit correctly and only then the transistor will
function). Electrons are emitted via one terminal and collected on another terminal,
while the third terminal acts as a control element. Each transistor has a number
marked on its body. Every number has its own specifications.

There are mainly two types of transistor (i) NPN & (ii) PNP

NPN Transistors:

When a positive voltage is applied to the base, the transistor begins to


conduct by allowing current to flow through the collector to emitter circuit. The
relatively small current flowing through the base circuit causes a much greater
current to pass through the emitter / collector circuit. The phenomenon is called
current gain and it is measure in beta.

PNP Transistor:

It also does exactly same thing as above except that it has a negative voltage
on its collector and a positive voltage on its emitter.

Transistor is a combination of semi-conductor elements allowing a


controlled current flow. Germanium and Silicon is the two semi-conductor
elements used for making it. There are two types of transistors such as POINT
CONTACT and JUNCTION TRANSISTORS. Point contact construction is
defective so is now out of use. Junction triode transistors are in many respects
analogous to triode electron tube.

A junction transistor can function as an amplifier or oscillator as can a triode


tube, but has the additional advantage of long life, small size, ruggedness and
absence of cathode heating power.

24
Junction transistors are of two types which can be obtained while
manufacturing.

The two types are: -

1) PNP TYPE: This is formed by joining a layer of P type of


germanium to an N-P Junction

P N P
2) NPN
TYPE: This is formed by joining a
layer of germanium to a P- N
Junction.

N P N
Both types
are shown in figure, with their symbols for
representation. The centre section is called the
base, one of the outside sections-the emitter and
the other outside section-the collector. The direction of the arrowhead gives the
direction of the conventional current with the forward bias on the emitter. The
conventional flow is opposite in direction to the electron flow.

OPERATION OF PNP TRANSISTOR:-


A PNP transistor is made by sand witching two PN germanium or silicon
diodes, placed back to back. The centre of N-type portion is extremely thin in
comparison to P region. The P region of the left is connected to the positive
terminal and N-region to the negative terminal i.e. PN is biased in the forward
direction while P region of right is biased negatively i.e. in the reverse direction as
shown in Fig. The P region in the forward biased circuit is called the emitter and P
region on the right, biased negatively is called collector. The centre is called base.

25
The majority carriers (holes) of P region (known as emitter) move to N
region as they are repelled by the positive terminal of battery while the electrons of
N region are attracted by the positive terminal. The holes overcome the barrier and
cross the emitter junction into N region. As the width of base region is extremely
thin, two to five percent of holes recombine with the free electrons of N-region
which result in a small base current while the remaining holes (95% to 98%) reach the
collector junction. The collector is biased negatively and the negative collector
voltage aids in sweeping the hole into collector region.

As the P region at the right is biased negatively, a very small current should
flow but the following facts are observed:-

1) A substantial current flows through it when the emitter junction is biased in


a forward direction.

2) The current flowing across the collector is slightly less than that of the
emitter, and

3) The collector current is a function of emitter current i.e. with the decrease
or increase in the emitter current a corresponding change in the collector
current is observed.

26
The facts can be explained as follows:-

1. As already discussed that 2 to 5% of the holes are lost in recombination with


the electron in base region, which result in a small base current and hence
the collector current is slightly less than the emitter current.

2. The collector current increases as the holes reaching the collector junction
are attracted by negative potential applied to the collector.

3. When the emitter current increases, most holes are injected into the base
region, which is attracted by the negative potential of the collector and hence
results in increasing the collector current. In this way emitter is analogous to
the control of plate current by small grid voltage in a vacuum triode.

Hence we can say that when the emitter is forward biased and collector is
negatively biased, a substantial current flows in both the circuits. Since a small
emitter voltage of about 0.1 to 0.5 volts permits the flow of an appreciable emitter
current the input power is very small. The collector voltage can be as high as 45
volts.

CD4049UBC • CD4050BC
Hex Inverting Buffer •
Hex Non-Inverting Buffer

General Description

The CD4049UBC and CD4050BC hex buffers are monolithic


complementary MOS (CMOS) integrated circuits constructed with N- and P-
channel enhancement mode transistors. These devices feature logic level
conversion using only one supply voltage (VDD). The input signal high level
(VIH) can exceed the VDD supply voltage when these devices are used for logic
level conversions. These device are intended for use as hex buffers, CMOS to
DTL/ TTL converters, or as CMOS current drivers, and at VDD 5.0V, they can
drive directly two DTL/TTL loads over the full operating temperature range.

27
Features

_ Wide supply voltage range: 3.0V to 15V


_ Direct drive to 2 TTL loads at 5.0V over full temperature
range
_ High source and sink current capability
_ Special input protection permits input voltages greater
than VDD

Applications

• CMOS hex inverter/buffer


• CMOS to DTL/TTL hex converter
• CMOS current “sink” or “source” driver

28
CAPACITORS

It is an electronic component whose function is to accumulate charges and


then release it.

To understand the concept of capacitance,


consider a pair of metal plates which all are
placed near to each other without
touching. If a battery is connected to
these plates the positive pole to one and the negative pole to the other, electrons
from the battery will be attracted from the plate connected to the positive terminal
of the battery. If the battery is then disconnected, one plate will be left with an
excess of electrons, the other with a shortage, and a potential or voltage difference
will exists between them. These plates will be acting as capacitors. Capacitors are
of two types: - (1) fixed type like ceramic, polyester, electrolytic capacitors-these
names refer to the material they are made of aluminium foil. (2) Variable type like
gang condenser in radio or trimmer. In fixed type capacitors, it has two leads and
its value is written over its body and variable type has three leads. Unit of
measurement of a capacitor is farad
denoted by the symbol F. It is a very
big unit of capacitance. Small unit
capacitor are pico-farad denoted by pf
(Ipf=1/1000,000,000,000 f) Above all,
in case of electrolytic capacitors, it's
two terminal are marked as (-) and (+)
so check it while using capacitors in
the circuit in right direction. Mistake
can destroy the capacitor or entire circuit in operational.

RESISTANCE

29
Resistance is the opposition of a material to the current. It is measured in
Ohms ( ). All conductors represent a certain amount of resistance, since no
conductor is 100% efficient. To control the electron flow (current) in a predictable
manner, we use resistors. Electronic circuits use calibrated lumped resistance to
control the flow of current. Broadly speaking, resistor can be divided into two
groups viz. fixed & adjustable (variable) resistors. In fixed resistors, the value is
fixed & cannot be varied. In variable resistors, the resistance value can be varied
by an adjuster knob. It can be divided into (a) Carbon composition (b) Wire wound
(c) Special type. The most common type of resistors used in our projects is carbon
type. The resistance value is normally indicated by colour bands. Each resistance
has four colours, one of the band on either side will be gold or silver, this is called
fourth band and indicates the tolerance, others three band will give the value of
resistance (see table). For example if a resistor has the following marking on it say
red, violet, gold. Comparing these coloured rings with the colour code, its value is
27000 ohms or 27 kilo ohms and its tolerance is ±5%. Resistor comes in various
sizes (Power rating). The bigger, the size, the more power rating of 1/4 watts. The
four colour rings on its body tells us the value of resistor value as given below.
COLOURS CODE

Black--------------------------------------------0
Brown-------------------------------------------1
Red----------------------------------------------2
Orange------------------------------------------3
Yellow------------------------------------------4
Green--------------------------------------------5
Blue----------------------------------------------6
Violet--------------------------------------------7
Grey---------------------------------------------8
White--------------------------------------------9

30
The first rings give the first digit. The second ring gives the second digit.
The third ring indicates the number of zeroes to be placed after the digits. The
fourth ring gives tolerance (gold ±5%, silver ± 10%, No colour ± 20%).

In variable resistors, we have the dial type of resistance boxes. There is a


knob with a metal pointer. This presses over brass pieces placed along a circle with
some space b/w each of them.

Resistance coils of different values are connected b/w the gaps. When the
knob is rotated, the pointer also moves over the brass pieces. If a gap is skipped
over, its resistance is included in the circuit. If two gaps are skipped over, the
resistances of both together are included in the circuit and so on.

A dial type of resistance box contains many dials depending upon the range,
which it has to cover. If a resistance box has to read upto 10,000, it will have
three dials each having ten gaps i.e. ten resistance coils each of resistance 10.
The third dial will have ten resistances each of 100.

The dial type of resistance boxes is better because the contact resistance in
this case is small & constant.

31
CIRCUIT DESCRIPTION

Fig. 3 shows the circuit of the frequency counter including the power supply. The
microcontroller used is AT89C2051, which features 2 kB of Flash, 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, an on-chip oscillator and clock circuitry.

Port-1 is used to drive the LCD in 4-bit mode with 10-kilo-ohm pull-up resistors.
The 24MHz crystal used gives a processing speed of 2 million instructions per
second (MIPS).

Timer-0 is used as an external counter to count the input pulses. Transistor T1


amplifies the input signal, while non-inverting gate NI (1/6 CD4050) serves as a
buffer for coupling the amplified pulses to input pin 8 (P2.4) of timer-0.

A software gate of one-second duration is used to count the number of pulses


corresponding to the frequency of the input signal source. The count value is read
and displayed on the 2-line, 16-character LCD module. The flow-chart of the
frequency-counting routine is shown in Fig. 4.

A conventional power supply circuit comprising a step-down transformer followed


by a bridge rectifier, smoothing capacitor and 5V regulator is used to power the
circuit. Capacitor C2 (0.1µ F) filters ripples in the output of the regulator and
LED1 shows the supply status. To test the circuit, connect any pulse generator
output to the probe and check the frequency displayed on the LCD screen.

32
The LCD module is used in the 4-bit data interface mode, wherein only data pins
DB4 through DB7 are used for data transfer. The configuration used is shown in
Table II.

TABLE II
LCD Connections Used for
4-Bit Data Mode
LCD Display Port Pin
DB7 P1.7 14
DB6 P1.6 13
DB5 P1.5 12
DB4 P1.4 11
E P1.3 6
RS P1.2 4
RW Ground 5
Vss Ground 1
Vdd +5 volt 2
Vo 0-5 volt 3

33
PRINTED CIRCUIT BOARD

Printed circuit boards are used for housing components to make a circuit, for
comactness, simplicity of servicing and ease of interconnection. Single sided,
double sided and double sided with plated-through-hold (PYH) types of p.c boards
are common today.

Boards are of two types of material (1) phenolic paper based material (2)
Glass epoxy material. Both materials are available as laminate sheets with copper
cladding.

Printed circuit boards have a copper cladding on one or both sides. In both
boards, pasting thin copper foil on the board during curing does this. Boards are
prepared in sizes of 1 to 5 metre wide and upto 2 metres long. The thickness of the
boards is 1.42 to 1.8mm. The copper on the boards is about 0.2 thick and weighs
and ounce per square foot.

An actual-size, single-side PCB for the LCD frequency meter (Fig. 3) is shown in
Fig. 5 and its component layout in Fig. 6.

34
Fig. 5: Actual-size, single-side PCB layout for frequency meter

Fig. 6 : Component layout for the PCB

COMPONENTS REQUIRED
35
SEMICONDUCTORS
IC1.......................................................7805 5V regulator
IC2.......................................................AT89C2051 microcontroller
IC3.......................................................CD4050 hex buffer
T1.........................................................BC547 npn transistor
D1-D4..................................................IN4007 rectifier diode
D5........................................................IN4148 switching diode
LED1...................................................5mm LED

RESISTORS
R1.........................................................1-kilo-ohm
R2, R4, R6-R9.....................................10-kilo-ohm
R3.........................................................4.7-kilo-ohm
R5.........................................................150-ohm

CAPACITORS
C1.........................................................1000 F, 25V electrolytic
C2, C3, C7...........................................0.1F ceramic disk
C4, C5..................................................22pF ceramic disk
C6.........................................................10F, 16V electrolytic

MISCELLANEOUS

36
X1........................................................230V AC primary to 9V,
250mA secondary transformer
S1.........................................................ON/OFF switch
S2.........................................................Push-to-on switch
XTAL......................................................24 MHz
...........................................................16x2 LCD

CIRCUIT DIAGRAM
37
THE SOFTWARE
38
The software is compiled using the demo version of BASCOM-8051, which can be
downloaded from website ‘www.mcselec.com’.
The BASCOM compiler provides special instructions for use and display of data
on the LCD module.

START

DEFINE VARIABLES
INITIALISE PORTS

CONFIGURE LCD
CONNECTIONS

CONFIGURE TIMER0
AS A COUNTER

SET TIMER0 INT


SUBROUTINE

ENABLE
INTERRUPTS

START COUNTER 0 TO COUNT


EXTERNAL PULSES ON PORT 3.4

ONE SECOND ACCURATE


DELAY LOOP

GET COUNTER VALUE


AFTER ONE SECOND

DISPLAY THE COUNT ON


LCD AS FREQUENCY
39

RESET VARIABLES
Fig. 4 : Flow chart of the frequency counting program

MICROCONTROLLER CODE

40
'Connect the timer0 input P3.4 to a frequency generator
' freq meter
' 24 mhz xtal ok upto 300khz

' define crystal speed and include file


$regfile = "89C2051.dat"
$crystal = 24000000

' define variables used


Dim A As Byte
Dim C As Long , D As Long
Dim Count As Word
Dim Onceasec As Bit
Dim T0ic As Long
Dim Green As Byte
Dim Delayword As Word

' Initialize variables


Onceasec = 0
Count = 0
T0ic = 0
D = 0
Green = 0

41
' initialize ports
P1 = 0
P3 = 255

' configure lcd display


Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = P1.4 , Db5 = P1.5 , Db6 =
P1.6 , Db7 = P1.7 , E = P1.3 , Rs = P1.2
Cls
'clear the LCD display
Lcd "Frequency Meter"

' define timer0


Config Timer0 = Counter , Gate = Internal , Mode = 1
'Timer0 = counter : timer0 operates as a counter
'Gate = Internal : no external gate control
' exte/internal makes no difference
'Mode = 1 : 16-bit counter
' set t0 internal interrupt

On Timer0 Timer_0_overflow_int
' interrupt will be generated on every 65536 count
Priority Set Timer0
Enable Interrupts
Enable Timer0

42
Counter0 = 0
'clear counter
Start Counter0
'enable the counter to count

Do
'set up a 1 sec accurate DO NOTHING loop
Enable Interrupts
'wait 1 as per BASCOM-51 is not accurate

For Delayword = 1 To 45440


Next Delayword

Disable Interrupts
C = Counter0
'get counter value
D = T0ic * 65536

Lowerline
C = C + D
T0ic = 0
Lcd " "
Lowerline
' show the frequency

43
Lcd "f=" ; C ; " Hz"
Waitms 255
Waitms 255

C = 0

Counter0 = 0
Start Counter0
're-start it because it was stopped by accessing the
COUNTER
Loop

' timer0 int subroutine


Timer_0_overflow_int:
Rem timer0 overflow ( 65535 ) interrupt comes here
' increment the variable
Incr T0ic
Return
End

' end of program


' uses 1114 bytes of program memory

RESULTS

44
45
CONCLUSION

46
BIBLIOGRAPHY

a) www.mcselec.com

b) www.wikipedia.com

c) www.esnips.com

d) Electronics For You

47
48

You might also like