Project Report On: Energy Meter Monitoring Online Using Wireless Transmission

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 52

ROBO INDIA | Energy Meter monitoring online using wireless Transmission

PROJECT REPORT ON
Energy Meter monitoring online using wireless
transmission

Page 1
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

Chapter 1
Introduction

Wireless communication is the transfer of information between two or more points that
are not connected by an electrical conductor.

Here in our project we have used GSM for the wireless communication.

GSM (Global System for Mobile Communications, originally Groupe Spécial Mobile), is a
standard developed by the European Telecommunications Standards Institute (ETSI) to
describe protocols for second generation (2G) digital cellular networks used by mobile
phones. It is the de facto global standard for mobile communications with over 90%
market share, and is available in over 219 countries and territories.

Page 2
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

The GSM standard was developed as a replacement for first generation (1G) analog
cellular networks, and originally described a digital, circuit-switched network optimized
for full duplex voice telephony. This was expanded over time to include data
communications, first by circuit-switched transport, then packet data transport via
GPRS (General Packet Radio Services) and EDGE (Enhanced Data rates for GSM
Evolution or EGPRS).

Subsequently, the 3GPP developed third generation (3G) UMTS standards followed by
fourth generation (4G) LTE Advanced standards, which are not part of the ETSI GSM
standard.

"GSM" is a trademark owned by the GSM Association. It may also refer to the initially
most common voice codec used, Full Rate.

In 1981, work began to develop a European standard for digital cellular voice telephony
when the European Conference of Postal and Telecommunications Administrations
(CEPT) created the Groupe Spécial Mobile committee and later provided a permanent
technical support group based in Paris. Five years later, in 1987, 15 representatives
from 13 European countries signed a memorandum of understanding in Copenhagen to
develop and deploy a common cellular telephone system across Europe, and EU rules
were passed to make GSM a mandatory standard. The decision to develop a continental
standard eventually resulted in a unified, open, standard-based network which was
larger than that in the United States. In 1989, the Groupe Spécial Mobile committee was
transferred from CEPT to the European Telecommunications Standards Institute (ETSI).

In 1987 Europe produced the very first agreed GSM Technical Specification in February.
Ministers from the four big EU countries cemented their political support for GSM with
the Bonn Declaration on Global Information Networks in May and the GSM MoU was
tabled for signature in September. The MoU drew-in mobile operators from across
Europe to pledge to invest in new GSM networks to an ambitious common date. It got
GSM up and running fast.

In this short 37-week period the whole of Europe (countries and industries) had been
brought behind GSM in a rare unity and speed guided by four public officials Armin
Silberhorn (Germany), Stephen Temple (UK), Philippe Dupuis (France), and Renzo Failli

Page 3
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

(Italy).[8] In 1989 the Groupe Spécial Mobile committee was transferred from CEPT to
the European Telecommunications Standards Institute (ETSI).

In parallel, France and Germany signed a joint development agreement in 1984 and
were joined by Italy and the UK in 1986. In 1986 the European Commission proposed
reserving the 900 MHz spectrum band for GSM.

Phase I of the GSM specifications were published in 1990. The world's first GSM call was
made by the former Finnish prime minister Harri Holkeri to Kaarina Suonio (mayor in
city of Tampere) on July 1, 1991, on a network built by Telenokia and Siemens and
operated by Radiolinja.[9] The following year in 1992, the first short messaging service
(SMS or "text message") message was sent and Vodafone UK and Telecom Finland
signed the first international roaming agreement.

Work began in 1991 to expand the GSM standard to the 1800 MHz frequency band and
the first 1800 MHz network became operational in the UK by 1993. Also that year,
Telecom Australia became the first network operator to deploy a GSM network outside
Europe and the first practical hand-held GSM mobile phone became available.

In 1995, fax, data and SMS messaging services were launched commercially, the first
1900 MHz GSM network became operational in the United States and GSM subscribers
worldwide exceeded 10 million. Also this year, the GSM Association was formed. Pre-
paid GSM SIM cards were launched in 1996 and worldwide GSM subscribers passed 100
million in 1998.

In 2000, the first commercial GPRS services were launched and the first GPRS
compatible handsets became available for sale. In 2001 the first UMTS (W-CDMA)
network was launched, a 3G technology that is not part of GSM. Worldwide GSM
subscribers exceeded 500 million. In 2002 the first Multimedia Messaging Service
(MMS) were introduced and the first GSM network in the 800 MHz frequency band
became operational. EDGE services first became operational in a network in 2003 and
the number of worldwide GSM subscribers exceeded 1 billion in 2004.

By 2005, GSM networks accounted for more than 75% of the worldwide cellular
network market, serving 1.5 billion subscribers. In 2005 the first HSDPA capable
network also became operational. The first HSUPA network was launched in 2007.

Page 4
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

High-Speed Packet Access (HSPA) and its uplink and downlink versions are 3G
technologies, not part of GSM. Worldwide GSM subscribers exceeded two billion in
2008.

The GSM Association estimated in 2010 that technologies defined in the GSM standard
serve 80% of the global mobile market, encompassing more than 5 billion people across
more than 212 countries and territories, making GSM the most ubiquitous of the many
standards for cellular networks.

It is important to note that GSM is a second-generation (2G) standard employing Time-


Division Multiple-Access (TDMA) spectrum-sharing, issued by the European
Telecommunications Standards Institute (ETSI). The GSM standard does not include the
3G UMTS CDMA-based technology nor the 4G LTE OFDMA-based technology standards
issued by the 3GPP.

Macau planned to phase out its 2G GSM networks as of June 4, 2015, making it the first
region to decommission a GSM network.

Page 5
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

Chapter 2
Objective

This project reads reading from an energy meter, displays that reading on the LCD
panel. Then it upload these reading on internet via http request. These readings are
easily accessible using a URL . Apart from monitoring it also record data, that too is
online accessible.

The objective of the project is to make the data available through the globe. Different
hardware and software have been used in this project. All these hardware and software
works in a coordination. For making HTTP request and response, online webserver is
used. The server is Linux server. For recording data we have use PHP My Admin data
base management system.

Page 6
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

Chapter 3
Methodology
The following block diagram explains working of the system, later we shall discuss all of
the components of the diagram.

Fig.2 | Block diagram

Page 7
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

Chapter 4
Programming of hardware controller
This chapter elaborate the programming of hardware controller.

4.1 Introduction to embedded C

Our project is made using embedded programming. The programming language


required for construction of the project is Embedded C. Here in this chapter we will see
the programming of the project and interfacing with the compiler. Before moving ahead
have a look on embedded system.

An embedded system is a computer system with a dedicated function within a larger


mechanical or electrical system, often with real-time computing constraints.It is
embedded as part of a complete device often including hardware and mechanical parts.
By contrast, a general-purpose computer, such as a personal computer (PC), is designed

Page 8
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

to be flexible and to meet a wide range of end-user needs. Embedded systems control
many devices in common use today.

Modern embedded systems are often based on microcontrollers (i.e CPUs with
integrated memory and/or peripheral interfaces) but ordinary microprocessors (using
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.

Telecommunications systems employ numerous embedded systems from telephone


switches for the network to cell phones at the end-user. Computer networking uses
dedicated routers and network bridges to route data.

Consumer electronics include personal digital assistants (PDAs), mp3 players, mobile
phones, videogame consoles, digital cameras, DVD players, GPS receivers, and printers.
Household appliances, such as microwave ovens, washing machines and dishwashers,
include embedded systems to provide flexibility, efficiency and features. Advanced
HVAC systems use networked thermostats to more accurately and efficiently control
temperature that can change by time of day and season. Home automation uses wired-

Page 9
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

and wireless-networking that can be used to control lights, climate, security,


audio/visual, surveillance, etc., all of which use embedded devices for sensing and
controlling.

Transportation systems from flight to automobiles increasingly use embedded systems.


New airplanes contain advanced avionics such as inertial guidance systems and GPS
receivers that also have considerable safety requirements. Various electric motors —
brushless DC motors, induction motors and DC motors — use electric/electronic motor
controllers. Automobiles, electric vehicles, and hybrid vehicles increasingly use
embedded systems to maximize efficiency and reduce pollution. Other automotive
safety systems include anti-lock braking system (ABS), Electronic Stability Control
(ESC/ESP), traction control (TCS) and automatic four-wheel drive.

Medical equipment uses embedded systems for vital signs monitoring, electronic
stethoscopes for amplifying sounds, and various medical imaging (PET, SPECT, CT, MRI)
for non-invasive internal inspections. Embedded systems within medical equipment are
often powered by industrial computers. Embedded systems are used in transportation,
fire safety, safety and security, medical applications and life critical systems, as these
systems can be isolated from hacking and thus, be more reliable.[citation needed] For
fire safety, the systems can be designed to have greater ability to handle higher
temperatures and continue to operate. In dealing with security, the embedded systems
can be self-sufficient and be able to deal with cut electrical and communication systems.

A new class of miniature wireless devices called motes are quickly gaining popularity as
the field of wireless sensor networking is increasing. Wireless sensor networking, WSN,
makes use of miniaturization made possible by advanced IC design to couple full
wireless subsystems to sophisticated sensors, enabling people and companies to
measure a myriad of things in the physical world and act on this information through IT
monitoring and control systems. These motes are completely self-contained, and will
typically run off a battery source for years before the batteries need to be changed or
charged.

Embedded Wi-Fi modules provide a simple means of wirelessly enabling any device
which communicates via a serial port.

Page
10
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

4.2 The compiler

Atmel® Studio 6 is the integrated development platform (IDP) for developing and
debugging Atmel ARM® Cortex®-M and Atmel AVR® microcontroller (MCU) based
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.

fig | Atmel Studio

Page
11
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

Chapter 5
The parts & Interfacing
Following are the parts of the project.

5.1. Energy Meter


An electricity meter or energy meter is a device that measures the amount of electric
energy consumed by a residence, business, or an electrically powered device.

Electricity meters are typically calibrated in billing units, the most common one being
the kilowatt hour [kWh]. Periodic readings of electricity meters establishes billing
cycles and energy used during a cycle.

In settings when energy savings during certain periods are desired, meters may
measure demand, the maximum use of power in some interval. "Time of day" metering
allows electric rates to be changed during a day, to record usage during peak high-cost

Page
12
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

periods and off-peak, lower-cost, periods. Also, in some areas meters have relays for
demand response load shedding during peak load periods.
As commercial use of electric energy spread in the 1880s, it became increasingly
important that an electric energy meter, similar to the then existing gas meters, was
required to properly bill customers for the cost of energy, instead of billing for a fixed
number of lamps per month. Many experimental types of meter were developed. Edison
at first worked on a DC electromechanical meter with a direct reading register, but
instead developed an electrochemical metering system, which used an electrolytic cell
to totalise current consumption. At periodic intervals the plates were removed,
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.

Page
13
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

The first specimen of the AC kilowatt-hour meter produced on the basis of Hungarian
Ottó Bláthy'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 Bláthy-meters. The AC
kilowatt hour meters used at present operate on the same principle as Bláthy'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
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 watt-
hour meter of the modern electromechanical form, using an induction disk whose
rotational speed was made proportional to the power in the circuit. The Bláthy 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.

Page
14
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

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
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.

5.3 Electro Mechanical Meter

The most common type of electricity meter is the electromechanical induction watt-
hour meter.

The electromechanical induction meter operates by counting the revolutions of a non-


magnetic, but electrically conductive, metal disc which is made to rotate at a speed
proportional to the power passing through the meter. The number of revolutions is thus
proportional to the energy usage. The voltage coil consumes a small and relatively
constant amount of power, typically around 2 watts which is not registered on the
meter. The current coil similarly consumes a small amount of power in proportion to
the square of the current flowing through it, typically up to a couple of watts at full load,
which is registered on the meter.

Page
15
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

Fig | Enegy Meter

The disc is acted upon by two sets of coils, which form, in effect, a two phase induction
motor. One coil is connected in such a way that it produces a magnetic flux in
proportion to the voltage and the other produces a magnetic flux in proportion to the
current. The field of the voltage coil is delayed by 90 degrees, due to the coil's inductive
nature, and calibrated using a lag coil. This produces eddy currents in the disc and the
effect is such that a force is exerted on the disc in proportion to the product of the
instantaneous current, voltage and phase angle (power factor) between them. A
permanent magnet exerts an opposing force proportional to the speed of rotation of the
disc. The equilibrium between these two opposing forces results in the disc rotating at a
speed proportional to the power or rate of energy usage. The disc drives a register

Page
16
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

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.

Most domestic electricity meters must be read manually, whether by a representative of


the power company or by the customer. Where the customer reads the meter, the

Page
17
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

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.

5.4 Electronic Meters

Electronic meters display the energy used on an LCD or LED display, and some can also
transmit readings to remote places. In addition to measuring energy used, electronic
meters can also record other parameters of the load and supply such as instantaneous
and maximum rate of usage demands, voltages, power factor and reactive power used
etc. They can also support time-of-day billing, for example, recording the amount of
energy used during on-peak and off-peak hours.

Solid-state design: Solid state electricity meter used in a home in the Netherlands. Basic
block diagram of an electronic energy meter As in the block diagram, the meter has a
power supply, a metering engine, a processing and communication engine (i.e. a
microcontroller), and other add-on modules such as RTC, LCD display, communication
ports/modules and so on. The metering engine is given the voltage and current inputs
and has a voltage reference, samplers and quantisers followed by an ADC section to
yield the digitised equivalents of all the inputs. These inputs are then processed using a
digital signal processor to calculate the various metering parameters such as powers,
energies etc.

The largest source of long-term errors in the meter is drift in the preamp, followed by
the precision of the voltage reference. Both of these vary with temperature as well, and
vary wildly because most meters are outdoors. Characterising and compensating for
these is a major part of meter design.

Page
18
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

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.

5.3 The controller

Robotic arm controller comprises several electronic components. Here we will discuss
the important parts of the circuit.

5.3.1 The microcontroller (Atmega 8)

The ATmega16 is a low-power CMOS 8-bit microcontroller based on the AVR enhanced
RISC architecture. By executing powerful instructions in a single clock cycle, the
ATmega16 achieves throughputs approaching 1 MIPS per MHz allowing the system
designer to optimize power consumption versus processing speed.

Page
19
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

Fig.| Atmega 16 Pinout diagram. | PDIP package

Page
20
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

Fig.| Atmega 16 Pinout diagram. | TQFP package

Page
21
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

Fig.| Atmega 16 Pinout diagram. | MLF package

Page
22
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

Fig.31 | Block diagram of Atmega 8

Page
23
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

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 Atmel’s 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 Self-
Programmable Flash on a monolithic chip, the Atmel ATmega16 is a powerful

Page
24
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

microcontroller that provides a highly-flexible and cost-effective solution to many


embedded control applications. The ATmega16 AVR is supported with a full suite of
program and system development tools including: C compilers, macro assemblers,
program debugger/simulators, in-circuit emulators, and evaluation kits.

5.3.1.1 Pin Description of ATmega 16.

 VCC: Digital supply voltage.


 GND: Ground.
 Port A (PA7..PA0): Port A serves as the analog inputs to the A/D
Converter. Port A also serves as an 8-bit bi-directional I/O port, if the A/D
Converter is not used. Port pins can provide internal pull-up resistors
(selected for each bit). The Port A output buffers have symmetrical drive
characteristics with both high sink and source capability. When pins PA0
to PA7 are used as inputs and are externally pulled low, they will source
current if the internal pull-up resistors are activated. The Port A pins are
tri-stated when a reset condition becomes active, even if the clock is not
running.
 Port B (PB7..PB0): Port B is an 8-bit bi-directional I/O port with internal
pull-up resistors (selected for each bit). The Port B output buffers have
symmetrical drive characteristics with both high sink and source
capability. As inputs, Port B pins that are externally pulled low will source
current if the pull-up resistors are activated. The Port B pins are tri-stated
when a reset condition becomes active, even if the clock is not running.
 Port C (PC7..PC0): Port C is an 8-bit bi-directional I/O port with internal
pull-up resistors (selected for each bit). The Port C output buffers have
symmetrical drive characteristics with both high sink and source
capability. As inputs, Port C pins that are externally pulled low will source
current if the pull-up resistors are activated. The Port C pins are tri-stated
when a reset condition becomes active, even if the clock is not running. If
the JTAG interface is enabled, the pull-up resistors on pins PC5(TDI),
PC3(TMS) and PC2(TCK) will be activated even if a reset occurs.

Page
25
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

 Port D (PD7..PD0): Port D is an 8-bit bi-directional I/O port with internal


pull-up resistors (selected for each bit). The Port D output buffers have
symmetrical drive characteristics with both high sink and source
capability. As inputs, Port D pins that are externally pulled low will source
current if the pull-up resistors are activated. The Port D pins are tri-stated
when a reset condition becomes active, even if the clock is not running.
 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.
 XTAL1: Input to the inverting Oscillator amplifier and input to the
internal clock operating circuit.
 XTAL2: Output from the inverting Oscillator amplifier.
 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.

5.3 Serial Communication:

Serial communication is a way enables different equipments to communicate with their


outside world. It is called serial because the data bits will be sent in a serial way over a
single line.

A personal computer has a serial port known as communication port or COM Port used
to connect a modem for example or any other device, there could be more than one COM
Port in a PC.

Serial ports are controlled by a special chip called UART (Universal Asynchronous
Receiver Transmitter). Different applications use different pins on the serial port and
this basically depend of the functions required. If we need to connect our PC for
example to some other device by serial port, then we have to read instruction manual
for that device to know how the pins on both sides must be connected and the setting
required.

Page
26
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

5.3.1 Advantages of Serial Communication

Serial communication has some advantages over the parallel communication. One of the
advantages is transmission distance, serial link can send data to a remote device more
far then parallel link. Also the cable connection of serial link is simpler then parallel link
and uses less number of wires.

Serial link is used also for Infrared communication, now many devices such as laptops &
printers can communicate via inferred link.

5.3.2 Communication methods

There are two methods for serial communication, Synchronous & Asynchronous.

5.3.2.1 Synchronous serial communication:

In Synchronous serial communication the receiver must know when to “read” the next
bit coming from the sender, this can be achieved by sharing a clock between sender and
receiver.

In most forms of serial Synchronous communication, if there is no data available at a


given time to transmit, a fill character will be sent instead so that data is always being
transmitted. Synchronous communication is usually more efficient because only data
bits are transmitted between sender and receiver, however it will be more costly
because extra wiring and control circuits are required to share a clock signal between
the sender and receiver.

5.3.2.2 Asynchronous serial communication:

Asynchronous transmission allows data to be transmitted without the sender having to


send a clock signal to the receiver. Instead, special bits will be added to each word in
order to synchronize the sending and receiving of the data.

When a word is given to the UART for Asynchronous transmissions, a bit called the
“Start Bit” is added to the beginning of each word that is to be transmitted. The Start Bit

Page
27
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

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.

Fig.32 | Example of serial data transmission

After the Start Bit, the individual bits of the word of data are sent, each bit in the word is
transmitted for exactly the same amount of time as all of the other bits

When the entire data word has been sent, the transmitter may add a Parity Bit that the
transmitter generates. The Parity Bit may be used by the receiver to perform simple
error checking. Then at least one Stop Bit is sent by the transmitter.

If the Stop Bit does not appear when it is supposed to, the UART considers the entire
word to be garbled and will report a Framing Error.

5.4 GSM Modem

Fig | GSM Modem

Page
28
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

SIMCom Wireless Solutions is a subsidiary of SIM Technology Group Ltd (stock code:
2000. H.K). It is a fast growing[citation needed] wireless M2M company, designing and
offering a variety of wireless modules based on GSM/GPRS/EDGE, WCDMA/HSDPA and
TD-SCDMA technical platforms

By partnering with third parties, SIMCom Wireless provides customized design


solutions in M2M, WLL, Mobile Computing, GPS and other applications. SIMCom
Wireless also provides ODM services for customers.

According to ABI Insight report, SIMCom Cellular Module was number two provider of
wireless modules worldwide in 2008 with 20% acquisition of global market share in
2009 the launched SIM 900.

5.5 Server site application


http://scl.fabroll.com this is the URL that is needed to be accessed. This URL tell about
the last reading and the last time when the data was recorded. Below mentioned image
is the glimpse of the server page.

Fig | The web application

Page
29
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

Chapter 7
References
1. Atmega 16 data sheet.
2. USB to serial data sheet.
3. Energy meter manuals
4. Serial communication manuals of AVR
5. GSM Modem manual
6. AT commands manual

Page
30
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

Appendix 1
The codding
/*

* Source code.c

* Created: 19/Mar/2014 15:48:10

* Author: acer

*/

#include <avr/io.h>

Page
31
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

#include <util/delay.h>

#include "lcd.h"

uint16_t E_data;

char digits[2];

/*Macros definition*/

#define BIT(x) (1 << (x)) //Set a particular bit mask

#define CHECKBIT(x,b) x&b //Checks bit status

#define SETBIT(x,b) x|=b; //Sets the particular bit

#define CLEARBIT(x,b) x&=~b; //Sets the particular bit

#define TOGGLEBIT(x,b) x^=b; //Toggles the particular bit

void EEPROM_write(unsigned int uiAddress, unsigned char ucData);

unsigned char EEPROM_read(unsigned int uiAddress);

save_EEPROM(unsigned int add,unsigned int data);

read_EEPROM(unsigned int add);

void USART_SEND_INT(int data);

void USART_SEND_DEC(int num);

void USARTInit(uint16_t ubrr_value)

Page
32
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

UBRRL = ubrr_value;

UBRRH = (ubrr_value>>8);

UCSRC=(1<<URSEL)|(3<<UCSZ0);

UCSRB=(1<<RXEN)|(1<<TXEN);

char USARTReadChar()//For reading a single character

while(!(UCSRA & (1<<RXC)))

//Do nothing

return UDR;

Page
33
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

void USARTWriteChar(char data)//For writing a single character

while(!(UCSRA & (1<<UDRE)))

//Do nothing

UDR=data;

void USARTWriteString(char* StringPtr)//For writing a string

while(*StringPtr != 0x00)

{ //Here we check if there is still more chars to send, this is done


checking the actual char and see if it is different from the null char

USARTWriteChar(*StringPtr); //Using the simple send function we send


one char at a time

StringPtr++;

} //We increment the pointer so we can read the next char

Page
34
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

void SIM900Init(void)

char command[60];

char ret;

sprintf(command, "AT+SAPBR=3,1,\"APN\",\"airtelgprs.com\"");

USARTWriteString(command);

USARTWriteChar(13);

USARTWriteChar(10);

LCDWriteStringXY (0,0, "Setting up GPRS.");

_delay_ms(1000);

LCDClear();

for(int i = 0; i<2; i++)

ret = USARTReadChar();

if (ret == 13)

//i--;

else if (ret ==10)

Page
35
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

//i--;

else

LCDGotoXY(i,0);

LCDData(ret);

_delay_ms(1000);

sprintf(command, "AT+SAPBR=1,1");
USARTWriteString(command);
USARTWriteChar(13);

USARTWriteChar(10);
LCDClear();
LCDWriteStringXY(0,0, "Setting APN");
_delay_ms(1000);
LCDClear();
for(int i = 0; i<2; i++)

ret = USARTReadChar();

if (ret == 13)

Page
36
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

//i--;

else if (ret ==10)

//i--;

else

LCDGotoXY(i,0);

LCDData(ret);

}
_delay_ms(1000);
sprintf(command, "AT+CREG?");
USARTWriteString(command);
USARTWriteChar(13);

USARTWriteChar(10);
LCDClear();
LCDWriteStringXY(0,0, "Checking registration status");

_delay_ms(1000);

Page
37
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

LCDClear();
for(int i = 0; i<2; i++)

ret = USARTReadChar();

if (ret == 13)

//i--;

else if (ret ==10)

//i--;

else

LCDGotoXY(i,0);

LCDData(ret);

_delay_ms(1000);
sprintf(command, "AT+SAPBR=2,1");

Page
38
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

USARTWriteString(command);
USARTWriteChar(13);

USARTWriteChar(10);
LCDClear();
LCDWriteStringXY(0,0,"Querying bearer 1");
_delay_ms(1000);
LCDClear();
for(int i = 0; i<2; i++)

ret = USARTReadChar();

if (ret == 13)

//i--;

else if (ret ==10)

//i--;

else

LCDGotoXY(i,0);

LCDData(ret);

Page
39
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

_delay_ms(1000);

sprintf(command, "AT+HTTPINIT");
USARTWriteString(command);
USARTWriteChar(13);

USARTWriteChar(10);
LCDClear();
LCDWriteStringXY(0,0,"Intializing HHTP");
_delay_ms(1000);
LCDClear();
for(int i = 0; i<2; i++)

ret = USARTReadChar();

if (ret == 13)

//i--;

else if (ret ==10)

//i--;

Page
40
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

else

LCDGotoXY(i,0);

LCDData(ret);

}
_delay_ms(1000);
}

void http_send(int main_, int dec_)


{
LCDClear();
char ret;
char command[100];
sprintf(command,
"AT+HTTPPARA=\"URL\",\"http://efyjaipur.com/shree_cement/load_pecrc.php?main=
%d&dec=%d\"", main_, dec_);
USARTWriteString(command);
USARTWriteChar(13);
USARTWriteChar(10);
LCDWriteStringXY(0,0, "Sending data to URL");
LCDWriteStringXY(0,1, "Reading");
LCDWriteStringXY(11,1, ".");
LCDWriteIntXY(8,1, main_,3);
LCDWriteIntXY(12,1, dec_,2);
_delay_ms(1000);

for(int i = 0; i<2; i++)

Page
41
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

ret = USARTReadChar();

if (ret == 13)

//i--;

else if (ret ==10)

//i--;

else

//LCDGotoXY(i,0);

//LCDData(ret);

}
_delay_ms(1000);
LCDClear();
sprintf(command, "AT+HTTPPARA=\"CID\",1");
USARTWriteString(command);
USARTWriteChar(13);

Page
42
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

USARTWriteChar(10);
LCDWriteStringXY(0,0, "Sending HTTP Parameters");

LCDWriteStringXY(0,1, "Reading");
LCDWriteStringXY(11,1, ".");
LCDWriteIntXY(8,1, main_,3);
LCDWriteIntXY(12,1, dec_,2);
_delay_ms(1000);
LCDClear();
for(int i = 0; i<2; i++)

ret = USARTReadChar();

if (ret == 13)

//i--;

else if (ret ==10)

//i--;

else

LCDGotoXY(i,0);

Page
43
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

LCDData(ret);

sprintf(command, "AT+HTTPACTION=0");
USARTWriteString(command);
USARTWriteChar(13);
USARTWriteChar(10);
LCDWriteStringXY(0,0, "Sending HTTP Action");
LCDWriteStringXY(0,1, "Reading");
LCDWriteStringXY(11,1, ".");
LCDWriteIntXY(8,1, main_,3);
LCDWriteIntXY(12,1, dec_,2);
_delay_ms(1000);
LCDClear();
for(int i = 0; i<2; i++)

ret = USARTReadChar();

if (ret == 13)

//i--;

else if (ret ==10)

//i--;

Page
44
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

else

LCDGotoXY(i,0);

LCDData(ret);

sprintf(command, "AT+HTTPREAD");
USARTWriteString(command);
USARTWriteChar(13);
USARTWriteChar(10);
LCDWriteStringXY(0,0, "Reading HTTP");
LCDWriteStringXY(0,1, "Reading");
LCDWriteStringXY(11,1, ".");
LCDWriteIntXY(8,1, main_,3);
LCDWriteIntXY(12,1, dec_,2);
_delay_ms(1000);
LCDClear();
for(int i = 0; i<2; i++)

ret = USARTReadChar();

if (ret == 13)

//i--;

Page
45
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

else if (ret ==10)

//i--;

else

LCDGotoXY(i,0);

LCDData(ret);

int main(void)

int unit_main;

char unit_decimal;

char check=0;

InitLCD(LS_BLINK);

Page
46
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

USARTInit(103);

SIM900Init();

LCDClear();

LCDWriteStringXY(0,0," ONLINE E Meter ");

LCDWriteStringXY(0,1," MONITORING ");

_delay_ms(1000);

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,".");

Page
47
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

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)

Page
48
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

unit_decimal = 0;

unit_main ++;

save_EEPROM(20,unit_main);

//LCDWriteIntXY(0,1,unit_main,4);

//LCDWriteIntXY(5,1,unit_decimal,2);

http_send(unit_main, unit_decimal);

_delay_ms(10000);

// else

// {

// LCDWriteStringXY(0,1,"else loop");

// }

Page
49
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

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);

read_EEPROM(unsigned int add)

//use E_data to store the full value

uint16_t data_l,data_h;

data_h = EEPROM_read(add);

add++;

Page
50
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

data_l = EEPROM_read(add);

E_data = ((data_h<<8)|data_l);

return E_data;

void EEPROM_write(unsigned int uiAddress, unsigned char ucData)

// sei();

/* Wait for completion of previous write */

while(EECR & (1<<EEWE))

/* Set up address and data registers */

EEAR = uiAddress;

EEDR = ucData;

/* Write logical one to EEMWE */

EECR |= (1<<EEMWE);

/* Start eeprom write by setting EEWE */

EECR |= (1<<EEWE);

// sei();

Page
51
ROBO INDIA | Energy Meter monitoring online using wireless Transmission

unsigned char EEPROM_read(unsigned int uiAddress)

//CLEARBIT(SREG,BIT(7));

/* Wait for completion of previous write */

while(EECR & (1<<EEWE))

/* Set up address register */

EEAR = uiAddress;

/* Start eeprom read by writing EERE */

EECR |= (1<<EERE);

/* Return data from data register */

return EEDR;

//SETBIT(SREG,BIT(7));

Page
52

You might also like