You are on page 1of 47

MICROCONTROLLER BASED AUTOMATIC RAILWAY GATE CONTROL

INTRODUCTION:The objective of this paper is to provide an automatic railway gate at a level crossing replacing the gates operated by the gatekeeper. It deals with two things. Firstly, it deals with the reduction of time for which the gate is being kept closed And secondly, to provide safety to the road users by reducing the accidents. By the presently existing system once the train leaves the station, the stationmaster informs the gatekeeper about the arrival of the train through the telephone. Once the gatekeeper receives the information, he closes the gate depending on the timing at which the train arrives. Hence, if the train is late due to certain reasons, then gate remain closed for a long time causing traffic near the gates. By employing the automatic railway gate control at the level crossing the arrival of the train is detected by the sensor placed near to the gate. Hence, the time for which it is closed is less compared to the manually operated gates and also reduces the human labor. This type of gates can be employed in an unmanned level crossing where the chances of accidents are higher and reliable operation is required. Since, the operation is automatic error due to manual operation is prevented. Automatic railway gate control is highly economical microcontroller based arrangement, designed for use in almost all the unmanned level crossings in the country. In this paper we are concerned of providing an automatic railway gate control at unmanned level crossings replacing the gates operated by gate keepers and also the semi automatically operated gates. It deals with two things. Firstly, it deals with the reduction of time for which the gate is being kept closed. And secondly, to provide safety to the road users by reducing the accidents that usually occur due to carelessness of road users and at times errors made by the gatekeepers.

By employing the automatic railway gate control at the level crossing the arrival of train is detected by the sensor placed on either side of the gate at about 5km from the level crossing. Once the arrival is sensed , the sensed signal is sent to the microcontroller then MC activate the gate motor to close the gate automatically after crossing the level cross at that time train sensed the second sensor second sensor then sensor send a signal to MC then MC again activate the motor to open the level crossing gate.

BLOCK DIAGRAM OF THIS PROJECT

This project contain 7 section ie 1. Power supply section 2. Motor driver section 3. Motherboard section 4. Relay driver section 5. Buzzer driver section 6. IR transmitter section 7. IR receiver section 8. NOT gate section

COMPONENTS USED IN POWER SUPPLY CIRCUIT

COMPONENTS NAME Diode Capacitor Resistor Regulator IC

SPECIFICATION IN4007 1000f,25V 1.5k quarter watt 7812,7805

COMPONENTS USED IN IR SENSOR COMPONENTS NAME Transistor IC Resistor PHOTO DIODE LED SPECIFICATION BC 547 LM393 1K ,10K

COMPONENTS USED IN RELAY DRIVER CIRCUIT COMPONENTS NAME Transistor PCB Resistor Diode RELAY COMPONENTS NAME Relay TRANSFORMER COMPONENTS NAME Transformer SPECIFICATION Step down 230V-12V 0-12,1A SPECIFICATION 12v,10amp SPECIFICATION BC 547 PRINTED CKT BOARD 1.5k IN4007

CIRCUIT DESCRIPTION 4.1 POWER SUPPLY(+ive) Circuit connection: - In this we are using Transformer (0-12) v, 1Amp,LED & resistors. Here 230V, 50 Hz ac signal is given as input to the primary of the transformer and the secondary of the transformer is given to the bridge rectification diode. Circuit Explanations: - When ac signal is given to the primary of the transformer, due to the magnetic effect of the coil magnetic flux is induced in the coil(primary) and transfer to the secondary coil of the transformer due to the transformer action. Transformer is an electromechanical static device which transformer electrical energy from one coil to another without changing its frequency. Here the diodes are connected in a bridge fashion. The secondary coil of the transformer is given to the bridge circuit for rectification purposes. During the +ve cycle of the ac signal the diodes D2 & D4 conduct due to the forward bias of the diodes and diodes D1 & D3 does not conduct due to the reversed bias of the diodes. Similarly during the ve cycle of the ac signal the diodes D1 & D3 conduct due to the forward bias of the diodes and the diodes D2 & D4 does not conduct due to reversed bias of the diodes. The output of the bridge rectifier is not a power dc along with rippled ac is also present. To overcome this effect, a capacitor is connected to the o/p of the diodes (D2 & D3). Which removes the unwanted ac signal and thus a pure dc obtained. Here we need a fixed voltage, thats for we are using IC regulators. The o/p of the bridge rectifier is given as input to the IC regulator through capacitor with respect to GND and thus a fixed o/p is obtained. The o/p of the IC regulator (7805 & 7812) is given to the LED for indication purpose through resistor. Due to the forward bias of the LED, the LED glows ON state, and the o/p are obtained .

POWER SUPPLY CIRCUIT

4.2LED INDICATOR The indicator section consists of a light emitting diode and its driver circuit is designed on the basis of current required to glow the light emitting diode. Here the driver circuit is required for the following functionality. The Microcontroller cannot provide adequate current for glowing the LED. The LEDs requires a current between 10mA to 20mA of current to glow. The driver circuit provides current to the load from a separate source, so the load current used not pass through the Microcontroller.

IR TRANSMITTER (transmitter zone) The IR LED is also light emitting diode but the junction is made out of such material that the transition of electron between the bands emits quanta of energy( E=h) having a particular frequency which is having a particular characteristic. When a diode emits a particular characteristic signal having frequency in the range of infrared then, that diode is called a infrared emitting diode. The IR data transmitter is a high intensity IR signal transmitter. There are two diodes connected in parallel to increase the intensity to avoid data corruption receiver end. In this section our aim is to protect the zone/door/almira etc. from the unauthorized entry or interruption, for that we need some element that should not be visible to the unauthorized person. For that we have taken elements as IR LED as a source and photo diode as a destination. Generally, we have taken IR because IR is invisible to the eye, where as in case of LASER, which is easily visible to the human eye by which will, alert the unauthorized person. That is why we have taken IR as a transmitter which will transmit a continuously IR signal. At the receiver end the photodiode will receive the IR signal. if somebody tries to interrupt the IR signal at the transmitter end, the receiver will decide the absence of the IR signal at the receiver end.

Operation IR transmitter consist of resister ,IR diode and connected according above the fig. when the +Ve 12 V is fed to the IR diode through 150E resistor ir diode get +ve from DC supply and also IR diode get Ve from Ve terminal of DC voltage. When IR diode gets +Ve and VE then it transmit a IR beam .

4.2 IR RECEIVER Introduction A PHOTO DIODE is light sensitive device the junction of the photo diode is such that it generates carriers when the light falls on it. There are different type of diodes, which generates carriers in different magnitudes at different frequency this depends on the nature and doping of the junction. The liberation of carriers are very small in magnitude which is very much dependant on the frequency and intensity of the light signal falling on the junction. In the forward biased condition the majority carrier current is so high that the current generated due to fall of light signal is very negligible. The photon bombardment cause the avalanche break down of the junction and generate current which is in the order of 100s micro ampere to few 10s of mA, due to the above mentioned causes the photo diodes to connected in the reverse biased condition. In the reverse biased condition the normal current is always in the order of few microamperes, the current generated due to fall of light signal on the junction is also in the order of microampere so the net current through the diode is appreciably increased. The same current pass through the resistance connected in series and drop across the resistance is increased. There are two types of arrangements very much widely used in the circuits, as shown in the Fig.1 and Fig.2.

VC C

VC C

D1

D1

Vout

Vout

Fig.1

Fig.2

If the diode junction is exposed with visible light or invisible light like Infrared / Laser in the circuit shown in fig.2, the diode current will rise, possibly to as high as 1mA, producing a significant output across R. In use, the photodiode is reversed biased and the output voltage is taken from across a series-connected load resistor.

CIRCUIT DIAGRAM OF IR RECEIVER

Operation In this project in the data receiving section, the photodiode is used as signal (data) detector purpose to detect the IR signal (data) from the IR transmitter LED section. Whenever the signal is transmitted from the IR transmitter LED, the signal is received at the photodiode receiving section. The receiving signal is very weak in strength, for that we used an amplifier. The output of the photodiode is given as input to the amplifier (Op-amp LM351) through a filtering capacitor (0.01uF) which is configured as an Comparator and the reference voltage is set at noninverting terminal of the operational Amplifier. There is a 10K variable resistor which is connected between +5 Volt and Ground and the variable terminal is connected to the OP-AMP for providing the Threshold value. The output of the LM351 swings in between +Vsat and Vsat, even for a small variation of signal across the threshold value. That output signal is not Compatible with the Micro controller because of the high current; that output from the Op-amp is given to the signal conditioning i.e. the signal is given to the base of the Transistor through a base resistance between 1K 43K and the collector is connected to Vcc= +5Volt in series with a 10K resistance and the output is taken from the collector. The emitter is grounded. The transmitted data is received at the receiving section. The transmitted signal must fall pin pointed to the photodiode junction in order to receive the Signal.

RELAY DRIVER : A relay is an electrically operated switch. Many relays use an electromagnet to operate a switching mechanism, but other operating principles are used. Relays find applications where it is necessary to control a circuit by a low-power signal, or where several circuits must be controlled by one signal. The first relays were used in long distance telegraph circuits, repeating the signal coming in from one circuit and re-transmitting it to another. Relays found extensive use in telephone exchanges and early computers to perform logical operations. A type of relay that can handle the high power required to directly drive an electric motor is called a contractor. Solid-state relays control power circuits with no moving parts, instead using a semiconductor device triggered by light to perform switching. Relays with calibrated operating characteristics and sometimes multiple operating coils are used to protect electrical circuits from overload or faults; in modern electric power systems these functions are performed by digital instruments still called "protection relays".

Relay Switch Characteristics Relays provide a way for one electric current to control another electric current. Switches control the flow of electricity, and relays are switches that are operated by the flow of electricity. Relays are devices whereby one electric current can control another electric current. The control part of a relay is just an electromagnet. The switch part of the relay is a metal piece that can be moved by the electromagnet to close a circuit. Relays can be characterized by poles and throws like any switch, as well as by other characteristics. Poles and Throws Like all switches, relays are characterized by poles and throws. Throws is really a way of saying how many different circuits the relay can control. If there is one throw, the relay opens and closes one switch, and controls one circuit. Two throws indicates that the relay opens and closes two mechanically linked switches, and so controls two circuits. Poles are the number of current carrying positions the switches can be in. A single pole switch only opens and closes a circuit. A double pole switch diverts a current into one of two possible paths. Both poles and throws are usually only one or two, but higher numbers are sometimes seen.

Normally Open or Closed Single pole relays are characterized as normally open or normally closed. This refers to the position of the switch when the electromagnet is not activated. If the relay is normally open, activating the electromagnet will close the switch and activate another circuit. If the relay is normally closed, some circuit is active and activating the electromagnet will deactivate this previously active circuit. Normally open relays are found when a tiny current is used to control a bigger current; activating the electromagnet closes the switch that carries the larger current. Normally closed relays are found in burglar alarms, with the circuits that controls the electromagnet that holds the switch open running through the doors and windows of a home. When a door or window is opened, it stops the current to the electromagnet which causes the switch to close and sets off an alarm. Cutting the wires to this relay also sets off the alarm. Latching Relays
Latching relays are a way of making a switch with memory. The circuit that is controlled by a latching relay also runs through the electromagnet. When the electromagnet operates the normally open switch, it controls some circuit, but it also energizes the electromagnet. If the electromagnet is activated, even by a single pulse, it latches so it stays closed even when the original circuit that activated the switch is no longer active. The only way to unlatch the switch is to break, even temporarily, the circuit that includes the electromagnet.

Latching relays are used when machines are turned on and off by push buttons.

Relay driver section Relay driver is consists of capacitor 10f, diode IN4007, resister and NPN transistor BC547 which is connected according the below diagram. Before going to the relay driver first we should know that about Relay. Relay is an electrical and electronics SWITCH which is ON and OFF by the help of voltage and current which depends upon transistor switching circuit and digital IC. Here transistor acts as a switching circuit .when the high voltage is fed to the base of the transistor through resister then the transistor is ON that means it conducts and the relay coil get +12V from the 12V power supply but it does not get the ve power supply so it cant be ON. When the transistor is ON then the relay gets VE power and the relay is ON. After getting VE power relay come out from its normal condition to the ON condition , which ON the device which is connected through the relay in other words which depends on relay for ON and OFF. Here diode and capacitor works for freewheeling purpose.

The above circuit is the relay driver by this above circuit we can on or off the relay easily.
RELAY DRIVER

This application is in some ways a continuation of he discussion introduced for diodes how the effects of inductive kick can be minimized through proper design. In the below figure (a), a transistor is used to established the current necessary to energize the relay in the collector circuit. With no input at the base of the transistor, the base current, collector current, and the coil current are essentially 0A, and the relay sits in the unenergized state (normally open, NO). However when a positive pulse is applied to the base, the transistor turns ON, establishing sufficient current through the coil of the electromagnet to close the relay. Problem can be now develop when the signal is removed from the base to turn OFF the transistor and de-energized the relay. Ideally, the current through he coil and the transistor will quickly drop to zero, the arm of the relay will be released, and the relay will simply remain dormant until the next ON signal. However we know from our basic circuit courses that the current through the coil cannot change instantaneously, and in fact the more quickly changes, greater the induced voltage across the coil as defined by, VL = L (diL / dt). In this case, the rapid changing current through the coil will develop a large voltage across the coil with the polarity shown

in figure (a), which will appear directly across the output of the transistor. The chances are likely that its magnitude will exceeds the maximum ratings of the transistor, and the semiconductor device will be permanently damaged. The voltage across the coil will not remain at its highest switching level but will oscillate as shown until its level drops to zero as the system settles down. The destructive action can be subdued by placing a diode across the coil as shown in below figure (b). During the ON state of the transistor, the diode is back biased: it sits like an open circuit and does not affect the thing. However, when the transistor turns OFF, the voltage across the coil will reverse and will forward biased the diode, placing the diode in its ON state. The current through the inductor established during ON state of the transistor can then continue to flow through the diode, eliminating the severe change in current level. Because the inductive current is switched to diode almost instantaneously after the OFF state is established, the diode must have a current rating to match the current through the inductor and the transistor when is in ON state. Eventually, because of the resistive elements in the loop, including the resistance of the coil windings and the diode, the high frequency (quickly oscillating) variation in voltage level across the coil will decay to zero and the system will settle down.

Overload Relays

SIRIUS overload relays with screw-type, spring-loaded or ring cable lug connections reliably protect loads as well as other switching and protective devices in the respective load

feeder against overload, phase imbalance and phase failure. Thanks to ATEX certification, they can be used in many different applications, even under the particularly harsh conditions of the process industry. The overload relays can easily be used with the contactors of the modular SIRIUS system.There are two versions of overload relays: thermal and electronic. In the main circuit, the SIRIUS 3RU thermal overload relays are responsible for current-dependent overload protection of electrical loads (e.g. motors). The 3RU2 overload relays are available with spring-loaded, screw-type and ring cable lug connections - for a particularly flexible implementation. In the 3RU2 overload relays, the power losses are 5 to 10 % lower than for the previous models thanks to a new bimetal technology. Therefore, the temperature within the control cabinet can be reduced as well. The 3RB electronic overload relay ensures real commercial added value: In the main circuit, the electronic overload relays for standard applications are responsible for currentdependent overload protection of electrical loads (e.g. motors). Due to the wide current setting ranges, complete series of motors are covered with just a few types. An electrical remote reset has been added to the already extensive basic functions of the 3RB31 version.

For demanding applications, a modular variant of the electronic overload relay even offers full motor protection by also sensing the temperature of the motor. In addition, optimized, uniform accessories are available for 3RU2 and 3RB3. This reduces the costs for the ordering process and for maintaining stocks. Electronic overload relay SIRIUS 3RB24 for IO-Link With the new communication-capable electronic overload relay SIRIUS 3RB24 for IO-Link you can easily connect your load feeder to a higher-level control and therefore its integration in your automation environment. As the electronic overload relay supports the transmission of analog process variables like currents, system processes can be optimized, e.g. through load monitoring. Moreover, you will profit from an increased system availability and easier system documentation thanks to integrated diagnostic functions and readable parameter assignment. In combination with contactors, the overload relay can also be employed as direct, reversing and stardelta starter.

NOT GATE

SIGNAL CONDITIONING The output form the input signal i.e. comparator or any other external circuit must be compatible with the -controller, because the -controller can takes 5V as input voltage and gives a 5V as output voltage. That for we need a signal conditioning circuit as given in the below figure.

VCC= +5v

VCC= +5v

INPUT

10k 1.5k

OUTPUT
BC547

BC547

INPUT

1.5k

10k

OUTPUT

(1:1)

(1:0)

(SIGNAL CONDITIONING) fig..1:1 In the fig1: 1, whenever the base voltage is HIGH the transistor comes to saturation condition i.e. the collector current flows to the emitter which gives a high voltage at the output corresponding to Vcc given at the collector. The output is taken from the emitter junction through a current limiting resistance and the output signal is given to the - controller or any other circuit which needs a compatible (5V) voltage. Similarly, whenever the base voltage is LOW the emitter current flows from the emitter junction of the transistor, which gives a low voltage at the output corresponding to GND. The output is taken from the emitter junction through a current limiting resistance and the output signal is given to the - controller or any other circuit which needs a compatible (5V) voltage. fig..1:0

In the fig1: 0, whenever the base voltage is HIGH the transistor comes to saturation condition i.e. the emitter current flows to the collector which gives a low voltage at the output corresponding to GND. The output is taken from the collector junction through a current limiting resistance and the output signal is given to the - controller or any other circuit which needs a compatible (5V/0V) voltage. Similarly, whenever the base voltage is LOW the collector current flows from the collector junction of the transistor, which gives a high voltage at the output corresponding to Vcc. The output is taken from the emitter junction through a current limiting resistance and the output signal is given to the - controller or any other circuit which needs a compatible (5V/0V) voltage. The application of the transistors is not limited solely to the amplification of the signals. Through proper design transistors can be used as switches for computers and control applications. The network of figure-01 (a) can be employed as an inverter in computer logic circuitry. Note that the output voltage Vc is opposite to the applied to the base or input terminal. In addition note the absence of dc supply connected to the base circuit. The only dc source is connected to the collector or output side, and for computer applications is typically equal to the magnitude of the high side of the applied signal in this case 5V.
Vcc = +5V

Vi 5v 0v t IN
Rb

Vc 5v
OUT

Rc

Q1 BC547

0v

IC (mA)

IC sat = 6mA

IB = 80A IB = 60A IB = 40A IB = 20A IB = 10A IB = 0A

OPERATION:

Vcc = 5V (b)

VCE

Proper design for the inversion process requires that the operating points switch from cut-off to saturation along the load line depicted in above figure (b). For our proposes we will assume that IC = ICEO = 0mA, when IB = 0A (an excellent approximation in light of improving construction techniques), as shown in above figure (b). In addition, we will assume that VCE = VCE sat = 0V. When Vi = 5v, the transistor will be ON and design must insured that the network is heavily saturated by a level of IB greater than that associated if the IB curve appearing near the saturation level. In the above figure (b), this requires that IB > 50A.

The saturation level for the collector current for the circuit is defined by, IC = VCC / RC The level of IB in the active region just before saturation results can be approximated by the following equation, IB max IC sat / dc For the saturation level we must therefore insure that the following condition is satisfied: IB max >IC sat / dc For the network of the above figure (b), when Vi = 5v the resulting level of IB is IB = Vi 0.7 / RB = 5v 0.7 / 1.5k = 2866A IC sat = VCC / RC = 5v / 10k = 0.5mA Testing the above equation gives: IB =2866A > IC sat / dc = 0.5mA / 300 Which is satisfied. Certainly any level of IB greater than 2866A will pass through a Q- point on the load line that is very close to the vertical axis. INVERTER EXAMPLE At saturation, IC sat = VCC / RC 10mA = 5V / RC RC = 5V / 10mA = 500

At saturation, IB IC sat / dc = 10mA / 300 = 33 A Choosing IB = 60A to ensure saturation and using, IB = Vi 0.7V / RB RB = Vi 0.7V / IB = 5v 0.7v / 60A or 80A = 716k or 537k Choose RB = 720k or 560k which is a standard value. Then, IB = Vi 0.7V / RB IB= Vi 0.7V / 720k or 560k = 4.3V / 720k or 560k = 59A or 76 A PIEZO ELECRTIC BUZZER: It is a device that converts electrical signal to an audible signal (sound signal).The Microcontroller cannot drive directly to the buzzer, because the Microcontroller cannot give sufficient current to drive the buzzer for that we need a driver transistor (BC547), which will give sufficient current to the buzzer.Whenever a signal received to the base of the transistor through a base resistance (1.5k) is high, the transistor comes to saturation condition i.e. ON condition thus the buzzer comes to on condition with a audible sound. Similarly, whenever the signal is not received to the base of the transistor, thus the transistor is in cut-off state i.e. is in OFF state thus the buzzer does not gets activated.

BUZZER

DRIVER

VCC

BUZZER

DATA INPUT

1.5K BC547

3 MOTHER BOARD: The motherboard of this project is designed with a MSC 51 core compatible micro controller. The motherboard is designed on a printed circuit board, compatible for the micro controller. This board is consisting of a socket for micro controller, input /output pull-up registers; oscillator section and auto reset circuit. Microcontroller core processor: Introduction Despite its relatively old age, the 89C51 is one of the most popular Micro controller in use today. Many derivatives Micro controllers have since been developed that are based on--and compatible with--the 8051. Thus, the ability to program an

89C51 is an important skill for anyone who plans to develop products that will take advantage of Micro controller. Many web pages, books, and tools are available for the 89C51 developer. The 89C51 has three very general types of memory. To effectively program the 8051 it is necessary to have a basic understanding of these memory types. The memory types are illustrated in the following graphic. They are: On-Chip Memory, External Code Memory, and External RAM.

Fig-9 (Memory structure of Microcontroller) On-Chip Memory refers to any memory (Code, RAM, or other) that physically exists on the Microcontroller itself. On-chip memory can be of several types, but we'll get into that shortly. External Code Memory is code (or program) memory that resides off-chip. This is often in the form of an external EPROM.

External RAM is RAM memory that resides off-chip. This is often in the form of standard static RAM or flash RAM.

Code Memory Code memory is the memory that holds the actual 8051 program that is to be run. This memory is limited to 64K and comes in many shapes and sizes: Code memory may be found on-chip, either burned into the Microcontroller as ROM or EPROM. Code may also be stored completely off-chip in an external ROM or, more commonly, an external EPROM. Flash RAM is also another popular method of storing a program. Various combinations of these memory types may also be used--that is to say, it is possible to have 4K of code memory on-chip and 64k of code memory off-chip in an EPROM. When the program is stored on-chip the 64K maximum is often reduced to 4k, 8k, or 16k. This varies depending on the version of the chip that is being used. Each version offers specific capabilities and one of the distinguishing factors from chip to chip is how much ROM/EPROM space the chip has. However, code memory is most commonly implemented as offchip EPROM. This is especially true in low-cost development systems and in systems developed by students. Programming Tip: Since code memory is restricted to 64K, 89C51 programs are limited to 64K. Some assemblers and compilers offer ways to get around this limit when used with specially wired hardware. However, without such special compilers and hardware, programs are limited to 64K.

External RAM As an obvious opposite of Internal RAM, the 89C51 also supports what is called External RAM. As the name suggests, External RAM is any random access memory which is found off-chip. Since the memory is off-chip it is not as flexible in terms of accessing, and is also slower. For example, to increment an Internal RAM location by 1 requires only 1 instruction and 1 instruction cycle. To increment a 1-byte value stored in External RAM requires 4 instructions and 7 instruction cycles. In this case, external memory is 7 times slower! What External RAM loses in speed and flexibility it gains in quantity.While Internal RAM is limited to 128 bytes (256 bytes with an 8052), the 8051 supports External RAM up to 64K. Programming Tip: The 8051 may only address 64k of RAM. To expand RAM beyond this limit requires programming and hardware tricks. You may have to do this "by hand" since many compilers and assemblers, while providing support for programs in excess of 64k, do not support more than 64k of RAM. This is rather strange since it has been my experience that programs can usually fit in 64k but often RAM is what is lacking. Thus if you need more than 64k of RAM, check to see if your compiler supports it-- but if it doesn't, be prepared to do it by hand. On-Chip Memory As mentioned at the beginning of this chapter, the 89C51 includes a certain amount of on-chip memory. On-chip memory is really one of two types: Internal RAM and Special Function

Register (SFR) memory. The layout of the 89C51's internal memory is presented in the following memory map:

As is illustrated in this map, the 8051 has a bank of 128 bytes of Internal RAM. This Internal RAM is found on-chip on the 8051 so it is the fastest RAM available, and it is also the most flexible in terms of reading, writing, and modifying its contents. Internal RAM is volatile, so when the 8051 is reset this memory is cleared. The 128 bytes of internal ram is subdivided as shown on the memory map. The first 8 bytes (00h - 07h) are "register bank 0". By manipulating certain SFRs, a program may choose to use register banks 1, 2, or 3. These alternative register banks are located in internal RAM in addresses 08h through 1Fh. We'll discuss "register banks" more in a later chapter. For now it is sufficient to know that they "live" and are part of internal RAM. Bit Memory also lives and is part of internal RAM. We'll talk more about bit memory very shortly, but for now just keep in

mind that bit memory actually resides in internal RAM, from addresses 20h through 2Fh. The 80 bytes remaining of Internal RAM, from addresses 30h through 7Fh, may be used by user variables that need to be accessed frequently or at high-speed. This area is also utilized by the Microcontroller as a storage area for the operating stack. This fact severely limits the 8051s stack since, as illustrated in the memory map, the area reserved for the stack is only 80 bytes--and usually it is less since this 80 bytes has to be shared between the stack and user variables. SFR Descriptions There are different special function registers (SFR) designed in side the 89C51 micro controller. In this micro controller all the input , output ports, timers interrupts are controlled by the SFRs. The SFR functionalities are as follows. This section will endeavor to quickly overview each of the standard SFRs found in the above SFR chart map. It is not the intention of this section to fully explain the functionality of each SFR--this information will be covered in separate chapters of the tutorial. This section is to just give you a general idea of what each SFR does. P0 (Port 0, Address 80h, Bit-Addressable): This is input/output port 0. Each bit of this SFR corresponds to one of the pins on the Microcontroller. For example, bit 0 of port 0 is pin P0.0, bit 7 is pin P0.7. 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 a low level.

Programming Tip: While the 8051 has four I/O port (P0, P1, P2, and P3), if your hardware uses external RAM or external code memory (i.e., your program is stored in an external ROM or EPROM chip or if you are using external RAM chips) you may not use P0 or P2. This is because the 8051 uses ports P0 and P2 to address the external memory. Thus if you are using external RAM or code memory you may only use ports P1 and P3 for your own use. SP (Stack Pointer, Address 81h): This is the stack pointer of the Microcontroller. This SFR indicates where the next value to be taken from the stack will be read from in Internal RAM. If you push a value onto the stack, the value will be written to the address of SP + 1. That is to say, if SP holds the value 07h, a PUSH instruction will push the value onto the stack at address 08h. This SFR is modified by all instructions which modify the stack, such as PUSH, POP, LCALL, RET, RETI, and whenever interrupts are provoked by the Microcontroller. Programming Tip: The SP SFR, on startup, is initialized to 07h. This means the stack will start at 08h and start expanding upward in internal RAM. Since alternate register banks 1, 2, and 3 as well as the user bit variables occupy internal RAM from addresses 08h through 2Fh, it is necessary to initialize SP in your program to some other value if you will be using the alternate register banks and/or bit memory. It's not a bad idea to initialize SP to 2Fh as the first instruction of every one of your programs unless you are 100% sure you will not be using the register banks and bit variables.

DPL/DPH (Data Pointer Low/High, Addresses 82h/83h): The SFRs DPL and DPH work together to represent a 16-bit value called the Data Pointer. The data pointer is used in operations regarding external RAM and some instructions involving code memory. Since it is an unsigned two-byte integer value, it can represent values from 0000h to FFFFh (0 through 65,535 decimal). Programming Tip: DPTR is really DPH and DPL taken together as a 16-bit value. In reality, you almost always have to deal with DPTR one byte at a time. For example, to push DPTR onto the stack you must first push DPL and then DPH. You can't simply plush DPTR onto the stack. Additionally, there is an instruction to "increment DPTR." When you execute this instruction, the two bytes are operated upon as a 16-bit value. However, there is no instruction that decrements DPTR. If you wish to decrement the value of DPTR, you must write your own code to do so. PCON (Power Control, Addresses 87h): The Power Control SFR is used to control the 8051's power control modes. Certain operation modes of the 8051 allow the 8051 to go into a type of "sleep" mode, which requires much, less power. These modes of operation are controlled through PCON. Additionally, one of the bits in PCON is used to double the effective baud rate of the 8051's serial port. TCON (Timer Control, Addresses 88h, Bit-Addressable): The Timer Control SFR is used to configure and modify the way in which the 8051's two timers operate. This SFR controls whether each of the two timers is running or stopped and

contains a flag to indicate that each timer has overflowed. Additionally, some non-timer related bits are located in the TCON SFR. These bits are used to configure the way in which the external interrupts are activated and also contain the external interrupt flags which are set when an external interrupt has occurred. TMOD (Timer Mode, Addresses 89h): The Timer Mode SFR is used to configure the mode of operation of each of the two timers. Using this SFR your program may configure each timer to be a 16-bit timer, an 8-bit auto reload timer, a 13-bit timer, or two separate timers. 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. TL0/TH0 (Timer 0 Low/High, Addresses 8Ah/8Ch): These two SFRs, taken together, represent timer 0. Their exact behavior depends on how the timer is configured in the TMOD SFR; however, these timers always count up. What is configurable is how and when they increment in value. TL1/TH1 (Timer 1 Low/High, Addresses 8Bh/8Dh): These two SFRs, taken together, represent timer 1. Their exact behavior depends on how the timer is configured in the TMOD SFR; however, these timers always count up. What is configurable is how and when they increment in value. P1 (Port 1, Address 90h, and Bit-Addressable): This is input/output port 1. Each bit of this SFR corresponds to one of the pins on the Microcontroller. For example, bit 0 of port 1 is pin P1.0, bit 7 is pin P1.7. 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 a low level. SCON (Serial Control, Addresses 98h, Bit-Addressable): The Serial Control SFR is used to configure the behavior of the 8051's on-board serial port. This SFR controls the baud rate of the serial port, whether the serial port is activated to receive data, and also contains flags that are set when a byte is successfully sent or received. Programming Tip: To use the 8051's on-board serial port, it is generally necessary to initialize the following SFRs: SCON, TCON, and TMOD. This is because SCON controls the serial port. However, in most cases the program will wish to use one of the timers to establish the serial port's baud rate. In this case, it is necessary to configure timer 1 by initializing TCON and TMOD. SBUF (Serial Control, Addresses 99h): The Serial Buffer SFR is used to send and receive data via the on-board serial port. Any value written to SBUF will be sent out the serial port's TXD pin. Likewise, any value which the 8051 receives via the serial port's RXD pin will be delivered to the user program via SBUF. In other words, SBUF serves as the output port when written to and as an input port when read from. P2 (Port 2, Address A0h, and Bit-Addressable): This is input/output port 2. Each bit of this SFR corresponds to one of the pins on the Microcontroller. For example, bit 0 of port 2 is pin P2.0, bit 7 is pin P2.7. 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 a low level.

Programming Tip: While the 8051 has four I/O port (P0, P1, P2, and P3), if your hardware uses external RAM or external code memory (i.e., your program is stored in an external ROM or EPROM chip or if you are using external RAM chips) you may not use P0 or P2. This is because the 8051 uses ports P0 and P2 to address the external memory. Thus if you are using external RAM or code memory you may only use ports P1 and P3 for your own use. IE (Interrupt Enable, Addresses A8h): The Interrupt Enable SFR is used to enable and disable specific interrupts. The low 7 bits of the SFR are used to enable/disable the specific interrupts, where as the highest bit is used to enable or disable ALL interrupts. Thus, 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. P3 (Port 3, Address B0h, and Bit-Addressable): This is input/output port 3. Each bit of this SFR corresponds to one of the pins on the Micro controller. For example, bit 0 of port 3 is pin P3.0, bit 7 is pin P3.7. 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 a low level.

Fig-10 (Structural Hierarchy)

Auto reset Circuit:

MICROCONTROLLER
39 38 37 36 35 34 33 32 1 2 3 4 5 6 7 8 P0.0/AD0 P0.1/AD1 P0.2/AD2 P0.3/AD3 P0.4/AD4 P0.5/AD5 P0.6/AD6 P0.7/AD7 P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 XTAL1 XTAL2 EA/VPP RST P2.0/A8 P2.1/A9 P2.2/A10 P2.3/A11 P2.4/A12 P2.5/A13 P2.6/A14 P2.7/A15 P3.0/RXD P3.1/TXD P3.2/IN T0 P3.3/IN T1 P3.4/T0 P3.5/T1 P3.6/WR P3.7/RD ALE/PROG PSEN 21 22 23 24 25 26 27 28 10 11 12 13 14 15 16 17 30 29

22pF 4 - 12Mhz

19 18 31 9

22pF

VCC=+5vdc

AT89C51

10uF RST

8.2k

Fig-11 (Connection of Relay with microcontroller)

The auto reset circuit is a RC network as shown in the mother board circuit diagram. A capacitor of 1-10mfd is connected in series with a 8k2 resister the R-C junction is connected to the micro controller pin 9 which is reset pin. The reset pin is one when ever kept high( logic 1) the programme counter (PC) content resets to 0000h so the processor starts executing the programme. from that location. When ever the system is switched ON the mother board gets power and the capacitor acts as short circuit and the entire voltage appears across the resistor, so the reset pin get a logic 1 and the system get reset, whenever it is being switched ON.

Pull-UP Resisters:
VCC=+5V

10k

PORT-0

39 38 37 36 35 34 33 32 1 2 3 4 5 6 7 8 19 18 31 9

P0.0/AD0 P0.1/AD1 P0.2/AD2 P0.3/AD3 P0.4/AD4 P0.5/AD5 P0.6/AD6 P0.7/AD7 P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 XTAL1 XTAL2 EA/VPP RST

P2.0/A8 P2.1/A9 P2.2/A10 P2.3/A11 P2.4/A12 P2.5/A13 P2.6/A14 P2.7/A15 P3.0/RXD P3.1/TXD P3.2/INT0 P3.3/INT1 P3.4/T0 P3.5/T1 P3.6/WR P3.7/RD ALE/PROG PSEN

21 22 23 24 25 26 27 28 10 11 12 13 14 15 16 17 30 29

AT89C51

FIG-12 (Pin configuration of AT89C51 microcontroller) The PORT0 and PORT2 of the MCS-51 architecture is of open collector type so on writing logic 0 the pins are providing a perfect ground potential. Where as on writing logic 1 the port pins behaves as high impedance condition so putting a pull-up resister enables the port to provide a +5volt( logic 1). Port1 and Port3 are provided with internal pull-ups. A pull-up resister is normally a 10K resistance connected from the port pin to the Vcc (+5) volt.

Crystal Oscillator The 8051 family microcontroller contains an inbuilt crystal oscillator, but the crystal has to be connected externally. This family of microcontroller can support 0 to 24MHz crystal and two numbers of decoupling capacitors are connected as shown in the figure. These capacitors are decouples the charges developed on the crystal surface due to piezoelectric effect. These decoupling capacitors are normally between 20pf to 30pf. The clock generator section is designed as follows,

Fig-13 (Crystal oscillator)

The Microcontroller design consist of two parts 1) Hardware 2) Software .

HARDWARE: The controller operates on +5 V dc, so the regulated + 5v is supplied to pin no. 40 and ground at pin no. 20. The controller is used here need not required to handle high frequency signals, so as 4 MHz crystal is used for operating the processor. The pin no. 9 is supplied with a +5V dc through a push switch to reset the processor .As prepare codes are store in the internal flash memory the pin no. 31 is connected to + Vcc

4.6-IC 7805 ITs one of the most famous regulator IC to make the ripple in wave form smooth.when we convert AC to DC we need to use like this IC to regulate the voltage and current.78 mean that it works with + polarity and 05 means it produce +5 volts for u regulated and without ripple. if we want to have the higher voltage u should use 7805,7806.7812,78XXand for the negative polarity use 7905,7912, 79XX is positive type.

Features Output Current up to 1A Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24V Thermal Overload Protection Short Circuit Protection Output Transistor Safe Operating Area Protection Description The KA78XX/KA78XXA series of three-terminal positive regulator are available in the TO-220/D-PAK package and with several fixed output voltages, making them useful in wide range of applications. Each type employs internal current limiting, thermal shut down and safe operating area protection, making it essentially indestructible. If adequate heat sinking is provided, they can deliver over 1A outpu current. Although designed primarily as fixed voltage regulators, these devices can be used with externalcomponents to obtain adjustable voltages and currents.

You might also like