CHAPTER 1 INTRODUCTION
The aim of this project is to remote monitoring of domestic energy meter using GSM. This system enables the electricity department to read the meter reading regularly without the person visiting each house through GSM network. This can be achieved by the use of microcontroller (89C51) unit. The microcontroller based system continuously observes the reading of the live meter and it sends the current reading of live meter. The microcontroller at the transmitter is provided with GSM unit.
1.1 The main features of this project are:1) Monitoring of energy meter 2) Dynamic update of meter reading
1.2 The device provides learning’s on following advancement :• • • • • GSM modem interfacing to controller Energy meter interfacing PCB design LCD interfacing Embedded C programming
2
INTRODUCTIONChapter-1
1.3 The major building blocks of this project are:• • • • Microcontroller based control unit with regulated power supply. GSM modem Energy meter LCD display with driver circuit
1.4 Simplified Block Diagram of Project
3
INTRODUCTIONChapter-1
Fig.1
4
STRUCTURAL LAYOUTChapter-2
4
STRUCTURAL LAYOUTChapter-2
CHAPTER 2 STRUCTURAL LAYOUT
Figure 2.1
As shown in above circuit diagram IC CS5460 is low cost Analog to Digital converter. So the reference voltage & current values are taken in the form of analog signal from the main source. Reference Voltage are taken on across of R1(as shown in above diagram) & Reference Current are taken on across of Rs (as shown in above diagram). The regulated power supply constantly feds supply to pin no. 14 as positive pin no. 3 as negative. Now as a clock source crystal is connected between pin no. 1 & 24. And remaining pins are connected as shown in above circuit diagram with Controller 89S52.
5
STRUCTURAL LAYOUTChapter-2
Figure 2.2
Above diagram shows detailing of connections. Here we use 5 volts DC regulated power supply. A 12 volts, 1 ampere transformer is connected with diode bride. The output of diode bridge is connected with regulate power IC (7805) to provide 5 volt regulated power supply. The two capacitors are used to filtered the DC into pure form. This power supply is supplied to the whole circuit as shown in above diagram.
6
STRUCTURAL LAYOUTChapter-2
Crystal is connected between pin no. 18 & 19. To reset the IC RC circuit is connect on pin no.9. The value acquired by controller 89S52 is stored in EPROM 24C02C every second. Pin no. 5 (SDA) of EPROM is connected on port no. P 1.0 & Pin no. 6 (SCK) is connected with port no. P 1.1 So we can get the previous data from EPROM at the time of power failure. LCD (16x2) is connected to port no. 2 of controller. And the RS pin of LCD is connected with port no. P 3.6 (WR). And the E pin of LCD is connected wiyh port no. P 3.5 (T1). Vee Pin of LCD is used for contrast setting. And 5 volt supply is given to LCD & RW is grounded. GSM MODULE SIM 300 is used to transmit & receive the data from controller. Now Rx & Tx of GSM MODULE SIM 300 are crossly connected with controller. And 12 volt supply is given to GSM module. Relay is connected with port no P 0.7 through transistor BC547. This relay can used to operate the ON & OFF function of energy meter output.
7
PROGRAMMING DESCRIPTIONChapter-3
8
PROGRAMMING DESCRIPTIONChapter-3
CHAPTER 3 PROGRAMMING DESCRIPTION 3.1 PROGRAMMING OF IC 89S52 USING uKEIL
STEP 1 Open the uKEIL application software.
9
PROGRAMMING DESCRIPTIONChapter-3
STEP 2 Crate a project as shown below
10
PROGRAMMING DESCRIPTIONChapter-3
STEP 3 Select required device from the list as given below
STEP 4
11
PROGRAMMING DESCRIPTIONChapter-3
Now right click on TARGET and ADD a new (.c format) file.
STEP 6
12
PROGRAMMING DESCRIPTIONChapter-3
Now compile the program & analysize the error. It automatically hex file in particular folder.
STEP 7
13
PROGRAMMING DESCRIPTIONChapter-3
Right click on target & click on option for target window to set parameters of particular controllers.
14
PROGRAMMING DESCRIPTIONChapter-3
3.2 Programming of IC 89S52 using C programming Language
#include<reg52.h> #include"lcd.h" #include"e2p.h" #include"spi.h" #include<string.h> long double i = 0; long int Power=0; char send=0; unsigned long int Energy = 0; unsigned long int TEnergy=0,PrevEnergy=0; char a=0,t=0; char p=0; char TeH=0,TeL=0; unsigned long int Vrms=0,count1000=0,Irms=0; char sec=0; char resp0[]="info"; char resp1[]="off9"; char resp2[]="on99"; int y=0; char v=0,b=0; char temp[10]; sbit RLY = P0^7;
15
} */ void lcd_print(char x, char y, char code *string) // send string of characters to LCD { int i; int c; for (i=0;string[i]!=0;i++) { c = string[i]; if (c<0) c=0; sendcommand(base_y[y]+x+i); us_delay(100); senddata(c); us_delay(100); } } // convert ASCII to LCD char address
void lcd_print1(char x, char y, char* strg) { int j; int b; for (j=0;j<=5;j++) { b = strg[j]+0x30; // convert ASCII to LCD char address
33
PROGRAMMING DESCRIPTIONChapter-3
if (b<0) b=0; sendcommand(base_y[y]+x+j); us_delay(100); senddata(b); us_delay(100); } } /*void lcd_char(char x, char y, char stg) { int j; int b; b = stg; // convert ASCII to LCD char address
unsigned char unithb,tenhb,hundhb,thoushb,thous10hb,lachb; void spi_write(unsigned char length, long int value) { char i; ADC_CS=FALSE; i = 32 - length; while ( i > 0) { i -= 1; value = value << 1; }
41
// command to write configuration register // set rs bit of configureation register // command to write configuration register // set rs bit of configureation register // command to write configuration register // set VRS bit of configureation register
// command to write in channel set up register // define channel set up reg 1,and reg 2 // command for self offset calibration // command for self gain calibration
46
PROGRAMMING DESCRIPTIONChapter-3
*/ } long read_5460(void) { char i; char j=0; long temp; temp=0;
COMPONENTS USED:1) Microcontroller 89S52 2) EPROM 24C02 3) IC CS5460 (Analog to Digital converter) 4) LCD (16x2) 5) Relay 6) Crystal (11.0592 Mhz & 6 Mhz) 7) IC 7805 8) Resistors. Capacitors, Diodes, Transistor, Connecters & Transformer.
4.1 Microcontroller 89S52
The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K bytes of in-system programmable Flash memory. The device is manufactured using Atmel’s high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer.
52
HARDWARE DESCRIPTIONChapter-4
By combining a versatile 8-bit CPU with in-system programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller which provides a highly-flexible and cost-effective solution to many embedded control applications.
The AT89S52 provides the following standard features: 8K bytes of Flash, 256 bytes of RAM, 32 I/O lines, timers, two data pointers, three 16-bit timer/counters, a six-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry. In addition, the AT89S52 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue functioning.
53
HARDWARE DESCRIPTIONChapter-4
The Power-down mode saves the RAM contents but freezes the oscillator, disabling all other chip functions until the next interrupt or hardware reset.
Why we are using 89s52?
Microcontroller 89s51 89s52 ROM(Code Memory) 4,000 Bytes(4 kB) 8,000 Bytes(8 kB) RAM 128 B 256 B Table-4.1 Timer 2 3 Ext.-Int. Sources 6 8
Difference between S-type and C-type
Type Power Consumption C-type S-type Less More Less More Speed Crystal Frequency 0-24 MHz 0-33 MHz Table-4.2 10 mA 10 mA 10 mA Very weak Sink Source
Features
54
HARDWARE DESCRIPTIONChapter-4
•
Compatible with MCS®-51 Products 8K Bytes of In-System Programmable (ISP) Flash Memory Endurance: 10,000 Write/Erase Cycles 4.0V to 5.5V Operating Range Fully Static Operation: 0 Hz to 33 MHz Three-level Program Memory Lock 256 x 8-bit Internal RAM 32 Programmable I/O Lines Three 16-bit Timer/Counters Eight Interrupt Sources Full Duplex UART Serial Channel Low-power Idle and Power-down Modes Interrupt Recovery from Power-down Mode Watchdog Timer Dual Data Pointer Power-off Flag Fast Programming Time Flexible ISP Programming (Byte and Page Mode) Green (Pb/Halide-free) Packaging Option
• • • • • • • • • • • • • • • • • •
Pin configuration
55
HARDWARE DESCRIPTIONChapter-4
Fig 4.1
4.2 EPROM 24C02
56
HARDWARE DESCRIPTIONChapter-4
Features
• Low-Voltage and Standard-Voltage Operation – – – – • • • • • • • • • • • 5.0 (VCC = 4.5V to 5.5V) 2.7 (VCC = 2.7V to 5.5V) 2.5 (VCC = 2.5V to 5.5V) 1.8 (VCC = 1.8V to 5.5V)
Internally Organized 128 x 8 (1K), 256 x 8 (2K), 512 x 8 (4K), 1024 x 8 (8K) or 2048 x 8 (16K) 2-Wire Serial Interface Schmitt Trigger, Filtered Inputs for Noise Suppression Bidirectional Data Transfer Protocol 100 kHz (1.8V, 2.5V, 2.7V) and 400 kHz (5V) Compatibility Write Protect Pin for Hardware Data Protection 8-Byte Page (1K, 2K), 16-Byte Page (4K, 8K, 16K) Write Modes Partial Page Writes Are Allowed Self-Timed Write Cycle (10 ms max) High Reliability – – – Endurance: 1 Million Write Cycles Data Retention: 100 Years ESD Protection: >3000V
• •
Automotive Grade and Extended Temperature Devices Available 8-Pin and 14-Pin JEDEC SOIC, 8-Pin PDIP, 8-Pin MSOP, and 8-Pin TSSOP Packages
Description
57
HARDWARE DESCRIPTIONChapter-4
The AT24C01A/02/04/08/16 provides 1024/2048/4096/8192/16384 bits of serial electrically erasable and programmable read only memory (EEPROM) organized as 128/256/512/1024/2048 words of 8 bits each. The device is optimized for use in many industrial and commercial applications where low power and low voltage operation are essential. The AT24C01A/02/04/08/16 is available in space saving 8-pin PDIP, (AT24C01A/02/04/08/16) , 8-Pin MSOP (AT24001A/02), 8-Pin TSSOP (AT24C01A/02/04/08/16), and 8-Pin and 14-Pin JEDEC SOIC (AT24C01A/02/04/08/16) packages and is accessed via a 2-wire serial interface. In addition, the entire family is available in 5.0V (4.5V to 5.5V), 2.7V (2.7V to 5.5V), 2.5V (2.5V to 5.5V) and 1.8V (1.8V to 5.5V) versions.
PIN CONFIGURATION
Fig 4.2
58
HARDWARE DESCRIPTIONChapter-4
4.3 IC CS5460 (Analog to Digital converter)
CS5460 Features
CS5460 is a single chip containing two one Σ analog-digital converter (ADC), highspeed power calculation functions and a serial interface of highly integrated analog Σ a digital converter. He can accurately measure the instantaneous voltage, instantaneous current, instantaneous power, etc.; He also has two-way communication with the microcontroller serial port. The CS5460 can be initialized after power and can perform all functions, including procedures under the control of the user system calibration.
59
HARDWARE DESCRIPTIONChapter-4
Structure
CS5460 structure shown in Figure 1. Ten of them IN, IN A analog current input channels; VIN +, VIN an output an analog voltage input channels; and different order and magnitude of the input voltage matches the current channel also features a programmable gain amplifier (PGA), the input signal full-scale range selectable; 2 △ Σ analog-digital converter samples the signal on the system model of a digital conversion; two digital highspeed filter to (MCLK / K) / 1024 output rate of output data word; 2 high-pass filter can be calculated in the energy before the DC component of the input signal filter; calibration unit to achieve the calibration of the analog input channels;-power computing unit used to calculate the instantaneous power and voltage and current RMS and so on. Serial Interface (Serial Interface) unit provides a CS5460 with external data communication interface.
Works
CS5460 energy calculation is a monolithic CMOS cited Hajime power measurement chip. Voltage analog signal from the VIN +, VIN A △ Σ after the analog input of a digital converter to convert the converted signal by the high-speed filter and high-pass filter given away after the power calculator. Current analog signal from the VIN +, VIN A △ Σ after the input of a digital analog converter to convert the converted signal by the high-speed filter and high-pass filter given away after the power calculator. Power calculator for processing the two signals output measured after the operation voltage, current, power and so on. All of these data by the serial interface and microcontroller for data exchange.
Analog input
Measure the instantaneous sampling circuit is to achieve voltage, instantaneous current, instantaneous power basis. The resistors and capacitors not only high precision, but its role is not the same. Circuit RPl inrush current for the current channel when the input pin for current limit protection; in VlN + feet do not need to protect the resistance because of the introduction of the resistive divider as sensors, resistive voltage divider resistors in series have been be directed to the VIN + pin, if the voltage input channel CS5460 negative
60
HARDWARE DESCRIPTIONChapter-4
side is not earthed (VIN + and VIN connected as a differential input mode) plus the input signal is necessary to protect the resistance. CPl and CP2 is the role of absorption coupled to the input line of high-frequency noise. The resistance and capacitance, the voltage channel should be the ultimate guarantee of full scale input signal amplitude is 150mV, the current channel input signal amplitude of 30mV full scale or 150mV selectable (programmable gain amplifier by the program through implementation).
Calibration
Calibration of the input channels, there are several software shown in Figure 3, the calibration process. Channel all of the calibration samples were calibrated by computer software, should be the order from left to right in Figure 3 in order calibration. After calibration by the calibration equipment used to do a higher level than the right, to ensure the accuracy of the measurement data.
Computing
Voltage and current channel input signal is calibrated to the power calculation unit, the measured voltage and current to calculate power. Also from the measured instantaneous voltage and current to calculate the instantaneous voltage and current RMS.
Hardware Design
CS5460 implementation of the system by the instantaneous voltage, instantaneous current, instantaneous power measurement, energy measurement achieved by the microcontroller μPD75P3116 and other features, interface circuit shown in Figure 4 instructions. CS5460s serial interface consists of four control lines that: CS, SDI, SDO, and SCLK. CS is chip select signal, is allows access to the serial port of the control line, active low, high, high-impedance state when the SDO client; SDI as serial data input, used to transfer data from the microcontroller to the CS5460; SDO is serial data output, used to
61
HARDWARE DESCRIPTIONChapter-4
output data to the microcontroller; SCLK is to control the data input or output serial bit clock, SCLK port level conversion can be identified before the CS must be set to logic low. MCU is through the four control lines to achieve the data exchange with the CS5460. Microcontroller to read from the CS5460 the instantaneous voltage, instantaneous current and instantaneous power exists and other data in memory after treatment, after power microcontroller read the data from memory to memory. All of these data can be an external communication interface from the host computer read out by the LCD display can easily query. Order to ensure safe and reliable system operation in the system by adding "watchdog" circuit. HCF4060 CMOS components and parts from the discrete components of the "watchdog" circuit, its low cost, simple to use, stable and reliable. When the program runs into infinite loop error or when the system can ensure quick and safe and reliable reset.
System software design
Program starts, first start the watchdog circuit, and then test the memory. If the test is not successful then the re-testing, if successful, read CS5460. After the reading of the data processing, the instantaneous voltage, instantaneous current, instantaneous power, total power and voltage and current RMS displayed on the LCD display.
Conclusion
The CS5460 and t ~ PD75P3116 used to achieve power and energy measurement approach to simple, easy to use, high cost performance characteristics by the majority of design and development departments of all ages, a very good market prospects. At present, our company has developed under this approach the single-phase electronic meter, three phase and single-phase multi-site electronic form calibrator and other products, has been widely used in the power sector.
Pin Configuration
62
HARDWARE DESCRIPTIONChapter-4
Fig 4.3
4.4 LCD (16x2)
63
HARDWARE DESCRIPTIONChapter-4
Description.
This is the first interfacing example for the Parallel Port. We will start with something simple. This example doesn't use the Bi-directional feature found on newer ports, thus it should work with most, if no all Parallel Ports. It however doesn't show the use of the Status Port as an input. So what are we interfacing? A 16 Character x 2 Line LCD Module to the Parallel Port. These LCD Modules are very common these days, and are quite simple to work with, as all the logic required to run them is on board.
Schematic
64
HARDWARE DESCRIPTIONChapter-4
Fig4.4
Above is the quite simple schematic. The LCD panel's Enable and Register Select is connected to the Control Port. The Control Port is an open collector / open drain output. While most Parallel Ports have internal pull-up resistors, there are a few which don't. Therefore by incorporating the two 10K external pull up resistors, the circuit is more portable for a wider range of computers, some of which may have no internal pull up resistors. We make no effort to place the Data bus into reverse direction. Therefore we hard wire the R/W line of the LCD panel, into write mode. This will cause no bus conflicts on the data lines. As a result we cannot read back the LCD's internal Busy Flag which tells us if the LCD has accepted and finished processing the last instruction. This problem is overcome by inserting known delays into our program.
65
HARDWARE DESCRIPTIONChapter-4
The 10k Potentiometer controls the contrast of the LCD panel. Nothing fancy here. As with all the examples, I've left the power supply out. You can use a bench power supply set to 5v or use a onboard +5 regulator. Remember a few de-coupling capacitors, especially if you have trouble with the circuit working properly.
The 2 line x 16 character LCD modules are available from a wide range of manufacturers and should all be compatible with the HD44780. The one I used to test this circuit was a Powertip PC-1602F and an old Philips LTN211F-10 which was extracted from a Poker Machine! The diagram to the right, shows the pin numbers for these devices. When viewed from the front, the left pin is pin 14 and the right pin is pin 1.
66
GSMChapter-5
67
GSMChapter-5
CHAPTER 5 GSM
This GSM wireless data module is the ready a solution for remote wireless applications, machine to machine or user to machine and remote data communications in all vertical market applications.
5.1 SIM300 AT Command Set
In application, controlling device controls the GSM engine by sending AT Command via its serial interface. The controlling device at the other end of the serial line is referred to as following term: 1) TE (Terminal Equipment); 2) DTE (Data Terminal Equipment)
Types of AT commands and responses
Test command AT+<x>=? The mobile equipment returns the list of parameters and value ranges set with the corresponding Write command or by internal processes. This command returns the currently set value of the parameter or parameters. This command sets the user-definable parameter values. The execution command reads non-variable parameters affected by internal processes in the GSM engine
Read command Write command Execution command
AT+<x>? AT+<x>=<…> AT+<x> Table 5.1
68
GSMChapter-5
5.2 Product concept
Designed for global market, SIM300 is a Tri-band GSM/GPRS engine that works on frequencies EGSM 900 MHz, DCS 1800 MHz and PCS 1900 MHz. SIM300 features GPRS multi-slot class 10/ class 8 (optional) and supports the GPRS coding schemes CS-1, CS-2, CS-3 and CS-4.
69
MERITS & DEMERITSChapter-6
70
MERITS & DEMERITSChapter-6
CHAPTER 6 MERITS & DEMERITS
6.1 MERITS • • • • • • Different Tariffs can be implemented. Power thefts can be caught. Power can be cut-off in case of non payement of bill. For ON & OFF purpose security feature is provided. Quick reponse. It can Give every second update of energy meter value by SMS.
6.2 DEMERITS •
•
The energy meter is of only 5 ampere current rating only (Domestic Use). Maximum rating of meter is 10 KWh but it can be extended upto 10 MWh. Costing of GSM is higher for regular use. GSM module can be operated only proper network coverage is available. It has to rely on particular SIM or service provider. Accuracy of energy meter is only in watt hour. The relay used has switching rating of 6 ampere so we can perform upto that only. The SIM card must have a balance in order to send message.
• • • • • •
71
FUTURE DEVELOPMENTChapter-7
72
FUTURE DEVELOPMENTChapter-7
CHAPTER 7 FUTURE DEVELOPMENT
• • • • •
Power theft can be caught using this device. This device can perform as reminder for bills or tariffs. Using this device new tariffs can be implemented. Prepaid tariffs can also be available using this device. Electric consumption can be improved if once gets regular update of its energy consumption.
•
Any fault in power system can be detected using this device. The capacity of energy meter can be increased upto 10 MWh.
•
73
CONCLUSIONChapter-8
74
CONCLUSIONChapter-8
CHAPTER 8 CONCLUSION
While preparing this project we learn the operating of microcontroller 89S52. And also understand the performance of IC CS5460. We learn interfacing of LCD (16x2), EPROM 24C02C with microcontroller 89S52.And also learn programming of 89S52 to operate remaining components. Along with controller this device provide learning about GSM module and also interfacing GSM module with controller. We also learn about the usage of AT Command & how it can used to send SMS. Finally by preparing this device we can understand how the device can be useful in present as well as future.
75
REFERENCES
REFERENCES
[1] Electric Power Distribution By A. S. Pabla [2] A Textbook of Electrical Technology By R.K. Rajput [3] Principles and Applications of GSM By Garg [4] Exploring C for microcontrollers: a hands on approach By Jivan S. Parab, Vinod
G. Shelake, Rajanish K. Kamat
[5] Microprocessors & Microcontroller Systems By D.A.Godse A.P.Godse [6] http://www.keil.com/dd/docs/datashts/atmel/at89s52_ds.pdf [7] http://www.atmel.com/dyn/resources/prod_documents/doc1919.pdf [8] http://www.alldatasheet.com/datasheet-pdf/pdf/230848/CIRRUS/CS5460.html [9] http://www.datasheetcatalog.org/datasheet/Cirrus_Logic/mXxtrxu.pdf