Professional Documents
Culture Documents
PROJECT REPORT ON
Energy Meter data logging and online monitoring
using Matlab and Visual Basic.
Robo India | www.roboindia.com
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
Chapter 1
Introduction
A data logger (also datalogger or data recorder) is an electronic device that records data
over time or in relation to location either with a built in instrument or sensor or via
external instruments and sensors. Increasingly, but not entirely, they are based on a
digital processor (or computer). They generally are small, battery powered, portable,
and equipped with a microprocessor, internal memory for data storage, and sensors.
Some data loggers interface with a personal computer and utilize software to activate
the data logger and view and analyze the collected data, while others have a local
interface device (keypad, LCD) and can be used as a stand-alone device.
Data loggers vary between general purpose types for a range of measurement
applications to very specific devices for measuring in one environment or application
type only. It is common for general purpose types to be programmable; however, many
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
One of the primary benefits of using data loggers is the ability to automatically collect
data on a 24-hour basis. Upon activation, data loggers are typically deployed and left
unattended to measure and record information for the duration of the monitoring
period. This allows for a comprehensive, accurate picture of the environmental
conditions being monitored, such as air temperature and relative humidity.
The cost of data loggers has been declining over the years as technology improves and
costs are reduced. Simple single channel data loggers cost as little.
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
Chapter 2
Objective
The main objective of our project is to log data. The project is has got load support.
Load can be connected through the project. This project will show the energy
consumption live on the computer software. These readings of consumption are also
recorded in a separate log file. This log file is compatible for Microsoft Excel.
These file stores energy reading with date and time. These log file are very useful in
industry and needed to be observed in most of the industries.
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
Chapter 3
Methodology
The following block diagram explains working of the system, later we shall discuss all of
the components of the diagram.
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
Chapter 4
Programming of hardware controller
This chapter elaborate the programming of hardware controller.
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
external chips for memory and peripheral interface circuits) are also still common,
especially in more complex systems. In either case, the processor(s) used may be types
ranging from rather general purpose to very specialised in certain class of
computations, or even custom designed for the application at hand. A common standard
class of dedicated processors is the digital signal processor (DSP).
The key characteristic, however, is being dedicated to handle a particular task. Since the
embedded system is dedicated to specific tasks, design engineers can optimize it to
reduce the size and cost of the product and increase the reliability and performance.
Some embedded systems are mass-produced, benefiting from economies of scale.
Physically, embedded systems range from portable devices such as digital watches and
MP3 players, to large stationary installations like traffic lights, factory controllers, and
largely complex systems like hybrid vehicles, MRI, and avionics. Complexity varies from
low, with a single microcontroller chip, to very high with multiple units, peripherals and
networks mounted inside a large chassis or enclosure.
Embedded systems are commonly found in consumer, cooking, industrial, automotive,
medical, commercial and military applications.
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
applications. The Atmel Studio 6 IDP gives you a seamless and easy-to-use environment
to write, build and debug your applications written in C/C++ or assembly code.
Atmel Studio 6 is free of charge and is integrated with the Atmel Software Framework
(ASF)a large library of free source code with 1,600 ARM and AVR project examples.
ASF strengthens the IDP by providing, in the same environment, access to ready-to-use
code that minimizes much of the low-level design required for projects. Use the IDP for
our wide variety of AVR and ARM Cortex-M processor-based MCUs, including our
broadened portfolio of Atmel SAM3 ARM Cortex-M3 and M4 Flash devices.
With the introduction of Atmel Gallery and Atmel Spaces, Atmel Studio 6 further
simplifies embedded MCU designs to reduce development time and cost. Atmel Gallery
is an online apps store for development tools and embedded software. Atmel Spaces is a
cloud-based collaborative development workspace allowing you to host software and
hardware projects targeting Atmel MCUs.
In summary, standard integrated development environments (IDEs) are suited for
creating new software for an MCU project. By contrast, the Atmel Studio 6 IDP also:
Facilitates reuse of existing software and, by doing so, enables design differentiation.
Supports the product development process with easy access to integrated tools and
software extensions through Atmel Gallery. Reduces time to market by providing
advanced features, an extensible software eco-system, and powerful debug integration.
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
10
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
Chapter 5
The parts & Interfacing
Following are the parts of the project.
11
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
weighed, and the customer billed. The electrochemical meter was labor-intensive to
read and not well received by customers.
An early type of electrochemical meter used in the United Kingdom was the 'Reason'
meter. This consisted of a vertically mounted glass structure with a mercury reservoir
at the top of the meter. As current was drawn from the supply, electrochemical action
transferred the mercury to the bottom of the column. Like all other DC meters, it
recorded ampere-hours. Once the mercury pool was exhausted, the meter became an
open circuit. It was therefore necessary for the consumer to pay for a further supply of
electricity, whereupon, the supplier's agent would unlock the meter from its mounting
and invert it restoring the mercury to the reservoir and the supply.
In 1885 Ferranti offered a mercury motor meter with a register similar to gas meters;
this had the advantage that the consumer could easily read the meter and verify
consumption. The first accurate, recording electricity consumption meter was a DC
meter by Dr Hermann Aron, who patented it in 1883. Hugo Hirst of the British General
Electric Company introduced it commercially into Great Britain from 1888.[3] Unlike
their AC counterparts, DC meters did not measure energy. Instead they measured
charge in ampere-hours. Since the voltage of the supply should remain substantially
constant, the reading of the meter was proportional to actual energy consumed. For
example: if a meter recorded that 100 ampere-hours had been consumed on a 200 volt
supply, then 20 kilowatt-hours of energy had been supplied. Aron's meter recorded the
total charge used over time, and showed it on a series of clock dials.
The first specimen of the AC kilowatt-hour meter produced on the basis of Hungarian
Ott Blthy's patent and named after him was presented by the Ganz Works at the
Frankfurt Fair in the autumn of 1889, and the first induction kilowatt-hour meter was
already marketed by the factory at the end of the same year. These were the first
alternating-current watt-hour meters, known by the name of Blthy-meters. The AC
kilowatt hour meters used at present operate on the same principle as Blthy's original
invention. Also around 1889, Elihu Thomson of the American General Electric company
developed a recording watt meter (watt-hour meter) based on an ironless commutator
12
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
motor. This meter overcame the disadvantages of the electrochemical type and could
operate on either alternating or direct current.
In 1894 Oliver Shallenberger of the Westinghouse Electric Corporation applied the
induction principle previously used only in AC ampere-hour meters to produce a watthour meter of the modern electromechanical form, using an induction disk whose
rotational speed was made proportional to the power in the circuit. The Blthy meter
was similar to Shallenberger and Thomson meter in that they are two-phase motor
meter. Although the induction meter would only work on alternating current, it
eliminated the delicate and troublesome commutator of the Thomson design.
Shallenberger fell ill and was unable to refine his initial large and heavy design,
although he did also develop a polyphase version.
5.2 Energy Meter Reading
The most common unit of measurement on the electricity meter is the kilowatt hour
[kWh], which is equal to the amount of energy used by a load of one kilowatt over a
period of one hour, or 3,600,000 joules. Some electricity companies use the SI
megajoule instead.
Demand is normally measured in watts, but averaged over a period, most often a
quarter or half hour.
Reactive power is measured in "thousands of volt-ampere reactive-hours", (kvarh). By
convention, a "lagging" or inductive load, such as a motor, will have positive reactive
power. A "leading", or capacitive load, will have negative reactive power.
Volt-amperes measures all power passed through a distribution network, including
reactive and actual. This is equal to the product of root-mean-square volts and amperes.
Distortion of the electric current by loads is measured in several ways. Power factor is
the ratio of resistive (or real power) to volt-amperes. A capacitive load has a leading
power factor, and an inductive load has a lagging power factor. A purely resistive load
(such as a filament lamp, heater or kettle) exhibits a power factor of 1. Current
harmonics are a measure of distortion of the wave form. For example, electronic loads
13
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
such as computer power supplies draw their current at the voltage peak to fill their
internal storage elements. This can lead to a significant voltage drop near the supply
voltage peak which shows as a flattening of the voltage waveform. This flattening causes
odd harmonics which are not permissible if they exceed specific limits, as they are not
only wasteful, but may interfere with the operation of other equipment. Harmonic
emissions are mandated by law in EU and other countries to fall within specified limits.
14
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
15
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
mechanism which counts revolutions, much like the odometer in a car, in order to
render a measurement of the total energy used.
The type of meter described above is used on a single-phase AC supply. Different phase
configurations use additional voltage and current coils.
Three-phase electromechanical induction meter, metering 100 A 240/415 V supply.
Horizontal aluminum rotor disc is visible in center of meter
The disc is supported by a spindle which has a worm gear which drives the register. The
register is a series of dials which record the amount of energy used. The dials may be of
the cyclometer type, an odometer-like display that is easy to read where for each dial a
single digit is shown through a window in the face of the meter, or of the pointer type
where a pointer indicates each digit. With the dial pointer type, adjacent pointers
generally rotate in opposite directions due to the gearing mechanism.
The amount of energy represented by one revolution of the disc is denoted by the
symbol Kh which is given in units of watt-hours per revolution. The value 7.2 is
commonly seen. Using the value of Kh one can determine their power consumption at
any given time by timing the disc with a stopwatch.
P = {{3600 \cdot Kh } \over t}.
Where:
t = time in seconds taken by the disc to complete one revolution,
P = power in watts.
For example, if Kh = 7.2 as above, and one revolution took place in 14.4 seconds, the
power is 1800 watts. This method can be used to determine the power consumption of
household devices by switching them on one by one.
16
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
reading may be supplied to the power company by telephone, post or over the internet.
The electricity company will normally require a visit by a company representative at
least annually in order to verify customer-supplied readings and to make a basic safety
check of the meter.
In an induction type meter, creep is a phenomenon that can adversely affect accuracy,
that occurs when the meter disc rotates continuously with potential applied and the
load terminals open circuited. A test for error due to creep is called a creep test.
17
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
The processing and communication section has the responsibility of calculating the
various derived quantities from the digital values generated by the metering engine.
This also has the responsibility of communication using various protocols and interface
with other addon modules connected as slaves to it.
RTC and other add-on modules are attached as slaves to the processing and
communication section for various input/output functions. On a modern meter most if
not all of this will be implemented inside the microprocessor, such as the real time clock
(RTC), LCD controller, temperature sensor, memory and analog to digital converters.
18
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
19
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
20
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
21
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
22
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
The AVR core combines a rich instruction set with 32 general purpose working
registers. All the 32 registers are directly connected to the Arithmetic Logic Unit (ALU),
allowing two independent registers to be accessed in one single instruction executed in
one clock cycle. The resulting architecture is more code efficient while achieving
throughputs up to ten times faster than conventional CISC microcontrollers. The
ATmega16 provides the following features: 16K bytes of In-System Programmable Flash
Program memory with Read-While-Write capabilities, 512 bytes EEPROM, 1K byte
SRAM, 32 general purpose I/O lines, 32 general purpose working registers, a JTAG
interface for Boundary scan, On-chip Debugging support and programming, three
flexible Timer/Counters with compare modes, Internal and External Interrupts, a serial
programmable USART, a byte oriented Two-wire Serial Interface, an 8-channel, 10-bit
ADC with optional differential input stage with programmable gain (TQFP package
only), a programmable Watchdog Timer with Internal Oscillator, an SPI serial port, and
six software selectable power saving modes. The Idle mode stops the CPU while
allowing the USART, Two-wire interface, A/D Converter, SRAM, Timer/Counters, SPI
port, and interrupt system to continue functioning. The Power-down mode saves the
register contents but freezes the Oscillator, disabling all other chip functions until the
next External Interrupt or Hardware Reset. In Power-save mode, the Asynchronous
Timer continues to run, allowing the user to maintain a timer base while the rest of the
device is sleeping. The ADC Noise Reduction mode stops the CPU and all I/O modules
except Asynchronous Timer and ADC, to minimize switching noise during ADC
conversions. In Standby mode, the crystal/resonator Oscillator is running while the rest
of the device is sleeping. This allows very fast start-up combined with low-power
consumption. In Extended Standby mode, both the main Oscillator and the
Asynchronous Timer continue to run. The device is manufactured using Atmels high
density non-volatile memory technology. The On chip ISP Flash allows the program
memory to be reprogrammed in-system through an SPI serial interface, by a
conventional non-volatile memory programmer, or by an On-chip Boot program
running on the AVR core. The boot program can use any interface to download the
application program in the Application Flash memory. Software in the Boot Flash
section will continue to run while the Application Flash section is updated, providing
true Re ad-While-Write operation. By combining an 8-bit RISC CPU with In-System SelfProgrammable Flash on a monolithic chip, the Atmel ATmega16 is a powerful
23
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
GND: Ground.
24
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
RESET: Reset Input. A low level on this pin for longer than the minimum
pulse length will generate a reset, even if the clock is not running.
AVCC: AVCC is the supply voltage pin for Port A and the A/D Converter. It
should be externally connected to VCC, even if the ADC is not used. If the
ADC is used, it should be connected to VCC through a low-pass filter.
AREF: AREF is the analog reference pin for the A/D Converter.
25
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
26
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
is used to alert the receiver that a word of data is about to be sent, and to force the clock
in the receiver into synchronization with the clock in the transmitter.
27
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
5.5 Software
The software we have got, is very easy to use. It requires the comport no. to
the project controller is attached. The complete operations of the project
can be controlled through the buttons provided in the software.
This software provide axis wise control.
28
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
Chapter 7
References
1. Atmega 16 data sheet.
2. USB to serial data sheet.
3. Serial communication manual of MS .net frame work
4. Serial communication manual of MATLAB.
5. Energy meter mannuals
29
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
Appendix 1
The codding
/*
* EM_dataLog.c
*
* Created: 19/Mar/2014 15:48:10
* Author: acer
*/
30
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
#include <avr/io.h>
#include <util/delay.h>
#include "lcd.h"
uint16_t E_data;
char digits[2];
/*Macros definition*/
#define BIT(x)
(1 << (x))
31
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
UCSRC=(1<<URSEL)|(3<<UCSZ0);
//Enable The receiver and transmitter
UCSRB=(1<<RXEN)|(1<<TXEN);
}
//This function is used to read the available data
//from USART. This function will wait untill data is
//available.
char USARTReadChar()
{
//Wait untill a data is available
while(!(UCSRA & (1<<RXC)))
{
//Do nothing
}
return UDR;
}
32
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
UDR=data;
}
int main(void)
{
int unit_main;
char unit_decimal;
char check=0;
int counter=0;
33
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
InitLCD(LS_BLINK);
USARTInit(103);
LCDClear();
LCDWriteStringXY(0,0," ENERGY METER ");
LCDWriteStringXY(0,1,"USB DATA LOGGER ");
_delay_ms(1500);
SETBIT(DDRC,BIT(5));
CLEARBIT(DDRC,BIT(4));
SETBIT(PORTC,BIT(4));
LCDClear();
/**********************************/
//First Time Initialisation to erase memory block//
//keep the fuse EF C1 to avoid erasing memory block//
//save_EEPROM(20,0);
//EEPROM_write(30,0);
//EEPROM_write(40,0);
/*********************************/
int i = EEPROM_read(40);
unit_decimal = EEPROM_read(30);
unit_main = read_EEPROM(20);
LCDWriteStringXY(4,1,".");
LCDWriteStringXY(0,0," ENERGY METER ");
34
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
LCDWriteStringXY(8,1,"KWh");
while(1)
{
//TODO:: Please write your application code
if(
(PINC&(1<<4)) == 0 )
{
//LCDWriteStringXY(0,1,"if loop");
SETBIT(PORTC,BIT(5));
_delay_ms(200);
CLEARBIT(PORTC,BIT(5));
i++;
//LCDWriteIntXY(0,0,i,3);
EEPROM_write(40,i);
check=1;
}
if(i==32)
{
i=0;
unit_decimal ++;
EEPROM_write(30,unit_decimal);
}
if (unit_decimal == 100)
35
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
{
unit_decimal = 0;
unit_main ++;
save_EEPROM(20,unit_main);
}
}
}
void USART_SEND_INT(int num)
{
char i=0,j=0;
if(num>999) return;
if(num>=0)
{
while(num)
{
digits[i]=num%10;
i++;
num=num/10;
}
36
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
for(j=i;j<=2;j++)
{
digits[j]=0;
}
}
USARTWriteChar(digits[2]+48);
USARTWriteChar(digits[1]+48);
USARTWriteChar(digits[0]+48);
}
if(num>=0)
{
while(num)
{
digits[i]=num%10;
i++;
num=num/10;
37
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
for(j=i;j<=1;j++)
{
digits[j]=0;
}
}
//USARTWriteChar(digits[2]+48);
USARTWriteChar(digits[1]+48);
USARTWriteChar(digits[0]+48);
}
save_EEPROM(unsigned int add,unsigned int data)
{
uint16_t data_l,data_h,data_f;
data_f = data;
data_l = data_f & 0x00FF;
data_h = data_f >> 8;
EEPROM_write(add,data_h);
add++;
EEPROM_write(add,data_l);
}
38
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
sei();
39
A project report on Energy Meter data logging and online monitoring using Matlab and Visual Basic.
EECR |= (1<<EEMWE);
/* Start eeprom write by setting EEWE */
EECR |= (1<<EEWE);
//
sei();
40