A Project report

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


Under the guidance of

Assistant Professor


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


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



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

Head of the Department of Electrical & Electronics Engineering who has been an excellent guide and also a great source of inspiration to my work.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. PRAVEEN DESAI VIKAS VOOTURI PRASHANTH KUMAR CH 07BK1A0237 07BK1A0255 07BK1A0236 .GIRI PRASAD. SURESH BABU for his technical guidance.V. K. I am grateful to our principal. I profoundly thank Mr. who have extended their timely help and eased my task. constant encouragement and support in carrying out my project at college. I would like to thank my internal guide Mr. In this context.J RAO who most ably run the institution and has had the major hand in enabling me to do my project. 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 would also like to thank my external guide Mr. 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. both teaching and non-teaching. I would like thank all the other staff members.


Hence it is to be updated step by step manually. The relay controlling unit is taking power supply with the help of load sharing transformer by the help of Current Sensors.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. Here we are receiving the data from GSM modem and is given to the micro controller by serial communication through MAX 232. hence GSM is preferred most for this mode of controlling. 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. and appliances which would be controlled from anywhere else. automobiles. depending up on the information received it operates relay control unit and is there by operating load bank. The AT89S52 is the heart of this project. Hence it is considered as highly efficient communication through the mobile which will be useful in industrial controls. 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. . 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. GSM is the most popular mobile phone system in the world which could be used for this controlling operation from anywhere else. It has its own deterministic character. Thereby. It is also highly economic and less expensive.

Proload AT89S52 +5V. 2-line (16X2) GSM modem 11. Embedded Systems Design. Industries . 750mA Regulated Power Supply LCD HD44780 16-character.Title of the project SHARING Domain Software Microcontroller Power Supply Display LCD Communication Device Crystal Applications : : : : : : : : : : AUTOMATIC TRANSFORMER LOAD Electrical.0592MHz Electricity Generation stations. Wireless Embedded C. Keil.




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.


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 there’s 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


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 client’s 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



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.

The load is shared by these . 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.HARDWAR E 2.1 INTRODUCTION In our project we propose to design an idea for load sharing of distribution transformers using a microcontroller.

The relay controlling unit is taking power supply with the help of load sharing transformer with the help of current sensors . the controller receives the data from GSM Modem and sends to micro controller through serial communication. 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). voltage and temperature of transformer. This itself shows how vastly the technology is expanding. Technology today is seeing its heights in all the areas.transformers automatically with the help of microcontroller. Using this we are going to monitor the consumed load current. The project has in it an AT89S52 microcontroller. This project design makes use of 8051 micro controllers for interfacing to various hardware interfaces. especially in the area of Embedded Systems. micro controller operates relay control unit and is there by operating load bank. which is used for controlling the industrial equipments through a single message from anywhere. current sensing circuits. 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. a GSM modem. Based upon the message received. 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 Atmel AT89C52 is a powerful microcomputer which provides a highly-flexible and costeffective solution to many embedded control applications. By combining a versatile 8-bit CPU with Flash on a monolithic chip.3. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional non-volatile memory programmer.3 MAJOR COMPONENTS 2. high-performance CMOS 8-bit microcomputer with 8Kbytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmel’s high-density non-volatile memory technology and is compatible with the industry-standard MCS-51 instruction set and pin out.2. Pin Configurations .1 MICROCONTROLLER AT89C52 Description The AT89C52 is a low-power.

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

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

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

10V dual charge pump voltage converter. +12V power supplies required. 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 four level translators.5V (used in power supply Section of computers. A dual transmitter 2. The other two level translators are RS232 receivers that convert RS232 inputs to 5V TTL\CMOS output level. Serial communication requires only one line for the data. peripherals. PIN DIAGRAM OF MAX 232 . + or . Three main sections of MAX232 are 1. Suitable for all RS232 communications.5V and can operate up to + 30V input. 3. These receivers have a nominal threshold of 1. A dual receiver 3. which allows the transmission of an entire byte at once.5V to + or . Although this is slower than parallel communication. in serial communication data is sent one bit at a time. 1. 2. It has 2 onboard charge pump voltage converters which generate +10V and –10V power supplies from a single 5V power supply. Voltage quadruple for input voltage up to 5.3V.The concept of serial communication is simple. two of which are RS232 transmitters that convert TTL\ CMOS input levels into + 9V RS232 outputs. second line for ground & possible a third line for clock. a typical hysterics of 0. and modems).

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 .5v output swing under the worst of both transmitter driving the 3KΩ . 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 .9 v.10V internally generated supply.TRANSMITTER SECTION: Each of the two transmitters is a CMOS inverter powered by + or .5V and maximum allowable ambient temperature typical voltage with 5KΩ and Vcc = + or . RECEIVER SECTION . the Vcc input at 4. Minimum load impedance.2V applied to the output with Vcc = 0V.The outputs are short circuit protected and can be short circuited to ground indefinitely. The input is TTL and CMOS compatible with a logic threshold of about 26% of Vcc.

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

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

K . pin 2 or pin 15.APPLICATIONS • Power supply regulators • Digital logic inputs • Microprocessor inputs 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.2. pin 16 or A.

optional for + 3V power supply PIN DESCRIPTION DISPLAY 2.(LED) • N.V. The use of radio at the transmission media .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.3.

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

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. linked by the common magnetic flux. . 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. Transformer works on the principle of mutual induction. terminals. Transformers play a major role in the transmission and distribution of ac power. This flux induces voltage in secondary coil. The design of energy meter depends upon which rating of current and voltage upon meter has to work. a current flows in the primary coil producing magnetic flux in the transformer core. Other components like magnets. The components like potential coils and current coils are to be designed in accordance with customer's requirements. When an alternating voltage is applied across the primary coil. Primary and secondary coils are wound upon the two cores of the magnetic frame. A transformer consists of laminated magnetic core forming the magnetic frame. Disc and reading registration mechanism are to be designed accordingly.remains the same during the transformation.

2. the cheapest and commonly available energy source of 230v-50Hz and stepping down. rectifying. We are utilizing for the same. So it this fast moving world we deliberately need a proper power source which will be apt for a particular requirement. This will be dealt briefly in the forth-coming sections. . filtering and regulating the voltage. All the electronic components starting from diode to Intel IC’s only work with a DC supply ranging from -+5v to -+12v.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.

RECTIFIER UNIT: In the power supply unit. rectification is normally achieved using a solid state diode. One alteration of input causes the top of the transformer to be positive and the bottom negative. For a positive cycle. As AC is applied to the diode. electrons only flow when the anode and cathode is negative. Diode has the property that will let the electron flow easily in one direction at proper biasing condition. it gives isolation between the power source and power supply circuitries. The DC voltage appearing across the output terminals of the bridge rectifier will be somewhat lass than 90% of the applied rms value. Two diodes will conduct during the negative cycle and the other two will conduct during the positive half cycle. A bridge rectifier of four diodes (4*IN4007) are used to achieve full wave rectification. In this circuit due to positive half . 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. Opposite ends of the transformer will therefore always be 180 deg out of phase with each other. 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. two diodes are connected to the positive voltage at the top winding and only one diode conducts. The next alteration will temporarily cause the reverse.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. The current rating of the transformer used in our project is 2A. A commonly used circuit for supplying large amounts of DC power is the bridge rectifier. Reversing the polarity of voltage will not permit electron flow. Apart from stepping down AC voltages. Normally one alteration of the input voltage will reverse the polarities.

5% of the load. C2R2 is used as a low pass filter. i. Since each altercation produces a resulting output pulse. 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. 1f : for bypassing the high frequency disturbances. The primary purpose of a regulator is to aid the rectifier and filter circuit in providing a constant DC voltage to the device.8v pulsating DC. it passes only low frequency signals and bypasses high frequency signals. The output obtained is not a pure DC and therefore filtration has to be done. 10f/25v : for maintaining the stability of the voltage at the load side.cycleD1 & D2 will conduct to give 10. The DC output has a ripple frequency of 100Hz. FILTERING UNIT: Filter circuits which are usually capacitors acting as a surge arrester always follow the rectifier unit. VOLTAGE REGULATORS: The voltage regulators play an important role in any power supply unit. 1000f/25v: for the reduction of ripples from the pulsating. 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.5 CONCLUSION . The load resistor should be 1% to 2. 2. O. A load resistor R1 is connected so that a reference to the ground is maintained. C1R1 is for bypassing ripples. This capacitor is also called as a decoupling capacitor or a bypassing capacitor. the voltage can be maintained within a close tolerant region of the desired output.e. IC7812 and 7912 is used in this project for providing +12v and –12v DC supply. frequency = 2*50 Hz.

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.


Now .54mm) apart and there are holes every 0. which is below 400 °C (752 °F). then the stripboard is turned over to solder the component leads to the copper tracks.[1] The filler metal used in the process is called solder. 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. Stripboard layouts are shown from the component side. Stripboard is used to make up permanent. Layouts are normally shown with the tracks running horizontally across the diagram.1" (2.3 CIRCUIT DIAGRAM . 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. soldered circuits.54mm). complex circuits it is usually best to use a printed circuit board (PCB) if you can buy or make one. Soft soldering is characterized by the melting point of the filler metal.1" (2. the filler metal having a relatively low melting point. in this project we look into the designing of the circuit using the mentioned components in the previous phase 3. 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. 3. Components are placed on the non-copper side. For large. The tracks are 0. Then you can position all the other components relative to the IC holder(s). so the tracks are out of sight under the board. Placing components on stripboard requires care.2 BASICS STRIP BOARD Strip board has parallel strips of copper track on one side.


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 .In this way we can design the circuit of the project which is to be implemented.


2. the project development cycle is roughly the same as it is for any other software development project.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.compile and debug this program Micro Flash programmer is used for burning the developed code on Keil in to the micro controller Chip.4.1 KEIL SOFTWARE Keil Compiler: Keil is an IDE(Integrated Development Environment) which is used to develop an application program . In our design the main heart of the hardware module is the micro controller which is the programmable IC . 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. compile and run it Even the code can be debugged . Software Development Cycle When you use the Keil Software tools.The programming language used for developing the software to the micro controller is Embedded C /Assembly.It is a simulator where we can check the application code even in the absence of the hardware board. . The KEIL cross compiler is used to edit . The coding of the software made has to be programmed to the Microcontroller and then the project is implemented 4.2 SOFTWARES REQUIRED 4.

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

numerous features for direct support of the 8051 architecture have been added. 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. µVision2 Debugger The µVision2 symbolic. _ Use the Advanced GDI interface to attach use the µVision2 Debugger front end with your target system. source-level debugger is ideally suited for fast. The debugger includes a high-speed simulator that let you simulate an entire 8051 system including on-chip peripherals and external 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.C51 Compiler & A51 Assembler: Source files are created by the µVision2 IDE and are passed to the C51 Compiler or A51 assembler. The Keil A51 macro assembler supports the complete instruction set of the 8051 and all derivatives. The compiler and assembler process source files and create relocatable object files. In addition. The Keil C51 Compiler is a full ANSI implementation of the C programming language that supports all standard features of the C language. reliable program debugging.

device datasheets & user’s guides. µVision2 supports all of the Keil tools for the 8051 including the C compiler. and object-HEX converter. _ True integrated source-level Debugger with high-speed CPU and peripheral simulator.µVision2 Integrated Development Environment The µVision2 IDE is a Windows-based software development platform that combines a robust editor. linker/locator. The C51 Compiler generates object code that matches the efficiency and speed of assembly programming. _ Device database for configuring the development tool setting. and linking your embedded applications. and make facility. project manager. _ Project manager for creating and maintaining your projects. compiling. µVision2 helps expedite the development process of your embedded applications by providing the following: _ Full-featured source code editor. _ Dialogs for all development tool settings. 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. _ Links to development tools manuals. macro assembler. _ Advanced GDI interface for software debugging in the target hardware and for connection to Monitor-51. Using a high-level language like C has many advantages over assembly language programming: . _ Integrated make facility for assembling.

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

Each increasing level includes the optimizations of levels below it. _ Reentrant Functions. 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. General Optimizations .Even though the C51 Compiler is ANSI-compliant. _ Pointers. _ Real-Time Operating Systems. The following is a list of all optimizations currently performed by the C51 Compiler. The C51 Compiler includes extensions for: _ Data Types. _ Interrupt Functions. The compiler analyzes the generated code to produce the most efficient instruction sequences. The C51 Compiler provides nine different levels of optimizing. some extensions were added to support the facilities of the 8051 microprocessor. _ Interfacing to PL/M and A51 source files. _ Memory Types. _ Memory Models. This ensures that your C program runs as quickly and effectively as possible in the least amount of code space.

_ Common Tail Merging: Common instruction blocks are merged together using jump instructions. _ Parameter Passing Via Registers: A maximum of three function arguments may be passed in registers. 8051-Specific Optimizations . _ Global Common Subexpression Elimination: Identical subexpressions or address calculations that occur multiple times in a function are recognized and calculated only once whenever possible._ 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. _ Common Block Subroutines: Multiple instruction sequences are packed into subroutines. Instructions are rearranged to maximize the block size. _ Re-use Common Entry Code: Common instruction sequences are moved in front of a function to reduce code size. No data memory space is reserved for these variables. _ Register Variables: Automatic variables and function arguments are located in registers whenever possible.

. _ Access Optimizing: Constants and variables are computed and included directly in operations. _ Case/Switch Optimizing: Depending upon their number. Program code size is reduced at the expense of program speed. the PL/M-51 compiler. This is compatible with earlier versions of the C51 Compiler. _ Extended Access Optimizing: The DPTR register is used as a register variable for memory specific pointers to improve code density. sequence. Options for Code Generation _ OPTIMIZE(SIZE): Common C operations are replaced by subprograms. and location. Program speed is increased at the expense of code size. _ Data Overlaying: Function data and bit segments are OVERLAYABLE and are overlaid with other data and bit segments by the BL51 linker. and the ASM-51 assembler. _ OPTIMIZE(SPEED): Common C operations are expanded in-line._ Peephole Optimization: Complex operations are replaced by simplified operations when memory space or execution time can be saved as a result. _ NOREGPARMS: Parameter passing is performed in local data segments rather than dedicated registers. _ NOAREGS: Absolute register access is not used. Program code is independent of the register bank. switch and case statements may be optimized using a jump table or string of jumps.

line numbers. A51 Macro Assembler The A51 Assembler is a macro assembler for the 8051 microcontroller family. and exact hardware control is essential. function names. small code size. 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. The A51 Assembler allows you to define each instruction in an 8051 program and is used where utmost speed. and so on to allow detailed and thorough debugging and analysis with the µVision2 Debugger or any Intel-compatible emulators. 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. the compiler can include all the necessary information such as. In addition. It translates symbolic assembler language mnemonics into executable machine code. variable names. The assembler’s macro facility saves development and maintenance time since common sequences need only be developed once. Additionally. .Debugging: The C51 Compiler uses the Intel Object Format (OMF51) for object files and generates complete symbol information.

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

•C is not memory specific. • In embedded C this can be done using specific inbuilt instructions. PIC C etc. i.• With C the programmer need not know the architecture of the processor.e Embedded C has all the features of normal C.e variables cannot be put in the desired memory location but the location of variable can be found out. BC • Compilers for Embedded C are keil µvision . • Code developed in C will be more portable to other systems rather than in assembly. . but has some extra added features which are not available in C. Difference between Conventional C and Embedded C: • Compliers for conventional C are TC. •The C program is used for developing an application and not suitable for embedded systems. • 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 embedded C is an extension of the conventional C. • Many functions in C do not support Reentrant concept of functions.2 & 3. i.

• Embedded C is Controller or target specific. Hence. it will be avoiding frame pointer operations on local variables that are kept on stack. 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. . •If no local variables need to be saved on the stack. 1. the compiler will be able to fit them into registers. 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. the compiler will not incur the overhead of setting up and restoring the frame pointer. • Embedded C allows direct communication with memory.•C depends on particular processor or application.Minimize local variables If the number of local variables in a function is less.

it generates a jump table of case labels along with manipulating the value of the switch to index the table. • Instead. • If the parameter was declared in the outermost scope. the compiler does not generate a ifelse-if cascade for the switch statement. • Also. • This code generated is faster than if-else-if cascade code that is generated in cases where the case labels are far apart. all function calls would have incurred the overhead of object . For the same reason. • If local variables are declared in the inner most scope.Declare local variables in the inner most scope • Do not declare all the local variables in the outermost function scope. 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.1. • Place case labels in narrow range • If the case labels are in a narrow range. avoid .

This optimization can be performed easily without a major impact to the code by replacing pass by value parameters by const references. This way you save on the overhead of a temporary object creation. This is fine for regular types like integer. . When passing bigger types. A temporary return object is created in this case too. the cost of copying the object on the stack can be prohibitive. copying and destruction. (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 complete structures as parameters. pointer etc. Use pointers and references in such cases. When the function exits the destructor will also be invoked. Passing bigger objects as return values also has the same performance issues. Thus it is efficient to pass references as parameters. These types are generally restricted to four bytes. 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.

3 CONCLUSION In this phase. •Eg sbit rs = P3^6. • So we cannot define the above declaration as sbit rs = P3. •Always define the variables in the code memory by using the keyword code in declaration. no decimal values can be given as input to them. •Make use of sbit definition for single bit declaration. •Make use of MACRO definitions in the program. •Eg unsigned int code a[] = { }.6. P3^6 = 0. • The declaration like this below are invalid. • Permanent termination of the program is got by using while(1).•Use All the SFR’s in capital letters only. •Always define as unsigned type of declaration. •Since these are not floating point co-processor. 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 . 4. • P3^6 is bit addressable type & 0 is a 8 bit data which cannot be stored in single bit. •Reduce the warnings in the program.


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

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

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

i<10000.//var baud rate enable reception TH1=-3. en=0.i++).//dis mode en=1. while(str[i]!=0) lcddis(str[i++]).//enablew UART .//9600 bps TR1=1. } void lcddis(unsigned char dis) { lcd=dis.void lcd_init() { lcdcmd(0x38).//activate 5x8 matrix lcdcmd(0x01). } void del() { unsigned int i.//clear the screen lcdcmd(0x06). rs=1. del().//port2 is equal to cmd rs=0.//increment the cursor lcdcmd(0x0e).//cmd mode en=1. for(i=0. } void lcdstr(unsigned char *str) { char i=0.//dipslay the cursor } void lcdcmd(unsigned char cmd) { lcd=cmd. en=0.//enable del(). } void ser_ini() { SCON=0x50.

//sim memory message storage del(). } void msgsnd() { serstr("AT+CMGS=\"9703456607\"\r"). TI=0.del().} } void serstr(unsigned char *str) { unsigned char i=0.del().while(RI){RI=0.del().del(). ser(0x1a).del(). while (!TI).serstr("AT+CMGF=1\r"). serstr("The supply has been shared by two transformers").} } 5. del().del().3 METHODS OF IMPLEMENTATION Open Keil IDE installed previously on your PC .//message format=TEXT FORMAT del().del().del(). while(RI){RI=0.del().while(RI){RI=0. del(). } void ser(unsigned char tx) { SBUF=tx.del(). while (str[i]!=0) ser(str[i++]). while (!RI).del().} serstr("AT+CPMS=\"SM\"\r").

Choose your device AT89S52 . Now keil will ask you to choose your target device.Create a New Project from Projet -> New -> uVision Project IDE will tell you to save the project and give it a name.

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. Check the Create hex file box . So we need to configure it to produce Hex file as output.

Now you can find the generated iHex file for the project in the same directory as in project lies ...Now you are ready to compile source and generate the hex file. The final output will look like this.

e testing .We now proceed to the next step i.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.Program the code in uvision 5. which is very important before delivering the project. .


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.6. turn on the second bulb too .3 Testing Results  A good test has a high probability of finding an as yet undiscovered error. this shows that the load is only through master transformer • After this . . 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 LED’s 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. 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.1 INTRODUCTION Testing is a critical element for any project to be successful.

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 . 6. A successful test is one that uncovers an as yet undiscovered error.


Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.