smart energy meter

18
FOR ANY INFO PLEASE CONTACT: [email protected] 1 Project Name: Smart Energy Meter Course No.: EEE 428 Course Title: Measurement and Instrumentation Laboratory Submitted to: MR. ABIR SHADMAN LECTURER,DEPT. OF EEE,BUET Submission date: 13.12.2015 Submitted by: GROUP: 05 MD. JAWWAD SADIQ(1006144) FAHIM FERDAUS HOSSAIN(1006134) MALIHA NOSHIN(1006139) FARJANA SNIGDHA(1006152) TANVIR HOSSAIN(1006155) _________________________ Signature of the Project Leader

Upload: jawwad-sadiq-ayon

Post on 10-Feb-2017

199 views

Category:

Engineering


2 download

TRANSCRIPT

Page 1: Smart Energy Meter

FOR ANY INFO PLEASE CONTACT: [email protected]

1

Project Name: Smart Energy Meter

Course No.: EEE 428

Course Title: Measurement and Instrumentation Laboratory

Submitted to:

MR. ABIR SHADMAN

LECTURER,DEPT. OF EEE,BUET

Submission date: 13.12.2015

Submitted by:

GROUP: 05

MD. JAWWAD SADIQ(1006144) FAHIM FERDAUS HOSSAIN(1006134)

MALIHA NOSHIN(1006139) FARJANA SNIGDHA(1006152)

TANVIR HOSSAIN(1006155)

_________________________

Signature of the Project Leader

Page 2: Smart Energy Meter

FOR ANY INFO PLEASE CONTACT: [email protected]

2

Objective:

1. Energy Measurement and Instrumentation: Real time energy usage is measured

comprising the data of voltage and current and calculate the power.

We want to use the following instruments for this purpose:

a. Hall Effect Current Sensor ACS 712 and

b. Potential Transformer.

2. Signal processing i.e. Precision Rectification: Alternating voltages are processed using

voltage divider ,full wave rectifier and low pass filter for measurement purpose.

3. Phase Angle (Power Factor) Measurement and instrumentation: Though the integrated

circuitry is quite complex one, our proposed instrumentation idea is able to measure Power

Factor with the help of coding on the basis of the theory of power factor determination.

4. Frequency measurement and instrumentation:

For measuring supply frequency we have used the technique of analog to digital conversion

method and coding in Arduino.

5. Graphical instrumentation for showing Measured data:

The energy meter we are proposing also comes with an in-home display i.e. LCD display,

which will give real-time feedback of energy usage. On board this LCD display shows

measured voltage, current, power ,KWhr consumption, frequency ,Power Factor, etc

continuously. Computer’s serial monitor will also be used as local energy control centre using

serial communication.

Apparatus:

1.Arduino UNO

2.Arduino Leonardo

3.Transformer

4.Resistor (10k,10k)

5.Potentiometer

6.Adapter

7.Buck module

Page 3: Smart Energy Meter

FOR ANY INFO PLEASE CONTACT: [email protected]

3

Theory:

For power and power factor measurement:

We know that –

Vrms 2=

1

170∑ 𝑣𝑖

1701 *𝑣𝑖

and

Irms 2=

1

170∑ 𝑖𝑖

1701 *𝑖𝑖

The following equation is derived by integrating the average power. We get-

Pavg= vi * ii cosƟ/2

Or, Pavg= vi/√2 * ii/√2 *cosƟ

=Vrms * Irms * cosƟ

=Preal

=P

Again, Pavg = 1

𝑇 ∫ 𝑣𝑖(𝑡) ∗ 𝑖𝑖(𝑡) ∗ 𝑑𝑡

= 1

𝑁∆𝑡 ∑ 𝑣𝑖 ∗ 𝑖𝑖 𝑁

𝑖=1 ∗ ∆𝑡

= 1

𝑁 ∑ 𝑣𝑖 ∗ 𝑖𝑖 𝑁

𝑖=1

Page 4: Smart Energy Meter

FOR ANY INFO PLEASE CONTACT: [email protected]

4

Thus we get our desired real power.

As S= Vrms * Irms

So power factor cosƟ= 𝑃

𝑆

For measuring frequency we use upper half cycle of the input signal as arduino cannot

measure the negative part.If N number of sample is taken and sample interval is ∆𝑡 then,

F =1

𝑇

=1

2∗𝑇/2

=1

2∗𝑁∆𝑡

Thus frequency is measured.

Connection and Working Method of the Circuit:

As the objective of the project is to measure AC voltage, current ,power factor of

variable load, and frequency, we have implied the real time simulation here. For that we

have used two Arduino boards along with a laptop for serial data communication. One

Arduino is used for frequency measurement and the other one is for measuring power

which comes from the values of voltages and currents.The whole circuit can be described as

a hardware part and a software part.

Page 5: Smart Energy Meter

FOR ANY INFO PLEASE CONTACT: [email protected]

5

Hardware Part And Circuit Connections:

For the hardware connection we have used a 60W bulb. This bulb is connected to the

AC 230V line. The AC voltage and AC current are then taken as input to the Arduino input

port. Prior to these, we made the AC voltage and current ready for direct input to Arduino

using the following steps.

i. Data of AC Voltage

ii. Data of AC Current

iii. Data for Frequency Measurement

i. Data of AC Voltage:

As the maximum rated voltage of the Arduino board is 5V, if the direct line voltage (230V) is

applied, then it will be damaged. So we used a transformer to step down the voltage. After

stepping down we got 6.9V. As it is still beyond the range of Arduino, a potentiometer is

used from which we got 1.5V (rms) output.

The Arduino board can only read value of voltage from 0 to 5V. But our voltage and current

are non-sinusoidal having value on positive and negative side. So, we have added a DC

voltage with the AC voltages as an offset so that input voltages of Arduino are leveled up

and we can get our desired data. We added 2.27V as DC offset voltage.Then these values

are directly sent to the Arduino port A1.

Page 6: Smart Energy Meter

FOR ANY INFO PLEASE CONTACT: [email protected]

6

ii. Data of AC Current:

For measuring current, ‘Hall Effect Current Sensor ACS 712’ is used. It is connected to the

bulb and line voltage directly. From the 3 output pins, one is grounded and one is at 5V. the

middle pin shows our desired value of current with the help of voltage change. When there

is no current flow,this node shows 2.5V. Once connected, the output would be scaled to the

current drawn through the bulb. This is a 20 Amp module and the light bulb pulled 1 Amp,

the output of the module would be 2.6 volts.The battery polarity being reversed, using the

same 20A module, the output would be 2.4 volts.

The node shows voltage change 100mV/1 A .Then this output is sent to Arduino port A0.

The connections are like the pictures below:

iii. Data for Frequency Measurement:

The line power signal consists of a voltage with magnitude of 230 V and a frequency of 50

Hz. Our aim is to measure this frequency accurately using the Arduino. The voltage rating of

the microcontroller of Arduino is 5 V. So, any signal having amplitude of more than 5V can

damage the microcontroller.

Thus, a transformer is used to convert 230V voltage to around 6.9V. Then a voltage divider

circuit is used where two 10KΩ resistances are used. We get an output of 3.3V which is sent

to A0 of Arduino.

Page 7: Smart Energy Meter

FOR ANY INFO PLEASE CONTACT: [email protected]

7

The voltage and current data taken by the Arduino port are then sent to the

laptop with a serial data port and necessary calculations are done using MATLAB

software. That gives us our desired output values of real power, power factor and frequency

.

Arduino Uno & Arduino Leonardo:

The Arduino Uno is a microcontroller board based on the ATmega328P. It has 14 digital

input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz

quartz crystal, a USB connection, a power jack, an ICSP header and a reset button. It

contains everything needed to support the microcontroller; simply connected to a computer

Page 8: Smart Energy Meter

FOR ANY INFO PLEASE CONTACT: [email protected]

8

with a USB cable or powered with a AC-to-DC adapter or battery to get started. The Uno can

be programmed with the Arduino Software.

The Arduino Leonardo is a microcontroller board based on the ATmega32u4 (datasheet). It

has 20 digital input/output pins (of which 7 can be used as PWM outputs and 12 as analog

Page 9: Smart Energy Meter

FOR ANY INFO PLEASE CONTACT: [email protected]

9

inputs), a 16 MHz crystal oscillator, a micro USB connection, a power jack, an ICSP header,

and a reset button.

Software Part and Simulation: We used two software in this project for calculation of our datas-

Page 10: Smart Energy Meter

FOR ANY INFO PLEASE CONTACT: [email protected]

10

i. Calculation in Arduino

ii. Calculation in MATLAB

i. Calculation in Arduino:

The Arduino board we have mentioned in the hardware part is mainly used

to take sampled data from the AC input source. For that a code is written to

initialize the Arduino input and output port with proper baud rate and sampling

rate.

Here current and voltage output from hardware part is connected to the A0

and A1 pin respectively and both grounds are connected to common ground pin

at Arduino board. After that the sampled data are sent to the laptop one after

another for further calculations in MATLAB through serial port communication.

Arduino code for power fator,voltage,current,power :

int analogPin1 = A0; // current at analog pin 0 int analogPin2 = A1; // voltage at analog pin 1 int val = 0; // variable to store the value read void setup() Serial.begin(115200); // setup serial void loop() val = analogRead(analogPin1); // read the input pin Serial.println(val); // debug value delay(10); val = analogRead(analogPin2); // read the input pin Serial.println(val); // debug value delay(10);

Page 11: Smart Energy Meter

FOR ANY INFO PLEASE CONTACT: [email protected]

11

ii. Calculation in MATLAB:

Actually all the analytical calculations are done here in MATLAB. A proper

MATLAB code has been written to initialize a serial port for the incoming data

and all the data are stored in an array one by one. As we are calculating both the

voltage and current, the serial port gives data sample one after another. So, it has

been easier to separate the voltage and current samples. Then rms voltage, rms

current, reactive power and average power have been measured for a group of

data comprising of 170 samples each. With these the power factor is calculated

and after every 170 samples, the calculations are updated. To keep the record of

the change of data a table has been provided to tabulate the results for every

group of samplesFrom the table we can observe the value of the power

factor of the system.

Code of MATLAB: (For voltage,current,power and power factor):

clear

clc

%% Define Function Variables

j=0;

realpower=0;

reactivepower=0;

pf=0;

vd=0;

id=0;

vis=0;

m=0;

vrms=0;

irms=0;

viavg=0;

val=16/1;

ct=0;

min = -400; % set y-min

max = 400; % set y-max

scrollWidth = 15; % display period in plot, plot entire data log if <= 0

delay = .015; % make sure sample faster than resolution

time = 0;

data1 = 0;

data2=0;

count = 0;

%% Set up Plot

fmain = figure(1);

subplot(2,1,1)

plotGraph=plot(time,data1,'r');

ylabel('Current','FontSize',15);

grid on

Page 12: Smart Energy Meter

FOR ANY INFO PLEASE CONTACT: [email protected]

12

subplot(2,1,2)

plotGraph2=plot(time,data2);

grid on

xlabel('Elapsed Time (s)','FontSize',15);

ylabel('Voltage','FontSize',15);

%% Open Serial COM Port

s = serial('COM11','Baudrate',115200);

disp('Close Plot to End Session');

fopen(s);

% read data from serial port

tic

dt = [];

f = figure('Position',[500 500 580 390],'Name','Output Data'); % table

while (1)

z1=fgets(s);

z1=str2double(z1);

z1=z1*5/1024;

z1=z1-2.5;%offset

z1=z1/1000;%why?????????????????????????????????????????

dat1=z1*10;%gojamil

z2=fgets(s);

z2=str2double(z2);

z2=z2*5/1024;

z2=z2-0;%offset

z2=(z2*val);%why???????????????????????????????????????????????????????????

???

dat2=z2*32.5/6.95;%voltage divider turns ratio

count = count + 1;

time(count) = toc; %Extract Elapsed Time

if (abs(dat1)>0.15)%thresold

data1(count) = dat1; %Extract 1st Data Element

else data1(count)=0;

end

data2(count) = dat2; %Extract 2nd Data Element

j=count;

%% calculation vrms,irms,pf

vsqr=data2(j).^2+vd;

vd=vsqr;

visum=data2(j)*data1(j)+vis;

vis=visum;

isqr=data1(j).^2+id;

id=isqr;

m=mod(count,170);

if (m==0)

m=170;

end

if (m==170)

vrms=sqrt(vsqr/170);

irms=sqrt(isqr/170);

viavg=(visum/170);

realpower=abs(viavg);

Page 13: Smart Energy Meter

FOR ANY INFO PLEASE CONTACT: [email protected]

13

reactivepower= sqrt((vrms*irms).^2 -(viavg).^2);

energy=realpower*time(count)/(1000*3600);

pf=-viavg/(vrms*irms);

vd=0;

id=0;

vis=0;

ct=ct+1;

end

%% disply data in table

if (ct==1)

dt = [dt;time(end) vrms irms realpower reactivepower energy pf];

cnames = 'time','Voltage_rms','current_rms','Real Power','Reactive

Power','energy','power factor';

t = uitable;

set(t,'Parent',f,'Data',dt,'ColumnName',cnames,'ColumnWidth',81,'Position

',[40 60 640 450]);

ct=0;

end

%% Set Axis according to Scroll Width

if(scrollWidth > 0)

set(plotGraph,'XData',time(time > time(count)-

scrollWidth),'YData',data1(time > time(count)-scrollWidth));

set(plotGraph2,'XData',time(time > time(count)-

scrollWidth),'YData',data2(time > time(count)-scrollWidth));

set(0,'CurrentFigure',fmain)

axis([time(count)-scrollWidth time(count) min max]);

else

set(plotGraph,'XData',time,'YData',data1);

set(plotGraph2,'XData',time,'YData',data2);

set(0,'CurrentFigure',fmain)

axis([0 time(count) min max]);

end

pause(delay);

end

%Close Serial COM Port and Delete useless Variables

fclose(s);

clear count dat1 dat2 delay max min plotGraph1 plotGraph2 plotGrid

plotTitle s scrollWidth serialPort xLabel yLabel

disp('Session Terminated...');

Code For Frequency measurement:

/* Analog Input Demonstrates analog input by reading an analog sensor on analog pin 0 and turning on and off a light emitting diode(LED) connected to digital pin 13. The amount of time the LED will be on and off depends on

Page 14: Smart Energy Meter

FOR ANY INFO PLEASE CONTACT: [email protected]

14

the value obtained by analogRead(). The circuit: * Potentiometer attached to analog input 0 * center pin of the potentiometer to the analog pin * one side pin (either one) to ground * the other side pin to +5V * LED anode (long leg) attached to digital output 13 * LED cathode (short leg) attached to ground * Note: because most Arduinos have a built-in LED attached to pin 13 on the board, the LED is optional. Created by David Cuartielles Modified 16 Jun 2009 By Tom Igoe http://arduino.cc/en/Tutorial/AnalogInput */ #include <math.h> #include <LiquidCrystal.h> // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12,11,5,4,3,2); #define acosf acos int sensorPin = 0; // select the input pin for the potentiometer // select the pin for the LED int sensorValue = 0; // variable to store the value coming from the sensor int x = 0; int i; int y; int z; long a; int b; int k=0; long c; int arr[250] ; unsigned long time; void setup() // declare the ledPin as an OUTPUT: pinMode(12,OUTPUT); pinMode(13,OUTPUT); digitalWrite(12,HIGH);

Page 15: Smart Energy Meter

FOR ANY INFO PLEASE CONTACT: [email protected]

15

digitalWrite(13,LOW); Serial.begin(9600); time = millis(); Serial.println(time); for(i=0;i<250;i=i+1) arr[i] = analogRead(sensorPin); time = millis(); Serial.println(time); // Print a message to the LCD. //for(i=0;i<251;i=i+1) // //Serial.println(arr[i]); // float f; for(i=0;i<250;i=i+1) if(arr[i]==0 && arr[i+1]!=0) while(arr[i+1]!=0) k=k+1; //Serial.println("k"); i=i+1; break; f=1000/(2*k*0.112); Serial.println(k); Serial.println("FREQUENCY MEASURED IS"); Serial.println(f); lcd.begin(16, 2); // Print a message to the LCD. lcd.print("Frequency is :"); lcd.setCursor(0, 1); // print the number of seconds since reset:

Page 16: Smart Energy Meter

FOR ANY INFO PLEASE CONTACT: [email protected]

16

lcd.print(f); void loop() // read the value from the sensor: // turn the ledPin on //digitalWrite(ledPin, HIGH); // stop the program for <sensorValue> milliseconds: // turn the ledPin off: //digitalWrite(ledPin, LOW); // stop the program for for <sensorValue> milliseconds: //delay(sensorValue);

Outputs:

For Real Power, Energy, Power factor:

In computer’s monitor , we get this values for voltages and currents after a specific time

interval. From the codes, we get the real power, reactive power, energy and power factor.

Page 17: Smart Energy Meter

FOR ANY INFO PLEASE CONTACT: [email protected]

17

For Frequency:

In LCD display, when the switch is on and current flows through the bulb, we can see a value

of 49.60 Hz.

If the switch is off, it shows a garbage value.

Page 18: Smart Energy Meter

FOR ANY INFO PLEASE CONTACT: [email protected]

18

Problems we faced:

. While making the entire project we have faced a lot of problems. We are mentioning only

some of the major problems here:

1) As the line voltage is 230V and we needed 5V for our Arduino as it can not take more

than 5V, we had to try several times for getting the desired ratio of the transformer.

2) We had to use the command delete(instrfindal) to clear the Arduino COM port.

Otherwise there are unexpected values.

3) We used a lower baud rate at first and the sampling rate was not capable of giving

the exact values.After that we used a higher baud rate, and this problem was solved.

4) We used two separate Arduino borad for simplifying out work. Arduino UNO is used

for measuring frequency and Arduino Leonardo is used for measuring voltages and

currents.