This action might not be possible to undo. Are you sure you want to continue?
S.No. 1. 2. 3. 5. 6. 7. 8. 9. Contents Abbreviations Abstract Introduction Block diagram Block diagram Description Schematic Schematic Description (pin to pin connectivity) Hardware components a. Microcontroller (max 50 pages) b. MAX 232 c. Power supply d. ADC e. Current sensor f. LCD g. Relay Page
Software components a. About Keil b. Embedded ‘C’ Source Code Conclusion or Synopsis Bibliography
12. 12. 13.
ACC B PSW SP DPTR DPL DPH P0 P1 P2 P3 IP IE TMOD TCON T2CON T2MOD TH0 TL0 TH1 TL1 TH2 TL2 SCON SBUF PCON
Accumulator B register Program status word Stack pointer Data pointer 2 bytes Low byte High byte Port0 Port1 Port2 Port3 Interrupt priority control Interrupt enable control Timer/counter mode control Timer/counter control Timer/counter 2 control Timer/counter mode2 control Timer/counter 0high byte Timer/counter 0 low byte Timer/counter 1 high byte Timer/counter 1 low byte Timer/counter 2 high byte Timer/counter 2 low byte Serial control Serial data buffer Power control
1 2 3 4 5 6 7 8 9 10
Figure Page No. Components of Typical Linear Power Supply An Electrical Transformer Bridge Rectifier Bridge Rectifier Positive Cycle Bridge Rectifier Negative Cycle Three terminal voltage Regulator Functional Diagram of Microcontroller Pin Diagram of Microcontroller Oscillator connections External clock drive connections 3
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 A register B register RAM RAM Allocation Register Banks PSW DPTR SP PORT 0 TL0 and TH0 DB9 Connecting Microcontroller to PC Types of SIM Structures Smart Card Pin-out Smart Card Reader LCD MAX 232 Pin-out MAX 232 Operating circuit MAX 232 Logic output Relay Project New Project Select Target device Select device for Target Copy 8051 startup code Source group 1 New file Opened new file File Save Add files to the source group Adding files to the source group 4 .
INTRODUCTION 1. for reason such as safety and usability. Some also have real time performance constraints that must be met. rather than be a general-purpose computer for multiple tasks. others may have low 5 .42 43 44 45 46 47 Compilation After Compilation Build Selecting the Ports to be visualized Start Debugging CHAPTER 1 1.1 EMBEDDED SYSTEMS: Embedded systems are designed to do some specific task.
and is stored in read-only memory or flash convector chips rather than a disk drive. allowing the system hardware to be simplified to reduce costs.very often it is physically built-in to the device it is controlling. Here the load is directly connected to the secondary of the main transformer as well as backup transformer. and short-distance wireless communication used for \personal wireless networks. The communication mediums were twisted pair." Technology advancements are providing smaller and more cost effective devices for integrating computational processing. These embedded communications devices will be integrated into applications ranging from homeland security to industry automation and monitoring. there are few adorable environments available for development and classroom use. low-power. and little memory. here two transformers are connected through the relay. one area of commercial interest has been low-cost. one is main transformer (TF1) and the next is backup transformer (TF2). It often runs with limited computer hardware resources: small or no keyboard. INTRODUCTION TO THE PROJECT: In this project “AUTOMATIC LOAD SHARING OF TRANSFORMERS” we are using two transformers. Wireless communication has become an important feature for commercial products and a popular research topic within the last ten years. creating a revolutionary way of disseminating and processing information. 6 . and a host of other functionalities. Lately. and the need for employees in these technological areas. Engineers who have knowledge of embedded systems and wireless communications will be in high demand. and generally wireless radio. With new technologies and devices come new business activities. There are now more mobile phone subscriptions than wired-line subscriptions. so students often do not learn about these technologies during hands-on lab exercises.or no performance requirements. An embedded system is not always a separate block . wireless communication. screen. optical fiber. The software written for embedded systems is often called firmware. They will also enable custom tailored engineering solutions. Unfortunately. infrared.
These two transformers are connected with the relay which is controlled by the embedded controller. The present system is designed around two transformers.The transfers switch senses when utility power is interrupted. the transfer switch disconnects the load from the utility and connects it to the Transformer TF2. Initially TF1 is connected to the load. One transformer (TF1) is used as the main supply and the other transformer (TF2) is used in the place of the generator (for demo purpose). The transfer switch continues to monitor utility power. All the status of the transformers will be displayed on LCD. switches the load from the Transformer TF2 back to the Main transformer TF1. then it is identified by the controller and it immediately switches ON to the TF2 through the relay. Once the Transformer TF2 is disconnected. and starts up the transformer TF2 which acts as a backup transformer. BLOCK DIAGRAM: POWER SUPPLY LCD DISPLAY Main Transformer (TF1) 7 LOAD AT 89C51 MICRO CONTROLLER . If the utility power remains absent. and when it is restored. the loads run with this power. The objective of the present project is to satisfy the above needs with an extent. restoring electricity to the load. it goes through a cool-down routine and is automatically shut down. Due to any reason this power is interrupted. The loads are connected to the main line (TF1) and as well as to the TF2. When it finds the power on it again switches the loads connection to the main line. The controller continuously monitors the TF1 (main line).
8 . It basically consists of a Transformer to step down the 230V ac to 18V ac followed by diodes. A positive voltage regulator is used to regulate the obtained dc voltage. Here diodes are used to rectify the ac to dc.RELAY ADC Sharing transformer (TF2) CURRENT SENSOR BLOCK DIAGRAM EXPLANATION: The above block diagram gives the overview of the project in the pictorial form with the help of the block diagram we will create pre model of the project and the analyze the function of the project the explanation of the project with block diagram over view is given as follows. After rectification the obtained rippled dc is filtered using a capacitor Filter. Microcontroller Section: This section forms the control unit of the whole project. This section basically consists of a Microcontroller with its associated circuitry like Crystal with capacitors. Power Supply Section: This section is meant for supplying Power to all the sections mentioned above.
ADC: Analog to digital (A/D. some power supplies (notably for PCs) are deliberately designed to operate directly from the ac line without a line transformer. At the same time. The Microcontroller forms the heart of the project because it controls the devices being interfaced and communicates with the devices according to the program being written. which is an important safety consideration. a line transformer is generally large and heavy. from the analog domain to the digital domain where the signals are represented by numbers. Therefore. The output of the transformer is still an ac voltage. Relay: 9 . the transformer provides electrical isolation between the ac line and the circuit being powered. and is rather expensive. Sensors: This part of the system consists of current sensor. ADC) converters are electrical circuit devices that convert continuous signals. such as voltages or currents. However.Reset circuitry. but now of an appropriate magnitude for the circuit to be powered. Most circuits require a considerably lower voltage.current and are then sent to the Analog to Digital Converter. Pull up resistors (if needed) and so on. This project makes use of Liquid Crystal Display to display / prompt for necessary information. while a few require higher voltages. LCD Display Section: This section is basically meant to show up the status of the project. The transformer serves to convert the ac line voltage to a voltage level more appropriate to the needs of the circuit to be powered. These sensor sense various parameters of load. Transformers: In general. the ac line voltage present in your house wiring is not suitable for electronic circuits.
A relay is an electrical switch that opens and closes under control of another electrical circuit. SCHEMATIC: 10 .In this project Relays are used to the Trip the transformer. the switch is operated by an electromagnet to open or close one or many sets of contacts. In the original form.
the required operating voltage for Microcontroller 89C51 is 5V. The rectified a.SCHEMATIC EXPLANATION: Firstly. The diodes used are 1N4007. The step downed a. The rectified.c voltage is being rectified by the Bridge Rectifier. 7805 and 7812. filtered D. Now the rectified. This regulated 5V is generated by first stepping down the 230V to 18V and 12 V operating voltage for relays. power supply is needed by the same. These voltage regulators regulate 5v for microcontroller and 12v for relays.e. voltage is fed to the Voltage Regulator. This voltage regulator allows us to have a Regulated Voltage which is +5V. filtered and regulated voltage is again filtered for ripples using an electrolytic capacitor 100μF..C. We are using two voltage regulators i.C.c voltage is now filtered using a ‘C’ filter. Hence the 5V D. Now the output from this section is fed to 40th pin of 89c51 microcontroller to supply operating voltage. 11 . Hence another supply is required to generate 12V.
0 microcontroller. CHAPTER III HARDWARE Components 12 .0592 MHz crystal in conjunction with couple of capacitors of is placed at 18th & 19th pins of 89c51 to make it work (execute) properly. What ever the data in ADC from C. The control pins of LCD are connected to Port 2 as shown in schematic.T (current transformer) will be converted from analog to digital and fed it to the microcontroller. The data pins of ADC are connected to the port 1 of microcontroller.The microcontroller 89C51 with Pull up resistors at Port0 and crystal oscillator of 11. Relay is used to on & off the transformer occurred it is connected to P2.e whether the power supply is on or off to the transformer one through relay. The LCD is interfaced to Microcontroller. One of the port 3 pin is connected to the secondary side of transformer one through bridge rectifier and regulator to check the status of the transformer one i. The data pins of LCD are connected to Port 0.
The Hardware components used in this project are Regulated Power Supply Microcontroller Transformers Relay ADC Current sensor LCD 3.1 MICROCONTROLLER 89C51 INTRODUCTION: 13 .
Advantages of microcontrollers: 1. for example switch contacts can only be open or close. Timer/Counters. Interrupt Controller. not bytes as in the real world application.A Micro controller consists of a powerful CPU tightly coupled with memory RAM. everything integrated onto a single Silicon Chip. ROM or EPROM and peripherals and hence the size of the PCB will be large enough to hold all the required peripherals. COMPARISON 14 . the designer has to go for external memory such as RAM. ROM or EPROM). If a system is developed with a microprocessor. It does not mean that any micro controller should have all the above said features on chip. indicators should be lit or dark and motors can be either turned on or off and so forth. Parallel Ports. One of the major differences between a micro controller and a microprocessor is that a controller often deals with bits . apart from the controlling unit called the Central Processing Unit. parallel port or serial port for communicating with an external system. various I / O features such as Serial ports. the micro controller has got all these peripheral facilities on a single chip so development of a similar system with a micro controller reduces PCB size and cost of the design. Depending on the need and area of application for which it is designed. timer / counter for control purposes like generating time delays. Baud rate for the serial port. Any microcomputer system requires memory to store a sequence of instructions making up a program. But. Data Acquisition interfaces-Analog to Digital Converter (ADC). Digital to Analog Converter (ADC). The ONCHIP features present in it may or may not include all the individual section said above.
and no I/O PORTS on the chip itself.What is the difference between a microprocessor and microcontroller? By microprocessor is meant the general-purpose microprocessors such as Intel’s x86 Family(8086.80386. For this reason.80486.68020. no ROM.80286.etc.These microprocessors contain no RAM.). they are commonly referred as general-purpose microprocessors.68010.68040.and the Pentium)or Motorola’s680x0 family(68000.68030. Data bus CPU General purpose Micro Processor RAM ROM I/O PORT TIMER SERIAL COM PORT Address bus (A)General purpose Micro processor System CPU RAM I/O ROM TIMER Serial COM PORT (b) Microcontroller 15 .
parallel port timer or counter. the designer can’t add any external memory. A microcontroller has a CPU (a microprocessor) in addition to a fixed amount of RAM. meaning that the CPU can work on only 8-bits of data at a time. In many applications. For these reason some call these processors IBP (itty-bitty processors). The 8051 is an 8-bit processor. and number of I/O PORTS in microcontrollers makes them ideal for many applications in which cost and space are critical. various I/O interfaces such as serial port. In 1981. and 4 ports(each 8-bits wide)all on single chip. The 8051 can have a maximum of 64K bytes of ROM. In other words. and TIMERS externally to make them functional. The fixed amount of on-chip ROM. for example a TV remote control.Intel corporation introduced an 8 bit microcontroller called the 8051. I/O. and a timer all on a single chip. ROM. RAM. In many applications. they have the advantage of versatility such that the designer can decide on the amount of RAM.This microcontroller had 128 bytes of RAM. one serial port. interrupt 16 . many manufacturers have put only 4Kbytes on chip. therefore. and the price per unit are much more critical considerations than the computing power.A system designer using a general-purpose microprocessor such as the Pentium or the 68040 must add RAM. Although the addition of external RAM. I/OPORTS. the processor. there is no need for the computing power of a 486 or even an 8086 microprocessor. and timer are all embedded together on one chip. ROM and I/O PORTS needed to fit the task at hand this is not the case with microcontrollers. ROM and I/O PORTS makes these systems bulkier and much expensive. the space it takes.4K bytes of on-chip ROM. RAM. I/O PORTS. ROM. I/OPORTS. two timers. At that time it was also referred to as a “system on a chip”. the power it consumes. or timer to it. Data larger than 8-bits has to be broken into 8-bit pieces to be processed by the CPU. These applications most often require some I/O operation to read signal and turn on and off certain bits. ROM. A Micro controller consists of a powerful CPU tightly coupled with memory.
the designer has to go for external memory such as RAM. Digital to Analog converter. ROM. Development of a Micro controller reduces PCB size and cost of design. 32 or 64 bit micro controllers or microprocessors. 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.controller. Systems using these may be earlier to 17 . The Major Features: • • • • • • • • Compatible with MCS-51 products 4k Bytes of in-system Reprogrammable flash memory Fully static operation: 0HZ to 24MHZ Three level programmable clock 128 * 8 –bit timer/counters Six interrupt sources Programmable serial channel Low power idle power-down modes o Why AT 89C51? : The system requirements and control specifications clearly rule out the use of 16. integrated on to a single silicon chip. EPROM and peripherals. data acquisition interfaces-Analog to Digital converter. But controller is provided all these facilities on a single chip. Intel has introduced a family of Micro controllers called the MCS-51. If a system is developed with a microprocessor.
18 . and IE Two external and three internal interrupts sources. The on-chip Flash ROM allows the program memory to be reprogrammed in system or by conventional non-volatile memory Programmer.bit stack pointer (PSW) Eight-bit stack pointer (Sp) Internal ROM or EPROM (8751) of 0(8031) to 4K (89C51) Internal RAM of 128 bytes: 1. They are also faster and more reliable but. the above application is satisfactorily served by 8-bit micro controller. PCON. TMOD. Sixteen bytes. each containing eight registers 2. IP.implement due to large number of internal features. Using an inexpensive 8-bit Microcontroller will doom the 32-bit product failure in any competitive market place. Moreover ATMEL is the leader in flash technology in today’s market place and hence using AT 89C51 is the optimal solution.purpose data memory • • • • • • Thirty –two input/output pins arranged as four 8-bit ports:p0-p3 Two 16-bit timer/counters: T0 and T1 Full duplex serial data receiver/transmitter: SBUF Control registers: TCON. Oscillator and clock circuits. Four register banks. SCON. Coming to the question of why to use AT89C51 of all the 8-bit microcontroller available in the market the main answer would be because it has 4 Kb on chip flash memory which is just sufficient for our application. AT89C51 MICROCONTROLLER ARCHITECTURE The 89C51 architecture consists of these specific features: • • • • • • Eight –bit CPU with registers A (the accumulator) and B Sixteen-bit program counter (PC) and data pointer (DPTR) Eight. Eighty bytes of general. which maybe addressed at the bit level 3.
The manufacturers make 89C51 designs that run at specific minimum and maximum frequencies typically 1 to 16 MHz. Typically a quartz crystal and capacitors are employed. Pins XTAL1 And XTAL2 is provided for connecting a resonant network to form an oscillator. 19 . The crystal frequency is the basic internal clock frequency of the microcontroller.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.
They are on-chip memory. External code memory is the code memory that resides off chip. 20 . This often is in the form of standard static RAM or flash RAM.Oscillator and timing circuit Types of memory: The 89C51 have three general types of memory. external Code memory and external Ram. On-Chip memory refers to physically existing memory on the micro controller itself. This is often in the form of an external EPROM. External RAM is the Ram that resides off chip.
Internal RAM also contains 128 bits. Each bank contains 8 registers. which is slower than flash memory updating. The internal RAM is found onchip. unlike flash memory. It is possible to have 4K of code memory on-chip and 60K off chip memory simultaneously. which are addressed from 20h to 2Fh. flash memory is not useful as random access memory (RAM) because RAM needs to be addressable at the byte (not the block) level." The erasure is caused by Fowler21 . is erased and rewritten at the byte level. If only off-chip memory is available then there can be 64K of off chip ROM. So it is the fastest Ram available. this memory is cleared. FLASH MEMORY: Flash memory (sometimes called "flash RAM") is a type of constantly-powered non volatile that can be erased and reprogrammed in units of memory called blocks. Flash memory gets its name because the microchip is organized so that a section of memory cells are erased in a single action or "flash. This is controlled by pin provided as EA b) Internal RAM The 89C51 have a bank of 128 of internal RAM.a) Code memory Code memory is the memory that holds the actual 89C51 programs that is to be run. Internal Ram is volatile. On the other hand. This memory is limited to 64K. so when 89C51 is reset. the flash memory can be written to in block (rather than byte) sizes. These bits are bit addressed i. Code memory may be found on-chip or off-chip. making it easy to update. Flash memory is often used to hold control code such as the basic input/output system (BIOS) in a personal computer.e. When BIOS needs to be changed (rewritten). And also it is most flexible in terms of reading and writing. The user may make use of these variables with commands such as SETB and CLR. each individual bit of a byte can be addressed by the user. It is a variation of electrically erasable programmable read-only memory (EEPROM) which. The first 32 bytes are divided into 4 register banks. They are numbered 00h to 7Fh. 128 bytes of internal memory are subdivided.
embedded controllers.Nordheim tunneling in which electrons pierce through a thin dielectric material to remove an electronic charge from a floating gate associated with each memory cell. Memory Types 22 . Intel offers a form of flash memory that holds two bits (rather than one) in each memory cell. digital set-up boxes. LAN switches. Flash memory is used in digital cellular phones. thus doubling the capacity of memory without a corresponding increase in price. and other devices. digital cameras. PC Cards for notebook computers.
high-density. lower Programmable reliability. reliable. time-consuming mask required. low power. but with a much thinner. high-speed. high-density. Intel® Flash memory uses memory cells similar to an EPROM. high-power. high-speed architecture. Intel Flash memory is an extremely reliable nonvolatile memory architecture.Memory Type FLASH ROM Read-Only Memory SRAM Static Random-Access Memory EPROM Memory EEPROM Electrically DRAM Dynamic Random Access Memory or Erasable E2 Features Low-cost. which allows the user to electrically program and erase information. Flash programming occurs when electrons are placed on the floating gate. low cost. limited density drives up cost High-density memory. must be exposed Electrically Programmable Read-Only to ultraviolet light for erasure Electrically byte-erasable. with the oxide layer allowing the cell to be electrically erased through the source. precisely grown oxide between the floating gate and the source (see Figure 2). low-density memory. lowest density High-density. high-power low-cost. 23 . Read-Only Memory Technical Overview of Flash Memory Flash memory is a nonvolatile memory using NOR technology. high reliability Mature. higher cost. suitable for high production with stable code Highest speed. The charge is stored on the floating gate.
Pin diagram of AT89C51 Pin Description: VCC: Supply voltage. Port 0: 24 . GND: Ground.
When 1s are written to Port 2 pins they are pulled high by the internal pull-ups and can be used as inputs. Port 3: 25 . As an output port. The Port 1 output buffers can sink/source four TTL inputs. the pins can be used as high impedance inputs. In this mode P0 has internal pull-ups. and outputs the code bytes during program verification.Port 0 is an 8-bit open-drain bi-directional I/O port. Port 1 also receives the low-order address bytes during Flash programming and verification. Port 0 may also be configured to be the multiplexed low order address/data bus during accesses to external program and data memory. Port 0 also receives the code bytes during Flash programming. each pin can sink eight TTL inputs. Port 2: Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 2 output buffers can sink/source four TTL inputs. As inputs. Port 2 emits the contents of the P2 Special Function Register. External pull-ups are required during program verification. 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. it uses strong internal pull-ups when emitting 1s. Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. When 1s are written to Port 1 pins they are pulled high by the internal pull-ups and can be used as inputs. Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. In this application. When 1’s are written to port 0 pins. Port 2 also receives the high-order address bits and some control signals during Flash programming and verification. During accesses to external data memories that use 8-bit addresses (MOVX @ RI). Port 1: Port 1 is an 8-bit bi-directional I/O port with internal pull-ups.
A high on this pin for two machine cycles while the oscillator is running resets the device. The Port 3 output buffers can sink/source four TTL inputs. In normal operation ALE is emitted at a constant rate of 1/6the oscillator frequency. that one ALE pulse is skipped during each access to external Data Memory. 26 .1 Port pins and their alternate functions RST: Reset input. When 1s are written to Port 3 pins they are pulled high by the internal pull-ups and can be used as inputs. As inputs. 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. This pin is also the program pulse input (PROG) during Flash programming. Note. ALE/PROG: Address Latch Enable output pulse for latching the low byte of the address during accesses to external memory.2. however. and may be used for external timing or clocking purposes.Port 3 is an 8-bit bi-directional I/O port with internal pull-ups.
With the bit set. that if lock bit 1 is programmed. as shown in Figs 6. EA should be strapped to VCC for internal program executions.2. When the AT89C51 is executing code from external program memory. for parts that require 12-volt VPP. EA will be internally latched on reset. except that two PSEN activations are skipped during each access to external data memory. the pin is weakly pulled high. XTAL1: Input to the inverting oscillator amplifier and input to the internal clock operating circuit.If desired. PSEN is activated twice each machine cycle. This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming. Note. Either a quartz crystal or ceramic resonator may be used. Oscillator Characteristics: XTAL1 and XTAL2 are the input and output. Otherwise. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode. PSEN: Program Store Enable is the read strobe to external program memory. ALE operation can be disabled by setting bit 0 of SFR location 8EH.3. XTAL2 should be left unconnected while XTAL1 is driven as 27 . however. ALE is active only during a MOVX or MOVC instruction. 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. To drive the device from an external clock source. XTAL2: Out put from the inverting oscillator amplifier. of an inverting amplifier which can be configured for use as an on-chip oscillator. respectively.
2. 2. since the input to the internal clocking circuitry is through a divide-by-two flipflop. IOL must be externally limited as follows: • • • • • Maximum IOL per port pin: 10 mA Maximum IOL per 8-bit port: Port 0: 26 mA Ports 1. 2. VOL may exceed the related specification.shown in Figure 6. Oscillator Connections Notes: External Clock Drive Configuration 1.There are no requirements on the duty cycle of the external clock signal. 3: 15 mA Maximum total IOL for all output pins: 71 mA If IOL exceeds the test condition. Minimum VCC for Power-down is 2V. but minimum and maximum voltage high and low time specifications must be observed. Types of memory: 28 . Pins are not guaranteed to sink current greater than the listed test conditions.4. Under steady state (non-transient) conditions.
e. External code memory is the code memory that resides off chip. This memory is limited to 64K. this memory is cleared. 128 bytes of internal memory are subdivided. The internal RAM is found on-chip. a) Accumulator (0E0h) As its name suggests. The user may make use of these variables with commands such as SETB and CLR. On-Chip memory refers to physically existing memory on the micro controller itself. it is used to accumulate the results of large no of instructions.The 8051 have three general types of memory. External RAM is the Ram that resides off chip. Each bank contains 8 registers. Code memory may be found on-chip or off-chip. external Code memory and external Ram. Internal Ram is volatile. These bits are bit addressed i. so when 8051 is reset. It can hold 8 bit values. each individual bit of a byte can be addressed by the user. Internal RAM also contains 128 bits. This is often in the form of an external EPROM. They are numbered 00h to 7Fh. The first 32 bytes are divided into 4 register banks. It is possible to have 4K of code memory on-chip and 60K off chip memory simultaneously. If only off-chip memory is available then there can be 64K of off chip ROM. This is controlled by pin provided as EA b) Internal RAM The 8051 have a bank of 128 bytes of internal RAM. And also it is most flexible in terms of reading and writing. They are on-chip memory. b) Code memory Code memory is the memory that holds the actual 8051 programs that is to be run. which are addressed from 20h to 2Fh. Special Function registered memory: Special function registers are the areas of memory that control specific functionality of the 8051 micro controller. 29 . So it is the fastest Ram available. This often is in the form of standard static RAM or flash RAM.
And is incremented each time an instruction is executes.B) B register (0F0h) The B register is very similar to accumulator. Certain operation modes of the 8051 allow the 8051 to go into a type of “sleep mode ” which consume much lee power. It may hold 8-bit value. e) Program counter The program counter is a 16 bit register. which contains the 2 byte address. which tells the 8051 where the next instruction to execute to be found in memory. The data pointer is used in operations regarding external RAM and some instructions code memory. It is not addressable SFR. In div AB the quotient gets stored in B with the remainder in A. d) Data pointer The SFRs DPL and DPH work together work together to represent a 16-bit value called the data pointer. In MUL AB the higher byte of the product gets stored in B register. 87h) The power control SFR is used to control the 8051’s power control modes. This is used to indicate where the next value to be removed from the stack should be taken from. When a value is to be popped from the stack. the 8051 returns the value from the memory location indicated by SP and then decrements the value of SP. 30 . the 8051 first store the value of SP and then store the value at the resulting memory location. The b register is only used by MUL AB and DIV AB instructions. When the 8051 is initialized PC starts at 0000h. It is a 16-bit SFR and also an addressable SFR. f) PCON (power control. When a value is to be pushed onto the stack. c) Stack pointer (81h) The stack pointer holds 8-bit value.
which are set when an external interrupt occurs. these timers always count up. h) TMOD (Timer Mode. Using this SFR your program may configure each timer to be a 16-bit timer. address 8A/8C h) These two SFRs taken together represent timer 0. i) TO (Timer 0 low/high. Additionally. This SFR controls whether each of the two timers is running or stopped and contains a flag to indicate that each timer has overflowed. 89h) The timer mode SFR is used to configure the mode of operation of each of the two timers. These bits are used to configure the way in which the external interrupt flags are activated. Their exact behavior depends on how the timer is configured in the TMOD SFR. 31 . or two separate timers. some non-timer related bits are located in TCON SFR. 8-bit auto reload timer. or 13 bit timer. 88h) The timer control SFR is used to configure and modify the way in which the 8051’s two timers operate.g) TCON (timer control. What is configurable is how and when they increment in value. however. Additionally you may configure the timers to only count when an external pin is activated or to count “events ” that are indicated on an external pin.
Their exact behavior depends on how the timer is configured in the TMOD SFR.7.0. however. address 0A0h.7. What is Configurable is how and when they increment in value.7. For e.. For e.0. For e. Writing a value of 1 to a bit of this SFR will send a high level on the corresponding I/O pin whereas a value of 0 will bring it to low level. l) P1 (port 1. bit 0 of port 0 is pin P3.. k) P0 (Port 0. bit 7 is pin P1. For e. bit addressable) : This is a port latch3.0. taken together.g.g. address 8B/ 8D h) These two SFRs. Each bit of this SFR corresponds to one of the pins on a micro controller.j) T1 (Timer 1 Low/High. Each bit of this SFR corresponds to one of the pins on a micro controller. n) P3(port 3. Any data to be outputted to port 0 is first written on P0 register. Any data to be outputted to port 0 is first written on P0 register.address B0h. Writing a value of 1 to a bit of this SFR will send a high level on the corresponding I/O pin whereas a value of 0 will bring it to low level m) P2 (port 2.g.0.7. bit 0 of port 0 is pin P0. Any data to be outputted to port 0 is first written on P0 register. Writing a value of 1 to a bit of this SFR will send a high level on the corresponding I/O pin whereas a value of 0 will bring it to low level 32 . Each bit of this SFR corresponds to one of the pins on a micro controller. address 90h. Any data to be outputted to port 0 is first written on P0 register... these timers always count up. bit addressable) This is port latch1. Writing a value of 1 to a bit of this SFR will send a high level on the corresponding I/O pin whereas a value of 0 will bring it to low level. bit 7 is pin P2. bit 0 of port 0 is pin P1. Each bit of this SFR corresponds to one of the pins on a micro controller. bit 7 is pin P3. bit 7 is pin p0. represent timer 1. address 90h. bit addressable) This is port 0 latch.g. bit addressable) : This is a port latch2. bit 0 of port 0 is pin P2.
33 . even if another interrupt is currently executing. However. The PSW SFR contains the carry flag.g. which of the “R” register banks currently in use. p) IP (Interrupt Priority. the parity flag and the overflow flag. The serial interrupt always interrupts the system.o) IE (interrupt enable. which are used to select. On 8051. Thus. q) PSW (Program Status Word. if a serial interrupt is executing no other interrupt will be able to interrupt the serial interrupt routine since the serial interrupt routine has the highest priority. if the high bit of IE is 0 all interrupts are disabled regardless of whether an individual interrupt is enabled by setting a lower bit. 0B8h) The interrupt priority SFR is used to specify the relative priority of each interrupt. where the MSB bit is used to enable or disable all the interrupts. For e. 0D0h) The program Status Word is used to store a number of important bits that are set and cleared by 8051 instructions. the auxiliary carry flag. An interrupt may interrupt interrupts. an interrupt maybe either low or high priority. The low 7 bits of the SFR are used to enable/disable the specific interrupts. if we configure all interrupts as low priority other than serial interrupt. it also contains the register bank select flags. Additionally.. 0A8h): The Interrupt Enable SFR is used to enable and disable specific interrupts.
on what software programs are used to “program” the pins. 99h) SBUF is used to hold data in serial communication. To configure a pin as input. 1 must be written into the corresponding port 0 latch by the program. 1 is to be written into the corresponding Port 1 latch. latched using Address latch enable (ALE) pulse and then the bus is turned around to become the data bus for external memory. When used for interfacing with the external memory. on what is physically connected to it and. when used together. PORT 1 pins have no dual function. The main constraint that limits numerous functions is the number of pins available in the 8051 circuit.r) SBUF (Serial Buffer. PORT 1 Port 1 is exclusively used for input/output operations. The DIP had 40 pins and the success of the design depends on the flexibility incorporated into use of these pins. 24 of the pins may each used for one of the two entirely different functions which depend. For this reason. PORT 0 Port 0 pins may serve as inputs. The other is read only and holds received data from external sources via RXD. When a pin is to be configured as input. Both mutually exclusive registers use address 99h. 34 . the lower byte of address is first sent via PORT0. One is writing only and is used to hold data to be transmitted out of 8051 via TXD. as a bi directional low-order address and data bus for external memory. first. or. It is physically two registers. then. I/O ports: One major feature of a microcontroller is the versatility built into the input/output (I/O) circuits that connect the 8051 to the outside world. outputs.
1 TCON.RD Alternate Use Serial data input Serial data output External interrupt 0 External interrupt 1 External Timer 0 input External timer 1 input External memory write pulse External memory read pulse SFR SBUF SBUF TCON.0 . which can have external addressing functions and change all eight-port b se. It may also be used to supply a high – order address byte in conjunction with Port 0 low-order byte to address external memory.PORT 2 Port 2 maybe used as an input/output port.INTO 0 P3.T0 P3. Port 2 pins are momentarily changed by the address control signals when supplying the high byte a 16-bit address. The Port 3 alternate uses are: Pin P3.INTO 1 P3. Unlike Port 0 and Port 2. Port 2 latches remain stable when external memory is addressed. PORT 3 Port 3 may be used to input /output port.7 .TXD P3.6 .3 .5 – T1 P3.RXD P3.WR P3.2 . The input and output functions can be programmed under the control of the P3 latches or under the control of various special function registers.1 . as they do not have to be turned around (set to 1) for data input as in the case for Port 0.4 . each pin of port 3 maybe individually programmed to be used as I/O or as one of the alternate functions.3 TMOD TMOD - 35 .
These register can be accessed like any other register. They can be used either as timers to generate a time delay or as counters to count events happening outside the microcontroller. These includes pulse counting. etc. PROGRAMMING 8051 TIMERS The 8051 has timers: Timer 0 and Timer1. BASIC RIGISTERS OF THE TIMER Both Timer 0 and Timer 1 are 16 bits wide. TIMER 0 REGISTERS The 16-bit register of Timer 0 is accessed as low byte and high byte. Since the 8051 has an 8-bit architecture. pulse width measurement.TIMERS On-chip timing/counting facility has proved the capabilities of the microcontroller for implementing the real time application.. each 16-bit timer is accessed as two separate registers of low byte and high byte. Having sufficient number of timer/counters may be a need in a certain design application. such as 36 . Let discuss how these timers are used to generate time delays and we will also discuss how they are been used as event counters.they can be used either as timers or as event counters. The 8051 has two timers/counters. 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). frequency measurement. Let us first discuss about the timers’ registers and how to program the timers to generate time delays. baud rate generation.
These registers can also be read like any other register. referred to as TL1 (Timer 1 low byte) and TH1(Timer 1 high byte). #4F”moves the value 4FH into TL0.B.these registers are accessible n the same way as the register of Timer 0. TMOD (timer mode) REGISTER Both timers 0 and 1 use the same register.A.etc.the low byte of Timer 0. D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 TH0 TL0 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 37 .R0. to set the various timer operation modes.R1. the instruction ”MOV TL0. called TMOD.R2.for example.
MODES: M1.in each case. and mode 2 is an 8-bit timer. set. 1. the timer is enabled. We will concentrate on modes 1 and 2 since they are the ones used most widely.Timer 0 and the upper 4 bits for Timer 1. 2. the lower 2 bits are used to set the timer mode and the upper 2 bits to specify the operation. The timer/counter is enabled only while the INTx pin is high and the TRx control pin is.Mode 0 is a 13-bit timer. after describing the reset of the TMOD register. we will soon describe the characteristics of these modes. When cleared. M0: M0 and M1 are used to select the timer mode. C/T Timer or counter selected cleared for timer operation (Input from internal system clock). mode 1 is a 16-bit timer.set for counter operation (input TX input pin). There are three modes: 0. 38 . GATE Gate control when set.
there is no prescaler 1 0 2 8-bit auto reload 8-bit auto reload timer/counter.this section is concerned with this choice. EX: Find the values of TMOD to operate as timers in the following modes.Mode 2 Timer 1 39 . (a) Mode 1 Timer 1 (b) Mode 2 Timer 0. The clock source for the time delay is the crystal frequency of the 8051.M1 M0 M1 0 M0 0 Mode bit 1 Mode bit 0 MODE 0 Operating Mode 13-bit timer mode 8-bit timer/counter THx with TLx as 5-bit prescaler. 0 1 1 16-bit timer mode 16-bit timer/counters THx with TLx are cascaded. The timer’s use as an event counter is discussed in the next section. 1 1 3 Split timer mode. If C/T=0. it is used as a timer for time delay generation.THx Holds a value that is to be reloaded into TLx each time it overflows. TMOD Register 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.
This means that the size of the crystal frequency attached to the 8051 also decides the speed at which the 8051 timer ticks. and some have both software and hardware controls. and the unused timer(Timer 0 bit is also 0) (b) TMOD is 01010010=52H (c) TMOD is 00000000H = 00H Note: 8051 Timers use 1/12 of XTAL frequency.0592MHz.the reason behind such an odd number has to do with the baud rate for serial communication of the 8051. The frequency for the timer is always 1/12th the frequency of the crystal attached to the 8051. Although various 8051-based systems have an XTAL frequency of 10MHz. the crystal frequency attached to the 8051 is the source of the clock for the timer. regardless of machine cycle time.0592MHz allows the 8051 system to communicate with the IBM PC with no errors. Notice in the TMOD register in the below example figure that both Timers 0 and 1 have the GATE bit. Clock source for timer As you know. every timer needs a clock pulse to tick. Gate The other bit of the TMOD register id the GATE bit.we will concentrate on the XTAL frequency of 11. What is the source of the clock pulse for the 8051 timers? If C/T=0. the timers in the 8051 40 . Some timers do this by software. some by hardware. What is its purpose? Every timer has a means of starting and stopping.(c) Mode 0 Timer 1 Solution: (a)TMOD is 00010000 = 10H The gate control bit and C/T bit are made 0.XTAL =11.
When a timer counts to its maximum value. it is necessary to know more about the bits TF and TR for timers 0 and 1. another register called the TCON controls the timer/counter operations. we will look at the timer’s modes and how they are programmed to create a time delay. but the upper four bits are for timer operations.while TMOD controls the timer modes. it sets a flag TF0 or TF1. The details of the TCON register are shown below. These instructions start and stop the timers as long as GATE =0 in the TMOD register. in using software to start and stop the timer where GATE=0. we describe each of them in detail. The lower four bits of TCON cater to interrupt functions. Now that we have this basic understanding of the role of the TMOD register. The hardware way of starting and stopping the timer by an external source GATE =0. MSB LSB TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0 41 .the SETB instruction starts it. EX: How are timers 0 and 1 started and stopped by instruction? Solution: The timers are started by using instructions to set timer start bits TR0 and TR1.all we need are the instructions “SETB TRx” and “CLR TRx”.have is achieved by the instructions “SETB TR1” and “CLR TR1” for Timer 1. Because modes 1 and 2 are so widely used.at this point. meaning that no external hardware is needed to start and stop the timers. They can be cleared by clearing these bits.and “SETB TR0” and “CLR TR0” for Timer0. and it is stopped by the CLR instruction.which are called timer run control bits.
BIT TCON.7 TCON.6 TCON.5 TCON.4
SYMBOL TF1 TR1 TF0 TR0
FUNCTION Timer 1 overflows flag Timer 1 run control bit Timer 0 overflows flag Timer 0 run control bit
Some assemblers don’t allow the use of TF0, TR0, etc.in programs, but instead need the use of these as bits of TON. For example, TF1 is TCON.7 and TR1 is TCON.6.
Mode 1 programming
The following are the characteristic and operations of mode 1: 1. it is a 16-bit timer: therefore, it allows values of 0000 to FFFFH to be loaded into the timer’s registers TL and TH. 2. After TH and TL are loaded with 16-bit initial value, the timer must be started. This is done by “SETB TR0” for Timer 0 and “SET TR1” for Timer1. 3. After the timer is started, it starts to count up. it counts up until it reaches its limit of FFFFH. When it rolls over from FFFFH to 0000, it sets high a flag bit called TF (timer flag).this timer flag can be monitored. When this timer flag is raised, one option would be to stop the timer with the instructions “CLR TR0” or “CLR TR1” for Timer 0 and Timer 1, respectively.again, it must be noted that each timer has its own timer flag: TF0 for Timer 0, and TF1 for Timer 1. 4. After the timer reaches its limit its limit and rolls over, in order to repeat the process the registers TH and TL must be reloaded with the original value and TF must be reset to 0
XTAL oscillat or .
/12 _ C/T =0 TR
TF goes high When FFFF—0
Steps to program in mode 1
1. Load the TMOD value register indicating which timer (Timer 0 or Timer 1) is to be used and which timer mode (0 or 1) is selected. 2. Load register TL and TH with initial count values. 3. Start the timer. 4. Keep monitoring the timer flag (TF) with the “JNB TFx, target” instruction to see if it is raised. Get out of the loop when TF becomes high. 5. Stop the timer. 6. Clear the TF flag for the next round 7. Go back to Step 2 to load TH and TL again.
EX: In the following program, we are creating a square wave of 50% duty cycle (with equal portion high and low) on the P1.5 bit. Timer 0 is used to generate the time delay. Analyze the program. Solution: MOV HERE: MOV MOV CPL SJMP TMOD, # 01 TL0, #0F2H TH0, #0FFH P1.5 HERE ; Timer 0, mode 1 (16 – bit mode) ; TL0 =F2H, the low byte ; TH0 =FFH, the High byte ;toggle P1.5 ; load TH , TL again
ACALL DELAY ; ------------ delay using Timer 0 DELAY: SETB AGAIN: JNB TR0 TF0, AGAIN ; start Timer 0 ; monitor Timer 0 flag until ; It rolls over 44
#28 45 . Solution: MOV REPT: MOV TMOD. 1. mode 1 . Divide the desired time delay by 1. counter for multiple delays . clear Timer 0 flag Finding values to be loaded into the timer Assuming that we know the amount of timer delay we need. Timer 1. what if that is not enough? See the below example. Perform 65536-n.both of these factors are beyond the control of the 8051 programmer.4.write a program to generate a pulse train 2 seconds period on pin P2. Ex: Assuming XTAL = 2MHz.USse Timer 1 in mode 1. 3. 4. Generating a large time delay Size of the time delay depends on two factors. TL registers. We saw earlier that the largest time delay is achieved by making both TH and TL zero.CLR CLR RET TR0 TF0 . where yyxx is the initial hex value to be loaded into the timer’s registers. #10H R0.085μs. Set TL=xx and TH=yy. the question is how to find the values needed for the TH. (a) the crystal frequency and (b) the timer’s 16-bit register in mode 1. 2. where n is the decimal value we got in step 1. To calculate the values to be loaded into the TL and TH registers. stop Timer 0 . Convert the result of step 2 to hex.
4 . repeat for continuous pulse generation Calculation = 28x 35. clear timer flag . start timer .CPL BACK: MOV MOV SETB AGAIN: JNB CLR CLR DJNZ SJMP P2. #00H TH1. complement P2.the 13-bit counter can hold values between 0000 to 1FFFH in TH-TL. stay until timer roller over .4 TL1. if R0 is not zero. AGAIN TR1 TF1 R0. stop timer . load count value in th1 . reload timer . 46 . BACK REPT .75ms =1001 ms. Mode 0 Mode 0 is exactly like mode 1 except that it is a 13-bit timer instead of 16-bit. #00H TR1 TF1. Therefore. and TF is raised. load count value in TL1 . when the timer reaches its maximum of 1FFH. it rolls over to 0000.
Overflow 47 . if we are using Timer 1. 3. it start to count up by incrementing the TL register. it started.this is just like mode 1. the 8051 gives a copy of it to TL. This is done by the instruction “SETB TR0” for Timer 0 and “SETB TR1” for Timer 1. therefore. It is 8-bit timer.if we are using Timer 0. 1. Then the timer must be started. TF0 goes high. After the timer is started. After TH is loaded with the 8-bit value. and TF1 is raised. It counts up until it reaches its limit of FFH. it allows only values if 00 to FFH to be loaded into the timer’s register TH. When it rolls over from FFH to 00. 2. it sets high the TF (timer flag).Mode 2 programming The following are the characteristics and operations of mode 2.
flag XTAL Oscillator TL /12 TF TH TR TF goes high when FF---0 4. To repeat the process. When the TL registers rolls from FFH to 0 and TF is set to 1. we must simply clear TF and let it go without any need by the programmer to reload the original value. 48 . in contrast with mode 1 in which the programmer has to reload TH and TL. This makes mode 2 an auto-reload. TL is reloaded automatically with the original value kept by the TH register.
including setting the baud rate in serial communication. Load the TMOD value register indicting which timer (Timer 0 or Timer 1) is to be used. However. start the timer 49 . This reloading leaves TH unchanged. 1.It must be emphasized that mode 2 is an 8-bit timer. still holding a copy of the original value. This mode has many applications. 3. In auto-reload TH is loaded with the initial count and a copy of it is given to TL. and select the timer mode(mode 2). Steps to program in mode 2 To generate a time delay using the timer’s mode 2 take the following steps. Load the TH registers with the initial count value. it has an autoreloading capability. 2.
asynchronous and synchronous. The synchronous method transfers a block of data at a time. 50 . If data is transmitted one way at a time. depending on whether or not the data transfer can be simultaneous. which stands for “modulator/demodulator. 5. often 8 or more lines (wire conductors) are used to transfer data to a device that is only a few feet away. The 8051 has serial communication capability built into it. in which the computer only sends data. there by making possible fast data transfer using only a few wires. Although in such cases a lot of data can be transferred in a short amount of time by using many wires in parallel. it is referred to as half duplex. Keep monitoring the timer flag (TF) with the “JNB TFx. Serial communication of the 8051 is the topic of this chapter. the distance cannot be great.” Serial data communication uses two methods. To transfer to a device located many meters away. it is full duplex. while the asynchronous method transfers a single byte at a time. SERIAL COMMUNICATION: Computers can transfer data in two ways: parallel and serial. since mode 2 is auto-reload. in contrast to parallel communication.4. in order to transfer and receiv e data simultaneously. each uses cables with many wire strips. full duplex requires two wire conductors for the data lines. In parallel data transfers. one for transmission and one for reception. Duplex transmissions can be half or full duplex. This conversion is performed by a peripheral device called a modem. If data is to be transferred on the telephone line. In data transmission if the data can be transmitted and received. the serial method is used. Of course. Examples of parallel transfers’ ae printers and hard disks. This is in contrast to simplex transmissions such as with printers. which are sinusoidal-shaped signals. it must be converted from 0s and 1s to audio tones. the data is sent one bit at a time. in which the data is sent a byte or more at a time. Go back to step 4. it is a duplex transmission. clear the TF flag 6. In serial communication. get out of the loop when TF goes high. If the data can go both ways at the same time. target” instruction to see whether it is raised.
it is difficult to make sense of the data unless the sender and receiver agree on a set of rules. In 1963 it was modified and called RS232A.000bps. sometimes transfers several bits of data. and when the data begins and ends. each character is placed between start and stop bits. the baud and bps rates are not necessarily equal. but the stop bit can be one or two bits. Start and stop bits Asynchronous serial data communication is widely used for character-oriented transmissions. For example. respectively. are packed between a start bit and a stop bit. However. Data transfer rate The rate of data transfer in serial data communication is stated in bps (bits per second). This is called framing. In modems a single change of signal. The start bit is always a 0 (low) and the stop bit (s) is 1 (high). In the asynchronous method. Today. an interfacing standard called RS232 was set by the Electronics Industries Association (EIA) in 1960. while block-oriented data transfers use the synchronous method. The start bit is always one bit. the baud rate and bps are the same. In recent years. 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 early IBMPC/XT could transfer data at the rate of 100 to 9600 bps. RS232 is the most widely 51 It must be noted that in asynchronous serial data communication. . a protocol. RS232B AND RS232C were issued in 1965 and 1969. In the data framing for asynchronous communications. Pentium based PCS transfer data at rates as high as 56K bps.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. the baud rate is generally limited to 100. The data transfer rate of given computer system depends on communication ports incorporated into that system. how many bits constitute a character. As far as the conductor wire is concerned. the data. RS232 Standards To allow compatibility among data communication equipment made by various manufacturers. and for this reason we use the bps and baud interchangeably. Another widely used terminology for bps is baud rate. on how the data is packed. however. such as ASCII characters.
The three essential signals for 2 way RS-232 52 . For this reason. DSR. and vice versa. as shown in table. Rx. MAX232 IC chips are commonly referred to as line drivers. its input and output voltage levels are not TTL compatible. and Ground. 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.used serial I/O interfacing standard. while a 0 bit is +3 to +25V. which uses 9 pins only. a 1 is represented by -3 to -25V. The method used by RS-232 for communication allows for a simple connection of three lines: Tx. IBM introduced the DB-9 Version of the serial I/O standard. This standard is used in PCs and numerous types of equipment. commonly referred to as the DB-25 connector. Since not all the pins are used in PC cables. However. making -3 to +3 undefined. In RS232. RS232 pins RS232 cable. since the standard was set long before the advert of the TTL logic family. In labeling. RTS and CTS are active low pins. DB-25P refers to the plug connector (male) and DB-25S is for the socket connector(female). DB-9 pin connector 12345 6789 (Out of computer and exposed end of cable) 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.
RXD: carries data from DCE to the DTE SG: signal ground 8051 connection to RS232 The RS232 standard is not TTL compatible.1). The line drivers used for TXD are called T1 and T2. they require a line driver to make them RS232 compatible. The MAX232 has two sets of line drivers for transferring and receiving data. In many applications only one of each is used. The 8051 has two pins that are used specifically for transferring and receiving data serially. In the other words. and vice versa.Communications are these: TXD: carries data from DTE to the DCE. One such line driver is the MAX232 chip. with a single +5V power supply we can power both the 8051 and MAX232. it requires a line driver such as the MAX232 chip to convert RS232 voltage levels to TTL levels. The interfacing of 8051 with RS232 connectors via the MAX232 chip is the main topic. while the line drivers for RXD are designated as R1 and R2. These two pins are called TXD and RXD and a part of the port 3 group (P3. pin 11 of the 8051 is assigned to TXD and pin 10 is designated as RXD. and vice versa. therefore. MAX232 converts from RS232 voltage levels to TTL voltage levels. TXD RXD TXD 2 3 5 Embedded Controller RXD GND MAX 232 53 . therefore. These pins are TTL compatible. with no need for the power supplies that are common in many older systems. is the same as the source voltage for the 8051.0 and P3. One advantage of the MAX232 chip is that it uses a +5V power source which.
921. In the case of XTAL=11.6khz divided by 32 once more before it is used by Timer 1 to set the Baud rate.. copy SBUF into accumulator The moment a byte is written into SBUF.592MHz SBUF register SBUF is an 8-bit register used solely for serial communication in the 8051. copy accumulator into SBUF .Baud rate in the 8051 The 8051 transfers and receives data serially at many different baud rates. A A. load SBUF=44h. it is framed with the start and stop bits and transferred serially via the TXD pin.6KHz).6 kHz divided by 32 gives 28. the 8051’s serial communication UART circuitry divides the machine cycle frequency of 921. Look at the following the examples of how this register is accessed. #’D’ SBUF. 54 . The 8051 divides the crystal frequency by 12 to get the machine cycle frequency. Similarly. SBUF holds the byte of data when it is received by the 8051’s RXD line. the 8051 defames it by eliminating the stop and start bits. making a byte out of the data received. MOV MOV MOV SBUF. and then placing it in the SBUF. The is done with the help of Timer1. the machine cycle frequency is 921. SBUF can be accessed like any other register in the 8051.800 Hz. SBUF . Baud rate 9600 4800 2400 1200 TH1(Decimal) -3 -6 -12 -24 TH1(Hex) FD FA F4 E8 NOTE: XTAL=11.0592MHz/12=921. This is the number well use to find the Timer 1 value to set baud rate. The baud rate in the 8051 is programmable.. it must be placed in the SBUF register. when the bits are received serially via RXD.0592MHZ. Similarly. for a byte of data to be transferred via the TXD line.6 KHz (11. Therefore. ASCII for ‘D’ .
and data bits of data framing. (make it 0. SM0 SM1 SM2 REN TB8 RB8 TI RI SM0 SM1 SM2 REN TB8 RB8 TI RI software. Set by hardware at the beginning Of the stop bit in mode 1.1 SCON. among other things.) Set/cleared by software to enable/disable reception Not widely used Not widely used Transmit interrupt flag. Note: Make SM2.SCON (serial control) register The SCON register is an 8-bit register used to program the start bit.6 SCON.5 SCON. They take the following combinations.2 SCON. stop bit. SM0 0 SM1 0 FUNCTION Serial Mode 0 55 . SM1 SM0 and SM1 are D7 and D6 of the SCON register.0 Serial port mode specifier Serial port mode specifier Used for multiprocessor communication. TB8. Must be cleared by SM0. These two bits determine the framing of data by specifying the number of bits per character and the start and stop bits.3 SCON. and RB8=0. respectively. Must be cleared by software. SCON.4 SCON.7 SCON. Set by hardware halfway through the stop bit time mode 1. Receive interrupt flag. The following describes various bits of the SCON register.
MODE 0 In mode 0. and 1 start bit. serial mode 1 allows the baud rate to be variable and is set by Timer 1 of the 8051. when serial mode 1 is chosen. On transmit.In fact. TRANSMIT Data transmission in form of pulse train automatically starts on the pin RXD at the moment the data has been written to the SBUF register. only mode 1 is of interest to us. followed by 8 bits of data. 1 start bit Serial Mode 2 Serial Mode 3 Of the 4 serial modes. In serial mode 1. where the first bit is the start bit. The bout rate is fixed at 1/12 the quartz oscillator frequency. and finally 1 stop bit. 1 stop bit. which makes it compatible with the COM port of IBM/compatible PCs. this process starts after any instruction being performed on this register. the data are transferred through the RXD pin. 8-bit data. 1 stop bit. In the SCON register. the data framing is 8 bits. (received). for each character a total of 10 bits are transferred. Upon all 8 bits have been sent.0 1 1 1 0 1 Serial Mode 1. the bit TI in the SCON register is automatically set. the least significant bit (LSB bit) is being sent/received first. while clock pulses appear on the TXD pin. More importantly. RECEIVE 56 .
there are no START and STOP bits or any other bit except data from the SBUF register. which indicates that one byte is received. A typical example for this is I/O port extension by adding cheap IC circuit ( shift registers 74HC595. 74HC597 and similar). Since. Upon 8 bits have been received. Mode 1 57 . the bit RI (register SCON) is automatically set.Starts data receiving through the pin RXD once two necessary conditions are met: bit REN=1 and RI=0 (both bits reside in the SCON register). this mode is mainly used on shorter distance where the noise level is minimal and where operating rate is important.
8 data bits (LSB first) and a STOP bit (always 1) last.In Mode1 10 bits are transmitted through TXD or received through RXD in the following manner: a START bit (always 0). The START bit is not registered in this pulse train. 58 . End of 1 byte transmission is indicated by setting the TI bit in the SCON register. TRANSMIT A sequence for data transmission via serial communication is automatically started upon the data has been written to the SBUF register. On receive the STOP bit is automatically written to the RB8 bit in the SCON register. Its purpose is to start data receiving mechanism.
59 . For our applications. The condition is that bit REN=1and bit RI=0. By making REN=0. The Baud rate in this mode is determined by the timer 1 overflow time.4”. REN The REN (receive enable) bit is D4 of the SCON register.4” and “CLR SCON. REN must be set to 1. As a result if we want the 8051 to both transfer and receive data. we will make SM2=0 since we are not using the 8051 in a multi processor environment. When the REN bit is high. it allows the 8051 to receive data on the RXD pin of the 8051.4 since SCON is a bit-addressable register.RECEIVE Receiving starts as soon as the START bit (logic zero (0)) appears on the pin RXD. MODE 2 SM2 SM2 is the D5 bit of the SCON register. respectively. This bit can be used to block any serial data reception and is an extremely important in the SCON register. the receiver is disabled. Both of them are stored in the SCON register. The REN bit is also referred to as SCON. Notice that these instructions use the bit-addressable features of the register SCON. Making REN=1 or REN=0 can be achieved by the instructions “SETB SCON. The RI bit is automatically set upon receiving has been completed. This bit enables the multiprocessing capability of the 8051.
In all our applications we will make RB8=0. Like TB8. The TI bit is raised at the beginning of the stop bit. In serial mode 1. we make TB8=0 since it is not used in our applications. RB8 RB8 (receive bit 8) is bit D2 of the SCON register.TB8 TB8 (transfer bit 8) is bit D3 of SCON. it raises the TI flag to indicate that it is ready to transfer another byte. When the 8051 finishes the transfer of the 8-bit character. TRANSMIT TI (transmit interrupt) is bit D1 of the SCON register. this bit gets a copy of the stop bit when an 8-bit data is received. the RB8 bit is also used in serial modes 2 and 3. 60 . This is an extremely important flag bit in the SCON register. This is (as is the case for TB8) is rarely used anymore. It is used for serial modes 2 and 3.
RI is raised halfway through the stop bit. In Mode 3 is variable and can be selected. Mode 3 Mode 3 is the same as Mode 2 except the baud rate. 61 . When the 8051 receives data serially via RXD. This is another extremely important flag bit in the SCON register.RECEIVE RI (receive interrupt) is the D0 of the SCON register. Then it raises the RI flag bit to indicate that a byte has been received and should be picked up before it is lost. it gets rid of the start and stop bits and places the byte in the SBUF register.
FLOW CHART: TX Loop: START Initialization: Load SFRs with Respective values Copy data into Accumulator (or) memory location Copy into SBUF Is TI = = 1 Clr TI STOP RX Loop: START Initialization: Load SFRs with Respective values Is RI = = 1 Clr RI ` Copy SBUF into M emory STOP 62 .
Let XClk Baud Rate For attaining 9600 baud Rate. Use a higher.frequency crystal. shown below.0592 Mhz (XClk / 12 / 16 / 2 / X ) So set the 2’s Complement of 3 in Timer 1 so that we can achieve 9600 baud rates. 2. SMOD GF1 GF0 PD IDL 63 . Change a bit in the PCON register. X can be calculated as = = 11. Note: Assuming 8-bit Auto reload mode and 8-bit variable baud rate modes.BAUD RATE CALCULATION: Internal timer stages are as fallows XClk Divided by 12 Divided by 32 Divided by X Baud Rate UART Divided by X box can be replaced with T1 timer so that by changing the value of timer we can obtain the required baud rate. Doubling the baud rate in the 8051: There are two ways to increase the baud rate to data transfer in the 8051. 1.0592 x 106 / 12 / 16 / 2 / 9600 3 = = 11.
The following sequence of instructions must be used to set high D7 of PCON. and some are used for the power control capability of the 8051. Therefore. This is done with the register called PCON (power control). changing any other bits To see how the baud rate is double with this method. Of the 8 bits. This has been the basis of all the examples so far since it is the default when the 8051 is powered up. In the case of XTAL=11.0592MHZ we have: Machine cycle freq. The PCON register is an 8bit register. there is a software way to double the baud rate of the 8051 while the crystal frequency is fixed.6KHz And 921. We can set it to high by software and thereby double the baud rate. More Importantly. When the SMOD bit (D7 of the PCON register) is set to 1. we show the role of the SMOD bit (D7 bit of the PCON register). place a copy a of PCON in ACC SETB ACC. we can double the baud rate by making SMOD=1.Option1 is not feasible in many situations since the system crystal is fixed. we will explore option2.800 Hz since SMOD=0 This is the frequency used by Timer 1 to set the baud rate. Baud rates for SMOD = 1 With the fixed crystal frequency. The bit that is used for the serial communication is D7. When the 8051 is powered up. 1/12 of XTAL is 64 . we discuss each case. Baud rates for SMOD =0 When SMOD=0.6 KHz/32 = 28. D7 (SMOD) of this PCON register is zero. The baud rate for SMOD=0 was listed in above table. which can be 0 or 1. A . since it is not a bitaddressable register: MOV A. the SMOD (serial mode) bit.0592 MHz/12 = 921. it is not feasible because the new crystal may not be compatible with the IBM PC serial COM port’s baud rate. the 8051 divides 1/12 of the crystal frequency by 32 and uses that frequency for Timer 1 to set the baud rate. some are unused.=11. PCON . make D7=1 MOV PCON.7 .
600 Hz since SMOD = 1 This is the frequency used by Timer 1 to set the baud rate. Three of these are generated automatically by the internal operations: Timer flag 0. and the Timer Control (TCON) register.200 9.200 Note: XTAL=11.800 2.e.0592 MHz. given priority or otherwise controlled by altering the bits in the Interrupt Enabled (IE) register. It is generated when a high is applied to the reset pin. the registers are loaded with the default values.0592 MHz.400 -24 E8 1. 65 . baud rates are doubled when SMOD=1.0592 MHz / 12 = 921. Table: Baud Rate comparison for SMOD = 0 and SMOD = 1 TH1 (Decimal) (Hex) SMOD = 0 -3 FD 9. Timer Flag 1. SMOD = 1 19. the INTERRUPTS: Interrupts are hardware signals that are used to determine conditions that exist in external and internal circuits.800 -12 F4 2. Five interrupts are provided in the 8051.6 KHz And 921. we have: Machine cycle freq. These interrupts are mask able i. and the serial port interrupt (RI or TI) Two interrupts are triggered by external signals provided by the circuitry that is connected to the pins INTO 0 and INTO1. In the case of XTAL=11.600 -6 FA 4. however. Interrupt Priority (IP) register.600 4.400 Table: shows that the values loaded into TH1 are the same for both cases. Any interrupt can cause the 8051 to perform a hardware call to an interrupt –handling subroutine that is located at a predetermined absolute address in the program memory. = 11. Reset is a non maskable interrupt which has the highest priority. they can be disabled.divided by 16 (instead of 32) and that is the frequency used by Timer 1 to set the baud rate.6 KHz / 16 = 57. . Upon reset. The interrupts maybe enable or disabled.
Sends appropriate information to the display unit as per status 66 . 3. 6. Sends command to the modem for dialing the base every 80 sec.Each interrupt source causes the program to do store the address in PC onto the stack and causes a hardware call to one of the dedicated addresses in the program memory. 2. 5. Sends data in a serial manner to MODEM. 4. Collects the output of ADC for every 10 sec and stores in buffer. the communication medium. The appropriate memory locations for each for each interrupt are as follows: Interrupt RESET IE0 (External interrupt 0) TF0 (Timer 0 interrupt) IE1 (External interrupt 1) TF1 (Timer 1 interrupt) SERIAL Functions of micro controller in main unit are 1. After data gets transmitted sends command for disconnection. of Address 0000 0003 000B 0013 001B 0023 Sends appropriate commands to ADC to start conversion.
in a broad sense. but gravity is also used commonly in industrial motor starters. If the coil is energized with DC. which increases the minimum pull on the armature during the AC cycle. It was invented by Joseph Henry in 1835. the switch is operated by an electromagnet to open or close one or many sets of contacts. this is to reduce noise. Most relays are manufactured to operate quickly. Some automotive relays already include that diode inside the relay case. to dissipate the energy from the collapsing magnetic field at deactivation. the armature is returned by a force approximately half as strong as the magnetic force to its relaxed position. When the current to the coil is switched off. this is to reduce arcing.RELAY: A relay is an electrical switch that opens and closes under the control of another electrical circuit. If the coil is designed to be energized with AC. Operation When a current flows through the coil. Alternatively a contact protection network. the resulting magnetic field attracts an armature that is mechanically linked to a moving contact. which would otherwise generate a spike of voltage and might cause damage to circuit components. To achieve electrical isolation an optocoupler can be used which is a light-emitting diode (LED) coupled with a photo transistor. may absorb the surge. The movement either makes or breaks a connection with a fixed contact. it can be considered to be. consisting of a capacitor and resistor in series. a form of an electrical amplifier. By analogy with the functions of the original electromagnetic device. 67 . In a low voltage application. In the original form. In a high voltage or high current application. Usually this is a spring. a diode is frequently installed across the coil. This "shading ring" creates a small out-of-phase current. Because a relay is able to control an output circuit of higher power than the input circuit. a solid-state relay is made with a thyristor or other solid-state switching device. a small copper ring can be crimped to the end of the solenoid.
the first pulse to the coil turns the relay on and the second pulse turns it off. In the ratchet and cam example. while it is being switched. In the two coil example. which protects the contacts against atmospheric corrosion. or with a remnant core. Reed relays are capable of faster switching speeds than larger types of relays. and it retains its last setting across a power outage. This is achieved with a solenoid operating a ratchet and cam mechanism. the relay remains in its last state. The contacts are closed by a magnetic field generated when current passes through a coil around the glass tube. These are also called 'keep' relays.Types of relay Small relay as used in electronics Latching relay A latching relay has two relaxed states (bistable). 68 . See also reed switch. a pulse to one coil turns the relay on and a pulse to the opposite coil turns the relay off. This type of relay has the advantage that it consumes power only for an instant. Reed relay A reed relay has a set of contacts inside a vacuum or inert gas filled glass tube. or by having two opposing coils with an over-center spring or permanent magnet to hold the armature and contacts in position while the coil is relaxed. but have low switch current and voltage ratings. When the current is switched off.
Polarized relays were used in middle 20th Century telephone exchanges to detect faint pulses and correct telegraphic distortion. Machine tool relay A machine tool relay is a type standardized for industrial control of machine tools. See also mercury switch.Mercury-wetted relay A mercury-wetted reed relay is a form of reed relay in which the contacts are wetted with mercury. the programmable logic controller mostly displaced the machine tool relay from sequential control applications. and a form factor that allows compactly installing many relays in a control panel. Polarized relay A Polarized Relay placed the armature between the poles of a permanent magnet to increase sensitivity. The unavoidable arcing 69 . the contacts are made with pure silver. They are characterized by a large number of contacts (sometimes extendable in the field) which are easily converted from normally-open to normally-closed status. or for high-speed counting and timing applications where the mercury eliminates contact bounce. these relays are rarely specified for new equipment. Mercury wetted relays are positionsensitive and must be mounted vertically to work properly. Such relays are used to switch low-voltage signals (one volt or less) because of its low contact resistance. transfer machines. With high current. Although such relays once were the backbone of automation in such industries as automobile assembly. Contactor relay A contactor is a very heavy-duty relay used for switching electric motors and lighting loads. The poles were on screws. Because of the toxicity and expense of liquid mercury. and other sequential control. so a technician could first adjust them for maximum sensitivity and then apply a bias spring to set the critical current that would operate the relay. easily replaceable coils.
or where a solder pot melts. Transistortransistor logic (TTL) sources. Solid state contactor relay 25 amp or 40 amp solid state contactors A solid state contactor is a very heavy-duty solid state relay. Contactor relays can be extremely loud to operate. Such devices are often used for motor starters. They are activated by AC control signals or DC control signals from Programmable logic controller (PLCs). or other microprocessor controls. PCs. which will alarm on slow accumulation of gas or shut down the transformer if gas is produced rapidly in the transformer oil. where frequent on/off cycles are required. small electric motors and lighting loads. making them unfit for use where noise is a chief concern. including the necessary heat sink. There are no moving parts to wear out and there is no contact bounce due to vibration. releasing a spring to operate auxiliary contacts. 70 . the coil is de-energized. Buchholz relay A Buchholz relay is a safety device sensing the accumulation of gas in large oil-filled transformers. The overload sensing devices are a form of heat operated relay where a coil heats a bi-metal strip. If the overload senses excess current in the load. A motor starter is a contactor with overload protection devices attached. used for switching electric heaters. These auxiliary contacts are in series with the coil.causes the contacts to oxidize and silver oxide is still a good conductor.
Compared to electromagnetic relays. the tradeoff came from the fact that every transistor has a small voltage drop across it. The heat generated by the motor current operates a bimetal strip or melts solder. increasing long-term reliability. If one set of contacts in the relay becomes immobilized. "captive contacts". Overload protection relay One type of electric motor overload protection relay is operated by a heating element in series with the electric motor . able to handle 100 to 1. releasing a spring to operate contacts. Forced-guided contacts are also known as "positive-guided contacts". or "safety relays". This collective voltage drop limited the amount of current a given SSR could handle. they may be falsely triggered by transients. Where the overload 71 . all of the linked contacts move together. which has no moving parts Solid-state relay A solid state relay (SSR) is a solid state electronic component that provides a similar function to an electromechanical relay but does not have any moving components. "locked contacts". As transistors improved.Forced-guided contacts relay A forced-guided contacts relay has relay contacts that are mechanically linked together. The function of forced-guided contacts is to enable the safety circuit to check the status of the relay. higher current SSR's.200 amps. no other contact of the same relay will be able to move. have become commercially available. With early SSR's. A solid state relay. so that when the relay coil is energized or de-energized.
It is also called a Form A contact or "make" contact. Pole & Throw Circuit symbols of relays. the circuit is disconnected when the relay is inactive. Since relays are switches. A relay will switch one or more poles. each of whose contacts can be thrown by energizing the coil in one of three ways: • Normally-open (NO) contacts connect the circuit when the relay is activated. a useful though crude compensation for motor ambient temperature is provided. "C" denotes the common terminal in SPDT and DPDT types.relay is exposed to the same environment as the motor. 72 . the terminology applied to switches is also applied to relays.
These have two pairs of terminals. A common terminal connects to either of two others. These have two terminals which can be connected or disconnected. • Change-over.Double Pole Single Throw.• Normally-closed (NC) contacts disconnect the circuit when the relay is activated. normally closed. It is also called a Form B contact or "break" contact. DPST . then it is called a Form D contact. such a relay has five terminals in total. such a relay has six terminals in total. Including two for the coil. or double-throw. It is ambiguous whether the pole is normally open or normally closed. If this type of contact utilizes a "make before break" functionality. contacts control two circuits: one normally-open contact and one normally-closed contact with a common terminal. It is ambiguous whether the poles are normally open. Including two for the coil. • The diagram on the package of a DPDT AC coil relay 73 . The following types of relays are commonly encountered: • SPST .Single Pole Single Throw. Equivalent to two SPST switches or relays actuated by a single coil. Including two for the coil.Single Pole Double Throw. or one of each. such a relay has four terminals in total. the circuit is connected when the relay is inactive. • SPDT . The terminology "SPNO" and "SPNC" is sometimes used to resolve the ambiguity. It is also called a Form C contact or "transfer" contact.
Quadruple Pole Double Throw. Often referred to as Quad Pole Double Throw. Equivalent to four SPDT switches or relays actuated by a single coil. These have four rows of change-over terminals. including the coil. as in the starter solenoid of an automobile.Double Pole Double Throw. The latter is often applied to control office lighting as the low voltage wires are easily installed in partitions. These have two rows of change-over terminals. fourteen terminals including the coil. or two DPDT relays. • • A DPDT AC coil relay with "ice cube" packaging • to isolate the controlling circuit from the controlled circuit when the two are at different potentials. for example when controlling a mains-powered device from a low-voltage switch. Equivalent to two SPDT switches or relays actuated by a single coil. Applications Relays are used: • to control a high-voltage circuit with a low-voltage signal. • QPDT .• DPDT . as in some types of modems. Such a relay has eight terminals. to detect and isolate faults on transmission and distribution lines by opening and closing circuit breakers (protection relays). which may be often moved as 74 . or 4PDT. In total. to control a high-current circuit with a low-current signal.
lengthening release time. The Ladder programming language is often used for designing relay logic networks. For longer time periods. a mechanical clockwork timer is installed.needs change. and Zuse Z3. Current flowing in the disk maintains magnetic field for a short time. Because relays are much more resistant than semiconductors to nuclear radiation. a dashpot is used. the boolean AND function is realised by connecting NO relay contacts in series. Zuse Z2. the OR function by connecting NO contacts in parallel. A very short (a fraction of a second) delay would use a copper disk between the armature and moving blade assembly. For example. Relays can be modified to delay opening or delay closing a set of contacts. Safety-critical logic. Relay application considerations A large relay with two coils and many sets of contacts. Before vacuum tubes and transistors. used in an old telephone switching system. • to perform logic functions. o • to perform time delay functions. 75 . For a slightly longer (up to a minute) delay. They may also be controlled by room occupancy detectors in an effort to conserve energy. Similar functions for NAND and NOR are accomplished using NC contacts. A dashpot is a piston filled with fluid that is allowed to escape slowly. See ARRA (computer). The change-over or Form C contacts perform the XOR (exclusive or) function. Harvard Mark II. The time period can be varied by increasing or decreasing the flow rate. such as the control panels of radioactive waste-handling machinery. they are widely used in safety-critical logic. relays were used as logical elements in digital computers. o Early computing.
outdoor. normally closed. there are two types.small relays switch a few amperes. changeover (double-throw) In the case of changeover. This style of relay can be manufactured two different ways. "Make before Break" and "Break before Make". panel mount. oil-splashresistant Mounting . relays for switchgear may have 125 V or 250 VDC coils. "sensitive" relays operate on a few milliamperes • • • Package/enclosure . The railroad still uses them to control railroad crossings. through-panel mount. large contactors are rated for up to 3000 amperes. • • Rating of contacts .machine-tool relays usually 24 VAC or 120 VAC. special high-voltage relays to about 15.normally open.000 V Coil voltage . rail mount. plug board. cover removed on one Selection of an appropriate relay for a particular application requires evaluation of many different factors: • Number and type of contacts . double-voltage for isolation between circuits. enclosure for mounting on walls or equipment 76 • . touch-safe.Several 30-contact relays in "Connector" circuits in mid 20th century 1XB switch and 5XB switch telephone exchanges. The old style telephone switch required Make-before-break so that the connection didn't get dropped while dialing the number.typical control relays rated 300 VAC or 600 VAC. explosion proof. alternating or direct current Voltage rating of contacts .sockets. automotive types to 50 VDC.open.
protective relays had wellestablished.where high speed is required "Dry" contacts . Unlike switching type relays with fixed and usually illdefined operating voltage thresholds and operating times. a relay including function 51 would be a timed overcurrent protective relay. For example. special quality assurance Expected mechanical loads due to acceleration . often with more than one coil. • • • • • • • • Protective relay A protective relay is a complex electromechanical apparatus. over-voltage.and under. auxiliary contacts. selectable. solenoid-type operators. with a score of individual electromechanical devices.• • Switching time .frequency.suppress arcing in very inductive circuits Coil protection . test buttons Regulatory approvals Stray magnetic linkage between coils of adjacent relays on a printed circuit board. telephone-relay style contacts. 77 . An important transmission line or generator unit would have had cubicles dedicated to protection. and phase-shifting networks to allow the relay to respond to such conditions as over-current. designed to calculate operating conditions on an electrical circuit and trip circuit breakers when a fault was found. over.when switching very low level signals. reverse power flow. special contact materials may be needed such as gold-plated contacts Contact protection . shaded-pole magnets. The various protective functions available on a given relay are denoted by standard ANSI Device Numbers. pilot lamps. using arrays of induction disks. and even distance relays that would trip for faults up to a certain distance away from a substation but not beyond that point. time/current (or other operating parameter) curves.some relays used in aerospace applications are designed to function in shock loads of 50 g or more Accessories such as timers. Such relays were very elaborate. operating and restraint coils.suppress the surge voltage produced when switching the coil current Isolation between coil circuit and contacts Aerospace or radiation-resistant testing.
78 . middle: reed switches.These protective relays provide various types of electrical protection by detecting abnormal conditions and isolating them from the rest of the electrical system by circuit breaker operation. The ANSI Device Designation Number is 50 for an Instantaneous over Current (IOC). When the relay operates. By combining several functions in one case. In a typical application the over current relay is used for over current protection. However. due to their very long life span. Top. connected to a current transformer and calibrated to operate at or above a specific current level. numerical relays also save capital cost and maintenance cost over electromechanical relays. Design and theory of these protective devices is an important part of the education of an electrical engineer who specializes in power systems. 51 for a Time over Current (TOC). bottom: reed relay Over current relay An "Over current Relay" is a type of protective relay which operates when the load current exceeds a preset value. Such relays may be located at the service entrance or at major load centers. Today these devices are nearly entirely replaced (in new designs) with microprocessor-based instruments (numerical relays) that emulate their electromechanical ancestors with great precision and convenience in application. one or more contacts will operate and energize a trip coil in a Circuit Breaker and trip (open) the Circuit Breaker. tens of thousands of these "silent sentinels" are still protecting transmission lines and electrical apparatus all over the world.
Distance relay It is a protective relay used to protect power transmission and distribution lines against different fault types. The relay monitors line impedance by measuring line voltage and current. Once a fault occurs, the voltage drops to zero and thus the measured impedance become less than the setting value ``reach``. As a result the relay issues a trip command
TRANSFORMER: A transformer is a device that transfers electrical energy from one circuit to another through inductively coupled electrical conductors. A changing current in the first circuit (the primary) creates a changing magnetic field; in turn, this magnetic field induces a changing voltage in the second circuit (the secondary). By adding a load to the secondary circuit, one can make current flow in the transformer, thus transferring energy from one circuit to the other. The secondary induced voltage VS is scaled from the primary VP by a factor ideally equal to the ratio of the number of turns of wire in their respective windings: By appropriate selection of the numbers of turns, a transformer thus allows an alternating voltage to be stepped up — by making NS more than NP — or stepped down, by making it less. Transformers are some of the most efficient electrical 'machines', with some large units able to transfer 99.75% of their input power to their output. Transformers come in a range of sizes from a thumbnail-sized coupling transformer hidden inside a stage microphone to huge units weighing hundreds of tons used to interconnect portions of national power 79
grids. All operate with the same basic principles, though a variety of designs exist to perform specialized roles throughout home and industry. Applications A key application of transformers is to reduce the current before transmitting electrical energy over long distances through wires. Most wires have resistance and so dissipate electrical energy at a rate proportional to the square of the current through the wire. By transforming electrical power to a high-voltage, and therefore low-current form for transmission and back again afterwards, transformers enable the economic transmission of power over long distances. Consequently, transformers have shaped the electricity supply industry, permitting generation to be located remotely from points of demand. All but a fraction of the world's electrical power has passed through a series of transformers by the time it reaches the consumer Basic principles The transformer is based on two principles: first, that an electric current can produce a magnetic field (electromagnetism) and, second, that a changing magnetic field within a coil of wire induces a voltage across the ends of the coil (electromagnetic induction). By changing the current in the primary coil, one changes the strength of its magnetic field; since the changing magnetic field extends into the secondary coil, a voltage is induced across the secondary.
An ideal step-down transformer showing magnetic flux in the core A simplified transformer design is shown to the left. A current passing through the primary coil creates a magnetic field. The primary and secondary coils are wrapped around a core of very high magnetic permeability, such as iron; this ensures that most of
the magnetic field lines produced by the primary current are within the iron and pass through the secondary coil as well as the primary coil. Induction law The voltage induced across the secondary coil may be calculated from Faraday's law of induction, which states that: where VS is the instantaneous voltage, NS is the number of turns in the secondary coil and Φ equals the total magnetic flux through one turn of the coil. If the turns of the coil are oriented perpendicular to the magnetic field lines, the flux is the product of the magnetic field strength B and the area A through which it cuts. The area is constant, being equal to the cross-sectional area of the transformer core, whereas the magnetic field varies with time according to the excitation of the primary. Since the same magnetic flux passes through both the primary and secondary coils in an ideal transformer, the instantaneous voltage across the primary winding equals Taking the ratio of the two equations for VS and VP gives the basic equation for stepping up or stepping down the voltage Ideal power equation
The ideal transformer as a circuit element If the secondary coil is attached to a load that allows current to flow, electrical power is transmitted from the primary circuit to the secondary circuit. Ideally, the transformer is perfectly efficient; all the incoming energy is transformed from the primary circuit to the magnetic field and thence to the secondary circuit. If this condition is met, the incoming electric power must equal the outgoing power
Pincoming = IPVP = Poutgoing = ISVS giving the ideal transformer equation Thus, if the voltage is stepped up (VS > VP), then the current is stepped down (IS < IP) by the same factor. In practice, most transformers are very efficient (see below), so that this formula is a good approximation. The impedance in one circuit is transformed by the square of the turns ratio. For example, if an impedance ZS is attached across the terminals of the secondary coil, it appears to the primary circuit to have an impedance of . This relationship is reciprocal, so that the impedance ZP of the primary circuit appears to the secondary to be . Detailed operation The simplified description above avoids several complicating factors, in particular the primary current required to establish a magnetic field in the core, and the contribution to the field due to current in the secondary circuit. Models of an ideal transformer typically assume a core of negligible reluctance with two windings of zero resistance. When a voltage is applied to the primary winding, a small current flows, driving flux around the magnetic circuit of the core.. The current required to create the flux is termed the magnetizing current; since the ideal core has been assumed to have near-zero reluctance, the magnetizing current is negligible, although a presence is still required to create the magnetic field. The changing magnetic field induces an electromotive force (EMF) across each winding.  Since the ideal windings have no impedance, they have no associated voltage drop, and so the voltages VP and VS measured at the terminals of the transformer, are equal to the corresponding EMFs. The primary EMF, acting as it does in opposition to the primary voltage, is sometimes termed the "back EMF". This is due to Lenz's law which states that the induction of EMF would always be such that it will oppose development of any such change in magnetic field 82
The AMF Control Panel is a specially designed panel for standby generators. It consists of a state of the art microcontroller based AMF controller for monitoring, indicating and controlling the Mains and Generator for AMF operation. The AMF Control Panel can be operated in following modes: •AUTO In this mode the AMF controller takes command of the total system operation. Sequence of operation: i.] At power ON, if Mains is healthy the Mains contactor is turned ON and load gets power from Mains. ii]. If Mains is unhealthy or if the load is above the rated voltage of the transformer; the controller starts the generator and transfers the load on the generator (In this project we are using transformer). iii.] If the Mains recover or the load is below the rated voltage, the controller switches the load back onto Mains and shuts down the generator after cooling time.
•MANUAL In this mode the starting / stopping of the generator and load ON/OFF can be done manually from the AMF controller. In this mode if any fault occurs in the generator while running the AMF controller takes necessary action by indicating alarms and/or tripping the generator. •TEST this mode is used to check the health of the generator. In TEST mode the generator is started and kept ON for a fixed duration. During this period the AMF controller checks for any faults in the generator. If any fault is sensed the controller displays the same. If the generator is found healthy GENSET OK is indicated on the display. • BYPASS In BYPASS mode the AMF controller acts just as an indicating instrument. The system is 83
with sufficient current-handling capacity to maintain the operating conditions of the circuit. VCRs. but provide a lower voltage. The basic purpose of a power supply is to provide one or more fixed voltages to the working circuit. • HOLD INDICATIONS ON LCD DISPLAY The LCD display of AMF Controller indicates following parameters in scrolling mode: i.) Normal voltage POWER SUPPLY UNIT Introduction: When dealing with electronic circuits. The AMF controller in case of faults in this mode takes no action. Major electronic appliances such as television sets. The power source doesn't have to be fancy. Although each power supply has its own individual specifications and characteristics. Without that power.operated from the external switches provided on the Control Panel.) Over Voltage ii. We'll look at the main parts of 84 . A flashlight uses cells that are physically much larger. and microwave ovens have electronic circuits built in that take power from a wall socket and convert it to the form and voltages required by the other internal circuits of the appliance. we have to meet the basic requirement of providing electrical power for them to work. all power supplies have certain characteristics in common. the typical handheld transistor radio uses a 9-volt battery as its power source. your circuit is no more useful or meaningful than a single raindrop in a hurricane.
Each of the sections serves one or more specific purposes. The transformer serves to convert the ac line voltage to a voltage level more appropriate to the needs of the circuit to be powered. Then. Most circuits require a considerably lower voltage. Therefore. the transformer provides electrical isolation between the ac line and the circuit being powered. However. as follows: Transformer: In general. and is rather expensive. which is an important safety consideration.a power supply on this page and see how they work together. At the same time. as shown in the block diagram below and to the right. while a few require higher voltages. we'll take a more detailed look at each of the parts we haven't seen before. on subsequent pages. but now of an appropriate magnitude for the circuit to be powered. and explore the major variations that are commonly used in modern power supplies. Depending on the requirements for a given power supply. 85 . a line transformer is generally large and heavy. The output of the transformer is still an ac voltage. some power supplies (notably for PCs) are deliberately designed to operate directly from the ac line without a line transformer. the ac line voltage present in your house wiring is not suitable for electronic circuits. the sections can be very simple or extremely complex. or even left out altogether in certain circumstances. The Main Sections: A basic power supply consists of three main sections.
we insert a circuit to store energy during each voltage peak. In the remaining pages in this group. The goal of any power supply design is to reduce the ripple factor as much as possible. There are many different rectifier configurations that may be used according to the requirements of the circuit. and its job is to reduce the pulses from the rectifier to a much smaller ripple voltage. or ripple. and the circuit that accomplishes the task is the rectifier. The ratio of ac voltage to dc voltage is known as the ripple factor. The output of the rectifier is a pulsating dc. or pick different trade-offs between possible alternatives. However. preventing the alternations that occur in the transformer and the ac line. or at least to the point where the load circuit will not be adversely affected by the remaining ac ripple voltage.Rectifier: The next step is to force current to flow in one direction only. Each of the three sections identified above can have a number of variations — even the transformer. The pulsations typically vary from 0 volts to the peak output voltage of the transformer. we compare the magnitude of the remaining ac component. and then release it to the load when the rectifier output voltage drops. No filter configuration can be absolutely perfect. but a properly designed filter will provide a dc output voltage with only a small ac ripple. Regardless of these variations. Filter: The pulsating dc from the rectifier is generally still not suitable to power the actual load circuit. we will examine typical circuits and variations used for rectifiers and filters. which we covered in an earlier page on transformers. This circuit is called a filter. Therefore. which still has some of the variations from the ac line and transformer. with the dc component of the total voltage appearing at the output of that section. some circuits do the job more effectively than others. This process is known as rectification. 86 . To measure the effectiveness of each circuit. each section performs its specific task. and compare their performance.
As we have noted when looking at the Elements of a Power Supply. The circuit required to do this may be nothing more than a single diode. Because these circuits operate on the entire incoming ac wave. The resulting waveform is shown to the right. and modifies it so that the output current flows only in one direction. all rectifier circuits may be classified into one of two categories. Such circuits are known as half-wave rectifiers because they only work on half of the incoming ac wave. However. That is. Full-Wave Rectifiers: The more common approach is to manipulate the incoming ac wave so that both halves are used to cause output current to flow in the same direction. they are known as full-wave rectifiers. as follows: Half-Wave Rectifiers: An easy way to convert ac to pulsating dc is to simply allow half of the ac cycle to pass. The figure to the right shows the resulting output. it takes current that flows alternately in both directions as shown in the first figure to the right. or it may be considerably more complex. 87 . the purpose of the rectifier section is to convert the incoming ac from a transformer or other ac power source to some form of pulsating dc. as shown in the second and third figures below. while blocking current to prevent it from flowing during the other half cycle.
this is a basic halfwave rectifier. If the diode were to be reversed. the negative half-cycle would be passed instead. where vp is the peak voltage output from the transformer secondary winding. Since a diode passes current in only one direction. The orientation of the diode matters. In either case. it passes only the positive half-cycle of the ac input. so the output voltage contains a positive dc component. Thus.Rectifier circuits may also be further classified according to their configuration. The Half-Wave Rectifier: The simplest rectifier circuit is nothing more than a diode connected in series with the ac input. and the dc component of the output would have a negative polarity. 88 . only half of the incoming ac wave will reach the rectifier output. as we will see below. as shown.3183vp. as shown to the right. the DC component of the output waveform is vp/ = 0.
It is typically connected to the common ground of the overall circuit. it isn't very efficient. It only uses half of the incoming ac cycle. and wastes all of the energy available in the other half. Note that in all cases. The Full-Wave Rectifier: While the half-wave rectifier is very simple and does work. This can be very important in some applications. as shown in the second figure to the right.It is also quite possible to use two half-wave rectifiers together. This arrangement provides both positive and negative output voltages. the lower transformer connection also serves as the common reference point for the output. we would like to be able to utilize both halves of the incoming ac. The transformer windings are of course electrically insulated from the iron core. For greater efficiency. By also grounding one end of the secondary winding. One way to accomplish this is to double the size of the secondary winding 89 . we help ensure that this winding will never experience even momentary voltages that might overload the insulation and damage the transformer. with each output utilizing half of the incoming ac cycle. and that core is normally grounded by the fact that it is bolted physically to the metal chassis (box) that supports the entire circuit.
Because both half-cycles are being used. without large intervals when no energy is provided at all. rather than positive. to provide full-wave rectification. 90 . At the same time. however. where vp is the peak voltage output from half the transformer secondary winding. the full-wave rectifier is more efficient than the half-wave rectifier.6366vp. The circuit is shown to the right. a full-wave rectifier providing only a single output polarity does require a secondary winding that is twice as big as the halfwave rectifier's secondary. because only half of the secondary winding is providing power on any one half-cycle of the incoming ac. The full-wave rectifier can still be configured for a negative output voltage. Therefore. In this case. because only half is being used at a time. Then we can use two separate half-wave rectifiers on alternate half-cycles. however. the DC component of the output waveform is now 2vp/ = 0.and provide a connection to its center. it is the center connection. calls for one of the transformer's secondary leads to be grounded. This rectifier configuration. The full-wave rectifier passes both halves of the ac cycle to either a positive or negative output. as shown to the right. it is quite possible to use two full-wave rectifiers to get outputs of both polarities at the same time. This makes more energy available to the output. In addition. generally known as the center tap on the secondary winding. like the half-wave rectifier.
and this rectifier circuit is similarly known as a bridge rectifier. The only change is that we have removed the center tap on the secondary winding. With power being provided on both half-cycles. The Full-Wave Bridge Rectifier: The four-diode rectifier circuit shown to the right serves very nicely to provide fullwave rectification of the ac output of a single transformer winding.Actually. and used the negative output as our ground reference instead. This means that the transformer secondary is never directly grounded. In fact. If you compare this circuit with the dual-polarity full-wave rectifier above. one half-cycle doesn't have to provide enough power to carry the load past an unused half-cycle. Nevertheless. because the use of both half-cycles means that the current drain on the transformer winding need not be as heavy. there are some occasions when we would like to be able to use the entire transformer winding at all times. you'll find that the connections to the diodes are the same. any set of components in this configuration is identified as some sort of bridge. and still get full-wave rectification with a single output polarity. it isn't all that bad. 91 . The diamond configuration of the four diodes is the same as the resistor configuration in a Wheatstone Bridge.
Therefore. We can replace the resistor with any other circuit. the resistor. including more power supply circuitry (such as the filter). through D3 which is forward biased. Therefore. the transformer pushes electrons from its bottom end. CURRENT TRANSFORMER 92 . consider the figure to the right. Here we have placed a simple resistor as the load.but one end or the other will always be close to ground. In this manner. electrons move through D1. shown in red. Now. During the negative half-cycle. D1 and D4 are reverse biased. the top end of the transformer winding is negative. This is not usually a problem in modern circuits. To understand how the bridge rectifier can pass current to a load in only one direction. through a forward-biased diode. so current can indeed flow. During the positive half-cycle. As with the positive half-cycle. D1 and D4 are forward biased. and still see the same behavior from the bridge rectifier. and D2 and D3 are reverse biased. the diodes keep switching the transformer connections to the resistor so that current always flows in only one direction through the resistor. At the same time. electrons move through the resistor from left to right. so they do not conduct any current. and we have numbered the four diodes so we can identify them individually. the top end of the transformer winding is positive with respect to the bottom half. This forms a complete circuit. and D4 in the direction shown by the blue arrows. and from there to the top of the transformer winding. Electrons then continue through the forward-biased D2. and through the load resistor in the direction shown by the red arrows.
a magnetic core. A primary objective of current transformer design is to ensure that the primary and secondary circuits are efficiently coupled. are known as instrument transformers. a current transformer (CT) is used for measurement of electric currents. The most common design of CT consists of a length of wire wrapped many times around a silicon steel ring passed over the circuit being measured. a current transformer has a primary winding. Current transformers.In electrical engineering. so that the secondary current bears an accurate relationship to the primary current. and a secondary winding. which can be conveniently connected to measuring and recording instruments. together with voltage transformers (VT) (potential transformers (PT)). which then induces a current in the secondary winding circuit. with a secondary of many hundreds of 93 . a current transformer produces a reduced current accurately proportional to the current in the circuit. Current transformers are commonly used in metering and protective relays in the electrical power industry. Design Like any other transformer. The alternating current flowing in the primary produces a magnetic field in the core. The CT's primary circuit therefore consists of a single 'turn' of conductor. When current in a circuit is too high to directly apply to measuring instruments. A current transformer also isolates the measuring instruments from what may be very high voltage in the monitored circuit.
The secondary winding can be single ratio or multi ratio. slight inaccuracies may occur. of the CT should be of low resistance. which can have circuit cables run through the middle of an opening in the core to provide a single-turn primary winding. When conductors passing through a CT are not centered in the circular (or oval) opening. with a heavy copper bar to carry current through the magnetic core. or burden. The primary circuit is largely unaffected by the insertion of the CT. Usage 94 . The primary winding may be a permanent part of the current transformer.turns. Some CT configurations slip around the bushing of a high-voltage transformer or circuit breaker. High-voltage current transformers are mounted on porcelain bushings to insulate them from ground. Typical examples of low voltage single ratio metering current transformers are either ring type or plastic moulded case. the core goes into saturation towards the end of each cycle. If the voltage time integral area is higher than the core's design rating. Window-type current transformers are also common. Current transformers used in metering equipment for three-phase 400 ampere electricity supply Shapes and sizes can vary depending on the end user or switchgear manufacturer. distorting the waveform and affecting accuracy. a 4000:5 CT would provide an output current of 5 amperes when the primary was passing 4000 amperes. The load. The rated secondary current is commonly standardized at 1 or 5 amperes. which automatically centers the conductor inside the CT window. with five taps being common for multi ratio CTs. For example.
and allows current transformers with different characteristics (accuracy. For example. The CT is typically described by its current ratio from primary to secondary. Safety precautions Care must be taken that the secondary of a current transformer is not disconnected from its load while current is flowing in the primary.Current transformers are used extensively for measuring current and monitoring the operation of the power grid. multiple CTs are installed as a "stack" for various uses. Along with voltage leads. The high voltage produced will compromise operator and equipment safety and permanently affect the accuracy of the transformer. Often. What Are the Functions of a Current Transformer? What Are the Functions of a Current Transformer? 95 . This will produce a high voltage across the open secondary (into the range of several kilovolts in some cases). revenue-grade CTs drive the electrical utility's watt-hour meter on virtually every building with three-phase service and single-phase services greater than 200 amp. as the transformer secondary will attempt to continue driving current across the effectively infinite impedance. protection devices and revenue metering may use separate CTs to provide isolation between metering and protection circuits. which may cause arcing. overload performance) to be used for the different purposes.
to another coil in a different circuit. Relation to Voltage Transformer 1. nearly undiminished. Also. effectively. CT & VT Formulae 96 . The difference with a CT is that the circuit with power has.A current transformer (CT) is a transformer which measures the current of another circuit. Measuring high-voltage current directly would require insertion of measuring instrumentation into the measured circuit--an unnecessary difficulty which would draw down the very current meant to be measured. The powered circuit goes through the iron core only once. Voltage Transformer The function of a current transformer (CT) can be understood better by comparing it to the more commonly known voltage transformer (VT). which spreads the magnetic field. The coil is wrapped around an iron core. A CT is. the heat generated in the measuring equipment from the high current could give false readings. a step-up transformer. one without a power source. Measuring current indirectly with a CT is much more practical. It is coupled to an ammeter (A in the diagram) in its own circuit to perform this measurement. one loop. Recall that in a voltage transformer. an alternating current in one circuit sets up an alternating magnetic field in a coil in the circuit. therefore.
N1 = 1 for the primary in the case of the current transformer. the following formula is more appropriate: B = mu --. This is because for a coil (solenoid). where r is the distance of the center of the wire to the point where B is measured or sensed (the iron core. i1 is. where mu here means the magnetic permeability constant. B = mu --.2. therefore. However. merely proportional to the ammeter-measured value i2.i --. Solenoid Magnetic Field Recall also that the current and number of turns in the coils in a VT can be related as: i1 --. So i1/(2πr) = i2 --N2.N1 = i2 --.N2? No. For N1 = 1. Common Uses 3.n.i/(2πr).N2. reducing current measurement to a simple conversion. giving us i1 --N1 = i2 --N2. Electric Meter (Courtesy: Oak Ridge Nat'l Lab) 97 . in the transformer case). so the B equations for the two coils are effectively equal. Is the single power line effectively the equivalent of one loop? Does the last equation reduce to i1 = i2 --. Little intensity of B is lost from one coil to the other with a good iron core. because it was based on solenoid equations.
Another ubiquitous use of CTs is in domestic electric meters.com) 98 . as N2 in the formula i1/(2πr) = i2 --N2 goes up.blogspot. By increasing the number of (secondary) windings. the current in the CT can be made much smaller than the current in the primary circuit being measured. Protective Relays 5. CT Mounted Over Bushing of Circuit Recloser (Courtesy: emadrlc. Current Transformer (Courtesy: tradeindia. This is relevant because high current produces heat which can damage sensitive measuring equipment. N2. such as the resistor in an ammeter. This is especially useful for monitoring high-voltage lines throughout the power grid. Instrument Safety 4.com) Another function of CTs is protection of sensitive measuring equipment.The one central function of a CT is to determine the current in a circuit. It also prevents heat from throwing off the accuracy of the measurement. Reducing i2 protects the ammeter. i2 goes down. In other words. A CT is coupled with a meter to measure what electrical usage to charge the customer.
1 BASICS OF OPERATION Ratio A current transformer (henceforth called a CT) is designed to produce a secondary current.2 Rated Ratio x 5 99 . (OR) CURRENT TRANSFORMERS Basics of Operation and In-Service Testing 1. that is directly proportional to its primary current.CTs also protect the main lines of the power grid. 2. An overcurrent relay is a type of protective relay (switch) that trips a circuit breaker if a high-voltage current exceeds a certain preset value. Is. which is also called the load current. since the current of a high-voltage line could not be measured directly. Ip. Overcurrent relays use a CT to measure the current. 2. This paper presents the basics of operation of current transformers and discusses the in-service testing of current transformers to assure accurate performance. In metering this proportionality is called the ratio of the CT and is represented by: Ip Ratio = Is 2. INTRODUCTION Current transformers are used in electric metering for large load situations to reduce the current level presented to the metering circuit in order to make it more manageable and safe.
The CT manufacturer classifies its CT’s by its ratio value called the rated ratio which is stamped on the nameplate of the CT and that is the certified operating value of the CT.6 percent for the above-stated case. Hence a 200 to 5 rated ratio CT with a rating factor of 2 will remain within its accuracy certification up to 400 amps (200 amps times 2). 1. Voltage Transformers: 100 .00 amps it is certified to produce a secondary current between 2. Accuracy Class The CT accuracy is determined by its certified accuracy class which is also stamped on its nameplate. 3. Hence a CT with a rated ratio of 200 to 5 with accuracy class of 0. This over-range is designated by a rating factor representing the factor by which the upper limit of the primary current can be increased and still remain within certified accuracy.3.The ratio of a CT is referenced to a 5 amp secondary output for nominal full value input current such that a CT ratio of 200 to 5 means that the CT would produce a secondary current of 5 amps when exposed to a primary current of 200 amps.3 percent of its rated ratio value for a primary current of 100 percent of rated ratio. The accuracy is relatively linear between these two points. 2. For primary currents of 10 percent of rated ratio the specified accuracy for a given classification is double that of the 100 percent value or 0. 2. and 4. For example.511 amps. for a primary current of 100. a CT accuracy class of 0.4.5. called over-range. 2. Rating Factor Some CT’s are certified to be accurate for primary current values greater than 100 percent of the rated ratio.45 percent of its rated ratio value for a primary current of 100 amps. To be more explicit. Typical rating factors are 1.3 means that the CT is certified by the manufacturer to be accurate to within 0.489 amps and 2.3 would operate within 0. The rating factor of the CT is stamped on the nameplate of the CT.
Their role in electrical systems is of primary importance as they are a means of "stepping down" the current or voltage of a system to measurable values. • • Voltage transformers Current transformers Voltage transformers Principle of operation The standards define a voltage transformer as one in which "the secondary voltage is substantially proportional to the primary voltage and differs in phase from it by an angle which is approximately zero for an appropriate direction of the connections. together with equipment such as meters and relays. In a "practical" transformer. when multiplied by the turn’s ratio.Instrument transformers are used for measurement and protective application. In an "ideal" transformer. in essence. means that the voltage transformer has to be as close as possible to the "ideal" transformer. This offers the advantage that measurement and protective equipment can be standardized on a few values of current and voltage. errors are introduced because some current is drawn for the magnetization of the core and because of drops in the primary and secondary windings due to leakage reactance and winding resistance. and the phase error. the secondary voltage vector is exactly opposite and equal to the primary voltage vector. One can thus talk of a voltage error. which is the amount by which the voltage is less than the applied primary voltage. 101 . which is the phase angle by which the reversed secondary voltage vector is displaced from the primary voltage vector." This. such as 5A or 1A in the case of a current transformers or 110V or 100V in the case of a voltage transformer.
102 . The control word differentiated the various operations and is executed. Because of this port5 is made as input / output port depending on the situation.e. The data to be displayed on the LCD is to be sent in the ASCII format. The Micro controller has to send the necessary control words followed by the data to be displayed. Port0 can be basically used as I/O port i. suppose if it is required to read data from LCD immediately it is not possible. Before reading the data it is required to make the port as an input port.LIQUID CRYSTAL DISPLAY: The alphanumeric 16character X 2line LCD requires 8data lines and also 3 control signals. At different instance such as data write / command write / data read etc. Thus all the character to be displayed are converted into ASCII form and then sent to the LCD along with different control words. That means if it is programmed as output port. to the Micro controller it require an 8 bit and also three control signals differentiate the data from the control words send to the LCD. Depending on the operation to be performed the control words are selected and passes to the LCD. To interface the LCD. By using 2 ports. RW bar. port 0&3 data pins are connected to LCD as data bus. It is also possible to read the LCD data if required. it can be programmed as an input or as an output port. The control signals are connected to port 3 pins. Various signals are to be provided as indicated by the by the LCD manufacturers. They are EN bar & RS bar. Data reading from LCD gives an erroneous reading & should not be implemented.
There are two major types of LCD s which are: 1) Dynamic-scattering LCD s 2) Field-effect LCD s Field-effect LCD s are normally used in such applications where source of energy is a prime factor (e. However. It is limited to a temperature range of about 0C to 60C and lifetime is an area of concern. watches.7. the cost for field-effect units is 103 .. portable instrumentation etc. The soft ware and associated hardware perform the LCD interface. The Liquid Crystal Display (LCD) is a low power device. The remaining can be used for some other purpose if there is a need. However.5.).They absorb considerably less power than the light-scattering type. This is also done through pins 3.The control signals to the LCD are also provided by the Micro controller.3. because LCDs can chemically degrade. The power requirement is typically in the order of microwatts for the LCD.g. The software controls the necessary ports and performs the task it is designed for. an LCD requires an external or internal light source.Through program necessary control signals are passed to the LCD by using the bits of the port.6&3. LCD DISPLAY Gnd vcc preset rs rw en d0 d1 d2 d3 d4 d5 d6 d7 vcc Gnd A liquid crystal is a material (normally organic for LCDs) that will flow like a liquid but whose molecular structure has some properties normally associated with solids.
The liquid crystals can be manipulated through an applied electric voltage so that light is allowed to pass or is blocked.000+hours limit. Since the colour generated by LCD units is dependent on the source of illumination.The lifetime of LCD s is steadily increasing beyond 10. Other advances have allowed LCD’s to greatly reduce liquid crystal cell response times. LCD is a type of display used in digital watches and many portable computers. An electric current passed through the liquid causes the crystals to align so that light cannot pass through them. LCD technology has advanced very rapidly since its initial inception over a decade ago for use in laptop computers. reduce response times and cheaper manufacturing process. By carefully controlling where and what wavelength (color) of light is allowed to pass. The turn-on and turn-off time is an important consideration in all displays. there is a wide range of colour choice. This has been particularly important for improving LCD’s ability to display small-sized fonts and image clearly. Response time is basically the amount of time it takes for a pixel to 104 . the LCD monitor is able to display images. light-scattering units are available up to 8 inches in height. LCD displays utilize to sheets of polarizing material with a liquid crystal solution between them. Over the years many improvements have been made to LCD to help enhance resolution. The response time of LCD s is in the range of 100 to 300ms. Technical achievement has resulted in brighter displace. Field-effect LCD is used in the project for displaying the appropriate information. TFT-LCD’s make use of a very thin transistor that is applied to glass during acts as switch allowing control of light at the pixel level. On the other hand. A backlight provides LCD monitor’s brightness. One of the latest such advancements is TFT or Thin Film Transistor. greatly enhancing image sharpness and resolution. higher resolutions. image. sharpness and response times.typically higher. and their height is limited to 2 inches.
“change colors”. A 14pin access is provided having eight data lines. One of the. or a single row of 14 pins. This is due to following reasons: The declining prices of LCDs. The ability to display numbers. connected to it. 20 characters per line. Vee is used for controlling LCD contrast. either two rows of seven pins. and it is generally connected to metalwork at same point. pins are numbered on the LCD’s print circuit board (PCB). Vss and Vee While Vcc and Vss provide +5V and ground respectively. In reality response time is the amount of time it takes a liquid crystal cell to go from being active to inactive. PIN DIAGRAM Most of the LCD modules conform to a standard interface specification. LCD interfacing with 8052 is a real-world application. three control lines and three power lines. which are limited to numbers and a few characters. it often has a thicker PCB track. The connections are laid out in one of the two common configurations. In recent years the LCD is finding widespread use replacing LEDs (seven segment LEDs or other multisegment LEDs). but if not. characters and graphics. Since this pin is connected to ground. 105 . it is quite easy to locate pin1. This is in contrast to LEDs. that is interfaced to the 8051. PIN DESCRIPTIONS Vcc. An intelligent LCD display of two lines.
When data is supplied to data pins. R/W. 106 . To display letters and numbers. The 8-bit data pins. R/W=1 when reading. as follows: if R/W=1. D0-D7. This pulse must be a minimum of 450ns wide. Enable The LCD to latch information presented to its data pins uses the enable pin. allowing the user to send data to be displayed on the LCD. EN. the instruction command code register is selected. the LCD is busy taking care of internal operations and will not accept any information. allowing the user to send a command such as clear display.. We also use RS=0 to check the busy flag bit to see if the LCD is ready to receive information. R/W=0 when writing. a-z. When D7=1 (busy flag=1).RS=0. register select There are two very important registers inside the LCD. There are also instruction command codes that can be sent to the LCD to clear the display or force the cursor to the home position or blink the instruction command codes.RS. The busy flag is D7 and can be read when R/W=1 and RS=0. etc. read/write R/W input allows the user to write information to the LCD or read information from it. are used to send information to the LCD or read the contents of the LCD’s internal registers. a high-to-low pulse must be applied to this pin in order for the LCD to latch in the data present at the data pins. and numbers 0-9 to these pins while making RS=1. If RS=1 the data register is selected. The RS pin is used for their selection as follows. If RS=0. we send ASCII codes for the letters A-Z. cursor at home.
OPERATING INSTRUCTIONS INSTRUCTION CODE EXPLANATIONS The two registers 1) Instruction Register (IR) and the 2) Data Register (DR) in the KS0066 controller chip are directly controlled by the MPU. possibly only on part of display. which curiously has the display blanked off so that even if characters are entered.DB7) are polled instructions. before attempting to wire the two together.Basic commands of LCD: When LCD is powered up. It is therefore necessary to issue a command at this point. Internal operations of the KS0066 are determined from the signals sent from the MPU. This can be a quite beneficial step. some initial experiments can be performed by connecting a series of switches to the pins of the module. if even you are thoroughly conversant with the workings of microprocessors. and allows interface from peripheral control ICs. The display module resets itself to an initial state when power is applied. This allows interface to various types of MPUs which operate at different speeds from that of the KS0066. Read/Write (R/W) and data bus signals (DBO . a microprocessor or a micro controller is usually required to drive it. so the contrast control should be adjusted anti-clockwise until the squares are just visible. However. These signals. Control information is temporarily stored in these registers prior to internal operation start. Prototype circuit: For a LCD module to be used effectively in any piece of equipment. These characters are actually in their off state. including register selection signals (RS). 107 . they cannot be seen. the display should show a series of dark squares. to switch the display on.
2 and 4 line display. In other words.. If an Address Set instruction (for DD RAM or CG RAM) is written in the IR. Clear all display memory and return the cursor to the home position. except L4044 refer “clear display”: (Address 0. The contents of DD 108 . 2. First line first character blocks on all 1. the AC are output to DBO to DB6. If the above is entered on E2 (the second controller for lines 3 and 4). A. Returns cursor to home position. refer to above “Register Selection Table” when RS = 0 and R/W= 1. and 4 line character modules except L4044.6.Tab 6. the cursor will return to the first character on the third line. When display data is written into or read from DD RAM or CG RAM.1 Register Selection ADDRESS COUNTER (AC) The counter specifies an address when data is written into DD RAM or CG RAM and the data stored in DD RAM or CG RAM is read out. the cursor returns to the first character block on the first line on all 1. “80”). the address information is transferred from the IR to the AC.
RAM remain unchanged. The cursor automatically moves to the right when incremented by one or to the left if decremented by one. DISPLAY AND CURSOR ON/OFF CONTROL 109 . Display & Clear Instructions ENTRY MODE SET I/D: Increments (I/D = 1) or decrements (I/D = 0) the DD RAM address by one block when writing or reading a character code from DD RAM or CG RAM.
When S = 1 and I/D = 0 the display shifts one position to the right. Display is not shifted when S = 0. B: When B = 1. The blink is done by stitching between the all black dot matrix and displayed character at 0. If the cursor disappears. When display is OFF. S: Shifts the entire display to either the right or left when S = 1 (high). 5 X 7 DOT MATRIX C = 1 (cursor display) B = 1 (blinking) Cursor Conditions 110 . This right or left shift occurs after each data write to DD RAM. The cursor and the blink can be set at the same time (fosc = 250 kHz). When B = 0 the cursor does not blink. When S = 1 and I/D = 1 the display shifts one position to the left. In a 5 x 7 dot matrix there is an eighth line which functions as the cursor.D: Display is turned ON when D = 1 and OFF when D =0. Display is not shifted when reading from DD RAM. C: Cursor is displayed when C = 1 and not displayed when C = 0.4 second intervals. display data in DD RAM remains unchanged. Information comes back immediately when D = 1 is entered. function of I/D etc. the character at the cursor position starts blinking.
CURSOR OR DISPLAY SHIFT Cursor/Display Shift moves the cursor or shifts the display without changing the DD RAM contents. The cursor is shifted from character block 40 of line 3 to character block 1 of line 4. The cursor position and the AC contents match. In case of a 4-line display. This instruction is available for display correction and retrieval because the cursor position or display can be shifted without writing or reading display data. The display pattern of line 2 or 4 is not shifted to line 1 or 3. Displays of lines 3 and 4 are shifted at the same time. Displays of lines 1 and 2 are shifted at the same time. the cursor does not move continuously from line 2 to line 3. 111 . the cursor is shifted from character block 40 of line 1 to character block 1 of line 2. In case of a 2-line display.
which are common in the real world. The processing of signals is preferably carried out in the digital domain because digital processing is fast.ADC MODULE THEORY: ADC is short for Analog Digital Converter. from the analog domain to the digital domain where the signals are represented by numbers Most processing equipment today are digital in nature. Analog to digital converters allow the use of sophisticated digital signal processing systems to process analog signals. high definition digital television (HDTV). Circuits for performing these functions are now required in numerous common consumer devices such as digital cameras. Sometimes called a A-D or A to D Converter. (or) Analog to digital (A/D. which is composed of a finite number of bits. and video equipment such as digital video disk (DVD) players. movement. The signals that are monitored are sounds. Analog to digital converters are widely used for converting analog signals to corresponding digital signals for many electronic circuits. Many modern electronic systems require conversion of signals from analog to digital or from digital to analog form. Analog to digital converters (ADC's) form an essential link in the signal processing pathway at the interface between the analog and digital domains. such as voltages or currents. audio devices such as MP3 players. An ADC is a device that converts a continuous analog signal to a multi-level digital signal without altering its content. Advances in ADC technology have 112 . and temperature into binary code for the PC. cellular telephones. and they work with signals which are binary valued. a signal is represented by a word. In a digital or binary representation. ADC) converters are electrical circuit devices that convert continuous signals. wireless data network equipment. and numerous other products. accurate and reliable.
Quantizing means partitioning the analog signal range into a number of discrete quanta and determining to which quantum the input signal belongs. numbered consecutively. and resulted in a proliferation of ADC applications. The illustration shows a typical three-bit binary representation of a range of input signals. partitioned into eight quanta. lowered the cost. Conversion involves quantizing and encoding.increased the speed. the code is a set of n physical two-valued levels or bits (1 or 0) corresponding to the binary number associated with the signal quantum. and reduced the power requirements of analog to digital converters. For example. Encoding means assigning a unique digital code to each quantum and determining the code that corresponds to the input signal. • Cell phone and digital desk phone has an ADC converter that converts the pressure of sound waves into PCM code Etc. full scale (between 5/16 and 7/16) will be coded 011 (binary 3). in which there are 2n quanta (where n is some whole number). a signal in the vicinity of 3/8. A three-bit binary representation of a range of input signals. There are four commonly used ADC’s: • • • • Parallel converter Successive approximation ADC Voltage-to-Frequency ADC Integrating ADC Applications of ADC: • Digital camera or scanner uses A/D converters to transform the variable charges in CCD and CMOS chips into the binary data that represent pixels. 113 . The most common system is binary.
The 8-bit A/D converter uses successive approximation as the conversion technique. The device eliminates the need for external zero and full-scale adjustments. a 256R voltage divider with analog switch tree and a successive approximation register. The 8-channel multiplexer can directly access any of 8-single-ended analog signals. The converter features a high impedance chopper stabilized comparator. Features • • • • • • • • Easy interface to all microprocessors Operates ratio metrically or with 5 VDC or analog span adjusted voltage reference No zero or full-scale adjust required 8-channel multiplexer with address logic 0V to 5V input range with single 5V power supply Outputs meet TTL voltage level specifications ADC0808 equivalent to MM74C949 ADC0809 equivalent to MM74C949-1 Key Specifications • • • • • Resolution 8 Bits Total Unadjusted Error ±1⁄2 LSB and ±1 LSB Single Supply 5 VDC Low Power 15 mW Conversion Time 114 .ADC0808: This is 8-Bit µP Compatible A/D Converters with 8-Channel Multiplexer. Easy interfacing to microprocessors is provided by the latched and decoded multiplexer address inputs and latched TTL TRI-STATE outputs.8-channel multiplexer and microprocessor compatible Control logic. The ADC0808 data acquisition component is a monolithic CMOS device with an 8-bit analog-to-digital converter.
The data in the output latch can be then be read by the host system any time before the end of the next conversion. On the rising edge of this pulse the internal registers are cleared and on the falling edge the start conversion is initiated. This algorithm is executed 8 times per conversion. When the conversion cycle is complete the resulting data is loaded into the TRISTATE output latch. Based on the result of this comparison.FUNCTIONAL DESCRIPTION: The ADC0808 shown in figure can be functionally divided into 2 basic sub circuits. the control logic and the successive approximation register (SAR) will decide whether the next tap to be selected should be higher or lower than the present tap on the resistor ladder. depending on the data latched into a 3-bit multiplexer address register. The converter control logic controls the switch tree. C in and out pins. the START pin is pulsed. The output of the multiplexer goes to one of two comparator inputs. the successive approximation A/D converter. The TRI-STATE capability of the latch allows easy interfaces to bus oriented systems. To begin the conversion. a 3bit channel address is placed on the A. 115 . The controlling device first selects the desired input channel. The multiplexer uses 8 standard CMOS analog switches to provide to up to 8 analog inputs. The operation on these converters by a microprocessor or some control logic is very simple. These two sub circuits are an analog multiplexer and an A/D converter. The other input is derived from a 256R resistor ladder. transforms the analog output of the multiplexer to an 8-bit digital word. and the ALE input is pulsed positively. The second functional block. To do this. funneling a particular tap voltage to comparator. The switches are selectively turned on. clocking the address into the multiplexer address register. which is tapped by a MOSFET transistor switch tree. B. once every 8-clock period. yielding a total conversion time of clock periods.
Once EOC does go high this signals the interface logic that the data resulting from the conversion is ready to be read. is what the control logic is looking for. too. As long as the start pin is held high no conversion begins. there are 8 clock periods per approximation. which occurs at the end of a conversion. but this is not important. but when the start pin is taken low the conversion will start within 8 clock periods.Functional block diagram of ADC 116 . Figure shows the timing diagram. This enables the TRI-STATE outputs. so it will go low within 8 clock periods of the rising edge of the start pulse.As mentioned earlier. allowing the data to be read. One can see that it is entirely possible for EOC to go low before the conversion starts internally. The output enable(OE) is then raised high. A start pulse can occur any time during this cycle but the conversion will not actually begin until the converter internally cycles to the beginning of the next 8 clock period sequence. since the positive transition of EOC. It. Even though there is no conversion in progress the ADC0808 is still internally cycling through these 8 clock periods. The EOC output is triggered on the rising edge of the start pulse. C NR L O T O MX U ad ress d reg ister C N R LL G O T O O IC S R A 8x1 an alog MX U T I R SAE T T O tp t u u L atch Fig : . is controlled by the 8 clock period cycle.
PIN DIAGRAM: CONNECTION DIAGRAM: SC IN0 IN1 IN2 IN3 IN4 IN5 IN6 IN7 ALE EOC CHA CHB ADC EMBEDDED CONTROLLER CHC Data(D0-D7) 117 .
SC (Chip Selection): By using this selection Bit you can select the Chip. By using HIGH (1) you can select this pin as an active high. ALE is emitted at a constant rate of 1/6 the oscillator frequency. In normal operation. CHANNEL SELECTION: 118 . EOC (End of Conversion): After End of ADC Conversion EOC bit is set to high. and can be used for external timing or clocking. This pin is also the Program Pulse input (PROG) during Flash programming. After selecting this bit the chip is ready to do operation. so that the selected channel is activated. Note that one ALE pulse is skipped during each access to external data memory. ALE (Address Latch Enable): ALE is to enable address latch of ADC.
CHC) SET & CLEAR SC BIT TO INITIATE THE CHIP SET & CLEAR ALE BIT TO ENABLE THE ALE IS EOC=1 COPY THE ADC PORT DATA INTO MEMORY STOP 120 Set callCSF . CHB.FLOW CHART: START CONFIGURE PINS SELECT ADC CHANNEL (CHA.
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 In this project. if totally overload occurs then automatically all loads will be shutdown.CIRCUIT DESCRIPTION: This section gives an overview of the whole circuitry and hardware involved in the project. The relays will trips to another transformer upon exceeding the limit of load. Whenever applying the more loads on one transformer exceeding the particular limit then it will not broke down but the excess load must be shared by the another transformer. it basically consists of a Transformer to step down the 230V ac to 18V ac followed by diodes. This will be displayed as load status on the LCD display. we are using current transformer. In this project we are giving power supply to all units. In this project. it will measure the current of the loads. The ADC is an analog to digital converter which converts the values of analog current value to the digital value. 121 . Here. The aim of the project is to protect the failing or damage of transformers having applied more loads on it and to share these overloads with another transformer. we are using two transformers for sharing of power upon exceeding the loads. no failure of transformers will occurs. Therefore. Through the micro controller. we are using two transformers instead of one transformer. we are controlling this sharing of power with the help of relay. After rectification the obtained rippled dc is filtered using a capacitor Filter. A positive voltage regulator is used to regulate the obtained dc voltage. Here diodes are used to rectify the ac to dc.
Quick Function Navigation. and \ARM\. To help you get started. Tool configuration. What is µVision3? µVision3 is an IDE (Integrated Development Environment) that helps you write. 122 . • HELLO is a simple program that prints the string "Hello World" using the Serial Interface.SOFTWARE DESCRPITION: ABOUT SOFTWARE Software’s used are: *Keil software for C programming *Express PCB for lay out design *Express SCH for schematic design What's New in µVision3? µVision3 adds many new features to the Editor like Text Templates. A powerful debugger. Editor.\Examples) are provided.. \C251\Examples. and debug embedded programs. several example programs (located in the \C51\Examples. µ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. It encapsulates the following components: • • • • • A project manager. compile.. \C166\Examples. A make facility.
select Source Group1. 251.UV2).Select Device and select an 8051. and links the files in your project. you must: 1.Rebuild all target files or Build target. Files. Building an Application in µVision2 To build (compile. Select a directory and enter the name of the project file.New Project. assembles. Creating Your Own Application in µVision2 To create a new project in µVision2.166\EXAMPLES\HELLO\HELLO.Targets. Create source files to add to the project. 123 . Select Project . Debugging an Application in µVision2 To debug an application created using µVision2. You typically only need to configure the memory map of your target hardware. Note when you select the target device from the Device Database™ all special options are set automatically. Select Debug . DHRY is the Dhrystone Benchmark. SIEVE is the SIEVE Benchmark. you must: 1. Select Project . Select Project . and add the source files to the project. Groups. 6. µVision2 compiles. Select Project -(forexample. or C16x/ST10 device from the Device Database™. Select Project . 2. TRAFFIC is a traffic light controller with the RTX Tiny operating system. Default memory model settings are optimal for most applications. Select Project . assemble. 2. 5. Additional example programs not listed here are provided for each device architecture. 7.Start/Stop Debug Session. Add/Files. Select Project .Options and set the tool options. and link) an application in µVision2. 3. you must: 1.• • • • • MEASURE is a data acquisition system for analog and digital systems. 4. WHETS is the Single-Precision Whetstone Benchmark.Rebuild all target files or Build target.
We suggest that you use a separate folder for each project.2. After you have tested your application. and so on. You can see these names in the Project Window – Files. To create a new project file select from the µVision2 menu Project – New Project…. µVision2 creates a new project file with the name PROJECT1. 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.Once you have successfully generated your application you can start debugging. Go. Now use from the menu Project – Select Device for Target and select a CPU for your project. You may translate all source files and line the application with a click on the Build Target toolbar icon. Starting µVision2 and creating a Project µVision2 is a standard Windows application and started by clicking on the program icon. µVision2 creates HEX files with each build process when Create HEX files under Options for Target – Output is enabled. 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. The Select Device dialog box shows the µVision2 device database.e. main in the Output Window to execute to the main C function. Debug your program using standard options like Step. i. A double click on a message line opens the source file on the correct location in a µVision2 editor window. Use the Step toolbar buttons to single-step through your program. Project1. it is required to create an Intel HEX file to download the software into an EPROM programmer or simulator. 3. You may enter G. Break. 124 . We are using for our examples the Philips 80C51RD+ CPU. When you build an application with syntax errors. You may start your PROM programming utility after the make process when you specify the program under the option Run User Program #1. This opens a standard Windows dialog that asks you for the new project file name. µVision2 will display errors and warning messages in the Output Window – Build page. the tool settings under Options – Target are all you need to start a new application. Just select the microcontroller you use. Then select this folder and enter the file name for the new project. Open the Serial Window using the Serial #1 button on the toolbar.
µVision2 opens an editor window with the source text or shows CPU instructions in the disassembly window. You may select and display the on-chip peripheral components using the Debug menu. The on-chip peripherals of the CPU you have selected are configured from the Device Database selection You have made when you create your project target. Disassembly Window The Disassembly window shows your target program as mixed source and assembly 125 . You can also change the aspects of each peripheral using the controls in the dialog boxes. In addition to memory mapping. Depending on the Options for Target – Debug Configuration. For example. you can use the find command or correct program errors. Program source text of your application is shown in the same windows. The µVision2 simulator traps and reports illegal memory accesses.CPU Simulation µVision2 simulates up to 16 Mbytes of memory from which areas can be mapped for read. the simulator also provides support for the integrated peripherals of the various 8051 derivatives. _ The project structure or tool parameters cannot be modified. most editor features are still available. Refer to page 58 for more Information about selecting a device. All build Commands are disabled. The next executable statement is marked with a yellow arrow. write. During debugging. µ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. Start Debugging You start the debug mode of µVision2 with the Debug – Start/Stop Debug Session command. If the program execution stops. The µVision2 debug mode differs from the edit mode in the following aspects: _ The “Debug Menu and Debug Commands” described on page 28 are Available. The additional debug windows are discussed in the following. or code execution access.
program or just assembly code. A trace history of previously executed instructions may be displayed with Debug – View Trace Records. 2. SOFTWARE DESCRPITION: SOURCE CODE 1. To enable the trace history. set Debug – Enable/Disable Trace Recording. That allows you to correct mistakes or to make temporary changes to the target program you are debugging. Click on the Project menu from the title bar Then Click on New Project 126 . If you select the Disassembly Window as the active window all program step commands work on CPU instruction level rather than program source lines. You can select a text line and set or modify code breakpoints using toolbar buttons or the context menu commands. You may use the dialog Debug – Inline Assembly… to modify the CPU instructions. 4. Click on the Keil uVision Icon on DeskTop The following fig will appear 3.
5. Then Click on Save button above. Atmel…… Click on the + Symbol beside of Atmel 127 . 8. Select the component for u r project.e. Save the Project by typing suitable project name with no extension in u r own folder sited in either C:\ or D:\ 6. i. 7.
11.9. Then Click on “OK” The Following fig will appear 128 . Select AT89C52 as shown below 10.
13. 14. 15. you would get another option “Source group 1” as shown in next page. Then Click either YES or NO………mostly “NO” Now your project is ready to USE Now double click on the Target1.12. Click on the file option from menu bar and select “new” 129 .
and just maximize it by double clicking on its blue boarder.C” 130 . 17. asm” and for “C” based program save it with extension “ .16. 18. Now start writing program in either in “C” or “ASM” For a program written in Assembly. The next screen will be as shown in next page. then save it with extension “.
on which by default “C” files will appear. 131 . Now you will get another window.19. Now right click on Source group 1 and click on “Add files to Group Source” 20.
23. 25. The new window is as follows 132 . 24.21. Now select as per your file extension given while saving the file Click only one time on option “ADD” Now Press function key F7 to compile. Any error will appear if so happen. If the file contains no error. then press Control+F5 simultaneously. 22.
Then Click “OK” Now Click on the Peripherals from menu bar. 133 . Drag the port a side and click in the program file. and check your required port as shown in fig below 28.26. 27.
Now keep Pressing function key “F11” slowly and observe.29. 30. You are running your program successfully 134 .
CONCLUSION The project “AUTO MAIN FAILURE AND AUTOMATIC TRANSFER SWITCH” 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. Integrating features of all the hardware components used have developed it. Secondly. 135 .
V.Ram Micro processor Architecture.Prasad Wireless Communications .Theodore S.Ayala Fundamentals Of Micro processors and Micro computers -B. Programming & Applications -Kenneth J.BIBLIOGRAPHY The 8051 Micro controller and Embedded Systems -Muhammad Ali Mazidi Janice Gillispie Mazidi The 8051 Micro controller Architecture.Gaonkar Electronic Components -D. Rappaport 136 . Programming & Applications -Ramesh S.
com www.com 137 .microsoftsearch. Lee References on the Web: www.William C.Y.geocities.com www.national.com www.Mobile Tele Communications .atmel.