You are on page 1of 70

In this paper the differential mode(DM)electromagnetic interference (EMI)noise

of a single-phase boost power factor correction converter operating in critical


current mode was analyzed.The DM noise spectra are calculated based on the
mathematical model of EMI receiver and the required corner frequencies of
DM filter are obtained.It can be seen that the minimum corner frequencies are
determined by the maximum noise at 150Khz.With the relation between
magnitude of the inductor current ripple and the DM noise,the characterctics of
noise at 150Khz are obtained by analyzing the current ripple magnitude at
150Khz;thus,the worst conditions which have the maximum noise value are
figured out.Meanwhile,the maximum noises at 150Khz for different input
voltages are identical,so the DM filter can be designed based on one worst
spectrum at one input voltage without testing the spectra in other conditions.

INTRODUCTION
INTRODUCTION

From many years, the electric power systems hadundergone


negligible changes in their operating conditionsand the equipment employed for
their control and monitoring. Many attempts have been made to design
theenergy meter with instant billing but till now the designedenergy meters did
not give any replacement for the systemwhere the user has to connect the
recharge card torecharging unit, and then the units will be loaded intorecharge
card.

Objective
The objective of this project is to pay the Electricity Bill through
SMS.

Scope

This project is very useful in today’s life. By using this project we


can pay the Electricity Bill through SMS instead of standing in the queue in
front of the EB office.

CHAPTER-II
WORKING CONCEPT
2. PROPOSED WORK

In this proposed work we are implementing a prepaid electricity


meter connected to electricity office interface through GSM network. When we
use the electricity the amount which we had used is calculated by energy meter
at user interface. This information is passed to microcontroller .Here we use
8051 microcontroller programmed withEmbedded C language. This controller
decodes the information given by the electric meter and transmits the
information to LCD module and GSM modem.GSM modem consists of a SIM
card possessing unique number that transmits the information to electricity
board which again consists of a GSM modem connected to a PC.
The information from the modem is decoded and data base in
thePC is updated. This updated information is sent to user mobile.Now by just
recharging this mobile the bill amount can be settled. A conformation message
is sent to mobile about the bill settlement .The whole process is done
automatically without any manual involvement hence the probability of
occurrence of error is negligible
2.2BLOCK DIAGRAM
fig2.1Block diagram of advanced electricity control system

2.3MICROCONTROLLER
Microcontroller is a general purpose device, which integrates a number
of the components of a microprocessor system on to single chip. It has inbuilt
CPU, memory and peripherals to make it as a mini computer. A microcontroller
combines on to the same microchip:

 The CPU core


 Memory(both ROM and RAM)
 Some parallel digital i/o

Microcontrollers will combine other devices such as:

 A timer module to allow the microcontroller to perform tasks for


certain time periods.
 A serial i/o port to allow data to flow between the controller and other
devices such as a PIC or another microcontroller.
 An ADC to allow the microcontroller to accept analogue input data for
processing.

Microcontrollers are

 Smaller in size
 Consumes less power
 Inexpensive

2.4INTRODUCTION TO PIC
The microcontroller that has been used for this project is from PIC series. PIC
microcontroller is the first RISC based microcontroller fabricated in CMOS
(complimentary metal oxide semiconductor) that uses separate bus for
instruction and data allowing simultaneous access of program and data memory.

The main advantage of CMOS and RISC combination is low power


consumption resulting in a very small chip size with a small pin count. The
main advantage of CMOS is that it has immunity to noise than other fabrication
techniques

2.4.1PIC (16F877)

Various microcontrollers offer different kinds of memories. EEPROM,


EPROM, FLASH etc. are some of the memories of which FLASH is the most
recently developed. Technology that is used in pic16F877 is flash technology,
so that data is retained even when the power is switched off. Easy Programming
and Erasing are other features of PIC 16F877.

Direct, indirect, and relative addressing modes

•Power-on Reset (POR)

• Power-up Timer (PWRT) and Oscillator Start-up Timer (OST)

• Watchdog Timer (WDT) with its own on-chip RC Oscillator for reliable
operation

• Programmable code-protection

• Power saving SLEEP mode

• Selectable oscillator options

• Low-power, high-speed CMOS EPROM/EEPROM technology

• Fully static design


• In-Circuit Serial Programming (ICSP) via two pins

• Only single 5V source needed for programming capability

• In-Circuit Debugging via two pins

• Processor read/write access to program memory

• Wide operating voltage range: 2.5V to 5.5V

• High Sink/Source Current: 25 mA

• Commercial and Industrial temperature ranges

• Low-power consumption:

< 2mA typical @ 5V, 4 MHz

20mA typical @ 3V, 32 kHz

< 1mA typical standby current

2.4.2SPECIAL FEATURES OF PIC MICROCONTROLLER


2.4.2.1COREFEATURES
 High-performance RISC CPU
 Only 35 single word instructions to learn
 All single cycle instructions except for program branches which are two
cycle
 Operating speed: DC - 20 MHz clock input
 DC - 200 ns instruction cycle
 Up to 8K x 14 words of Flash Program Memory,
 Up to 368 x 8 bytes of Data Memory (RAM)
 Up to 256 x 8 bytes of EEPROM data memory
 Pin out compatible to the PIC16C73/74/76/77
 Interrupt capability (up to 14 internal/external
 Eight level deep hardware stack
 Direct, indirect, and relative addressing modes
 Power-on Reset (POR)
 Power-up Timer (PWRT) and Oscillator Start-up Timer (OST)
 Watchdog Timer (WDT) with its own on-chip RC Oscillator for reliable
operation
 Programmable code-protection
 Power saving SLEEP mode
 Selectable oscillator options
 Low-power, high-speed CMOS EPROM/EEPROM technology
 Fully static design
 In-Circuit Serial Programming (ICSP) via two pins
 Only single 5V source needed for programming capability
 In-Circuit Debugging via two pins
 Processor read/write access to program memory
 Wide operating voltage range: 2.5V to 5.5V
 High Sink/Source Current: 25 mA
 Commercial and Industrial temperature ranges
 Low-power consumption:
 < 2mA typical @ 5V, 4 MHz
o 20mA typical @ 3V, 32 kHz
 < 1mA typical standby current

2.4.2.2PERIPHERAL FEATURES

 Timer0: 8-bit timer/counter with 8-bitprescaler


 Timer1: 16-bit timer/counter with prescaler, can be incremented during
sleep
 via external crystal/clock
 Timer2: 8-bit timer/counter with 8-bit period register, prescaler and
postscaler
 Two Capture, Compare, PWM modules
 Capture is 16-bit, max resolution is 12.5 ns,
 Compare is 16-bit, max resolution is 200 ns,
 PWM max resolution is 10-bit
 10-bit multi-channel Analog-to-Digital converter
 Synchronous Serial Port (SSP) with SPI. (Master Mode) and I2C.
(Master/Slave)
 Universal Synchronous Asynchronous Receiver Transmitter
(USART/SCI) with
 9- bit address detection.
 Brown-out detection circuitry for Brown-out Reset (BOR)

2.4.3 ARCHITECTURE OF PIC 16F877


The complete architecture of PIC 16F877 is shown in the fig 2.1.
Table 2.1 gives details about the specifications of PIC 16F877. Fig 2.2 shows
the complete pin diagram of the IC PIC 16F877.

2.4.3.1 SPECIFICATIONS

DATA DATA
DEVICE PROGRAM FLASH
MEMORY EEPROM
PIC
8K 368 Bytes 256 Bytes
16F877

Table2.1

2.4.4 PIN DIAGRAM OF PIC 16F877


Fig.2.2Pin diagram of pic16f877

2.4.4.1PIN OUT DESCRIPTION


Table 2.2

Legend: I = input O = output I/O = input/output P = power

— = Not used TTL = TTL input ST = Schmitt Trigger input

Note

1. This buffer is a Schmitt Trigger input when configured as an external


interrupt 2. This buffer is a Schmitt Trigger input when used in serial
programming mode.
3. This buffer is a Schmitt Trigger input when configured as general purpose
I/O and a TTL

input when used in the Parallel Slave Port mode (for interfacing to a
microprocessor bus).

4. This buffer is a Schmitt Trigger input when configured in RC oscillator mode


and a

CMOS input otherwise.


Legend: I = input O = output I/O = input/output P = power

— = Not used TTL = TTL input ST = Schmitt Trigger input

Note :

1. This buffer is a Schmitt Trigger input when configured as an external


interrupt.

2. This buffer is a Schmitt Trigger input when used in serial programming


mode.

3. This buffer is a Schmitt Trigger input when configured as general purpose


I/O and a TTL

input when used in the Parallel Slave Port mode (for interfacing to a
microprocessor bus).

4. This buffer is a Schmitt Trigger input when configured in RC oscillator mode


and a

CMOS input otherwise.

2.5 I/O PORTS

Some pins for these I/O ports are multiplexed with an alternate function
for the peripheral features on the device. In general, when a peripheral is
enabled, that pin may not be used as a general purpose I/O pin.

Additional Information on I/O ports may be found in the IC micro™


Mid-Range Reference Manual,
2.5.1PORTA AND THE TRISA REGISTER

PORTA is a 6-bit wide bi-directional port. The corresponding data


direction register is TRISA. Setting a TRISA bit (=1) will make the
corresponding PORTA pin an input, i.e., put the corresponding output driver in
a Hi-impedance mode. Clearing a TRISA bit (=0) will make the corresponding
PORTA pin an output, i.e., put the contents of the output latch on the selected
pin. Reading the PORTA register reads the status of thepins whereas writing to
it will write to the port latch. All write operations are read-modify-write
operations. Therefore a write to a port implies that the port pins are read; this
value is modified, and then written to the port data latch. Pin RA4 is
multiplexed with the Timer0 module clock input to become the RA4/T0CKI
pin. The RA4/T0CKI pin is a Schmitt Trigger input and an open drain output.
All other RA port pins have TTL input levels and full CMOS output drivers.
Other PORTA pins are multiplexed with analog inputs andanalog VREF input.
The operation of each pin is selected by clearing/setting the control bits in the
ADCON1 register (A/D Control Register1).

The TRISA register controls the direction of the RA pins, even when
they are being used as analog inputs. The user must ensure the bits in the
TRISA register are maintained set when using them as analog inputs.
2.5.2 PORT A FUNCTION

Table 2.3

Legend: TTL = TTL input, ST = Schmitt Trigger input

2.5.3 SUMMARY OF REGISTERS ASSOCIATED WITH PORTA

Table 2.4

Legend: x = unknown, u = unchanged, - = unimplemented locations


read as '0'. Shaded cells are not used by PORTA.
2.6. DIGITAL ENERGY METER

Fig.2.3Circuit Diagram of digital energy meter

2.6.1Explanation:

This circuit relates to measure the energy consumption through Digital energy
meter. Here we are taken the output from digital energy meter and given to the
4N35 opto coupler IC input. Where the opto coupler is nothing but isolation
circuit. That is AC Line Digital logic isolator, which useful in AC line detection
over short circuit prevention. 4N37 (short) consists of a gallium arsenide
infrared emitting diode coupled with a silicon phototransistor in a dual in−line
package. In that IC output will be always low. When input comes from energy
meter gives logic high as output. If this IC output is low means the output of
BC547 is High, so the LED behind that operation is in Off condition also the
input given to controller also low. When the output of 4N37 is high means the
output of BC547 is Low, so the LED behind that operation is in On condition
also the input given to controller also high. Like this whenever the input comes
from digital energy meter, the LED on board will glow, also the input to
controller is changing their logic from high to low. Otherwise the output of
circuit remains high condition. The output logic is inverted through 74LS04
which is placed on the circuit at final point. So through the logic changes we
can measure the unit of consumption
2.7GSM MODULE

2.7.1 Global System for Mobile Communications

The Global System for Mobile Communications (GSM) is the


most popular standard for in the world. GSM service is used by over 2 billion
people across more than 212 countries and territories. The ubiquity of the GSM
standard makes international roaming very common between mobile phone
operators, enabling subscribers to use their phones in many parts of the world.
GSM differs significantly from its predecessors in that both signaling and
speech channels are Digital call quality, which means that it is considered a
second generation (2G) mobile phone system. This fact has also meant that data
communication was built into the system from the 3rd Generation Partnership
Project (3GPP).

The GSM logo is used to identify compatible handsets and equipment.

From the point of view of the consumers, the key advantage of


GSM systems has been higher digital voice quality and low cost alternatives to
making calls such as text messaging. The advantage for network operators has
been the ability to deploy equipment from different vendors because the open
standard allows easy inter-operability. Like other cellular standards GSM allows
network operators to offer roaming services which mean subscribers can use
their phones all over the world.

2.8 HISTORY OF GSM


The growth of cellular telephone systems took off in the early
1980s, particularly in Europe. The lack of a technological standardization
prompted the European Conference of Postal and Telecommunications
Administrations (CEPT) to create the Groupe Special Mobile (GSM) in 1982
with the objective of developing a standard for a mobile telephone system that
could be used across Europe.

In 1989, GSM responsibility was transferred to the European


Telecommunications Standards Institute (ETSI), and phase I of the GSM
specifications were published in 1990. By the end of 1993, over a million
subscribers were using GSM phone networks being operated by 70 carriers
across 48 countries.

2.8.1Structure of GSM Network

The network behind the GSM system seen by the customer is large
and complicated in order to provide all of the services which are required. It is
divided into a number of sections and these are each covered in separate
articles. The growth of cellular telephone systems took off in the early 1980s,
particularly in Europe. The lack of a technological standardization prompted the
European Conference of Postal and Telecommunications Administrations
(CEPT) to create the Groupe Special Mobile (GSM) in 1982 with the objective
of developing a standard for a mobile telephone system that could be used
across Europe.

The first GSM network was launched in 1991 by Radiolinja in


Finland.

In 1989, GSM responsibility was transferred to the European


Telecommunications Standards Institute (ETSI), and phase I of the GSM
specifications were published in 1990. By the end of 1993, over a million
subscribers were using GSM phone networks being operated by 70 carriers
across 48 countries.

 The Base Station Subsystem (the base stations and their controllers).
 The Network and Switching Subsystem (the part of the network most
similar to a fixed network). This is sometimes also just called the core
network.
 The GPRS Core Network (the optional part which allows packet based
Internet connections).
 All of the elements in the system combine to produce many GSM
services such as voice calls and SMS.

2.8.2.Subscriber identity module

One of the key features of GSM is the Subscriber Identity Module


(SIM), commonly known as a SIM card. The SIM is a detachable smart card
containing the user's subscription information and phonebook. This allows the
user to retain his or her information after switching handsets. Alternatively, the
user can also change operators while retaining the handset simply by changing
the SIM. Some operators will block this by allowing the phone to use only a
single SIM, or only a SIM issued by them; this practice is known as SIM
locking, and is illegal in some countries.

2.9INTRODUCTION TO GSM WIRELESS MODEMS


A wireless modem behaves like a dial-up modem. The main difference between
them is that a dial-up modem sends and receives A GSM modem is a wireless
modem that works with a GSM wireless network data through a fixed telephone
line while a wireless modem sends and receives data through radio waves.
A GSM modem can be an external device or a PC Card / PCMCIA Card.
Typically, an external GSM modem is connected to a computer through a serial
cable or a USB cable. A GSM modem in the form of a PC Card / PCMCIA
Card is designed for use with a laptop computer. It should be inserted into one
of the PC Card / PCMCIA Card slots of a laptop computer. Like a GSM mobile
phone, a GSM modem requires a SIM card from a wireless carrier in order to
operate.
As mentioned in earlier sections of this SMS tutorial, computers use AT
commands to control modems. Both GSM modems and dial-up modems
support a common set of standard AT commands. You can use a GSM modem
just like a dial-up modem.
In addition to the standard AT commands, GSM modems support an extended
set of AT commands. These extended AT commands are defined in the GSM
standards. With the extended AT commands, you can do things like:

 Reading, writing and deleting SMS messages.


 Sending SMS messages.
 Monitoring the signal strength.
 Facts and Application of GSM/ GPRS Modem
 The GSM/GPRS Modem comes with a serial interface through which the
modem can be controlled using AT command interface

2.10GSM MODEM APPLICATIONS


Fig. 2.10. GSM Modem Applications

Voice calls

Voice calls are not an application area to be targeted. In future if interfaces like
a microphone and speaker are provided for some applications.
SMS

SMS is an area where the modem can be used to provide features


• These SMS can be transmitted on certain trigger events in
automationsystem
• SMS can also be used in areas where small text information has to be
sent. The transmitter can be an automation system or machines like vending
machines, collection machines or applications like positioning systems where
the navigator keeps on sending SMS at particular time intervals
.

2.10.1 GSM Data Calls: Data calls can be made using this modem. Data calls
can be made to a normal PSTN modem/phone line also (even received). Data
calls are basically made to send/receive data streams between two units either
PC’s or embedded devices.

2.10.1.1Applications of data calls

•Devices that have communication on serial port either on PC.


•Devices that want to communicate with a remote server for data transfer.
•This capability of data transfer can help in reducing processing
requirements.
•The basic aim is to provide a wireless solution keeping the existing
firmware intact.
•The client’s firmware continues to work without any modifications.
• The interface on two sides can be between PC’s as well as embedded
devices

Fig 2..4. Interface of GSM Modem with PC/Embedded device


• Calls can be established by the terminals at either side to start data calls
• The Modem remains transparent during data transfer after the call is
established.
• Call establishment utility to be provided in case PC terminals
• Call establishment to be automated in case of embedded terminals. GSM
converter can be an option where intelligence of establishing calls has to be put
in case of embedded devices.

2.10.2Applications

2.10.2.1Access control devices: Now access control devices can communicate


with servers and security staff through SMS messaging. Complete log of
transaction is available at the head-office Server instantly without any wiring
involved and device can instantly alert security personnel on their mobile phone
in case of any problem.

2.10.2.2Transaction terminals: EDC machines, POS terminals can use SMS


messaging to confirm transactions from central servers. The main benefit is that
central server can be anywhere in the world. Today you need local servers in
every city with multiple telephone lines. You save huge infrastructure costs as
well as per transaction cost.

2.10.2.3Supply Chain Management: Today SCM require huge IT


infrastructure with leased lines, networking devices, data centre, workstations
and still you have large downtimes and high costs. You can do all this at a
fraction of the cost with GSM M2M technology. A central server in your head
office with GSM capability is the answer, you can receive instant transaction
data from all your branch offices, warehouses and business associates with low
cost and nil down time.
2.10.3Applications suitable for GSM Communication

2.10.3.1Short Data Size:

You data size per transaction should be small like 1-3 lines. e.g. banking
transaction data, sales/purchase data, consignment tracking data, updates. These
small but important transaction data can be sent through SMS messaging which
cost even less then a local telephone call or sometimes free of cost worldwide.
Hence with negligible cost you are able to send critical information to your head
office located anywhere in the world from multiple points. You can also transfer
faxes, large data through GSM but this will be as or more costly compared to
landline networks.

2.10.3.2Multiple remote data collection points:

If you have multiple data collections points situated all over your city,
state, country or worldwide you will benefit the most. The data can be sent from
multiple points like your branch offices, business associates, warehouses, agents
with devices like GSM modems connected to PCs, GSM electronic terminals
and Mobile phones. Many a times some places like warehouses may be situated
at remote location may not have landline or internet but you will have GSM
network still available easily.

2.10.3.3High uptime:

If your business require high uptime and availability GSM is best suitable
for you as GSM mobile networks have high uptime compared to landline,
internet and other communication mediums. Also in situations where you
expect that someone may sabotage your communication systems by cutting
wires or taping landlines, you can depend on GSM wireless communication.
2.10.3.4Large transaction volumes:

GSM SMS messaging can handle large number of transaction in a very


short time. You can receive large number SMS messages on your server like e-
mails without internet connectivity. E-mails normally get delayed a lot but SMS
messages are almost instantaneous for instant transactions. Consider situation
like shop owners doing credit card transaction with GSM technology instead of
conventional landlines. many a time you find local transaction servers busy as
these servers use multiple telephone lines to take care of multiple transactions,
whereas one GSM connection is enough to handle hundreds of transaction per
minute.

2.10.3.5Mobility, Quick installation:

GSM technology allows mobility, GSM terminals, modems can be just


picked and installed at other location unlike telephone lines. Also you can be
mobile with GSM terminals and can also communicate with server using your
mobile phone. You can just purchase the GSM hardware like modems,
terminals and mobile handsets, insert SIM cards, configure software and your
are ready for GSM communication. GSM solutions can be implemented within
few weeks whereas it may take many months

2.10.4 AT commands features

2.1.4.1 Wavecom line settings

A serial link handler is set with the following default values (factory settings)
autobaud, 8 bits data, 1 stop bit, no parity, and RTS/CTS flow control.

Use the +IPR, +IFC and +ICF commands to change these settings.
2.10.4.2Command line

Commands always start with AT (which means Attention) and finish with a
<CR> character.

2.10.4.3Information responses and result codes

Responses start and end with <CR><LF>, except for the ATV0 DCE response
format) and the ATQ1 (result code suppression) commands.

- If command syntax is incorrect, an ERROR string is returned.

- If command syntax is correct but with some incorrect parameters, the +CME
ERROR: <Err> or +CMS ERROR: <SmsErr> strings are returned with
different error codes.

-If the command line has been performed successfully, an OK string is returned.

AT command for sending message

Send message +CMGS

Description:

The <address> field is the address of the terminal to which the message is sent.
To send the message, simply type, <ctrl-Z> character (ASCII 26). The text can
contain all existing characters except <ctrl-Z> and <ESC> (ASCII 27).

This command can be aborted using the <ESC> character when entering text.

In PDU mode, only hexadecimal characters are used (‘0’…’9’,’A’…’F’).


Syntax:

Command syntax in text mode:

AT+CMGS= <da> [,<toda> ] <CR>

Text is entered <ctrl-Z / ESC >

Command syntax in PDU mode:

AT+CMGS= <length><CR>

PDU is entered <ctrl-Z / ESC >

Table 3.1 Commands and possible response for sending message

COMMANDS POSSIBLE RESPONSE


AT+CMGS=”+33146290800”<CR> +CMGS: <mr>
Hi <ctrl-Z> OK
Note: Send a message in text mode Note: Successful transmission
2.11PIC WITH MICROCONTROLLER

Fig.2.5 Pin diagram of PIC with microcontroller

We connect the LCD display with PIC through PORT B.


2.11.1 PORTB AND TRISB REGISTER:

PORTB is an 8-bit wide bi-directional port. The corresponding data direction


register is TRISB. Setting a TRISB bit (=1) will make the corresponding
PORTB pin an input, i.e., put the corresponding output driver in a hi-impedance
mode. Clearing a TRISB bit (=0) will make the corresponding PORTB pin an
output, i.e., put the contents of the output latch on the selected pin. Three pins of
PORTB are multiplexed with the Low Voltage Programming function;
RB3/PGM, RB6/PGC and RB7/PGD. The alternate functions of these pins are
described in the Special Features Section. Each of the PORTB pins has a weak
internal pull-up. A single control bit can turn on all the pull-ups.

This is performed by clearing bit RBPU (OPTION_REG<7>). The weak


pull-up is automatically turned off when the port pin is configured as an output.
The pull-ups are disabled on a Power-on Reset.

Four of PORT B’s pins, RB7:RB4, have an interrupt on change feature.


Only pins configured as inputs can cause this interrupt to occur (i.e. any
RB7:RB4 pin configured as an output is excluded from the interrupt on change
comparison). The input pins (of RB7:RB4) are compared with the old value
latched on the last read of PORTB. The “mismatch” outputs of RB7:RB4 are
OR’ed together to generate the RB Port Change Interrupt with flag bit RBIF
(INTCON<0>). This interrupt can wake the device from SLEEP. The user, in
the interrupt service routine, can clear the interrupt in the following manner:

a) Any read or write of PORTB. This will end the mismatch condition.

b) Clear flag bit RBIF. A mismatch condition will continue to set flag bit RBIF.
Reading PORTB will end the mismatch condition, and allow flag bit RBIF to be
cleared. The interrupt on change feature is recommended for wake-up on key
depression operation and operations where PORTB is only used for the interrupt
on change feature.
Polling of PORTB is not recommended while using the interrupt on
change feature. This interrupt on mismatch feature, together with software
configurable pull-ups on these four pins, allow easy interface to a keypad and
make it possible for wake-up on key depression

Table 2.5
2.12RELAY

Fig 2.6Circuit diagram of relay circuit

2.12.1Explanation

A relay is an electrically operated switch. Current flowing through the


coil of the relay creates a magnetic field which attracts a lever and changes the
switch contacts. The coil current can be on or off so relays have two switch
positions and they are doublethrow (changeover) switches. Relays allow one
circuit to switch a second circuit which can be completely separate from the
first. For example a low voltage battery circuit can use a relay to switch a 230V
AC mains circuit. There is no electrical connection inside the relay between the
two circuits; the link is magnetic and mechanical.

The coil of a relay passes a relatively large current, typically 30mA for a
12V relay, but it can be as much as 100mA for relays designed to operate from
lower voltages. Most ICs (chips) cannot provide this current and a transistor is
usually used to amplify the small IC current to the larger value required for the
relay coil. The maximum output current for the popular 555 timer IC is 200mA
so these devices can supply relay coils directly without amplification.

Relays are usually SPDT or DPDT but they can have many more sets of
switch contacts, for example relays with 4 sets of changeover contacts are
readily available. Most relays are designed for PCB mounting but you can
solder wires directly to the pins providing you take care to avoid melting the
plastic case of the relay. The animated picture shows a working relay with its
coil and switch contacts. You can see a lever on the left being attracted by
magnetism when the coil is switched on. This lever moves the switch contacts.
There is one set of contacts (SPDT) in the foreground and another behind them,
making the relay DPDT.
The relay's switch connections are usually labeled COM, NC and NO:

 COM = Common, always connect to this, it is the moving part of the


switch.
 NC = Normally Closed, COM is connected to this when the relay coil is
off.
 NO = Normally Open, COM is connected to this when the relay coil is
on.

2.12.2 Circuit description:

This circuit is designed to control the load. The load may be motor or
any other load. The load is turned ON and OFF through relay. The relay ON
and OFF is controlled by the pair of switching transistors (BC 547). The relay is
connected in the Q2 transistor collector terminal. A Relay is nothing but
electromagnetic switching device which consists of three pins. They are
Common, Normally close (NC) and Normally open (NO).

The relay common pin is connected to supply voltage. The normally


open (NO) pin connected to load. When high pulse signal is given to base of the
Q1 transistors, the transistor is conducting and shorts the collector and emitter
terminal and zero signals is given to base of the Q2 transistor. So the relay is
turned OFF state.

When low pulse is given to base of transistor Q1 transistor, the


transistor is turned OFF. Now 12v is given to base of Q2 transistor so the
transistor is conducting and relay is turned ON. Hence the common terminal
and NO terminal of relay are shorted. Now load gets the supply voltage through
relay.
Voltage Signal from Transistor Q1 Transistor Q2 Relay

Microcontroller or PC

1 on off off

0 off on on

2.12.3 Applications

 Relays are used to realize logic functions. They play a very important
role in providing safety critical logic.
 Relays are used to provide time delay functions. They are used to time
the delay open and delay close of contacts.
 Relays are used to control high voltage circuits with the help of low
voltage signals. Similarly they are used to control high current circuits
with the help of low current signals.
 They are also used as protective relays. By this function all the faults
during transmission and reception can be detected and isolated.
2.13ALARM

Fig.2.7Circuit diagram of alarm circuit

2.13.1 Buzzer:

A buzzer or beeper is a signalling device, usually electronic, typically


used in automobiles, household appliances such as a microwave oven, or game
shows. It most commonly consists of a number of switches or sensors connected
to a control unit that determines if and which button was pushed or a preset time
has lapsed, and usually illuminates a light on the appropriate button or control
panel, and sounds a warning in the form of a continuous or intermittent buzzing
or beeping sound. Initially this device was based on an electromechanical
system which was identical to an electric bell without the metal gong (which
makes the ringing noise).

Often these units were anchored to a wall or ceiling and used the ceiling
or wall as a sounding board. Another implementation with some AC-connected
devices was to implement a circuit to make the AC current into a noise loud
enough to drive a loudspeaker and hook this circuit up to a cheap 8-ohm
speaker. Nowadays, it is more popular to use a ceramic-based piezoelectric
sounder like a Sonalert which makes a high-pitched tone. Usually these were
hooked up to "driver" circuits which varied the pitch of the sound or pulsed the
sound on and off.

2.13.2 Circuit description:

The circuit is designed to control the buzzer. The buzzer ON and OFF is
controlled by the pair of switching transistors (BC 547). The buzzer is
connected in the Q2 transistor collector terminal.

When high pulse signal is given to base of the Q1 transistors, the transistor is
conducting and close the collector and emitter terminal so zero signals is given
to base of the Q2 transistor. Hence Q2 transistor and buzzer is turned OFF state.

When low pulse is given to base of transistor Q1 transistor, the transistor


is turned OFF. Now 12v is given to base of Q2 transistor so the transistor is
conducting and buzzer is energized and produces the sound signal.

Voltage Signal from Transistor Q1 Transistor Q2 Buzzer

Microcontroller or PC

1 on off off

0 off on on
2.14 RS232 COMMUNICATION

Fig.2.8 Circuit diagram of RS232

2.14.1 EXPLANATION

In telecommunications, RS-232 is a standard for serial binary data


interconnection between a DTE (Data terminal equipment) and a DCE (Data
Circuit-terminating Equipment). It is commonly used in computer serial ports.
2.14.2Scope of the Standard

The Electronic Industries Alliance (EIA) standard RS-232-C [3] as of 1969


defines:

 Electrical signal characteristics such as voltage levels, signaling


rate, timing and slew-rate of signals, voltage withstand level, short-
circuit behavior, maximum stray capacitance and cable length
 Interface mechanical characteristics, pluggable connectors and pin
identification
 Functions of each circuit in the interface connector
 Standard subsets of interface circuits for selected telecom
applications
The standard does not define such elements as character encoding (for
example, ASCII, Baudot or EBCDIC), or the framing of characters in the data
stream (bits per character, start/stop bits, parity). The standard does not define
protocols for error detection or algorithms for data compression.

The standard does not define bit rates for transmission, although the standard
says it is intended for bit rates lower than 20,000 bits per second. Many modern
devices can exceed this speed (38,400 and 57,600 bit/s being common, and
115,200 and 230,400 bit/s making occasional appearances) while still using RS-
232 compatible signal levels.Details of character format and transmission bit
rate are controlled by the serial port hardware, often a single integrated circuit
called a UART that converts data from parallel to serial form. A typical serial
port includes specialized driver and receiver integrated circuits to convert
between internal logic levels and RS-232 compatible signal levels.
2.14.3Circuit working Description:

In this circuit the MAX 232 IC used as level logic converter. The
MAX232 is a dual driver/receiver that includes a capacive voltage generator to
supply EIA 232 voltage levels from a single 5v supply. Each receiver converts
EIA-232 to 5v TTL/CMOS levels. Each driver converts TLL/CMOS input
levels into EIA-232 levels.

In this circuit the microcontroller transmitter pin is connected in the


MAX232 T2IN pin which converts input 5v TTL/CMOS level to RS232 level.
Then T2OUT pin is connected to reviver pin of 9 pin D type serial connector
which is directly connected to PC.

In PC the transmitting data is given to R2IN of MAX232 through


transmitting pin of 9 pin D type connector which converts the RS232 level to 5v
TTL/CMOS level. The R2OUT pin is connected to receiver pin of the
microcontroller. Likewise the data is transmitted and received between the
microcontroller and PC or other device vice versa.

2.15 REAL TIME CLOCK

2.15.1DESCRIPTION:

The DS12887 real-time clock (RTC) plus RAM is designed to be a


direct replacement for the DS1287.The DS12887 is identical in form, fit, and
function to the DS1287, and has an additional 64 bytes of general-purpose
RAM. The logic level presented on AD6 during the address portion of an access
cycle determines access to this additional RAM space. A lithium energy source,
quartz crystal, and write-protection circuitry are contained within a 24-pin dual
in-line package. As such, the DS12887 is a complete subsystem replacing 16
components in a typical application. The functions include a nonvolatile time-
of-day clock, an alarm, a 100-year calendar, programmable interrupt, square-
wave generator, and 114 bytes of NV SRAM. The RTC is unique in that time-
of-day and memory are maintained even in the absence of power.
2.15.2 Features:

 Drop-in replacement for IBM AT computer clock/calendar


 Pin-compatible with the MC146818B and DS1287
 Totally nonvolatile with over 10 years of operation in the absence of power
 Self-contained subsystem includes lithium, quartz, and support circuitry
 Counts seconds, minutes, hours, days, day of the week, date, month, and
year with leap-year compensation valid up to 2100
 Binary or BCD representation of time, calendar, and alarm
 12-hour or 24-hour clock with AM and PM in 12-hour mode
 Daylight Savings Time option
 Selectable between Motorola and Intel bus timing
 Multiplex bus for pin efficiency
 Interfaced with software as 128 RAM locations
 14 bytes of clock and control registers
 114 bytes of general-purpose RAM
 Programmable square-wave output signal
 Bus-compatible interrupt signals (IRQ)
 Three interrupts are separately software-maskable and testable
 Time-of-day alarm once/second to once/day
 Periodic rates from 122ms to 500ms
 End-of-clock update cycle
 Underwriters Laboratory (UL) recognized
2.16 SIGNAL CONDITIONING UNIT:

Signal conditioning means manipulating an analogue to manipulating an


analogue signal in such a way that it meets the requirements of the next stage
for further processing.The signal conditioning is the amplification necessary to
bring the voltage level up to that required by the ADC.Signal conditioning stage
is a processing stage carried out by an ADC and microcontroller.

2.16.1Applications

It is primarily utilized fordata acquisition, in which sensor signals must be


normalized and filtered to levels suitable for analog-to-digital conversion so
they can be read by computerized devices. Other uses include preprocessing
signals in order to reduce computing time, converting ranged data to Boolean
values, for example when knowing when a sensor has reached certain value
CHAPTER-III

SOFTWARE TOOLS
3.SOFTWARE TOOLS

3.1MPLAB

MPLAB IDE is an integrated development environment that provides


development engineers with the flexibility to develop and debug firmware for
various Microchip devices. MPLAB IDE is a Windows-based Integrated
Development Environment for the Microchip Technology Incorporated
PICmicrocontroller (MCU) and dsPIC digital signal controller (DSC) families. In
the MPLAB IDE, you can:

 Create source code using the built-in editor.


 Assemble, compile and link source code using various language tools. An
assembler, linker and librarian come with MPLAB IDE. C compilers are
available from Microchip and other third party vendors.
 Debug the executable logic by watching program flow with a simulator,
such as MPLAB SIM, or in real time with an emulator, such as MPLAB
ICE. Third party emulators that work with MPLAB IDE are also
available.
 Make timing measurements.
 View variables in Watch windows.
 Program firmware into devices with programmers such as PICSTART
Plus or PRO MATE II.
 Find quick answers to questions from the MPLAB IDE on-line Help.
3.1.1 MPLAB SIMULATOR

MPLAB SIM is a discrete-event simulator for the PIC microcontroller (MCU)


families. It is integrated into MPLAB IDE integrated development
environment. The MPLAB SIM debugging tool is designed to model operation
of Microchip Technology's PIC microcontrollers to assist users in debugging
software for these devices

3.1.2 IC PROG

The PRO MATE II is a Microchip microcontroller device programmer.


Through interchangeable programming socket modules, PRO MATE II enables
you to quickly and easily program the entire line of Microchip PICmicro
microcontroller devices and many of the Microchip memory parts.

PRO MATE II may be used with MPLAB IDE running under supported
Windows OS's (see Read me for PRO MATE II.txt for support list), with the
command-line controller PROCMD or as a stand-alone programmer

3.1.3COMPILER-HIGH TECH C

A program written in the high level language called C; which will be


converted into PICmicro MCU machine code by a compiler. Machine code is
suitable for use by a PICmicro MCU or Microchip development system product
like MPLAB IDE.
3.2 PIC START PLUS PROGRAMMER

The PIC start plus development system from microchip technology provides
the product development engineer with a highly flexible low cost
microcontroller design tool set for all microchip PIC micro devices. The pic
start plus development system includes PIC start plus development programmer
and MPLAB IDE.

The PIC start plus programmer gives the product developer ability to program
user software in to any of the supported microcontrollers. The PIC start plus
software running under MPLAB provides for full interactive control over the
programmer.
3.3POWER SUPPLY

3.3.1BLOCK DIDGRAM

The ac voltage, typically 220V rms, is connected to a transformer, which


steps that ac voltage down to the level of the desired dc output. A diode rectifier
then provides a full-wave rectified voltage that is initially filtered by a simple
capacitor filter to produce a dc voltage. This resulting dc voltage usually has
some ripple or ac voltage variation.

A regulator circuit removes the ripples and also remains the same dc
value even if the input dc voltage varies, or the load connected to the output dc
voltage changes. This voltage regulation is usually obtained using one of the
popular voltage regulator IC units.

TRANSFORM RECTIFIER FILTE IC REGULATOR LOAD


ER R

Fig 3.1 Block diagram (Power supply)

3.3.2 Working principle

3.3.2.1 Transformer

The potential transformer will step down the power supply voltage (0-
230V) to (0-6V) level. Then the secondary of the potential transformer will be
connected to the precision rectifier, which is constructed with the help of op–
amp. The advantages of using precision rectifier are it will give peak voltage
output as DC, rest of the circuits will give only RMS output.
3.3.2.2Bridge rectifier

When four diodes are connected as shown in figure, the circuit is called
as bridge rectifier. The input to the circuit is applied to the diagonally opposite
corners of the network, and the output is taken from the remaining two corners.

Let us assume that the transformer is working properly and there is a positive
potential, at point A and a negative potential at point B. the positive potential at
point A will forward bias D3 and reverse bias D4.

The negative potential at point B will forward bias D1 and reverse D2. At
this time D3 and D1 are forward biased and will allow current flow to pass
through them; D4 and D2 are reverse biased and will block current flow.

The path for current flow is from point B through D1, up through RL,
through D3, through the secondary of the transformer back to point B. this path
is indicated by the solid arrows. Waveforms (1) and (2) can be observed across
D1 and D3.

One-half cycle later the polarity across the secondary of the transformer
reverse, forward biasing D2 and D4 and reverse biasing D1 and D3.
Currentflow will now be from point A through D4, up through RL, through D2,
through the secondary of T1, and back to point A. This path is indicated by the
broken arrows. Waveforms (3) and (4) can be observed across D2 and D4. The
current flow through RL is always in the same direction. In flowing through RL
this current develops a voltage corresponding to that shown waveform (5).
Since current flows through the load (RL) during both half cycles of the applied
voltage, this bridge rectifier is a full-wave rectifier.
One advantage of a bridge rectifier over a conventional full-wave rectifier
is that with a given transformer the bridge rectifier produces a voltage output
that is nearly twice that of the conventional full-wave circuit.

This may be shown by assigning values to some of the components


shown in views A and B. assume that the same transformer is used in both
circuits. The peak voltage developed between points X and y is 1000 volts in
both circuits. In the conventional full-wave circuit shown—in view A, the peak
voltage from the center tap to either X or Y is 500 volts. Since only one diode
can conduct at any instant, the maximum voltage that can be rectified at any
instant is 500 volts.

The maximum voltage that appears across the load resistor is nearly-but
never exceeds-500 v0lts, as result of the small voltage drop across the diode. In
the bridge rectifier shown in view B, the maximum voltage that can be rectified
is the full secondary voltage, which is 1000 volts. Therefore, the peak output
voltage across the load resistor is nearly 1000 volts. With both circuits using the
same transformer, the bridge rectifier circuit produces a higher output voltage
than the conventional full-wave rectifier circuit.
3.3.2.3 IC voltage regulators

Voltage regulators comprise a class of widely used ICs. Regulator


IC units contain the circuitry for reference source, comparator amplifier, control
device, and overload protection all in a single IC. IC units provide regulation of
either a fixed positive voltage, a fixed negative voltage, or an adjustably set
voltage. The regulators can be selected for operation with load currents from
hundreds of milli amperes to tens of amperes, corresponding to power ratings
from milli watts to tens of watts.

Fig.3.2 IC voltage regulators


A fixed three-terminal voltage regulator has an unregulated dc input voltage, Vi,
applied to one input terminal, a regulated dc output voltage, Vo, from a second
terminal, with the third terminal connected to ground.

The series 78 regulators provide fixed positive regulated voltages from 5


to 24 volts. Similarly, the series 79 regulators provide fixed negative regulated
voltages from 5 to 24 volts.

 For ICs, microcontroller, LCD --------- 5 volts


 For alarm circuit, op-amp, relay circuits ---------- 12 volts

3.4.SOFTWARE IMPLEMENTATION

The microcontroller IC AT89C52 is programmed usingEmbedded C language.


Steps for software implementation is givenbelow

1. Initially serial data rate is set to 9600


2. LCD and GSM modules are initialized
3. Accuracy of GSM modem is tested
4. SMS sent by the user is read
5. Validity of the number is checked
6. As soon as SMS is received an indication for reception
is given
7. SMS is received in cell phone indicating that we should
Make recharge as available balance is very less.
8. Space is made available for new data that is to be receivedby clearing the old
data
3.4.1ALGORITHM

Step1.Connect GSM module to electric meter


Step2.Intiate baud rate and set it to 9600.
Step3.LCD display and GSM module are initialized
Step4.User punches his/her number for connecting to
his/her energy meter
Step5.The number is then validated
Step6.Bill is displayed by LCD which is interfaced with
GSM modem
Step7.Delay of 200 seconds is set and result is displayed
for that time
Step8.Bill is sent to users cell phone and LCD displays
the received message
Step9.Buzzer attached in the device buzzes indicating that
Message has been sent successfully
Step10.The user on receiving the message recharges
Through his/her phone
Step11.Stop
CHAPTER-IV
PROGRAM
4.1CODING

Private Sub Command1_Click()

On Error Resume Next

With MSComm1

.CommPort = Val(Text1.Text)

.Handshaking = comNone

.RThreshold = 1

.SThreshold = 8

.Settings = "9600,n,8,1"

.PortOpen = True

End With

End Sub

Private Sub Command2_Click()

End

End Sub

Private Sub Command3_Click()


MSComm1.Output = "AT" &vbCrLf

Sleep 500

MSComm1.Output = "AT+CMGF=1" &vbCrLf

Sleep 500

MSComm1.Output = "AT+CNMI=2,2,0,0,0" &vbCrLf

Sleep 3000

End Sub

Private Sub Command4_Click()

Text2.Text = ""

End Sub

Private Sub Command5_Click()

If Len(Text6.Text) < 10 Then

MsgBox "enter valid number"

Else

MSComm1.Output = "AT+CMGS=" &Chr(34) & Text6.Text &Chr(34)


&vbCrLf

Sleep 500

MSComm1.Output = "#F" &Chr(26) &vbCrLf

Sleep 500
MsgBox "message sent"

End If

End Sub

Private Sub Command6_Click()

If Len(Text7.Text) < 10 Then

MsgBox "enter valid number"

Else

MSComm1.Output = "AT+CMGS=" &Chr(34) & Text7.Text &Chr(34)


&vbCrLf

Sleep 500

MSComm1.Output = "#N" &Chr(26) &vbCrLf

Sleep 500

MsgBox "message sent"

End If

'queryAddress = "http://maps.google.com/maps?q="

' lat = Text4.Text + ","

' queryAddress = queryAddress& lat

' lon = Text3.Text


' queryAddress = queryAddress&lon

' WebBrowser1.Navigate queryAddress

End Sub

Private Sub Command7_Click()

Text4.Text = ""

Text5.Text = ""

End Sub

Private Sub MSComm1_OnComm()

Dim databuf As String

Select Case comEvReceive

Case comEvReceive

databuf = MSComm1.Input

Text2.Text = Text2.Text + databuf

Text5.Text = Len(Text2.Text)
If Len(Text2.Text) >= 60 And Mid(Text2.Text, 50, 1) = "*" Then

Text4.Text = Mid(Text2.Text, 51, 3)

Text3.Text = Mid(Text2.Text, 54, 3)

' Text4.Text = Mid(Text2.Text, 78, 2) + "." + Mid(Text2.Text, 80, 2) +


Mid(Text2.Text, 83, 4) '+ "`" + "N"

' Text3.Text = Mid(Text2.Text, 87, 2) + "." + Mid(Text2.Text, 90, 3) +


Mid(Text2.Text, 94, 3) '+ "0" '+ "`" + "E"

' queryAddress = "http://maps.google.com/maps?q="

' lat = Text4.Text + ","

' queryAddress = queryAddress& lat

' lon = Text3.Text

' queryAddress = queryAddress&lon

' WebBrowser1.Navigate queryAddress

Text2.Text = ""

'Text5.Text = ""

End If
'If Len(Text3.Text) = 12 And Mid(Text3.Text, 1, 1) = "*" Then

'Text9.Text = Mid(Text3.Text, 2, 2) + "." + Mid(Text3.Text, 4, 1)

'Text10.Text = Mid(Text3.Text, 5, 1) + "." + Mid(Text3.Text, 6, 2)

'Text11.Text = Mid(Text3.Text, 8, 1) + "." + Mid(Text3.Text, 9, 2)

'Text3.Text = ""

'End If

End Select

End Sub

Private Sub Text6_Click()

Text6.Text = ""

End Sub
CHAPTER- V

CONCLUSION
5. CONCLUSION AND FUTURE HOPES

Proposed system is highly effective in penalising manwork and making the


system fully automatic. Hence theprobability of error is negligible. Using
wirelesscommunication is very big boon which enables instantbilling. In future
this system can be utilised throughout theworld as communication is done by
GSM which is auniversal standard
CHAPTER-VI

REFERENCE
6.REFERENCES

[1] TarekKhalifa, KshirasagarNaik and AmiyaNayak ” PrototypeDevelopment


of Single Phase Prepaid kWh
[2] Meter” presented at 2011 International Conference on Electrical
Engineering and Informatics 17-19 July 2011, Bandung, Indonesia
[3] ury, J. Miller, W., “Smart Prepaid Energy Meter Implementation,”Power
Delivery, IEEE Transactions on, Jan 2002, pp. 1-5,
[4] “The 8051 microcontroller and embedded systems” by MuhammadAli
Mazidi, Publisher: Prentice Hall.
[5] Alessandro Ferrero, Marco Faifer, and SimonaSalicone “On Testingthe
Electronic Revenue Energy Meters,”presented at IEEETRANSACTIONS
ON INSTRUMENTATION AND MEASUREMENT, VOL. 58, NO. 9,
SEPTEMBER 2009
[6] TarekKhalifa, KshirasagarNaik and AmiyaNayak ”A Survey of
Communication Protocols for Automatic Meter Reading Applications,”at
IEEE COMMUNICATIONS SURVEYS & TUTORIALS, VOL.13, NO.
2, SECOND QUARTER 2011

[7]www.wikipedia.org

[8]www.engineersgarage.com

[9]www.rentron.com

[10]www.edaboard.com

You might also like