Design and Development of PIC Microcontroller Based 3 Phase Energy Meter | Open Access Journals

ISSN ONLINE(2319-8753)PRINT(2347-6710)

Design and Development of PIC Microcontroller Based 3 Phase Energy Meter

Thousif ahamed1, A.Sreedevi2
Department Electrical and Electronics Engineering, R.V. College Of Engineering, Bangalore, Indias
Related article at Pubmed, Scholar Google

Visit for more related articles at International Journal of Innovative Research in Science, Engineering and Technology

Abstract

the purpose of this project is to develop a 3-phase Energy Meter, using dsPIC33F microcontroller and MCp3909 ADC IC from microchip, used to perform all the measurements in the energy meter. Basically, the energy meter is designed to measure the energy, equivalent to the power consumption over time, using the formula of P = V * I. Therefore, two input channels are connected to the ADC chip, one for voltage, and another for current. Analog signals will be detected from the two input channels, which will be converted into Digital signals by ADCs respectively. With the two digital input signals transmitted to the microcontroller via SPI protocol, dsPIC33F calculates the power hence, energy consumed will be accumulated after a specified period of time. The microcontroller is programmed with C language; ADC channels are used for converting both current analog signal and voltage analog signal; multiply algorithm is used to process the power and energy, voltage and current signals based on the energy formula and many parameters are displayed such as voltage, current, Active power, reactive power, apparent power, frequency etc. A suitable multiple output power supply circuit is designed to provide supply to the MCU, with a input range of 85 to 265v a constant output of 3.3v and 5v is obtained

Keywords

dsPIC33F Microcontroller, MCP3909 ADC IC, Multiple output power supply and flyback transformer.

INTRODUCTION

One of the main goals of this paper in the field of energy management system (EMS) is to improve the efficiency of the electric power system. The effective control of the system requests a large amount of information for the parameters in great number of points. This requires monitoring of the system parameters in different places – power plants, substations, power lines and etc. The main parameters of the three-phase electric power system are voltage, current, frequency, active power, reactive power, power factor, active energy and reactive energy. The increase of the electric energy price forces design and introduction of precise measuring devices with high accuracy [1]. In this application a 3-phase 4wire energy meter is designed using 16bit dsPIC microcontroller and MCP3909 ADC chip.
The MCP3909 device is an energy-metering IC designed to support the IEC 62053 international metering standard specification. It supplies a frequency output proportional to the average active real power, with simultaneous serial access to ADC channels and multiplier output data.
In this Approach the 3-phase energy meter is unique in fact all the calculations take advantage of dsPIC33F DSP engine, and all output quantities are calculated in frequency domain through the use of Discrete Fourier Transforms. Another significant advantage of this design is that the dsPIC firmware implements a quasi-synchronous sampling algorithm, eliminating the need for external zero-crossing detection and PLL (Phase Locked Loop) circuit for the synchronization of ADC samples to line frequency[2] [3] [4]. The line frequency is measured in software and corrected for measurement errors caused by frequency fluctuations in the power grid. This additional processing on the dsPIC reduces the overall meter cost by eliminating the requirement for a PLL circuit.

HARDWARE BLOCK DIAGRAM DESCRIPTION

There are number of hardware devices used in this design that are integrated in order to make this device function appropriately. The fig 2.1 describes the energy meter block diagram required in this design work. The hardware includes dsPIC33F microcontroller unit, MCP3909 energy meter IC for analog signal conditioning of 3-phase voltage and current inputs, external oscillator of 3.2768Mhz acting as clock to energy meter ICs(MCP3909), external EEPROM to store the data temporally during power failure, ICD2 interface is used for MCU programming and power supply circuits. Threephase voltage and current signals are connected to the meter through transformers and to the MCP3909 A/D converter through a voltage divider circuit. The sampling of the signal as well as analog-to-digital conversion is performed using the device MCP3909 which sends the digital converted results to the dsPIC device through SPI interface.
A. Analog Inputs to MCP3909 Ic
The back end of the meter is made up of three pairs of voltage and current input networks. Each of the three line voltages is attenuated by a resistor divider and filtered through identical anti-aliasing filters as shown in fig.2.The current channels signals are converted from current to a voltage through current transformers and burden resistors as shown in fig 3. The signals are then filtered by the anti-aliasing filter on each of the three phases, and the result is applied to the current inputs of the MCP3909.
image
image
B. Analog to Digital Conversion
All This meter design uses Microchip's MCP3909 energy meter ICs. Small-signal current inputs can be amplified by the programmable gain amplifier inside the MCP3909 device. The programmable range for the MCP3909's PGA is 16:1 V/V. The MCP3909 PGA gain can be configured by G0 and G1 (Pin 15 and 16 of the dsPIC33F). The MCP3909 device's clock is provided by a 3.3768 MHz active crystal. The MCP3909 device's output data rate is 12.8 ksps. The clock lines and MCLR lines of all 3 MCP3909 devices are connected together, which ensures that the 3 phases are strictly synchronous as shown in fig 4.
image

POWER SUPPLY CIRCUIT DESIGN

A suitable power supply circuit is required that generates a fixed or controllable magnitude dc voltage from the available form of input voltage. In this design we require a multiple output power supplies with 5v and 3.3v. A multiple output power supply includes a flyback transformer, feedback technique using TL431 and TOP221 switch regulator. Fig.5 shows the circuit for multiple output power supply[11].
image
Fig.5 shows a typical flyback power supply using the TOP221 Switch[14][15]. This Switch combines an integrated high voltage MOSFET switch with a complete switching power supply controller and protection circuitry in a single 3 pin TO221 package. The TOPSwitch power supply operates from 85 to 265 VAC and delivers 7 Watts at 5 Volt output. AC power is rectified and filtered by bridge rectifier (BR1) and capacitor C4 (CIN) to create the high voltage DC bus applied to the primary winding of transformer (T1). The other side of the transformer primary is driven by TOPSwitch. D3, C5 and R3 form a snubber circuit to clamp voltage spikes caused by transformer leakage inductance. Diode (D2), capacitor (C12,C14) and inductor L2, rectify and filter the power secondary. TOPSwitch bias voltage is provided by D9 and C20 which rectify and filter the bias winding. EMI filter components L5 and C1 reduce conducted emission currents. Bypass capacitor C5 filters internal TOPSwitch gate charge current spikes and also compensates the control loop. TOPSwitch turns on to effectively apply the DC input voltage across the transformer winding with the “dot” side at lower potential than the “no-dot side”. Primary current IPRI increases linearly with a rate of change (di/dt) that varies directly with DC input voltage and inversely with primary inductance. Ripple current IR is defined as the incremental linear current rise (di) over the entire TOPSwitch on time (Ton). Peak primary current IP is the final value occurring as TOPSwitch turns off. Energy, proportional to the square of peak current IP, is stored by magnetic field in the transformer core as if the primary winding were a simple inductor. The secondary winding carries a reflected voltage proportional to primary voltage by turns ratio with the same “dot” polarity. While TOPSwitch is on, output diode D2, D5 and bias diode D9 are reverse biased which prevents secondary current flow. When TOPSwitch turns off, the decreasing magnetic field induces an abrupt voltage reversal on all transformer windings such that the “dot” side is now higher potential than the “nodot” side. Diode D2, D5 and D9 become forward biased and secondary current rises quickly to a peak value (proportional by the inverse turns ratio to primary peak current IP). Primary current immediately drops to zero. TOP Switch drain voltage quickly rises to a voltage equal to the sum of the DC input voltage and reflected output voltage. Secondary winding current now linearly decreases at a rate that varies directly with output voltage and inversely with secondary inductance.

SOFTWARE IMPLEMENTATION

The software is to have an overall control of the hardware at all time and to determine the current, voltage, power and energy based on the principles of power and energy calculations. Hardware controlling consists of input devices, external reference voltage device, and power circuit and display board with external peripherals. In addition, based on the selected algorithm, the software must be able to continue track the input current and voltage signals, convert these analog signals to digital signals, multiply both signals to a power signal and with a consumed time to get energy. And send those data to display. After overall planning, instructs the microcontroller to execute for initializing peripherals in first priority to work on, the principle of power and energy calculations, value collection and data sending to display board base on the microcontroller. To achieve those functions, the pins configuration and ADC conversion should be considered, interrupt should be introduced in the programming.
Initialize and Configure MCP3909Ic to operating mode
The task of this module is to enable the MCP3909 device to enter the "Channel Output" mode. In this mode, the current and voltage data channels measured by the ADC are sent through the MCP3909 device's SPI port. To enable the MCP3909 device to enter the Channel Output mode, certain instructions must be sent to the device via the SPI interface within a specified time (32CLK) after resetting the MCP3909 device with a flow chart shown in Fig.6
• Enable all MCP3909 devices: enable ADCS1, ADCS2 and ADCS3, and configure MCU's SPI to 16-bit mode
• Reset the MCP3909 device through the RESET pin. The pin must be pulled low for no less than 1 clock cycle of the MCP3909 device
• After the RESET pin is pulled high, wait for 4 clock cycles for the MCP3909 device pin functions to reset
• Send Instruction 0xac to the MCP3909 device through the SPI Interface • Configure the SPI interface to 16-bit mode and strobe the MCP3909 device for Phase A
A. ADC Sampling Scheme for Calculation
The ADC conversion rate of the MCP3909 device is determined by the frequency of master clock, MCLK, and the The ADC conversion rate of the MCP3909 device is determined by the frequency of master clock, MCLK, and the
image
The signal is fed into IC1 (Input Capture 1 on the dsPIC33F), allowing the Interrupt Service Routine (ISR) of IC1 to invoke data-read function of the MCP3909 device. When the MCP3909 device outputs data, it first sends the ADC result of the voltage channel, then that of the current channel, with the MSB first.
B. Processing IC1 Interrupt
Input capture IC1 is used to detect if the A/D conversion is complete. After each conversion, a positive pulse width of 4 clock cycles is outputted by the SDO pin of the MCP3909 device. IC1 is used to detect the falling edge of the pulse and generate an interrupt for every 2 falling edges, i.e., 1 data is read for every 2 conversions, thus realizing 6.4 ksps sampling rate. In addition to reading the data of the MCP3909 device, the IC1 interrupt service routine (ISR) also controls the energy pulse output generation.
The energy pulse processing program only begins when the level is close to outputting pulse level. To simplify the process and shorten the ISR execution time, a counter is used in place of the energy accumulation function for each pulse and to determine if a pulse will be outputted. When the count is greater than the threshold of pulse output, an energy pulse will be outputted, and the appropriate amount of energy will be subtracted from the energy accumulating register. Output toggling will then be processed. Once the width of the output pulse exceeds 80 ms, the pulse output will be turned off.
image
C. Reading A/D data of the MCP3909 device
All three MCP3909 devices use the same clock source and reset signal, so all 6 A/D channels of the 3 MCP3909 devices are synchronous. Only a single Data Ready (SDO) signal of any of the MCP3909 device is required to read A/D data of the 3 phases in turn. This module is invoked by IC1 interrupt triggered by the "data ready" signal on the SDO of the MCP3909 device. IC1 is set to generate an interrupt for every two falling edges. Therefore, only one of the two sampling data of the MCP3909 device is read. The flow of reading the MCP3909 device's data is as follows:
• Retrieve all values of 3-phases, both current channel and voltage channel data. Bits 0-15 of each phase data are voltage channel data, bits 16-31 are current channel data
• Accumulate the active power of each phase. On every other interrupt, the current and voltage values are stored into RAM in the cyclic sampling array
• Update the pointer of sampling array and length of sampling data. If the length of sampling data is 3-line cycles long, set the sampling complete flag, and then the calculation function Calculate () will be called by the main flow to start computing all corresponding parameters.
image

EXPERIMENTAL SETUP

This section is used to represent the effectiveness of the designed system. It describes the experiments done to evaluate and quantize the performance of the system. When dealing with a system such as this where the outcome specifies target accuracy, many of the experiments might seem irrational and irrelevant. A system such as this, containing many subsystems, might introduce (or eliminate) some of the error percentage from the original test variable (being the energy measurement). It is imperative then, to test (at least to some extent) all the subsystems handling the test variable for accuracy.
This section is used to represent the effectiveness of the designed system. It describes the experiments done to evaluate and quantize the performance of the system.
When dealing with a system such as this where the outcome specifies target accuracy, many of the experiments might seem irrational and irrelevant. A system such as this, containing many subsystems, might introduce (or eliminate) some of the error percentage from the original test variable (being the energy measurement). It is imperative then, to test (at least to some extent) all the subsystems handling the test variable for accuracy. The energy metering system is connected to the 220V 3phase power line. Between the energy metering system and the load, three current transformers are connected in series to each phase, a multimeters are connected between load and dimmer stat to vary voltage, and a ammeter is connected to any one phase to note current during load variation, so that it should not exceed the rated current of the load (induction motor) as shown in the test setup layout in Fig.9. The voltage, current readings and instantaneous power from watt meters are noted and compared with the readings recorded from energy meter. This was repeated with different loads, as shown in the below table 5.1(a &b).
image
image

RESULTS

The electrical quantities indicated by the watt meters are shown in Table 6.1a and the values indicated by the energy meter are shown in table 6.1b with the variation of load respectively. By taking watt meters reading as reference the percentage variations calculated for the quantities indicated by the energy meter at various loading conditions are shown in table 6.1c
image
With the obtained values from table 5.1a and table 5.1b various graphs has been plotted, Fig.10 shows a graph of power factor verses current, where the current readings obtained from energy meter are taken as reference. The power factor obtained from the watt meters and energy meter are plotted. Fig.11 and Fig.12 shows a graph of Power (Active, Reactive and Apparent) verses current, the current readings obtained from energy meter is taken as a reference. At different loading conditions the variation of the power i.e. active power, reactive power and apparent power of both watt meters and energy meter are shown along the y-axis respectively.
image
image
Fig. 13 shows a graph of active power indicated by both watt meters and the energy meter verses current for the different loads. The percentage variation occurred between the two meters are shown in the table5.1c. Similarly in Fig.14 and Fig.15 graphs of reactive power and the apparent power indicated by the both Watt meters and energy meter verses current are shown for the different loading conditions and the percentage variation in the readings obtained by the watt meter and the energy meter are shown in the table5.1c respectively.
image
The test results of the converter operating for various input voltages from 85v to 265v are as shown in table 6.1 and during the test the captured waveforms at the output terminal of 3.3v and 5v are shown in Fig.16 and Fig.17 respectively which remained constant for all the values of voltage in table 6.1.
A test setup performed is shown in Fig.18 in which a designed power supply board is connected to a digital oscilloscope and power supply is given from the main through a single phase autotransformer in order to vary mains voltage from 85v to 265v. With the different values of voltage from the mains the output from the 5v and 3.3v terminal of the power supply board are recorded and tabulated in table 6.1. The component placements of the power supply board are shown in fig.19
image
image

CONCLUSION

With the latest advancements in integrated circuit development, implementing an electronic energy meter with a PIC microcontroller is a straight forward exercise. The design and implementation of a fully functional energy meter with added functionalities of dsPIC33F microcontroller is presented. The energy meter is interfaced with the MCP3909 ADC chip which has simple voltage and current sampling techniques in order to measure active power, reactive power, apparent power and total energy which satisfies emerging requirements of energy providers.
The designed prototype of energy meter is more cost effective than the existing meters due to the added functionality of quasi-synchronous sampling algorithm in coding to eliminate external zero-crossing detection and Phase Locked Loop (PLL) circuit for the synchronization of ADC samples to line frequency. The dsPIC33F microcontroller provides a costeffective way to implement a metering solution with a low part count.
Compared to electromechanical electric meter, the power requirement of the designed energy meter is less. An experiment is conducted to verify the values, obtained from the designed prototype of energy meter, using the watt meters by taking induction motor as load. The percentage variation in the watt meter readings and the energy meter readings is discussed in results chapter. The energy meter designed is free from tampering hence, energy theft is prevented.

SCOPE OF FUTURE WORK

Future work concerning this project lies in adding features and streamlining the prototype towards production. The most important feature that should be added is the “Maximum Demand Control” possibility. Demand controlling is a method of controlling the consumption not to overload the grid. Demand is calculated in different ways, different parameters depend on the region/ country. There are two types of demand measurement names Sliding window and fixed window, Forecast demand control and Step wise demand control. It minimizes utilization of demand thereby preventing paying of penalty for exceeding demand. The controller is precise, predictive and informative to get alarm and trip when the threshold limit is crossed. Demand controller helps the user to mange power optimally utilizing the feature of time of Tariff for energy and demand.

References

[1] Dr. Yaduvir Singh and Mandhir Verma, “General concept on Electrical Measurements” Page 224 – 244. Laxmi Publications, Ltd., First Edition-2010.

[2] Liu Xian-chun, Xiao Yu-ling, Zhao Liang-qin, “Design of Three-phase Multi-purpose Standard Electric Energy Meter”, 2011 International Conference on System Science, Engineering Design and Manufacturing Informatisztion, Guiyang, ISBN: 978-1-4577-0247-1, vol 1,pp- 263.

[3] Fei Wang, Fan Yang, Tianyu Liu, Xiaoguang Hu, “Measuring Energy Meter of Three-phase Electricity- Stealing Defense System”, 2011 6th IEEE Conference on Industrial Electronics and Applications (ICIEA),Beijing,June2011, DOI: 10.1109/ICIEA.2011.5975542, pp- 11-15.

[4] Zheng Dezhi Sch. of Instrum. Sci. & Opto-Electron. Eng., Beijing Univ. of Aeronaut. & Astronaut.,Beijing WangShuai “Research on Measuring Equipment of Single-Phase Electricity-Stealing with Long-Distance Monitoring Function.Power and Energy Engineering Conference, 2009. APPEEC2009. Asia-Pacific.DOI: 10.1109/APPEEC.2009.4918696 PP 1-4

[5] A. Sinha, S.Neogi, R. N. Lahiri, S. Chowdhury, S. P. Chowdhury, N. Chakraborty, “Role of Demand Side Management for power distribution utility in India”, 2011 IEEE Power and Energy Society General Meeting, 24-29 July 2011, DOI: 10.1109/PES.2011.6039352, pp 1 -8

[6] Jishun Jiang Sch. of Electr. & Electron. Eng., Shandong Univ. of Technol., Zibo, China Lanlan Yu “Design of a New Three-Phase Multi-Rate Watt-Hour Meter Based on Single chip” Computational Intelligence and Software Engineering, 2009. CiSE 2009. International Conference 28 December 2009.DOI: 10.1109/CISE.2009.5366939, PP 1 – 4

[7] Ovidiu,P “DSP's based energy meter” Integrated Management of Electronic Material Production,2003. DOI: 10.1109/ISSE.2003.1260523. PP 235 – 238

[8] A. Cairullo and M. Parvis, “Power meter for highlydistorted three-phase systems”, IEEE Instrumentation and measurement Technology Conference, Belgium, 4-6 June 1996, DOI: 0-7803-3312 -8/968

[9] Kawin Lekhanont, Chaiyaphorn Chatchawarnkitkul, Pisit Rattapaisarn, “Error Analyses of a 3-Phase Electricity Meter with Class-0.5 Accuracy”, 2004 IEEE Region 10 Conference TENCON, Nov 2004, DOI: 10.1109/TENCON.2004.1414901, Vol. 4, pp. 191- 194

[10] Xiaohan Ji, Dapeng Zhang and Chunmeng Wang. “A watt-hour meter reading device for electric energy allowance”,Artificial Intelligence, Management Science and Electronic Commerce (AIMSEC), 2011 2nd International Conference. DOI: 10.1109/AIMSEC.2011.6009920.

[11] Sun Hao, Yuan Huimei and Lu Simei “A Design of Three-Phase Digital Watt-Hour Power Meter on SOPC Platform”,ITCS International Conference on 25 jul-2009. DOI: 10.1109/ITCS.2009.61. Vol 1, pp 264 - 267

[12] Guo Zong-lian, Chen Xiao-qin, “ADE7758 and the application in three phase digital power meter”, Information Technology, 2009, Vol. 29, No.12, pp. 138- 141.

[13] Keith Curtis , Principal Applications Engineer “ Levels of Microcontroller Integration in Power-Supply Design” Microchip Technology Inc

[14] Coruh, N.”Design and implementation of flyback converters”, 2010 Industrial Electronics and Application (ICIEA), 2010 the 5th IEEE Conference,. DOI: 10.1109/ICIEA.2010. Pages 1189-1193.

[15] Jung, J.-H. Smart Grid Res. Div., Korea Electrotechnol. Res. Inst., Changwon, South Korea Ahmed, S.”Flyback converter with novel active clamp control and secondary side post regulator for low standby power consumption under high-efficiency operation” Power Electronics, IET , NOV2011,Vol-4, pages1058 – 1067.

[16] Bisci, J, “Part IV: Magnet Wire: Selection Determines Performance, PCIM”, October 1994, pp. 37.

[17] Leman, B., “Finding the Keys to Flyback Power Supplies Produces Efficient Design, EDN”, April 13, 1995, pp. 101-113.

[18] McLyman, C., “Transformer and Inductor Design Handbook”, Marcel Dekker, Inc. 1978

[19] Singh, S. Singh, B. “Multiple output SMPS with improved input power quality” Industrial and Information Systems (ICIIS), 2010 International Conference on,. DOI: 10.1109/ICIINFS.2010.5578673. July 29 2010-Aug. 1 2010, pages 382 – 387.