R&D Publishing‎ > ‎

### Energy Metering Engineering

1. Di/Dt current sensor simulation

To understand di/dt current sensing in the energy meter application, We simulate it by using the schematic as fingure below.
- Harmonic wave form f(x)=1.sin(x) + 0.3 sin(3x) + 0.1sin(5x) after pass di/dt function will be swing as r2_1 wave form fater that it be restored by integral circuit.
-  Output wave form quality be affected by RC components (filter factor).
-  For good in practice the OPAMP-OP07 should be select to reject dc offset component

2. di/dt in practice use OP07 OPAMP

- Blue wave: Current wave form measured by current transofrmer
- Red wave:
Current wave form measured by di/dt current transofrmer after integral by OP 07

Schematic
(I will post later)

3. Three phase voltage sensing with resistor divider
3.1 Schematics:
To measure high voltage without using transformer, the resistor divider is the best choise and realiability. In the RDLAB, We had applied this schematics to major our project in the three phase system section

Figure 3.1: Three phases voltage sensing use resistor
3.2 Wave form

Look on the figure 2.2, in the case of 50% rate voltage V1 and V2 the measurement show that voltage sensing is high accuracy as it is

Fingure 3.2: Wave form of voltage in the case of imbalance system

# DIY Digital AC Watt Meter

Electro-Labs
February 6, 2015

Have you ever been curious about the power consumption of an appliance? For example did you wonder how much it will cost you to leave your television in standby mode whole night? Or did you want to learn how much change your refrigerator settings will make on your electric bill? If your answer is yes, you can use a wattmeter to measure the power consumption of a device. In this project we are building one.

This is an AC Watt Meter which can measure the real power consumption of a device connected to the 230Vrms/50Hz mains line. The PIC microcontroller collects the voltage and the current information with the help of ADCs and then calculates the RMS voltage of the mains line, RMS current drawn by the device and the resulting average power consumption. All these information is then displayed on the dot matrix LCD.

The meter itself doesn’t need an external power source. It is powered from the mains. Despite this, the microcontroller side is fully isolated from the parts interfacing to the mains.

## Circuit Design

The schematic of the project is drawn in SoloCapture, the schematic editor of SoloPCB tools. SoloCapture makes the schematic drawing process very easy and fast. You can download SoloPCB tools at Fabstream.com for FREE.

Please check out this video to see how to import the project libraries, open and synchronize the schematic and PCB files.

To calculate the power, we need to know the voltage across the load and the current drawn by the load. The voltage that should be measured is directly the mains voltage. We know that the mains voltage is 230Vrms/50Hz but it has a 10% tolerance. So the voltage can change between 207Vrms and 253Vrms. To make an accurate power measurement, it will be better to measure the mains voltage instead of putting 230Vrms into the calculations.

The mains line is connected to the AC IN connector (J1). For the voltage measurement, a resistor divider network (R1, R2, R3) is connected between the phase and the neutral lines.  With the help of the voltage divider, the mains voltage is down scaled at a factor of R1/(R1 + R2 + R3) = 1/201 which converts ±320V (peak) to ±1.59V. Then 2.5V up shifting is applied which finally maps ±320V to 0.91V – 4.09V that nicely fits between 0-5V with a good level of safety margin.

After this scaling and shifting process, the voltage across R2 is read by MCP3202 ADC. Then the voltage information is read by the microcontroller in 12 bit format over SPI interface. To isolate the microcontroller part from the section interfacing to the mains, HCPL-0630 high speed optocouplers are used. The second analog input channel of MCP is used to read the 2.5V reference voltage and use it as the correction factor in the calculations.

While the neutral and earth lines coming from the AC IN connector are directly connected to the AC OUT connector (J2), the phase line is passing through the ACS712-20A  hall effect based current sensor (U4) for the purpose of current measurement. The sensor outputs 2.5V at 0A. When current flows between the IP+ and IP- terminals, the sensor output changes at a rate of 100mV/A. So the output voltage becomes 4.50V at +20A and 0.500V at -20A. The sensor output is read by another MCP3202 and sent to the microcontroller over SPI.  The ACS712 provides internal isolation so no external precaution is required for isolation.

ACS712-20A is capable of reading ±20A. But considering the current limitations of the terminal blocks and the fuse holder, the AC current path is protected by a 16A fuse which is connected in series to the phase line.

There are two isolated 5V sources to power the mains and the microcontroller sides. The transformer generates 2x6Vrms from the 230Vrms. Each output is rectified by the bridge diodes and then regulated by the 78L05 linear regulators. D2 and D3 are the LEDs indicating the status of each 5V.

The microcontroller of the wattmeter is PIC18F252. Basically it reads the voltage and the current and calculates the RMS voltage, the RMS current and the average power. Then it interfaces with the LCD and shows all these values. It has a hardware SPI module which lets communicating with the MCP3202 ADCs. On the other hand it interfaces to the LCD over 4-bit or 8-bit interface.  The microcontroller’s master clock becomes 5Mhz when 20Mhz crystal oscillator is used. There is an onboard ICSP connector (J3) which is used to program the PIC.

## PCB Design

The PCB of the project is designed in SoloPCB. SoloPCB is a pack of powerful tools consisting of schematic capture, PCB layout, and integrated autorouting. You can download SoloPCB tools at Fabstream.com for FREE and start using immediately.

Please check out this video to see how to import the project libraries, open and synchronize the schematic and PCB files.

Designing the wattmeter as a handheld device was a good idea. The outline of the PCB was drawn accordingly. Autocad was used to draw the outline and the .dxf file was imported in SoloPCB.

All the footprints which are not included in the SoloPCB libraries were created manually. They can be found in the SoloPCB design files.

The lines (phase, neutral and earth) connecting AC IN connector to AC OUT connector were drawn as thick as possible.  The bypass capacitors are placed as close to the ICs as possible. Two separate ground planes are drawn for AGND and DGND to keep the ground resistance low.

All the components were placed at the top layer. An acrylic cover was planned to use as a cover for both the top and bottom layers. So the height of the bottom layer would be as low as possible.

## Software

Basically the MCU reads the voltage and the current samples every 1 ms and collects 40 sample pairs which means two periods for the 50Hz. Then calculates the RMS values and the average power. 1ms period is generated by using the Timer A module. The module runs in 16 bit mode and generates an interrupt at each overflow. So we assign a start value in each cycle and wait for the 1ms trigger.

After collecting all of the samples, the calculation processes begin. The RMS voltage is calculated by using the equation below,

The RMS current is also calculated by using the same equation.

The voltage and the current samples include the phase relation between the voltage and the current. So active (real) AC power which is V * I* cosθ can be achieved by calculating the average power by using the equation below.

Calculated RMS and power values are displayed on the LCD by using the lcd.h library of CCS C compiler.

The whole CCS C code is provided at the end of the article.

## Assembly and Test

The part list of the project is given below

QuantityPart DescriptionDesignator
278L05 5V 0.1A Linear Voltage Regulator SOT-89U1 U2
1REF03 2.5V Voltage Reference SO-8U3
1ACS712-20A Hall Effect Current Sensor SO-8U4
2MCP3202-BI/SN Dual Channel 12 Bit Analog to Digital Converter SO-8U5 U10
3HCPL-0630 High Speed Optocoupler SO-8U6 U7 U8
1PIC18F252-I/SO 8 Bit Microcontroller SO-28U9
2DF08S 800V 1A Mini Bridge RectifierBR1 BR2
1HR-E3013051 230V to 2x6V 1.5VA TransformerTR1
1TC1602D 2×16 Dot Matrix LCDLCD1
2470uF 25V Electrolytic Capacitor 10x10mmC1 C18
2100uF 16V Electrolytic Capacitor 6.3×5.4mmC2 C17
222pf 50V 0805 NPO SMD Ceramic CapacitorC11 C12
11nF 50V 0805 X7R SMD Ceramic CapacitorC9
14100nF 50V 0805 X7R SMD Ceramic CapacitorC2 C4 C5 C6 C7 C8 C10 C13 C22 C14 C15 C16 C17 C20
11uF 25V 1206 X7R SMD Ceramic CapacitorC21
20R 1% 0805 ResistorR16
21M 1% 0805 ResistorR2 R3
31K 1% 0805 ResistorR5 R6 R17
510K 1% 0805 ResistorR1 R14 R15 R18 R19
42K 5% 0805 ResistorR7 R8 R9 R13
4330R 5% 0805 ResistorR4 R10 R11 R12
2Red LED 0805D2 D3
120MHZ Crystal OscillatorY1
1SS14 1A 40V Schottky Rectifier SMAD1
1Schurter 0031.8221 SMD Fuse HolderF1
116A Fuse 20x5mm-
21×3 5.2mm Pitch Screw Terminal BlockJ1 J2

You can see the power consumption of a solder station while heating up below.

You can see another measurement below. 2KW water boiler is connected to the meter.

## PIC Code

The PIC code is written in CCS C compiler.