project21 final paper

19
ECE445 Senior Design Final Report Prepaid Electricity Meter Ankit Chandak Yen-Chia Huang Pattaramon Vuttipittayamongkol Department of Electrical and Computer Engineering University of Illinois at Urbana-Champaign 04 May 2011

Upload: manorama-tewary

Post on 17-Oct-2014

24 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Project21 Final Paper

ECE445 Senior Design

Final Report

Prepaid Electricity Meter

Ankit Chandak

Yen-Chia Huang

Pattaramon Vuttipittayamongkol

Department of Electrical and Computer Engineering

University of Illinois at Urbana-Champaign

04 May 2011

Page 2: Project21 Final Paper

1

ABSTRACT

Our team designed and built a prepaid energy meter with a GSM module. The GSM

module provides a mode of communication between the user/meter and the utility. This

will enable the user to recharge his electricity account from home. This will also enable

the user to carry his electricity account with him, eliminating the need to set up a new

account every time the user changes homes. The GSM module will also get real time

electricity rates and enable the utility to keep a check on electricity theft. Our model of

the energy meter samples the current and voltage waveform using the ADC available on

the PIC microcontroller and computes real power, taking into account, the power factor

of the load.

The device was implemented with GSM to transmit the exchanged data between the end-

users, which are a utility company and a customer. The keypad is used to get banking

information from an electricity customer, and the LCD will display the user’s account

balance and the present electricity rate. The LED light will blink when the balance goes

below the threshold to remind the user to refill the account. If the balance goes down to

zero, the power will be cut off.

Page 3: Project21 Final Paper

2

TABLE OF CONTENTS

1. INTRODUCTION ....................................................................................................................3

1.1 Objective .............................................................................................................................3

1.2 Specifications ......................................................................................................................3

1.3 Subprojects .........................................................................................................................4

1.3.1 LCD Display ..............................................................................................................4

1.3.2 Keypad .......................................................................................................................4

1.3.3 Current Sensing Module ............................................................................................4

1.3.4 Voltage Sensing Module ...........................................................................................4

1.3.5 Power Measurement Module .....................................................................................4

1.3.6 GSM Module .............................................................................................................5

1.3.7 User Interface Program .............................................................................................5

2. DESIGN PROCEDURE ...........................................................................................................6

2.1 Current Sensing Module Design .........................................................................................6

2.2 Voltage Sensing Module Design ........................................................................................6

2.3 Power Measurement Module Design ..................................................................................7

3. DESIGN DETAILS ..................................................................................................................8

3.1 LCD Display .......................................................................................................................8

3.2 Keypad ................................................................................................................................8

3.3 Current Sensing Module .....................................................................................................8

3.4 Voltage Sensing Module .....................................................................................................9

3.5 Power Measurement Module ..............................................................................................9

3.6 GSM Module ....................................................................................................................10

3.7 User Interface Program .....................................................................................................10

4. DESIGN VERIFICATION .....................................................................................................12

4.1 LCD Display .....................................................................................................................12

4.2 Keypad ..............................................................................................................................12

4.3 Current Sensing Module ...................................................................................................12

4.4 Voltage Sensing Module ...................................................................................................14

4.5 Power Measurement Module ............................................................................................14

4.6 GSM Module ....................................................................................................................15

4.7 User Interface Program .....................................................................................................15

5. COST ......................................................................................................................................16

5.1 Parts ..................................................................................................................................16

5.2 Labor .................................................................................................................................16

6. CONCLUSIONS ....................................................................................................................17

REFERENCES .......................................................................................................................18

Page 4: Project21 Final Paper

3

1. INTRODUCTION

We designed and built a prepaid electricity meter. This meter will be the medium

between an individual household and the utility company for conducting money

transactions and exchanging the current electricity rate and usage. Although prepaid

meters have been out in the market nowadays, we are aiming for a better performance in

term of coverage range and wireless technology seems to handle this issue well.

1.1 Objective

Upon completion, we would like our meter to be able to do the following things:

1. Measure electricity consumption accurately.

2. Display real time account balance.

3. Communicate with the utility company to:

Let the user recharge his electricity account from the meter

Using a previously used card

Using a new card

Update rates for electricity as and when required

Perform a daily/hourly verification of electricity consumption

4. Warn the user of low account balance by flashing an LED

5. Cut power off when there is zero credit on the account.

In order to complete the afore mentioned tasks, we plan to make accurate power

measurements, interface an LCD display as well as a keypad with the central

microcontroller unit and implement a transceiver module in our system.

1.2 Specifications

An electricity meter provides an interface between the utility and the customer.

Successfully implemented, our product will benefit the end customer as well as the

electric utility in the following ways:

The customer can recharge his account wirelessly from his home.

The customer can use a different card every time. He will not have to worry about

his default credit card already been maxed out.

The device will show the remaining balance so that the user knows how much he

has consumed and can plan ahead to not overuse the budget and know when he

needs to refill the account.

The display will also show the current electricity rate. Since electricity rates vary

throughout the day, the user can cut down on consumption when the rate is high.

The utility companies will have a better idea of electricity demand. This will help

them to plan ahead.

Page 5: Project21 Final Paper

4

The utility companies would be able to collect the expenses from customers in

advance, so they will no longer have to deal with late payments or non-paying

customers.

Since the meter will send daily/hourly consumption data to the utility company, it

will help reduce electricity theft.

Our product will have the following features:

Wireless capabilities to recharge the account from home.

Provision of a keypad to recharge the account from a different card every time.

LCD to display real time account balance and the current electricity rate.

LED to warn the user of low account balance.

Automatic shut-down feature once the account balance is zero

1.3 Subprojects

The design was broken into many modules, which each perform specific tasks.

1.3.1 LCD Display

The LCD display is used for displaying user account information, account balance and

power usage. It also acts as an interface between user and power meter.

1.3.2 Keypad

The keypad allow user to input his/her account number, credit number and PIN number.

1.3.3 Current Sensing Module

The current sensor needed to monitor the current flow by measuring and reporting the

actual current usage and the current phase angle to the microcontroller. The current

sensor needed to operate accurately and linearly in order to obtain the accurate usage and

consequently the accurate power usage. Lastly, the current sensor was expected to be able

to hold the maximum current of 10 Amperes.

1.3.4 Voltage Sensing Module

The voltage sensor needed to measure voltage and the phase angle of the voltage across

the load accurately, and it was expected to behave linearly in some specific voltage range.

1.3.5 Power Measurement Module

The power measurement module takes the scaled-down signals from the voltage divider

and the current transducer and computes the real power consumed by the load. These

power consumptions readings then are used to compute the real time balance for the

customer.

Page 6: Project21 Final Paper

5

1.3.6 GSM Module

GSM module transmits user’s account information from power meter to utility company

and also receives data from utility company.

1.3.7 User Interface Program

The user interface program is consist of a finite state machine and was loaded onto PIC

micro-controller. The state machine jumps from one state to another based on different

conditions.

Page 7: Project21 Final Paper

6

2. DESIGN PROCEDURE

2.1 Current Sensing Module Design

The current sensor was designed to connect directly to the load on the input side and to

the microcontroller on the output side. The input to the entity was the value of the voltage

drop across a shunt resistor and the output to the microcontroller was the voltage that was

proportional to the input voltage. The ratio of the input and output voltage would depend

on the model of the current transformer used in the circuit. Because the 120 AC volts

would be apply to the load but the maximum input voltage that the microcontroller we

used was 5 Volts, we then were looking for a current transformer that had the turn ration

of at least 1: 25 including any error, in order to scale the 120 AC supply voltage down

within a 5 volt constraint.

After searching for a proper current transformer, the main component of this module, we

decided to go with the LAH 25-NP current transducer, which has all the properties within

our constraints. The LAH 25-NP current transducer works with both DC and AC. It can

be configured to have a turn ratio of 1:1000, 2:1000, or 3:1000. Different turn ratio comes

with different nominal and maximum primary currents; thus after considering all the

factors, we chose the configuration of 1:1000 turn ratio with 25A nominal current and

55A maximum current in order to have the optimize result even though any of these three

configurations would work fine with our circuit.

2.2 Voltage Sensing Module Design

The voltage sensor module was designed to be connected to the power supply on the

input side and to the microcontroller on the output side. As this module would be

connected directly to the power supply, we wanted to insert an isolated voltage amplifier

or optocoupler, which will conduct the current signal without electrical connection

between the input and output in order to prevent high voltages or rapidly changing

voltages on one side of the circuit from damaging components on the other side. After

searching for a proper optocouple, we carefully decided to use the HCPL-7800A

Isolation Amplifier, which had a broad ambient operating temperature of

and worked accurate and linearly in the range of -200 to 200 mV.

Because the microcontroller we decided to use had the maximum input voltage of 5

Volts, we would need to add a voltage divider somewhere in between the 120 voltage

supply and the microcontroller.

Page 8: Project21 Final Paper

7

Figure1. Complete Current and Voltage Sensor circuit

2.3 Power Measurement Module Design

The power consumed by the load is calculated by sampling the current and voltage

waveforms for their peak values. The peak values are then used to compute the RMS

values of the signals. Next, the power factor is calculated as explained in the next section.

Once we get the RMS values for the current and voltage signals and the power factor of

the load, we easily compute the real power consumed by the load.

Page 9: Project21 Final Paper

8

3. DESIGN DETAILS

3.1 LCD Display

We use 16x2 Lumex LCD display for our meter. This LCD uses 5V power supply and

the contrast is adjustable. We interface LCD with PIC micro-controller using 4-Pin

control mode. For LCD driver, we use the code from CCS forum; the detail will be

included in reference section.

3.2 Keypad

In order to interface hex keypad and PIC micro-controller, we need to use matrix

decoding. One of disadvantages of using this keypad is the debouncing issue, and we are

able to solve it using the software method. We use the keypad driver code also from CCS

forum.

3.3 Current Sensing Module

Figure2. Current Sensor Circuit

The current sensor circuit was designed to measure the current passing through the load.

To scale down the output voltage from the load, the LAH 25-NP was placed in between

the load and the PIC microcontroller as seen in Figure 1. Also, we a shunt resistor was

needed to be placed in between the current transducer and the PIC microcontroller

because the output of the current sensor was a voltage, and thus the current through the

load could be obtained by the division of the output voltage value over the shunt resistor

value.

The turn ratio of 1:1000 of the current transducer results in a maximum of 0.12 Volts on

the output side. Thus, the voltage limit to the PIC16F877A microcontroller is in the

proper range. The voltage will never exceed 0.12 Volts as a positive voltage across the

load indicates that the output side of the load will have a voltage lower than 120 Volts.

The output flowing can be obtained by the equation:

(Eq1)

Page 10: Project21 Final Paper

9

3.4 Voltage Sensing Module

Figure3. Voltage Sensor Circuit

Knowing from the HCPL-7800A that it behaved accurately and linearly in the range of -

200 to 200 mV, we scaled down the input voltage from the 120 V supply to be within the

range by placing a voltage divider circuit in between. The circuit divider consisted of two

resistors that their values were measured and recorded for the purpose of later power

calculation. We calculated the ratio of the two resistors from

(Eq2)

Then, we got the ratio of R1:R2 999:1.

Because the input to the optocouple would not exceed 0.2 Volts, the output to the

microcontroller would be in the proper range, which was within 5 Volts.

3.5 Power Measurement Module

We start power measurement by sampling the input voltage and current signals and

sampling them to get their peak values. These peak values are then used to compute the

RMS values of these signals using the following relation:

(Eq3)

The code to sample the waveforms is included in the appendix.

After obtaining the RMS values for the input signals, we find out the phase difference

between the two signals to compute the power factor for real power calculation.

Page 11: Project21 Final Paper

10

Figure4. Voltage and current waveforms for power factor calculation

The power factor was calculated using the following algorithm and the code is included

in the appendix.

Both the voltage and the current signals are sent through a comparator with the reference

voltage set at 0V. Now, the half-period of the waveform is calculated by setting the

counter when the voltage comparator reads a ‘1’. Let this value be C1. After this, a

logical construct is used to set the counter only when both the voltage comparator and the

current comparator are set as ‘1’. This value is named as C2. The difference between C1

and C2, calibrated against time (since the frequency is known) gives the phase difference.

The cosine of this phase difference gives the power factor.

After obtaining the power factor and the RMS values of the voltage and current signals,

real power can be computed as follows.

(Eq4)

3.6 GSM Module

Our original idea is to connect the GSM module (GM862) to PIC micro-controller. First

we test the AT commands by connecting GSM to computer using Putty. The result is that

we are able to send and receive messages using AT command without any major issues.

In order to interface GSM module with PIC micro-controller, we have to remove the

solder jumper on the GSM evaluation board to separate the connection between USB

ports and the module. We use hardware UART channel of PIC which consist of two

signal lines, TX and RX. However, when we send AT commands to GSM, we never get

any signal back from it. We also try using logic analyzer to test if GSM ever responds to

the input signal from PIC. The result from logic analyzer shows that GSM did output

signal. However, we were not able to read it inside the PIC micro-controller.

3.7 User Interface Program

The user interface program consists of six states from state zero to state five. When the

meter first starts, it always starts from state zero which does all the initialization. Once

initialization process is done, it automatically goes to next state which is state one. In

Page 12: Project21 Final Paper

11

state one, the meter asks user to input account number and account PIN number. This

information will be sent to utility company through GSM module. Once the confirmation

signal is received by power meter, it also extracts account balance from utility company.

If the account balance is normal, the meter goes into normal operation mode. If the

account balance is low, it will remind user to recharge. Once the balance goes to zero, the

user can choose to recharge or shut down the meter.

Page 13: Project21 Final Paper

12

4. DESIGN VERIFICATION

4.1 LCD Display

For testing LCD display, first we power up the LCD and test the limitation of adjustable

contrast. Finally we decide to use 0V for contrast input. Secondly, we send data from PIC

micro-controller and test if LCD displays the correct value. After we are able to interface

keypad with PIC, we also try inputting data from keypad and test if LCD displays the

correct value.

4.2 Keypad

The most important thing for testing keypad is to make sure we have solved the

debouncing issue. The way we test it is by constantly pressing one key and make sure

LCD still displays the correct value.

4.3 Current Sensing Module

Figure5. Current Transducer

To test if the current sensor module worked properly, we powered the LAH 25-NP

current transducer with +12V and -12V supplies, inserted three different values of loads

and three different values of input voltages from the function generator across each load

for each test, then measured the output current using a multi-meter in the ammeter mode.

By apply equation (3.1.1), we could calculate the expected output current of each test.

Then, we compared the expected and the observed currents to see how much the error

was. The table 1 below shows the results from the testing procedures. The theoretical and

observed results are to be compared in the two right most columns.

Page 14: Project21 Final Paper

13

Table1 Results from the Current Sensor Circuit Testing

R1

(Ω)

Vin

(V)

Expected Iin

(mA)

Experiment Iin

(mA)

Expected Io

(mA)

Experiment Io

(mA)

Error*

(%)

1488 12 8.064516129 8.05 0.0080645 0.00804 0.303801

1488 20 13.44086022 13.54 0.0134409 0.01353 0.662902

1488 25 16.80107527 16.98 0.0168011 0.0172 2.374249

744 12 16.12903226 16.12 0.016129 0.0164 1.680203

744 20 26.88172043 26.86 0.0268817 0.027 0.440076

744 25 33.60215054 33.54 0.0336022 0.03353 0.214867

38.9 12 308.4832905 308.33 0.3084833 0.309 0.167497

38.9 20 514.1388175 514.01 0.5141388 0.521 1.334503

38.9 25 642.6735219 642.47 0.6426735 0.656 2.073603

The plot of expected and the observed currents from the table 1 is shown below to make

it easier to compare those values. We can see that most parts of the lines overlap, which

indicates that the errors are very small.

* Error (%) = –

(Eq5)

Figure6 Plots Comparing the Expected and Observed Current from table1

Page 15: Project21 Final Paper

14

4.4 Voltage Sensing Module

To make sure that the voltage sensor module worked properly, we tested the HCPL-

7800A give us accurate result and linear input-output relationship. We input the isolated

amplifier with different voltages and measure the output voltages. Table 888 shows the

results and the gain

.

Table2. HCPL-7800A Isolated Voltage Amplifier Testing Results

R1 (Ω) R2 (Ω) Input (V) Output (V) Vo/Vin

300 300 0.05 0.394 7.88

300 300 0.1 0.794 7.94

300 300 0.15 1.194 7.96

300 300 0.2 1.594 7.97

300 300 0.3 2.395 7.98

300 300 0.31 and above 2.56 7.31

These results verified that the chip behaved linearly when the output voltage was no

higher than 0.3 Volts and the average gain was around 7.95.

Moreover, with the input limit and the gain, the amplified output to the microcontroller

would not exceed 5 volts. Therefore, the voltage sensor module had been proved to be

proper to add to the rest of the circuit of the project.

4.5 Power Measurement Module

We tested the power measurement module by sending two 60 Hz sine wave signals from

a function generator. We chose a function generator for testing purposes as it gave us the

freedom of choosing the frequency and amplitude of input signals, thus helping in

debugging sampling and phase measurement algorithms. Following is the data obtained

while measuring the peak value of the input signal:

Table3. Data from scaling input current and voltage signals with scaling factor

Input Value Reading Scaling Factor Peak Value

0.5 11 1/23 0.48

1 24 1/23 1.04

2 46 1/23 2.00

3 70 1/23 3.04

4 91 1/23 3.95

5 114 1/23 4.95

Page 16: Project21 Final Paper

15

The phase measurement algorithm was tested by building the circuit and testing it for

various different capacitive and inductive loads and measuring the power factor with the

help of the watt-meter in the power lab and verifying the result against the power factor

calculated by our algorithm. Following is a snapshot of this procedure:

Figure7. Phase angle measurement testing

The two different values of the power factor are tabulated below:

Power Factorwatt-meter Power Factorour meter

-0.93 -0.93

-0.76 -0.74

0.13 0.15 Table4. Power Factor comparison

4.6 GSM Module

When connecting the GSM module to computer using Putty, we use AT command to

make sure we can perform bi-directional communication. We also test if there is any data

loss during the process. The result was perfect.

4.7 User Interface Program

Our user interface program is a finite state machine. For testing it, we make sure it goes

from one state to another based on the desired condition and never get stuck at any states.

Page 17: Project21 Final Paper

16

5. COST

5.1 Parts

Table5. Parts cost

Parts For Quantity Price($)/Unit Total($)

HCPL 7800A

Isolated Voltage

Amplifier

Power

Measurement 1 10 10

LAH25NP Current

Transducer

Power

Measurement 1 23 23

Power IC ADE

7753

Power

Measurement 1 5 5

PIC 16F877A

Micro-controller MPU 1 8 8

GM 862 GSM

Module Transceiver 1 20 20

4x4 HEX Keypad User

Interface 1 10 10

2x16 LCD User

Interface 1 15 15

Capacitor

(100nF*2, 0.1uF*3,

1uF*1, 10uF*2,

24uF*2)

10 0.32 3.2

Resistor (8ohm*1,

10ohm*1,

1kohm*1,

10kohm*1,

2.4kohm*1

5 0.32 1.6

5.2 Labor

Table6. Labor cost

Name Salary ($/hr.) # of Hours Cost of Labor

(Salary*hrs.*2.5) ($)

Ankit Chandak

40 200 20000

Pattaramon

Vuttipittayamongkol 40 200 20000

Yen-Chia Huang

40 200 20000

Total cost = Parts + Labor = $60,120

Page 18: Project21 Final Paper

17

6. CONCLUSIONS

Our team was successfully able to build a power measurement system, complete with

voltage dividers, current transformers and a phase angle measurement algorithm. We

were able to interface an LCD display as well as a matrix keypad with our system and

also successfully implement a user interface program. This user interface notifies the user

of his current account balance and assists him in recharging/managing his account. We

also tested the GSM module successfully using a terminal emulator application (PuTTY).

However, we weren’t able to interface the GSM module with the microcontroller.

Further work on this project can lead to the development of a utility-side program that

can manage the utility database and assist them to address account recharge requests.

Page 19: Project21 Final Paper

18

References

PCM programmer, “Flexible LCD driver”

http://www.ccsinfo.com/forum/viewtopic.php?t=24661

Ahmed, “Flexible Keypad Driver”

http://www.ccsinfo.com/forum/viewtopic.php?t=26333

Lukas Hoffmann, “PIC 16F877A Tutorials for Pitt Robotics Club”

http://www.pitt.edu/~sorc/robotics/Lukas%20PIC%20Tutorial.doc