You are on page 1of 64

A Project report

INTELLIGENT REAL-TIME AUTOMATIC TRANSFORMER LOAD SHARING AND REMOTE CONTROLLING SYSTEM USING GSM MODEM
submitted in partial fulfilment of the requirement for the award of degree of BACHELOR OF TECHNOLOGY in ELECTRICAL & ELECTRONICS ENGINEERING by PRAVEEN DESAI VIKAS VOOTURI PRASHANTH KUMAR CH 07BK1A0237 07BK1A0255 07BK1A0236

on

Under the guidance of

Mr. SURESH BABU(M. Tech.)


Assistant Professor

DEPARTMENT OF ELECTRICAL & ELECTRONICS ENGINEERING

ST.PETERS ENGINEERING COLLEGE


(Affiliated to Jawaharlal Nehru Technological University, Hyderabad) Opp Forest Academy, Dhulapally, Near Kompally, Medchal Mandal, A.P.

2011

ST.PETERS ENGINEERING COLLEGE (Affiliated to Jawaharlal Nehru Technological University, Hyderabad) Opp Forest Academy, Dhulapally, Near Kompally, Medchal Mandal, A.P. DEPARTMENT OF ELECTRICAL & ELECTRONICS ENGINEERING

CERTIFICATE
This is to certify that the project entitled INTELLIGENT REAL-TIME AUTOMATIC TRANSFORMERLOAD SHARING AND REMOTE CONTROLLING SYSTEM USING GSM MODEM is being submitted by

PRAVEEN DESAI VIKAS VOOTURI PRASHANTH KUMAR CH

07BK1A0237 07BK1A0255 07BK1A0236

in partial fulfilment of the requirements for the award of BACHELOR OF TECHNOLOGY to JNTU, Hyderabad. This record is a bonafide work carried out by them under my guidance and supervision. The result embodied in this project report has not been submitted to any other university or institute for the award of any degree of diploma.

Internal Guide H. O. D.

External Guide

ACKNOWLEDGEMENT
I would like to express my gratitude to all the people behind the screen who helped me to transform an idea into a real application. I would like to express my heart-felt gratitude to my parents without whom I would not have been privileged to achieve and fulfil my dreams. I am grateful to our principal, Mr. K.V.J RAO who most ably run the institution and has had the major hand in enabling me to do my project. I profoundly thank Mr.GIRI PRASAD, Head of the Department of Electrical & Electronics Engineering who has been an excellent guide and also a great source of inspiration to my work. I would like to thank my internal guide Mr. SURESH BABU for his technical guidance, constant encouragement and support in carrying out my project at college. I would also like to thank my external guide Mr.SANDEEP for his technical guidance and support in carrying out my project at ORBIT The satisfaction and euphoria that accompany the successful completion of the taskwould be great but incomplete without the mention of the people who made it possible with their constant guidance and encouragement crowns all the efforts with success. In this context, I would like thank all the other staff members, both teaching and non-teaching, who have extended their timely help and eased my task.

PRAVEEN DESAI VIKAS VOOTURI PRASHANTH KUMAR CH

07BK1A0237 07BK1A0255 07BK1A0236

ABSTRACT

INTELLIGENT REAL-TIME AUTOMATIC TRANSFORMER LOAD SHARING AND REMOTE CONTROLLING SYSTEM USING GSM MODEM
In normal we used to control the industrial equipments by manual operation. Hence it is to be updated step by step manually. It is overcome by a new mode of communication which is used to control all those equipments through load sharing mechanism by a single message from anywhere. GSM is the most popular mobile phone system in the world which could be used for this controlling operation from anywhere else. GSM Global System for Mobile Communication is used as a media which is used to control and monitor the transformer load from anywhere by sending a message. It has its own deterministic character. Thereby, here GSM is used to monitor and control by sending a message through GSM modem. Hence no need to waste time by manual operation and transportation. Hence it is considered as highly efficient communication through the mobile which will be useful in industrial controls, automobiles, and appliances which would be controlled from anywhere else. It is also highly economic and less expensive; hence GSM is preferred most for this mode of controlling. The AT89S52 is the heart of this project. Here we are receiving the data from GSM modem and is given to the micro controller by serial communication through MAX 232, depending up on the information received it operates relay control unit and is there by operating load bank. The relay controlling unit is taking power supply with the help of load sharing transformer by the help of Current Sensors.

Title of the project SHARING Domain Software Microcontroller Power Supply Display LCD Communication Device Crystal Applications

: : : : : : : : : :

AUTOMATIC TRANSFORMER LOAD Electrical, Embedded Systems Design, Wireless Embedded C, Keil, Proload AT89S52 +5V, 750mA Regulated Power Supply LCD HD44780 16-character, 2-line (16X2) GSM modem 11.0592MHz Electricity Generation stations, Industries

INTRODUCTION

1. INTRODUCTION
1.1

MOTIVATION

Power travels from the power plant to house through an amazing system called the power distribution grid. For power to be useful in a home or business, it comes off the transmission grid and is stepped-down to the distribution grid.This may happen in several phases. The place where the

conversion from "transmission" to "distribution" occurs is in a power substation. It has transformers that step transmission voltages (in the tens or hundreds ofthousands of volts range) down to distribution voltages (typically less than10,000 volts). It has a "bus" that can split the distribution power off in multiple directions. It often has circuit breakers and switches so that the substation can be disconnected from the transmission grid or separate distribution lines can be disconnected from transmission grid or separate distribution lines can be disconnected from the substation when necessary.

In this project, a slave transformer in the case of shares the load of master transformer over load and over temperature. A sensor circuit is designed to log the data from the master transformer and if it is found to be in over load condition, immediately the slave transformer will be connected in parallel to the master transformer and the load is shared.

1.2

PROBLEM DEFINATION The existing system presently is done manually, where by which there are possibilities for the transformer to get easily damaged hence this is a heavy loss to any grid or industry. If theres heavy load suddenly and not spotted out the transformer gets damaged and there are even chances for the equipment to get damaged. For home applications to the heavy industries this paper can be a solution for the protection

1.3

OBJECTIVE OF THE PROJECT This paper is a method for the automatic load sharing of the transformers using a GSM modem A message regarding the sharing of the load by the transformers is sent to the clients mobile using the GSM Reasons for preference of this method

1. Automated Load sharing of transformers 2. No manual errors 3. Fit and Forget system 4. Low cost and reliable circuit

1.1

ORGANISATION OF DOCUMENTATION

In this project documentation we have initially put the definition and

objective of the project as well as the design of the project which is followed by the implementation and testing phases. Finally the project has been concluded successfully and also the future enhancements of the project were given in this documentation.

HARDWAR E

2.1 INTRODUCTION In our project we propose to design an idea for load sharing of distribution transformers using a microcontroller, here we are using two transformers which are connected in parallel, one acts as the main transformer and the other one acts as additional transformers. The load is shared by these

transformers automatically with the help of microcontroller. Using this we are going to monitor the consumed load current, voltage and temperature of transformer. the project work has a very good practical value and is the much sought after by the department of electricity and also by many industries in power sector Aim of the design is to develop a system based on Embedded micro controller (8051), which is used for controlling the industrial equipments through a single message from anywhere. This project design makes use of 8051 micro controllers for interfacing to various hardware interfaces. Technology today is seeing its heights in all the areas, especially in the area of Embedded Systems. It is true that every electronic gadget that is used in daily life right from a PC keyboard to a refrigerator is an Embedded System. This itself shows how vastly the technology is expanding. As the technology is improving day to day many things of our daily life became so simple and easy. The design is based on 8051 micro controller. The project has in it an AT89S52 microcontroller, a GSM modem, current sensing circuits, the controller receives the data from GSM Modem and sends to micro controller through serial communication. Based upon the message received, micro controller operates relay control unit and is there by operating load bank. The relay controlling unit is taking power supply with the help of load sharing transformer with the help of current sensors

2.2 BLOCK DIAGRAM OF THE SYSTEM

2.3 MAJOR COMPONENTS 2.3.1 MICROCONTROLLER AT89C52 Description


The AT89C52 is a low-power, high-performance CMOS 8-bit microcomputer with 8Kbytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmels high-density non-volatile memory technology and is compatible with the industry-standard MCS-51 instruction set and pin out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional non-volatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C52 is a powerful microcomputer which provides a highly-flexible and costeffective solution to many embedded control applications.

Pin Configurations

Pin Description Port 0 Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as highimpedance inputs. Port 0 may also be configured to be the multiplexed loworder address/data bus during accesses to external program and data memory. In this mode P0 has internal pullups. Port 0 also receives the code bytes during Flash programming, and outputs the code bytes during program verification. External pullups are required during program verification. Port 1 Port 1 is an 8-bit bi-directional I/O port with internal pullups. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pullups. Port 1 also receives the low-order address bytes during Flash programming and verification. Port 2 Port 2 is an 8-bit bi-directional I/O port with internal pullups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pullups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit addresses (MOVX @ DPTR). In this application, it uses strong internal pull-ups when emitting 1s. During accesses to external data memory that use 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives the high-order address bits and some control signals during Flash programming and verification. Port 3 Port 3 is an 8-bit bi-directional I/O port with internal pullups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pullups. Port 3 also serves the functions of various special features of the

AT89C52 as listed

Port 3 also receives some control signals for Flash programming and verification. RST Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. ALE/PROG Address Latch Enable output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming. In normal operation ALE is emitted at a constant rate of 1/6 the oscillator frequency, and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped during each access to external Data Memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALEdisable bit has no effect if the microcontroller is in external execution mode. PSEN Program Store Enable is the read strobe to external program memory. When the AT89C52 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory. EA/VPP External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt programming enable voltage

(VPP) during Flash programming, for parts that require 12-volt VPP. XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit. XTAL2 Output from the inverting oscillator amplifier. Block Diagram

2.3.2 MAX 232

The concept of serial communication is simple, in serial communication data is sent one bit at a time. Serial communication requires only one line for the data; second line for ground & possible a third line for clock. Although this is slower than parallel communication, which allows the transmission of an entire byte at once, it is simpler & requires less physical wires for communication so can be used over longer distances MAX 232 The Max 232 is a dual RS-232 receiver / transmitter that meets all EIA RS232C specifications while using only a +5V power supply. It has 2 onboard charge pump voltage converters which generate +10V and 10V power supplies from a single 5V power supply. It has four level translators, two of which are RS232 transmitters that convert TTL\ CMOS input levels into + 9V RS232 outputs. The other two level translators are RS232 receivers that convert RS232 inputs to 5V TTL\CMOS output level. These receivers have a nominal threshold of 1.3V, a typical hysterics of 0.5V and can operate up to + 30V input. 1. Suitable for all RS232 communications. 2. +12V power supplies required. 3. Voltage quadruple for input voltage up to 5.5V (used in power supply Section of computers, peripherals, and modems). Three main sections of MAX232 are 1. A dual transmitter 2. A dual receiver 3. + or - 5V to + or - 10V dual charge pump voltage converter. PIN DIAGRAM OF MAX 232

TRANSMITTER SECTION: Each of the two transmitters is a CMOS inverter powered by + or - 10V internally generated supply. The input is TTL and CMOS compatible with a logic threshold of about 26% of Vcc. The input if an unused transmitter section can be left unconnected: an internal 400KW pull up resistor connected between the transistor input and Vcc will pull the input high forming the unused transistor output low. The open circuit output voltage swing is guaranteed to meet the RS232 specification + or - 5v output swing under the worst of both transmitter driving the 3K . Minimum load impedance, the Vcc input at 4.5V and maximum allowable ambient temperature typical voltage with 5K and Vcc = + or - 9 v. The slow rate at output is limited to less than 30V/ s and the powered done output impedance will be a minimum of 300W with + or - 2V applied to the output with Vcc = 0V.The outputs are short circuit protected and can be short circuited to ground indefinitely. RECEIVER SECTION

The two receivers fully conform to RS232 specifications. Theyre input impedance is between 3K either with or without 5V power applied and their switching threshold is within the +3V of RS232 specification. To ensure compatibility with either RS232 IIP or TTL/CMOS input. The MAX232 receivers have VIL of 0.8V and VIH of 2.4V the receivers have 0.5V of hysterisis to improve noise rejection. The TTL\CMOS compatible output of receiver will be low whenever the RS232 input is greater than 2.4V. The receiver output will be high when input is floating or driven between +0.8V and 30V. 2.3.3 RELAY A relay is an electrical switch that opens and closes under the control of another electrical circuit. In the original form, the switch is operated by an electromagnet to open or close one or many sets of contacts. It was invented by Joseph Henry in 1835. Because a relay is able to control an output circuit of higher power than the input circuit, it can be considered to be, in a broad sense, a form of an electrical amplifier. A simple electromagnetic relay, is an adaptation of an electromagnet. It consists of a coil of wire surrounding a soft iron core, an iron yoke, which provides a low reluctance path for magnetic flux, a moveable iron armature, and a set, or sets, of contacts; two in the relay pictured. The armature is hinged to the yoke and mechanically linked to a moving contact or contacts. It is held in place by a spring so that when the relay is de-energised there is an air gap in the magnetic circuit. In this condition, one of the two sets of contacts in the relay pictured is closed, and the other set is open. Other relays may have more or fewer sets of contacts depending on their function. The relay in the picture also has a wire connecting the armature to the yoke. This ensures continuity of the circuit between the moving contacts on the armature, and the circuit track on the Printed Circuit Board (PCB) via the yoke, which is soldered to the PCB. When an electric current is passed through the coil, the resulting magnetic field attracts the armature, and the consequent movement of the movable contact or contacts either makes or breaks a connection with a fixed contact. If the set of contacts was closed when the relay was de-energised, then the movement opens the contacts and breaks the connection, and vice versa if the contacts were open. When the current to the coil is switched off, the armature is returned by a force, approximately half as strong as the magnetic force, to its relaxed position. Usually this force is provided by a spring, but gravity is also used commonly in industrial motor starters. Most relays are

manufactured to operate quickly. In a low voltage application, this is to reduce noise. In a high voltage or high current application, this is to reduce arcing. If the coil is energized with DC, a diode is frequently installed across the coil, to dissipate the energy from the collapsing magnetic field at deactivation, which would otherwise generate a voltage spike dangerous to circuit components. Some automotive relays already include that diode inside the relay case. Alternatively a contact protection network, consisting of a capacitor and resistor in series, may absorb the surge. If the coil is designed to be energized with AC, a small copper ring can be crimped to the end of the solenoid. This "shading ring" creates a small out-of-phase current, which increases the minimum pull on the armature during the AC cycle.[1] By analogy with the functions of the original electromagnetic device, a solidstate relay is made with a thyristor or other solid-state switching device. To achieve electrical isolation an optocoupler can be used which is a light-emitting diode (LED) coupled with a photo transistor.

2.3.4 MCT2E (OPTOCOUPLER) DESCRIPTION The MCT2XXX series optoisolators consist of a gallium arsenide infrared emitting diode driving a silicon phototransistor in a 6-pin dual in-line package.

APPLICATIONS Power supply regulators Digital logic inputs Microprocessor inputs

2.2.5 LCD-016M002A FEATURES 5 x 8 dots with cursor Built-in controller (KS 0066 or Equivalent) + 5V power supply (Also available for + 3V) 1/16 duty cycle B/L to be driven by pin 1, pin 2 or pin 15, pin 16 or A.K

(LED) N.V. optional for + 3V power supply PIN DESCRIPTION

DISPLAY

2.3.5 GSM (Global System for Mobile) Global System for Mobile (GSM) is a second generation cellular standard developed to cater voice services and data delivery using digital modulation The objective of security for GSM system is to make the system as secure as the public switched telephone network. The use of radio at the transmission media

allows a number of potential threats from eavesdropping the transmissions. It was soon apparent in the threat analysis that the weakest part of the system was the radio path, as this can be easily intercepted. GSM provides a basic range of security features to ensure adequate protection for both the operator and customer. Over the lifetime of a system threat and technology change, and so the security is periodically reviewed and changed. The technical security features must be properly supported by procedures to ensure complete security. The security provided by GSM is well in advance of similar mobile radio systems, and should ensure that it remains at the front of the field for some time to come. However, it is vitally important that these capabilities are designed in from the start, as they will have an impact on the system requirements. Business cases should show the effect of fraud and the costs of protection. Encryption of GSM

2.3.6 OTHER COMPONENTS TRANSFORMERS The transformer is a static electro-magnetic device that transforms one alternating voltage (current) into another voltage (current). However, power

remains the same during the transformation. Transformers play a major role in the transmission and distribution of ac power. Transformer works on the principle of mutual induction. A transformer consists of laminated magnetic core forming the magnetic frame. Primary and secondary coils are wound upon the two cores of the magnetic frame, linked by the common magnetic flux. When an alternating voltage is applied across the primary coil, a current flows in the primary coil producing magnetic flux in the transformer core. This flux induces voltage in secondary coil. ENERGY METER The energy meter is an electrical measuring device, which is used to record Electrical Energy Consumed over a specified period of time in terms of units. In this project the energy meter acts a s a current sensor for the two transformers Energy meter is basically an assembly of electrical and mechanical components. The design of energy meter depends upon which rating of current and voltage upon meter has to work. The components like potential coils and current coils are to be designed in accordance with customer's requirements. Other components like magnets, terminals, Disc and reading registration mechanism are to be designed accordingly.

2.4 Power Supply Circuit Diagram

Power supply unit:

As we all know any invention of latest technology cannot be activated without the source of power. So it this fast moving world we deliberately need a proper power source which will be apt for a particular requirement. All the electronic components starting from diode to Intel ICs only work with a DC supply ranging from -+5v to -+12v. We are utilizing for the same, the cheapest and commonly available energy source of 230v-50Hz and stepping down, rectifying, filtering and regulating the voltage. This will be dealt briefly in the forth-coming sections.

STEP DOWN TRANSFORMER: When AC is applied to the primary winding of the power transformer it can either be stepped down or up depending on the value of DC needed. In our circuit the transformer of 230v/15-0-15v is used to perform the step down operation where a 230V AC appears as 15V AC across the secondary winding. One alteration of input causes the top of the transformer to be positive and the bottom negative. The next alteration will temporarily cause the reverse. The current rating of the transformer used in our project is 2A. Apart from stepping down AC voltages, it gives isolation between the power source and power supply circuitries. RECTIFIER UNIT: In the power supply unit, rectification is normally achieved using a solid state diode. Diode has the property that will let the electron flow easily in one direction at proper biasing condition. As AC is applied to the diode, electrons only flow when the anode and cathode is negative. Reversing the polarity of voltage will not permit electron flow. A commonly used circuit for supplying large amounts of DC power is the bridge rectifier. A bridge rectifier of four diodes (4*IN4007) are used to achieve full wave rectification. Two diodes will conduct during the negative cycle and the other two will conduct during the positive half cycle. The DC voltage appearing across the output terminals of the bridge rectifier will be somewhat lass than 90% of the applied rms value. Normally one alteration of the input voltage will reverse the polarities. Opposite ends of the transformer will therefore always be 180 deg out of phase with each other. For a positive cycle, two diodes are connected to the positive voltage at the top winding and only one diode conducts. At the same time one of the other two diodes conducts for the negative voltage that is applied from the bottom winding due to the forward bias for that diode. In this circuit due to positive half

cycleD1 & D2 will conduct to give 10.8v pulsating DC. The DC output has a ripple frequency of 100Hz. Since each altercation produces a resulting output pulse, frequency = 2*50 Hz. The output obtained is not a pure DC and therefore filtration has to be done. FILTERING UNIT: Filter circuits which are usually capacitors acting as a surge arrester always follow the rectifier unit. This capacitor is also called as a decoupling capacitor or a bypassing capacitor, is used not only to short the ripple with frequency of 120Hz to ground but also to leave the frequency of the DC to appear at the output. A load resistor R1 is connected so that a reference to the ground is maintained. C1R1 is for bypassing ripples. C2R2 is used as a low pass filter, i.e. it passes only low frequency signals and bypasses high frequency signals. The load resistor should be 1% to 2.5% of the load. 1000f/25v: for the reduction of ripples from the pulsating. 10f/25v : for maintaining the stability of the voltage at the load side. O, 1f : for bypassing the high frequency disturbances.

VOLTAGE REGULATORS: The voltage regulators play an important role in any power supply unit. The primary purpose of a regulator is to aid the rectifier and filter circuit in providing a constant DC voltage to the device. Power supplies without regulators have an inherent problem of changing DC voltage values due to variations in the load or due to fluctuations in the AC liner voltage. With a regulator connected to the DC output, the voltage can be maintained within a close tolerant region of the desired output. IC7812 and 7912 is used in this project for providing +12v and 12v DC supply.

2.5 CONCLUSION

In this phase we understand the components required for the project and the block diagram needed to develop the project. Hence we are clear with the requirements thus we will proceed to the design phase followed by the softwares required.

DESIGN

3.DESIGN 3.1 INTRODUCTION

Now , in this project we look into the designing of the circuit using the mentioned components in the previous phase 3.2 BASICS STRIP BOARD Strip board has parallel strips of copper track on one side. The tracks are 0.1" (2.54mm) apart and there are holes every 0.1" (2.54mm). Stripboard is used to make up permanent, soldered circuits. It is ideal for small circuits with one or two ICs (chips) but with the large number of holes it is very easy to connect a component in the wrong place. For large, complex circuits it is usually best to use a printed circuit board (PCB) if you can buy or make one. Components are placed on the non-copper side, then the stripboard is turned over to solder the component leads to the copper tracks. Stripboard layouts are shown from the component side, so the tracks are out of sight under the board. Layouts are normally shown with the tracks running horizontally across the diagram. Placing components on stripboard requires care. The large number of holes means it is very easy to make a mistake! For most small circuits the best method is to very carefully place the IC holder(s) in the correct position and solder in place. Then you can position all the other components relative to the IC holder(s). SOLDERING Soldering is a process in which two or more metal items are joined together by melting and flowing a filler metal into the joint, the filler metal having a relatively low melting point. Soft soldering is characterized by the melting point of the filler metal, which is below 400 C (752 F).[1] The filler metal used in the process is called solder.

3.3 CIRCUIT DIAGRAM

3.4 CONCLUSION

In this way we can design the circuit of the project which is to be implemented. Thus we have a clear picture of the project before the microcontroller being coded. Hence any necessary enhancements can be made during the phase and coding can be started

SOFTWARES

4. SOFTWARES

4.1 INTRODUCTION After finishing the design of the circuit we now move to the software part which is the heart of this project for the Microcontroller. The coding of the software made has to be programmed to the Microcontroller and then the project is implemented 4.2 SOFTWARES REQUIRED 4.2.1 KEIL SOFTWARE

Keil Compiler:
Keil is an IDE(Integrated Development Environment) which is used to develop an application program , compile and run it Even the code can be debugged .It is a simulator where we can check the application code even in the absence of the hardware board. Keil is also a cross compiler The process of development of the soft code on a processor for a particular application and which can be implemented on the target processor is known as Cross Development. In our design the main heart of the hardware module is the micro controller which is the programmable IC .The programming language used for developing the software to the micro controller is Embedded C /Assembly. The KEIL cross compiler is used to edit ,compile and debug this program Micro Flash programmer is used for burning the developed code on Keil in to the micro controller Chip. Software Development Cycle

When you use the Keil Software tools, the project development cycle is roughly the same as it is for any other software development project.

1. Create a project, select the target chip from the device database, and configure the tool settings. 2. Create source files in C or assembly. 3. Build your application with the project manager. 4. Correct errors in source files. 5. Test the linked application. 4.2.2 Vision2 IDE: The Vision2 IDE combines project management, a rich-featured editor with interactive error correction, option setup, make facility, and on-line help. Use Vision2 to create your source files and organize them into a project that defines your target application. Vision2 automatically compiles, assembles, and links your embedded application and provides a single focal point for your development efforts.

C51 Compiler & A51 Assembler: Source files are created by the Vision2 IDE and are passed to the C51 Compiler or A51 assembler. The compiler and assembler process source files and create relocatable object files. The Keil C51 Compiler is a full ANSI implementation of the C programming language that supports all standard features of the C language. In addition, numerous features for direct support of the 8051 architecture have been added. The Keil A51 macro assembler supports the complete instruction set of the 8051 and all derivatives. Vision2 Debugger The Vision2 symbolic, source-level debugger is ideally suited for fast, reliable program debugging. The debugger includes a high-speed simulator that let you simulate an entire 8051 system including on-chip peripherals and external hardware. The attributes of the chip you use are automatically configured when you select the device from the Device Database. The Vision2 Debugger provides several ways for you to test your programs on real target hardware. _ Install the MON51 Target Monitor on your target system and download your program using the Monitor-51 interface built-in to the Vision2 Debugger. _ Use the Advanced GDI interface to attach use the Vision2 Debugger front end with your target system.

Vision2 Integrated Development Environment The Vision2 IDE is a Windows-based software development platform that combines a robust editor, project manager, and make facility. Vision2 supports all of the Keil tools for the 8051 including the C compiler, macro assembler, linker/locator, and object-HEX converter. Vision2 helps expedite the development process of your embedded applications by providing the following: _ Full-featured source code editor, _ Device database for configuring the development tool setting, _ Project manager for creating and maintaining your projects, _ Integrated make facility for assembling, compiling, and linking your embedded applications, _ Dialogs for all development tool settings, _ True integrated source-level Debugger with high-speed CPU and peripheral simulator, _ Advanced GDI interface for software debugging in the target hardware and for connection to Monitor-51, _ Links to development tools manuals, device datasheets & users guides. C51 Optimizing C Cross Compiler

The Keil C51 Cross Compiler is an ANSI C Compiler that was written specifically to generate fast, compact code for the 8051 microcontroller family. The C51 Compiler generates object code that matches the efficiency and speed of assembly programming. Using a high-level language like C has many advantages over assembly language programming:

_ Knowledge of the processor instruction set is not required. Rudimentary knowledge of the memory structure of the 8051 CPU is desirable (but not necessary). _ Details like register allocation and addressing of the various memory types and data types is managed by the compiler. _ Programs get a formal structure (which is imposed by the C programming language) and can be divided into separate functions. This contributes to source code reusability as well as better overall application structure. _ The ability to combine variable selection with specific operations improves program readability. _ Keywords and operational functions that more nearly resemble the human thought process may be used. _ Programming and program test time is drastically reduced. _ The C run-time library contains many standard routines such as: formatted output, numeric conversions, and floating-point arithmetic. _ Existing program parts can be more easily included into new programs because of modular program construction techniques. _ The language C is a very portable language (based on the ANSI standard) that enjoys wide popular support and is easily obtained for most systems. Existing program investments can be quickly adapted to other processors as needed.

C51 Language Extensions

Even though the C51 Compiler is ANSI-compliant, some extensions were added to support the facilities of the 8051 microprocessor. The C51 Compiler includes extensions for: _ Data Types, _ Memory Types, _ Memory Models, _ Pointers, _ Reentrant Functions, _ Interrupt Functions, _ Real-Time Operating Systems, _ Interfacing to PL/M and A51 source files. Code Optimizations The C51 Compiler is an aggressive optimizing compiler that takes numerous steps to ensure that the code generated and output to the object file is the most efficient (smallest and/or fastest) code possible. The compiler analyzes the generated code to produce the most efficient instruction sequences. This ensures that your C program runs as quickly and effectively as possible in the least amount of code space. The C51 Compiler provides nine different levels of optimizing. Each increasing level includes the optimizations of levels below it. The following is a list of all optimizations currently performed by the C51 Compiler.

General Optimizations

_ Constant Folding: Constant values occurring in an expression or address calculation are combined as a single constant. _ Jump Optimizing: Jumps are inverted or extended to the final target address when the program efficiency is thereby increased. _ Dead Code Elimination: Code that cannot be reached (dead code) is removed from the program. _ Register Variables: Automatic variables and function arguments are located in registers whenever possible. No data memory space is reserved for these variables. _ Parameter Passing Via Registers: A maximum of three function arguments may be passed in registers. _ Global Common Subexpression Elimination: Identical subexpressions or address calculations that occur multiple times in a function are recognized and calculated only once whenever possible. _ Common Tail Merging: Common instruction blocks are merged together using jump instructions. _ Re-use Common Entry Code: Common instruction sequences are moved in front of a function to reduce code size. _ Common Block Subroutines: Multiple instruction sequences are packed into subroutines. Instructions are rearranged to maximize the block size.

8051-Specific Optimizations

_ Peephole Optimization: Complex operations are replaced by simplified operations when memory space or execution time can be saved as a result. _ Access Optimizing: Constants and variables are computed and included directly in operations. _ Extended Access Optimizing: The DPTR register is used as a register variable for memory specific pointers to improve code density. _ Data Overlaying: Function data and bit segments are OVERLAYABLE and are overlaid with other data and bit segments by the BL51 linker. _ Case/Switch Optimizing: Depending upon their number, sequence, and location, switch and case statements may be optimized using a jump table or string of jumps.

Options for Code Generation

_ OPTIMIZE(SIZE): Common C operations are replaced by subprograms. Program code size is reduced at the expense of program speed. _ OPTIMIZE(SPEED): Common C operations are expanded in-line. Program speed is increased at the expense of code size. _ NOAREGS: Absolute register access is not used. Program code is independent of the register bank. _ NOREGPARMS: Parameter passing is performed in local data segments rather than dedicated registers. This is compatible with earlier versions of the C51 Compiler, the PL/M-51 compiler, and the ASM-51 assembler.

Debugging:

The C51 Compiler uses the Intel Object Format (OMF51) for object files and generates complete symbol information. Additionally, the compiler can include all the necessary information such as; variable names, function names, line numbers, and so on to allow detailed and thorough debugging and analysis with the Vision2 Debugger or any Intel-compatible emulators.

In addition, the OBJECTEXTEND control directive embeds additional variable type information in the object file that allows type-specific display of variables and structures when using certain emulators.

You should check with your emulator vendor to determine if it is compatible with the Intel OMF51 object module format and if it can accept Keil object modules.

A51 Macro Assembler

The A51 Assembler is a macro assembler for the 8051 microcontroller family. It translates symbolic assembler language mnemonics into executable machine code. The A51 Assembler allows you to define each instruction in an 8051 program and is used where utmost speed, small code size, and exact hardware control is essential. The assemblers macro facility saves development and maintenance time since common sequences need only be developed once.

Source-Level Debugging The A51 Assembler generates complete line number, symbol, and type information in the object file created. This allows exact display of program variables in your debugger. Line numbers are used for source-level debugging of your assembler programs with the Vision2 Debugger or third-party emulator. Functional Overview The A51 Assembler translates an assembler source file into a relocatable object module. It generates a listing file optionally with symbol table and cross reference. The A51 Assembler supports two different macro processors: _ The Standard Macro Processor is the easier macro processor to use. It allows you to define and use macros in your 8051 assembly programs. The standard macro syntax is compatible with that used in many other assemblers. _ The Macro Processing Language (MPL) is a string replacement facility that is fully compatible with the Intel ASM51 macro processor. MPL has several predefined macro processor functions that perform many useful operations like string manipulation or number processing. Another powerful feature of the A51 Assembler macro processors is conditional assembly depending on command line directives or assembler symbols. Conditional assembly of sections of code can help you achieve the most compact code possible. It also allows you to generate different applications from one assembly source file. ASSEMBLY VS C: The assembly code is difficult to read and maintain. The amount of code reusable from assembly code is very low. C programs are easy to read, understand, maintain , because it possesses greater structure.

With C the programmer need not know the architecture of the processor. Code developed in C will be more portable to other systems rather than in assembly.

Difference between Conventional C and Embedded C: Compliers for conventional C are TC, BC Compilers for Embedded C are keil vision - 2 & 3, PIC C etc. Conventional C programs needs complier to compile the program & run it. The embedded C program needs a cross compiler to compile & generate HEX code. The programs in C are basically processor dependent whereas Embedded C programs are micro controller dependent.

The C program is used for developing an application and not suitable for embedded systems. The embedded C is an extension of the conventional C. i.e Embedded C has all the features of normal C, but has some extra added features which are not available in C. Many functions in C do not support Reentrant concept of functions.

C is not memory specific. i.e variables cannot be put in the desired memory location but the location of variable can be found out. In embedded C this can be done using specific inbuilt instructions.

C depends on particular processor or application. Embedded C is Controller or target specific. Embedded C allows direct communication with memory. Why C for Micro controllers: Compatibility Direct access to hardware address Direct connection to interrupts Optimization consideration Development environment Reentrancy

Rules for developing Embedded C Program: Code Optimization. 1.Minimize local variables If the number of local variables in a function is less, the compiler will be able to fit them into registers. Hence, it will be avoiding frame pointer operations on local variables that are kept on stack. This can result in considerable improvement due to two reasons: All local variables are in registers so this improves performance over accessing them from memory. If no local variables need to be saved on the stack, the compiler will not incur the overhead of setting up and restoring the frame pointer.

1.Declare local variables in the inner most scope Do not declare all the local variables in the outermost function scope. If local variables are declared in the inner most scope. If the parameter was declared in the outermost scope, all function calls would have incurred the overhead of object .

Place case labels in narrow range If the case labels are in a narrow range, the compiler does not generate a ifelse-if cascade for the switch statement. Instead, it generates a jump table of case labels along with manipulating the value of the switch to index the table. This code generated is faster than if-else-if cascade code that is generated in cases where the case labels are far apart. Also, performance of a jump table based switch statement is independent of the number of case entries in switch statement. Reduce the number of parameters Function calls with large number of parameters may be expensive due to large number of parameter pushes on stack on each call. For the same reason, avoid

passing complete structures as parameters. Use pointers and references in such cases.

Use references for parameter passing and return value for types bigger than 4 bytes Passing parameters by value results in the complete parameter being copied on to the stack. This is fine for regular types like integer, pointer etc. These types are generally restricted to four bytes. When passing bigger types, the cost of copying the object on the stack can be prohibitive. When the function exits the destructor will also be invoked.

Thus it is efficient to pass references as parameters. This way you save on the overhead of a temporary object creation, copying and destruction. This optimization can be performed easily without a major impact to the code by replacing pass by value parameters by const references. (It is important to pass const references so that a bug in the called function does not change the actual value of the parameter. Passing bigger objects as return values also has the same performance issues. A temporary return object is created in this case too.

Use All the SFRs in capital letters only. Reduce the warnings in the program. Make use of MACRO definitions in the program. Always define the variables in the code memory by using the keyword code in declaration. Eg unsigned int code a[] = { };

Always define as unsigned type of declaration. Make use of sbit definition for single bit declaration. Eg sbit rs = P3^6; Since these are not floating point co-processor, no decimal values can be given as input to them. So we cannot define the above declaration as sbit rs = P3.6. The declaration like this below are invalid. P3^6 = 0; P3^6 is bit addressable type & 0 is a 8 bit data which cannot be stored in single bit. Permanent termination of the program is got by using while(1);

4.3 CONCLUSION In this phase, we understand the software requirement specifications for the Project and the methods of using it for coding and programming the Microcontroller and thus we will proceed to the next phase that is Implementation

IMPLEMENTATION

5.IMPLEMENTATION 5.1 INTRODUCTION The implementation part is the most important phase of the project. In this phase, we code the entire project in the chosen software according to the design laid during the previous phases. The code should be efficient in all terms like space, easy to update, etc. In this manner, we can complete the coding part of the project and later it can be tested 5.2 CODING #include <reg52.h> #include <stdio.h>

#include <string.h> sbit rs=P1^0;//selecting cmd or display mode sbit en=P1^2; //make lcd to excue a cmd or display a charactrer sbit relay=P1^3; sfr lcd=0xa0; //a0 is ram address of port 2 void lcd_init();//initialize ur lcd void lcdcmd(unsigned char);//execute any cmd void lcddis(unsigned char);//display an ASCII chrcter void lcdstr(unsigned char *);//display a string void del();//generate a delay void ser_ini();//initalize serial comm void serstr(unsigned char *);//transmit a string to GSM void ser(unsigned char);//transmit a char to gsm void msgsnd();//send the msg unsigned int val=0; unsigned long res=0,cnt=0; float result=0; bit first,msg; unsigned char i; void pulse() interrupt 0 { relay=0; EA=0; TR0=0; if(first) { val=(TH0<<8|TL0); result=65536*cnt; result+=val; result*=1.085; result=result/1000000; result=(((1000/result)*3600)/230); res=(unsigned long)result; TH0=0;TL0=0; cnt=0; } else first=1; TR0=1; EA=1; }

void cyc() interrupt 1 { cnt++; } void main() { unsigned char current[5]; TMOD=0x21;//timer 1 in serial comm timer 0 in interrupt lcd_init(); IT0=1;//level triggering interrupt IE=0x83;// enable global interrupt timer interrupt xerternal interrupt ser_ini(); while (1) { for (i=0;i<5;i++) current[i]=0; lcdcmd(0x01); sprintf(current,"%lu",res); EA=1; lcdstr("Current:-"); while (!first); lcdstr(current); lcdstr("mA"); { static bit msg=0; if (res>1400) { relay=1; if(msg==0) msgsnd(); msg=1; } else {relay=0;msg=0;} } // if ((msg==1)&&(res>1400)) // {msgsnd();msg=0;} } }

void lcd_init() { lcdcmd(0x38);//activate 5x8 matrix lcdcmd(0x01);//clear the screen lcdcmd(0x06);//increment the cursor lcdcmd(0x0e);//dipslay the cursor } void lcdcmd(unsigned char cmd) { lcd=cmd;//port2 is equal to cmd rs=0;//cmd mode en=1;//enable del(); en=0; }

void lcddis(unsigned char dis) { lcd=dis; rs=1;//dis mode en=1; del(); en=0; } void lcdstr(unsigned char *str) { char i=0; while(str[i]!=0) lcddis(str[i++]); } void del() { unsigned int i; for(i=0;i<10000;i++); } void ser_ini() { SCON=0x50;//var baud rate enable reception TH1=-3;//9600 bps TR1=1;//enablew UART

serstr("AT+CMGF=1\r");//message format=TEXT FORMAT del();while(RI){RI=0;del();} serstr("AT+CPMS=\"SM\"\r");//sim memory message storage del();while(RI){RI=0;del();} } void serstr(unsigned char *str) { unsigned char i=0; while (str[i]!=0) ser(str[i++]); } void ser(unsigned char tx) { SBUF=tx; while (!TI); TI=0; } void msgsnd() { serstr("AT+CMGS=\"9703456607\"\r"); del();del(); serstr("The supply has been shared by two transformers"); ser(0x1a); del();del();del();del();del();del();del(); while (!RI); while(RI){RI=0;del();del();} }

5.3 METHODS OF IMPLEMENTATION


Open Keil IDE installed previously on your PC

Create a New Project from Projet -> New -> uVision Project

IDE will tell you to save the project and give it a name. Now keil will ask you to choose your target device. Choose your device AT89S52

Now make a new empty file Type in your source code in that empty file and save this file as main.c

Add the main source file to your project by right clicking on left side bar over "Source Group1"

By default keil compiler do not generate intel hex file on source compilation. So we need to configure it to produce Hex file as output.

Check the Create hex file box

Now you are ready to compile source and generate the hex file.

The final output will look like this...

Now you can find the generated iHex file for the project in the same directory as in project lies

Program the code in uvision

5.4 CONCLUSION In this way we implemented the code required for the project successfully with the help of Keil Compiler and uvision to the Microcontroller.We now proceed to the next step i.e testing , which is very important before delivering the project.

TESTING

6.TESTING

6.1 INTRODUCTION Testing is a critical element for any project to be successful. Now the code interfaced into the Microcontroller is in the circuit this has to be tested so that the load is shared by the transformer when it is high 6.2 STEPS Check that the whole setup is in OFF condition first Now turn on the supply and see that only one bulb is turned ON this indicates that the load is low and the current is displayed on the LCD Now for this condition only one LED of Master transformer has to be turned on, this shows that the load is only through master transformer After this , turn on the second bulb too , this indicates that the load is high and the current is displayed on the LCD Now as the load is high the microcontroller trips on the relay and the load is shared by the two transformers Now both the LEDs of transformers start glowing which indicates the load is being shared by both the transformers

A message has to be sent to the mobile number saved in the program through GSM

Thus the project is tested if the results satisfy the conditions

6.3 Testing Results A good test has a high probability of finding an as yet undiscovered error.

A successful test is one that uncovers an as yet undiscovered error. 6.4 CONCLUSION In this way we also completed the testing phase of the project and ensured that the system is ready to go live.Thus we developed a system which automatically shares the load with two transformers when the load is high by which many industries and companies can run safely

CONCLUSION

You might also like