Sei sulla pagina 1di 45

CHAPTER 5 HARDWARE IMPLEMENTATION

5.1 INTRODUCTION
The power factor of an AC electric power system is defined as the ratio of the real power to the apparent power, and is a number between 0 to 1 inclusive. Real power is the capacity of the circuit for performing work in a particular time. Apparent power is the product of the current and voltage of the circuit. Due to energy stored in the load and returned to the source, or due to a non-linear load that distorts the wave shape of the current drawn from the source, the apparent power will be equal to or greater than the real power. Low power factor loads increase losses in a power distribution system and results in increased cost for electrical energy use. In a purely resistive AC circuit, voltage and current waveforms are in step, changing polarity at the same instant in each cycle. Where reactive loads are present, such as with capacitors or inductors, energy storage in the loads result in a time difference between the current and voltage waveforms. This stored energy returns to the source and is not available to do work at the load. A circuit with a low power factor will have thus higher currents to transfer at a given quantity of power than a circuit with a high power factor.

26

5.2 BLOCK DIAGRAM

Fig 5.1 Block diagram The hardware components used in this project are Step down transformer Rectifier Boost converter Potential Transformer Current Transformer Zero Crossing Detector (ZCD) Mosfet Driver PIC Micro controller 27

5.3 STEP DOWN TRANSFORMER

Fig 5.2 Step down transformer The potential transformer will step down the power supply voltage (0-230V) to (0-6V) level. Then the secondary of the potential transformer will be connected to the precision rectifier, which is constructed with the help of opamp. The advantages of using precision rectifier are it will give peak voltage output as DC, rest of the circuits will give only RMS output.

5.4 RECTIFIER

Fig 5.3 Rectifier circuit When four diodes are connected as shown in figure, the circuit is called as bridge rectifier. The input to the circuit is applied to the diagonally opposite corners of the network, and the output is taken from the remaining two corners. 28

Let us assume that the transformer is working properly and there is a positive potential, at point A and a negative potential at point B. the positive potential at point A will forward bias D3 and reverse bias D4. The negative potential at point B will forward bias D1 and reverse D2. At this time D3 and D1 are forward biased and will allow current flow to pass through them; D4 and D2 are reverse biased and will block current flow. The path for current flow is from point B through D1, up through RL, through D3, through the secondary of the transformer back to point B. this path is indicated by the solid arrows. Waveforms (1) and (2) can be observed across D1 and D3. One-half cycle later the polarity across the secondary of the transformer reverse, forward biasing D2 and D4 and reverse biasing D1 and D3. Current flow will now be from point A through D4, up through RL, through D2, through the secondary of T1, and back to point A. This path is indicated by the broken arrows. Waveforms (3) and (4) can be observed across D2 and D4. The current flow through RL is always in the same direction. In flowing through RL this current develops a voltage corresponding to that shown waveform (5). Since current flows through the load (RL) during both half cycles of the applied voltage, this bridge rectifier is a fullwave rectifier. One advantage of a bridge rectifier over a conventional full-wave rectifier is that with a given transformer the bridge rectifier produces a voltage output that is nearly twice that of the conventional full-wave circuit. This may be shown by assigning values to some of the components shown in views A and B. assume that the same transformer is used in both circuits. The peak voltage developed between points X and y is 1000 volts in both circuits. In the conventional full-wave circuit shownin view A, the peak voltage from the center tap to either X or Y is 500 volts. Since only one diode can conduct at any instant, the maximum voltage that can be rectified at any instant is 500 volts.

29

The maximum voltage that appears across the load resistor is nearly-but never exceeds500 v0lts, as result of the small voltage drop across the diode. In the bridge rectifier shown in view B, the maximum voltage that can be rectified is the full secondary voltage, which is 1000 volts. Therefore, the peak output voltage across the load resistor is nearly 1000 volts. With both circuits using the same transformer, the bridge rectifier circuit produces a higher output voltage than the conventional full-wave rectifier circuit.

5.5 BOOST CONVERTER

Fig 5.4 Boost converter

30

The boost converter converts an input voltage to a higher output voltage. The boost converter is also called a step-up converter. Boost converters are used in battery powered devices, where the electronic circuit requires a higher operating voltage than the battery can supply, e.g. notebooks, mobile phones and camera-flashes.

5.6 POTENTIAL TRANSFORMER


A transformer is a device that transfers electrical energy from one circuit to another through inductively coupled conductorsthe transformer's coils. A varying current in the first or primary winding creates a varying magnetic flux in the transformer's core and thus a varying magnetic fieldthrough the secondary winding. This varying magnetic field induces a varying electromotive force (EMF), or "voltage", in the secondary winding. This effect is called inductive coupling. If a load is connected to the secondary, current will flow in the secondary winding, and electrical energy will be transferred from the primary circuit through the transformer to the load. In an ideal transformer, the induced voltage in the secondary winding (Vs) is in proportion to the primary voltage (Vp) and is given by the ratio of the number of turns in the secondary (Ns) to the number of turns in the primary (Np) as follows:

By appropriate selection of the ratio of turns, a transformer thus enables an alternating current (AC) voltage to be "stepped up" by making Ns greater than Np, or "stepped down" by making Nsless than Np. In the vast majority of transformers, the windings are coils wound around a ferromagnetic core, air-core transformers being a notable exception.

31

Transformers range in size from a thumbnail-sized coupling transformer hidden inside a stage microphone to huge units weighing hundreds of tons used to interconnect portions of power grids. All operate on the same basic principles, although the range of designs is wide. While new technologies have eliminated the need for transformers in some electronic circuits, transformers are still found in nearly all electronic devices designed for household ("mains") voltage. Transformers are essential for high-voltage electric power transmission, which makes long-distance transmission economically practical.

5.7 CURRENT TRANSFORMER


In electrical engineering, a current transformer (CT) is used for measurement of electric currents. Current transformers, together with voltage transformers (VT) (potential transformers (PT), are known as instrument transformers. When current in a circuit is too high to directly apply to measuring instruments, a current transformer produces a reduced current accurately proportional to the current in the circuit, which can be conveniently connected to measuring and recording instruments. A current transformer also isolates the measuring instruments from what may be very high voltage in the monitored circuit. Current transformers are commonly used in metering and protective relays in the electrical power industry. Current transformers are used extensively for measuring current and monitoring the operation of the power grid. Along with voltage leads, revenue-grade CTs drive the electrical utility's watt-hour meter on virtually every building with three-phase service and single-phase

services greater than 200 amps. The CT is typically described by its current ratio from primary to secondary. Often, multiple CTs are installed as a "stack" for various uses. For example, protection devices and revenue metering may use separate CTs to provide isolation between metering and protection circuits, and allows current transformers with different characteristics (accuracy, overload performance) to be used for the devices.

32

5.8 ZERO CROSSING DETECTOR

Fig 5.5 Zero Crossing Detector

A zero crossing detector is a comparator with the reference level set at zero. It is used for detecting the zero crossings of AC signals. It can be made from an operational amplifier with an input voltage at its positive input When the input voltage is positive, the output voltage is a positive value, when the input voltage is negative, the output voltage is a negative value. The magnitude of the output voltage is a property of the operational amplifier and its power supply. Applications include converting an analog signal into a form suitable to use for frequency measurements, in phase locked loops, or for controlling power electronics circuits that must switch with a defined relationship to an alternating current waveform. This detector exploits the property that the instantaneous frequency of an FM wave is approximately given by

where

is the time difference between adjacent zero crossings of FM wave

33

5.9 MOSFET DRIVER CIRCUIT

Fig 5.6 MOSFET driver circuit The metal-oxide-semiconductor field-effect transistor (MOSFET, MOS-FET, or MOS FET), is by far the most common field-effect transistor in both digital and analog circuits. The MOSFET is composed of a channel of n-type or p-type semiconductor material (see article on semiconductor devices), and is accordingly called an NMOSFET or a PMOSFET (also commonly nMOSFET, pMOSFET, NMOS FET, PMOS FET, nMOS FET, pMOS FET). The 'metal' in the name (for transistors up to the 65 nanometer technology node) is an anachronism from early chips in which the gates were metal; They use polysilicon gates. IGFET is a related, more general term meaning insulated-gate field-effect transistor, and is almost synonymous with "MOSFET", though it can refer to FETs with a gate insulator that is not oxide. Some prefer to use "IGFET" when referring to devices with polysilicon gates, but most still call them MOSFETs. With the new generation of high-k technology that Intel and IBM have announced [1], metal gates in conjunction with the high-k dielectric material replacing the silicon dioxide are making a comeback replacing the polysilicon.

34

Usually the semiconductor of choice is silicon, but some chip manufacturers, most notably IBM, have begun to use a mixture of silicon and germanium (SiGe) in MOSFET channels. Unfortunately, many semiconductors with better electrical properties than silicon, such as gallium arsenide, do not form good gate oxides and thus are not suitable for MOSFETs. The gate terminal in the current generation (65 nanometer node) of MOSFETs is a layer of polysilicon (polycrystalline silicon; why polysilicon is used will be explained below) placed over the channel, but separated from the channel by a thin insulating layer of what was traditionally silicon dioxide, but more advanced technologies used silicon oxynitride. The next generation (45 nanometer and beyond) uses a high-k + metal gate combination. When a voltage is applied between the gate and source terminals, the electric field generated penetrates through the oxide and creates a so-called "inversion channel" in the channel underneath. The inversion channel is of the same type P-type or N-type as the source and drain, so it provides a conduit through which current can pass. Varying the voltage between the gate and body modulates the conductivity of this layer and makes it possible to control the current flow between drain and source

5.10 MICROCONTROLLER 5.10.1 INTRODUCTION TO MICROCONTROLLER


Microcontrollers are destined to play an increasingly important role in revolutionizing various industries and influencing our day to day life more strongly than one can imagine. Since its emergence in the early 1980's the microcontroller has been recognized as a general purpose building block for intelligent digital systems. It is finding using diverse area, starting from simple children's toys to highly complex spacecraft. Because of its versatility and many advantages, the application domain has spread in all conceivable directions, making it ubiquitous.

35

As a consequence, it has generate a great deal of interest and enthusiasm among students, teachers and practicing engineers, creating an acute education need for imparting the knowledge of microcontroller based system design and development. It identifies the vital features responsible for their tremendous impact, the acute educational need created by them and provides a glimpse of the major application area.

5.10.2 MICROCONTROLLER
A microcontroller is a complete microprocessor system built on a single IC. Microcontrollers were developed to meet a need for microprocessors to be put into low cost products. Building a complete microprocessor system on a single chip substantially reduces the cost of building simple products, which use the microprocessor's power to implement their function, because the microprocessor is a natural way to implement many products. This means the idea of using a microprocessor for low cost products comes up often. But the typical 8-bit microprocessor based system, such as one using a Z80 and 8085 is expensive. Both 8085 and Z80 system need some additional circuits to make a microprocessor system. Each part carries costs of money. Even though a product design may requires only very simple system, the parts needed to make this system as a low cost product. To solve this problem microprocessor system is implemented with a single chip microcontroller. This could be called microcomputer, as all the major parts are in the IC. Most frequently they are called microcontroller because they are used they are used to perform control functions. The microcontroller contains full implementation of a standard MICROPROCESSOR, ROM, RAM, I/0, CLOCK, TIMERS, and also SERIAL PORTS. Microcontroller also called "system on a chip" or "single chip microprocessor system" or "computer on a chip".

36

A microcontroller is a Computer-On-A-Chip, or, if you prefer, a single-chip computer. Micro suggests that the device is small, and controller tells you that the device' might be used to control objects, processes, or events. Another term to describe a microcontroller is embedded controller, because the microcontroller and its support circuits are often built into, or embedded in, the devices they control. Today microcontrollers are very commonly used in wide variety of intelligent products. For example most personal computers keyboards and implemented with a microcontroller. It replaces Scanning, Debounce, Matrix Decoding, and Serial transmission circuits. Many low cost products, such as Toys, Electric Drills, Microwave Ovens, VCR and a host of other consumer and industrial products are based on microcontrollers.

5.10.3 EVOLUTION OF MICROCONTROROLLER


Markets for microcontrollers can run into millions of units per application. At these volumes of the microcontrollers is a commodity items and must be optimized so that cost is at a minimum. .Semiconductor manufacturers have produced a mind-numbing array of designs that would seem to meet almost any need. Some of the chips listed in this section are no longer regular production, most are current, and a few are best termed as "smoke ware": the dreams of an aggressive marketing department.

5.10.4 APPLICATION
A microcontroller is a kind of miniature computer that you can find in all kinds of Gizmos. Some examples of common, every-day products that have microcontrollers are built-in. If it has buttons and a digital display, chances are it also has a programmable microcontroller brain. Every-Day the devices used by ourselves that contain Microcontrollers. Try to make a list and counting how many devices and the events with microcontrollers you use in a typical day.

37

Here are some examples: if your clock radio goes off, and you hit the snooze button a few times in the morning, the first thing you do in your day is interact with a microcontroller. Heating up some food in the microwave oven and making a call on a cell phone also involve operating microcontrollers. That's just the beginning. Here are a few more examples: Turning on the Television with a handheld remote, playing a hand held game, Using a calculator, and Checking your digital wrist watch. All those devices have microcontrollers inside them, that interact with you. Consumer appliances aren't the only things that contain microcontrollers. Robots, machinery, aerospace designs and other hightech devices are also built with microcontrollers.

5.10.5 BLOCK DIAGRAM OF MICROCONTROLLER

Fig 5.7 Block Diagram Of Microcontroller

38

5.10.6 PIC
The microcontroller that has been used for this project is from PIC series. PIC microcontroller is the first RISC based microcontroller fabricated in CMOS (complimentary metal oxide semiconductor) that uses separate bus for instruction and data allowing simultaneous access of program and data memory. The main advantage of CMOS and RISC combination is low power consumption resulting in a very small chip size with a small pin count. The main advantage of CMOS is that it has immunity to noise than other fabrication techniques. Various microcontrollers offer different kinds of memories. EEPROM, EPROM, FLASH etc. are some of the memories of which FLASH is the most recently developed. Technology that is used in pic16F877 is flash technology, so that data is retained even when the power is switched off. Easy Programming and Erasing are other features of PIC 16F877.

5.10.7 CORE FEATURES:


High-performance RISC CPU Only 35 single word instructions to learn All single cycle instructions except for program branches which are two cycle Operating speed: DC - 20 MHz clock input DC - 200 ns instruction cycle Up to 8K x 14 words of Flash Program Memory, Up to 368 x 8 bytes of Data Memory (RAM) Up to 256 x 8 bytes of EEPROM data memory Pin out compatible to the PIC16C73/74/76/77 39

Interrupt capability (up to 14 internal/external Eight level deep hardware stack Direct, indirect, and relative addressing modes Power-on Reset (POR) Power-up Timer (PWRT) and Oscillator Start-up Timer (OST) Watchdog Timer (WDT) with its own on-chip RC Oscillator for reliable operation Programmable code-protection Power saving SLEEP mode Selectable oscillator options Low-power, high-speed CMOS EPROM/EEPROM technology Fully static design In-Circuit Serial Programming (ICSP) via two pins Only single 5V source needed for programming capability In-Circuit Debugging via two pins Processor read/write access to program memory Wide operating voltage range: 2.5V to 5.5V High Sink/Source Current: 25 mA Commercial and Industrial temperature ranges

40

Low-power consumption: < 2mA typical @ 5V, 4 MHz 20mA typical @ 3V, 32 kHz < 1mA typical standby current

5.10.8 PERIPHERAL FEATURES:


Timer0: 8-bit timer/counter with 8-bit prescaler Timer1: 16-bit timer/counter with prescaler, can be incremented during sleep Via external crystal/clock Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler

Two Capture, Compare, PWM modules Capture is 16-bit, max resolution is 12.5 ns, Compare is 16-bit, max resolution is 200 ns, PWM max. Resolution is 10-bit 10-bit multi-channel Analog-to-Digital converter Synchronous Serial Port (SSP) with SPI. (Master Mode) and I2C. (Master/Slave) Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) with 9- Bit addresses detection. Brown-out detection circuitry for Brown-out Reset (BOR)

41

5.10.9 ARCHITECTURE OF PIC 16F877:

The complete architecture of PIC 16F877 is shown in the fig 2.1. Table 2.1 gives details about the specifications of PIC 16F877. Fig 2.2 shows the complete pin diagram of the IC PIC 16F877.

Fig 5.8 Architecture Of Pic 16f877 42

5.10.10 PIN DIAGRAM OF PIC 16F877

Fig 5.9 Pin Diagram Of PIC 16F877

43

PIN OUT DESCRIPTION

44

Table 5.1 PIN OUT Description Legend: I = input O = output I/O = input/output P = power = Not used TTL = TTL input ST = Schmitt Trigger input 1. This buffer is a Schmitt Trigger input when configured as an external interrupt. 2. This buffer is a Schmitt Trigger input when used in serial programming mode. 3. This buffer is a Schmitt Trigger input when configured as general purpose I/O and input when used in the Parallel Slave Port mode (for interfacing to a microprocessor bus). a TTL

45

5.10.11 I/O PORTS:


Some pins for these I/O ports are multiplexed with an alternate function for the peripheral features on the device. In general, when a peripheral is enabled, that pin may not be used as a general purpose I/O pin. Additional Information on I/O ports may be found in the IC micro Mid-Range Reference Manual, PORTA AND THE TRISA REGISTER: PORTA is a 6-bit wide bi-directional port. The corresponding data direction register is TRISA. Setting a TRISA bit (=1) will make the corresponding PORTA pin an input, i.e., put the corresponding output driver in a Hi-impedance mode. Clearing a TRISA bit (=0) will make the corresponding PORTA pin an output, i.e., put the contents of the output latch on the selected pin. PORTB AND TRISB REGISTER: PORTB is an 8-bit wide bi-directional port. The corresponding data direction register is TRISB. Setting a TRISB bit (=1) will make the corresponding PORTB pin an input, i.e., put the corresponding output driver in a hi-impedance mode. Clearing a TRISB bit (=0) will make the corresponding PORTB pin an output, i.e., put the contents of the output latch on the selected pin. Three pins of PORTB are multiplexed with the Low Voltage Programming function; RB3/PGM, RB6/PGC and RB7/PGD. The alternate functions of these pins are described in the Special Features Section. Each of the PORTB pins has a weak internal pull-up. A single control bit can turn on all the pull-ups. This is performed by clearing bit RBPU (OPTION_REG<7>). The weak pull-up is automatically turned off when the port pin is configured as an output. The pull-ups are disabled on a Power-on Reset.

46

PORTC AND THE TRISC REGISTER: PORTC is an 8-bit wide bi-directional port. The corresponding data direction register is TRISC. Setting a TRISC bit (=1) will make the corresponding PORTC pin an input, i.e., put the corresponding output driver in a hi-impedance mode. Clearing a TRISC bit (=0) will make the corresponding PORTC pin an output, i.e., put the contents of the output latch on the selected pin. PORTC is multiplexed with several peripheral functions. PORTC pins have Schmitt Trigger input buffers. PORTD AND TRISD REGISTERS: This section is not applicable to the 28-pin devices. PORTD is an 8-bit port with Schmitt Trigger input buffers. Each pin is individually configurable as an input or output. PORTD can be configured as an 8-bit wide microprocessor Port (parallel slave port) by setting control bit PSPMODE (TRISE<4>). In this mode, the input buffers are TTL. PORTE AND TRISE REGISTER: PORTE has three pins RE0/RD/AN5, RE1/WR/AN6 and RE2/CS/AN7, which are individually configurable as inputs or outputs. These pins have Schmitt Trigger input buffers. The PORTE pins become control inputs for the microprocessor port when bit PSPMODE (TRISE<4>) is set. In this mode, the user must make sure that the TRISE<2:0> bits are set (pins are configured as digital inputs). Ensure ADCON1 is configured for digital I/O. In this mode the input buffers are TTL. PORTE pins are multiplexed with analog inputs. When selected as an analog input, these pins will read as '0's. TRISE controls the direction of the RE pins, even when they are being used as analog inputs. The user must make sure to keep the pins configured as inputs when using them as analog inputs.

47

5.10.12 MEMORY ORGANISATION:


There are three memory blocks in each of the PIC16F877 MUCs. The program memory and Data Memory have separate buses so that concurrent access can occur.

5.10.13 PROGRAM MEMORY ORGANISATION:


The PIC16f877 devices have a 13-bit program counter capable of addressing 8K *14 words of FLASH program memory. Accessing a location above the physically implemented address will cause a wraparound. The RESET vector is at 0000h and the interrupt vector is at 0004h.

5.10.14 DATA MEMORY ORGANISTION:


The data memory is partitioned into multiple banks which contain the General Purpose Registers and the special functions Registers. Bits RP1 (STATUS<6) and RP0 (STATUS<5>) are the bank selected bits.

RP1:RP0 00 01 10 11

Banks 0 1 2 3

Table 5.2 Bank selection

48

Each bank extends up to 7Fh (1238 bytes). The lower locations of each bank are reserved for the Special Function Registers. Above the Special Function Registers are General Purpose Registers, implemented as static RAM. All implemented banks contain special function registers. Some frequently used special function registers from one bank may be mirrored in another bank for code reduction and quicker access.

EEPROM: EEPROM (electrically erasable, programmable read only memory) technology supplies Nonvolatile storage of variables to a PIC-controlled device or instrument. That is variables stored in an EEPROM will remain there even after power has been turned off and then on again. Some instruments use an EEPROM to store calibration data during manufacture. In this way, each instrument is actually custom built, with customization that can be easily automated. Other instruments use and EEPROM For an instrument to allow a user to store several sets of setup information.

requiring a complicated setup procedure, this permits a user to retrieve the

setup required for any one of several very Different measurements. Still other devices use an EEPROM in a way that is transparent to a user, providing backup of setup parameters and thereby bridging over power outages. The data EEPROM and flash program memory are readable and writable during normal operation over the entire VDD range. A bulk erase operation may not be issued from user code (which includes removing code protection. The data memory is not directly mapped in the register file space. Instead it is indirectly addressed through the special function registers (SFR). There are six SFRS used to read and write the program and data EEPROM memory.

49

These registers are:

EECON1 EECON2 EEDATA EEDATH EEADR EEADRH EEDATA holds the 8-bit data for read/write and EEADRR holds the address of the EEPROM location being accessed. The 8-bit EEADR register can access up to 256 locations of data EEPROM. The EEADR register can be thought of as the indirect addressing register of the data EEPROM. EEcon1 contains the control bits, while eecon2 is the register used to initiate the read/write. The EEPROM data memory allows bytes read and write. A byte write automatically erases the location and writes the new data. The write time is controlled by timer in-built.

5.10.15 TIMERS
There are three timers used Timer 0, Timer1 and Timer2 Timer 0 8-bit timer/counter Software programmable prescaler Internal or external clock select Readable writable Interrupt on overflow 50

Timer 1 Timer 1 can be used as timer or counter It is 16-bit register Software programmable prescaler Interrupt on overflow Readable and writable The timer-1 module is a 16-bit timer/counter consisting two 8-bit register (TMR1H) and TMR1L), which are readable and writable. The TMR1 register pair (TMR1H:TMR1L) Increments from 0000h to FFFFH and rolls over to 0000h. The tmr1 interrupt, if enabled, is generated on overflow, which is latched in interrupt flag bit tmr1IF. This interrupt can be enabled/disabled by setting/clearing tmr1 interrupt enable bit tmr1IE.

Timer-2 Timer2 is an 8-bit timer with a prescaler and a postscaler. IT can be used as the PWM Time-base for the PWM mode of the CCP module(s). The TMR2 register is readable and writable, and is cleared on any device reset. The input clock (Fosc/4) has a prescale option of 1:1, 1:4 OR 1:16, selected by control bits. The timer2 module has an 8-bit period register PR2. Timer2 increments from 00h until it match PR2 and then resets to 00h on the next increment cycle. PR2 is a readable and writable register. The PR2 register is initialized to FFh upon reset. 51

The match output of TMR2 goes through a 4-bit postscaler (which gives a 1:1 to 1:16 scaling inclusive) to generate a tmr2 interrupt Timer 2 can be shut off by clearing control bit tmr2on to minimize power consumption. The prescaler and postscaler counters are cleared when any of the following occurs: A write to the tmr2 register A write to the t2con register An any device reset Tmr2 is not cleared when t2con is written

5.10.16 ANALOG TO DIGITAL CONVERTER (ADC)


There are two types of analog to digital converter is present in this IC. We use 10-bit ADC. The ADC module can have up to eight analog inputs for a device. The analog input charges a sample and hold capacitor. The output of sample and hold capacitor is the input into the converter. The converter then generates a digital result of this analog level via successive approximation. The A/D conversion of the analog input signal results in a corresponding10-bit digital number. The A/D module has high and low voltage reference input that is software selectable to some combination of VDD, VSS, and RA2 or RA3. The A/D module has four registers. These registers are A/D result high register (ADRESH) A/D RESULT LOW REGISTER (ADRESL) A/D CONTROL REGISTER 0 (ADCON0) A/D CONTROL REGISTER 1 (ADCON1)

52

5.10.17 INTERRUPTS
The PIC16F87X FAMILY HAS UPTO 14 SOURCES OF INTERRUPT. The interrupt control register (INTCON) records individual interrupt requests in flag bits. IT also has

individual interrupt requests in flag bits. IT also has individual and global interrupt enables bits. Though some modules may generate multiple interrupts such as (USART) They have 14 sources. There is a minimum of one register used in the control and status of the interrupts. INTCON Additionally if the device has peripheral interrupts, then it will have registers to enable the peripheral interrupts and registers to hold the interrupt flag bits PIE1 PIE2 PIR1 PIR2

5.10.18 ADDRESSING MODES:


DIRECT ADDRESSING: In direct addressing, the operand specified by an 8-bit address field in the instruction. Only internal data RAM and SFRs can be directly addressed. INDIRECT ADDRESSING: In Indirect addressing, the instruction specifies a register that contains the address of the operand. Both internal and external RAM can indirectly address. The address register for 8-bit addresses can be either the Stack Pointer or R0 or R1 of the selected register Bank. The address register for 16-bit addresses can be only the 16-bit data pointer register, DPTR.

53

INDEXED ADDRESSING: Program memory can only be accessed via indexed addressing this addressing mode is intended for reading look-up tables in program memory. A 16 bit base register (Either DPTR or the Program Counter) points to the base of the table, and the accumulator is set up with the table entry number. Adding the Accumulator data to the base pointer forms the address of the table entry in program memory. Another type of indexed addressing is used in the case jump instructions. In this case the destination address of a jump instruction is computed as the sum of the base pointer and the Accumulator data. REGISTER INSTRUCTION: The register banks, which contains registers R0 through R7, can be accessed by instructions whose opcodes carry a 3-bit register specification. Instructions that access the registers this way make efficient use of code, since this mode eliminates an address byte. When the instruction is executed, one of four banks is selected at execution time by the row bank select bits in PSW.

REGISTER - SPECIFIC INSTRUCTION: Some Instructions are specific to a certain register. For example some instruction always operates on the Accumulator, so no address byte is needed to point OT ir. In these cases, the opcode itself points to the correct register. Instruction that register to Accumulator as A assemble as Accumulator - specific Opcodes. IMMEDIATE CONSTANTS: The value of a constant can follow the opcode in program memory For example. MOV A, #100 loads the Accumulator with the decimal number 100. The same number could be specified in hex digit as 64h. 54

5.10.19 OSCILLATOR AND CLOCK CIRCUIT:


XTAL1 and XTAL2 are the input and output respectively of an inverting amplifier which is intended for use as a crystal oscillator in the pioerce configuration, in the frequency range of 1.2 Mhz to 12 Mhz. XTAL2 also the input to the internal clock generator. To drive the chip with an internal oscillator, one would ground XTAL1 and XTAL2. Since the input to the clock generator is divide by two filip flop there are no requirements on the duty cycle of the external oscillator signal. However, minimum high and low times must be observed. The clock generator divides the oscillator frequency by 2 and provides a tow phase clock signal to the chip. The phase 1 signal is active during the first half to each clock period and the phase 2 signals are active during the second half of each clock period.

5.10.20 CPU TIMING:


A machine cycle consists of 6 states. Each stare is divided into a phase / half, during which the phase 1 clock is active and phase 2 half. Arithmetic and Logical operations take place during phase1 and internal register - to register transfer take place during phase 2

5.10.21 TRENDS AND DEVELOPMENTS IN MICRO CONTROLLER


The manner in which the use of micro controllers is shaping our lives is breathtaking. Today, this versatile device can be found in a variety of control applications. CVTs, VCRs, CD players, microwave ovens, and automotive engine systems are some of these. A micro controller unit (MCU) uses the microprocessor as its central processing unit (CPU) and incorporates memory, timing reference, I/O peripherals, etc on the same chip. Limited computational capabilities and enhanced I/O are special features.

55

The micro controller is the most essential IC for continuous process- based applications in industries like chemical, refinery, pharmaceutical automobile, steel, and electrical, employing programmable logic systems (DCS). PLC and DCS thrive on the programmability of an MCU. There are many MCU manufacturers. To understand and apply general concepts, it is necessary to study one type in detail. This specific knowledge can be used to understand similar features of other MCUs. Micro controller devices have many similarities. When you look at the differences, they are not so great either. Most common and popular MCUs are considered to be mature and wellestablished products, which have their individual adherents and devotees. There are a number of variants within each family to satisfy most memory, I/O, data conversion, and timing needs of enduser applications. The MCU is designed to operate on application-oriented sensor data-for example, temperature and pressure of a blast furnace in an industrial process that is fed through its serial or operated on under the control of software and stored in ROM. Appropriate signals are fed via output ports to control external devices and systems.

5.10.22 APPLICATIONS OF MICROCONTROLLERS


Microcontrollers are designed for use in sophisticated real time applications such as 1. Industrial Control 2. Instrumentation and 3. Intelligent computer peripherals They are used in industrial applications to control Motor Robotics Discrete and continuous process control

56

In missile guidance and control In medical instrumentation Oscilloscopes Telecommunication Automobiles For Scanning a keyboard Driving an LCD

5.11 LIQUID CRYSTAL DISPLAY (LCD)


Liquid crystal displays (LCDs) have materials, which combine the properties of both liquids and crystals. Rather than having a melting point, they have a temperature range within which the molecules are almost as mobile as they would be in a liquid, but are grouped together in an ordered form similar to a crystal. An LCD consists of two glass panels, with the liquid crystal material sand witched in between them. The inner surface of the glass plates are coated with transparent electrodes which define the character, symbols or patterns to be displayed polymeric layers are present in between the electrodes and the liquid crystal, which makes the liquid crystal molecules to maintain a defined orientation angle. One each polarizes are pasted outside the two glass panels. These polarizes would rotate the light rays passing through them to a definite angle, in a particular direction. When the LCD is in the off state, light rays are rotated by the two polarizes and the liquid crystal, such that the light rays come out of the LCD without any orientation, and hence the LCD appears transparent. When sufficient voltage is applied to the electrodes, the liquid crystal molecules would be aligned in a specific direction. The light rays passing through the LCD would be rotated by the polarizes, which would result in activating / highlighting the desired characters.

57

The LCDs are lightweight with only a few millimeters thickness. The LCD does not generate light and so light is needed to read the display. By using backlighting, reading is possible in the dark. The LCDs have long life and a wide operating temperature range. Changing the display size or the layout size is relatively simple which makes the LCDs more customers friendly. The LCDs used exclusively in watches, calculators and measuring instruments are the simple seven-segment displays, having a limited amount of numeric data. The recent advances in technology have resulted in better legibility, more information displaying capability and a wider temperature range. These have resulted in the LCDs being extensively used in telecommunications and entertainment electronics. The LCDs have even started replacing the cathode ray tubes (CRTs) used for the display of text and graphics, and also in small TV applications. Crystalonics dotmatrix (alphanumeric) liquid crystal displays are available in TN, STN types, with or without backlight. The use of C-MOS LCD controller and driver ICs result in low power consumption. These modules can be interfaced with a 4-bit or 8-bit microprocessor /Micro controller. The built-in controller IC has the following features: Correspond to high speed MPU interface (2MHz) 80 x 8 bit display RAM (80 Characters max) 9,920-bit character generator ROM for a total of 240 character fonts. 208 character fonts (5

x 8 dots) 32 character fonts (5 x 10 dots) 64 x 8 bit character generator RAM 8 character generator RAM 8 character fonts (5 x 8 dots)

4 characters fonts (5 x 10 dots) Programmable duty cycles 1/8 for one line of 5 x 8 dots with cursor 1/11 for one line of 5 x 10 dots with cursor 1/16 for one line of 5 x 8 dots with cursor 58

Wide range of instruction functions display clear, cursor home, display on/off, cursor on/off,

display character blink, cursor shift, display shift. Automatic reset circuit, which initializes the controller / driver ICs after power on.

5.12 MPLAB
MPLAB IDE is an integrated development environment that provides development engineers with the flexibility to develop and debug firmware for various Microchip devices MPLAB IDE is a Windows-based Integrated Development Environment for the Microchip Technology Incorporated PICmicrocontroller (MCU) and dsPIC digital signal controller (DSC) families. In the MPLAB IDE, you can:

Create source code using the built-in editor. Assemble, compile and link source code using various language tools. An assembler, linker and librarian come with MPLAB IDE. C compilers are available from Microchip and other third party vendors.

Debug the executable logic by watching program flow with a simulator, such as MPLAB SIM, or in real time with an emulator, such as MPLAB ICE. Third party emulators that work with MPLAB IDE are also available.

Make timing measurements. View variables in Watch windows. Program firmware into devices with programmers such as PICSTART Plus or PRO MATE II.

Find quick answers to questions from the MPLAB IDE on-line Help.

59

5.13 MPLAB SIMULATOR


MPLAB SIM is a discrete-event simulator for the PIC microcontroller (MCU) families. It is integrated into MPLAB IDE integrated development environment. The MPLAB SIM debugging tool is designed to model operation of Microchip Technology's PIC microcontrollers to assist users in debugging software for these devices.

5.14 IC PROG
The PRO MATE II is a Microchip microcontroller device programmer. Through interchangeable programming socket modules, PRO MATE II enables you to quickly and easily program the entire line of Microchip PICmicro microcontroller devices and many of the Microchip memory parts. PRO MATE II may be used with MPLAB IDE running under supported Windows OS's (see Read me for PRO MATE II.txt for support list), with the command-line controller PROCMD or as a stand-alone programmer

5.15 COMPILER-HIGH TECH C


A program written in the high level language called C; which will be converted into PICmicro MCU machine code by a compiler. Machine code is suitable for use by a PIC micro MCU or Microchip development system product like MPLAB IDE.

5.16 PIC START PLUS PROGRAMMER:


The PIC start plus development system from microchip technology provides the product development engineer with a highly flexible low cost microcontroller design tool set for all microchip PIC micro devices. The pic start plus development system includes PIC start plus development programmer and MPLAB IDE. 60

5.18 DESCRIPTION 5.18.1 POWER SUPPLY

Fig 5.11 Power supply INTRODUCTION: The present chapter introduces the operation of power supply circuits built using filters, rectifiers, and then 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, regulating to obtain a desired fixed dc voltage. The regulation is usually obtained from an IC voltage regulator unit, which takes a dc voltage and provides a somewhat lower dc voltage, which remains the same even if the input dc voltage varies, or the output load connected to the dc voltage changes.

61

A block diagram containing the parts of a typical power supply and the voltage at various points in the unit is shown in fig 19.1. The ac voltage, typically 120 V rms, is connected to a transformer, which steps that ac voltage down to the level for the desired dc output. A diode rectifier then provides a full-wave rectified voltage that is initially filtered by a simple capacitor 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 dc voltage that not only has much less ripple voltage but also remains the same dc value even if the input dc voltage varies somewhat, or the load connected to the output dc voltage changes. This voltage regulation is usually obtained using one of a number of popular voltage regulator IC units.

IC VOLTAGE REGULATORS: Voltage regulators comprise a class of widely used ICs. Regulator IC units contain the circuitry for reference source, comparator amplifier, control device, and overload protection all in a single IC. Although the internal construction of the IC is somewhat different from that described for discrete voltage regulator circuits, the external operation is much the same. IC units provide regulation of either a fixed positive voltage, a fixed negative voltage, or an adjustably set voltage. A power supply can be built using a transformer connected to the ac supply line to step the ac voltage to a desired amplitude, then rectifying that ac voltage, filtering with a capacitor and RC filter, if desired, and finally regulating the dc voltage using an IC regulator. The regulators can be selected for operation with load currents from hundreds of milli amperes to tens of amperes, corresponding to power ratings from milliwatts to tens of watts.

62

THREE-TERMINAL VOLTAGE REGULATORS: Fig shows the basic connection of a three-terminal voltage regulator IC to a load. The fixed voltage regulator has an unregulated dc input voltage, Vi, applied to one input terminal, a regulated output dc voltage, Vo, from a second terminal, with the third terminal connected to ground. For a selected regulator, IC device specifications list a voltage range over which the input voltage can vary to maintain a regulated output voltage over a range of load current. The specifications also list the amount of output voltage change resulting from a change in load current (load regulation) or in input voltage (line regulation). Fixed Positive Voltage Regulators:

Fig 5.12 Fixed Positive Voltage Regulators: The series 78 regulators provide fixed regulated voltages from 5 to 24 V. Figure 19.26 shows how one such IC, a 7812, is connected to provide voltage regulation with output from this unit of +12V dc. An unregulated input voltage Vi is filtered by capacitor C1 and connected to the ICs IN terminal. The ICs OUT terminal provides a regulated + 12V which is filtered by capacitor C2 (mostly for any high-frequency noise). The third IC terminal is connected to ground (GND). While the input voltage may vary over some permissible voltage range, and the output load may vary over some acceptable range, the output voltage remains constant within specified voltage variation limits. These limitations are spelled out in the manufacturers specification sheets. A table of positive voltage regulated ICs is provided in table .

63

IC Part

Output Voltage (V) +5 +6

Minimum Vi (V)

7805 7806

7.3 8.3

7808

+8

10.5

7810

+10

12.5

7812

+12

14.6

7815

+15

17.7

7818

+18

21.0

7824

+24

27.1

Table 5.3 Positive Voltage Regulators in 7800 series

64

5.18.2 74LS36 (EXCLUSIVE OR GATE)

CONNECTION DIAGRAM

Fig 5.13 Connection diagram of 74LS36 TRUTH TABLE

Table 6. Truth table of 74LS36 65

5.18.3 LM 741 OPERATIONAL AMPLIFIER

Fig 5.14 Pin Diagram of 741 Op-Amp The LM741 is a high performance monolithic operational amplifier constructed on a single silicon chip. It is intented for a wide range of analog applications. Summing amplifier Voltage follower Integrator Active filter Function generator The high gain and wide range of operatingvoltages provide superior performances in integrator, summing amplifier and general feedbackapplications. The internal compensation network (6dB / octave) insures stability in closed loop circuits.

FEATURES Large input voltage range No latch-up High gain Short-circuit protection no frequency compensation required

66

5.18.4 BC547 NPN GENERAL PURPOSE TRANSISTORS

SYMBOL

Fig 5.15. Symbol of BC547

FEATURES Low current (max. 100 mA) Low voltage (max. 65 V).

APPLICATIONS General purpose switching and amplification.

DESCRIPTION NPN transistor in a TO-92; SOT54 plastic package. PNP complements: BC556 and BC557.

67

5.19 WORKING PRINCIPLE This circuit is designed to find the power factor in the power line. The power line voltage and current is monitored through the potential and current transformer respectively. The potential transformer is used to step down the mains supply voltage to low voltage level. The voltage level is from 440V AC to 6V AC. Then the output of the transformer is given to Zero Crossing Detector. The current consumed by the load is measured with the help of a current transformer. The current transformer will convert the load current in to lower values that current output will be converted in to voltage with the help of the shunt resistor. Then the corresponding the AC voltage is given to zero crossing detector. The Zero Crossing Detector is used to convert the sine wave to square wave signal. The zero crossing detectors are constructed by the operational amplifier LM 741. The inverting and non inverting input terminals are connected to the potential transformer and current transformer terminals respectively. So the input sine wave signal is converted in to square wave signals. The square signal is in the range of +12v to -12v level. Then the square wave signal is given to base of the BC 547 switching transistor in order to convert the TTL voltage 0 to 5v level. Then the both ZCDs outputs are given to logical XOR gate 74LS86 to find the phase angle difference between the voltage and current. The XOR gate output is given to microcontroller or PC and caclculate the power factor with help of software.

5.20 ADVANTAGES:
1. constant switching frequency; 2. only the switch current must be sensed and this can be accomplished by a current transformer, thus avoiding the losses due to the sensing resistor; 3. no need of current error amplifier and its compensation network; 4. possibility of a true switch current limiting.

68

CHAPTER 6
CONCLUSION
In this project, power factor control technique is developed for PFC boost converter is analyzed. In this control strategy advantages and drawbacks are highlighted and information on available commercial IC's is given. Extension of this control technique the drawbacks are rectified and some experimental results based on a PFC Sepic converter with power factor control methods is reported. Lastly, considerations regarding the PFC dynamic response are given.

69

Potrebbero piacerti anche