relay driver

14
Relay Driver and Power Factor Correction Concept with Application in Micro controllers Source: www.microcontrollerslab.com

Upload: ghufran-hassan

Post on 27-Jul-2015

99 views

Category:

Engineering


0 download

TRANSCRIPT

Page 1: Relay  driver

Relay Driver and Power Factor Correction Concept with

Application in Micro controllers

Source: www.microcontrollerslab.com

Page 2: Relay  driver

What is relay?A relay is electro mechanical switch which is used in industrial application to provide

isolation between high voltage and low voltage circuits. These two circuits have different

voltage rating. One might be a low voltage side and other high voltage side. A relay is

electrical mechanical switch which is used for switching between 5  volt circuits and 220/

120 Volt AC circuits. For example, in microcontrollers based circuits, relay is used to isolate

microcontrollers from 220 volt AC supply.

Components of electro mechanical relay?Electrical mechanical relay have three main components:

1. Coil

2. spring

3. contacts

A five volt signal at the coil can turn on relay. When coil is energize with 5 volt signal,

current flows through the coil. When current flows through the coil, a magnetic field is

created in the coil which attract causes the armature ( contacts) to attract towards spring.

When no current flows through coil, spring causes the contacts to pull towards normal

position. Circuit diagram of electro mechanical relay with components are given below:

how to use relay

In above circuit diagram 5 volt signal is given to coil of electro mechanical relay, when

switch is closed, current flows through the coil and energize the coil. When coil energize

through 5 volt signal, spring attracts contact form normally open position to closed position.

Page 3: Relay  driver

On Left hand side of coil is normally open position of contact. Because circuit is no

complete or in other words current flow path is not complete. When coil is energized with

the help of 5 volt signal, internal spring of electro mechanical relay attract or pulls contact

towards other point and complete the circuit.  A electro mechanical relay can be either

normally open or normally closed. In above circuit diagram, Normally open electro

mechanical relay is used. A voltage required to energize the coil, vary from relay to relay.

Voltage may vary from 5 volt to 50 volt and current may very from mA to 20mA. The relays

also have minimum voltage rating. Its means below voltage rating relay will not operate.

One can check minimum operating voltage o relay in its data sheet. But current

requirements are not specified in date sheets. Coil resistance is usually provided in data

sheet of relay which can be used to find current requirement of relay using Ohm’s law

formula V= IR. After getting basics understanding of relay, now you can understand what is

relay driver and how to use relay driver circuit IC ULN2003?

What is relay driver circuits IC?Relays are used mostly interfaced with microcontrollers and digital systems. But

microcontroller usually can not provide enough current to drive relays. Microcontrollers pins

usually  provide maximum current of 1-2 mA per pin which is not enough o operate relay.

The circuits which are used to derive relays are called relay driver circuits. Therefore Relay

driver circuits using ULN2003 is used to drive relays. There are many other ways to operate

relays. I will also discuss other methods of relay driver circuits in later part of this article.

Why we need to use relay driver circuits?While working on electronics projects which used microcontroller, we need to use relays to

control AC loads or high voltage loads. Relays are used to provide isolation between

microcontrollers circuits and high voltage operating loads. Microcontrollers are only used to

provide on/off signals to relays.  Microcontrollers don’t have enough current sourcing ability

to derive relays. Therefore relay driver circuits IC is used to derive relays properly.  There

are many ways to design relay driver circuits. But dedicated relay driver circuits integrated

circuits are available which serve the purpose of relay driver IC. Relay driver circuit IC

ULN2003 is one of popular realy driver circuits. I will disucss relay driver IC ULN2003 in this

article.  Following types of relay driver circuit IC’s are also available in market:

ULN2003

CS1107

MAX4896

FAN3240

A2550

Page 4: Relay  driver

Relay driver circuit using TransistorRelay driver circuit using NPN transistor is given below. Transistor is used as a switch in

this circuit. Microcontroller provides High or low input signals to NPN transistor. NPN

transistor provide high driving current to electro mechanical relay through 12 volt external

power supply.

relay driver cricuit using transistor

Following  components are used in relay driver circuit using transistor:

Base current limiter resistor R1 = 1K

zener diode of 12 volt used as a free wheeling diode

NPN transistor

12 volt dc power supply

Electro mechanical relay rating depend on your requirement of load

Relay driver circuit using ULN2003ULN2003 is very famous relay driver integrated circuit.  Relay driver IC uln2003 is high

voltage and high current integrated IC which used Darlington array. Its contains seven

Darlington pair of transistor which have high voltage and high current carrying capability. Its

mean ULN3002 can drive up to seven relay at a time. Diode is used with each pair of NPN

Darlington transistor. Diode makes it easily useable with inductive loads.

Page 5: Relay  driver

pin configuration of ULN2003Applications of relay driver IC using ULN2003There are many applications of relay driver circuit using uln2003, but some of famous

applications are given below:

relay drivers circuits

motor drivers circuits

lamp drivers

line drivers

hammer drivers

logic buffers and many others

Diagram of relay driver circuit using uln2003:Relay driver circuit using uln2003 is given below. In this circuit diagram, pic microcontroller

is providing signal to 4 relays through relay driver IC uln2003.

Page 6: Relay  driver

relay driver circuit using uln2003

if we make above circuit diagram using transistors, it will be very difficult to design this

circuit. Single ULN2003 can be easily used int this circuit to drive upto five relays.

Microcontrollers can easily provide high or low signal to relays through its output port D.

Simple programming instructions tells microcontroller to provide either high or low signal to

relays. According to signals provided by microcontroller, ULN2003 IC drive relays.

I have posted a project on green house system in which relay driver circuit using uln2003 is

used to drive four relays. Four relays are connected with four different relays. Check

following link to to know more about practical use of relay driver circuit:

Intelligent green house control system

Stepper motor interfacing using Uln2003While interfacing stepper motor with microcontrollers, relay driver circuit using uln2003 is

also used. Its circuit diagram using pic microcontroller is given below:

Page 7: Relay  driver

stepper motor interfacing with pic microcontroller

Schematic of relay driver circuit using uln2003:Internal circuit diagram of relay driver ic Darlington pairs is given below. Clamped diode is

used as a free wheeling diode to avoid back emf effect in case of inductive loads.

schamtic of darlington pair of transistor in uln2003

Each output pin of ULN2003 provide upto 500mA current and peak current of 600mA. So

this is all about relay driver circuit  using uln2003.

Page 8: Relay  driver

What is power factor?Let’s start with basic introduction of power factor.  Power factor is basically a ration of real

power absorbed by electrical circuit to total appearent power consumed by electrical circuit.

In other words, power factor is a ratio of real power and appearent power. Many inductive

loads are used in power system. Inductive loads need reactive power for their proper

operation. So main cause of power factor in electrical power system is reactance.

Capacitors provide reactive power. In other words, capacitors generate reactive power and

inductors consume reactive power.

Why we need to improve power factor?Reactive power is basically a burn on power system and transmission lines. Reactive power

travel back and forth from power generation point to load and hence a lost of electrical

energy. Now a days inductive loads are used in domestic as well as industrial applications.

Low power factor cause losses in transmission line and voltage drops in transmission lines.

Need of electrical power is increasing day by day, so can’t afford to waste power in

transmission line. Therefore we need to improve power factor of electrical power system

and loads. By providing  reactive power locally at the load side, we can increase power

factor of system and power factor of machines. Hence Power factor improvement is local

issue.  As I have already mentioned, capacitors are source of reactive power. So capacitors

can be used to improve power factor or to provide reactive power to load locally instead of

from power generations ends.

How to improve power factor:Before understanding what is power factor? Let me tell you what is good power factor?

Unity is ideal power factor. Resistive loads have unity power factor. But all electrical loads

are not fully resistive. Therefore we need to improve power factor of these load. Power

factor can be increased by adding power factor correction capacitor to loads. Capacitors

provide reactive power to load locally . There are many methods have been developed for

power factor improvement. But in this article, you will learn about power factor

measurement and correction using microcontroller.

Advantages of power factor improvement?Major advantages of power  factor improvement are given below:

It reduces the losses in transmission lines and cables

It reduces the voltage drop in transmission lines and cables

It reduces the burden on power generation utility companies

Page 9: Relay  driver

Power factor measurement using pic microcontroller:Power factor is basically due to lag and lead concept of current and voltage. When current

waveform lags behinds the voltage by some angle, power factor will be lagging and when

current wave form leads the voltage by some angle, power factor will be leading. Inductor

causes a lagging power factor and capacitors produces leading power factor. Hence

capacitors improve power factor by providing leading VARS or reactive power to system

which cancels the lagging power factor effect of inductors.

Now the question is how to measure power factor using microcontroller? To measure power

factor we need to measure phase angle difference between voltage and current wave form.

The cosine of this phase angle is power factor. Power factor is also represented by

following formula:

Power factor = Cos (θ)

Where θ is basically phase angle difference between voltage and current wave form. So we

need to develop a method to measure phase angle difference between voltage and current

wave form. I have used zero crossing detection concept to measure time difference

between current and voltage wave form. Time difference between two signal or waves can

also be used to measure power factor. I will discuss more about it in later part of this article.

Now let’s proceed further with zero crossing detection?What is zero crossing detection?Zero crossing detection is used to detect sine wave zero crossing from positive half cycle to

negative half cycle  or negative half cycle. To measure time difference between two waves

we need to detect zero crossing of two waves. There are many methods available to

measure zero crossing detection. But I have already posted an article on zero crossing

detection using pic microcontroller. I have explained zero crossing detection concept in

following article. So I recommend you to read following article first before reading further.

How to detect zero crossing using pic microcontrollerI  assume that After reading an article on zero crossing detection, you got the idea about

how to detect zero crossing of sine waves using pic microcontroller. In zero power factor

measurement circuit, two zero crossing detection circuits are used. One for voltage wave

form and other for current wave form. After detecting zero crossing for voltage wave and

sine wave we need to measure time difference between zero crossing of voltage and

current wave forms.

Page 10: Relay  driver

How to measure time difference two wave for power factor measurement: Now I will discuss how to measure time difference between two waves. It is very easy to

measure time difference between two waves with the help of hardware external interrupt pin

of microcontroller. hardware interrupt is used to detect zero crossing signal. Microcontroller

internal timer is used to measure time. When external interrupt occur on microcontroller pin

time will start and after another external interrupt time will stop counting. One interrupt will

be generated with the help of current signal and other interrupt with the help voltage signal

zero crossing. Timer value will be stored in one variable. This variable value is basically a

time difference between two waves. For better results take 20-30 values and take their

average.

How to find angel using time difference:So using time difference we can easily calculate phase angle using below given formula’s :

 Time difference = average values of timer /1000 ;

In above equation 1000 is used to convert time into seconds because half of the sine wave

is about 10us and there will 1000 counts per second.

θ = time difference *  2π;

Power factor = Cos ( θ ) ;

After that time difference is multiplied with  2π to convert it into radians and phase angle in

radians. After that by using power factor formula we can easily calculate power factor.  All

these calculations are done in programming by writing a code in microcontroller.

Power factor measurement circuit using pic microcontroller:Circuit diagram of power factor measurement circuit using pic microcontroller is given

below.  Voltage transformer and current transformer is used in power factor measurement

circuit.

Page 11: Relay  driver

power factor measurement circuit using pic microcontroller

In above circuit diagram. voltage transformer is used to step down voltage. Because

microcontroller can not read high voltage 220v AC directly. Current transformer is used to

get wave form of current wave. magnitude of current depend on the load and voltage almost

remains constant. After that these signals are fed to zero crossing detector circuit using

LM358 operational amplifier. I have already posted an article on zero crossing detection

using operational amplifier. For more information about zero crossing detector circuit check

following article:

Zero crossing detection using op ampMicrocontroller PIC16F877A read zero crossings of voltage and current waveform and start

timer according to zero crossing detection of current and voltage wave form. PC16F877A

microcontroller is main part of this project. In reads zero crossing detection. measures time

difference and calulate power factor according to above given formula’s.After calculating

power factor, PIC16F877A microcontroller displays it on 16 X2 LCD.

List of components for power measurement circuit:List of components for power measurement circuit using pic microcontroller is given below:

Category,Reference,Value,Order Code

Resistors,"R1",2k,

Resistors,"R2",4k,

Resistors,"R3",4k,

Resistors,"R4",4k,

Page 12: Relay  driver

Resistors,"R5",4k,

Integrated Circuits,"U1",PIC16F877A,

Integrated Circuits,"U2",LM358,

Miscellaneous,"AC SOURCE",,

Miscellaneous,"CURRENT TRANSFORMER" It can be wind according to requirement,

Miscellaneous,"POTENTIAL TRANSFORMER" 220V AC to 12V AC step down transformer,

Liquid crystal display: ,"LCD1",LM016L,

Variable resistor: ,"RV1",10k,

This guide has provided you all the information you need to measure power factor. I have

tried to cover a question on ” How to measure power factor using microcontroller. I

recommend you to write your own code for this project.