Sei sulla pagina 1di 46

IMPROVING POWER FACTOR

USING APFC UNIT


ABSTRACT

The project is designed to reduce the power loss in industries by power factor

compensation through a number of shunt capacitors. This results in reduction in amount of

electrical bill for industries and commercial establishments.

Power factor is defined as the ratio of real power to apparent power. This definition

is often mathematically represented as KW/KVA, where the numerator is the active (real)

power and the denominator is the (active + reactive) or apparent power . Reactive power is

the non working power generated by the magnetic and inductive loads, to generate magnetic

flux. The increase in reactive power increases the apparent power, so the power factor also

decreases. Having low power factor, the industry needs more energy to meet its demand, so

the efficiency decreases.

In this proposed system the time lag between the zero voltage pulse and zero

current pulse duly generated by suitable operational amplifier circuits in comparator

mode are fed to two interrupt pins of the microcontroller. Microcontroller displays the

power loss due to the inductive load on the LCD. The program takes over to actuate

appropriate number of relays at its output to bring shunt capacitors into the load circuit to

get zero power loss. The 8 bit microcontroller used in the project belongs to 8051 family.
Further the project can be enhanced by using thyristor control switches instead of

relay control to avoid contact pitting often encountered by switching of capacitors due to

high in rush current.

BLOCK DIAGRAM
BENEFITS OF POWER FACTOR IMPROVEMENT

Most benefits provided by a power factor improvement system from the reduction of
reactive power in the system. This may result in

A) Lower purchased-power cost if the utility enforces a power-factor clause


B) Release of system electrical capacity
C) Voltage improvement and
D) Lower system losses

Maximum benefits are obtained when capacitors are located at low power-factor levels.
Although reducing the power bill is still primary reason for improving the power factor,
and it is becoming more important because of conservation of energy, the function of
releasing system capacity is sometimes the decisive factor.

2. POWER-FACTOR FUNDAMENTALS:

Causes of Low Power Factor.


Most utilization devices require two components of current.
a) The power producing current or working current is that current which is converted by
the equipment into useful work, usually in the form of heat, light or mechanical power.
The unit of measurement of power is WATT.

b) Magnetizing current, also known as Watt-less, reactive or non-working current, is the


current required to produce the flux necessary for the operation of electromagnetic
devices. Without magnetizing current, energy could not flow through the core of
transformer. The unit of measurement of reactive power is VAR.

The normal relationship of these two components of current to each other, to the total
current, and to the system voltage is explained in Fig-1. It shows that the active current
and reactive current add vectorially to form the total current which can be determined
from the expression,
Total current = I = √(ICos Φ )2 + (ISin Φ )2

Where ICos Φ = Active current and ISin Φ = Reactive current

At a given voltage, V, the active, reactive and apparent power are proportional to current
and are related as follows:

VI =((VICos Φ )2 + (VISin Φ )2)1/2

Where VI = apparent power, VI Cosj = Active power, VI Sinj = Reactive power

DEFINITION OF POWER-FACTOR:

The power factor is defined as the ratio of active power to apparent power in a circuit. It
varies from one to zero but is generally given as below:

Power factor = Active power in KW / Apparent power KVA

Power Factor = cosine of angle between active power and apparent power

= Cos Φ

Active Power = Apparent power × Power Factor


= (KVA). (PF)

LEADING AND LAGGING POWER FACTOR:


The power factor may be lagging or leading depending on the direction of both the
active and reactive power flows. If these flows are in same direction, the power factor at
that point of reference is lagging. If either power component flow is in an opposite
direction, the power factor at that point of reference is leading. Since the capacitors are a
source of reactive power only, their power factor is always leading. An induction motor
or transformer has a lagging power factor as it required both active and reactive power
into in the motor or transformer.(same direction)

BASIC POWER FACTOR ECONOMICS:


High plant power factors can yield direct savings. Some, such as reduced power
bills and release of system capacity, are quite visible; others, such as decreased I2R losses
(copper loss) are also visible. The cost of improving the power factor in existing plants,
and of maintaining proper levels as load is added, depends on the power factor value
selected and upon the equipment chosen to supply the compensating reactive power. In
general, medium voltage capacitors cost less per kilovar than low-voltage capacitors.
The combination of reduced power billing and released system capacity by
improving the power factor is very attractive economically.
On comparing the installation cost of power factor improving capacitors and
installed cost per KVA of power distribution equipment, it is achieved that the economic
power factor would be 0.95

HOW THE POWER FACTOR IS IMPROVED:


When the reactive power component in a circuit is reduced, the total current is
reduced. If the active power component does not change, as is usually true, the power
factor will improve as the reactive power component becomes zero, the power factor will
be unit or 100 percent.

Suppose a transformer load (in the power plant used in DOT) takes an active load of 80A
and a reactive load of 60A from the mains, the total or line current will be of v802 + 1002
= 100 Amps. If a capacitor is installed so that it will supply the reactive current of 60A,
then the supply needs to deliver only 80A to the exactly same load of the transformer. The
supply circuit is now carrying only active power, hence the system capacity is not wasted
in carrying reactive power.
Now, if we increase the capacity of capacitor further to increase the reactive current, the
excess reactive current tends to flow towards the mains, causing the leading power-factor,
which is also not advisable in the view of Electricity authorities.
Calculation of methods of power-factor improvement.
From the right triangle relationship shown in Fig.1, the simple and useful
mathematical expressions may be written.

Cos Φ = Active Power = KW -EQ:1


Apparent Power KVA
Tan Φ = Reactive Power =Kvar -EQ:2
Active power KW
Sin Φ = Reactive power =Kvar -EQ:3
Apparent power KVA

Because the active power component usually remains constant and the apparent
power and reactive power components change with the power factor, the expression
involving the active power component is the most convenient one to analyse. This
expression may be written as

Reactive Power = Active power × Tan Φ


Kvar = (KW). Tan Φ -EQ:4
Where Tan Φ corresponds to the power factor angle.
For example, assume that it is necessary to determine the Capacitor rating to
improve the load power factor:
Reactive power at Original power factor = Active power × Tan Φ1
= (KW).( TanΦ1) -EQ:5

Reactive power at Improved power factor = Active power × Tan Φ2


= (KW).( Tan Φ2) - EQ6
Where the Φ1= angle of original power factor
Φ2= angle of improved power factor

Therefore the capacitor rating required to improve the power factor is


Reactive power of capacitor = Active power × (Tan Φ1 - Tan
Φ2 )
‘Kvar ‘ Rating of the capacitor
=(KW). (Tan Φ1 - Tan Φ2 ) -EQ:7

Example: Find the capacitor rating required to improve the power factor of a 50KW load
from 0.76 to 0.93

Kvar = KW. (Tan Φ1 - Tan Φ2 )


Cos Φ1 = 0.76; Φ1 = 40º 54’ : Tan Φ1 = 0.8662
Cos Φ2 =0.93; Φ2 =21º 38’ : Tan Φ2 =0.3966
Tan Φ1 - Tan Φ2 = 0.4676
Now Kvar = 50 (0.4696) = 23.48 d 25 Kvar
Capacitor rating = 25 Kvar

LOCATION OF REACTIVE POWER SUPPLY:


The benefits obtained by installing capacitors for power factor improvement result from
the reduction of reactive power in the system. They should, in general, be installed as
cloase to the load as possible. It is in common practice to connect the capacitors ahead of
individual plants. This provides power factor improvement at the load and permits
switching the capacitor and the plant as a unit as shown in location C1 of fig.3.
Power factor improvement for small loads or for those units that for some other reason
may not lend themselves to have capacitors directly associated with the load, may be
accomplished by connecting capacitors at a substation at location C2.
Large plants with extensive primary distribution systems often install capacitors at the
primary voltage bus at location C3 when the utility billing encourages the user to improve
the power factor.
o Fig 3

RELEASE OF SYSTEM CAPACITY


The expression, release of capacity means that as the power factor is improved, the
current in the existing system will be readuced, permitting additional load to be served by
the same system.
If a plant has a load of 100KVA at 70 percent power factor and 48 Kvar of capacitors are
added, the system electric capacity is released by 28 percent approximately, that the
system can carry 28 percent more load without exceeding the apparent power rating. The
final power factor of the original load plus the additional load will be 0.9 (90 percent)
approximately.

VOLTAGE IMPROVEMENT
Although capacitors raise a circuit voltage, it is rarely economical to apply them in
industrial plants for that reason alone. The following approximate expression shows the
importance of reducing the reactive power component of a current in order to reduce the
voltage drop.

∆V ≈ RI cos Ф ± XI sin Ф

∆V = ( R) X [Active power current] ±(X ) [Reactive power current]

Where ∆V is the voltage change, which may be a drop or rise in


voltage;

R and X are in ohms; I in amperes; Ф is the power factor


angle. Plus is used when the power is lagging and minus when it is leading.

Typically, reactive power flow produces a voltage drop. Since the power factor acts
directly to reduce reactive power flow, it is most effective in reducing voltage drop.
POWER SYSTEM LOSSES:

Although the financial return from conductor loss reduction is seldom sufficient to justify
the installation of capacitors, it is an attractive additional benefit. System conductor
losses are proportional to current squared, and since current is reduced in direct
proportion to power factor improvement, the losses are inversely porportional to the
square of the power factor.

Percentage loss reduction = 100 [1 – (Original PF / Improved PF)2 ]

Case Study of Usage of Capacitor banks for Improving PF - TE Harbour

1.When all the capacitors are switched OFF,


PF : 0.787 KVA : 414.3 KW : 326.1

2. KVAR required to improve the PF to 0.9 = 326.1 x 0.292 (MF) = 95.22


= 95 KVAR

3. KVAR required to improve the PF to 1.0 = 326.1 x 0.776 (MF) = 253 KVAR

4.Additional KVAR required to improve the PF from 0.9 to 1.0


= 253-95 =158 KVAR

5.Capital Investment for installing Capacitors:

 Cost of capacitor with MS compartment & switch gears


Per KVAR = Rs.1500
Total amount for 158 KVAR = 158 x 1500 = Rs.2,37,000 ----- (A)

 Watt loss of the capacitor = 0.5 W per KVAR


For 158 KVAR , the total watt loss = 0.5 x 158 = 79 W

Expenditure on electricity charges


Per month @ Rs. 5 /Unit = 79 x24 x5 x30 =Rs.284---(B)
1000

Sl Bill period from Actual Actual No. of units


No 4/2004 to 9/2004 Maximum Power consumed
Demand Factor
1 April 568.9 0.99 320,620
2 May 602.0 1.0 312,230
3 June 554.7 1.0 306,910
4 July 542.8 0.99 264,550
5 August 482.3 0.99 240,210
6 September 551.9 0.98 223,330
Average /Month 550 2,77,925

Contract demand : 700 KVA


 Electricity Charges for a month if PF = 0.9

 Unit Charges @ Rs.5/unit = 2,77,925 x 5 = 13,89,625


 MD charges @ Rs. 300 /KVA = 630 x 300 = 1,89,000
------------
15,78,625—©

 Electricity Charges for a month if PF = 1.0

 Unit Charges @ Rs.5/unit = 2,77,925 x 5 = 13,89,625


 MD charges @ Rs. 300 /KVA = 630 x 300 = 1,89,000
------------
15,78,625
------------
 Rebate @ 2.5 % 39,466
-----------
15,39,159—(D)
-----------
5. Rate of return of cost of Capacitors

Month Interest on the Expenditure due to Return of cost due Balance amt. to be
investment made watt loss of to incentive recovered
@ 5 % PA capacitor
0 0 0 0 237,000
1 995 284 39,466 198,813
2 835 284 39,466 160,466
3 674 284 39,466 121,958
4 512 284 39,466 83,289
5 350 284 39,466 44,456
6 187 284 39,466 5,461

 Approximately in 6 months time the cost of capacitors are paid back by


means of incentive.
Power Factor Correction – Power Quality Solutions

Awareness of the necessity of power quality and reliable supply is increasing, and Power
Quality Monitoring, Power Management, Power Quality Solutions and Power Factor
Correction are implemented on a growing scale. Enhancing power quality, stabilization of
the power supply, cost reduction and even climatic protection – these are targets that can
be realized by PQS.

Triple savings with Power Quality Solutions


To achieve a competitive advantage in an enterprise, cost factors and outputs have to be
controlled carefully that affect the bottom line. One important cost factor is the electricity
bill for production, processes, facilities, buildings or infrastructure object. However the
electricity bill is only one part – the visible one - of sometimes much higher cost,
considering “polluted” and unreliable power. Besides direct electricity cost the effective
usage of production equipment and reliable energy supply plays a major role in cost
effectiveness.

 Reduce electricity costs


 Optimize equipment utilization
 Improve system reliability and ensure stable processes

Power Quality Solutions

EPCOS is the world leading manufacturer of PFC-capacitors with global presence – not
only in terms of plants and sales offices. With a broad network of application experts we
are not just offering technology – we offer Power Quality Solutions. The portfolio
provides all PQS-key components that are mandatory for a successful and effective
power factor correction and harmonic filters:

 7 series of PFC-Capacitors
 4 types of PFC-Controllers
 3 types of Harmonic Filters
 2 types of Thyristor modules for Dynamic PFC
 2 types of Capacitor Contactors

The combination of first class technology and products, engineering and application
know-how makes EPCOS the first choice for Power Quality Solutions!
Product range

EPCOS is a world leading manufacturer and supplier of power capacitors. EPCOS


(formerly Siemens), the inventor of metallised polypropylene film capacitors, was laying
the milestones for today’s power capacitor industry - this is well documented by
numerous patents hold by EPCOS (Siemens).

EPCOS PFC capacitors - used with the corresponding application technology - can
handle all PFC problems even with high harmonic pollution.

EPCOS supplies all the components providing the latest tools and solutions for all kind of
PFC and harmonic filtering problems.

Three well proven technologies build the fundament for the various capacitor families:
 MKK: Concentric winding, polypropylene film, impregnation inert gas
 MKP/MPP: Stacked winding, polypropylene film, impregnation biodegradable
soft resin
 MKV: Double sided metallised paper as electrode carrier, polypropylene film
dielectric, with impregnation oil

Out of these three technologies, you can choose the appropriate capacitors for all
branches, applications and for all purposes:

The widest range of LV PFC-capacitors in industry will perfectly match to your needs in
any specific application:
 PhaseCap: Premium quality, high technology capacitor for standard
and detuned PFC applications.
 PhaseCap Compact: Improved capacitor based on the successful
PhaseCap MKK design.
 PhaseCap HD: Heavy duty type, higher power in a case.
 MKV-capacitors: For high harmonic contents or high ambient
temperature applications.
 PhiCap: Cost effective design, for all indoor applications.
 PoleCap: Outdoor applications or in surroundings with high dust-
or moisture presence.
 HomeCap: Capacitors for enegy savings in residential homes.

R&D expenses far above the market standards guarantee a continuous high innovation
rate. Five factories around the globe are ensuring highest production capacities and
supply guarantee. With a strong application and solution support from EPCOS experts
from allover the world, dedicated to PFC and Power Quality Solutions, we are
continuously improving our services to our customers.

PFC controllers

The PF-controller acts as the “brain” of a PFC-system. Its major task is to supervise the
pre-defined cos-phi-value: when the switching threshold (C/k-value) is exceeded, the PF-
controller will switch on or off particular capacitor steps. Generally spoken, the PF-
controller has to maintain a certain monthly average cos-phi-value. It is mandatory that
the controller protects the capacitor against an excessive number of switching operations
which would significantly influence the life expectancy of the PFC-system.
The PF-controller series BR6000 from EPCOS represent an innovative and intelligent
concept with a high number of customer benefits and user-friendly features.

 Large and multifunctional LCD display


 Menu-driven handling (plain language)
 Self initialisation
 Self optimized control capability
 Recall function of recorded values
 Easy installation and maintenance
 Panel mounted instrument
 Comprehensive software (for controller with RS interface)

EPCOS offers a broad range of PF-controllers of the BR600-series:


 BR604: 4 stages
 BR6000: 6 and 12 stages
 BR6000T: 6 and 12 stages(in combination with thyristor modules TSM-series)
 BR7000: 15 stages (for real 3 phase measurement and phase specific control)

Harmonics filters

The increasing use of modern power electronics (e.g. drives, uninterruptible power
supplies, etc) produces nonlinear current, influences and loads the network with
harmonics.

Resonance can lead to the following undesirable effects:


 Overloading of capacitors
 Overloading of transformers and transmission equipment
 Interference with metering and control systems, computers and switchgears
 Resonance elevation, i.e. amplification of harmonics
 Voltage distortion

These resonance phenomena can be avoided by connecting capacitors in series with filter
reactors. Detuned systems are scaled so that the self resonant frequency is below the
lowest line harmonic. The detuned PFC system is purely inductive seen by harmonics
above this frequency. For the fundamental line frequency (e.g. 50 Hz), the detuned
system acts purely capacitively, thus correcting the reactive power.

Our reactors feature:


 High harmonic loading capability
 Very low losses
 High linearity to avoid choke tilt
 Low noise
 Convenient mounting
 Long expected life time
 Temperature protection (NC auxiliary contact)

Contactors for capacitor switching

Capacitor contactors by EPCOS are especially designed for damping of these hazardous
inrush currents. Their reduction also avoids transients and voltage sags – thus improving
power quality and stability. We offer a very broad contactor range from 12,5 till 100kvar.

Benefits:
 Longer useful life of main contactors of capacitor contactor
 Soft switching of capacitor and thus longer useful life
 Enhanced mean life expectancy of PFC system
 Reduced ohmic losses
 Leading contacts with wiper function
 Tamper-proof and protected resistors
 Easy access for cable connectionDynamic PFC

Dynamic PFC

Conventional PFC-systems generally consist of capacitors, controllers and capacitor


contactors. This is sufficient for standard industry applications, but not suitable in
applications where fast changing loads are present. Automotive industry, cranes, welding
machines, steel presses, elevators or wind turbines require dynamic PFC-solutions that
allow real time reaction.

In a conventional PFC-system, the capacitor is connected to the supply grid by capacitor


contactors. These electro-mechanical contactors feature a reaction time of > 60 seconds
between the particular switching operations due to the discharge time of the capacitors.
This means that a useful power factor correction cannot be performed.

Another problem in conventional PFC-systems is the number of switching operations.


According to the PFC-relevant standards IEC60831 a capacitor should not undergo more
than 5,000 switching operations per year – a realistic value in applications with slow
changing loads and a low number of annual switching operations. Under conditions for
example like in a wind turbine – depending on the location and on the weather situation –
PFC-capacitors have to cope with a much higher number of switching operations far
beyond the limiting value. This influences the life time of the PFC-system in a very
negative degree. Thyristor switches allow a contact free switching of the capacitor, e.g.
without mechanical wear off and without negative impact on the life time of the PFC-
system. Thyristor modules switch the capacitors at zero current passage thus avoiding
high inrush currents. This prevents transients, increases power quality and provides
stabilization of the power supply.

With the TSM-series, EPCOS offers an output range for capacitive loads from 10 to 200
kvar, for 400V up to 690V grid voltage.

3.3 MICROCONTROLLER
A microcontroller (also MCU or µC) is a functional computer system-
on-a-chip. It contains a processor core, memory, and programmable
input/output peripherals. Microcontrollers include an integrated CPU,
memory (a small amount of RAM, program memory, or both) and
peripherals capable of input and output. Microcontrollers are used in
automatically controlled products and devices.

BASICS:
A designer will use a Microcontroller to
 Gather input from various sensors
 Process this input into a set of actions
 Use the output mechanisms on the Microcontroller to do
something useful.
MEMORY TYPES:
RAM:
 Random access memory.
 Ram is a volatile (change) memory.
 It general purpose memory that can store data or programs.
 Ex: hard disk, USB device.

ROM:
 Read only memory.
 Rom is a non volatile memory.
 This is typically that is programmed at the factory to have certain
values it cannot be changed.
 Ex: cd...
3.3.1 ARCHITECTURE OF AT89C51
8051 Architecture:
8051 Architecture contains the following:
 CPU
 ALU
 I/O ports
 RAM
 ROM
 2 Timers/Counters
 General Purpose registers
 Special Function registers
 Crystal Oscillators
 Serial ports
 Interrupts
 PSW
 Program Counter
 Stack pointer
Pin Description:

8051 contains 40 pins


32 Pins are used for I/O purpose
2 Pins for crystal oscillator to produce clock
2 Pins for Supply and ground
1 Pins for reset the controller
 Port 0:
Port 0 occupies a total of 8 pins. It can be used for input or
output. To use the pins of port 0 as both input and output ports.
Each pin must be connected externally to 10K ohm pull-up
resisters. This is due to the fact that P0 is an open drain.
 Port 1:
Port 1 occupies a total of 8 pins. It can be used as input or
output .In contrast to port 0, this port does not need any pull up
resisters since it already has pull up resisters internally. To make
port 1 an input port, it must be programmed as such by writing
1 to all its bits.
 Port 2:
Port 2 occupies a total of 8 pins. It can be used as input or
output. It already has pull-up resisters internally. To make port 2
an input, it must be programmed as such by writing 1 to all its
bits.
 Port 3:
Port 3 occupies a total of 8 pins. It can be used as input or
output. Port 3 has the additional function of providing some
extremely important signals such as interrupts.

DESCRIPTION OF AT89C51:

The AT89C51 is a low-power, high-performance CMOS 8-bit


microcomputer with 4K 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 and pinout. The on-chip Flash allows the program
memory to be reprogrammed in-system or by a conventional nonvolatile
memory programmer. By combining a versatile 8-bit CPU with Flash on a
monolithic chip, the Atmel AT89C51 is a powerful microcomputer which
provides a highly-flexible and cost-effective solution to many embedded
control applications.
The AT89C51 provides the following standard features: 4K bytes of
Flash, 128 bytes of RAM, 32 I/O lines, two 16-bit timer/counters, five vector
two-level interrupt architecture, a full duplex serial port, and on-chip
oscillator and clock circuitry. In addition, the AT89C51 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.

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;
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. 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.

IDLE MODE:
In idle mode, the CPU puts itself to sleep while all the on chip
peripherals remain active. The mode is invoked by software. The content of
the on-chip RAM and all the special functions registers remain unchanged
during this mode. The idle mode can be terminated by any enabled interrupt
or by a hardware reset. It should be noted that when idle is terminated by a
hard ware reset, the device normally resumes program execution, from
where it left off, up to two machine cycles before
the internal reset algorithm takes control. On-chip hardware inhibits access
to internal RAM in this event, but access to the port pins is not inhibited. To
eliminate the possibility of an unexpected write to a port pin when Idle is
terminated by
Reset, the instruction following the one that invokes Idle should not be one
that writes to a port pin or to external memory.
3.3.2 PIN DIAGRAM OF AT89C51

AT 89C51
3.3.3 PIN DESCRIPTION

VCC:
Supply voltage.

GND:
Ground.

Port 0:
Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port,
each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the
pins can be used as high impedance inputs. Port 0 may also be configured to
be the multiplexed low order address/data bus during accesses to external
program and data memory. In this mode P0 has internal pull-ups. Port 0 also
receives the code bytes during Flash programming, and outputs the code
bytes during program verification. External pull-ups are required during
program verification.

Port 1:
Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The
Port 1 output buffers can sink/source four TTL inputs. When 1s are written
to Port 1 pins they are pulled high by the internal pull-ups and can be used as
inputs. As inputs, Port 1 pins that are externally being pulled low will source
current (IIL) because of the internal pull-ups. Port 1 also receives the low-
order address bytes during Flash programming and verification.
Port 2:
Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The
Port 2 output buffers can sink/source four TTL inputs. When 1s are written
to Port 2 pins they are pulled high by the internal pull-ups and can be used as
inputs.
Port 2 pins that are externally being pulled low will source current (IIL)
because of the internal pull-ups.

RST:
Reset input a high on this pin for two machine cycles while the
oscillator is running resets the device.

ALE/PROG:

Address Latch Enable output pulse for latching the low byte of the
address during accesses to external memory. This pin is also the program
pulse input (PROG) during Flash programming. In normal operation ALE is
emitted at a constant rate of 1/6 the oscillator frequency, and may be used for
external timing or clocking purposes. Note, however, that one ALE pulse is
skipped during each access to external Data Memory.

PSEN:
Program Store Enable is the read strobe to external program memory.
When the AT89C51 is executing code from external program memory,
PSEN is activated twice each machine cycle, except that two PSEN
activations are skipped during
each access to external data memory.

EA/VPP:

External Access Enable. EA must be strapped to GND in order to


enable the device to fetch code from external program memory locations
starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is
programmed, EA will be
internally latched on reset. EA should be strapped to VCC for internal
program
executions. This pin also receives the 12volt programming enable voltage
(VPP) during Flash programming, for parts that require 12-volt VPP.

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

XTAL2:
Output from the inverting oscillator amplifier.

Port Pin Alternate Functions


P3.0 RXD (serial input port)
P3.1 TXD (serial output port)
P3.2 INT0 (external interrupt 0)
P3.3 INT1 (external interrupt 1)
P3.4 T0 (timer 0 external input)
P3.5 T1 (timer 1 external input)
P3.6 WR (external data memory write strobe)
P3.7 RD (external data memory read strobe)

3.4 POWER SUPPLIES

The present chapter introduces the operation of power supply circuits


built using filters, rectifiers and voltage regulators. Starting with an AC
voltage, a steady DC voltage, is obtained by rectifying the ac voltage then
filtering to a dc level and Finally Regulation is usually obtained from an IC
voltage regulator unit, which takes a dc voltage and provides a some what
lower dc voltage, which remains the same even if the input dc voltage varies
or the output load connected to the dc voltage changes.

BLOCK DIAGRAM:

Transformer Rectifier Filter Regulator


N
The ac voltage, typically 230v is connected to transformer, which
steps the ac voltage down to the level for desired dc output. A diode rectifier
provides a full wave rectified Voltage that is initially filtered by a simple
capacitive filter to produce a dc voltage.
This resulting dc voltage usually has some ripple or ac voltage
variation. A regulator Circuit can use this dc input to provide a regulated that
not only has much ripple voltage

But also remain the same dc values even if the input dc voltage
changes. This voltage Regulation is usually obtained using one of a number
of popular voltage regulation IC Units.

TRANSFORMER:

A transformer is the static device of which electric power in one


circuit is transformed into electric power of the same frequency in another
circuit. It can rise or lower the voltage in a circuit but with a corresponding
decrease or increase in current. It works with the principles of mutual
induction. In our project we are using step down transformer for providing
that necessary supply for the electronic circuits.

RECTIFIER:
The full wave rectifier conducts during both positive and negative half
cycles of input a.c. input; two diodes are used in this circuit. The a.c. voltage
is applied through a suitable power transformer with proper turn’s ratio. For
the proper operation of the circuit, a center-tap on the secondary winding of
the transformer is essential.

During the positive half cycle of ac input voltage, the diode D1 will be
forward biased and hence will conduct; while diode D2 will be reverse
biased and will act as open circuit and will not conduct.

In the next half cycle of ac voltage, polarity reverses and the diode D2
conducts, being forward biased, while D1 does not, being reverse biased.
Hence the load current flows in both half cycles of ac voltage and in the
same direction. The diode we are using here for the purpose of rectification
is IN4001.

FILTER:
The filter circuit used here is the capacitor filter circuit where a
capacitor is connected at the rectifier output, and a DC is obtained across
it. The filtered waveform is essentially a DC voltage with negligible
ripples, which is ultimately fed to the load.

REGULATOR:

The output voltage from capacitor is more filtered and finally


regulated. The voltage regulator is a device, which maintains the output
voltage constant irrespective of the change in supply variations, load
variations and temperature changes. Hence IC7805 is used which is a +5v
regulator.
CIRCUIT DIAGRAM OF POWER SUPPLIES:

Since all electronic circuits work only with low dc voltage it needs a
power supply unit to provide the appropriate voltage supply. This unit
consists of a transformer, rectifier, filter and regulator. AC voltage typically
230v is connected to the transformer that steps the AC voltage down to the
level to the desired AC voltage. A diode rectifier then provides a full wave
rectified voltage that is initially filtered by a simple capacitive filter to
produce a DC voltage. This resulting DC voltage usually has some ripple or
AC voltage variations.

LCD interfacing with Microcontrollers

►Introduction

The most commonly used Character based LCDs are based on Hitachi's HD44780
controller or other which are compatible with HD44580. In this tutorial, we will discuss
about character based LCDs, their interfacing with various microcontrollers, various
interfaces (8-bit/4-bit), programming, special stuff and tricks you can do with these
simple looking LCDs which can give a new look to your application.

For Specs and technical information HD44780 controller

►Pin Description
The most commonly used LCDs found in the market today are 1 Line, 2 Line or 4 Line
LCDs which have only 1 controller and support at most of 80 charachers, whereas LCDs
supporting more than 80 characters make use of 2 HD44780 controllers.

Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins (two
pins are extra in both for back-light LED connections). Pin description is shown in the
table below.

Figure 1: Character LCD type HD44780 Pin diagram

Pin No. Name Description


Pin no. 1 VSS Power supply (GND)
Pin no. 2 VCC Power supply (+5V)
Pin no. 3 VEE Contrast adjust
0 = Instruction input
Pin no. 4 RS
1 = Data input
0 = Write to LCD module
Pin no. 5 R/W
1 = Read from LCD module
Pin no. 6 EN Enable signal
Pin no. 7 D0 Data bus line 0 (LSB)
Pin no. 8 D1 Data bus line 1
Pin no. 9 D2 Data bus line 2
Pin no. 10 D3 Data bus line 3
Pin no. 11 D4 Data bus line 4
Pin no. 12 D5 Data bus line 5
Pin no. 13 D6 Data bus line 6
Pin no. 14 D7 Data bus line 7 (MSB)
Table 1: Character LCD pins with 1 Controller

Pin No. Name Description


Pin no. 1 D7 Data bus line 7 (MSB)
Pin no. 2 D6 Data bus line 6
Pin no. 3 D5 Data bus line 5
Pin no. 4 D4 Data bus line 4
Pin no. 5 D3 Data bus line 3
Pin no. 6 D2 Data bus line 2
Pin no. 7 D1 Data bus line 1
Pin no. 8 D0 Data bus line 0 (LSB)
Pin no. 9 EN1 Enable signal for row 0 and 1 (1stcontroller)
0 = Write to LCD module
Pin no. 10 R/W
1 = Read from LCD module
0 = Instruction input
Pin no. 11 RS
1 = Data input
Pin no. 12 VEE Contrast adjust
Pin no. 13 VSS Power supply (GND)
Pin no. 14 VCC Power supply (+5V)
Pin no. 15 EN2 Enable signal for row 2 and 3 (2ndcontroller)
Pin no. 16 NC Not Connected
Table 2: Character LCD pins with 2 Controller

Usually these days you will find single controller LCD modules are used more in the
market. So in the tutorial we will discuss more about the single controller LCD, the
operation and everything else is same for the double controller too. Lets take a look at the
basic information which is there in every LCD.

►DDRAM - Display Data RAM

Display data RAM (DDRAM) stores display data represented in 8-bit character codes. Its
extended capacity is 80 X 8 bits, or 80 characters. The area in display data RAM
(DDRAM) that is not used for display can be used as general data RAM. So whatever you
send on the DDRAM is actually displayed on the LCD. For LCDs like 1x16, only 16
characters are visible, so whatever you write after 16 chars is written in DDRAM but is
not visible to the user.

Figures below will show you the DDRAM addresses of 1 Line, 2 Line and 4 Line LCDs.

Figure 2: DDRAM Address for 1 Line LCD


Figure 3: DDRAM Address for 2 Line LCD

Figure 4: DDRAM Address for 4 Line LCD

►CGROM - Character Generator ROM

Now you might be thinking that when you send an ascii value to DDRAM, how the
character is displayed on LCD? so the answer is CGROM. The character generator ROM
generates 5 x 8 dot or 5 x 10 dot character patterns from 8-bit character codes (see Figure
5 and Figure 6 for more details). It can generate 208 5 x 8 dot character patterns and 32 5
x 10 dot character patterns. Userdefined character patterns are also available by mask-
programmed ROM.

Figure 5: LCD characters code map for 5x8 dots


Figure 6: LCD characters code map for 5x10 dots

As you can see in both the code maps, the character code from 0x00 to 0x07 is occupied
by the CGRAM characters or the user defined characters. If user want to display the
fourth custom character then the code to display it is 0x03 i.e. when user send 0x03 code
to the LCD DDRAM then the fourth user created charater or patteren will be displayed
on the LCD.

►CGRAM - Character Generator RAM

As clear from the name, CGRAM area is used to create custom characters in LCD. In the
character generator RAM, the user can rewrite character patterns by program. For 5 x 8
dots, eight character patterns can be written, and for 5 x 10 dots, four character patterns
can be written. Later in this tutorial i will explain how to use CGRAM area to make
custom character and also making animations to give nice effects to your application.
►BF - Busy Flag

Busy Flag is an status indicator flag for LCD. When we send a command or data to the
LCD for processing, this flag is set (i.e BF =1) and as soon as the instruction is executed
successfully this flag is cleared (BF = 0). This is helpful in producing and exact ammount
of delay. for the LCD processing.

To read Busy Flag, the condition RS = 0 and R/W = 1 must be met and The MSB of the
LCD data bus (D7) act as busy flag. When BF = 1 means LCD is busy and will not accept
next command or data and BF = 0 means LCD is ready for the next command or data to
process.

►Instruction Register (IR) and Data Register (DR)

There are two 8-bit registers in HD44780 controller Instruction and Data register.
Instruction register corresponds to the register where you send commands to LCD e.g
LCD shift command, LCD clear, LCD address etc. and Data register is used for storing data
which is to be displayed on LCD. when send the enable signal of the LCD is asserted, the
data on the pins is latched in to the data register and data is then moved automatically to
the DDRAM and hence is displayed on the LCD.
Data Register is not only used for sending data to DDRAM but also for CGRAM, the
address where you want to send the data, is decided by the instruction you send to LCD.
We will discuss more on LCD instuction set further in this tutorial.

►Commands and Instruction set

Only the instruction register (IR) and the data register (DR) of the LCD can be controlled
by the MCU. Before starting the internal operation of the LCD, control information is
temporarily stored into these registers to allow interfacing with various MCUs, which
operate at different speeds, or various peripheral control devices. The internal operation
of the LCD is determined by signals sent from the MCU. These signals, which include
register selection signal (RS), read/write signal (R/W), and the data bus (DB0 to DB7),
make up the LCD instructions (Table 3). There are four categories of instructions that:

 Designate LCD functions, such as display format, data length, etc.


 Set internal RAM addresses
 Perform data transfer with internal RAM
 Perform miscellaneous functions
Table 3: Command and Instruction set for LCD type HD44780

Although looking at the table you can make your own commands and test them. Below is
a breif list of useful commands which are used frequently while working on the LCD.

No. Instruction Hex Decimal


1 Function Set: 8-bit, 1 Line, 5x7 Dots 0x30 48
2 Function Set: 8-bit, 2 Line, 5x7 Dots 0x38 56
3 Function Set: 4-bit, 1 Line, 5x7 Dots 0x20 32
4 Function Set: 4-bit, 2 Line, 5x7 Dots 0x28 40
5 Entry Mode 0x06 6
Display off Cursor off
6 (clearing display without clearing DDRAM 0x08 8
content)
7 Display on Cursor on 0x0E 14
8 Display on Cursor off 0x0C 12
9 Display on Cursor blinking 0x0F 15
10 Shift entire display left 0x18 24
12 Shift entire display right 0x1C 30
13 Move cursor left by one character 0x10 16
14 Move cursor right by one character 0x14 20
15 Clear Display (also clear DDRAM content) 0x01 1
Set DDRAM address or coursor position on
16 0x80+add* 128+add*
display
Set CGRAM address or set pointer to CGRAM
17 0x40+add** 64+add**
location
Table 4: Frequently used commands and instructions for LCD

* DDRAM address given in LCD basics section see Figure 2,3,4


** CGRAM address from 0x00 to 0x3F, 0x00 to 0x07 for char1 and so on..

The table above will help you while writing programs for LCD. But after you are done
testing with the table 4, i recommend you to use table 3 to get more grip on working with
LCD and trying your own commands. In the next section of the tutorial we will see the
initialization with some of the coding examples in C as well as assembly.

►LCD Initialization

Before using the LCD for display purpose, LCD has to be initialized either by the internal
reset circuit or sending set of commands to initialize the LCD. It is the user who has to
decide whether an LCD has to be initialized by instructions or by internal reset circuit. we
will dicuss both ways of initialization one by one.

Initialization by internal Reset Circuit

An internal reset circuit automatically initializes the HD44780U when the power is
turned on. The following instructions are executed during the initialization. The busy flag
(BF) is kept in the busy state until the initialization ends (BF = 1). The busy state lasts for
10 ms after VCC rises to 4.5 V.
 Display clear
 Function set:
DL = 1; 8-bit interface data
N = 0; 1-line display
F = 0; 5 x 8 dot character font
 Display on/off control:
D = 0; Display off
C = 0; Cursor off
B = 0; Blinking off
 Entry mode set:
I/D = 1; Increment by 1
S = 0; No shift

Note: If the electrical characteristics conditions listed under the table Power Supply
Conditions Using Internal Reset Circuit are not met, the internal reset circuit will not
operate normally and will fail to initialize the HD44780U. For such a case, initial-ization
must be performed by the MCU as explained in the section, Initializing by Instruction.

As mentioned in the Note, there are certain condtions that has to be met, if user want to
use initialization by internal reset circuit. These conditions are shown in the Table 5
below.

Table 5: Power Supply condition for Internal Reset circuit

Figure 7 shows the test condition which are to be met for internal reset circuit to be
active.
Figure 7: Internal Power Supply reset

Now the problem with the internal reset circuit is, it is highly dependent on power supply,
to meet this critical power supply conditions is not hard but are difficult to achive when
you are making a simple application. So usually the second menthod i.e. Initialization by
instruction is used and is recommended most of the time.

Initialization by instructions

Initializing LCD with instructions is really simple. Given below is a flowchart that
describles the step to follow, to initialize the LCD.
Figure 8: Flow chart for LCD initialization

As you can see from the flow chart, the LCD is initialized in the following sequence...
1) Send command 0x30 - Using 8-bit interface
2) Delay 20ms
3) Send command 0x30 - 8-bit interface
4) Delay 20ms
5) Send command 0x30 - 8-bit interface
6) Delay 20ms
7) Send Function set - see Table 4 for more information
8) Display Clear command
9) Set entry mode command - explained below

The first 3 commands are usually not required but are recomended when you are using 4-
bit interface. So you can program the LCD starting from step 7 when working with 8-bit
interface. Function set command depends on what kind of LCD you are using and what
kind of interface you are using (see Table 4 in LCD Command section).

LCD Entry mode


From Table 3 in command section, you can see that the two bits decide the entry mode
for LCD, these bits are:
a) I/D - Increment/Decrement bit
b) S - Display shift.
With these two bits we get four combinations of entry mode which are
0x04,0x05,0x06,0x07 (see table 3 in LCD Command section). So we get different results
with these different entry modes. Normally entry mode 0x06 is used which is No shift
and auto incremement. I recommend you to try all the possible entry modes and see the
results, I am sure you will be surprised.

Programming example for LCD Initialization

CODE:
LCD_data equ P2 ;LCD Data port
LCD_D7 equ P2.7 ;LCD D7/Busy Flag
LCD_rs equ P1.0 ;LCD Register Select
LCD_rw equ P1.1 ;LCD Read/Write
LCD_en equ P1.2 ;LCD Enable

LCD_init:
mov LCD_data,#38H ;Function set: 2 Line, 8-bit,
5x7 dots
clr LCD_rs ;Selected command register
clr LCD_rw ;We are writing in
instruction register
setb LCD_en ;Enable H->L
clr LCD_en
acall LCD_busy ;Wait for LCD to process the
command
mov LCD_data,#0FH ;Display on, Curson blinking
command
clr LCD_rs ;Selected instruction
register
clr LCD_rw ;We are writing in
instruction register
setb LCD_en ;Enable H->L
clr LCD_en
acall LCD_busy ;Wait for LCD to process the
command
mov LCD_data,#01H ;Clear LCD
clr LCD_rs ;Selected command register
clr LCD_rw ;We are writing in
instruction register
setb LCD_en ;Enable H->L
clr LCD_en
acall LCD_busy ;Wait for LCD to process the
command
mov LCD_data,#06H ;Entry mode, auto increment
with no shift
clr LCD_rs ;Selected command register
clr LCD_rw ;We are writing in
instruction register
setb LCD_en ;Enable H->L
clr LCD_en
acall LCD_busy ;Wait for LCD to process the
command
ret ;Return from routine

Now we can do the same thing in C, I am giving example using Keil C. Similar code can
be written for SDCC.
CODE:
#include <AT89X51.H>.
#define LCD_data P2
#define LCD_D7 P2_7
#define LCD_rs P1_0
#define LCD_rw P1_1
#define LCD_en P1_2

void LCD_init()
{
LCD_data = 0x38; //Function set: 2 Line,
8-bit, 5x7 dots
LCD_rs = 0; //Selected command
register
LCD_rw = 0; //We are writing in data
register
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy(); //Wait for LCD to process
the command
LCD_data = 0x0F; //Display on, Curson
blinking command
LCD_rs = 0; //Selected command
register
LCD_rw = 0; //We are writing in data
register
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy(); //Wait for LCD to process
the command
LCD_data = 0x01; //Clear LCD
LCD_rs = 0; //Selected command
register
LCD_rw = 0; //We are writing in data
register
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy(); //Wait for LCD to process
the command
LCD_data = 0x06; //Entry mode, auto
increment with no shift
LCD_rs = 0; //Selected command
register
LCD_rw = 0; //We are writing in data
register
LCD_en = 1; //Enable H->L
LCD_busy();
}

With the help of the above code, you are able to initialize the LCD. Now
there is a function/subroutine coming in the code i.e. LCD_busy, which is
used to put delay for LCD so that there should not be any command or data
sent to the LCD untill it finish executing the command. More on this delay
routine is explained in the next section.
References:
www.embedded.com
www.mobileforcesolutions
www.squared.com
www.newdaedalus.com
www.springerlink.com
www.facebook.com

Potrebbero piacerti anche