You are on page 1of 37

MAJOR PROJECT

ON
AUTOMATED SPEED LIMITING SYSTEM ON
PUBLIC PLACES USING RFID

CONTENTS

1. Introduction
2. Block diagram
3. Circuit diagram
4. Working of circuit
5. PCB layout
6. Parts and price list
7. RFID
8. Microcontroller
9. LCD
10. Power Supply
11. Servomotor
12. Applications
13. Advantage
14. Disadvantage
15. Conclusion
16. References
17. Datasheets

ABSTRACT

Control system design and analysis technologies are widely suppress and very useful to be
applied in real-time development. Some can be solved by hardware technology and by the advance
used of software, control system are analyzed easily and detail. DC Motors can be used in various
applications and can be used as various sizes and rates as per our applications. In this project we have
control the actual speed of dc motor as per ours requirement. This can be achieved through PIC
microcontroller. The microcontroller computes the actual speed of the motor by sensing the terminal
voltage and displayed on LCD. In this project firstly we are giving the supply to PIC microcontroller.
Then controller generates the pulse generally 5 volt DC. The generated pulse is nothing but PWM
signal. Which giving to driver circuit. The function of this driver circuit to generate 12v DC pulse. This is
necessary to switch/triggering on MOSFET.Thus speed of DC motor is control through duty/PWM cycle.
This PWM pulse is giving to MOSFET for triggering purpose. The modeling and simulation of this project
is done through MP-LAB software. It then compares the actual speed of the motor with the reference
speed and generates a suitable control signal which is fed into the triggering unit using

INTRODUCTION

Control system design and analysis technologies are widely suppress and very useful to be
applied in real-time development. Some can be solved by hardware technology and by the advance
used of software, control system are analyzed easily and detail.DC Motors can be used in various
applications and can be used in various sizes and rates as per our applications. The DC-Motor is used in
domestics and industrial purpose. Whenever we think about any programmable devices then the
embedded technology comes into fore front. The embedded is now-a- days very much popular and
most of the product are developed with Microcontroller based embedded technology. The advantages
of using the microcontroller is the reduction of the cost and also the use of extra hardware such as the
use of timer, RAM and ROM can be avoided. This technology is very fast so controlling of multiple
parameters is possible; also the parameters are field programmable by the user. In this project we are
controlling speed of DC motor. As we increase the speed of DC motor as a result an increase in the
productivity of material. The application of this is used in domestics purpose examples are hair dryer,
mixer, zero machine,elevator and industrial purpose examples are traction and elevator. In this project
we have control the actual speed of dc motor as per ourrequirement. This can be achieved through PIC
microcontroller. The microcontroller computes the actual speed of the motor by sensing the terminal
voltage and displayed on LCD. In this project firstly we are giving the supply to PIC16F8774
microcontroller. Then controller generates the pulse generally 5VDC.The generated pulse is nothing
but PWM signal,which is given to the driver circuit. The function of this driver circuit is to generate 12V
DC pulse. This is necessary to switch/trigger the MOSFET.Thus the speed of DC motor is controlled
through duty/PWM cycle. This PWM pulse is given to MOSFET for triggering purpose. The modeling
and simulation of this project is done through MATLAB/PROTES software.It then compares the actual
speed of the motor with the reference speed and generates a suitable control signal which is fed into

the triggering unit using MATLAB.Here we use PID Controller for error minimization purpose. This unit
drives a Power MOSFET amplifier, which in turn supplies a PWM voltage to the dc motor.DC Motors
can be used in various applications.

Objective of project

The main core of this project is to design a speed control system of DC Motor by using microcontroller.
This system will be able to control the DC motor speed at desired speed regardless the changes of load.
1.3 Scope of Project In order to achieve the objective of the project, there are several scope had been
outlined. The scope of this project includes using MPLAB IDE to program microcontroller PIC 16F877A,
build hardware for the system.

DC Motor Speed Control Using PWM Technique


1. With the help of PWM it is possible to control the average power delivered to a load and by
thus we can easily regulate the speed of the DC Motor.
2. When the width of pulse is high, the motor will rotate with full speed.
3. Obviously with low pulse width, speed of motor gets reduced.
4. In both cases full current reaches the motor and only the average power changes, thus we
get better torque in each case.
5. Basically in this method we are chopping the DC voltage at regular interval.

BLOCK DIAGRAM:

POWER SUPPLY
CIRCUIT

5V

POTENTIOMETER

KEY PAD

5V

5V

MICROCONTROLLER
PIC18F4520

H-BRIDGE

PMDC GEARED
MOTOR

2*16 LCD
JHD162A

SCHEMATIC DIAGRAM

COMPONENTS LAYOUT

PARTS AND PRICE LIST


S. No.

PARTS DESCRIPTION

QUANTITY

COST

TOTAL COST

1.

LM7805 IC

10.00

10.00

2.

1K CARBON FILM RESISTANCE

0.25

1.50

3.

10K CARBON FILM RESISTANCE

0.25

1.50

4.

220 CARBON FILM RESISTANCE

0.25

0.25

5.

330 CARBON FILM RESISTANCE

0.25

0.25

6.

HS-311 SERVOMOTOR

300.00

600.00

7.

1N 4007 GENERAL PURPOSE Si DIODE

1.00

4.00

8.

5mm DIFFUSED LED

2.00

6.00

9.

0.1F/63V NONELECTROLYTIC
CAPACITOR

0.50

1.50

10.

22pF /50V NONELECTROLYTIC


CAPACITOR

0.50

1.00

11.

MICROSWITCH (TO RESET)

5.00

15.00

12.

1000F / 25V ELECTROLYTIC CAPACITOR

7.00

7.00

13.

10F / 63V ELECTROLYTIC CAPACITOR

2.50

2.50

14.

11.0592J3L CRYSTAL

10.00

10.00

15.

JHD162A 2X16 LCD

150.00

150.00

16.

5 K POTENTIOMETER

5.00

5.00

17.

MOLEX CONNECTOR (5 PIN)

9.00

9.00

18.

MOLEX CONNECTOR (4 PIN)

7.00

14.00

19.

MOLEX CONNECTOR (3 PIN)

6.00

18.00

20.

MOLEX CONNECTOR (2 PIN)

5.00

10.00

21.

40 PIN IC BASE

5.00

5.00

22.

16 PIN IC BASE

5.00

5.00

23.

14 PIN IC BASE

5.00

5.00

24.

PIC16F877A MICROCONTROLLER

150.00

150.00

25.

TRANSFORMER 220V pri 12V sec/1amp


step down shell type

200.00

200.00

26.

PCB BOARD

50.00

50.00

27.

TOTAL

2081.5

WORKING

Pulse an electromagnetic wave or modulation thereof of brief duration.


Width Modulation - to adjust to or keep in proper measure or proportion the width of the pulse with
respect to the frequency of the wave
This is a method to control the output voltage with the of constant frequency switching and by
adjusting on duration of switching and in other words by changing duty cycle of switching.

Constant switching time period = on time + off time


Duty Cycle = on time / on time + off time %
Duty cycle can not be greater than 1 or 100%. Because on time will always be less than total timer
period of switching frequency .The relationship of input-output voltage and duty cycle is
output voltage = duty cycle * input voltage
Hence output voltage and duty cycle is directly related with each other but their output also depend on
switching frequency of switch. What is a switch here.I will discuss it later.

Different Pulse width modulation having different duty cycles


In above picture there are four PWM having different duty cycle. So we need to change duty cycle
according to requirement of output voltage. But output voltage can never be greater than input
voltage. But now the question which into mind.how to generate PWM and how to use PWM for
variable output voltage generation.

PWM GENERATION METHODS:


There are two ways to generate pulse width modulation with variable duty cycle:
1. Using analog electronics (operational amplifier, comparator and saw tooth wave etc.)
2. Using digital electronics ( microcontrollers and dedicated PWM controllers ICs )
I will not discuss first method in this article. but in future I will write a complete post on Pulse width
modulator using analog electronics. But those who dont know about programming and
microcontrollers can use analog electronics method for this purpose.

PULSE WIDTH MODULATION

Pulse Width Modulation


There are many different ways to control the speed of motors but one very simple and easy way is to
use Pulse Width Modulation. But before we start looking at the ins and outs of pulse width
modulation we need to understand a little more about how a DC motor works.
Next to stepper motors, the Permanent Magnet DC Motor (PMDC) is the most commonly used type of
small direct current motor available producing a continuous rotational speed that can be easily
controlled. Small DC motors ideal for use in applications were speed control is required such as in small
toys, models, robots and other such electronics circuits.
A DC motor consist basically of two parts, the stationary body of the motor called the Stator and the
inner part which rotates producing the movement called the Rotor. For D.C. machines the rotor is
commonly termed the Armature.
Generally in small light duty DC motors the stator consists of a pair of fixed permanent magnets
producing a uniform and stationary magnetic flux inside the motor giving these types of motors their
name of permanent-magnet direct-current (PMDC) motors.

The motors armature consists of individual electrical coils connected together in a circular
configuration around its metallic body producing a North-Pole then a South-Pole then a North-Pole etc,
type of field system configuration.
The current flowing within these rotor coils producing the necessary electromagnetic field. The circular
magnetic field produced by the armatures windings produces both north and south poles around the
armature which are repelled or attracted by the stators permanent magnets producing a rotational
movement around the motors central axis as shown.
2-Pole Permanent Magnet Motor

As the armature rotates electrical current is passed from the motors terminals to the next set of
armature windings via carbon brushes located around the commutator producing another magnetic
field and each time the armature rotates a new set of armature windings are energised forcing the
armature to rotate more and more and so on.
So the rotational speed of a DC motor depends upon the interaction between two magnetic fields, one
set up by the stators stationary permanent magnets and the other by the armatures rotating
electromagnets and by controlling this interaction we can control the speed of rotation.
The magnetic field produced by the stators permanent magnets is fixed and therefore can not be
changed but if we change the strength of the armatures electromagnetic field by controlling the
current flowing through the windings more or less magnetic flux will be produced resulting in a
stronger or weaker interaction and therefore a faster or slower speed.
Then the rotational speed of a DC motor (N) is proportional to the back emf (Vb) of the motor divided
by the magnetic flux (which for a permanent magnet is a constant) times an electromechanical
constant depending upon the nature of the armatures windings (Ke) giving us the equation
of:N V/Ke.

So how do we control the flow of current through the motor. Well many people attempt to control the
speed of a DC motor using a large variable resistor (Rheostat) in series with the motor as shown.
While this may work, as it does with Scalextric slot car racing, it generates a lot of heat and wasted
power in the resistance. One simple and easy way to control the speed of a motor is to regulate the
amount of voltage across its terminals and this can be achieved using Pulse Width Modulation or
PWM.
As its name suggests, pulse width modulation speed control works by driving the motor with a series of
ON-OFF pulses and varying the duty cycle, the fraction of time that the output voltage is ON
compared to when it is OFF, of the pulses while keeping the frequency constant.
The power applied to the motor can be controlled by varying the width of these applied pulses and
thereby varying the average DC voltage applied to the motors terminals. By changing or modulating
the timing of these pulses the speed of the motor can be controlled, ie, the longer the pulse is ON,
the faster the motor will rotate and likewise, the shorter the pulse is ON the slower the motor will
rotate.
In other words, the wider the pulse width, the more average voltage applied to the motor terminals,
the stronger the magnetic flux inside the armature windings and the faster the motor will rotate and
this is shown below.
Pulse Width Modulated Waveform

The use of pulse width modulation to control a small motor has the advantage in that the power loss in
the switching transistor is small because the transistor is either fully ON or fully OFF. As a result the

switching transistor has a much reduced power dissipation giving it a linear type of control which
results in better speed stability.
Also the amplitude of the motor voltage remains constant so the motor is always at full strength. The
result is that the motor can be rotated much more slowly without it stalling. So how can we produce
apulse width modulation signal to control the motor.

LCD (Liquid crystal display)

The JHD162A dot-matrix liquid crystal display controller and driver LSI displays alphanumerics,
Japanese kana characters, and symbols. It can be configured to drive a dot-matrix liquid crystal display
under the control of a 4- or 8-bit microprocessor. Since all the functions such as display RAM, character
generator, and liquid crystal driver, required for driving a dot-matrix liquid crystal display are internally
provided on one chip, a minimal system can be interfaced with this controller/driver. A single JHD162A
can display up to one 16-character line or two 16-character lines. The JHD162A has pin function
compatibility with the HD44780S which allows the user to easily replace an LCD-II with aJHD162A. The
JHD162A character generator ROM is extended to generate 208 5 8 dot character fonts and 32 5 10
dot character fonts for a total of 240 different character fonts. The low power supply (2.7V to 5.5V) of
the JHD162A is suitable for any portable battery-driven product requiring low power dissipation.

LCD screen consists of two lines with 16 characters each. Every character consists of 5x8 or 5x11dot
matrix. This book covers 5x8 character display, which is indeed the most commonlyused one.

Pin assignment.The pin assignment shown in, Table 2.1.is the industry standard for character LCDmodules with a maximum of 80 characters. The pin assignment shown in Table 2 is the industry standard

for character LCD-modules with more than 80 characters.


To locate pin 1 on a module check the manufacturers datasheet!

Pin number
1
2
3
4
5
6
7
8
9
10
11
12
13
14

Table 2.1., Pin assignment for <= 80 character displays


Symbol
Level
I/O
Function
Vss
Power supply (GND)
Vcc
Power supply (+5V)
Vee
Contrast adjust
RS
0/1
I
0 = Instruction input
1 = Data input
R/W
0/1
I
0 = Write to LCD module
1 = Read from LCD module
E
1, 1->0
I
Enable signal
DB0
0/1
I/O
Data bus line 0 (LSB)
DB1
0/1
I/O
Data bus line 1
DB2
0/1
I/O
Data bus line 2
DB3
0/1
I/O
Data bus line 3
DB4
0/1
I/O
Data bus line 4
DB5
0/1
I/O
Data bus line 5
DB6
0/1
I/O
Data bus line 6
DB7
0/1
I/O
Data bus line 7 (MSB)

DC MOTOR FUNDAMENTALS

There are different kinds of D.C. motors, but they all work on the same principles. To
understand what goes on inside a motor, here is an example.

When a permanent magnet is positioned around a loop of wire that is hooked up to a D.C.
power source, we have the basics of a D.C. motor. In order to make the loop of wire spin,
we have to connect a battery or DC power supply between its ends, and support it so it can
spin about its axis. To allow the rotor to turn without twisting the wires, the ends of the
wire loop are connected to a set of contacts called the commutator, which rubs against a
set of conductors called the brushes. The brushes make electrical contact with the
commutator as it spins, and are connected to the positive and negative leads of the power
source, allowing electricity to flow through the loop. The electricity flowing through the
loop creates a magnetic field that interacts with the magnetic field of the permanent
magnet to make the loop spin.

The DC motor used in this project is Direct Current permanent magnet motors operated at
a constant voltage. Motor characteristics vary considerably from type to type, and their
performance characteristics can be altered by the way electrical power is supplied. can be
quite different than those covered here. Few physical parameters associated with DC
motors are

1. TORQUE

a. A force that produces or tends to produce rotation or torsion (an automobile

engine delivers torque to the drive shaft);also: a measure of the effectiveness


of such a force that consists of the product of the force and the perpendicular
distance from the line of action of the force to the axis of rotation.
b. A turning or twisting force.
c. The quantitative measure of the tendency of a force to cause or change
rotational motion is called torque.

Torque (also called a moment) is the term we use when we talk about forces that act in a
rotational manner. You apply a torque or moment when you turn a dial, flip a light switch,
drill a hole or tighten a screw or bolt.
As shown in the picture of a ratchet, a vertical force applied at the end of the handle
creates a torque. The force, F, applied to the ratchet as shown causes a tendency to rotate
about point O. The force can be broken down into two components: a radial component,
Frad, parallel to the ratchet handle that does not contribute to the torque, and a tangential
component, Ftan, perpendicular to the handle that does contribute to the torque. The
distance from point O to the point of action of F is described by the direction vector, r. The
moment arm, l is the perpendicular distance between point O and the line of action of F.
If we were to shorten the moment arm by applying the force closer to the head of the
ratchet, the magnitude of the torque would decrease, even if the force remained the same.
Thus, if we change the effective length of the handle, we change the torque (see equation
1).

UNITS of TORQUE
SI

English

newton-meters {Nm}

inch-pounds {inlb}
foot-pounds {ftlb}
inch-ounces {inoz}

1 Nm = 0.738 ftlb
1 inlb = 0.113 Nm
1 Nm = 0.113 inlb
1 ftlb = 1.356 Nm
1 Nm = 141.61 inoz 1 inoz = 7.062E-03 Nm

2. SPEED

Speed (Angular Velocity)

The rate of rotation around an axis usually expressed in radians or revolutions per second or
per minute

Motors are devices that convert electrical energy into mechanical energy. The D.C. motors
that we have been dealing with here convert electrical energy into rotational energy. That
rotational energy is then used to lift things, propel things, turn things, etc. When we supply
the specified voltage to a motor, it rotates the output shaft at some speed. This rotational
speed or angular velocity,
is typically measured in radians/second {rad/s},
revolutions/second {rps}, or revolutions/minute {rpm}.
o

When performing calculations, be sure to use consistent units. In the English system,
calculations should be done in degrees/second, and radians/sec for SI calculations.
NOTE:
1 revolution = 360
1 revolution = (2*) radians
1 radian = (180/)
1 = (/180) radians

From the angular velocity, , we can find the tangential velocity of a point anywhere on
the rotating body through the equation tangential velocity,
v= r* , where r is the distance from the axis of rotation. This relation can be used to
compute the steady state (constant speed - no acceleration) speed of a vehicle if the radius
and angular velocity of a wheel is known, or a winch winds up the linear speed of a rope as
it.
3. POWER

Motive Power
a. Ability to act or produce an effect
b. A source or means of supplying energy; especially: ELECTRICITY
c. MOTIVE POWER the time rate at which work is done or energy emitted or
transferred

Power in Rotational Motion


When you pedal a bicycle, you apply forces to a rotating body and do work on it.
Similar things happen in real-life situations, such as a rotating motor shaft driving a power
tool or a car engine propelling the vehicle. We can express this work in terms of torque and
an angular displacement...
What about the power associated with work done by a torque acting on a rotating body?
dW/dt is the rate of doing work, or power P. When a torque T (with respect to the axis of
rotation) acts on a body that rotates with angular velocity W, its power (rate of doing work)
is the product of the torque and angular velocity. This is the analog of the relation P = Fv for
particle motion.

Power in rotational motion can be written as:

UNITS of POWER
SI

English

Watts {W}
foot-pounds per second {ftlb/s}
newton-meters per second {Nm/s} horsepower {hp}
1 W = 1 Nm/s
1 W = 0.738 ftlb/s
1 W = 1.341E-03 hp

1 ftlb/s = 1.818E-03 hp
1 ftlb/s = 1.356 W

H-BRIDGE
THEORY OF OPERATION
How do we make a motor turn on? You take a battery; hook the positive side to one side
of your DC motor. Then you connect the negative side of the battery to the other motor
lead. The motor spins forward. If you swap the battery leads the motor spins in reverse.
Ok, that's basic. Now lets say you want a Micro Controller Unit (MCU) to control the
motor, how would you do it? Well, for starters you get a device that would act like a solid
state switch, a transistor, and hook it up the motor.
NOTE: If you connect up these relay circuits, remember to put a diode across the coil of
the relay. This will keep the spike voltage (back EMF), coming out of the coil of the relay,
from getting into the MCU and damaging it. The anode, which is the arrow side of the
diode, should connect to ground. The bar, which is the Cathode side of the diode, should
connect to the coil where the MCU connects to the relay.

If you connect this circuit to a small hobby motor you can control the motor with a
processor (MCU, etc.) Applying a logical one, (+12 Volts in our example) to point A causes
the motor to turn forward. Applying a logical zero, (ground) causes the motor to stop
turning (to coast and stop).

Hook the motor up in this fashion and the circuit turns the motor in reverse when you apply a logical
one (+12Volts) to point B. Apply a logical zero, which is usually a ground, causes the motor to stop
spinning.
If you hook up these circuits you can only get the motor to stop or turn in one direction, forward for the
first circuit or reverse for the second circuit.

Motor Speed
You can also pulse the motor control line, (A or B) on and off. This powers the motor in short burst and
gets varying degrees of torque, which usually translates into variable motor speed.
But if you want to be able to control the motor in both forward and reverse with a processor, you will
need more circuitry. You will need an H-Bridge. Notice the "H"-looking configuration in the next graphic.
Relays configured in this fashion make an H-Bridge. The "high side drivers" are the relays that control
the positive voltage to the motor. This is called sourcing current.
The "low side drivers" are the relays that control the negative voltage to sink current to the motor.
"Sinking current" is the term for connecting the circuit to the negative side of the power supply, which is
usually ground.

So, you turn on the upper left and lower right circuits, and power flows through the motor
forward, i.e.: 1 to A, 0 to B, 0 to C, and 1 to D.

Then for reverse you turn on the upper right and lower left circuits and power flows
through the motor in reverse, i.e.: 0 to A, 1 to B, 1 to C, and 0 to D.

CAUTION: You should be careful not to turn on both circuits on one side or the other, or
you have a direct short which will destroy your circuit; Example: A and C or B and D both
high (logical 1).

SEMICONDUCTOR H-BRIDGES
we can better control our motor by using transistors or Field Effect Transistors
(FETs).Most of what we have discussed about the relays H-Bridge is true of these circuits.
You don't need diodes that were across the relay coils now. You should use diodes across
your transistors though. See the following diagram showing how they are
connected.These solid state circuits provide power and ground connections to the motor,

as did the relay circuits. The high side drivers need to be current "sources" which is what
PNP transistors and P-channel FETs are good at. The low side drivers need to be current
"sinks" which is what NPN transistors and N-channel FETs are good at.

If you turn on the two upper circuits, the motor resists turning, so you effectively have a
breaking mechanism. The same is true if you turn on both of the lower circuits. This is
because the motor is a generator and when it turns it generates a voltage. If the
terminals of the motor are connected (shorted), then the voltagegenerated counteracts
the motors freedom to turn. It is as if you are applying a similar but opposite voltage to
the one generated by the motor being turned. Vis--vis, it acts like a brake.To be nice to
your transistors, you should add diodes to catch the back voltage that is generated by the
motor's coil when the power is switched on and off. This flyback voltage can be many
times higher than the supply voltage! If you don't use diodes, you could burn out your
transistors.

Transistors, being a semiconductor device, will have some resistance, which causes them
to get hot when conducting much current. This is called not being able to sink or source
very much power, i.e.: Not able to provide much current from ground or from plus
voltage.
Mosfets are much more efficient, they can provide much more current and not get as hot.
They usually have the flyback diodes built in so you don't need the diodes anymore. This
helps guard against flyback voltage frying your MCU.To use Mosfets in an H-Bridge, you
need P-Channel Mosfets on top because they can "source" power, and N-Channel Mosfets
on the bottom because then can "sink" power. N-Channel Mosfets are much cheaper than
P-Channel Mosfets, but N-Channel Mosfets used to source power require about 7 volts
more than the supply voltage, to turn on. As a result, some people manage to use NChannel Mosfets, on top of the H-Bridge, by using cleaver circuits to overcome the
breakdown voltage.
It is important that the four quadrants of the H-Bridgecircuits be turned on and off
properly. When there is a path between the positive and ground side of the H-Bridge,
other than through the motor, a condition exists called "shoot through". This is basically a
direct short of the power supply and can cause semiconductors to become ballistic, in
circuits with large currents flowing. There are H-bridge chips available that are much
easier, and safer, to use than designing your own H-Bridge circuit.

H-Bridge Devices
The L 293 has 2 H-Bridges, can provide about 1 amp to each and occasional peak loads to
2 amps. Motors typically controlled with this controller are near the size of a 35 mm film
plastic canister.
The L298 has 2 h-bridges on board, can handle 1amp and peak current draws to about
3amps. You often see motors between the size a of 35 mm film plastic canister and a coke
can, driven by this type H-Bridge. The LMD18200 has one h-bridge on board, can handle
about 2 or 3 amps and can handle a peak of about 6 amps. This H-Bridge chip can usually
handle an average motor about the size of a coke. There are several more commercially
designed H-Bridge chips as well.

DC GEARED MOTOR SPECIFICATION

1. OPERATING VOLTAGE 12V dc


2. 30 RPM
3. TORQUE 3kgcm

MICRO CONTROLLER PIC18F4520


Microcontroller
Circumstances that we find ourselves in today in the field of microcontrollers had their beginnings in
the development of technology of integrated circuits. This development has made it possible to store
hundreds of thousands of transistors into one chip. That was a prerequisite for production of
microprocessors, and the first computers were made by adding external peripherals such as memory,
input-output lines, timers and other. Further increasing of the volume of the package resulted in
creation of integrated circuits. These integrated circuits contained both processor and peripherals.
That is how the first chip containing a microcomputer, or what would later be known as a
microcontroller came about.

PIN OUTS OF MICROCONTROLLER PIC18F4520

SOFTWARE USED
MPLAB IDE 8.92

POWER SUPPLY

Types of Power Supply


There are many types of power supply. Most are designed to convert high voltage AC mains electricity
to a suitable low voltage supply for electronics circuits and other devices. A power supply can by
broken down into a series of blocks, each of which performs a particular function.
For example a 5V regulated supply:

Each of the blocks is described in more detail below:

Transformer - steps down high voltage AC mains to low voltage AC.


Rectifier - converts AC to DC, but the DC output is varying.
Smoothing - smoothes the DC from varying greatly to a small ripple.
Regulator - eliminates ripple by setting DC output to a fixed voltage.

Power supplies made from these blocks are described below with a circuit diagram and a graph of their
output:

Dual Supplies
Some electronic circuits require a power supply with positive and negative outputs as well as zero volts
(0V). This is called a 'dual supply' because it is like two ordinary supplies connected together as shown
in the diagram. Dual supplies have three outputs, for example a 9V supply has +9V, 0V and -9V
outputs.

Transformer only

The low voltage AC output is suitable for lamps, heaters and special AC motors. It is not suitable for
electronic circuits unless they include a rectifier and a smoothing capacitor.

Transformer + Rectifier

The varying DC output is suitable for lamps, heaters and standard motors. It is not suitable for
electronic circuits unless they include a smoothing capacitor.

Transformer + Rectifier + Smoothing

The smooth DC output has a small ripple. It is suitable for most electronic circuits.

Transformer + Rectifier + Smoothing + Regulator

The regulated DC output is very smooth with no ripple.


It is suitable for all electronic circuits.

Transformer
Transformers convert AC electricity from one voltage to another with little loss of power. Transformers
work only with AC and this is one of the reasons why mains electricity is AC.
Step-up transformers increase voltage, step-down transformers reduce voltage. Most power supplies
use a step-down transformer to reduce the dangerously high mains voltage (230V in UK) to a safer low
voltage.
The input coil is called the primary and the output coil is called the
secondary. There is no electrical connection between the two coils,
instead they are linked by an alternating magnetic field created in the
soft-iron core of the transformer. The two lines in the middle of the
circuit symbol represent the core.
Transformer
Transformers waste very little power so the power out is (almost)
circuit symbol
equal to the power in. Note that as voltage is stepped down current is
stepped up. The ratio of the number of turns on each coil, called the
turns ratio, determines the ratio of the voltages. A step-down
transformer has a large number of turns on its primary (input) coil
which is connected to the high voltage mains supply, and a small
number of turns on its secondary (output) coil to give a low output
voltage.
Vp
turns ratio =

Np
=

Vs

power out = power in


and

Ns

Vp = primary (input) voltage


Np = number of turns on primary coil
Ip = primary (input) current

Vs Is = Vp Ip
Vs = secondary (output) voltage
Ns = number of turns on secondary coil
Is = secondary (output) current

Rectifier

There are several ways of connecting diodes to make a rectifier to convert AC to DC. The
bridge rectifier is the most important and it produces full-wave varying DC. A full-wave rectifier can also
be made from just two diodes if a centre-tap transformer is used, but this method is rarely used now
that diodes are cheaper. A single diode can be used as a rectifier but it only uses the positive (+) parts
of the AC wave to produce half-wave varying DC.

Bridge rectifier
A bridge rectifier can be made using four individual diodes, but it is also available in special packages
containing the four diodes required. It is called a full-wave rectifier because it uses all the AC wave
(both positive and negative sections). 1.4V is used up in the bridge rectifier because each diode uses
0.7V when conducting and there are always two diodes conducting, as shown in the diagram below.

Bridge rectifiers are rated by the maximum current they can pass and the maximum reverse voltage
they can withstand (this must be at least three times the supply RMS voltage so the rectifier can
withstand the peak voltages). Please see the Diodespage for more details, including pictures of bridge
rectifiers.

Bridge rectifier

Output: full-wave varying DC

Alternate pairs of diodes conduct, changing over


the connections so the alternating directions of
AC are converted to the one direction of DC.

(using all the AC wave)

Single diode rectifier


A single diode can be used as a rectifier but this produces half-wave varying DC which has gaps when
the AC is negative. It is hard to smooth this sufficiently well to supply electronic circuits unless they
require a very small current so the smoothing capacitor does not significantly discharge during the
gaps. Please see the Diodespage for some examples of rectifier diodes.

Single diode rectifier

Output: half-wave varying DC


(using only half the AC wave)

Smoothing
Smoothing is performed by a large value electrolytic capacitor connected across the DC supply to act
as a reservoir, supplying current to the output when the varying DC voltage from the rectifier is falling.
The diagram shows the unsmoothed varying DC (dotted line) and the smoothed DC (solid line). The
capacitor charges quickly near the peak of the varying DC, and then discharges as it supplies current to
the output.

Note that smoothing significantly increases the average DC voltage to almost the peak value (1.4
RMS value). For example 6V RMS AC is rectified to full wave DC of about 4.6V RMS (1.4V is lost in the
bridge rectifier), with smoothing this increases to almost the peak value giving 1.4 4.6 = 6.4V smooth
DC.
Smoothing is not perfect due to the capacitor voltage falling a little as it discharges, giving a small
ripple voltage. For many circuits a ripple which is 10% of the supply voltage is satisfactory and the
equation below gives the required value for the smoothing capacitor. A larger capacitor will give
less ripple. The capacitor value must be doubled when smoothing half-wave DC. Smoothing
capacitor for 10% ripple, C =

5
Io
Vs
f

C = smoothing capacitance in farads (F)


Io = output current from the supply in amps (A)
Vs = supply voltage in volts (V), this is the peak value of the unsmoothed DC
f = frequency of the AC supply in hertz (Hz), 50Hz in the UK

Regulator
Voltage regulator ICs are available with fixed (typically 5, 12 and 15V) or variable output voltages. They
are also rated by the maximum current they can pass. Negative voltage regulators are available, mainly
for use in dual supplies. Most regulators include some automatic protection from excessive current
('overload protection') and overheating ('thermal protection'). Many of the fixed voltage regulator ICs
has 3 leads and look like power transistors, such as the 7805 +5V 1A regulator shown on the right.
They include a hole for attaching aheat sink if necessary. Please see the website for more information
about voltage regulator ICs.

REFERENCES
[1] Burmester, M., Magkos, E., :Towards secure and practical e-elections in the new era. In D. Gritzalis,
editor, Secure Electronic Voting, pages 6372. Kluwer Academic Publishers, (2003).
[2] Chaum, D.,: Untraceable electronic mail, return addresses, and digital pseudonyms.
Communications of the ACM, 24(2):8488, February (1981).
[3] Rivest, R., Sherman, A., editors, Advances in CryptologyCrypto 82, pages 199203, New
York,.Plenum Press, (1983).
[4] Chaum, D., : The dining cryptographers problem: Unconditional sender and recipient intractability.
Journal of Cryptology, (1):6575, (1988).
[5] Cranor, L., Cytron,L.F., Sensus: A security-conscious electronic polling system for the internet. In
Proceedings of IEEE 30th Hawaii International Conference on System Sciences (HICSS-30), pages
561 570, January (1997).
[6] ETS 300 506. Security aspects (RFID 02.09 version 4.5.1), Digital cellular telecommunications
system (phase 2), (2000).
[7] Fujioka, T., Okamoto, K.,Ohta :A practical secret voting scheme for large scale elections. In J.
Seberry and Y. Zheng, editors, Advances in CryptologyAuscrypt92, volume 718 of Lecture Notes in
Computer Science, pages pp. 244251, Gold Coast, Queensland, Austrailia, 13-16 December 1992.
Springer Verlag,(1992).
[8] Hirt ,M., Sako, K.,: Efficient receipt-freesvoting based on homomorphic encryption. In B. Preneel,
editor, Advances in Cryptology EUROCRYPT 00, volume 1807 of Lecture Notes in Computer
Science, pages 539 556. Springer-Verlag, May (2000).
[9] Jefferson, D., Rubin, A. D., Simons, B., D. Wagner.,: A Security Analysis of the Secure Electronic
Registration and Voting Experiment (SERVE), (2004).
[10] Lin, Y., Chlamtac,I.,:Wireless and Mobile Network Architectures. Wiley, (2000).
[11] A. J. Menezes, P. C. Van Oorschot, and S. A. Vanstone.Handbook of Applied Cryptography. CRC
Press, Inc., (1996).
[12] Naor, M.,: Bit commitment using pseudo-randomness (extended abstract). In G. Brassard, editor,
CRYPTO 89: Proceedings on Advances in cryptology, pages 128136. Springer-Verlag New York,
Inc., (1989).