Intelligent Train Engine With Gating

Embed Size (px)

Citation preview

  • 7/26/2019 Intelligent Train Engine With Gating

    1/74

    Intelligent Train Engine with Gate Control System

    1.ABSTRACT

    OBJECTIVE: The aim of this project is to Automate unmanned railway gate usingmechatronics.

    PROJECT DEFINATION:

    The objective of this project is to manage the control system of railway gate usingthe microcontroller. When train arrives at the sensing point alarm is triggered at therailway crossing point so that the people get intimation that gate is going to be closed.Then the control system activates and closes the gate on either side of the track. once thetrain crosses the other end control system automatically lifts the gate. For mechanicaloperation of the gates DC geared motors are employed. ere we are using embeddedcontroller built around the !"#$ family %AT!&C#'( for the control according to the data

    pattern produced at the input port of the micro controller) the appropriate selected actionwill be taken.. The logic is produced by the program written in *mbedded C language.The software program is written) by using the +*,-/01 micro vision environment. Theprogram written is then converted in *2 code after simulation and burned on tomicrocontroller using F-A/ micro vision.

    Page $

  • 7/26/2019 Intelligent Train Engine With Gating

    2/74

    Intelligent Train Engine with Gate Control System

    WORKING METHODOLOGY:

    0resent project is designed using !"#$ microcontroller to avoid railway accidentshappening at unattended railway gates) if implemented in spirit. This project utili3es twopowerful ,4 transmitters and two receivers5 one pair of transmitter and receiver is fi6ed at

    up side %from where the train comes( at a level higher than a human being in e6actalignment and similarly the other pair is fi6ed at down side of the train direction. /ensoractivation time is so adjusted by calculating the time taken at a certain speed to cross atleast one compartment of standard minimum si3e of the ,ndian railway. We haveconsidered # seconds for this project. /ensors are fi6ed at $km on both sides of the gate.We call the sensor along the train direction as 7foreside sensor8 and the other as 7after sidesensor8. When foreside receiver gets activated) the gate motor is turned on in onedirection and the gate is closed and stays closed until the train crosses the gate andreaches aft side sensors. When aft side receiver gets activated motor turns in oppositedirection and gate opens and motor stops. 9u33er will immediately sound at the fore sidereceiver 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 hascrossed.

    GATE CONTROL

    4ailways being the cheapest mode of transportation are preferred over all the othermeans .When we go through the daily newspapers we come across many railwayaccidents occurring at unmanned railway crossings. This is mainly due to the carelessnessin manual operations or lack of workers. We) in this project has come up with a solutionfor the same. :sing simple electronic components we have tried to automate the controlof railway gates. As a train approaches the railway crossing from either side) the sensorsplaced at a certain distance from the gate detects the approaching train and accordinglycontrols the operation of the gate. Also an indicator light has been provided to alert themotorists about the approaching train.

    Page '

  • 7/26/2019 Intelligent Train Engine With Gating

    3/74

    Intelligent Train Engine with Gate Control System

    Block Diagram of the System

    Page ;

    IR InputSensor

    IR Output

    Sensor

    Geared Motor-1 Engine

    Geared Motor- Engine

    IREngineSensor

    IREngine

    Sensor

    Geared Motor-1 Rail!ay

    Gate

    Geared Motor- Rail!ay

    Rail!ay

    SignalsRed and green

    !"#$micro

    controller

  • 7/26/2019 Intelligent Train Engine With Gating

    4/74

    Intelligent Train Engine with Gate Control System

    "I#$ROD%&$IO#

    Introd!t"on:The objective of this project is to manage the control system of railway gate using

    the microcontroller. When train arrives at the sensing point alarm is triggered at therailway crossing point so that the people get intimation that gate is going to be closed.Then the control system activates and closes the gate on either side of the track. once thetrain crosses the other end control system automatically lifts the gate. For mechanicaloperation of the gates geared motors are employed. ere we are using embeddedcontroller built around the !"#$ family %AT!&C#'( for the control according to the datapattern produced at the input port of the micro controller) the appropriate selected actionwill be taken.. The logic is produced by the program written in *mbedded C language.The software program is written) by using the +*,- micro vision environment. Theprogram written is then converted in *2 code after simulation and burned on tomicrocontroller using F-A/ micro vision.

    AT#$C%1 M"!ro!ontro&&'r

    The systemor by a conventional non>volatile memory programmer. 9y combining a versatile !>bitC0: with Flash on a monolithic chip) the Atmel AT!&C#$ is a powerful microcomputer)which provides a highly fle6ible and cost>effective solution to many embedded controlapplications. 9y using this controller the data inputs from the smart card is passed to theparallel port of the pc and accordingly the software responds. The ,D* for writing the

    embedded program used is +*, - software.

    K'"& M"!ro (")"on Int'*r+t'd D'('&o,-'nt En("ron-'nt.

    +eil /oftware development tools for the !"#$ micro controller family supportevery level of developer from the professional applications engineer to the student justlearning about embedded software development.The industry>standard +eil C Compilers)time +ernels) and /ingle>board Computers supportA-- !"#$>compatible derivatives and help you get your projects completed on schedule.

    The source code is written in assembly language .,t is saved as A/< file with ane6tension. A#$.the A/< file is converted into he6 file using keil software. e6 file isdumped into micro controller using -A9T==- software. At once the file is dumped andthe 4=< is burnt then it becomes an embedded one.

    Page ?

  • 7/26/2019 Intelligent Train Engine With Gating

    5/74

    Intelligent Train Engine with Gate Control System

    '"&IR&%I$ DI(GR(M

    Page #

  • 7/26/2019 Intelligent Train Engine With Gating

    6/74

    Intelligent Train Engine with Gate Control System

    Page @

  • 7/26/2019 Intelligent Train Engine With Gating

    7/74

    Intelligent Train Engine with Gate Control System

    )"&OM*O#E#$S

    The project consists of three main parts

    !"#$ microcontroller ,4 Transmitter ,4 4eceiver DC motor Circuit !"#$ C=BT4=--*4

    The ,= ports of the !"#$ are e6panded by connecting it to an !'## chip. The !'## isprogrammed as a simple ,= port for connection with devices such as -*Ds) geared DCmotors and sensors.

    The following block diagram shows the various devices connected to the differentports of an !'##. The ports are each !>bit and are named A) 9 and C. The individual portsof the !'## can be programmed to be input or output) and can be changed dynamically.The control register is programmed in simple ,= mode with port A) port 9 and port C%upper( as output ports and port C %lower( as an input port.

    IR CIRCITS

    This circuit has two stages a transmitter unit and a receiver unit. The transmitterunit consists of an infrared -*D and its associated circuitry.

    IR TRANSMITTER

    The ,4 -*D emitting infrared light is put on in the transmitting unit. To generate,4 signal) ### ,C based astable multivibrator is used. ,nfrared -*D is driven throughtransistor 9C #?!. ,C ### is used to construct an astable multivibrator which has twouasi>stable states. ,t generates a suare wave of freuency ;!k3 and amplitude #olts.,t is reuired to switch 7=B8 the ,4 -*D.

    IR RECEIVER:

    The receiver unit consists of a sensor and its associated circuitry. ,n receiver

    section) the first part is a sensor) which detects ,4 pulses transmitted by ,4>-*D.Whenever a train crosses the sensor) the output of ,4 sensor momentarily transits througha low state. As a result the monostable is triggered and a short pulse is applied to the portpin of the !"#$ microcontroller. =n receiving a pulse from the sensor circuit) thecontroller activates the circuitry reuired for closing and opening of the gates and fortrack switching. The ,4 receiver circuit is shown in the figure below.

    Page E

  • 7/26/2019 Intelligent Train Engine With Gating

    8/74

    Intelligent Train Engine with Gate Control System

    L/$0D D+& HBr"d*' Motor Dr"('r

    -'&;D is a dual >9ridge motor driver) /o with one ,C we can interface two DC motorswhich can be controlled in both clockwise and counter clockwise direction and if youhave motor with fi6 direction of motion the you can make use of all the four ,=s toconnect up to four DC motors. -'&;D has output current of @""mA and peak outputcurrent of $.'A per channel.

  • 7/26/2019 Intelligent Train Engine With Gating

    9/74

    Intelligent Train Engine with Gate Control System

    diodes are included within the ,C. The output supply %CC'( has a wide range from ?.#to ;@) which has made -'&;D a best choice for DC motor driver.

    A simple schematic for interfacing a DC motor using -'&;D is shown below.

    As you can see in the circuit) three pins are needed for interfacing a DC motor %A) 9)*nable(. ,f you want the op to be enabled completely then you can connect *nable toCC and only ' pins needed from controller to make the motor work.

    As per the truth mentioned in the image above its fairly simple to program themicrocontroller. ,ts also clear from the truth table of 91T circuit and -'&;D theprogramming will be same for both of them) just keeping in mind the allowedcombinations of A and 9. We will discuss about programming in C as well as assemblyfor running motor with the help of a microcontroller.

    Page &

  • 7/26/2019 Intelligent Train Engine With Gating

    10/74

    Intelligent Train Engine with Gate Control System

    +"EMBEDDED S,S$EMS

    Introd!t"on:

    An *mbedded system is a combination of computer hardware and software) and

    perhaps additional mechanical or other parts) designed to perform a specific function.

    *mbedded systems are usually a part of larger) comple6 system. Dedicated

    applications) designed to e6ecute specific activities) are implemented and embedded in

    systems. These embedded applications are reuired to collaborate with the other

    components of an enclosed system. *mbedded application components interact mostlywith the non>human e6ternal environment. They continuously collect data from sensors

    or other computer components and process data within real>time constraints. *mbedded

    systems are usually associated with dedicated hardware and specific software.

    *mbedding an application into system

    Page $"

  • 7/26/2019 Intelligent Train Engine With Gating

    11/74

    Intelligent Train Engine with Gate Control System

    Application and system are closely tied together

    Collaborative application

    Dedicated W and specific /W

    ,nteraction with non>human e6ternal environment

    4eal>time systems are embedded systems

    +"1 EMBEDDED*ROD%&$DEE.O*ME#$.I/E&,&.E

    Page $$

    :nderstand userreuirements

    Choose optimumelectronic chip

    --A--

    Algorithm

    Coding*ditingCompilingAssembling

    Debugging

    Testing

    /imulator

    /W

    0C9 -ayout design

    Assemblingcomponents

    Testing

    W

    ,C* %,n Circuit*mulator(

    *mbedded 0roduct

    /W /ide W /ide

    D=WB-=AD

  • 7/26/2019 Intelligent Train Engine With Gating

    12/74

    Intelligent Train Engine with Gate Control System

    %./ DESIGNCONSIDERATIONSFORANEMBEDDEDSYSTEM

    Introd!t"on:

    :nlike software designed for general>purpose computers) embedded software

    cannot usually be run on other embedded system without significant modification. This is

    mainly because of the incredible variety in the underlying hardware. The hardware in

    each embedded system is tailored specifically to the application) in order to keep system

    costs low. As a result) unnecessary circuitry is eliminated and hardware resources are

    shared whenever possible.

    ,n order to have software) there must be a place to store the e6ecutable code and

    temporary storage for runtime data manipulation. These take the form of 4=< and 4A

  • 7/26/2019 Intelligent Train Engine With Gating

    13/74

    Processor

    Memory

    Inputs Outputs

    Intelligent Train Engine with Gate Control System

    and probes) communication signals) or control knobs and buttons. The outputs are

    typically displays) communication signals) or changes to the physical world.

    E2+-,&' o3 +n E-4'dd'd S5)t'-

    =ther common design reuirement include >

    0rocessing power

  • 7/26/2019 Intelligent Train Engine With Gating

    14/74

    Intelligent Train Engine with Gate Control System

    M'-or5:

    The amount of memory %4=< and 4A

  • 7/26/2019 Intelligent Train Engine With Gating

    15/74

    Intelligent Train Engine with Gate Control System

    routinely handles calls from tens of thousands of subscriber. The system has to connect

    each call differently. Also) the e6act seuence of events in the call might vary a lot.

    *mbedded systems have to respond to e6ternal interactions in a predetermined

    amount of time. /uccessful completion of an operation depends upon the correct and

    timely operation of the system. Design the hardware and the software in the system to

    meet the 4ealtime reuirements. For e6ample) a telephone switching system must feed

    dial tone to thousands of subscribers within a recommended limit of one second. To meet

    these reuirements) the off hook detection mechanism and the software message

    communication involved have to work within the limited time budget. The system has to

    meet these reuirements for all the calls being set up at any given time.

    The designers have to focus very early on the 4ealtime response reuirements.

    During the architecture design phase) the hardware and software engineers work together

    to select the right system architecture that will meet the reuirements. This involves

    deciding inter connectivity of the processors) link speeds) processor speeds) etc.

    The main queries to be asked are:

    ,s the architecture suitable ,f message communication involves too many

    nodes) it is likely that the system may not be able to meet the Realtime

    reuirement due to even mild congestion. Thus a simpler architecture has a better

    chance of meeting theRealtimereuirements.

    Are the processing components powerful enough A C0: with really high

    utili3ation will lead to unpredictable Realtimebehavior. Also) it is possible that

    the high priority tasks in the system will starve the low priority tasks of any C0:

    time. This can cause the low priority tasks to misbehave.

    Page $#

  • 7/26/2019 Intelligent Train Engine With Gating

    16/74

    Intelligent Train Engine with Gate Control System

    ,s the =perating /ystem suitable Assign high priority to tasks that are involved

    in processing Realtime critical events. Consider preemptive scheduling if

    Realtime reuirements are stringent. When choosing the operating system) the

    interrupt latency and scheduling variance should be verified.

    o /cheduling variance refers to the predictability in task scheduling times.

    For e6ample) a telephone switching system is e6pected to feed dialtone in

    less than #"" ms. This would typically involve scheduling three to five

    tasks within the stipulated time. time operating systems would have

    much lower interrupt latency.

    0"MI&RO&O#$RO..ER

    Introduction:

  • 7/26/2019 Intelligent Train Engine With Gating

    17/74

    Intelligent Train Engine with Gate Control System

    A microcontroller has a dedicated input device and often %but not always( has a

    small -*D or -CD display for output. A microcontroller also takes input from the

    device it is controlling and controls the device by sending signals to different

    components in the device.

    For e6ample) the microcontroller inside a T takes input from the remote control

    and displays output on the T screen. The controller controls the channel selector)

    the speakersystem and certain adjustments on the picture tube electronics such as

    tint and brightness. The engine controllerin a car takes input from sensors such as

    the o6ygen and knock sensors and controls things like fuel mi6 and spark plug

    timing. A microwave ovencontroller takes input from a keypad) displays output on

    an -CD display and controls a relaythat turns the microwave generator on and off.

    A microcontroller is often small and low cost. The components are chosen to

    minimi3e si3e and to be as ine6pensive as possible.

    A microcontroller is often) but not always) ruggedi3ed in some way.

    =n the other hand) a microcontroller embedded inside a C4 hasnHt been

    ruggedi3ed at all.

    The actual processor used to implement a microcontroller can vary widely.

    Atmel 89c51 Microcontroller D')!r",t"on

    The AT!&C#$ is a low>power) high>performance Cbit microcomputer

    with ?+ bytes of Flash programmable and erasable read only memory %0*4=

  • 7/26/2019 Intelligent Train Engine With Gating

    18/74

    Intelligent Train Engine with Gate Control System

    F'+tr')

    The AT!&C#$ provides the following standard features

    Compatible with #$ 0roducts

    *ndurance $)""" Write*rase Cycles

    ?+ 9ytes of ,n>/ystem 4eprogrammable Flash bit(

    ;' 0rogrammable ,= -ines

    Two $@>bit TimerCounters

    Five vector two>level interrupt architecture

    A full duple6 serial port

    Three>level 0rogram

  • 7/26/2019 Intelligent Train Engine With Gating

    19/74

    Intelligent Train Engine with Gate Control System

    Figure 9lock Diagram of AT!&c#$

  • 7/26/2019 Intelligent Train Engine With Gating

    20/74

    Intelligent Train Engine with Gate Control System

    Figure 0D,0 Type AT!&c#$ 0in Diagram

    *I#DES&RI*$IO#

    VCC S,,&5 (o&t+*'.

    GND Iround.

    Port 9:

    0ort " is an !>bit open>drain bi>directional ,= port.

    As an output port) each pin can sink eight TT- inputs. When $s are written to port " pins)

    the pins can be used as high impedance inputs. 0ort " may also be configured to be the

    multiple6ed low order addressdata bus during accesses to e6ternal program and data

    memory. ,n this mode 0" has internal pull>ups. 0ort " also receives the code bytes during

    Page '"

  • 7/26/2019 Intelligent Train Engine With Gating

    21/74

    Intelligent Train Engine with Gate Control System

    Flash programming) and outputs the code bytes during program verification. *6ternal

    pull>ups are reuired during program verification.

    Port 1

    0ort $ is an !>bit bi>directional ,= port with internal pull>ups.

    The 0ort $ output buffers can sinksource four TT- inputs. When $s are written to 0ort $

    pins they are pulled high by the internal pull>ups and can be used as inputs. As inputs)

    0ort $ pins that are e6ternally being pulled low will source current %,,-( because of the

    internal pull>ups. 0ort $ also receives the low>order address bytes during Flash

    programming and verification.

    Port /

    0ort ' is an !>bit bi>directional ,= port with internal pull>ups.

    The 0ort ' output buffers can sinksource four TT- inputs. When $s are written to 0ort '

    pins they are pulled high by the internal pull>ups and can be used as inputs.As inputs)

    0ort ' pins that are e6ternally being pulled low will source current %,,-( because of the

    internal pull>ups. 0ort ' emits the high>order address byte during fetches from e6ternal

    program memory and during accesses to e6ternal data memory that uses $@>bit addresses

    %ups when emitting $s.

    Port 0

    0ort ; is an !>bit bi>directional ,= port with internal pull>ups.

    The 0ort ; output buffers can sinksource four TT- inputs. When $s are written to 0ort ;

    pins they are pulled high by the internal pull>ups and can be used as inputs. As inputs)

    0ort ; pins that are e6ternally being pulled low will source current %,,-( because of the

    pull>ups.

    0ort ; also serves the functions of various special features of the AT!&C#$ as listed

    below

    Port P"n A&t'rn+t' Fn!t"on)

    Page '$

  • 7/26/2019 Intelligent Train Engine With Gating

    22/74

    Intelligent Train Engine with Gate Control System

    0;." 42D %serial input port(

    0;.$ T2D %serial output port(

    0;.' ,BT" %e6ternal interrupt "(

    0;.; ,BT$ %e6ternal interrupt $(

    0;.? T" %timer " e6ternal input(

    0;.# T$ %timer $ e6ternal input(

    0;.@W4 %e6ternal data memory Write

    strobe(

    0;.E4D %e6ternal data memory read

    strobe(

    0ort ; also receives some control signals for Flash programming and verification.

    RST

    4eset input. A high on this pin for two machine cycles while the oscillator is

    running resets the device.

    ALEPROG

    Address -atch *nable output pulse for latching the low byte of the address during

    accesses to e6ternal memory. This pin is also the program pulse input %04=I( during

    Flash programming.

    ,n normal operation A-* is emitted at a constant rate of $@ the oscillator freuency) and

    may be used for e6ternal timing or clocking purposes. Bote) however) that one A-* pulse

    is skipped during each access to e6ternal Data

  • 7/26/2019 Intelligent Train Engine With Gating

    23/74

    Intelligent Train Engine with Gate Control System

    0rogram /tore *nable is the read strobe to e6ternal program memory. When the

    AT!&C#$ is e6ecuting code from e6ternal program memory) PSEN is activated twice

    each machine cycle) e6cept that two PSEN activations are skipped during each access to

    e6ternal data memory.

    EA VPP

    *6ternal Access *nable must be strapped to IBD in order to enable the device to

    fetch code from e6ternal program memory locations starting at """" up to FFFF.

    Bote) however) that if lock bit $ is programmed) EA will be internally latched on reset.

    EA should be strapped to CC for internal program e6ecutions. This pin also receives

    the $'>volt programming enable voltage %00( during Flash programming) for parts that

    reuire $'>volt 00.

    ;TAL1

    ,nput to the inverting oscillator amplifier and input to the internal clock operating

    circuit.

    ;TAL/

    =utput from the inverting oscillator amplifier

    O)!"&&+tor C7+r+!t'r")t"!)

    2TA-$ and 2TA-' are the input and output) respectively) of an inverting

    amplifier which can be configured for use as an on>chip oscillator) as shown in Figure $.

    *ither a uart3 crystal or ceramic resonator may be used.

    To drive the device from an e6ternal clock source) 2TA-' should be left

    unconnected while 2TA-$ is driven as shown in Figure '. There are no reuirements on

    the duty cycle of the e6ternal clock signal) since the input to the internal clocking

    circuitry is through a divide>by>two flip>flop) but minimum and ma6imum voltage high

    and low time specifications must be observed.

    Page ';

  • 7/26/2019 Intelligent Train Engine With Gating

    24/74

    Intelligent Train Engine with Gate Control System

    F"*r'1: O)!"&&+tor Conn'!t"on)

    Bote C$) C' K ;" pF L$" pF for Crystals

    K ?" pF L$" pF for Ceramic 4esonators

    F"*r' /: E2t'rn+& C&o!< Dr"(' Con3"*r+t"on

    Ho6 O)!"&&+tor 6or

  • 7/26/2019 Intelligent Train Engine With Gating

    25/74

    Intelligent Train Engine with Gate Control System

    charges oscillate back and front at the resonant freuency of crystal.

    fK$/'(%%$MCC0(%-C(((

    Nuart3 crystal e6hibits a property called the pie3o>electric effect that is they

    produce an electric voltage. When subjected to pressure along certain direction of the

    crystal because of this property uart3 crystal has important application in electronics

    industry for controlling the freuency of radio waves.When pie3o>electric crystal is used

    in place of -C circuit for higher freuency stability) the oscillator is called as crystal

    oscillator.

    Page '#

  • 7/26/2019 Intelligent Train Engine With Gating

    26/74

    Intelligent Train Engine with Gate Control System

    Crystal oscillator is used for stability freuency for a long period of time. The

    resolution of "."$ nms can be obtained. Crystal operates between fp and fs freuency %a

    very narrow bandwidth(.

    St+t) o3 E2t'rn+& P"n) dr"n* Id&' +nd Po6'rdo6n Mod')

    Pro*r+- M'-or5 Lo!< B"t)

    =n the chip are three lock bits which can be left un>programmed %:( or can be

    programmed %0( to obtain the additional features listed in the table below. When lock bit

    $ is programmed) the logic level at the *A pin is sampled and latched during reset. ,f the

    device is powered up without a reset) the latch initiali3es to a random value) and holds

    that value until reset is activated. ,t is necessary that the latched value of *A be in

    agreement with the current logic level at that pin in order for the device to function

    properly.

    Lo!< B"t Prot'!t"on Mod')

    Pro*r+- Lo!< B"t)

    Page '@

    Mod'Pro*r+-

    M'-or5ALE PSEN Port 9 Port 1 Port / Port0

    ,dle ,nternal $ $ Data Data Data Data

    ,dle *6ternal $ $ Float Data Address Data

    0ower>

    down,nternal " " Data Data Data Data

    0ower>down

    *6ternal " " Float Data Data Data

  • 7/26/2019 Intelligent Train Engine With Gating

    27/74

    Intelligent Train Engine with Gate Control System

    Prot'!t"on T5,'-9$ -9' -9;

    $ : : : Bo program lock features

    ' 0 : :

    chip Flash memory array in the

    erased state %that is) contents K FF( and ready to be programmed. The programming

    interface accepts either a high>voltage %$'>volt( or a low>voltage %CC( program enable

    signal.

    The low>voltage programming mode provides a convenient way to program the

    AT!&C#$ inside the user8s system) while the high>voltage programming mode is

    compatible with conventional third>party Flash or *04=< programmers.

    R'+d"n* t7' S"*n+tr' B5t'):

    The signature bytes are read by the same procedure as a normal verification of

    locations ";") ";$) and ";') e6cept that 0;.@ and 0;.E must be pulled to a logic low.

    The values returned are as follows.

    %";"( K $* indicates manufactured by Atmel

    %";$( K #$ indicates !&C#$

    %";'( K FF indicates $' programming

    %";'( K "# indicates # programming.

    Pro*r+--"n* Int'r3+!'

    *very code byte in the Flash array can be written and the entire array can be

    erased by using the appropriate combination of control signals. The write operation cycle

    is self timed and once initiated) will automatically time itself to completion. All major

    Page 'E

  • 7/26/2019 Intelligent Train Engine With Gating

    28/74

    Intelligent Train Engine with Gate Control System

    programming vendors offer worldwide support for the Atmel microcontroller series.

    0lease contact your local programming vendor for the appropriate software revision.

    F&+)7 Pro*r+--"n* Mod')

    Mod' RST PSEN ALEPROGEA

    VPPP/.= P/.> P0.= P0.>

    Write Code Data - $' -

    4ead Code Data - - -

    Write

    -ock

    9it>$ - $'

    9it>' - $' - -

    9it>; - $' - -

    Chip *rase - $' - - -

    4ead /ignature

    9yte - - - - -

    Bote Chip *rase reuires a $" ms 04=I pulse.

    E;TERNALPROGRAMMEMORYREADCYCLE

    E2t'rn+& D+t+ M'-or5 R'+d C5!&'

    Page '!

  • 7/26/2019 Intelligent Train Engine With Gating

    29/74

    Intelligent Train Engine with Gate Control System

    E2t'rn+& D+t+ M'-or5 Wr"t' C5!&'

    E2t'rn+& C&o!< Dr"(' W+('3or-)

    Page '&

  • 7/26/2019 Intelligent Train Engine With Gating

    30/74

    Intelligent Train Engine with Gate Control System

    E2t'rn+& C&o!< Dr"('

    S5-4o& P+r+-'t'r M"n M+2 n"t)

    $tC-C- =scillator Freuency " '?

  • 7/26/2019 Intelligent Train Engine With Gating

    31/74

    Intelligent Train Engine with Gate Control System

    step e6ecution controls the rate of motor rotation. A $.!O step motor e6ecuting steps at a

    speed of '"" steps per second will rotate at e6actly $ revolution per second.

    Ieared motors can be very accurately controlled in terms of how far and how fast

    they will rotate. The number of steps the motor e6ecutes is eual to the number of pulse

    commands it is given. A step motor will rotate a distance and at a rate that is proportional

    to the number and freuency of its pulse commands.

    B+)"! G'+r'd Motor S5)t'-

    The diagram above shows a typical step motor based system. All of these parts

    must be present in one form or another. *ach component8s performance will have an

    effect on the others. 9y altering the freuency of the pulse train) the pulse generator can

    instruct the motor to accelerate) run at a speed) decelerate or stop. A pulse generator must

    be present otherwise the motor will not move. Be6t is the motor driver.

    The driver takes the pulses from the pulse generator and determines how and

    when the windings should be energi3ed. The windings must be energi3ed in a specific

    seuence to generate motion. Finally there is the step motor itself. A step motor has two

    primary parts5 the rotor) the moving piece) and the stator) the stationary piece. The stator

    contains coils of wire called windings. The rotor spins on bearings or bushings inside the

    stator. All step motors operate through the principle of the rotor following a rotating

    magnetic field created by seuencing the flow of current through the stator windings.

    *ach B

  • 7/26/2019 Intelligent Train Engine With Gating

    32/74

    Intelligent Train Engine with Gate Control System

    movements to keep in synchronism with the magnetic field. The degree of rotation per

    step depends on the style of driver used and the construction of the motor.

    St', Motor Ad(+nt+*'):

    R Accuracy S 4epeatability Ability to position accurately.

    R 4esponsiveness S Nuick Acceleration /tep motors have low rotor inertia)

    allowing them to get up to speed uickly. This makes step motors an e6cellent choice for

    short) uick moves.

    R *6cellent torue for their si3e /tep motors have the highest torue per cubic

    inch of any motor.

    R 0ositioning /tability :nlike other types of motors) step motors can be held

    completely motionless in their stopped position.

    Con)tr!t"on +nd O,'r+t"n* t7' H54r"d STEP MOTOR

    Figure $a depicts a $.!O hybrid step motor. The rotor contains a permanent magnet

    similar to those found in permanent magnet step motors. ybrid rotors are a6ially

    magneti3ed) one end polari3ed north and the other polari3ed south. 9oth the rotor and the

    stator assemblies of hybrid motors have tooth>like projections. To understand the rotor8s

    interaction with the stator) e6amine the construction of a $.!O %the most common

    resolution( hybrid step motor.

    The two cups are oriented so that the teeth of the top cup are offset to the teeth of

    the bottom cup by ;.@O. /econd) the stator has a two>phase construction. The winding

    coils) &"O apart from one another) make up each phase. *ach phase is wound so that the

    poles $!"O apart are the same polarity) while the poles &"O apart are the opposite polarity.

    When the current in a phase is reversed) is the polarity) meaning that any winding coil can

    be either a north pole or a south pole. As shown in fig. $b below) when phase A is

    energi3ed) the windings at $' o8clock and @ o8clock are north poles and the windings at ;

    o8clock and & o8clock are south poles.

    Page ;'

  • 7/26/2019 Intelligent Train Engine With Gating

    33/74

    Intelligent Train Engine with Gate Control System

    The windings at $' and @ would attract the teeth of the magnetically south end of

    the rotor) and windings at ; and & would attract the teeth of the magnetically north end of

    the rotor.

    .

    3" &(*(&I$ORS

    Introduction:

    An '&'!tro&5t"! !+,+!"toris a type of capacitor typically with a larger capacitanceper unit volume than other types) making them valuable in relatively high>current andlow>freuency electrical circuits. This is especially the case in power>supply filters)where they store charge needed to moderate output voltage and current fluctuations) inrectifier output) and especially in the absence of rechargeable batteries that can providesimilar low>freuency current capacity. They are also widely used as coupling capacitorsin circuits where AC should be conducted but DC should not5 the large value of thecapacitance allows them to pass very low freuencies.

    Page ;;

  • 7/26/2019 Intelligent Train Engine With Gating

    34/74

    Intelligent Train Engine with Gate Control System

    The electrolytic capacitor was invented in $!!@ by Charles 0ollack. ,t was largelyresponsible for the development of mains>powered radio receivers) since it permitted thefiltering of the #">@" hert3 power supplied to residences) after it was rectified to powerthe radio tubes. This was not practical without the small volume and low cost ofelectrolytic capacitors.

    Construction

    Aluminum electrolytic capacitors are constructed from two conducting aluminumfoils) one of which is coated with an insulating o6ide layer) and a paper spacer soaked inelectrolyte. The foil insulated by the o6ide layer is the anode while the liuid electrolyteand the second foil act as cathode. This stack is then rolled up) fitted with pin connectorsand placed in a cylindrical aluminum casing. The two most popular geometries are a6ialleads coming from the center of each circular face of the cylinder) or two radial leads orlugs on one of the circular faces. 9oth of these are shown in the picture

    Polarity

    ,n aluminum electrolytic capacitors) the layer of insulating aluminum o6ide on thesurface of the aluminum plate acts as the dielectric) and it is the thinness of this layer thatallows for a relatively high capacitance in a small volume. The aluminum o6ide layer canwithstand an electric field strength of the order of $"&volts per meter. The combination ofhigh capacitance and high voltage result in high energy density.

    :nlike most capacitors) electrolytic capacitors have a voltage polarityreuirement. The correct polarity is indicated on the packaging by a stripe with minussigns and possibly arrowheads) denoting the adjacent terminal that should be more

    negative than the other. This is necessary because a reverse>bias voltage will destroy thecenter layer of dielectric material via electrochemical reduction %see redo reactions(.Without the dielectric material the capacitor will short circuit) and if the short circuitcurrent is e6cessive) then the electrolyte will heat up and either leak or cause thecapacitor to e6plode.

  • 7/26/2019 Intelligent Train Engine With Gating

    35/74

    Intelligent Train Engine with Gate Control System

    These are the different schematic symbols for electrolytic capacitors. The minus or Bmarked side of the physical capacitor is euivalent to the node opposite to the plus signon its symbolic euivalent. T",: Take notice of the shape of the symbols and the

    placement of the positive and negative nodes) because most schematics do not print theGMG) but rely on the symbol itself instead.

    note caps in metal can have the color mark at the minus side U

    0olarity of caps with wires

    a6ial the minus wire is connected to the case) the plus wire is isolated.

    radial K single ended a vertical color stripe indicates the minus side.

    For the polarity of /slugG) contain the more ha3ardous sulfuric acid) howevermost of these are no longer in service due to corrosion.

    Page ;#

    http://en.wikipedia.org/wiki/Image:Cap-elko-smd-polarity.jpg
  • 7/26/2019 Intelligent Train Engine With Gating

    36/74

    Intelligent Train Engine with Gate Control System

    Capacitance

    The capacitance value of any capacitor is a measure of the amount of electriccharge stored per unit of potential difference between the plates. The basic unit ofcapacitance is a farad) however this unit has been too large for general use until the

    invention of the Double>layer capacitor) so microfarad) nanofarad and microfarad aremore commonly used. These are usually abbreviated to if or of) no and puff

    or =.#by a power of ten. Therefore) it iscommon to find capacitors with values of $") $#) '') ;;) ?E) @!) $"") ''") and so on.:sing this method) values ranging from ".$ to ?E"" are common in most applications.alues are generally in microfarads %VF(.

  • 7/26/2019 Intelligent Train Engine With Gating

    37/74

    Intelligent Train Engine with Gate Control System

    Super capacitor

    load devices. /ome of the earliest uses were motor startupcapacitors for large engines in tanks and submarines) and as the cost has fallen they havestarted to appear on diesel trucks and railroad locomotives. electric cars and plug>in hybrids) as they combine uick charging)temperature stability and e6cellent safety properties.

    Page ;E

  • 7/26/2019 Intelligent Train Engine With Gating

    38/74

    Intelligent Train Engine with Gate Control System

    Concept

    Comparison of construction diagrams of three capacitors. -eft GnormalG capacitor)middle electrolytic) right super capacitor

    ,n a conventional capacitor) energy is stored by the removal of charge carriers) typicallyelectrons) from one metal plate and depositing them on another. This charge separationcreates a potential between the two plates) which can be harnessed in an e6ternal circuit.The total energy stored in this fashion is a combination of the number of charges stored

    and the potential between the plates.

    ,n contrast with traditional capacitors) super capacitors do not have a conventionaldielectric) as such. They are based on a structure that contains an electrical double layer.,n a double layer) the effective thickness of the GdielectricG is e6ceedingly thinXon theorder of nanometersXand that) combined with the very large surface area) is responsiblefor their e6traordinarily high capacitances in practical si3es.

    ,n an electrical double layer) each layer by itself is uite conductive) but thephysics at the interface where the layers are effectively in contact means that nosignificant current can flow between the layers. owever) the double layer can withstand

    only a low voltage) which means that super capacitors rated for higher voltages must bemade of matched series>connected individual super capacitors) much like series>connected cells in higher>voltage batteries.

    Page ;!

  • 7/26/2019 Intelligent Train Engine With Gating

    39/74

    Intelligent Train Engine with Gate Control System

    History:

    The super capacitor effect was first noticed in $E by Ieneral *lectric engineerse6perimenting with devices using porous carbon electrode. ,t was believed that theenergy was stored in the carbon pores and it e6hibited Ge6ceptionally high capacitanceG)

    although the mechanism was unknown at that time.

    Ieneral *lectric did not immediately follow up on this work) and it was /tandard=il of =hio that eventually developed the modern version of the devices in $&@@ afteraccidentally re>discovering the effect while working on e6perimental fuel cell designs.Their cell design used two layers of activated charcoal separated by a thin porousinsulator. /tandard =il also failed to commerciali3e their invention) licensing thetechnology to B*C) who finally marketed the results as Psuper capacitorsQ in $&E!) toprovide backup power for maintaining computer memory. ,n '""#) the ultra capacitormarket was between :/ Y'E' million and Y?"" million) depending on the source. ,t israpidly growing) especially in the automotive sector.

    4ecently) all solid state micrometer>scale super capacitors based on advancedsupersonic conductors had been recogni3ed as critical electron component of future sub>voltage and deep>sub>voltage nanoelectronics and related technologies %'' nmtechnological node of Cdischarge cycles %millions or morecompared to '""$""" for most commercially available rechargeable batteries( therewere no disposable parts during the whole operating life of the device) which makes the

    device environmentally friendly. storing energy from other sources for load balancingpurposes and then using any e6cess energy to charge the batteries only at opportunetimes.

    =ther advantages of super capacitors compared with rechargeable batteries aree6tremely low internal resistance or */4) high efficiency %up to &E>&!() high outputpower) e6tremely low heating levels) and improved safety. According to ,T/ %,nstitute ofTransportation /tudies) Davis) CA( test results) the specific power of super capacitors cane6ceed @ kWkg at efficiency

    The idea of replacing batteries with capacitors in conjunction with novel

    alternative energy sources became a conceptual umbrella of the Ireen *lectricity %I*-(,nitiative) introduced by Dr. Ale6ander 9ell.

    Page ;&

  • 7/26/2019 Intelligent Train Engine With Gating

    40/74

    Intelligent Train Engine with Gate Control System

    Transportation applications

    China is e6perimenting with a new form of electric bus %casabas( that runswithout power lines using power stored in large onboard super capacitors) which areuickly recharged whenever the electric bus stops at any bus stop %under so>called

    '&'!tr"! -4r'&&+)() and fully charged in the terminus. A few prototypes were beingtested in /hanghai in early '""#. ,n '""@) two commercial bus routes began to use supercapacitor buses5 one of them is route $$ in /hanghai.

    ,n '""$ and '""') AI) the public transport operator in Buremberg) Iermanytested a bus which used a diesel>electric drive system with super capacitors.

    =ther companies from the public transport manufacturing sector are developingsuper capacitor technology The Transportation /ystems division of /iemens AI isdeveloping a mobile energy storage based on double>layer capacitors called /ubic *nergy/torage and also /itars /*/) a stationary version integrated into the trackside power

    supply. The company Cudgeled is also developing a super capacitor>based energy storagesystem.

    Resistors, capacitors and inductors

    4esistor values are always coded in ohms) capacitorsin microfarads%pF()inductorsin micro henries%V() andtransformersinvolts.

    band Ais first significant figure of component value

    band Bis the second significant figure

    band Cis the decimal multiplier band Dif present) indicates tolerance of value in percent %no color means '"(

    For e6ample) a resistor with bands ofyellow, violet, red, and goldwill have firstdigit ? %yellow in table below() second digit E %violet() followed by ' %red( 3eros

    ?)E"" ohms. Iold signifies that the tolerance is Z#) so the real resistance could lieanywhere between ?)?@# and ?)&;# ohms.

    4esistors manufactured for military use may also include a fifth band whichindicates component failure rate %reliability(5 refer to D9+>$&& for further details.

    The /tandard *,AColor Code Table per *,A>4/>'E& is as follows

    Page ?"

    http://en.wikipedia.org/wiki/Ohmhttp://en.wikipedia.org/wiki/Capacitorhttp://en.wikipedia.org/wiki/Faradhttp://en.wikipedia.org/wiki/Faradhttp://en.wikipedia.org/wiki/Inductorhttp://en.wikipedia.org/wiki/Henry_(inductance)http://en.wikipedia.org/wiki/Transformerhttp://en.wikipedia.org/wiki/Transformerhttp://en.wikipedia.org/wiki/Transformerhttp://en.wikipedia.org/wiki/Volthttp://en.wikipedia.org/wiki/Volthttp://www.okaphone.nl/calc/resistor.shtml?ohm=4700&tol=5http://www.okaphone.nl/calc/resistor.shtml?ohm=4700&tol=5http://en.wikipedia.org/wiki/Reliabilityhttp://en.wikipedia.org/wiki/MIL-HDBKhttp://en.wikipedia.org/wiki/Electronic_Industries_Alliancehttp://en.wikipedia.org/wiki/Electronic_Industries_Alliancehttp://en.wikipedia.org/wiki/Image:Resistor_bands.pnghttp://en.wikipedia.org/wiki/Ohmhttp://en.wikipedia.org/wiki/Capacitorhttp://en.wikipedia.org/wiki/Faradhttp://en.wikipedia.org/wiki/Inductorhttp://en.wikipedia.org/wiki/Henry_(inductance)http://en.wikipedia.org/wiki/Transformerhttp://en.wikipedia.org/wiki/Volthttp://www.okaphone.nl/calc/resistor.shtml?ohm=4700&tol=5http://en.wikipedia.org/wiki/Reliabilityhttp://en.wikipedia.org/wiki/MIL-HDBKhttp://en.wikipedia.org/wiki/Electronic_Industries_Alliance
  • 7/26/2019 Intelligent Train Engine With Gating

    41/74

    Intelligent Train Engine with Gate Control System

    Co&or 1)t4+nd /nd4+nd 0rd4+nd @-&t",&"'r ?t74+nd @to&'r+n!' T'-,. Co'33"!"'nt

    9lack " " [$""

    9rown $ $ [$"$ Z$ %F( $"" pap

    4ed ' ' [$"' Z' %I( #" pap

    =range; ; [$"; $# pap

    \ellow ? ? [$"? '# pap

    Ireen # # [$"# Z".# %D(

    9lue @ @ [$"@ Z".'# %C(

    iolet E E [$"E Z".$ %9(

    Irey ! ! [$"! Z"."# %A(

    White & & [$"&

    Iold [".$ Z# %1(

    /ilver ["."$ Z$" %+(

    Bone Z'" %

  • 7/26/2019 Intelligent Train Engine With Gating

    42/74

    Intelligent Train Engine with Gate Control System

    7.3 POWER SUPPLY:

    CIRCUIT DIAGRAM:

    POWER SPPLY:

    To run the electronic gadget at home it is provided by some power supply. The

    microcontroller used %at!&c#$( reuires $'v D.C supply. The DT

  • 7/26/2019 Intelligent Train Engine With Gating

    43/74

    Intelligent Train Engine with Gate Control System

    For a transformer shown below

    D"od'):

    ,n bride rectifier four diodes are used. The specifications of diodes are chosen

    as

    0, ^ input voltage.

    /i diode is better.

    0ower dissipation is kept fi6ed with respect to current through the diode.

    1unction capacitance need not be considered for freuencies _$ k3.

    RECTIFIERS:

    4ectification is a process of conversion of AC to DC. ere) the AC of transformer

    output is given to the rectifier input) which converts it to DC output. 9asically) bridge

    rectifiers or diodes arranged in bridge called Diode arrangement are used for power

    supply design.

    A bridge rectifier makes use of four diodes in a bridge arrangement to achieve

    full>wave rectification. This is a widely used configuration) both with individual diodes

    wired as shown and with single component bridges where the diode bridge is wired

    internally

    Page ?;

    V1 V/

    "1 "/

    V1 "/ n1

    V/ "1 n/

  • 7/26/2019 Intelligent Train Engine With Gating

    44/74

    Intelligent Train Engine with Gate Control System

    Crr'nt F&o6 "n t7' Br"d*' R'!t"3"'r

    For both positive and

    negative swings of

    the transformer) there

    is a forward path through the diode bridge. 9oth conduction paths cause current to

    flow in the same direction through the load resistor) accomplishing full>wave

    rectification.

    While one set of diodes is forward biased) the other set is reverse biased and

    effectively eliminated from the circuit.

    Diode Bridge:

    A diode bridge is an arrangement of four diodes connected in a bridge circuit asshownbelow) that provides the same polarity of output voltage for any polarity of the

    input voltage. When used in its most common application) for conversion of alternating

    current %AC( input into direct current %DC( output) it is known as a bridge rectifier. The

    diagram describes a diode>bridge design known as a full>wave rectifier or Iraet3 circuit.

    This design can be used to rectify single phase AC when no transformer center tap

    is available

    Bridge Rectifier Circuit:

    Page ??

    http://en.wikipedia.org/wiki/Image:Diodebridge1.png
  • 7/26/2019 Intelligent Train Engine With Gating

    45/74

    Intelligent Train Engine with Gate Control System

    The essential feature of this arrangement is that for both polarities of the voltage

    at the bridge input) the polarity of the output is constant.

    Capacitors:

    Capacitive filters are used stabili3ed or perfect regulation of the voltage. The

    capacitive filters are opted because) they are more efficient. 9ut they are also more costly.

    Different types of capacitors are

    $. Ceramic capacitors.

    '. *lectrolyte capacitors.;. 0aper

  • 7/26/2019 Intelligent Train Engine With Gating

    46/74

    Intelligent Train Engine with Gate Control System

    LN/#90433'r:

    F'+tr'):

    #"">mA 4ated Collector Current %/ingle

    =utput(

    igh>oltage =utputs . . . #"

    =utput Clamp Diodes

    ,nputs Compatible With arious Types oflogic

    4elay Driver Applications

    Compatible with :-B'!""A /eries

    d')!r",t"onord'r"n* "n3or-+t"on:

    The :-B'!";A is a high>voltage) high>

    current Darlington transistor array. The device

    consists of eight nun Darlington pairs that feature high>voltage outputs with common>

    cathode clamp diodes for switching inductive loads. The collector>current rating of each

    Darlington pair is #"" mA. The Darlington pairs may be connected in parallel for higher

    current capability.

    Applications include relay drivers) hammer drivers) lamp drivers) display drivers

    %-*D and gas discharge() line drivers) and logic buffers. The :-B'!";A has a '.E>

    kLseries base resistor for each Darlington pair for operation directly with TT- or #>

    C

  • 7/26/2019 Intelligent Train Engine With Gating

    47/74

    Intelligent Train Engine with Gate Control System

    Lo*"! d"+*r+-:

    LOGIC DIAGRAM FOR THEULN2803buffer

    Page ?E

  • 7/26/2019 Intelligent Train Engine With Gating

    48/74

    Intelligent Train Engine with Gate Control System

    MNEMON CS

    A useful mnemonicfor remembering the first ten color codes matches the first letterof the color code) by order of increasingmagnitude.There are many variations

    Bad Beer Rots Our Young Guts But Vodka Goes Well

    Bright Boys Rave Over Young Girls But Veto Getting Wed B. B. ROYof Great Britain has a Very Good Wife Big Boys Race Our Young Girls But Violet Generally Wins Better Be Right Or Your Great Big Venture Goes West

    Black Beauty Ran Over Yellow Grass By Violent Grey Waters Bad Boys Race Over Yonder Green But Victory Goes Wanting Black Birds Roam Over Your Garden But Vultures Go West Bye Bye Rosie Off You Go Birmingham Via Great Weston

    The word G9adG in the first mnemonic and G9rightG in the second mnemonic are oftenreplaced with the word G9lackG since black comes before brown in the color code. While

    the second mnemonic is certainly the most offensive of these) all e6cept the third lack asobriety that might be desirable) especially in a teaching conte6t. A more staid memoryaide uses the fact that the central part of the code follows the color spectrum) without thei for indigo. That is)

    Black Brown 4oy I. 9igGray White

    The most common variation of the mnemonic for the *,A color code generallydoesnHt stay posted on this page for long due to its choice of words which is moreoffensive to many today than when it was originated %mid $&'"Hs(. 4efer to the discussionfor details.

    9esides the ten colors of the main value code) the tolerance code is oftenremembered as Gfor Iold or /ilverG appended to the more offensive mnemonic) or GGetSome NowG where Bow refers to nonefor '".

    ,f it is difficult to recall that black comes before brown in the color code) it maybe helpful to use the position of white at the end of the color code as a key to rememberthat black %and not brown( is at the beginning.

    Page ?!

    http://en.wikipedia.org/wiki/Mnemonichttp://en.wikipedia.org/wiki/Magnitude_(mathematics)http://en.wikipedia.org/wiki/Magnitude_(mathematics)http://en.wikipedia.org/wiki/Magnitude_(mathematics)http://en.wikipedia.org/wiki/Color_spectrumhttp://en.wikipedia.org/wiki/Roy_G._Bivhttp://en.wikipedia.org/wiki/Talk:Electronic_color_codehttp://en.wikipedia.org/wiki/Mnemonichttp://en.wikipedia.org/wiki/Magnitude_(mathematics)http://en.wikipedia.org/wiki/Color_spectrumhttp://en.wikipedia.org/wiki/Roy_G._Bivhttp://en.wikipedia.org/wiki/Talk:Electronic_color_code
  • 7/26/2019 Intelligent Train Engine With Gating

    49/74

  • 7/26/2019 Intelligent Train Engine With Gating

    50/74

    Intelligent Train Engine with Gate Control System

    *nough current flows to make the -*D light up) but not so much that the -*D is

    damaged. -ater in this Chapter) you will find out how to calculate a suitable value for thisresistor. %-*Ds are described in detail in Chapter #.(

    The Hbo6H symbol for a fi6ed resistor is popular in the :+ and *urope. A H3ig>3agHsymbol is used in America and 1apan

    4esistors are used with tr+n)d!'r)to make )'n)or )4)5)t'-). Transducers areelectronic components which convert energy from one form into another) where one ofthe forms of energy is electrical. A &"*7t d','nd'nt r')")tor) or LDR) is an e6ample ofan "n,t tr+n)d!'r. Changes in the brightness of the light shining onto the surface ofthe -D4 result in changes in its resistance. As will be e6plained later) an input transduceris most often connected along with a resistor to to make a circuit called a ,ot'nt"+&d"("d'r. ,n this case) the output of the potential divider will be a voltage signal whichreflects changes in illumination.

  • 7/26/2019 Intelligent Train Engine With Gating

    51/74

  • 7/26/2019 Intelligent Train Engine With Gating

    52/74

    Intelligent Train Engine with Gate Control System

    The second band gives the /*C=BD D,I,T. This is a violet band) making thesecond digit E. The third band is called the

  • 7/26/2019 Intelligent Train Engine With Gating

    53/74

    Intelligent Train Engine with Gate Control System

    7"SO/$5(RE DIS&RI*$IO#7"1 EI. MI&ROISIO#

    -An IDE for Microcontrollers

    Introduction:

    +eil development tools for the !"#$ standard +eil C Compilers) time+ernels) /ingle>board Computers) and *mulators support all !"#$ derivatives and helpyou get your projects completed on schedule

    The +eil !"#$ Development Tools are designed to solve the comple6 problems facingembedded software developers.

    When starting a new project) simply select the microcontroller you use from the

    Device Database and the Vision ,D* sets all compiler) assembler) linker) andmemory options for you.

    Bumerous e6ample programs are included to help you get started with the most

    popular embedded !"#$ devices. The +eil Vision Debugger accurately simulates on>chip peripherals %,C) CAB)

    :A4T) /0,) ,nterrupts) ,= 0orts) AD Converter) DA Converter) and 0Wfeatured source code editor)

    Device database for configuring the development tool setting) 0roject manager for creating and maintaining your projects)

    ,ntegrated make facility for assembling) compiling) and linking your embedded

    applications)

    Dialogs for all development tool settings) True integrated source>level Debugger with high>speed C0: and peripheral

    simulator) Advanced ID, interface for software debugging in the target hardware and for

    connection to +eil :-,B+) Flash programming utility for downloading the application program into Flash

    4=

  • 7/26/2019 Intelligent Train Engine With Gating

    55/74

    Intelligent Train Engine with Gate Control System

    T7' V")"on0 )!r''n ,ro("d') 5o 6"t7 + menu bar for command entry + too& 4+r

    67'r' 5o !+n r+,"d&5 )'&'!t !o--+nd 4tton) +nd 6"ndo6) 3or )or!' 3"&') d"+&o*

    4o2') +nd "n3or-+t"on d"),&+5). V")"on0 &'t) 5o )"-&t+n'o)&5 o,'n +nd ("'6

    -&t",&' )or!' 3"&').V")"on0 7+) t6o o,'r+t"n* -od'):

    B"&d Mod':Allows you to translate all the application files and to generate

    e6ecutable programs. The features of the 9uild

  • 7/26/2019 Intelligent Train Engine With Gating

    56/74

    Intelligent Train Engine with Gate Control System

    omeVision; =verview /oftware Development Cycle

    When you use the +eil Vision;) the project development cycle is roughly the sameas it is for any other software development project.

    $. Create a project) select the target chip from the device database) and configure thetool settings.'. Create source files in C or assembly.;. 9uild your application with the project manager.?. Correct errors in source files.#. Test the linked application.

    The following block diagram illustrates the complete Vision; software developmentcycle. *ach component is described below.

    Vision3 IDE

    The Vision; ,D* combines project management) a rich>featured editor withinteractive error correction) option setup) make facility) and on>line help. :se Vision; tocreate your source files and organi3e them into a project that defines your targetapplication. Vision; automatically compiles) assembles) and links your embeddedapplication and provides a single focal point for your development efforts.

    C Compiler & Macro Assembler

    /ource files are created by the Vision; ,D* and are passed to the C or *CMMCompiler or

  • 7/26/2019 Intelligent Train Engine With Gating

    57/74

  • 7/26/2019 Intelligent Train Engine With Gating

    58/74

  • 7/26/2019 Intelligent Train Engine With Gating

    59/74

    Intelligent Train Engine with Gate Control System

    Project Taret and !ile "roups#sho"s ho" to create application 'ariantsand organi(ed the files that belong to a pro)ect.

    Tips and Tric#s# pro'ides information about the ad'anced features of theision! Pro)ect Manager.

    &RE($E*RO8E&$

    Home Creating Applications Create Pro)ect

    ision! is a standard *indo"s application and started b+ clic,ing on theprogram icon. About the En'ironmentdescribes the different "indo" areas of

    ision!.

    ision! includes a pro)ect manager "hich ma,es it eas+ to design applications

    for an A-M based microcontroller. ou need to perform the follo"ing steps to createa ne" pro)ect#

    Select the Toolset /onl+ re%uired for A-M Pro)ects0. Create Pro)ect 1ile and Select CP2. Pro)ect *or,space 3 4oo,s. Create Ne" Source 1iles. Add Source 1iles to the Pro)ect. Create 1ile 5roups. Set Tool 6ptions for Target Hard"are. Configure the CP2 Startup Code. 4uild Pro)ect and 5enerate Application Program Code. Create a HE& 1ile for P-6M Programming.

    The section pro'ides a step3b+3step tutorial that sho"s +ou ho" to create asimple ision! pro)ect.

    *RO8E&$$(RGE$S(#D/I.EGRO%*S

    Home Creating Applications Pro)ect Targets and 1ile 5roups

    4+ using different Project Taretsision! lets +ou create se'eral programs

    from a single pro)ect. ou ma+ need one target for testing and another target for arelease 'ersion of +our application. Each target allo"s indi'idual tool settings "ithin

    the same pro)ect file.

    !iles "roupslet +ou group associated files together in a pro)ect. *e ha'ealread+ used file groups in our e$ample to separate the CP2 related files from other

    Page #&

    http://www.keil.com/support/man/docs/uv3/uv3_ca_projtargfilegr.htmhttp://www.keil.com/support/man/docs/uv3/uv3_ca_projtargfilegr.htmhttp://www.keil.com/support/man/docs/uv3/uv3_ca_tipsandtricks.htmhttp://www.keil.com/support/man/docs/uv3/default.htmhttp://www.keil.com/support/man/docs/uv3/uv3_creating_apps.htmhttp://www.keil.com/support/man/docs/uv3/uv3_1_environment.htmhttp://www.keil.com/support/man/docs/uv3/uv3_3_armtoolset.htmhttp://www.keil.com/support/man/docs/uv3/uv3_3_createprjfile.htmhttp://www.keil.com/support/man/docs/uv3/uv3_3_bookstab.htmhttp://www.keil.com/support/man/docs/uv3/uv3_3_create%20_source_file.htmhttp://www.keil.com/support/man/docs/uv3/uv3_3_sourcefiles.htmhttp://www.keil.com/support/man/docs/uv3/uv3_3_create_file_groups.htmhttp://www.keil.com/support/man/docs/uv3/uv3_3_tool_options.htmhttp://www.keil.com/support/man/docs/uv3/uv3_3_config_start_code.htmhttp://www.keil.com/support/man/docs/uv3/uv3_3_buildproject.htmhttp://www.keil.com/support/man/docs/uv3/uv3_3_createhexfile.htmhttp://www.keil.com/support/man/docs/uv3/default.htmhttp://www.keil.com/support/man/docs/uv3/uv3_creating_apps.htmhttp://www.keil.com/support/man/docs/uv3/uv3_ca_projtargfilegr.htmhttp://www.keil.com/support/man/docs/uv3/uv3_ca_tipsandtricks.htmhttp://www.keil.com/support/man/docs/uv3/default.htmhttp://www.keil.com/support/man/docs/uv3/uv3_creating_apps.htmhttp://www.keil.com/support/man/docs/uv3/uv3_1_environment.htmhttp://www.keil.com/support/man/docs/uv3/uv3_3_armtoolset.htmhttp://www.keil.com/support/man/docs/uv3/uv3_3_createprjfile.htmhttp://www.keil.com/support/man/docs/uv3/uv3_3_bookstab.htmhttp://www.keil.com/support/man/docs/uv3/uv3_3_create%20_source_file.htmhttp://www.keil.com/support/man/docs/uv3/uv3_3_sourcefiles.htmhttp://www.keil.com/support/man/docs/uv3/uv3_3_create_file_groups.htmhttp://www.keil.com/support/man/docs/uv3/uv3_3_tool_options.htmhttp://www.keil.com/support/man/docs/uv3/uv3_3_config_start_code.htmhttp://www.keil.com/support/man/docs/uv3/uv3_3_buildproject.htmhttp://www.keil.com/support/man/docs/uv3/uv3_3_createhexfile.htmhttp://www.keil.com/support/man/docs/uv3/default.htmhttp://www.keil.com/support/man/docs/uv3/uv3_creating_apps.htm
  • 7/26/2019 Intelligent Train Engine With Gating

    60/74

    Intelligent Train Engine with Gate Control System

    source files. *ith these techni%ue it is easil+ possible to maintain comple$ pro)ects"ith se'eral 788 files in ision!.

    The dialog Project $ Components% En&ironment% Boo#s''' $ Project

    Componentsallo"s +ou to create pro)ect targets and file groups. *e ha'e alread+used this dialog to add s+stem configuration files in a file group. An e$ample pro)ect

    structure is sho"n belo".

    The Project (or#spacesho"s all groups and the related files. 1iles are builtand lin,ed in the same order as sho"n in this "indo". ou can mo'e file positions

    "ith Dra ) Drop. ou ma+ select a target or group name and Clic#to rename it.The local menu opens "ith a right mouse Clic#and allo"s +ou for each item#

    to set tool options to remo'e the item to add files to a group to open the file.

    9n the build toolbar +ou can %uic,l+ change the current pro)ect target to build.

    *RO8E&$&OM*O#E#$S

    Home :ialogs Pro)ect

    ou ma+ add; delete; or re-arranethe items "ith the list bo$ buttons in

    Project Tarets; "roups; and !iles.

    Pro)ect Targets

    Sho"s all Project Taretsin +our pro)ect. Project Taretslet +ou createse'eral programs form a single pro)ect. ou ma+ need one target for testing

    and another target for a release 'ersion of +our application.5roups

    Page @"

    http://www.keil.com/support/man/docs/uv3/uv3_dg_prjcomp.htmhttp://www.keil.com/support/man/docs/uv3/uv3_dg_prjcomp.htmhttp://www.keil.com/support/man/docs/uv3/uv3_ca_create_file_groups.htmhttp://www.keil.com/support/man/docs/uv3/default.htmhttp://www.keil.com/support/man/docs/uv3/uv3_dialogs.htmhttp://www.keil.com/support/man/docs/uv3/uv3_dg_prjcomp.htmhttp://www.keil.com/support/man/docs/uv3/uv3_dg_prjcomp.htmhttp://www.keil.com/support/man/docs/uv3/uv3_ca_create_file_groups.htmhttp://www.keil.com/support/man/docs/uv3/default.htmhttp://www.keil.com/support/man/docs/uv3/uv3_dialogs.htm
  • 7/26/2019 Intelligent Train Engine With Gating

    61/74

  • 7/26/2019 Intelligent Train Engine With Gating

    62/74

    Intelligent Train Engine with Gate Control System

    ou ma+ select one of these de'ices and then specif+ an+ necessar+ chip options inthe in the Options for Taret $ Taretdialog. 1or e$ample on3chip memor+ ma+

    be specified as E*ternal Memory.

    Importin +,ision Projects

    Home Creating Applications Tips and Tric,s 9mporting ision 7 Pro)ects

    ou can import pro)ect files from ision7 b+ using the menu item Project -

    Import +,ision Project. This starts the follo"ing procedure#

    7. Create a ne" ision pro)ect file. 9t is important that the ne" ision=!

    pro)ect file is created in the e$isting ision7 pro)ect folder.=. Select a CP2 from the de'ice database.

    !. Select the old ision7 pro)ect file that e$ists in the pro)ect folder.

    B. This import the old ision7 lin,er settings into the 7?? dialogs. Ho"e'er; "erecommend that +ou use the dialog +,ision Options for Taret $ Tarettodefine the memor+ structure of the target hard"are. 6nce +ou ha'e done

    that; +ou should open the dialog Options for Taret $ .// 0 .*1

    .ocate. Enable the option 2se Memory .ayout from Taretand remo'ethe settings for 2ser Classes; 2ser Sements; or 2ser Sectionsin this

    dialog.

    >. Chec, carefull+ if all settings are copied correctl+ to the ne" ision pro)ectfile.

    ?. ou ma+ no" create file groups in the ne" ision pro)ect. Then +ou can :rag

    D :rop files into the ne" file groups.

    De3uin

    Home :ebugging

    This chapter describes the De3u Modeof ision! and sho"s +ou ho" to use theuser interface to test a sample program. Also discussed are simulation mode and the

    different options a'ailable for program debugging.

    ou can use ision! :ebugger to test the applications +ou de'elop. The

    ision! :ebugger offers t"o operating modes that are selected in the Options for

    Taret $ De3udialog.

    2se Simulatorconfigures the ision! :ebugger as software-only productthat simulates most features of a microcontroller "ithout actuall+ ha'ing

    target hard"are. ou can test and debug +our embedded application beforethe hard"are is read+. ision! simulates a "ide 'ariet+ of peripherals

    Page @'

    http://www.keil.com/support/man/docs/uv3/default.htmhttp://www.keil.com/support/man/docs/uv3/uv3_creating_apps.htmhttp://www.keil.com/support/man/docs/uv3/uv3_ca_tipsandtricks.htmhttp://www.keil.com/support/man/docs/uv3/default.htmhttp://www.keil.com/support/man/docs/uv3/uv3_5_cpusimulation.htmhttp://www.keil.com/support/man/docs/uv3/default.htmhttp://www.keil.com/support/man/docs/uv3/uv3_creating_apps.htmhttp://www.keil.com/support/man/docs/uv3/uv3_ca_tipsandtricks.htmhttp://www.keil.com/support/man/docs/uv3/default.htmhttp://www.keil.com/support/man/docs/uv3/uv3_5_cpusimulation.htm
  • 7/26/2019 Intelligent Train Engine With Gating

    63/74

    Intelligent Train Engine with Gate Control System

    including the serial port; e$ternal 96; and timers. The peripheral set isselected "hen +ou select a CP2 from the de'ice database for +our target.

    2seAd'anced 5:9 dri'ers; li,e the 2.IN4 De3uerto interface to +ourtarget hard"are. 1or ision! 'arious dri'ers are a'ailable that interface to#

    o 5TA"0OCDS Adapter# "hich connects to on3chip debugging s+stems

    li,e the A-M Embedded 9CE.

    o Monitor# that ma+ be integrated "ith user hard"are or is a'ailable onman+ e'aluation boards.

    o Emulator# "hich connects to the CP2 pins of the target hard"are.

    o In-System De3uer# "hich is part of the user application program

    and pro'ides basic test functions.o Test 6ard7are# such as the 9nfineon Smartcard -6M Monitor -M??P

    or the Philips Smarm 4o$.

    !las8 Prorammin

    Home 1lash Programming

    ision! integrates 1lash Programming 2tilities in the pro)ect en'ironment. All

    configurations are sa'ed in conte$t "ith +our current pro)ect.

    ou ma+ use e$ternal command3line dri'en utilities /usuall+ pro'ided b+ the chip

    'endor0 or the eil 29N 2S43FTA5 Adapter. The 1lash Programming 2tilities areconfigured under Project - Options - 2tilities.

    1lash Programming ma+ be started from the !las8 Menuor before starting theision! :ebugger "hen +ou enable Project - Options - 2tilities - 2pdate Taret

    3efore De3uin.

    Measure - Project !ile

    Home E$ample Programs Measure# A -emote Measurement S+stemMeasure 3 Pro)ect 1ile

    The pro)ect file for the MEAS2-E sample program is called Measure'2,9. Toload this pro)ect file; use Open Projectfrom the Projectmenu and select

    Measure'2,9in the folder ''':A;M:''':E*amples:Measure.

    The 1iles page in the Pro)ect *or,space sho"s the source files that composethe MEAS2-E pro)ect. The three application related source files that are located in

    the Source !ilesgroup. The function of the source files is described belo". To opena source file; double3clic, on the filename.

    Page @;

    http://www.keil.com/ulinkhttp://www.keil.com/support/man/docs/uv3/default.htmhttp://www.keil.com/support/man/docs/uv3/uv3_10_dlg_flashutil.htmhttp://www.keil.com/support/man/docs/uv3/uv3_2_flash.htmhttp://www.keil.com/support/man/docs/uv3/default.htmhttp://www.keil.com/support/man/docs/uv3/uv3_examples.htmhttp://www.keil.com/support/man/docs/uv3/uv3_ex_measureovw.htmhttp://www.keil.com/ulinkhttp://www.keil.com/support/man/docs/uv3/default.htmhttp://www.keil.com/support/man/docs/uv3/uv3_10_dlg_flashutil.htmhttp://www.keil.com/support/man/docs/uv3/uv3_2_flash.htmhttp://www.keil.com/support/man/docs/uv3/default.htmhttp://www.keil.com/support/man/docs/uv3/uv3_examples.htmhttp://www.keil.com/support/man/docs/uv3/uv3_ex_measureovw.htm
  • 7/26/2019 Intelligent Train Engine With Gating

    64/74

    Intelligent Train Engine with Gate Control System

    Measure

  • 7/26/2019 Intelligent Train Engine With Gating

    65/74

  • 7/26/2019 Intelligent Train Engine With Gating

    66/74

  • 7/26/2019 Intelligent Train Engine With Gating

    67/74

    Intelligent Train Engine with Gate Control System

    Proram E*ecution

    Home E$ample Programs Measure# A -emote Measurement S+stem

    Program E$ecution

    4efore +ou begin simulating MEAS2-E; open the Serial (indo7 =that

    displa+s the serial output "ith the ,ie7menu or the De3utoolbar. ou ma+disable other "indo"s if +our screen is not large enough.

    ou can use the Step toolbar buttons on assembler instructions or sourcecode lines. 9f the :isassembl+ *indo" is acti'e; +ou single step at assembl+instruction basis. 9f an editor "indo" "ith source code is acti'e; +ou single step at

    source code le'el.

    Call Stac#

    Home E$ample Programs Measure# A -emote Measurement S+stem Call

    Stac,

    ision! internall+ trac,s function nesting as the program e$ecutes. The Call

    Stac#page of the (atc8 (indo7sho"s the current function nesting. A doubleclic, on a line displa+s the source code that called the selected function.

    Brea#points Dialo

    Home E$ample Programs Measure# A -emote Measurement S+stem

    4rea,points :ialog

    Page @E

    http://www.keil.com/support/man/docs/uv3/default.htmhttp://www.keil.com/support/man/docs/uv3/uv3_examples.htmhttp://www.keil.com/support/man/docs/uv3/uv3_ex_measureovw.htmhttp://www.keil.com/support/man/docs/uv3/default.htmhttp://www.keil.com/support/man/docs/uv3/uv3_examples.htmhttp://www.keil.com/support/man/docs/uv3/uv3_ex_measureovw.htmhttp://www.keil.com/support/man/docs/uv3/default.htmhttp://www.keil.com/support/man/docs/uv3/uv3_examples.htmhttp://www.keil.com/support/man/docs/uv3/uv3_ex_measureovw.htmhttp://www.keil.com/support/man/docs/uv3/default.htmhttp://www.keil.com/support/man/docs/uv3/uv3_examples.htmhttp://www.keil.com/support/man/docs/uv3/uv3_ex_measureovw.htmhttp://www.keil.com/support/man/docs/uv3/default.htmhttp://www.keil.com/support/man/docs/uv3/uv3_examples.htmhttp://www.keil.com/support/man/docs/uv3/uv3_ex_measureovw.htmhttp://www.keil.com/support/man/docs/uv3/default.htmhttp://www.keil.com/support/man/docs/uv3/uv3_examples.htmhttp://www.keil.com/support/man/docs/uv3/uv3_ex_measureovw.htm
  • 7/26/2019 Intelligent Train Engine With Gating

    68/74

  • 7/26/2019 Intelligent Train Engine With Gating

    69/74

    Intelligent Train Engine with Gate Control System

    :"&ODI#GPro*r+- 6r"tt'n "n C &+n*+*'

    include_stdio.h^include_reg#$.h^void delay%into(5void medley%void(5sit sen$K0$"5sit sen'K0$$5sit bu33K0$;5sit sig$K0$?5sit sig'K0$#5sit laserK0$ @5void close%(5void open%(5void bu33er%(5

    into mK$""""5void main%(

    0"K0'K0;K"6""50$K"6ff5bu33er%(5sig$K"6""5 train stoproad gosig'K"6"$5open%(5for%55(

    if%sen$KK"6""(

    sig$K"6"$5 sig'K"6""5 train goroad stopbu33er%(5close%(5medley%(5while%sen'KK"6"$(while%sen'KK"6""(sig$K"6""5 sig'K"6"$5 train stoproad gobu33er%(5open%(5

    if%sen'KK"6""(

    sig$K"6"$5 sig'K"6""5 train goroad stopbu33er%(5close%(5medley%(5while%sen$KK"6"$(

    Page @&

  • 7/26/2019 Intelligent Train Engine With Gating

    70/74

  • 7/26/2019 Intelligent Train Engine With Gating

    71/74

    Intelligent Train Engine with Gate Control System

    0'K"6;;5deley%m(50'K"6''5deley%m(50'K"6@@5deley%m(50'K"6??5deley%m(50'K"6cc5deley%m(5

    0'K"6!!5deley%m(50'K"6&&5deley%m(5

    0'K"6$$5deley%m(50'K"6;;5deley%m(50'K"6''5deley%m(50'K"6@@5deley%m(50'K"6??5deley%m(50'K"6cc5deley%m(50'K"6!!5deley%m(50'K"6&&5deley%m(5

    void close%(

    0'K"6&&5deley%m(50'K"6!!5deley%m(50'K"6cc5deley%m(50'K"6??5deley%m(50'K"6@@5deley%m(50'K"6''5deley%m(50'K"6;;5deley%m(50'K"6$$5deley%m(5

    0'K"6&&5deley%m(50'K"6!!5deley%m(50'K"6cc5deley%m(50'K"6??5deley%m(50'K"6@@5deley%m(50'K"6''5deley%m(50'K"6;;5deley%m(50'K"6$$5deley%m(5

    void delay%k(

    into iK"5for%iK"5i_KkidMM(

    Page E$

  • 7/26/2019 Intelligent Train Engine With Gating

    72/74

  • 7/26/2019 Intelligent Train Engine With Gating

    73/74

  • 7/26/2019 Intelligent Train Engine With Gating

    74/74