P. 1
Mini Project on Gsm Based Ups Batterys Management Changes

Mini Project on Gsm Based Ups Batterys Management Changes

|Views: 1,272|Likes:
Published by Bhargav Reddy

More info:

Published by: Bhargav Reddy on Aug 12, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

05/28/2013

pdf

text

original

MINI PROJECT REPORT

On

GLOBAL ALERT AND CONTROL SYSTEM FOR UPS BATTERY MANAGEMENT FOR CORPORATE AUTOMATION (GSM)
Submitted in partial fulfillment of the requirements For the award of the degree of

BACHELOR OF TECHNOLOGY
IN

ELECTRONICS & COMMUNICATION ENGINEERING

BY

Y.SAI NITISH P.CHANDRA SHEKER

(08C71A04A9) (08C71A0482)

Under the Guidance of

P.SURESH REDDY
Asst.Prof Department of ECE

ELLENKI COLLEGE OF ENGINEERING & TECHNOLOGY
PATELGUDA, PATANCHERU, MEDAK DISTRICT-502305
AFFILIATED TO JNTU

ELLENKI COLLEGE OF ENGINEERING & TECHNOLOGY
PATELGUDA, PATANCHERU, MEDAK DISTRICT-502305 DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

CERTIFICATE

This

is

to

certify that project report entitled

“GLOBAL ALERT AND

CONTROL SYSTEM FOR UPS BATTERY MANAGEMENT FOR CORPORATE AUTOMATION (GSM)” of third year in partial fulfillment of requirements for the award of the degree of bachelor of technology in Electronics & Communication Engineering under Jawaharlal Nehru technology of University during the period of 2008-2012.

INTERNAL GUIDE

HEAD OF THE DEPARTMENT

Mr.P.SURESH REDDY Asst.Prof DEPARTMENT OF ECE

Mr.T.SRAVAN KUMAR Assoc.Prof DEPARTMENT OF ECE

EXTERNAL GUIDE

ACKNOWLEDGEMENT

Taking up the execution of project work was a rich experience by itself as it involved more of my efforts. It was the first opportunity for me to apply my knowledge and skill to work up on and an idea, which certainly will be helpful after stepping in to the actual field work.

My sincere thanks to external project guide SRINIVAS of KREST TECHNOLOGIES HYDERABAD, for the guidance and support pertaining to use lab facilities and carry out this project work.

I express my profound attitude to our guide Mr.P.SURESH REDDY Asst.prof of ECE department for her support and encouragement in completing the project .I thanks her project guidance and help through the development of this project for providing me with required information. Without her guidance, co-operation and encouragement, I couldn’t have learned many things during my project tenure.

I would like to thank Mr.T.SRAVAN KUMAR Assoc.Prof, Head of the department of electronics and communication engineering for his valuable guidance in bringing shape to this dissertation.

I express my special thanks to Principal Prof.MR.AMZAN SHAIK on behalf of our ECE department for his kind co-operation.

Y.SAI NITISH P.CHANDRA SHEKER

(08C71A04A9) (08C71A0482)

ABSTRACT

Then by power detector circuit this information goes to microcontroller and buzzer will produce an alarming sound.NO 1. but if due to some reason mains supply is not working. In the beginning we are giving the main supply by transformer one. The microcontroller simply connects the second power supply and disconnects the existing supply using relay based control circuit. If person wants to continue the power supply by second transformer then that person has to send message to gsm modem. Whenever the gsm modem receives sms message to change the power supply connection it gives instruction to microcontroller. One is as mains supply to corporate and second transformer as secondary (UPS) supply. CONTENTS INTRODUCTION PAGE NO . INDEX CH.In this project. we are using two transformers. Microcontroller will send the message to authorized person by GSM modem.

2. 1 SCHEMATIC DESCRIPTION 4. SCHEMATIC 3. BLOCK DIAGRAM 2. 1 BLOCK DIAGRAM DESCRIPTION 3. • • 6. • • • • • • • • 5. 7. HARDWARE COMPONENTS MICROCONTROLLER GSM MODEM BUZZER LED RELAY LCD POWER SUPPLY TRANSFORMERS SOFTWARE ABOUT KIEL EMBEDDED ‘C’ SOURCE CODE CONCLUSION (OR) SYNOPSIS ABBREVATIONS BIBLIOGRAPHY . 8.

. Embedded systems are often mass-produced. Unlike a general-purpose computer. If we want change the existed battery with another battery just we have to send the sms to gsm modem connected. Automated systems have less manual operations.CHAPTER 1 INTRODUCTION Every system is automated in order to face new challenges in the present day situation. Instead of analog services.The microcontroller simply connects the new battery and disconnects the existing battery using relay based control circuit. If you travel in parts of world. design engineers can optimize it. so that the flexibility. reliabilities are high and accurate. Probably the most useful thing to know about the global system for mobile communication is that it is an international standard. GSM was developed as a digital system using TDMA technology. In our project the microcontroller continuously monitors the voltage and if the voltage drops below the present value then this system alerts the local user and the remote personal through gsm in the form of sms message. Since the system is dedicated to specific tasks. Especially in the field of electronics automated systems are doing better performance increasingly. reducing the size and cost of the product. GSM is only type of cellular service available. benefiting from economies of scale. Hence every field prefers automated control systems. INTRODUCTION TO GSM TECHNOLOGY An embedded system is a special-purpose system in which the computer is completely encapsulated by or dedicated to the device or system it controls. usually with very specific requirements. Whenever the gsm modem receives sms message to change the battery connection it gives instruction to microcontroller . such as a personal computer. an embedded system performs one or a few predefined tasks.

then sends it down a channel with two other streams of user data.What is GSM Global System for Mobile Communication (GSM) is a set of ETSI standards specifying the infrastructure for a digital cellular service. 1800MHz. each in its own time slot. based on the global title translation of the IMSI that is stored within the SCCP Called Party Address portion of the message. GSM uses a variation of Time Division Multiple Access (TDMA) and is the most widely used of the three digital wireless telephone technologies. GSM operates in the 900MHz. GSM digitizes and compresses data. The standard is used in approx. which it does using an SS7 Location Update Request Message. The HLR responds with a message that informs the VLR whether the subscriber should be provided service in Fig:Gsm call routing GSM (Global System for Mobile communication) is a digital mobile telephone system that is widely used in many parts of the world. The Location Update Message is routed to the HLR through the SS7 network. or 1900 MHz frequency bands. . Japan and Australia1 GSM Call Routing Mobile Subscriber Roaming When a mobile subscriber roams into a new location area (new VLR). 85 countries in the world including such locations as Europe. the VLR automatically determines that it must update the HLR with the new location information.

and Universal Mobile Telecommunications Service (UMTS). particularly for content delivery over mobile phone networks: 1. Scalability 2. and legal interception continue to raise significant interest in the GSM community. . GSM security issues such as theft of service. The purpose of this portal is to raise awareness of these issues with GSM security. Micro transactions/Micro payments compatibility 3. General Packet Radio System (GPRS). Digital containers offer an alternative way of securely delivering content to consumers. uni cast /multicast/broadcast etc) 4. They can offer many advantages. Consumer anonymity Etc. Enhanced Data GSM Environment (EDGE).GSM together with other technologies is part of an evolution of wireless mobile telecommunication that includes High-Speed Circuit-Switched Data (HCSD). Possibility of DRM 5. Content channel neutrality (heterogeneous networks. privacy.

CHAPTER 2 BLOCK DIAGRAM: POWER SUPPLY MICRO CONTROLLER Y LCD RELA Transformer Transformer 2 BUZZER LED INDICATOR GSM MODEM M AX2 32 Power detector ckt .

This fault is indicated by displaying in LCD. Microcontrollers were originally used as components in complicated process-control systems. But here in this project two power supplies are used one is meant to supply operating voltage for Microcontroller and the other is to supply control voltage for Relays. After rectification the obtained rippled dc is filtered using a capacitor Filter. However. This project will facilitates us to monitor as well as control different parameters at a time which increase accuracy and speed. A positive voltage regulator is used to regulate the obtained dc voltage. . because of their small size and low price. POWER SUPPLY This section is meant for supplying Power to all the sections mentioned above. Gsm Modem Here we are using GSM MODEM to communicate with the mobile phone to which we are going to send the message.Fig: block diagram of microcontroller 2. It basically consists of a Transformer to step down the 230V ac to 18V ac followed by diodes. In several areas Microcontrollers are now outperforming their analog counterparts and are cheaper as well. Here diodes are used to rectify the ac to dc. Whenever an authorized person wants to know the status of parameter or whenever parameters values increases above the threshold value then a message will be sent through modem.1 BLOCK DIAGRAM EXPLANATION: Micro Controller: In this project work the micro-controller is plays major role. Micro-controllers are now also being used in regulators for individual control loops.

The word "buzzer" comes from the rasping noise that buzzers made when they were electromechanical devices. they have a temperature range within which the molecules are almost as mobile as they would be in a liquid. Introduced as a practical electronic component in 1962. & game shows. but are grouped together in an ordered form similar to a crystal. 5 Buzzer: A buzzer or beeper is a signaling device. Leds: A light-emitting diode (LED) is a semiconductor light source. operated from stepped-down AC line voltage at 50 or 60 cycles. early LEDs emitted low-intensity red light. Rather than having a melting point.. Other sounds commonly used to indicate that a button has been pressed are a ring or a beep.. typically used in automobiles. ultraviolet and infrared wavelengths.LCD: Liquid crystal displays (LCDs) have materials. and are increasingly used for lightning. with very high brightness. usually electronic. . but modern versions are available across the visible. household appliances such as a microwave ovens. which combine the properties of both liquids and crystals. LEDs are used as indicator lamps in many devices.

32 or 64 bit micro controllers or microprocessors.1 SCHEMATIC DESCRIPTION The system requirements and control specifications clearly rule out the use of 16. Systems using these may be earlier to .6 CHAPTER 3 SCHEMATIC DIAGRAM: 3.

c voltage is now filtered using a ‘C’ filter.C. the most common type today. The forms of practical capacitors vary widely. The microcontroller 89C51 with Pull up resistors at Port0 and . power supply is needed. high-performance CMOS 8-bit microcontroller with 4Kbytes of in-system programmable Flash memory. By combining a versatile 8-bit CPU with in-system programmable Flash on a Monolithic chip. 8-bit micro controller satisfactorily serves the above application. The on-chip Flash allows the program Memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. The required operating voltage for Microcontroller 89C51 is 5V. filtered and regulated voltage is again filtered for ripples using an electrolytic capacitor 100μF. voltage is fed to the Voltage Regulator. consist of metal foils separated by a layer of insulating film. Now the step downed a. The AT89S51 is a low-power. Now the rectified. A semiconductor diode. This regulated 5V is generated by stepping down the voltage from 230V to 12V using step down transformer. They are also faster and more reliable but. but all contain at least two conductors separated by a non-conductor. Hence the 5V D. The device is manufactured using Atmel’s high-density nonvolatile memory technology and is compatible with the industryStandard 80C51 instruction set and pin out.C. is a crystalline piece of semiconductor material connected to two electrical terminals. The rectified a.[1] A vacuum tube diode (now little used except in some high-power technologies) is a vacuum with two electrodes: a plate and a cathode. When a voltage V is applied across the terminals of a resistor. A diode is a two-terminal electronic component. The rectified. Now the output from this section is fed to 40th pin of 89c51 microcontroller to supply operating voltage. Using an inexpensive 8bit Microcontroller will doom the 32-bit product failure in any competitive market place. a current I will flow through the resistor in direct proportion to that voltage. filtered D. the Atmel AT89S51 is a powerful microcontroller which provides a Highly-flexible and cost-effective solution to many embedded control applications. A capacitor (formerly known as condenser) is a device for storing electric charge. This voltage regulator provides/allows us to have a Regulated constant Voltage which is of +5V.c voltage is being rectified by the Bridge Rectifier using 1N4007 diodes.implement due to large number of internal features. for example. 7 A resistor is a two-terminal passive electronic component that implements electrical resistance as a circuit element. Capacitors used as parts of electrical systems.

and connect the modem to an available serial port on your computer. or various Ericsson phones. . 8 Gsm Modem A GSM modem can be an external modem device. be sure to install the appropriate Windows modem driver from the device manufacturer. An additional benefit of utilizing this driver is that you can use Windows diagnostics to ensure that the modem is communicating properly with the computer. A GSM modem could also be a standard GSM mobile phone with the appropriate cable and software driver to connect to a serial port on your computer.0592 MHz crystal in conjunction with couple of 30-33pf capacitors is placed at 18th& 19th pins of 89c51 to make it work (execute) properly. or connect your GSM mobile phone to the computer. To simplify configuration. Insert a GSM SIM card into this modem. are often used for this purpose. Phones such as the Nokia 7110 with a DLR-3 cable. the Now SMS/MMS Gateway will communicate with the device via this driver. such as the Wavecom FASTRACK Modem.crystal oscillator of 11. When you install your GSM modem.

Digital to Analog converter. various I/O interfaces such as serial port. But controller is provided all these facilities on a single chip. integrated on to a single silicon chip. EPROM and peripherals. . interrupt controller. parallel port timer or counter. the designer has to go for external memory such as RAM. Development of a Micro controller reduces PCB size and cost of design. ROM. If a system is developed with a microprocessor.9 CHAPTER 4 Hardware Components MICROCONTROLLER GSM MODEM BUZZER LED RELAY LCD POWER SUPPLY TRANSFORMERS 4. data acquisition interfaces-Analog to Digital converter.1 MICRO CONTROLLER 89C51 Introduction A Micro controller consists of a powerful CPU tightly coupled with memory.

One of the major differences between a Microprocessor and a Micro controller is that a controller often deals with bits not bytes as in the real world application. Intel has introduced a family of Micro controllers called the MCS-51. The Major Features: • • • Compatible with MCS-51 products 4k Bytes of in-system Reprogrammable flash memory Fully static operation: 0HZ to 24MHZ 10 Label1 • • 128 * 8 –bit timer/counters Six interrupt sources .

7. Typically a quartz crystal and capacitors are employed. On-Chip memory refers to physically existing memory on the micro controller itself.Functional block diagram of micro controller The 89C51 oscillator and clock: The heart of the 89C51 circuitry that generates the clock pulses by which all the internal all internal operations are synchronized. External RAM is the Ram that resides off chip. External code memory is the code memory that resides off chip. external Code memory and external Ram. This often is in the form of standard static RAM or flash RAM . They are on-chip memory. This is often in the form of an external EPROM. The manufacturers make 89C51 designs that run at specific minimum and maximum frequencies typically 1 to 16 MHz 11 Fig 3.2: . Pins XTAL1 and XTAL2 are provided for connecting a resonant network to form an oscillator.Oscillator and timing circuit Types of memory: The 89C51 have three general types of memory.

e. Internal RAM also contains 128 bits.7. Code memory may be found on-chip or off-chip. If only off-chip memory is available then there can be 64K of off chip ROM. These bits are bit addressed i.Code memory Code memory is the memory that holds the actual 89C51 programs that is to be run. The internal RAM is found on-chip. The user may make use of these variables with commands such as SETB and CLR. So it is the fastest Ram available. which are addressed from 20h to 2Fh. They are numbered 00h to 7Fh. Internal Ram is volatile. It is possible to have 4K of code memory on-chip and 60K off chip memory simultaneously. Each bank contains 8 registers.3: . so when 89C51 is reset. this memory is cleared. each individual bit of a byte can be addressed by the user. This is controlled by pin provided as EA 12 a) Internal RAM The 89C51 have a bank of 128 of internal RAM. This memory is limited to 64K. And also it is most flexible in terms of reading and writing. The first 32 bytes are divided into 4 register banks. 128 bytes of internal memory are subdivided. Fig 3.Pin diagram of AT89C51 Pin Description: .

GND: Ground. the pins can be used as high impedance inputs. In this mode P0 has internal pullups. During accesses to external data memories that use 8-bit addresses (MOVX @ RI). Port 0 may also be configured to be the multiplexed low order address/data bus during accesses to external program and data memory. The Port 1 output buffers can sink/source four TTL inputs. Port 1 also receives the low-order address bytes during Flash programming and verification. External pull-ups are required during program verification. As inputs. In this application. The Port 2 output buffers can sink/source four TTL inputs. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memories that use 16-bit addresses (MOVX @DPTR). As inputs. Port 0 also receives the code bytes during Flash programming. and outputs the code bytes during program verification. When 1s are written to Port 2 pins they are pulled high by the internal pull-ups and can be used as inputs. When 1s are written to Port 1 pins they are pulled high by the internal pull-ups and can be used as inputs. 13 Port 0: Port 0 is an 8-bit open-drain bi-directional I/O port. When one’s are written to port 0 pins. Port 2: Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. Port 1: Port 1 is an 8-bit bi-directional I/O port with internal pull-ups.VCC: Supply voltage. Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. it uses strong internal pull-ups when emitting 1s. each pin can sink eight TTL inputs. Port 2 emits the contents of the P2 Special . As an output port.

2. When 1s are written to Port 3 pins they are pulled high by the internal pull-ups and can be used as inputs. The Port 3 output buffers can sink/source four TTL inputs. Port 2 also receives the high-order address bits and some control signals during Flash programming and verification. 14 Port 3: Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. As inputs.Function Register. Port 3 pins that are externally being pulled low will source current (IIL) because of the pull-ups. Port 3 also serves the functions of various special features of the AT89C51 as listed below: Port 3 also receives some control signals for Flash programming and verification. Tab 6.1 Port pins and their alternate functions RST: .

This pin is also the program pulse input (PROG) during Flash programming. 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. 15 ALE/PROG: Address Latch Enable output pulse for latching the low byte of the address during accesses to external memory. Note. A high on this pin for two machine cycles while the oscillator is running resets the device. In normal operation ALE is emitted at a constant rate of 1/6the oscillator frequency. PSEN is activated twice each machine cycle. that one ALE pulse is skipped during each access to external Data Memory. Otherwise.Reset input. and may be used for external timing or clocking purposes. . the pin is pulled high. however. PSEN: Program Store Enable is the read strobe to external program memory. When the AT89C51 is executing code from external program memory. except that two PSEN activations are skipped during each access to external data memory. If desired. With the bit set. ALE operation can be disabled by setting bit 0 of SFR location 8EH. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode. ALE is active only during a MOVX or MOVC instruction.

. 16 XTAL2: It is the Output from the inverting oscillator amplifier. This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming. Either a quartz crystal or ceramic resonator may be used. for parts that require 12-volt VPP.2. Oscillator Characteristics: XTAL1 and XTAL2 are the input and output.3. To drive the device from an external clock source. XTAL1: Input to the inverting oscillator amplifier and input to the internal clock operating circuit. respectively.There are no requirements on the duty cycle of the external clock signal. of an inverting amplifier which can be configured for use as an on-chip oscillator. as shown in Figs 6.4. since the input to the internal clocking circuitry is through a divide-by-two flip-flop.2. XTAL2 should be left unconnected while XTAL1 is driven as shown in Figure 6.EA should be strapped to VCC for internal program executions. but minimum and maximum voltage high and low time specifications must be observed.

2.2. or what is normally called Scratch pad. These 128 bytes are divided into three different groups as follows: 1. A total of 32 bytes from locations 00 to 1FH hex are set aside for register banks and the stack. 2.4 External Clock Drive Configuration 17 8051 Register Banks and Stack RAM memory space allocation in the 8051 There are 128 bytes of RAM in the 8051. A total of 80 bytes from locations 30H to 7FH are used for read and write storage. A total of 16 bytes from locations 20 to 2FH hex are set aside for bit-addressable read/write memory.Fig 6.3 Oscillator Connections Fig 6. Register banks in the 8051 . The 128 bytes of RAM inside the 8051 are assigned addresses 00 to7FH. 3. These 80 locations of RAM are widely used for the purpose of storing data and parameters nu 8051 programmers.

RAM locations 0. which register bank of R0-R7 do we have access to when the 8051 is powered up? The answer is register bank 0. Fig shows how the 32 bytes are allocated into 4 banks. RAM locations 18H to 1FH are set aside for the fourth bank of R0-R7. the bank 1 uses the same RAM space as the stack.2. R1. or allocate another area of RAM for the stack. than by their memory locations as shown in fig 2. R3. until memory location7. R1 is RAM location 1. and R7 when programming the 8051.3. 18 Default register bank If RAM locations 00-1F are set aside for the four register banks. R6. R2. These 32 bytes are divided into 4 banks of registers in which each bank has registers. The second bank of registers R0-R7 starts at RAM location 08 and goes to location 0FH. which belongs to R7 of bank0. we must either not use register bank1. The register banks are switched by using the D3 & D4 bits of register PSW. R4. As we can see from fig 1. The third bank of R0-R7 starts at memory location 10H and goes to location 17H. R5. It is much easier to refer to these RAM locations with names such as R0. . and R2 is location 2. and 7 are accessed with the names R0.6. 1.5. that is . RAM locations 0 to 7 are set aside for bank 0 of R0-R7 where R0 is RAM location 0. Finally. This is a major problem in programming the 8051. and so on.4. R0-R7. R1 and so on.A total of 32bytes of RAM are set aside for the register banks and stack.

FIG: RAM Allocation in the 8051 19 .

P . which is usually used in regulation of the program performing. If a number in accumulator is even then this bit will be automatically set (1). otherwise it will be cleared (0). This register contains: Carry bit. The Program Status Word (PSW) contains several status bits that reflect the current state of the CPU. The ALU automatically changes some of register’s bits.Fig: 8051 Register Banks and their RAM Addresses PSW Register (Program Status Word) This is one of the most important SFRs. and user-definable status flag. Auxiliary Carry. It is mainly used during data transmission and receiving via serial communication. parity bit. 20 . Overflow flag. two register bank select bits.Parity bit.

Their 16 bits are used for external memory addressing.. By writing zeroes and ones to these bits. Besides. so it is not supposed to be here. CY . DPTR Register (Data Pointer) These registers are not true ones because they do not physically exist. OV Overflow occurs when the result of arithmetical operation is greater than 255 (decimal).Flag 0. In that case. They consist of two separate registers: DPH (Data Pointer High) and (Data Pointer Low). a group of registers R0-R7 is stored in one of four banks in RAM.Register bank selects bits.Carry Flag is the (ninth) auxiliary bit used for all arithmetical operations and shift instructions. RS1 . this bit will be cleared (0). This bit is intended for the future versions of the microcontrollers. If there is no overflow. These two bits are used to select one of the four register banks in RAM. this bit will be set (1). so that it can not be stored in one register.Bit 1. They may be handled as a 16-bit register or as two independent 8-bit registers. 21 . RS0. the DPTR Register is usually used for storing data and intermediate results which have nothing to do with memory locations. This is a general-purpose bit available to the user. RS1 0 0 1 1 RS2 0 1 0 1 Space in RAM Bank0 00h-07h Bank1 08h-0Fh Bank2 10h-17h Bank3 18h-1Fh F0 .

Program counter: The important register in the 8051 is the PC (Program counter). This information could be data or an address. The program counter in the 8051 is 16bits wide. a total of 64k bytes of code. However. the program counter is incremented to point to the next instruction. 22 . not all members of the 8051 have the entire 64K bytes of on-chip ROM installed. The program counter points to the address of the next instruction to be executed.SP Register (Stack Pointer) The stack is a section of RAM used by the CPU to store information temporarily. As the CPU fetches the OPCODE from the program ROM. as we will see soon. The CPU needs this storage area since there are only a limited number of registers. This means that the 8051 can access program addresses 0000 to FFFFH.

Increment R1 (increment register R1) LJMP LAB5 .). If there is more than one operand in instruction.(if the number in the accumulator is not 0. called MNEMONIC refers to the operation an instruction performs (copying. LOOP . some have one. R3 .Types of instructions Depending on operation they perform. they are separated by comma. If they are not equal. all instructions are divided in several groups: • • • • • Arithmetic Instructions Branch Instructions Data Transfer Instructions Logical Instructions Logical Instructions with bits The first part of each instruction. Long Jump LAB5 (long jump to address specified as LAB5) JNZ LOOP. jump to address specified as LOOP) 23 .(return from sub-routine) JZ TEMP . Some instructions have no operand.(add R3 and accumulator) CJNE A.(compare accumulator with 20. called OPERAND is separated from mnemonic at least by one empty space and defines data being processed by instructions. jump to address specified as TEMP) ADD A. addition. two or three. For example: RET . Jump if Not Zero LOOP (if the number in the accumulator is not 0. #20. logical operation etc. Mnemonics commonly are shortened form of name of operation being executed. For example: INC R1. jump to address specified as LOOP) Another part of instruction.

pulse width measurement. These includes pulse counting. TIMER 0 REGISTERS The 16-bit register of Timer 0 is accessed as low byte and high byte.B. Let us first discuss about the timers’ registers and how to program the timers to generate time delays. They can be used either as timers to generate a time delay or as counters to count events happening outside the microcontroller. such as A. #4F”moves the value 4FH into TL0.they can be used either as timers or as event counters. frequency measurement.the low byte of Timer 0.These registers can also be read like any other register.for example. The 8051 has two timers/counters.These register can be accessed like any other register.R2.R1. etc.R0. Let discuss how these timers are used to generate time delays and we will also discuss how they are been used as event counters. baud rate generation.etc. having sufficient number of timer/counters may be a need in a certain design application. PROGRAMMING 8051 TIMER The 8051 has timers: Timer 0 and Timer1. the instruction ”MOV TL0. 24 . the low byte register is called TL0(Timer 0 low byte)and the high byte register is referred to as TH0(Timer 0 high byte).TIMERS On-chip timing/counting facility has proved the capabilities of the microcontroller for implementing the real time application.

Set. called TMOD. M0: M0 and M1 are used to select the timer mode.Mode 0 is a 13-bit timer. after describing the reset of the TMOD register. MODES: M1. We will soon describe the characteristics of these modes.these registers are accessible n the same way as the register of Timer 0. mode 1 is a 16-bit timer. The timer/counter is enabled only While the INTx pin is high and the TRx control pin is. GATE Gate control when set. referred to as TL1 (Timer 1 low byte) and TH1 (Timer 1 high byte). and mode 2 is an 8-bit timer.set for counter Operation (input TX input pin).in each case. 2. There are three modes: 0. When cleared. to set the various timer operation modes. 1. the timer is enabled. C/T Timer or counter selected cleared for timer operation (Input from internal system clock). We will concentrate on modes 1 and 2 since they are the ones used most widely. 25 . the lower 2 bits are used to set the timer mode and the upper 2 bits to specify the operation.TIMER 1 REGISTERS Timer 1 is also 16-bit register is split into two bytes. TMOD is an 8-bit register in which the lower 4 bits are set aside for Timer 0 and the upper 4 bits for Timer 1. TMOD (timer mode) REGISTER Both timers TIMER 0 and TIMER 1 use the same register.

The timer’s use as an event counter is discussed in the next section. it is used as a timer for time delay generation. 1 1 3 Split timer mode. If C/T=0. THx Holds a value that is to be reloaded into TLx each time it overflows.Bit pre-scaler. 0 1 1 16-bit timer mode 16-bit timer/counters THx with TLx are Cascaded. The clock source for the time delay is the crystal frequency of the 8051. there is no prescaler 1 0 2 8-bit auto reload 8-bit auto reload timer/counter. C/T (Clock / Timer) This bit in the TMOD register is used to decide whether the timer is used as a delay generator or an event counter. 27 .M1 M0 Mode bit 1 Mode bit 0 M1 0 M0 0 MODE 0 Operating Mode 13-bit timer mode 8-bit timer/counter THx with TLx as 5 . This section is concerned with this choice.

and when the data begins and ends. The synchronous method transfers a block of data at a time. a protocol. Serial communication of the 8051 is the topic of this chapter. while the asynchronous method transfers a single byte at a time. the distance cannot be great. often 8 or more lines (wire conductors) are used to transfer data to a device that is only a few feet away. If the data can go both ways at the same time. Duplex transmissions can be half or full duplex.Serial Communication Computers can transfer data in two ways: parallel and serial. one for transmission and one for reception. the serial method is used. there by making possible fast data transfer using only a few wires. in which the computer only sends data. To transfer to a device located many meters away. In data transmission if the data can be transmitted and received. the data is sent one bit at a time. how many bits constitute a character. Serial data communication uses two methods. in order to transfer and receive data simultaneously. Although in such cases a lot of data can be transferred in a short amount of time by using many wires in parallel. Examples of parallel data transfer are printers and hard disks. 28 . on how the data is packed. asynchronous and synchronous. it is a duplex transmission. it is full duplex. it is referred to as half duplex. in which the data is sent a byte or more at a time. it is difficult to make sense of the data unless the sender and receiver agree on a set of rules. Of course. Asynchronous serial communication and data framing The data coming in at the receiving end of the data line in a serial data transfer is all 0s and 1s. in contrast to parallel communication. If data is transmitted one way at a time. This is in contrast to simplex transmissions such as with printers. full duplex requires two wire conductors for the data lines. In parallel data transfers. depending on whether or not the data transfer can be simultaneous. In serial communication. each uses cables with many wire strips. The 8051 has serial communication capability built into it.

Start and stop bits Asynchronous serial data communication is widely used for character-oriented transmissions, while block-oriented data transfers use the synchronous method. In the asynchronous method, each character is placed between start and stop bits. This is called framing. In the data framing for asynchronous communications, the data, such as ASCII characters, are packed between a start bit and a stop bit. The start bit is always one bit, but the stop bit can be one or two bits. The start bit is always a 0 (low) and the stop bit (s) is 1 (high). Data transfer rate The rate of data transfer in serial data communication is stated in bps (bits per second). Another widely used terminology for bps is baud rate. However, the baud and bps rates are not necessarily equal. This is due to the fact that baud rate is the modem terminology and is defined as the number of signal changes per second. The data transfer rate of given computer system depends on communication ports incorporated into that system. For example, the early IBMPC/XT could transfer data at the rate of 100 to 9600 bps. In recent years, however, Pentium based PCS transfer data at rates as high as 56K bps. It must be noted that in asynchronous serial data communication, the baud rate is generally limited to 100,000bps. RS232 Standards To allow compatibility among data communication equipment made by various manufacturers, an interfacing standard called RS232 was set by the Electronics Industries Association (EIA) in 1960. In 1963 it was modified and called RS232A. RS232B AND RS232C were issued in 1965 and 1969, respectively. Today, RS232 is the most widely used serial I/O interfacing standard. This standard is used in PCs and numerous types of equipment. In RS232, a 1 is represented by -3 to -25V, while a 0 bit is +3 to +25V, making -3 to +3 undefined. For this reason, to connect any RS232 to a microcontroller system we must use voltage converters such as MAX232 to convert the TTL logic levels to the RS232 voltage levels, and vice versa. MAX232 IC chips are commonly referred to as line drivers.

29

RS232 pins
Pin Functions: Pin 1 2 3 4 5 6 7 8 9 Description Data carrier detect (DCD) Received data (RXD) Transmitted data (TXD) Data terminal ready(DTR) Signal ground (GND) Data set ready (DSR) Request to send (RTS) Clear to send (CTS) Ring indicator (RI)

Note: DCD, DSR, RTS and CTS are active low pins. The method used by RS-232 for communication allows for a simple connection of three lines: Tx, Rx, and Ground. The three essential signals for 2-way RS-232 Communications are these: TXD: carries data from DTE to the DCE. RXD: carries data from DCE to the DTE SG: signal ground

30 8051 connection to RS232

The RS232 standard is not TTL compatible; therefore, it requires a line driver such as the MAX232 chip to convert RS232 voltage levels to TTL levels, and vice versa. The interfacing of 8051 with RS232 connectors via the MAX232 chip is the main topic.

The 8051 has two pins that are used specifically for transferring and receiving data serially. These two pins are called TXD and RXD and a part of the port 3 group (P3.0 and P3.1). Pin 11 of the 8051 is assigned to TXD and pin 10 is designated as RXD. These pins are TTL compatible; therefore, they require a line driver to make them RS232 compatible. One such line driver is the MAX232 chip.

MAX232 converts from RS232 voltage levels to TTL voltage levels, and vice versa. One advantage of the MAX232 chip is that it uses a +5V power source which, is the same as the source voltage for the 8051. In the other words, with a single +5V power supply we can power both the 8051 and MAX232, with no need for the power supplies that are common in many older systems. The MAX232 has two sets of line drivers for transferring and receiving data. The line drivers used for TXD are called T1 and T2, while the line drivers for RXD are designated as R1 and R2. In many applications only one of each is used.

CONNECTING μC to PC using MAX 232 31

INTERRUPTS

TX D RXD

of course). So. INTERRUPTS Vs POLLING: The advantage of interrupts is that the microcontroller can serve many devices (not all the same time. There are two ways to do that: INTERRUPTS or POLLING. The program associated with the interrupts is called the interrupt service routine (ISR). whenever any device needs its service. Although polling can monitor the status of several devices and serve each of them as certain condition are met.or interrupt handler. interrupts are used. each device can get the attention of the microcontroller based on the priority assigned to it. in order to avoid tying down the microcontroller. The most important reason that the interrupt method is preferable is that the polling method wastes much of the microcontroller’s time by polling devices that do not need service.A single microcontroller can serve several devices. the device notifies the microcontroller by sending it an interrupts signal. 32 INTERRUPT SERVICE ROUTINE . Upon receiving an interrupt signal. in the interrupt method the microcontroller can also ignore (mask) a device request for service. The polling method cannot assign priority since it checks all devices in round-robin fashion. More importantly. INTERRUPTS: In the interrupts method. POLLING: In polling the microcontroller continuously monitors the status of a given device. it moves on to monitor the next device until each one is serviced. This is again not possible with the polling method.After that. when the status condition is met. the microcontroller interrupts whatever it is doing and serves the device. it performs the service .

2) and 13(P3. The group of memory location set aside to hold the addresses of ISR and is called the Interrupt Vector Table. 3. only five interrupts are available to the user in the 8051.respectively. For every interrupt.Memory location 000BH and 001BH in the interrupt vector table belong to Timer 0 and Timer 1. the 8051 jumps to address location 0000. or interrupt handler. there must be an interrupt service routine (ISR). 1. there is a fixed location in memory that holds the address of its ISR.this is the power-up reset. Serial communication has a single interrupt that belongs to both receive and transmit. Pin number 12(P3. 33 Interrupt Enable Register . When the reset pin is activated.the six interrupts in the 8051 are allocated as above.For every interrupt. When an interrupt is invoked.These external interrupts are also referred to as EX1 and EX2. respectively. respectively. Reset.Memory location 0003H and 0013H in the interrupt vector table are assigned to INT0 and INT1. The interrupt vector table location 0023H belongs to this interrupt. 2.3) in port 3 are for the external hardware interrupts INT0 and INT1. 4. Two interrupts are set aside for the timers: one for Timer 0 and one for Timer 1. Shown below: Six Interrupts in the 8051: In reality. but many manufacturers’ data sheets state that there are six interrupts since they include reset . the microcontroller runs the interrupts service routine. Two interrupts are set aside for hardware external harder interrupts.

each interrupt source is individually enabled disabled By setting or clearing its enable bit.2 IE.5 Not implemented. If EA=0.1 Enables or disables Timers 1 overflow interrupt Enables or disables external interrupt 1 Enables or disables Timer 0 overflow interrupt. reserved for future use. EX0 IE.7 disables all interrupts. -ET2 IE.D7 EA ET0 D6 D5 D4 ET2 D3 ES D2 D1 ET1 D0 EX1 -EX0 EA IE. no interrupts is acknowledged.4 Enables or disables the serial port interrupts.2 GSM Modems .3 IE. 34 4.6 IE. ET1 EX1 ET0 IE.0 Enables or disables external interrupt.* Enables or disables Timer 2 overflow or capture interrupt (8052 Only) ES IE. If EA=1.

ready to use. The Smart Modem can be customized to various applications by using the standard AT commands. Data. rugged and versatile modem that can be embedded or plugged into any application. provided that your computer hardware has the available communications port resources. Insert a GSM SIM card into this modem. or connect your GSM mobile phone to the computer.A GSM modem can be an external modem device. When you install your GSM modem. and connect the modem to an available serial port on your computer. A dedicated GSM modem (external or PC Card) is usually preferable to a GSM mobile phone. The modem is fully type-approved and can directly be integrated into your projects with any or all the features of Voice. Fig:16 GSM smart modem SMART MODEM (GSM/GPRS) INTRODUCTION: Analogic’s GSM Smart Modem is a multi-functional. Fax. be sure to install the appropriate Windows modem driver from the device manufacturer. This is because of some compatibility issues that can exist with mobile phones. the Now SMS/MMS Gateway will communicate with the device via this driver. 35 Smart Modem kit contains the following items: . such as the Wavecom FASTRACK Modem. and Internet etc. To simplify configuration. An additional benefit of utilizing this driver is that you can use Windows diagnostics to ensure that the modem is communicating properly with the computer. SMS. The Now SMS/MMS gateway can simultaneously support multiple modems.

Inserting/ Removing the SIM Card: To insert or Remove the SIM Card. it is necessary to press the SIM holder ejector button with Sharp edged object like a pen or a needle. Fig 17: Block diagram of modem with key connections Installing the modem: To install the modem. An extractible holder is used to insert the SIM card (Micro-SIM type). Status LED indicates the operating mode. 3 dBi antenna with cable (optional: other types) Data cable (RS232) User Manual PRODUCT DESCRIPTION: The connectors integrated to the body. the SIM holder comes out a little. then pulls it out and insert or remove the SIM Card 36 .Analogic’s GSM/GPRS Smart Modem SMPS based power supply adapter. With this. guarantee the reliable output and input connections. plug the device on to the supplied SMPS Adapter.

The Frequency of the antenna may be GSM 900/1800 MHz. The antenna may be (0 dbi.Fig 19: Inserting/Removing the sim card into the modem Make sure that the ejector is pushed out completely before accessing the SIM Card holder do not remove the SIM card holder by force or tamper it (it may permanently damage). Connectors: Connector SMA 15 pin or 9 pin D-SUB USB (optional) Function RF Antenna connector RS232 link Audio link (only for 15 DSUB) Reset (only for 15 D-SUB) USB communication port (optional) 2 pin Phoenix tm SIM Connector RJ11 (For 9 D-SUB and USB only) Power Supply Connector SIM Card Connection Audio link Simple hand set connection (4 wire) 2 wire desktop phone connection 37 . Place the SIM Card Properly as per the direction of the installation. 3 dbi or short length L-type antenna) as per the field conditions and signal conditions. It is very important that the SIM is placed in the right direction for its proper working condition Connecting External Antenna: Connect GSM Smart Modem to the external antenna with cable end with SMA male.

teleservice provided by GSM. such as Call Forward on Busy or Barring of Outgoing International Calls. Also supported are Group 3 facsimile service. and most important.Description of the interfaces: The modem comprises several interfaces: LED Function including operating Status External antenna (via SMA) Serial and control link Power Supply (Via 2 pin Phoenix tm contact) SIM card holder Services provided by GSM GSM was designed having interoperability with ISDN in mind. with user bit rates up to 9600 bps. ISDN. . call waiting. A service unique to GSM. supplementary services include variations of call forwarding and call barring. Packet Switched and Circuit Switched Public Data Networks. Specially equipped GSM terminals can connect with PSTN. advice of charge. are broadcast to users in particular cells. It is similar to paging services. including multiparty calls. videotext. the Short Message Service. allows users to send and receive point-to-point alphanumeric messages up to a few tens of bytes. and teletex. Other GSM services include a cell broadcast service. and calling line identification presentation will be offered in the Phase 2 specifications. through several possible methods. In addition. In the Phase I specifications. allowing bi-directional messages. various data services are supported. using synchronous or asynchronous transmission. and the services provided by GSM are a subset of the standard ISDN services. Many more supplementary services. where messages such as traffic reports. but much more comprehensive. store-and-forward delivery. Supplementary services enhance the set of basic teleservices. Speech is the most basic. and acknowledgement of successful delivery.

38 AT commands features: Line settings: A serial link handler is set with the following default values Auto baud. such as “AT+CPIN?” or (unsolicited) incoming events. If command syntax is correct but with some incorrect parameters. Architecture of the GSM network A GSM network is composed of several functional entities. the product does not return the OK string as a response. The MSC also handles the mobility management operations. whose functions and interfaces are specified. The GSM network can be divided into three broad parts. the main part of which is the Mobile services Switching Center (MSC). Command line Commands always start with AT (which means attention) and finish with a <CR> character. and between mobile and fixed network users. an ERROR string is returned. Information responses and result codes Responses start and end with <CR><LF>. Figure 1 shows the layout of a generic GSM network. In some cases. flow control. 8 bits data. . If the command line has been performed successfully. 1 stop bit. no parity. performs the switching of calls between the mobile users. the +CME ERROR: <Err> or +CMS ERROR: <SmsErr> strings are returned with different error codes. which oversees the proper operation and setup of the network. Subscriber carries the Mobile Station. The Network Subsystem. an OK string is returned. Not shown is the Operations intendance Center. If command syntax is incorrect. The Base Station Subsystem controls the radio link with the Mobile Station.

39 Fig 20: General architecture of a GSM network 4. in alarms. FIG: Types of Buzzers . for example. audio equipment telephones. transmitters. speakers. beep sounds. And they are applied widely. etc. OA equipment.3 BUZZER The "Piezoelectric sound components" introduced herein operate on an innovative principle utilizing natural oscillation of piezoelectric ceramics. telephone ringers. etc. Today. These buzzers are offered in lightweight compact sizes from the smallest diameter of 12mm to large piezoelectric sounders. piezoelectric sound components are used in many ways such as home appliances. receivers.

4 LIGHT EMITING DIODES It is a semiconductor diode having radioactive recombination. For example a low voltage battery circuit can use a relay to switch a 230V AC mains circuit. Current flowing through the coil of the relay creates a magnetic field which attracts a lever and changes the switch contacts. The coil current can be on or off so relays have two switch positions and they are double throw (changeover) switches.5 RELAYS Relay is an electrically operated switch. It requires a definite amount of energy to generate an electron-hole pair. the link is magnetic and mechanical. There is no electrical connection inside the relay between the two circuits. Relays allow one circuit to switch a second circuit which can be completely separate from the first. 40 4.4. .

COM is connected to this when the relay coil is on. NC = Normally Closed. Relays can switch high voltages. transistors can only switch DC. Connect to COM and NC if you want the switched circuit to be on when the relay coil is off. Relay coils produce brief high voltage 'spikes' when they are switched off and this can destroy transistors and ICs in the circuit.The coil of a relay passes a relatively large current. Most ICs (chips) cannot provide this current and a transistor is usually used to amplify the small IC current to the larger value required for the relay coil. Relays can switch many contacts at once. COM is connected to this when the relay coil is off. it is the moving part of the switch. NC and NO: • • • • COM = Common. The coil will be obvious and it may be connected either way round. 41 Most relays are designed for PCB mounting but you can solder wires directly to the pins providing you take care to avoid melting the plastic case of the relay. The maximum output current for the popular 555 timer IC is 200mA so these devices can supply relay coils directly without amplification. Relays are a better choice for switching large currents (> 5A). transistors cannot. NO = Normally Open. The relay's switch connections are usually labelled COM. always connect to this. typically 30mA for a 12V relay. . Connect to COM and NO if you want the switched circuit to be on when the relay coil is on. • Advantages of relays: • • • • Relays can switch AC and DC. but it can be as much as 100mA for relays designed to operate from lower voltages. The supplier's catalogue should show you the relay's connections.

which makes the liquid crystal molecules to maintain a defined orientation angle. in a particular direction. 42 • Relays require more current than many chips can provide. When the LCD is in the off state. 4. which would result in activating/ highlighting the desired characters. they are compatible with low power electronic circuits. This polarizer’s would rotate the light rays passing through them to a definite angle. The inner surface of the glass plates are coated with transparent electrodes which define the character. . The LCD’s are lightweight with only a few millimeters thickness. symbols or patterns to be displayed polymeric layers are present in between the electrodes and the liquid crystal. the liquid crystal molecules would be aligned in a specific direction. light rays are rotated by the two polarizer’s and the liquid crystal. such that the light rays come out of the LCD without any orientation. so a low power transistor may be needed to switch the current for the relay's coil. When sufficient voltage is applied to the electrodes. with the liquid crystal material sand witched in between them.6 Liquid crystal display An LCD consists of two glass panels. and hence the LCD appears transparent. The light rays passing through the LCD would be rotated by the polarizer’s. Since the LCD’s consume less power. and can be powered for long durations. One each polarizer’s are pasted outside the two glass panels. Relays cannot switch rapidly (except reed relays).Disadvantages of relays: • • Relays are bulkier than transistors for switching small currents. transistors can switch many times per second.

43 TABLE 1:Pin description for LCD: Pin 1 2 symbol Vss Vcc I/O --- Description Ground +5V supply power 3 VEE -- Power supply to control contrast 4 RS I RS=0 register to select command RS=1 to select data register 5 R/W I R/W=0 for write R/W=1 for read 6 7 E DB0 I/O I/O Enable The bus 8 DB1 I/O The bus 9 DB2 I/O The bus 10 DB3 I/O The bus 8-bit data 8-bit data 8-bit data 8-bit data .

cursor off Display on. cursor on Display on.11 DB4 I/O The bus 8-bit data 12 DB5 I/O The bus 8-bit data 13 DB6 I/O The bus 8-bit data 14 DB7 I/O The bus 8-bit data 44 TABLE 2: LCD Command Codes Code (hex) 1 2 4 6 5 7 8 A C E F 10 14 18 1C 80 C0 38 Command to LCD Instruction Register Clear display screen Return home Decrement cursor Increment cursor Shift display right Shift display left Display off. cursor blinking Shift cursor position to left Shift cursor position to right Shift the entire display to the left Shift the entire display to the right Force cursor to beginning of 1st line Force cursor to beginning of 2nd line 2 lines and 5x7 matrix . cursor off Display off. cursor on Display on.

Uses: The LCDs used exclusively in watches. These have resulted in the LCDs being extensively used in telecommunications and entertainment electronics. The declining prices of LCDs. more information displaying capability and a wider temperature range. The LED must be refreshed by the CPU to keep displaying the data.45 The LCD’s don’t generate light and so light is needed to read the display. LCD operation In recent years the LCD is finding widespread use replacing LEDs (seven-segment LEDs or other multi segment LEDs). 4. there by relieving the CPU of the task of refreshing the LCD. having a limited amount of numeric data.This is due to the following reasons: 1. 2. 3. characters and graphics. Ease of programming for characters and graphics. This section describes the operation modes of LCD’s then describe how to program and interface an LCD to 8051 using Assembly and C. By using backlighting. which are limited to numbers and a few characters. This is in Contract to LEDs. reading is possible in the dark. In the contrast. . calculators and measuring instruments are the simple seven-segment displays. Incorporation of a refreshing controller into the LCD. The LCD’s have long life and a wide operating temperature range. The recent advances in technology have resulted in better legibility. The ability to display numbers.

A power supply can by broken down into a series of blocks.c mains fluctuations or load variations is known as “Regulated D. A d.C Power Supply” . make RS=1. 4.Then sends a high –to-low pulse to the E pin to enable the internal latch of the LCD. For data. make pin RS=0. each of which performs a particular function.c power supply which maintains the output voltage constant irrespective of a.46 LCD INTERFACING Sending commands and data to LCDs with a time delay: Fig 21: Interfacing of LCD to a micro controller To send any command from table 2 to the LCD.7 Power supply The power supplies are designed to convert high voltage AC mains electricity to a suitable low voltage supply for electronic circuits and other devices.

A step-down transformer has a large number of turns on its primary (input) coil which is connected to the high voltage mains supply. and a small number of turns on its secondary (output) coil to give a low output voltage. Transformers work only with AC and this is one of the reasons why mains electricity is AC. The ratio of the number of turns on each coil. Transformers convert AC electricity from one voltage to another with little loss of power.8 Transformer: A transformer is an electrical device which is used to convert electrical power from one Electrical circuit to another without change in frequency. The two lines in the middle of the circuit symbol represent the core. Transformers waste very little power so the power out is (almost) equal to the power in. Step-up transformers increase in output voltage. called the turn’s ratio. The input coil is called the primary and the output coil is called the secondary. . Note that as voltage is stepped down current is stepped up. determines the ratio of the voltages. Most power supplies use a step-down transformer to reduce the dangerously high mains voltage to a safer low voltage.47 For example a 5V regulated power supply system as shown below: 4. step-down transformers decrease in output voltage. There is no electrical connection between the two coils. instead they are linked by an alternating magnetic field created in the soft-iron core of the transformer.

mainly for use in dual supplies. Many of the fixed voltage regulator ICs has 3 leads and look like power transistors. such as the 7805 +5V 1A regulator shown on the right. Negative voltage regulators are available. Fig 6.48 An Electrical Transformer Regulator: Voltage regulator ICs is available with fixed (typically 5. connect the negative lead to the Common pin and then when you turn on the power. The maximum current they can pass also rates them. 12 and 15V) or variable output voltages. Most regulators include some automatic protection from excessive current ('overload protection') and overheating ('thermal protection').6 A Three Terminal Voltage Regulator .1. The LM7805 is simple to use. you get a 5 volt supply from the output pin. You simply connect the positive lead of your unregulated DC power supply (anything from 9VDC to 24VDC) to the Input pin.

the LM78XX usually results in an effective output impedance improvement of two orders of magnitude. TO-220 & TO263packages.5A • Output Voltage Tolerance of 5% • Internal thermal overload protection • Internal Short-Circuit Limited • No External Component • Direct Replacement for LM78XX .49 78XX: The Bay Linear LM78XX is integrated linear positive regulator with three terminals. The LM78XX offer several fixed output voltages making them useful in wide range of applications. The LM78XX is available in the TO-252. lower quiescent current. Features: • Output Current of 1. When used as a zener diode/resistor combination replacement.

link your program together. Breakpoints may be set on either assembly instructions or lines of C code. all the way up to the entire application. run either the Library Manager or Linker and finally running the Object-HEX Converter to convert the Linker output file to an Intel Hex File. and debug your target program. showing the state of the peripheral. The contents of all the memory areas may be viewed along with ability to find specific variables. µVision2 for Windows™ Integrated Development Environment: combines Project Management. create HEX files. Simulator/Debugger: The simulator/ debugger in KEIL can perform a very detailed simulation of a micro controller along with external signals. the choice is clear.1 ABOUT KEIL SOFTWARE: It is possible to create the source files in a text editor such as Notepad. . specifying another list of controls. run the Assembler on each Assembler source file. It is possible to view the precise execution time of a single assembly instruction. Once that has been completed the Hex File can be downloaded to the target hardware and debugged. or a single line of C code. KEIL Greatly simplifies the process of creating and testing an embedded application. This enables quick trouble shooting of misconfigured peripherals. link and covert using options set with an easy to use user interface and finally simulate or perform debugging on the hardware with access to C variables and memory. Unless you have to use the tolls on the command line. and execution may be stepped through one instruction or C line at a time. The Keil Software 8051 development tools listed below are the programs you use to compile your C code. automatically compile. Source Code Editing. simply by entering the crystal frequency. specifying a list of controls.  C51 ANSI Optimizing C Cross Compiler: creates relocatable object modules from your C source code. Alternatively KEIL can be used to create source files.50 CHAPTER 5 SOFTWARE 5. assemble your assembler source files. and Program Debugging in one powerful environment. run the Compiler on each C source file. In addition the registers may be viewed allowing a detailed view of what the microcontroller is doing at any point in time. A window can be opened for each peripheral on the device.

You may enter G. Groups. and links the files in your project Creating Your Own Application in µVision2 To create a new project in µVision2. 2. and add the source files to the project. µVision3 is fully compatible to µVision2 and can be used in parallel with µVision2. and Syntax Coloring with brace high lighting Configuration Wizard for dialog based startup and debugger setup. Default memory model settings are optimal for most applications. 166\EXAMPLES\HELLO\HELLO. 5.Rebuild all target files or Build target. 4. Select Debug . you must: 1. Select Project . 2. Quick Function Navigation. BL51 Linker/Locator: combines relocatable object modules created by the compiler and assembler into the final absolute object module. Building an Application in µVision2 To build (compile. 51  LIB51 Library Manager: combines object modules into a library. Select Project . Select Project . Go. Debug your program using standard options like Step. 7. you must: 1. µVision2 compiles. and link) an application in µVision2. main in the Output Window to execute to the main C function.Select Device and select an 8051. assembles. Select Project . Select Project . 251. Select Project . . 3. and Files.Targets. Add/Files. 3. 6. 2.  OH51 Object-HEX Converter: creates Intel HEX files from absolute object modules.New Project. You typically only need to configure the memory map of your target hardware. which may be used by the linker.Start/Stop Debug Session. or C16x/ST10 device from the Device Database™. Note when you select the target device from the Device Database™ all special options are set automatically.(forexample. Create source files to add to the project.UV2).Options and set the tool options. Select a directory and enter the name of the project file. Open the Serial Window using the Serial #1 button on the toolbar. What's New in µVision3? µVision3 adds many new features to the Editor like Text Templates. Select Project . and so on. Debugging an Application in µVision2 To debug an application created using µVision2. you must: 1. assemble. Break. Use the Step toolbar buttons to single-step through your program.Rebuild all target files or Build target. select Source Group1.

Project1. Once you have successfully generated your application you can start debugging. When you build an application with Syntax errors. You can see these names in the Project Window – Files. We are using for our examples the Philips 80C51RD+ CPU. the tool settings under Options – Target are all you need to start a new Application. µVision2 will display errors and warning messages in the Output Window – Build page. i. You may translate all source files and line the application with a Click on the Build Target toolbar icon. A double click on a message line opens the source file On the correct location in a µVision2 editor window. To create a new project file select from the µVision2 menu Project – New Project…. . This selection sets necessary tool Options for the 80C51RD+ device and simplifies in this way the tool Configuration Building Projects and Creating a HEX Files Typical. This opens a standard Windows dialog that asks you For the new project file name. Now use from the menu Project – Select Device for Target and select a CPU For your project. You can simply use The icon Create New Folder in this dialog to get a new empty folder.UV2 which contains A default target and file group name. We suggest that you use a separate folder for each project. µVision2 creates a new project file with the name PROJECT1. The Select Device dialog box shows the µVision2 device Database. Then Select this folder and enter the file name for the new project.52 Starting µVision2 and creating a Project µVision2 is a standard Windows application and started by clicking on the program icon.e. Just select the micro controller you use.

The next executable statement is marked with a yellow arrow. You may select and display the on-chip peripheral components using the Debug menu. CPU Simulation: µVision2 simulates up to 16 Mbytes of memory from which areas can be Mapped for read. Refer to page 58 for more Information about selecting a device. . µVision2 opens an Editor window with the source text or shows CPU instructions in the disassembly window. You may start your PROM programming utility after the make process when you specify the program under the option Run User Program #1. During debugging. The µVision2 simulator traps And reports illegal memory accesses.53 After you have tested your application. or code execution access. write. the simulator also provides support for the Integrated peripherals of the various 8051 derivatives. Start Debugging: You start the debug mode of µVision2 with the Debug – Start/Stop Debug Session command. µVision2 creates HEX files with each build process when Create HEX files under Options for Target – Output is enabled. Depending on the Options for Target – Debug Configuration. it is required to create an Intel HEX file to download the software into an EPROM programmer or simulator. If the program execution stops. µVision2 will load the application program and run the startup Code µVision2 saves the editor screen layout and restores the screen layout of the last debug session. In addition to memory mapping. most editor features are still available. You can also change the aspects of each peripheral using the controls in the dialog boxes. Database selection: You have made when you create your project target. The on-chip peripherals Of the CPU you have selected are configured from the Device.

microprocessor or DSP chips) only accept instructions in ‘machine code’ (‘object codes’). set Debug – Enable/Disable Trace Recording. To enable the trace history. rather than that of the programmer. • All software. Interpretation of the code by the programmer is difficult and error prone. Java or Ada must ultimately be translated into machine code in order to be executed by the computer. C++. C. the next key decision that needs to be made is the choice of programming language. whether in assembly. by definition. .2 Embedded C: What is an embedded system? An embedded system is an application that contains at least one programmable computer and which is used by individuals who are. If you select the Disassembly Window as the active window all program step commands work on CPU instruction level rather than program source lines. A trace history of previously executed instructions may be displayed with Debug – View Trace Records. In order to identify a suitable language for embedded systems. That allows you to correct mistakes or to make temporary changes to the target program you are debugging.54 Disassembly Window The Disassembly window shows your target program as mixed source and assembly program or just assembly code. Which programming language should you use? Having decided to use an 8051 processor as the basis of your embedded system. Machine code is. You can select a text line and set or modify code breakpoints using toolbar buttons or the context menu commands. in the main. 5. we might begin by making the following observations: • Computers (such as microcontroller. unaware that the system is computer-based. in the language of the computer. You may use the dialog Debug – Inline Assembly… to modify the CPU instructions.

.. with ‘high-level’ features (such as support for functions and modules).....................• Embedded processors – like the 8051 – have limited processor power and very limited memory available: the language used must be efficient... 55 Summary of C language Features: It is ‘mid-level’. Good.........h> Void main (void) { While (1)............. • • • • It is very efficient........ well-proven compilers are available for every embedded processor (8-bit to 32bit or more). Even desktop developers who have used only Java or C++ can soon understand C syntax.....#include <reg51..... { Body of the loop } // Infinite loop // SFR declarations . and ‘low-level’ features (such as good access to hardware via pointers).//Basic blank C program that does nothing // Includes //. Basic C program structure: //..... It is popular and well understood........

Save the Project by typing suitable project name with no extension in u r own folder sited in either C:\ or D:\ . Click on the Project menu from the title bar Then Click on New Project 5. Click on the Keil u Vision Icon on Desktop The following fig will appear 3.} // match the braces 56 6. 2. 4. SOURCE CODE 1.

i. 8. Then Click on Save button above. Atmel…… Click on the + Symbol beside of Atmel 9.57 6.e. Select AT89C51 as shown below . Select the component for u r project. 7.

11.58 10. Then Click on “OK” The Following fig will appear 12. 13. you would get another option “Source group 1” as shown in next page. 14. . Then Click either YES or NO………mostly “NO” Now your project is ready to USE Now double click on the Target1.

. Click on the file option from menu bar and select “new” 16. and just maximize it by double clicking on its blue boarder.59 15. The next screen will be as shown in next page.

18. asm” and for “C” based program save it with extension “ .C” 19. Now right click on Source group 1 and click on “Add files to Group Source” . Now start writing program in either in “C” or “ASM” For a program written in Assembly.60 17. then save it with extension “.

Any error will appear if so happen. 61 21.20. Now you will get another window. Click only one time on option “ADD” Now Press function key F7 to compile. 23. . Now select as per your file extension given while saving the file 22. on which by default “C” files will appear.

Then Click “OK” Now Click on the Peripherals from menu bar. 25. If the file contains no error.24. 27. and check your required port as shown in fig below . then press Control+F5 simultaneously. The new window is as follows 62 26.

63 29.28. You are running your program successfully . Now keep Pressing function key “F11” slowly and observe. Drag the port a side and click in the program file. 30.

64 CHAPTER 7 7. Secondly. . Conclusion The project “global alert and control system for ups battery management for corporate automation (gsm)” has been successfully designed and tested. Presence of every module has been reasoned out and placed carefully thus contributing to the best working of the unit. using highly advanced IC’s and with the help of growing technology the project has been successfully implemented. It has been developed by integrating features of all the hardware components used.

1 FUTURE ASPECTS 65 ABBREVATIONS .7.

Symbol ACC Name Accumulator Symbol TL1 Name Timer/counter 1 low byte B B register TH2 Timer/counter 2 high byte PSW Program word status TL2 Timer/counter 2 low byte SP DPTR DPL Stack pointer Data pointer 2 bytes Low byte SCON SBUF MAX Serial control Serial data buffer MAXIM manufacturer ) (IC DPH High byte TTL Transistor Transistor Logic to P0 Port0 ATM Automatic Machine Teller P1 Port1 RS 232 Recommended Standard P2 P3 IP Port2 Port3 Interrupt control priority AC DC LCD Alternating Current Direct Current Liquid Display Crystal IE Interrupt control enable PC Personal Computer TMOD Timer/counter mode control RPS Regulated Supply Power TCON Timer/counter control RMS Root Mean Square T2CON Timer/counter control 2 EEPROM Electrically Erasable Programmable ROM ROM Read Only Memory T2MOD Timer/counter mode2 control TH0 Timer/counter 0high byte RAM Random Memory Access TL0 Timer/counter 0 low byte BIOS Basic Input Output System SRAM Static RAM TH1 Timer/counter 1 high byte TL1 Timer/counter low byte 1 EPROM Erasable Programmable ROM DRAM ISR Dynamic Random Access Memory Interrupt Service Routine .

Ram Micro processor Architecture. Programming & Applications -Ramesh S. Gaonkar .Bibliography The 8051 Micro controller and Embedded Systems -Muhammad Ali Mazidi Janice Gillispie Mazidi The 8051 Micro controller Architecture.Ayala Fundamentals of Micro processors and Micro computers -B. Programming & Applications -Kenneth J.

com www. Prasad Wireless Communications .com www. Lee References on the Web: www.V.Electronic Components -D.geocities.Y.atmel.William C.com www.Theodore S.national.microsoftsearch. Rappaport Mobile Tele Communications .com .

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->