You are on page 1of 88

ABSTRACT

Aim of this project is control the unmanned rail gate automatically using embedded platform. Today often we see news papers very often about the railway accidents happening at un- attended railway gates. Present project is designed to avoid such accidents if implemented in spirit. This project utilizes two powerful IR transmitter and two receivers one pair of transmitter and receiver is fi!ed at upside "from the train comes# at a level higher than human being in e!act alignment and similarly other pair is fi!ed at down side of the train direction sensor activation time is so adjusted by calculating the time ta$en at a certain speed to cross at least one compartment of standard minimum size of the Indian railway normally % seconds. The sensors are fi!ed at &''' meters on both sides of the gate we call fore side sensor pair for common towards gate train and aft side sensors for the train just (rosses the gate. )hen train cross the fore side sensor it gives signal to the gate receiver to close the gate. The buzzer is activated to clear the gate area for drivers about % seconds. *ate motor is turned on in one direction and gate is closed and stay closed till train crosses the gate and reaches aft side sensors when aft side receiver get activated motor turns in opposite direction and gate opens and motor stops . If there is any problem in the gate means it will operate red signal on both side fro the driver indication. Train arrival and departure sensing can be achieved by means of Relay techni+ues. )hen the wheels of the train moves over both trac$s are shorted to ground and this acts as a signal to microcontroller ",-(%&# indicating train arrival. R./ signal appears for the road user once the train cuts the relay sensor placed before the %0ms before the gate .A buzzer is made on as a pre cautionary measure for the road users.

Chapter 1 INTRODUCTION

INTRODUCTION Present project is designed using AT,-(%& microcontroller to avoid railway accidents happening at unattended railway gates if implemented in spirit. This project utilizes two powerful IR transmitters and two receivers1 one pair of transmitter and receiver is fi!ed at up side "from where the train comes# at a level higher than a human being in e!act alignment and similarly the other pair is fi!ed at down side of the train direction. 2ensor activation time is so adjusted by calculating the time ta$en at a certain speed to cross at least one compartment of standard minimum size of the Indian railway. )e have considered % seconds for this project. 2ensors are fi!ed at &$m on both sides of the gate. )e call the sensor along the train direction as 3foreside sensor4 and the other as 3aft side sensor4. )hen foreside receiver gets activated the gate motor is turned on in one direction and the gate is closed and stays closed until the train crosses the gate and reaches aft side sensors. )hen aft side receiver gets activated motor turns in opposite direction and gate opens and motor stops. 5uzzer will immediately sound at the fore side receiver activation and gate will close after % seconds so giving time to drivers to clear gate area in order to avoid trapping between the gates and stop sound after the train has crossed. The same principle is applied for trac$ switching. (onsidering a situation wherein an e!press train and a local train are traveling in opposite directions on the same trac$1 the e!press train is allowed to travel on the same trac$ and the local train has to switch on to the other trac$. Two sensors are placed at the either sides of the junction where the trac$ switches. If there4s a train approaching from the other side then another sensor placed along that direction gets activated and will send an interrupt to the controller. The interrupt service routine switches the trac$. Indicator lights have been provided to avoid collisions. 6ere the switching operation is performed using a stepper motor. Assuming that within a certain delay the train has passed the trac$ is switched bac$ to its original position allowing the first train to pass without any interruption. This concept of trac$ switching can be applied at &$m distance from the stations.

Gate Control7 Railways being the cheapest mode of transportation are preferred over all the other means .)hen we go through the daily newspapers we come across many railway accidents occurring at unmanned railway crossings. This is mainly due to the carelessness in manual operations or lac$ of wor$ers. )e in this project has come up with a solution for the same. 8sing simple electronic components we have tried to automate the control of railway gates. As a train approaches the railway crossing from either side the sensors placed at a certain distance from the gate detects the approaching train and accordingly controls the operation of the gate. Also an indicator light has been provided to alert the motorists about the approaching train. Track Switching: 8sing the same principle as that for gate control we have developed a concept of automatic trac$ switching. (onsidering a situation wherein an e!press train and a local train are traveling in opposite directions on the same trac$1 the e!press train is allowed to travel on the same trac$ and the local train has to switch on to the other trac$. Indicator lights have been provided to avoid collisions .6ere the switching operation is performed using a stepper motor. In practical purposes this can be achieved using electromagnets. Signaling using LCD7 Train arrival and departure message is needed at the platform for the passengers and also a announcement is re+uired. 5y detecting the signal at trac$s by sensors a command is sent to the micro controller which enables the 9(/ to display the arrival message. )e can also use another sensor after the station to display the departure message. And a buzzer can be connected across it to give a announcement. A specified delay is given to message so that can be displayed for that much time.

:icro-controllers are also being used increasingly as tools for analysis and design of control systems. The control engineer thus has much more powerful tools available now than in the past. /igital computers are still in a state of rapid development because of the progress in very large-scale integration ";92I# technology. Thus substantial technological improvements can be e!pected in the future. 5ecause of these developments the approach to analysis design and

implementation of control systems is changing drastically. <riginally it was only a matter of translating the earlier analog designs into the new technology. technology. 6owever it has been realized that there is much to be gained by e!ploiting the full potential of the new =ortunately control theory has also developed substantially over the past >% years. =or a while it was +uite unrealistic to implement the type of regulators that the new theory produced e!cept in a few e!otic mostly in aerospace or advanced process control. 6owever due to the revolutionary development of microelectronics advanced regulators can be implemented even for basic applications. It is also possible to do analysis and design at a reasonable cost with the interactive design tools that are becoming increasingly available. The purpose of this project wor$ is to present control theory that is relevant to the analysis and design of :icro-controller system with an emphasis on basic concept and ideas. It is assumed that a :icrocontroller with reasonable software is available for computations and simulations so that many tedious details can be left to the :icrocontroller. The control system design is also carried out up to the stage of implementation in the form of controller programs in assembly language. :icro-controllers are ?embedded? inside some other device so that they can control the features or actions of the product. Another name for a micro-controller therefore is ?embedded controller?. :icro-controllers are dedicated to one tas$ and run one specific program. The program is stored in R<: "read-only memory# and generally does not change. :icro-controllers are often low-power devices. A battery-operated :icrocontroller might consume %' mille watts. A micro-controller has a dedicated input

device and often "but not always# has a small 9./ or 9(/ display for output. A microcontroller also ta$es input from the device it is controlling and controls the device by sending signals to different components in the device.

1 ! Sco"e o# "ro$ect7 This project is developed in order to help the I@/IA@ RAI9)AA2 in ma$ing its present wor$ing system a better one by eliminating some of the loopholes e!isting in it. 5ased on the responses and reports obtained as a result of the significant development in the wor$ing system of I@/IA@ RAI9)AA2 this project can be further e!tended to meet the demands according to situation. This can be further implemented to have control room to regulate the wor$ing of the system. Thus becomes the user friendliness. This circuit can be e!panded and used in a station with any number of platforms as per the usage. Additional modules can be added with out affecting the remaining modules. This allows the fle!ibility and easy maintenance of the developed system. This system consists of following features over manual system7 There is no time lag to operate the device. Accuracy.

1.3 Contents of the Thesis: Chapter 2 describes the block diagram and operation of different units like gate control, track switching and etc., with block diagrams. Chapter 3 describes power supply part that we used in this project, with different parts of it, with ratings. Chapter 4 presents how the LC and e$planation for program. Chapter # presents stepper motor interfacing and e$planation for program written. Chapter % presents detailed e$planation about infrared sensors and its parts with circuit diagrams. Chapter & gi'es detailed presentation of all hardware components that we use in this project. Chapter ! gi'es the conclusions and future scope of this project. interfaced with !"c#1,

which we used in this project for displaying train status message

Chapter 2 BLOC% DIAGRA& AND G'N'RAL D'SCRI(TION

Block )iagra* an) General )escri"tion ! 1 Block )iagra* intro)uction:

+IG ! 1
The+IG! 1shows the general bloc$ diagram of unmanned railway gate control the various bloc$s of this are7 &. Power supply unit B. *ate control unit >. Trac$ changing unit C. 9(/ :essage display unit This project uses AT,-(%& microcontroller for programming and operation. And 89@B''> driver.

The 5loc$ diagram consists of the power supply which is of single-phase B>'; ac. This should be given to step down transformer to reduce the B>'; ac voltage to lower value. i.e. to -; or &,; ac this value depends on the transformer inner winding. The output of the transformer is given to the rectifier circuit. This rectifier converts ac voltage to dc voltage. 5ut the voltage may consist of ripples or harmonics. To avoid these ripples the output of the rectifier is connected to filter. The filter thus removes the harmonics. This is the e!act dc voltage of the given specification. 5ut the controller operates at %; dc and the relays and driver operates at &B; dc voltage. 2o the regulator is re+uired to reduce the voltage. Regulator D,'% produces %; dc and regulator D,&B produces &B; dc. 5oth are positive voltages. The supply from D,'% regulator is used for the purpose of trac$ changing which consists of a stepper motor driven with 89@B''> the current driver chip. The supply of &Bv is given to drive the stepper motor for the purpose of gate control. Through ulnB''>

2.2 Operation:

Fig 2.2. shows the of view of model project

T his project utilizes two powerful IR transmitters and two receivers1 one pair
of transmitter and receiver is fi!ed at up side "from where the train comes# at a level higher than a human being in e!act alignment and similarly the other pair is fi!ed at down side of the train direction. 2ensor activation time is so adjusted by calculating the time ta$en at a certain speed to cross at least one compartment of standard minimum size

of the Indian railway. )e have considered % seconds for this project. 2ensors are fi!ed at &$m on both sides of the gate. )e call the sensor along the train direction as 3foreside sensor4 and the other as 3aft side sensor4. )hen foreside receiver gets activated the gate motor is turned on in one direction and the gate is closed and stays closed until the train crosses the gate and reaches aft side sensors. )hen aft side receiver gets activated motor turns in opposite direction and gate opens and motor stops. 5uzzer will immediately sound at the fore side receiver activation and gate will close after % seconds so giving time to drivers to clear gate area in order to avoid trapping between the gates and stop sound after the train has crossed. The same principle is applied for trac$ switching. (onsidering a situation wherein an e!press train and a local train are traveling in opposite directions on the same trac$1 the e!press train is allowed to travel on the same trac$ and the local train has to switch on to the other trac$. Two sensors are placed at the either sides of the junction where the trac$ switches. If there4s a train approaching from the other side then another sensor placed along that direction gets activated and will send an interrupt to the controller. The interrupt service routine switches the trac$. Indicator lights have been provided to avoid collisions. 6ere the switching operation is performed using a stepper motor. Assuming that within a certain delay the train has passed the trac$ is switched bac$ to its original position allowing the first train to pass without any interruption. This concept of trac$ switching can be applied at &$m distance from the stations.

In this project Atmel ,-c%& :icro controller Integrated (hip plays the main role. The program for this project is embedded in this :icro controller Integrated (hip and interfaced to all the peripherals. The timer program is inside the :icro controller I( to maintain all the functions as per the scheduled time. The 9i+uid crystal /isplay "9(/# is interfaced to Atmel ,-c%& :icro controller to display the message stepper motors are used for the purpose of gate control and trac$ changing interfaced with current drivers chip 89@B''> it4s a &E pin ic.

Infrared sensors are used in this for the detection of the train when ever it sends a signal to microcontroller the stepper motor should operate or message will be displayed on 9(/. It consists of units called transmitter and receiver circuit. Infrared sensor circuit consists of I(%%% timer ( %%% is used to construct an astable multivibrator which has two +uasi-stable states. It generates a s+uare wave of fre+uency >, $6z and amplitude %;olts. It is re+uired to switch 3<@4 the IR 9./. A stepper motor is a widely used device that translates electrical pulses into mechanical movement. They function as their name suggests - they FstepG a little bit at a time. The software is written in (-language and is dumped to the microcontroller to run the project. <peration of this project can be e!plained through three units7 &. *ate control unit B. Trac$ changing unit >. Announcement unit C. Two trains opposite on same trac$ case 2.2.1 Gate control nit:

+IG: ! ! 1

Railways being the cheapest mode of transportation are preferred over all the other means .)hen we go through the daily newspapers we come across many railway accidents occurring at unmanned railway crossings. This is mainly due to the carelessness in manual operations or lac$ of wor$ers. )e in this project have come up with a solution for the same. 8sing simple electronic components we have tried to automate the control of railway gates. As a train approaches the railway crossing from either side the sensors placed at a certain distance from the gate detects the approaching train and accordingly controls the operation of the gate. Also an indicator light has been provided to alert the motorists about the approaching train. The above figure shows the gate controlling unit bloc$ diagram. Its operation can be e!plained through that. As the figure shows it consists of two pairs of infrared sensors placed at two sides of gate. They should $eep at a distance of - cm "B$m in usual case# from the gate. and a stepper motor is used for the purpose of the gate closing and opening. Interfaced to the 89@B''>. )hen train reaches the sensor it is detected by IR sensors placed - cm before the station and led in the sensor will glow because the %%% timer wor$s into +uasi state of operation. such that the IR 9./ should glow till the timer wor$s in +uasi state i.e. when train passes away the sensors it again into normal state then it receives %v at terminals that pin at the ,-c%& terminal goes high which enables the power to the stepper motor to rotate in steps which drives gate to close similarly when it reaches the second pair of sensors it senses and send the signal to the microcontroller to enable the current driver to open the gate by rotating the stepper motor in steps to get bac$ in to original position.

! ! ! Track changing unit:

FIG: 2.2.2 8sing the same principle as that for gate control we have developed a concept of automatic trac$ switching. (onsidering a situation wherein an e!press train and a local train are traveling in opposite directions on the same trac$1 the e!press train is allowed to travel on the same trac$ and the local train has to switch on to the other trac$. Indicator lights have been provided to avoid collisions .6ere the switching operation is performed using a stepper motor. In practical purposes this can be achieved using electromagnets. =or the ease of description we are considering only two plat forms thus this can be implemented to any number of platforms. )hen train reaches the platform before a &'cm distance apart a set of sensors are placed to detect the train and two pair of sensors are placed on each of trac$ at platforms. )hen the train is at the first pair of

sensors it sends a signal to microcontroller to $now the availability of plat form. 6ere after chec$ing availability microcontroller operates stepper motor to change the trac$. The mechanism is arranged as shown in fig. but in this case the trac$ changing is done due to second sensor that used to open the gate. It consists of %v driven stepper motor 89@ B''> current driver chip and pulley for trac$ changing mechanism. ! ! , Announce*ent unit: 8sually announcement made at the station for the information of train arrival and departure. In this model we are using a buzzer for the announcement and 9(/ for the purpose of display message. 9(/ is interfaced to ,-(%& microcontroller. The announcement and display message is according to the second sensor which should be used for the purpose of gate opening.

! ! , 1 Train arri-al )etection77 /etection of train approaching the gate can be sensed by means of sensors R& RB R>HRC placed on either side of the gate. In particular direction of approach R& is used to sense the arrival1 R> is used to sense the departure of the train. In the same way RCHRB senses arrival and departure in the other direction. Train arrival and departure sensing can be achieved by means of relay techni+ue. A confined part of parallel trac$ is supplied with positive voltage and ground. As wheels of the train is made up of aluminum which is a conducting material it shorts two parallel trac$s. )hen the wheels of the train moves over it both trac$s are shorted to ground and this acts as a signal to microcontroller ",-(%&# indicating train arrival. The train detection in the other direction is done in the same way by the sensors R& H RC. These sensors are placed five $ilometers before the gate. ! ! , ! warning #or roa) users: At that moment the train arrival is sensed on either of the gate road users are warned about the train approach by R./ signal placed to caution

the road users passing through the gate .R./ signal appears for the road user once the train cuts the relay sensor placed before the %0ms before the gate .A buzzer is for train when there is any obstacle1 signal is made R./ for train in order to slow done its speed before %$m from gate. ! ! , , Train )e"arture )etection: /etection of train is also done using relay techni+ues as e!plained the head of train arrival detection. 2ensor R>HRB respectively considering direction of train approach do train departure. A message is displayed on 9(/ when train reaches the platform. 2ensed by IR sensors. +uture enhance*ent7 In our techni+ue though it has many merits but still the power supply of BB>; A( P<).R is re+uired for functioning of the motor. It can be avoided with the help of a battery charged by a 2olar (ell. 2ince solar energy is an ine!haustible natural source of energy. ! ! . Two trains o""osite on sa*e track: )e $now that the rate of accidents increasing day by day in this because failure of mechanism at trac$ changing two trains coming on same trac$. This can also happens some times due to human negligence. This can avoided by using the following unmanned detection for two trains coming on same trac$ case. In our model of project we are using the gate controlling pair of sensors to e!ecute this method. i.e. when two trains are coming same trac$ at that location the two sensors will operate at a time i.e. two %%% timers of circuit are driven in to +uasi stable state and thus corresponding two buzzer will operate at a time and two IR 9./ will operate and hence signal sends to micro processor to operate the stepper motor at tac$ changing. The components that we use in order to e!ecute are stepper motor %v 89@B''> AT,-(%& A@/ IR sensors. ! ! / Initial signal )is"la0: 2ignals are placed near gate each at a specified distance. Train may be approaching gate at either direction so all four signals are made R./ initially to indicate gate is <P.@./ and vehicles are going through gate. The road user signals are made

*R..@ so that they freely move through gate. 5uzzer is <== since there is no approach of train and users need not be warned.

Chapter 3

!O"#R $U!!%&

3.1 Circ it Diagra' an( intro( ction:

+IG: , 1 Power supply unit consists of following units

i# 2tep down transformer ii# Rectifier unit iii# Input filter iv# Regulator unit v# <utput filter , !: ST'(DO1N TRANS+OR&'R The 2tep down Transformer is used to step down the main supply voltage from B>'; A( to lower value. This B>' A( voltage cannot be used directly thus it is stepped down. The Transformer consists of primary and secondary coils. To reduce or step down the voltage the transformer is designed to contain less number of turns in its secondary core. The output from the secondary coil is also A( waveform. Thus the conversion from A( to /( is essential. This conversion is achieved by using the Rectifier (ircuitI8nit.

, , R'CTI+I'R UNIT: The Rectifier circuit is used to convert the A( voltage into its corresponding /( voltage. There are 6alf-)ave =ull-)ave and bridge Rectifiers available for this specific function. The most important and simple device used in Rectifier circuit is the diode. The simple function of the diode is to conduct when forward biased and not to conduct in reverse bias. The =orward 5ias is achieved by connecting the diode4s positive with positive of the battery and negative with battery4s negative. The efficient circuit used is the =ull wave 5ridge rectifier circuit. The output voltage of the rectifier is in rippled form the ripples from the obtained /( voltage are removed using other circuits available. The circuit used for removing the ripples is called =ilter circuit. , . IN(UT +ILT'R7 (apacitors are used as filter. The ripples from the /( voltage are removed and pure /( voltage is obtained. And also these capacitors are used to reduce the harmonics of the input voltage. The primary action performed by capacitor is charging and discharging. It charges in positive half cycle of the A( voltage and it will discharge in

negative half cycle. 2o it allows only A( voltage and does not allow the /( voltage. This filter is fi!ed before the regulator. Thus the output is free from ripples. , / R'GULATOR UNIT7

+IG , 1 ! 234/ Regulator Regulator regulates the output voltage to be always constant. The output voltage is maintained irrespective of the fluctuations in the input A( voltage. As and then the A( voltage changes the /( voltage also changes. Thus to avoid this Regulators are used. Also when the internal resistance of the power supply is greater than >' ohms the output gets affected. Thus this can be successfully reduced here. The regulators are mainly classified for low voltage and for high voltage. =urther they can also be classified as7 i# Positive regulator &---J input pin B---J ground pin >---J output pin It regulates the positive voltage. ii# @egative regulator &---J ground pin B---J input pin >---J output pin It regulates the negative voltage.

, 5 OUT(UT +ILT'R: The =ilter circuit is often fi!ed after the Regulator circuit. (apacitor is most often used as filter. The principle of the capacitor is to charge and discharge. It charges during the positive half cycle of the A( voltage and discharges during the negative half cycle. 2o it allows only A( voltage and does not allow the /( voltage. This filter is fi!ed after the Regulator circuit to filter any of the possibly found ripples in the output received finally.

6ere we used '.&K= capacitor. The output at this stage is %; and is given to the :icrocontroller.

Chapter 4
%CD INT#RF)CING "IT* )T+,C-1

LCD INT'R+ACING 1IT6 AT37C/1 . 1 D'SCRI(TION

FIG: ..1. 9(/ is used in this project for the purpose of displaying message at the station. 9(/ interfacing consists of several parts li$e AT,-(C%& microprocessor B L &E line 9(/ are main components needed. AT,-(%& is a C' pin /IP micro processor. 9(/ is a B line &E pin device B lines means it contains B rows to display. To develop a protocol to interface this 9(/ with ,-(%& first we have to understand how they functions. These displays contain two internal byte-wide registers one for command and second for characters to be displayed. There are three control signals called RI) /IIR2 and .n. 2elect 5y ma$ing R2I/I signal ' you can send different commands to display. These commands are used to initialize 9(/ to display pattern to shift cursor or screen etc.

AT,-(%& can be divided in to C ports and each port consists of , pins. All the data lines of 9(/ are connected with port P&. i.e. data lines /'-/& are connected to port P& i.e. to pin numbers & to , through a 2I9 2I9 is a few ohms of resistance connected to withstand the large voltages and currents. 3.@4 pin is connected with PB.' 3/I4 "R2# is connected with PB.& and RI) pin is connected with PB.B. i.e. the three pins are connected to the port two. The operation of 9(/ depends upon these three pin only. =or the pins &, and &- a crystal oscillator circuit is connected to generate cloc$ signals to the micro processor to enable its pins. And B'th pin is grounded with oscillator. C'th pin is given to the ;cc i.e. supply lines. And PB.E is given to out put terminals of IR sensors. And ground terminal of IR sensor is given to B'th pin. . ! Descri"tion o# LCD inter#acing "rogra*: A (-language program is written to interface the 9(/ with AT,-(%& is written in $eel c software. Initially all the variables and pins are set to zero i.e. initialized all the re+uired codes to write this program are in reg%&.h header file. =irst the data lines are initialized to byte of pins i.e. to a port using 2=R instruction. And R2 R) .@ 2.@2. and 9./ variables are initialized to pB.' pB.& pB.B pB.% and pB.D simultaneously. A delay of B% is given after the each e!ecution of the instruction. And port ' is initialized as output port. In the program a separate function is written for display message. )hen R> RC sensor senses the signal to the microcontroller then the variable 2.@2. set to 3logical high4 i.e. to &. And R2M& and R) M'. Then first display function calls for display on first line of 9(/. After that it calls for display message on second line of the 9(/. @ow the message is displayed and reached the station. 2o it stays for some time. A delay of B%'' sec is given to run program to display the message.

/uring this 9(/ displays4 a message li$e FTRAI@ I2 (<:I@* 6I-T.(6 (<99.*. F Then again 2.@2. variable set to zero i.e. 3logical low4. In this R2M' and R)M'.

Chapter #
$T#!!#R /OTOR INT#RF)CING "IT* )T+,C-1 U$ING U%N2003

$tepper 'otor interfacing 1ith )T+,C-1 -.1. intro( ction:

Fig -.1. 2hows the complete diagram of a stepper motor interfacing

=ig shows the stepper motor interfacing with AT,-(%& using 89@B''>. The interfacing of stepper motor consists of several parts li$e AT,-(%& microcontroller stepper motor and 89@B''> current driver chip. This can be used in this project for the purpose of gate control and trac$ switching. =or the gate control a &Bv stepper motor is used and for the purpose of trac$ switching %v stepper motor is used. 89@B''> is a current driver chip used for supply control to the stepper motor1 it is a &E pin dip. AT,-(%& is a C' pin dip micro controller can be divided in to four ports it is driven by %v supply.

+ig/ 1 1 shows the two stepper motors interfaced with AT,-(%& using 89@B''> for the purpose of this project. 6ere a stepper motor is used for controlling the gates and trac$ switching. A stepper motor is a widely used device that translates electrical pulses into mechanical movement. They function as their name suggests - they FstepG a little bit at a time. 2teppers don4t simply respond to a cloc$ signal. They have several windings which need to be energized in the correct se+uence before the motor4s shaft will rotate. Reversing the order of the se+uence will cause the motor to rotate the other way. The bloc$ diagram of stepper motor interfacing is shown bellow7

+ig / 1 ! The connections according to the )iagra* shown can be as follows7 The two output terminals of sensors are given to the port one terminals & and B. Remaining two terminals are grounded at B'th pin and the buzzer terminals are given at C and % pins of micro controller and Eth is given to 9./ which operates for two trains opposite case. -th pin is reset pin through capacitor parallel with resistor. &,th and &-th pins are given to the crystal oscillator for the purpose of generating cloc$ signals and B'th pin is grounded. C'th pin is given to supply i.e. ;cc. Port ' is given to current driver chip 89@B''> through a C-pin real connector for which middle two pins are grounded and one is given to %v supply line and another is to &Bv supply line. Port B is given to another 89@B''> chip to drive another stepper motor. These two chips connected to microcontroller through a source in line (alled SIL.

+ig / 1 , shows connection diagram of stepper motor with 89@B''>. 89@B''> is a &E pin dip. Its connections can be e!plained as follows7 =irst C-pins of chip are connected to microcontroller pin at >D-C' pins and second at B&-BC pins. And ,th pin of chip is grounded. A stepper contains % terminals C winding wires and a power supply wire. These C winding wires are connected to chip and another to supply. in this circuit too the four pins ?(ontroller pin &? B > and C will control the motion and direction of the stepper motor according to the step se+uence sent by the controller.

/ ! Descri"tion o# C8"rogra* #or gate control9 track switching9 an) two trains o""osite case: A (-language program is written to interface the 9(/ with AT,-(%& is written in $eel c software. Initially all the variables and pins are set to zero i.e. initialized all the re+uired codes to write this program are in reg%&.h header file. Two sensors are initialized with variables sense& senseB at port pins p&.' and p&.&. with buzzers buzzer& and buzzerB as buz& buzB at p&.C and p&.%. and the led is connected at pins pB.D. In the program port& is set as output port and all sensor and buzzer variables are initialized to zero. =or gate opening the program e!ecution will be as follows7 The sense& pin go es high with detection of first pair of sensors then it sends a signal to dri'e stepper motor. (hen automatically the gate opens. =or gate closing the program e!ecution will be as follows7 The senseB pin goes high with detection of first pair of sensors then it sends a signal to drive stepper motor. Then automatically the gate closes. 5y rotating the stepper motor in reverse direction. =or two trains opposite case the e!ecution of program will be as follows7 The sense& and senseB pins goes high at a time and the buzzer gives alarm and gate closes because we are doing this at that part of the module. And us gives a user or the person at control should ta$e this to them. The e!ecution of program for trac$ changing as follows7

)hen senseB pin goes high the microcontroller should operate the stepper motor for trac$ changing which by use of pulley helps in changing trac$ to avoid accidents. This mechanism can be used for two purposes one in the case of two trains opposite case and another in the case of auto signaling at the platforms.

Chapter %
INFR)R#D $#N$OR$

Infrare( sensors 2.1.0 intro( ction:


This infrared sensor also called as IR sensors consists of two parts7 &. IR transmitter circuit B. IR receiver unit The transmitter unit consists of an infrared 9./ and its associated circuitry. 5 1 1 IR Trans*itter unit:

The IR transmitter circuit is shown in the #igure 5 1 1. The transmitter circuit consists of the following components7 &. I( %%% B. Resistors >. (apacitors

C. IR 9./ The IR 9./ emitting infrared light is put on in the transmitting unit. To generate IR signal %%% I( based astable multivibrator is used. Infrared 9./ is driven through transistor 5( %C,. I( %%% is used to construct an astable multivibrator which has two +uasi-stable states. It generates a s+uare wave of fre+uency >,$6z and amplitude %;olts. It is re+uired to switch 3<@4 the IR 9./.

5 1 ! IR Recei-er circuit:

The IR receiver circuit is shown in the #igure 5 1 !. The receiver circuit consists of the following components7 &. T2<P&D>, "sensor# B. I( %%% >. Resistors C. (apacitors

The receiver unit consists of a sensor and its associated circuitry. In receiver section the first part is a sensor which detects IR pulses transmitted by IR-9./. )henever a train crosses the sensor the output of IR sensor momentarily transits through a low state. As a result the monostable is triggered and a short pulse is applied to the port pin of the ,'%& microcontroller. <n receiving a pulse from the sensor circuit the controller activates the circuitry re+uired for closing and opening of the gates and for trac$ switching.

Chapter &
*)RD")R# D#$CRI!TION

#/3#DD#D $&$T#/$ 4.1 intro( ction: A system is something that maintains its e!istence and functions as a whole through the interaction of its parts. ..g. 5ody Access (ontrol etc. An embedded system is micro controller-based software driven reliable real-time control system. :icro controllers and :icroprocessors are widely used in embedded system products. An embedded product uses a :icro controller to do one tas$ only. A Printer is an e!ample of embedded system that it is getting the data and printing it. N N N N .mbedded 2ystem is a combination of hardware and software used to achieve a single specific tas$. .mbedded systems are computer systems that monitor respond to or control an e!ternal environment. .nvironment connected to systems through sensors actuators and other II< interfaces. .mbedded system must meet timing H other constraints imposed on it by environment. 6igh-end embedded H lower end embedded systems. 6igh-end embedded system *enerally >B EC 5it (ontrollers used with <2. .!amples Personal /igital Assistant and :obile phones etc. 9ower end embedded systems - *enerally , &E 5it (ontrollers used with a minimal operating systems and hardware layout designed for the specific purpose. .!amples 2mall controllers and devices in our every day life li$e )ashing :achine :icrowave <vens where they are embedded in.

&icrocontroller 2 ! intro)uction7 A computer-on-a-chip is a variation of a microprocessor which combines the processor core "(P8# some memory and II< "inputIoutput# lines all on one chip. The computer-on-a-chip is called the microcomputer whose proper meaning is a computer using a "number of# microprocessor"s# as its (P8s while the concept of the microcomputer is $nown to be a microcontroller. A microcontroller can be viewed as a set of digital logic circuits integrated on a single silicon chip. This chip is used for only specific applications. 2!1 AD:ANTAG'S O+ USING A &ICROCONTROLL'R O:'R &ICRO(ROC'SSOR7 A designer will use a :icrocontroller to &. *ather input from various sensors B. Process this input into a set of actions >. 8se the output mechanisms on the :icrocontroller to do something useful C. RA: and R<: are inbuilt in the :(. %. (heap compared to :P. E. :ulti machine control is possible simultaneously. .!amples7 ,'%& ,-(%& "AT:A9# PI( ":icrochip# :otorola ":otorola# AR: Processor Applications7 (ell phones (omputers Robots Interfacing to two pc4s.

37c/1 &icrocontroller IC The AT,-(%& is a low-power high-performance (:<2 ,-bit microcomputer with C0bytes of =lash programmable and erasable read only memory "P.R<:#. The device is manufactured using Atmel4s high-density nonvolatile memory technology and is compatible with the industry-standard :(2-%& instruction set and pin out. The on-chip =lash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. 5y combining a versatile ,-bit (P8 with =lash on a monolithic chip the Atmel AT,-(%& is a powerful microcomputer which provides a highly-fle!ible and cost-effective solution to many embedded control applications. The AT,-(%& provides the following standard features7 C0bytes of =lash &B, bytes of RA: >B II< lines two &E-bit timerIcounters a five vector two-level interrupt architecture a full duple! serial port on-chip oscillator and cloc$ circuitry. In addition the AT,-(%& is designed with static logic for operation down to zero fre+uency and supports two software selectable power saving modes. The Idle :ode stops the (P8 while allowing the RA: timerIcounters serial port and interrupt system to continue functioning. The Power-down :ode saves the RA: contents but freezes the oscillator disabling all other chip functions until the ne!t hardware reset.

2 ! ! (in )escri"tion o# AT&'L At37c/17

Fig:

4.2. 2

The AT ,-c%& micro controller is a C'-pin I(. The C'th pin of the controller is ;cc pin and the %; dc supply is given to this pin. This B'th pin is ground pin. A &B :6O crystal oscillator is connected to &,th and &-th pins of the AT ,-c%& micro controller and two BBpf capacitors are connected to ground from &,th and &-th pins. The -th pin is Reset pin.

(ort 4 Port ' is an ,-bit open-drain bi-directional II< port. As an output port each pin can sin$ eight TT9 inputs. )hen &s are written to port ' pins the pins can be used as high impedance inputs. Port ' may also be configured to be the multiple!ed low order addressIdata bus during accesses to e!ternal program and data memory. In this mode P' has internal pull-ups. Port ' also receives the code bytes during =lash programming and outputs the code bytes during program verification. .!ternal pull-ups are re+uired during program verification.

(ort 1

Port & is an ,-bit bi-directional II< port with internal pull-ups. The Port & output buffers can sin$Isource four TT9 inputs. )hen &s are written to Port & pins they are pulled high by the internal pull-ups and can be used as inputs. As inputs Port & pins that are e!ternally being pulled low will source current "II9# because of the internal pull-ups. Port & also receives the low-order address bytes during =lash programming and verification.

(ort !

Port B is an ,-bit bi-directional II< port with internal pull-ups. The Port B output buffers can sin$Isource four TT9 inputs. )hen &s are written to Port B pins they are pulled high by the internal pull-ups and can be used as inputs. As inputs Port B pins that are e!ternally being pulled low will source current "II9# because of the internal pull-ups. Port B emits the high-order address byte during fetches from e!ternal program memory and during accesses to e!ternal data memory that uses &E-bit addresses ":<;P Q /PTR#. In this application it uses strong internal pull-ups when emitting &s. /uring accesses to e!ternal data memory that uses ,-bit addresses ":<;P Q RI# Port B emits the contents of the PB

2pecial =unction Register. Port B also receives the high-order address bits and some control signals during =lash programming and verification.

(ort ,

Port > is an ,-bit bi-directional II< port with internal pull-ups. The Port > output buffers can sin$Isource four TT9 inputs. )hen &s are written to Port > pins they are pulled high by the internal pull-ups and can be used as inputs. As inputs Port > pins that are e!ternally being pulled low will source current "II9# because of the pull-ups. Port > also serves the functions of various special features of the AT,-(%& as listed below7

(ort (in

Alternate +unctions

P>.' P>.& P>.B P>.> P>.C P>.% P>.E P>.D

RP/ "serial input port# TP/ "serial output port# I@T' "e!ternal interrupt '# I@T& "e!ternal interrupt &# T' "timer ' e!ternal input# T& "timer & e!ternal input# )R "e!ternal data memory write strobe# R/ "e!ternal data memory read strobe#

Port > also receives some control signals for =lash programming and verification.

R$T )eset input. * high on this pin for two machine cycles while the oscillator is running resets the de'ice.

AL';(ROG

Address 9atch .nable output pulse for latching the low byte of the address during accesses to e!ternal memory. This pin is also the program pulse input "PR<*# during =lash programming. In normal operation A9. is emitted at a constant rate of &IE the oscillator fre+uency and may be used for e!ternal timing or cloc$ing purposes. @ote however that one A9. pulse is s$ipped during each access to e!ternal /ata :emory. If desired A9. operation can be disabled by setting bit ' of 2=R location ,.6. )ith the bit set A9. is active only during a :<;P or :<;( instruction. <therwise the pin is wea$ly pulled high. 2etting the A9.-disable bit has no effect if the micro controller is in e!ternal e!ecution mode.

(S'N

Program 2tore .nable is the read strobe to e!ternal program memory. )hen the AT,-(%& is e!ecuting code from e!ternal program memory P2.@ is activated twice each machine cycle e!cept that two P2.@ activations are s$ipped during each access to e!ternal data memory.

'A;:((

.!ternal Access .nable. .A must be strapped to *@/ in order to enable the device to fetch code from e!ternal program memory locations starting at ''''6 up to ====6. @ote however that if loc$ bit & is programmed .A will be internally latched on reset. .A should be strapped to ;(( for internal program e!ecutions. This pin also receives the

&B-volt programming enable voltage ";PP# during =lash programming for parts that re+uire &B-volt ;PP. <TAL1 Input to the inverting oscillator amplifier and input to the internal cloc$ operating circuit. <TAL! It is the output from the inverting oscillator amplifier.

Rela5 (ri6ers 4.3 intro( ction:

IC9 ULN!44,A )escri"tion7

#ig: 2 , 4

Pins @o. of7&E Temperature <perating Range7-B'R( to S,%R( Transistor Polarity7@P@ Transistors @o. of7D (ase 2tyle7/IP-&E Temp <p. :in7-B'R( Temp <p. :a!7,%R( 5ase @umber7B''> (hannels @o. of7D (urrent <utput :a!7%''mA /evice :ar$ing789@B''>A I( *eneric @umber7B''> Input Type7TT9 (:<2 %; 9ogic =unction @umber7B''> <utput Type7 <pen (ollector Transistor Type7 Power /arlington ;oltage Input :a!7%; ;oltage <utput :a!7%';

7.3.1 PIN CONNECTIONS OF ULN2003:

Fig: 7.3.1 The 89@B''&A 89@B''BA 89@B''> and 89@B''CAare high ;oltage high current /arlington arrays each containing seven open collector /arlington pairs with common emitters. .ach channel rated at %''mAand can withstand pea$ currents of E''mA.2uppressiondiodesare included for inductive load driving and the inputs are pinned opposite the outputs to simplify board layout. These versatile devices are useful for driving a wide range of loads including solenoids relays /( motors1 9./ displays filament lamps thermal print heads and high power buffers. The 89@B''&AIB''BAIB''>A and B''CA are supplied in &E pin plastic /IP pac$ages with a copper lead frame to reduce thermal resistance. They are available also in small outline pac$age "2<-&E# as 89@B''&/IB''B/IB''>/IB''C/.

4.3.2 $che'atics of Darlington7s pair:

Fig: 4.3.2 /arlington pairs are bac$ to bac$ connection of two transistors with some source resistors.

Fig:4.3.3 shows the /arlington pair connection of transistor. The circuit above is a 3/arlington Pair4 driver. The first transistor4s emitter feeds into the second transistor4s base and as a result the input signal is amplified by the time it reaches the output. The important point to remember is that the /arlington Pair is made up of two transistors

and when they are arranged as shown in the circuit they are used to amplify wea$ signals. The amount by which the weak signal is amplified is called the +,*-./. 4.3.3 +'ATUR'S O+ DRI:'R: 2even /arlington4s per pac$age <utput currents%''mA per driver"E''mA pea$# Integrated suppression diodes for inductive loads <utputs can be paralleled for high currents TT9I(:<2IP:<2I/T9 compatible inputs. Inputs pinned opposite to outputs 2implified layout .

IC --- TI/#R$ 4...0 Description:

Fig4...0 sho1s +8pin (ip for IC --- ti'er

I( %%% TI:.R used in this project for the purpose of IR sensor circuits. It can operate in several modes its internal circuit and description is as e!plained below7 2tandard %%% and %%E I(s create a significant TglitchT on the supply when their output changes state. This is rarely a problem in simple circuits with no other I(s but in more comple! circuits a smoothing capacitor "e.g. &''K=# should be connected across the S;s and '; supply near the %%% or %%E. The input and output pin functions are described briefly below and there are fuller e!planations covering the various circuits7

Astable - producing a s+uare wave :onostable - producing a single pulse when triggered 5istable - a simple memory which can be set and reset

5uffer - an inverting buffer "2chmitt trigger#

In"uts o# ///7

Trigger input7 when U &I> ;s "Tactive lowT# this ma$es the output high "S;s#. It monitors the discharging of the timing capacitor in an astable circuit. It has a high input impedance J B: . Threshold input7 when J BI> ;s "Tactive highT# this ma$es the output low "';#V. It monitors the charging of the timing capacitor in astable and monostable circuits. It has a high input impedance J &': . V providing the trigger input is J &I> ;s otherwise the trigger input will override the threshold input and hold the output high "S;s#. Reset input7 when less than about '.D; "Tactive lowT# this ma$es the output low "';# overriding other inputs. )hen not re+uired it should be connected to S;s. It has an input impedance of about &'$ . (ontrol input7 this can be used to adjust the threshold voltage which is set internally to be
B

I> ;s. 8sually this function is not re+uired and the control input is connected to '; with

a '.'&K= capacitor to eliminate electrical noise. It can be left unconnected if noise is not a problem. The discharge pin is not an input but it is listed here for convenience. It is connected to '; when the timer output is low and is used to discharge the timing capacitor in astable and monostable circuits. Out"ut o# /// The output of a standard %%% or %%E can sin$ and source up to B''mA. This is more than most I(s and it is sufficient to supply many output transducers directly including 9ed4s "with a resistor in series# low current lamps piezo transducers loudspea$ers "with a capacitor in series# relay coils "with diode protection# and some motors "with diode

protection#. The output voltage does not +uite reach '; and S;s especially if a large current is flowing. To switch larger currents you can connect a transistor. The ability to both sin$ and source current means that two devices can be connected to the output so that one is on when the output is low and the other is on when the output is high. The top diagram shows two 9ed4s connected in this way. This arrangement is used in the 9evel (rossing project to ma$e the red 9ed4s flash alternately. 2 . 1 /// ti*ers as asta=le: An astable circuit produces a Ts+uare wave41 this is a digital waveform with sharp transitions between low "';# and high "S;s#. @ote that the durations of the low and high states may be different. The circuit is called an astable because it is not stable in any state7 the output is continually changing between TlowT and ThighT. The time period "T# of the s+uare wave is the time for one complete cycle but it is usually better to consider fre+uency "f# which is the number of cycles per second. &.C "R& S BRB# L (&

T M '.D L "R& S BRB# L (& and f M

T M time period in seconds "s# f M fre+uency in hertz "6z# R& M resistance in ohms " # RB M resistance in ohms " # (& M capacitance in farads "=# The time period can be split into two parts7 T M Tm S Ts :ar$ time "output high#7 Tm M '.D L "R& S RB# L (& 2pace time "output low#7 Ts M '.D L RB L (&

:any circuits re+uire Tm and Ts to be almost e+ual1 this is achieved if RB is much larger than R&.

fig #ig 2 . 1 =or a standard astable circuit Tm cannot be less than Ts but this is not too restricting because the output can both sin$ and source current. =or e!ample an 9./ can be made to flash briefly with long gaps by connecting it "with its resistor# between S;s and the output. This way the 9./ is on during Ts so brief flashes are achieved with R& larger than RB ma$ing Ts short and Tm long. If Tm must be less than Ts a diode can be added to the circuit as e!plained under duty cycle below. (hoosing R& RB and (& R& and RB should be in the range &$ to &: . It is best to choose (& first because

capacitors are available in just a few values.


(hoose (& to suit the fre+uency range you re+uire "use the table as a guide#. (hoose RB to give the fre+uency "f# you re+uire. Assume that R& is much smaller than RB "so that Tm and Ts are almost e+ual# then you can use7 RB M '.D f L (&

(hoose R& to be about a tenth of RB "&$

min.# unless you want the mar$ time

Tm to be significantly longer than the space time Ts.


If you wish to use a variable resistor it is best to ma$e it RB. If R& is variable it must have a fi!ed resistor of at least &$ "this is not re+uired for RB if it is variable#. in series

Asta=le o"eration )ith the output high "S;s# the capacitor (& is charged by current flowing through R& and RB. The threshold and trigger inputs monitor the capacitor voltage and when it reaches BI>;s "threshold voltage# the output becomes low and the discharge pin is connected to ';.

+ig 2 . 1 1 The capacitor now discharges with current flowing through RB into the discharge pin. )hen the voltage falls to &I>;s "trigger voltage# the output becomes high again and the discharge pin is disconnected allowing the capacitor to start charging again. This cycle repeats continuously unless the reset input is connected to '; which forces the output low while reset is ';. An astable can be used to provide the cloc$ signal for circuits such as counters. A low fre+uency astable "U &'6z# can be used to flash an 9./ on and off higher fre+uency flashes are too fast to be seen clearly. /riving a loudspea$er or piezo

transducer with a low fre+uency of less than B'6z will produce a series of Tclic$sT "one for each lowIhigh transition# and this can be used to ma$e a simple metronome. An audio fre+uency astable "B'6z to B'$6z# can be used to produce a sound from a loudspea$er or piezo transducer. The sound is suitable for buzzes and beeps. The natural "resonant# fre+uency of most piezo transducers is about >$6z and this will ma$e them produce a particularly loud sound.

Dut0 c0cle The duty cycle of an astable circuit is the proportion of the complete cycle for which the output is high "the mar$ time#. It is usually given as a percentage. =or a standard %%%I%%E astable circuit the mar$ time "Tm# must be greater than the space time "Ts# so the duty cycle must be at least %'W7

uty cycle 0

T' R1 9 R2 : T' 9 Ts R1 9 2R2

; Fig4...1.2 shows the ### timer in astable operation with )2. To achie6e a ( t5 c5cle of less than -0< a diode can be added in parallel with )2 as shown in the diagram. (his bypasses )2 during the charging 1mark2 part of the cycle so that (m depends only on )1 and C13

T' : 0.4 = R1 = C1 1ignoring 4.&5 across diode2 Ts : 0.4 = R2 = C1 1unchanged2 ( t5 c5cle 1ith (io(e 0 T' R1 : T' 9 Ts R1 9 R2

7.4.2 555 Monostab !

###

monostable

output,

single

pulse

###

monostable

circuit

with

manual

trigger

Fig: 4...2.0 * monostable circuit produces a single output pulse when triggered. -t is called a monostable because it is stable in just one state3 6output low6. (he 6output high6 state is temporary. (he duration of the pulse is called the time period 1(2 and this is determined by resistor )1 and capacitor C13

time period, T : 1.1 = R1 = C1


( 0 time period in seconds 1s2 )1 0 resistance in ohms 1 2 C1 0 capacitance in farads 172 (he ma$imum reliable time period is about 14 minutes.

Choose C1 first 1there are relati'ely few 'alues a'ailable2.

Fig 4...2.1

(hoose R& to give the time period you need. R& should be in the range &$ to &: so use a fi!ed resistor of at least &$ in series if R& is variable. 5eware that electrolytic capacitor values are not accurate1 errors of at least B'W are common. 5eware that electrolytic capacitors lea$ charge which substantially increases the time period if you are using a high value resistor - use the formula as only a very rough guideX

2 . ! 1 &onosta=le o"eration The timing period is triggered "started# when the trigger input "%%% pin B# is less than & I> ;s this ma$es the output high "S;s# and the capacitor (& starts to charge through resistor R&. <nce the time period has started further trigger pulses are ignored. The threshold input "%%% pin E# monitors the voltage across (& and when this reaches B I> ;s the time period is over and the output becomes low. At the same time discharge "%%% pin D# is connected to '; discharging the capacitor ready for the ne!t trigger.

The reset input "%%% pin C# overrides all other inputs and the timing may be cancelled at any time by connecting reset to '; this instantly ma$es the output low and discharges the capacitor. If the reset function is not re+uired the reset pin should e connected to S;s.

7.4.3 555"55# In$!%ting &'((!% )S*+,itt t%igg!%- o% NOT gat!

### in'erting buffer circuit 1a .8( gate2

.8( gate symbol

Fig: 4...3.0 the buffer circuitTs input has a very high impedance "about &: # so it re+uires only a few KA but the output can sin$ or source up to B''mA. This enables a high impedance signal source "such as an 9/R# to switch a low impedance output transducer "such as a lamp#. It is an inverting buffer or @<T gate because the output logic state "lowIhigh# is the inverse of the input state7

Input low "U &I> ;s# ma$es output high S;s Input high "J BI> ;s# ma$es output low ';

)hen the input voltage is between &I> and BI> ;s the output remains in its present state. This intermediate input region is a dead space where there is no response a property called hysteresis it is li$e bac$lash in a mechanical lin$age. This type of circuit is called a 2chmitt trigger. If high sensitivity is re+uired the hysteresis is a problem but in many circuits it is a helpful property. It gives the input a high immunity to noise because once the circuit

output has switched high or low the input must change bac$ by at least &I> ;s to ma$e the output switch bac$.

7.4.5 555 timer to modulate infrared (IR) light An IR emitter is going to be modulated using an astable %%% timer in this electronics e!ercise. The IR emitter needs to be modulated by a fre+uency of >, $6z since the detector used in this e!ercise only detects >, $6z modulated IR. The detector is set to only see >, $6z modulated IR because there are random IR sources such as overhead lights the sun heaters etc. in most environments that can cause interference if using unmodulated IR. The following two circuits shown in =ig.C and =ig. % are modulated IR transmitter and receivers. .ach circuit should be soldered on separate proto-boards.

Fig. 7.4.5.0 modulated IR transmitter

Fig.7.4.5.1 modulated IR receiver ;erify with the TA that everything is soldered correctly. Then apply power to the transmitter circuit. 8se an oscilloscope to observe the signal at node A. Adjust the &'$Y variable resistor until the signal at node A is a >, $6z series of pulses. Apply power to the receiver circuit Point the IR light emitting diode "9./# on the transmitter to the detector on the receiver. )hen the pushbutton is depressed the visible 9./ on the receiver should blin$. If the visible led is blin$ing randomly put e!posed >% mm camera film around the IR detector.

$tepper 'otor 4.-.1 Description: A stepper motor "or step motor# is a brushless synchronous electric motor that can divide a full rotation into a large number of steps. The motorTs position can be controlled precisely without any feedbac$ mechanism "see open loop control#. 2tepper motors are similar to switched reluctance motors "which are very large stepping motors with a reduced pole count and generally are closed-loop commutated#.

+ig 2 / 1 1

7.5.2 Fundamentals of Operation


2tepper motors operate differently from normal /( motors which rotate when voltage is applied to their terminals. 2tepper motors on the other hand effectively have multiple ?toothed? electromagnets arranged around a central gear-shaped piece of iron. The electromagnets are energized by an e!ternal control circuit such as a microcontroller. To ma$e the motor shaft turn first one electromagnet is given power which ma$es the gearTs teeth magnetically attracted to the electromagnetTs teeth. )hen the gearTs teeth are thus aligned to the first electromagnet they are slightly offset from the ne!t electromagnet. 2o when the ne!t electromagnet is turned on and the first is turned off the gear rotates slightly to align with the ne!t one and from there the process is repeated. .ach of those slight rotations is called a ?step ? with an integral number of steps ma$ing a full rotation. In that way the motor can be turned by a precise angle.

7.5.3 Stepper motor characteristics


2tepper motors are constant power devices. As motor speed increases tor+ue decreases. The tor+ue curve may be e!tended by using current limiting drivers and increasing the driving voltage. 2teppers e!hibit more vibration than other motor types as the discrete step tends to snap the rotor from one position to another. This vibration can become very bad at some speeds and can cause the motor to lose tor+ue. The effect can be mitigated by accelerating +uic$ly through the problem speed range physically damping the system or using a micro-stepping driver. :otors with a greater number of phases also e!hibit smoother operation than those with fewer phases.

7.5.4 Open-loop versus closed-loop commutation


2teppers are generally commutated open loop i.e. the driver has no feedbac$ on where the rotor actually is. 2tepper motor systems must thus generally be over engineered especially if the load inertia is high or there is widely varying load so that there is no possibility that the motor will lose steps. This has often caused the system designer to consider the trade-offs between a closely sized but e!pensive servomechanism system and an oversized but relatively cheap stepper. A new development in stepper control is to incorporate a rotor position feedbac$ "eg. an encoder or resolver# so that the commutation can be made optimal for tor+ue generation according to actual rotor position. This turns the stepper motor into a high pole count brushless servo motor with e!ceptional low speed tor+ue and position resolution. An advance on this techni+ue is to normally run the motor in open loop mode and only enter closed loop mode if the rotor position error becomes too large -- this will allow the system to avoid hunting or oscillating a common servo problem.

7.5.5 Types
There are three main types of stepper motors7

Permanent :agnet 2tepper 6ybrid 2ynchronous 2tepper ;ariable Reluctance 2tepper

Two-phase stepper motors


(here are two basic winding arrangements for the electromagnetic coils in a two phase stepper motor3 bipolar and unipolar. Uni"olar *otors A unipolar stepper motor has logically two windings per phase one for each direction of magnetic field. 2ince in this arrangement a magnetic pole can be reversed without switching the direction of current the commutation circuit can be made very simple "e.g. a single transistor# for each winding. Typically given a phase one end of each winding is made common7 giving three leads per phase and si! leads for a typical two phase motor. <ften these two phase commons are internally joined so the motor has only five leads.

+ig 2 / / 4 Unipolar stepper 'otor coils

In the construction of unipolar stepper motor there are four coils. <ne end of each coil is tide together and it gives common terminal which is always connected with positive terminal of supply. The other ends of each coil are given for interface. 2pecific color code may also be given. 9i$e in my motor orange is first coil "9&# brown is second "9B# yellow is third "9># blac$ is fourth "9C# and red for common terminal. 5y means of controlling a stepper motor operation we can &. Increase or decrease the RP: "speed# of it B. Increase or decrease number of revolutions of it >. (hange its direction means rotate it cloc$wise or anticloc$wise To vary the RP: of motor we have to vary the PR= "Pulse Repetition =re+uency#. @umber of applied pulses will vary number of rotations and last to change direction we have to change pulse se+uence. 2o all these three things just depends on applied pulses. @ow there are three different modes to rotate this motor &. 2ingle coil e!citation B. /ouble coil e!citation >. half coil e!citation 8nipolar stepper motors with si! or eight wires may be driven using bipolar drivers by leaving the phase commons disconnected and driving the two windings of each phase together Zdiagram needed[. It is also possible to use a bipolar driver to drive only one winding of each phase leaving half of the windings unused Zdiagram needed[. Bi"olar *otor 5ipolar motors have logically a single winding per phase. The current in a winding needs to be reversed in order to reverse a magnetic pole so the driving circuit must be more complicated typically with an 6-bridge arrangement. There are two leads per phase none are common. 2tatic friction effects using an 6-bridge have been observed with certain drive topologies 5ecause windings are better utilized they are more powerful than a unipolar motor of the same weight.

38lea) ste""er An , lead stepper is wound li$e a unipolar stepper but the leads are not joined to common internally to the motor. This $ind of motor can be wired in several configurations7

8nipolar. 5ipolar with series windings. This gives higher inductance but lower current per winding. 5ipolar with parallel windings. This re+uires higher current but can perform better as the winding inductance is reduced. 5ipolar with a single winding per phase. This method will run the motor on only half the available windings which will reduce the available low speed tor+ue but re+uire less current.

7.5.6 Theory A step motor can be viewed as a synchronous A( motor with the number of poles "on both rotor and stator# increased ta$ing care that they have no common denominator. Additionally soft magnetic material with many teeth on the rotor and stator cheaply multiplies the number of poles "reluctance motor#. :odern steppers are of hybrid design having both permanent magnets and soft iron cores. To achieve full rated tor+ue the coils in a stepper motor must reach their full rated current during each step. )inding inductance and reverse .:= generated by a moving rotor tend to resist changes in drive current so that as the motor speeds up less and less time is spent at full current -- thus reducing motor tor+ue. As speeds further increase the current will not reach the rated value and eventually the motor will cease to produce tor+ue.

(ull8in tor>ue This is the measure of the tor+ue produced by a stepper motor when it is operated without an acceleration state. At low speeds the stepper motor can synchronize itself with an applied step fre+uency and this Pull-In tor+ue must overcome friction and inertia. (ull8out tor>ue The stepper motor Pull-<ut tor+ue is measured by accelerating the motor to the desired speed and then increasing the tor+ue loading until the motor stalls or ?pulls <ut of synchronism? with the step fre+uency. This measurement is ta$en across a wide range of speeds and the results are used to generate the stepper motorTs dynamic performance curve. As noted below this curve is affected by drive voltage drive current and current switching techni+ues. It is normally recommended to use a safety factor of between %'W and &''W when comparing your desired tor+ue output to the published ?pull-<ut? tor+ue performance curve of a step motor. Detent tor>ue 2ynchronous electric motors using permanent magnets have a remnant position holding tor+ue "called detent tor+ue and sometimes included in the specifications# when not driven electrically. 2oft iron reluctance cores do not e!hibit this behavior. Stepper motor ratings and specifications 2tepper motors nameplates typically give only the winding current and occasionally the voltage and winding resistance. The rated voltage will produce the rated winding current at /(7 but this is mostly a meaningless rating as all modern drivers are current limiting and the drive voltages greatly e!ceed the motor rated voltage. A stepperTs low speed tor+ue will vary directly with current. 6ow +uic$ly the tor+ue falls off at faster speeds depends on the winding inductance and the drive circuitry it is attached to especially the driving voltage.

2teppers should be sized according to published tor+ue curve which is specified by the manufacturer at particular drive voltages andIor using their own drive circuitry. It is not guaranteed that you will achieve the same performance given different drive circuitry so the pair should be chosen with great care.

+ig 2 / 5 4

2 / 2 R(& calculation:8 <ne can calculate the e!act RP: at which motor will run. )e $now that motor needs B'' pulses to complete & revolution. :eans if B'' pulses applied in & second motor will complete & revolution in & second. @ow & rev. in & sec means E' rev. in & minute. That will give us E' RP:. @ow B'' pulses in & sec means the PR= is B'' 6z. And delay will be % milli second "ms#. @ow let4s see it reverse. V If delay is &' ms then PR= will be &'' 6z. V 2o &'' pulses will be given in & sec V :otor will complete & revolution in B second V 2o the RP: will be >'.

In same manner as you change delay the PR= will be changed and it will change RP:\ 2 / 3 A""lications (omputer-controlled stepper motors are one of the most versatile forms of positioning systems. They are typically digitally controlled as part of an open loop system and are simpler and more rugged than closed loop servo systems. Industrial applications are in high speed pic$ and place e+uipment and multi-a!is machine (@( machines often directly driving lead screws or ball screws. In the field of lasers and optics they are fre+uently used in precision positioning e+uipment such as linear actuators linear stages rotation stages goniometers and mirror mounts. <ther uses are in pac$aging machinery and positioning of valve pilot stages for fluid control systems. (ommercially stepper motors are used in floppy dis$ drives flatbed scanners computer printers plotters and many more devices.

LCD )is"la0 2 5 Descri"tion: 9i+uid crystal display "9(/# has material which combines the properties of both li+uid and crystals. They have a temperature range within which the molecules are almost as mobile as they would be in a li+uid but are grouped together in an order form similar to a crystal

+ig:2 / 2 4

Control Signals It?s #unction M ' )rites character in display RI) M & Reads from display M ' 2elects command register M & 2elects /ata register to display R2I/I .n character M ' /isables the display M & .nables the displa

More

Fig:7.5.7.1 microcontroller devices are using Tsmart 9(/T displays to output visual information. The following discussion covers the connection of a 6itachi 9(/ display to a PI( microcontroller. 9(/ displays designed around 6itachiTs 9(/ 6/CCD,' module are ine!pensive easy to use and it is even possible to produce a readout using the , ! ,' pi!els of the display. 6itachi 9(/ displays have a standard A2(II set of characters plus ]apanese *ree$ and mathematical symbols. This display contains two internal byte-wide registers one for command and second for characters to be displayed. There are three control signals called RI) /IIR2 and .n. The table given below will tell you what the use of these three signals is. 5y ma$ing R2I/I signal ' you can send different commands to display. These commands are used to initialized 9(/ to select display pattern to shift cursor or screen etc. The different commands and their functions are as given below =or an ,-bit data bus the display re+uires a S%; supply plus && II< lines. =or a C-bit data bus it only re+uires the supply lines plus seven e!tra lines. )hen the 9(/ display is not enabled data lines are tri-state which means they are in a state of high impedance "as though they are disconnected# and this means they do not interfere with the operation of the microcontroller when the display is not being addressed. The 9(/ also re+uires > ?control? lines from the microcontroller. .nable ".# This line allows access to the display through RI) and R2 lines. )hen this line is low the 9(/ is disabled and ignores signals from RI) and R2. )hen ".# line is high the 9(/ chec$s the state of the two control lines and responds accordingly. ReadI)rite "RI)# This line determines the direction of data between the 9(/ and

microcontroller. )hen it is low data is written to the 9(/. )hen it is high data is read from the 9(/. Register select "R2# )ith the help of this line the 9(/ interprets the type of data on data lines. )hen it is low an instruction is being written to the 9(/. )hen it is high a character is being written to the 9(/. 5its =unction R2I/IRI) /D /E /% /C /> /B /& /' ' ' ' ' ' ' ' ' ' & (lear 9(/ memory 6ome cursor ' ' ' ' ' ' ' ' & ' (lear and 6ome cursor only s M &I' 7 2hift screenIcursor II< M &I' ' ' ' ' ' ' ' & II< s 7 shift RI9 / M &I' 7 2creen <nI<ff. ( M &I' 7 ' ' ' ' ' ' & / ( 5 cursor <nI<ff. 5 M &I' 7 (ursor blin$Ino blin$ 2I( M &I' 7 2creen I (ursor. RI9 M &I' 7 2hift one space right I left /I9 M &I' 7 ,IC bits per character. @ M &I' 7 BI& rows of char. = M &I' 7 %L&'I%LD dotsIchar. )rite to char. RA: address after this )rites to display RA: address after this 5= M &I' 7 display is busyInot busy )rite byte to last RA: chosen Read byte from last RA: chosen

'

'

'

'

'

&

2I( RI9 '

'

' ' ' & &

' ' '

' ' &

' &

&

/9 @

'

'

(har address

/isplay data address

& 5= (urrent address ' (haracter type & (haracter type +ig:2 / 2 !

This is a high +uality &E character by B line intelligent display module with bac$ lighting )or$s with almost any microcontroller. Rea) )ata #ro* )ata lines @i# it is rea)ingA Reading data from the 9(/ is done in the same way but control line RI) has to be high. )hen we send a high to the 9(/ it will reset and wait for instructions. Typical instructions sent to 9(/ display after a reset are7 turning on a display turning on a cursor

and writing characters from left to right. )hen the 9(/ is initialized it is ready to continue receiving data or instructions. If it receives a character it will write it on the display and move the cursor one space to the right. The (ursor mar$s the ne!t location where a character will be written. )hen we want to write a string of characters first we need to set up the starting address and then send one character at a time. (haracters that 5efore we access // RA: after defining a special character the program must set the // RA: address. )riting and reading data from any 9(/ memory is done from the last address which was set up using set-address instruction. <nce the address of // RA: is set a new written character will be displayed at the appropriate place on the screen. 8ntil now we discussed the operation of writing and reading to an 9(/ as if it were an ordinary memory. 5ut this is not so. The 9(/ controller needs C' to &B' microseconds "u2# for writing and reading. <ther operations can ta$e up to % m2. /uring that time the microcontroller can not access the 9(/ so a program needs to $now when the 9(/ is busy. )e can solve this in two ways. <ne way is to chec$ the 582A bit found on data line /D. This is not the best method because 9(/Ts can get stuc$ and program will then stay forever in a loop chec$ing the 582A bit. The other way is to introduce a delay in the program. The delay has to be long enough for the 9(/ to finish the operation in process. Instructions for writing to and reading from an 9(/ memory are shown in the previous table. At the beginning we mentioned that we needed && II< lines to communicate with an 9(/. 6owever we can communicate with an 9(/ through a C-bit data bus. Thus we can reduce the total number of communication lines to seven. The wiring for connection via a C-bit data bus is shown in the diagram below. In this e!ample we use an 9(/ display with B!&E characters. +eatures

&E (haracters ! B 9ines %!D /ot :atri! (haracter S (ursor 6/CCD,' .+uivalent 9(/ (ontrollerIdriver 5uilt-In C-bit or ,-bit :P8 Interface

2tandard Type )or$s with almost any :icrocontroller *reat ;alue Pricing :a!imum input voltage7 %.>;/( <perating input voltage7 %;/( ,-bit interface data bus (ontroller7 6/CDD,' e+uivalent (haracter font size7 '.&B%?) ! '.B''?6 &C pinIterminals /isplay size7 B.%?9 ! '.D?) :odule size7 >.C?9 ! &.B?) ! '.%?T

'*=e))e) C Co*"iler7 A@2I ( - full featured and portable Reliable - mature field-proven technology :ultiple ( optimization levels An optimizing assembler =ull lin$er with overlaying of local variables to minimize RA: usage (omprehensive ( library with all source code provided

Includes support for BC-bit and >B-bit I... floating point and >B-bit long data types

:i!ed ( and assembler programming 8nlimited number of source files 9istings showing generated assembler Runs on multiple platforms7 )indows 9inu! 8@IP :ac <2 P 2olaris

Aou can compile assemble and lin$ your embedded application with a single step. <ptionally the compiler may be run directly from the command line allowing you to compile assemble and lin$ using one command. This enables the compiler to be integrated into third party development environments such as :icrochipTs :P9A5 I/.. '*=e))e) s0ste* tools: Asse*=ler: An assembler is a computer program for translating assembly language ^ essentially a mnemonic representation of machine language ^ into object code. A cross assembler "see cross compiler# produces code for one type of processor but runs on another. The computational step where an assembler is run is $nown as assembly time. Translating assembly instruction mnemonics into opcodes assemblers provide the ability to use symbolic names for memory locations "saving tedious calculations and manually updating addresses when a program is slightly modified# and macro facilities for performing te!tual substitution ^ typically used to encode common short se+uences of instructions to run inline instead of in a subroutine. Assemblers are far simpler to write than compilers for high-level languages. Assembly language has several benefits7

S"ee)7 Assembly language programs are generally the fastest programs around. S"ace: Assembly language programs are often the smallest.

Ca"a=ilit0: Aou can do things in assembly which are difficult or impossible in 6igh-level languages.

Si*ulator: 2imulator is a machine that simulates an environment for the purpose of training or research. Co*"iler: A compiler is a program that reads a program in one language the source language and translates into an e+uivalent program in another language the target language. The translation process should also report the presence of errors in the source program.

Chapter !
$OFT")R# !ROGR)//ING

So#tware 1 "rogra* #or gate control9 track changing9 an) two rains o""osite case7 _includeUreg%&.hJ void :2/elay "unsigned int value#1 sbit sense&MP&`'1 sbit senseBMP&`&1 sbit buz&MP&`C1

sbit buzBMP&`%1 sbit ledMPB`D1 void main "# a int i1 P&M'!f'1 buz&M'1 buzBM'1 ledM'1 while "&# a if "sense&MM& HH senseBXM&# a buz&M&1 ledM&1 for "iM'1iUMB1iSS# a PBM'!EE1 :2/elay "&'#1 PBM'!((1 :2/elay "&'#1 PBM'!--1 :2/elay "&'#1

PBM'!>>1 :2/elay "&'#1 b b sense&M'1 if "senseBMM& HH sense&XM&# a buz&M'1 ledM'1 for "iM'1 iUMB1iSS# a PBM'!EE1 :2/elay "&'#1 PBM'!>>1 :2/elay "&'#1 PBM'!--1 :2/elay "&'#1 PBM'!((1 :2/elay "&'#1 b

for"iM'1iUMB1iSS# a

P'M'!EE1 :2/elay "&'#1 P'M'!((1 :2/elay "&'#1 P'M'!--1 :2/elay "&'#1 P'M'!>>1 :2/elay "&'#1 b b senseBM'1

if "sense&MM& HH senseBMM&# a buzBM&1 :2/elay "B''#1 buzBM'1 b

sense&M'1 senseBM'1 b

b void :2/elay "unsigned int value# a unsigned int ! y1 for"!M'1 !U&BD%1!SS# for"yM'1yUvalue1ySS#1 b ! "rogra* #or )is"la0ing *essage on LCD7 _includeUreg%&.hJ _includeUstdio.hJ _include Ustring.hJ void lcdcmd "unsigned char value#1 void lcddata "unsigned char value#1 void :2/elay "unsigned int time#1 void /isp:sg "char V/isp#1 void /isp(har "char (6AR#1 sfr ldataM'!-'1 sbit rsMPB`'1 sbit rwMPB`&1 sbit enMPB`B1 sbit senseMPB`%1 sbit ledMPB`D1 void main "#

a unsigned char str ZB'[ str& ZB'[1 int a b total1 aMB1 bM%1 totalMaVb1 P'M'!''1 sprintf"str& ?TRAI@ I2 (<:I@* ?#1 strcpy "str ?V6IT.(6 (<99.*.V?#1 lcdcmd "'!>,#1 IIBline %!D matri! :2/elay "B%#1 lcdcmd "'!'.#1 II :2/elay "B%#1 lcdcmd "'!'&#1 :2/elay "B%#1 lcdcmd "'!'=#1 :2/elay "B%#1 IIlcdcmd "'!'E#1 II:2/elay "B%#1 IIlcdcmd "'!,E#1 senseM'1 ledM'1

while "&#

a senseM'1 if "sensesMM&# a lcdcmd "'!,'#1 :2/elay "B%#1 /isp:sg "str&#1 II lcdcmd "'!c%#1 lcdcmd "'!c'#1 :2/elay "B%#1 /isp:sg "str#1 :2/elay "B%'#1 :2/elay "B%''#1 b senseM'1

b b void lcdcmd "unsigned char value# a ldataMvalue1 rsM'1 rwM'1

enM&1 :2/elay "&#1 enM'1 return1 b void lcddata "unsigned char value# a ldataMvalue1 rsM&1 rwM'1 enM&1 :2/elay "&#1 enM'1 return1 b void :2/elay "unsigned int itime# a unsigned int i j1 for"iM'1iUitime1iSS# for "jM'1jU&''1jSS#1 b void /isp:sg "char V/isp# a

while "V/isp# /isp(har "V/ispSS#1 b void /isp(har "char (6AR# a lcddata "(6AR#1 b

Concl sion: A new approach for improving safety at 9(s on IR has been suggested. =ormats have been given to maintain records of 9( inventories accidentIincident reports. .ach 9( should be assigned a hazard rating and the priority of safety enhancement wor$s be decided accordingly. A regular assessment of safety performance should be done. This approach should be able to bring down the rising trend in accidents at 9(s.

Sco"e o# "ro$ect This project is developed in order to help the I@/IA@ RAI9)AA2 in ma$ing its present wor$ing system a better one by eliminating some of the loopholes e!isting in it. 5ased on the responses and reports obtained as a result of the significant development in the wor$ing system of I@/IA@ RAI9)AA2 this project can be further e!tended to meet the demands according to situation.

This can be further implemented to have control room to regulate the wor$ing of the system. Thus becomes the user friendliness. This circuit can be e!panded and used in a station with any number of platforms as per the usage. Additional modules can be added with out affecting the remaining modules. This allows the fle!ibility and easy maintenance of the developed system. This system consists of following features over manual system7 There is no time lag to operate the device. Accuracy. 2imulation is provided to reflect the present status of the system. .nd user can operate this without $nowing about electronics.

References: 1. Kenneth.J.AyalaThe
89C51 Microcontroller Architecture programming and Applications, en ram !nternational.

2. ".#oychoudary and $ail Jain%.!.C, &e' Age !nternational. 3. ( rinciples o) *lectronics +y ,.K.M*-TA. 4. (Communication $ystems +y $imon -a'.ins.

You might also like