Sie sind auf Seite 1von 70

1.

ABSTRACT
OBJECTIVE: The aim of this project is to Automate unmanned railway gate using mechatronics. PROJECT DEFINATION: 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 the railway 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 the train crosses the other end control system automatically lifts the gate. For mechanical operation of the gates 1.8 step angle stepper motors are employed. ere we are using embedded controller built around the 8!"1 family #AT8$%"&' for the control according to the data pattern produced at the input port of the micro controller( the appropriate selected action will be taken.. The logic is produced by the program written in )mbedded % language. The software program is written( by using the *)+, micro vision environment. The program written is then converted in )- code after simulation and burned on to microcontroller using F,A. micro vision.

WORKING METHODOLOGY: /resent project is designed using 8!"1 microcontroller to avoid railway accidents happening at unattended railway gates( if implemented in spirit. This project utili0es two powerful +1 transmitters and two receivers2 one pair of transmitter and receiver is fi3ed at up side #from where the train comes' at a level higher than a human being in e3act alignment and similarly the other pair is fi3ed at down side of the train direction. .ensor activation time is so adjusted by calculating the time taken at a certain speed to cross at least one compartment of standard minimum si0e of the +ndian railway. We have considered " seconds for this project. .ensors are fi3ed at 1km on both sides of the gate. We call the sensor along the train direction as 4foreside sensor5 and the other as 4after side sensor5. When 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. When aft side receiver gets activated motor turns in opposite direction and gate opens and motor stops. 6u00er 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.

GATE CONTROL 1ailways being the cheapest mode of transportation are preferred over all the other means .When 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 lack of workers. We( in this project has come up with a solution for the same. 7sing 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.

2.INTRODUCTION
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 the railway 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 the train crosses the other end control system automatically lifts the gate. For mechanical operation of the gates 1.8 step angle stepper motors are employed. ere we are using embedded controller built around the 8!"1 family #AT8$%"&' for the control according to the data pattern produced at the input port of the micro controller( the appropriate selected action will be taken.. The logic is produced by the program written in )mbedded % language. The software program is written( by using the *)+, micro vision environment. The program written is then converted in )- code after simulation and burned on to microcontroller using F,A. micro vision.

AT#$C%1 M"!ro!ontro&&'r
The 8icro controller #AT8$%"1' is a low power2 high performance %89. 8:bit micro controller with ;* bytes of Flash programmable and erasable read only memory #/)198'. The on:chip Flash allows the program memory to be reprogrammed in:system or by a conventional non:volatile memory programmer. 6y combining a versatile 8:bit %/7 with Flash on a monolithic chip( the Atmel AT8$%"1 is a powerful microcomputer( which provides a highly fle3ible and cost:effective solution to many embedded control applications. 6y using this controller the data inputs from the smart card is passed to the parallel port of the pc and accordingly the software responds. The +<) 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 8!"1 micro controller family support every level of developer from the professional applications engineer to the student just learning about embedded software development.The industry:standard *eil % %ompilers( 8acro Assemblers( <ebuggers( 1eal:time *ernels( and .ingle:board %omputers support A,, 8!"1:compatible derivatives and help you get your projects completed on schedule. The source code is written in assembly language .+t is saved as A.8 file with an e3tension. A"1.the A.8 file is converted into he3 file using keil software. e3 file is dumped into micro controller using ,A6T99, software. At once the file is dumped and the 198 is burnt then it becomes an embedded one.

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


.tep motors convert electrical energy into precise mechanical motion. These motors rotate a specific incremental distance per each step. The number of steps e3ecuted controls the degree of rotation of the motor5s shaft. This characteristic makes step motors e3cellent for positioning applications. For e3ample( a 1.8= step motor e3ecuting 1!! steps will rotate e3actly 18!= with some small amount of non:cumulative error. The speed of step e3ecution controls the rate of motor rotation. A 1.8= step motor e3ecuting steps at a speed of &!! steps per second will rotate at e3actly 1 revolution per second. .tep motors can be very accurately controlled in terms of how far and how fast they will rotate. The number of steps the motor e3ecutes is e>ual 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 fre>uency of its pulse commands. .tep motors have several advantages over other types of motors. 9ne of the most impressive is their ability to position very accurately. ?865s standard step motors have an accuracy of @A:"B. The error does not accumulate from step to step. This means that a standard step motor can take a single step and travel 1.8= @A:!.!$=. Then it can take one million steps and travel 1(8!!(!!!= @A:!.!$=. This characteristic gives a step motor almost perfect repeatability. +n motor terms( repeatability is the ability to return to a previously held position. A step motor can achieve the same target position( revolution after revolution.

3.CIRCUIT DIAGRAM

4.COMPONENTS
The project consists of three main partsC 8!"1 microcontroller +1 Transmitter +1 1eceiver .tepper 8otor %ircuit 8!"1 %9?T19,,)1

The +A9 ports of the 8!"1 are e3panded by connecting it to an 8&"" chip. The 8&"" is programmed as a simple +A9 port for connection with devices such as ,)<s( stepper motors and sensors. The following block diagram shows the various devices connected to the different ports of an 8&"". The ports are each 8:bit and are named A( 6 and %. The individual ports of the 8&"" can be programmed to be input or output( and can be changed dynamically. The control register is programmed in simple +A9 mode with port A( port 6 and port % #upper' as output ports and port % #lower' as an input port. IR CIRC.ITS This circuit has two stagesC a transmitter unit and a receiver unit. The transmitter unit consists of an infrared ,)< and its associated circuitry.

IR TRANSMITTER The +1 ,)< emitting infrared light is put on in the transmitting unit. To generate +1 signal( """ +% based astable multivibrator is used. +nfrared ,)< is driven through transistor 6% ";8. +% """ is used to construct an astable multivibrator which has two

>uasi:stable states. +t generates a s>uare wave of fre>uency D8k 0 and amplitude "Eolts. +t is re>uired to switch 49?5 the +1 ,)<. IR RECEIVER: The receiver unit consists of a sensor and its associated circuitry. +n receiver section( the first part is a sensor( which detects +1 pulses transmitted by +1:,)<. Whenever a train crosses the sensor( the output of +1 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 8!"1 microcontroller. 9n receiving a pulse from the sensor circuit( the controller activates the circuitry re>uired for closing and opening of the gates and for track switching. The +1 receiver circuit is shown in the figure below.

STEP MOTOR ADVANTAGES .tep motors convert electrical energy into precise mechanical motion. These motors rotate a specific incremental distance per each step. The number of steps e3ecuted controls the degree of rotation of the motor5s shaft. This characteristic makes step motors e3cellent for positioning applications. For e3ample( a 1.8= step motor e3ecuting 1!! steps will rotate e3actly 18!= with some small amount of non:cumulative error. The speed of step e3ecution controls the rate of motor rotation. A 1.8= step motor e3ecuting steps at a speed of &!! steps per second will rotate at e3actly 1 revolution per second. .tep motors can be very accurately controlled in terms of how far and how fast they will rotate. The number of steps the motor e3ecutes is e>ual 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 fre>uency of its pulse commands. .tep motors have several advantages over other types of motors. 9ne of the most impressive is their ability to position very accurately. ?865s standard step motors have an accuracy of @A:"B. The error does not accumulate from step to step. This means that a standard step motor can take a single step and travel 1.8= @A:!.!$=. Then it can take one million steps and travel 1(8!!(!!!= @A:!.!$=. This characteristic gives a step motor almost perfect repeatability. +n motor terms( repeatability is the ability to return to a previously held position. A step motor can achieve the same target position( revolution after revolution.

5.EMBEDDED SYSTEMS
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( comple3 system. <edicated applications( designed to e3ecute specific activities( are implemented and embedded in systems. These embedded applications are re>uired to collaborate with the other components of an enclosed system. )mbedded application components interact mostly with the non:human e3ternal 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 Application and system are closely tied together %ollaborative application <edicated AW and specific .AW +nteraction with non:human e3ternal environment

1eal:time systems are embedded systems

7nderstand 7nderstanduser user re>uirements re>uirements optimum 5.1 EMBEDDED PRODUCT%hoose DEVELOPMENT LIFE CYCLE %hoose optimum electronic electronicchip chip .AW .ide AW .ide

,,AA,, ,,AA,, Algorithm Algorithm %odingA)diting %odingA)diting %ompilingAAssembling %ompilingAAssembling <ebugging <ebugging Testing Testing .imulator .imulator .AW .AW
<9W?,9A<

/%6 /%6,ayout ,ayoutdesign design

Assembling Assembling components components

Testing Testing

AW AW

+%) +%)#+n #+n%ircuit %ircuit )mulator' )mulator' )mbedded )mbedded/roduct /roduct

%./ DESIGN CONSIDERATIONS FOR AN EMBEDDED SYSTEM

Introd !t"on: 7nlike 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 e3ecutable code and temporary storage for runtime data manipulation. These take the form of 198 and 1A8( respectively. All embedded systems also contain some type of inputs and outputs. +t is almost always the case that the outputs of the embedded system are a function of its inputs and several other factors. The inputs to the system usually take the form of sensors and probes( communication signals( or control knobs and buttons. The outputs are typically displays( communication signals( or changes to the physical world.

Memory Memory

Inputs Inputs

Processor Processor

Outputs Outputs

E0+-,&' o1 +n E-2'dd'd S3)t'9ther common design re>uirement include : /rocessing power 8emory <evelopment cost ?umber of 7nits )3pected ,ifetime 1eliability

Pro!'))"n* ,o4'r This is the amount of processing power necessary to get the hob done. A common way to compare processing power is the 8+/. #millions of instructions per second' rating. 9ther important features of the processor need to be consider is register width( typically ranges from 8 to F; bits. M'-or3: The amount of memory #198 and 1A8' re>uired holding the e3ecutable software and data it manipulates. The amount of memory re>uired can also affect the processor selection. +n general( the register width off a processor establishes the upper limit of the amount of memory it can access.

D'('&o,-'nt !o)t: The development cost of the hardware and software design processes is a fi3ed( one:time cost( so it might be that money is no object or that this is the only accurate measure of system cost. N -2'r o1 n"t): The tradeoff between production cost and development cost is affected most by the number of units e3pected to be produced and sold.

E0,'!t'd &"1't"-': This indicates how long must the system continue to functionG This affects all sorts of design decisions from the selection of hardware components to how much the system may cost to develop and produce. R'&"+2"&"t3: ow reliable must the final product beG +f it is a children5s toy( it doesn5t always have to work right( but if it is part of a space shuttle or a car( it had sure better do what it is supposed to each and every time. T5' B+)"! D')"*n 6 REALTIME: <esigning )mbedded systems is a challenging task. 8ost of the challenge comes from the fact that )mbedded systems have to interact with real world entities. These interactions can get fairly comple3. A typical )mebbed system might be interacting with thousands of such entities at the same time. For e3ample( a telephone switching system routinely handles calls from tens of thousands of subscriber. The system has to connect each call differently. Also( the e3act se>uence of events in the call might vary a lot. )mbedded systems have to respond to e3ternal interactions in a predetermined amount of time. .uccessful completion of an operation depends upon the correct and timely operation of the system. <esign the hardware and the software in the system to meet the 1ealtime re>uirements. For e3ample( a telephone switching system must feed dial tone to thousands of subscribers within a recommended limit of one second. To meet these re>uirements( 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 re>uirements for all the calls being set up at any given time. The designers have to focus very early on the 1ealtime response re>uirements. <uring the architecture design phase( the hardware and software engineers work together to select the right system architecture that will meet the re>uirements. This involves deciding inter connectivity of the processors( link speeds( processor speeds( etc.

The mai !"e#ie$ %& 'e a$(e) a#e*


+s the architecture suitableG +f message communication involves too many

nodes( it is likely that the system may not be able to meet the Realtime re>uirement due to even mild congestion. Thus a simpler architecture has a better chance of meeting the Realtime re>uirements. Are the processing components powerful enoughG A %/7 with really high

utili0ation will lead to unpredictable Realtime behavior. Also( it is possible that the high priority tasks in the system will starve the low priority tasks of any %/7 time. This can cause the low priority tasks to misbehave. +s the 9perating .ystem suitableG Assign high priority to tasks that are involved in processing Realtime critical events. %onsider preemptive scheduling if Realtime re>uirements 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 e3ample( a telephone switching system is e3pected to feed dialtone in less than "!! ms. This would typically involve scheduling three to five tasks within the stipulated time. 8ost operating systems would easily meet these numbers as far as the mean dialtone delay is concerned. 6ut general

purpose operating systems would have much higher standard deviation in the dialtone numbers. o +nterrupt ,atency refers to the delay with which the operating system can handle interrupts and schedule tasks to respond to the interrupt. Again( )mbedded .ystems based on real:time operating systems would have much lower interrupt latency.

+.MICROCONTROLLER

Introduction:
8icrocontrollers are HembeddedH inside some other device #often a consumer product' so that they can control the features or actions of the product. Another name for a microcontroller( therefore( is Hembedded controller.H 8icrocontrollers are dedicated to one task and run one specific program. The program is stored in 198 #read:only memory' and generally does not change. 8icrocontrollers are often low:power devices. A microcontroller has a dedicated input device and often #but not always' has a small ,)< or ,%< 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 e3ample( the microcontroller inside a TE takes input from the remote control and displays output on the TE screen. The controller controls the channel selector( the speaker system and certain adjustments on the picture tube electronics such as tint and brightness. The engine controller in a car takes input from sensors such as the o3ygen and knock sensors and controls things like fuel mi3 and spark plug

timing. A microwave oven controller takes input from a keypad( displays output on an ,%< display and controls a relay that turns the microwave generator on and off. A microcontroller is often small and low cost. The components are chosen to minimi0e si0e and to be as ine3pensive as possible. A microcontroller is often( but not always( ruggedi0ed in some way. 9n the other hand( a microcontroller embedded inside a E%1 hasnIt been ruggedi0ed at all.
The actual processor used to implement a microcontroller can vary widely.

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

The AT8$%"1 is a low:power( high:performance %89. 8:bit microcomputer with ;* bytes of Flash programmable and erasable read only memory #/)198' based on the famous 8!"1 architecture. The device is manufactured using Atmel5s high:density nonvolatile memory technology and is compatible with the industry:standard 8%.:"1 instruction set and pinout. The on:chip Flash allows the program memory to be reprogrammed in:system or by a conventional nonvolatile memory programmer. 6y combining a versatile 8:bit %/7 with Flash on a monolithic chip( the Atmel AT8$%"1 is a powerful microcomputer which provides a highly:fle3ible and cost:effective solution to many embedded control applications. F'+t r') The AT8$%"1 provides the following standard featuresC %ompatible with 8%.:"1 /roducts )nduranceC 1(!!! WriteA)rase %ycles ;* 6ytes of +n:.ystem 1eprogrammable Flash 8emory 1&8 bytes of +nternal 1A8 #1&8 3 8:bit' D& /rogrammable +A9 ,ines

Two 1F:bit TimerA%ounters Five vector two:level interrupt architecture A full duple3 serial port Three:level /rogram 8emory ,ock .i3 +nterrupt .ources

BLOC, DIAGRAM*

FigureC 6lock <iagram of AT8$c"1 8icrocontroller

PIN CONFIGURATIONS*

FigureC /<+/ Type AT8$c"1 /in <iagram

PIN DESCRIPTION
VCC S ,,&3 (o&t+*'.
GND Jround. Port 7: /ort ! is an 8:bit open:drain bi:directional +A9 port. As an output port( each pin can sink eight TT, inputs. When 1s are written to port ! pins( the pins can be used as high impedance inputs. /ort ! may also be configured to be the multiple3ed low order addressAdata bus during accesses to e3ternal program and data memory. +n this mode /! has internal pull:ups. /ort ! also receives the code bytes during Flash programming( and outputs the code bytes during program verification. )3ternal pull:ups are re>uired during program verification. Port 1 /ort 1 is an 8:bit bi:directional +A9 port with internal pull:ups. The /ort 1 output buffers can sinkAsource four TT, inputs. When 1s are written to /ort 1 pins they are pulled high by the internal pull:ups and can be used as inputs. As inputs( /ort 1 pins that are e3ternally being pulled low will source current #++,' because of the

internal pull:ups. /ort 1 also receives the low:order address bytes during Flash programming and verification. Port / /ort & is an 8:bit bi:directional +A9 port with internal pull:ups. The /ort & output buffers can sinkAsource four TT, inputs. When 1s are written to /ort & pins they are pulled high by the internal pull:ups and can be used as inputs.As inputs( /ort & pins that are e3ternally being pulled low will source current #++,' because of the internal pull:ups. /ort & emits the high:order address byte during fetches from e3ternal program memory and during accesses to e3ternal data memory that uses 1F:bit addresses #89E- K </T1'. +n this application( it uses strong internal pull:ups when emitting 1s.

Port 8 /ort D is an 8:bit bi:directional +A9 port with internal pull:ups. The /ort D output buffers can sinkAsource four TT, inputs. When 1s are written to /ort D pins they are pulled high by the internal pull:ups and can be used as inputs. As inputs( /ort D pins that are e3ternally being pulled low will source current #++,' because of the pull:ups. /ort D also serves the functions of various special features of the AT8$%"1 as listed belowC Port P"n /D.! /D.1 /D.& /D.D /D.; /D." /D.F /D.L A&t'rn+t' F n!t"on) 1-< #serial input port' T-< #serial output port' +?T! #e3ternal interrupt !' +?T1 #e3ternal interrupt 1' T! #timer ! e3ternal input' T1 #timer 1 e3ternal input' W1 #e3ternal data memory Write strobe' 1< #e3ternal data memory read strobe'

/ort D also receives some control signals for Flash programming and verification.

RST 1eset input. A high on this pin for two machine cycles while the oscillator is running resets the device.

ALE9PROG Address ,atch )nable output pulse for latching the low byte of the address during accesses to e3ternal memory. This pin is also the program pulse input #/19J' during Flash programming. +n normal operation A,) is emitted at a constant rate of 1AF the oscillator fre>uency( and may be used for e3ternal timing or clocking purposes. ?ote( however( that one A,) pulse is skipped during each access to e3ternal <ata 8emory. +f desired( A,) operation can be disabled by setting bit ! of .F1 location 8) . With the bit set( A,) is active only during a 89E- or 89E% instruction. 9therwise( the pin is weakly pulled high. .etting the A,):disable bit has no effect if the microcontroller is in e3ternal e3ecution mode.
PSEN

/rogram .tore )nable is the read strobe to e3ternal program memory. When the AT8$%"1 is e3ecuting code from e3ternal program memory( each machine cycle( e3cept that two e3ternal data memory.
EA
PSEN PSEN

is activated twice

activations are skipped during each access to

9VPP )3ternal Access )nable must be strapped to J?< in order to enable the device to up to FFFF .

fetch code from e3ternal program memory locations starting at !!!! ?ote( however( that if lock bit 1 is programmed(
EA

will be internally latched on reset.

EA

should be strapped to E%% for internal program e3ecutions. This pin also receives

the 1&:volt programming enable voltage #E//' during Flash programming( for parts that re>uire 1&:volt E//.

:TAL1 +nput to the inverting oscillator amplifier and input to the internal clock operating circuit.

:TAL/ 9utput from the inverting oscillator amplifier O)!"&&+tor C5+r+!t'r")t"!) -TA,1 and -TA,& 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 1. )ither a >uart0 crystal or ceramic resonator may be used. To drive the device from an e3ternal clock source( -TA,& should be left unconnected while -TA,1 is driven as shown in Figure &. There are no re>uirements on the duty cycle of the e3ternal clock signal( since the input to the internal clocking circuitry is through a divide:by:two flip:flop( but minimum and ma3imum voltage high and low time specifications must be observed.

F"* r'1: O)!"&&+tor Conn'!t"on) ?oteC %1( %& M D! pF NO1! pF for %rystals

M ;! pF NO1! pF for %eramic 1esonators

F"* r' /: E0t'rn+& C&o!; Dr"(' Con1"* r+t"on Ho4 O)!"&&+tor 4or;) When >uart0 crystal is subjected to mechanical pressure( they produce a measurable electrical voltage conversely when an electric current is applied to a crystal( it will induce mechanical movement. +f an ac is passed through the crystal plate the charges oscillate back and front at the resonant fre>uency of crystal.

fM1/& (##1@%A%/'A#,%'''

Puart0 crystal e3hibits a property called the pie0o:electric effect that is they produce an electric voltage. When subjected to pressure along certain direction of the crystal because of this property >uart0 crystal has important application in electronics industry for controlling the fre>uency of radio waves.When pie0o:electric crystal is used in place of ,% circuit for higher fre>uency stability( the oscillator is called as crystal oscillator.

%rystal oscillator is used for stability fre>uency for a long period of time. The resolution of !.!1 nmAs can be obtained. %rystal operates between fp and fs fre>uency #a very narrow bandwidth'. St+t ) o1 E0t'rn+& P"n) d r"n* Id&' +nd Po4'r<do4n Mod') Pro*r+M'-or3 +nternal )3ternal +nternal )3ternal

Mod' +dle +dle /ower: down /ower: down

ALE 1 1 ! !

PSEN

Port 7 <ata Float <ata Float

Port 1 <ata <ata <ata <ata

Port /

Port8

1 1 ! !

<ata <ata Address <ata <ata <ata <ata <ata

Pro*r+- M'-or3 Lo!; B"t)

9n the chip are three lock bits which can be left un:programmed #7' or can be programmed #/' to obtain the additional features listed in the table below. When lock bit 1 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 initiali0es 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) ,61 1 7 ,6& 7 ,6D 7 Prot'!t"on T3,' ?o program lock features 89E% instructions e3ecuted

from

e3ternal

program memory are disabled from fetching code & / 7 7 bytes from internal memory( )A is sampled and latched on reset( and further programming of the D ; / / / / 7 / Flash is disabled .ame as mode &( also verify is disabled .ame as mode D( also e3ternal e3ecution is disabled

Pro*r+--"n* t5' F&+)5 The AT8$%"1 is normally shipped with the on:chip Flash memory array in the erased state #that is( contents M FF ' and ready to be programmed. The programming

interface accepts either a high:voltage #1&:volt' or a low:voltage #E%%' program enable signal. The low:voltage programming mode provides a convenient way to program the AT8$%"1 inside the user5s system( while the high:voltage programming mode is compatible with conventional third:party Flash or )/198 programmers. R'+d"n* t5' S"*n+t r' B3t'): The signature bytes are read by the same procedure as a normal verification of locations !D! ( !D1 ( and !D& ( e3cept that /D.F and /D.L must be pulled to a logic low. The values returned are as follows. #!D! ' M 1) indicates manufactured by Atmel #!D1 ' M "1 indicates 8$%"1 #!D& ' M FF indicates 1&E programming #!D& ' M !" indicates "E programming. Pro*r+--"n* Int'r1+!' )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 programming vendors offer worldwide support for the Atmel microcontroller series. /lease contact your local programming vendor for the appropriate software revision. F&+)5 Pro*r+--"n* Mod') Mod' Write %ode <ata 1ead %ode <ata Write ,ock 6it:1 6it:& 6it:D RST PSEN , , , , , , , A1&E A1&E A1&E A1&E , , , , , , , , , , , ALE9PROG EA P/.= P/.> P8.= VPP A1&E , , , A P8.>

%hip )rase 1ead .ignature

6yte ?oteC %hip )rase re>uires a 1! ms /19J pulse. E:TERNAL PROGRAM MEMORY READ CYCLE

E0t'rn+& D+t+ M'-or3 R'+d C3!&'

E0t'rn+& D+t+ M'-or3 Wr"t' C3!&'

E0t'rn+& C&o!; Dr"(' W+('1or-)

E0t'rn+& C&o!; Dr"('

S3-2o& 1At%,%, t%,%, techs talc talc techs

P+r+-'t'r 9scillator Fre>uency %lock /eriod igh Time ,ow Time 1ise Time Fall Time

M"n ! ;1.F 1" 1"

M+0 &;

&! &!

.n"t) 8 0 ns ns ns ns ns

-..ARD/ARE DISCRIPTION -.1 STEPER MOTOR


Introd !t"on:
.tepper motors convert electrical energy into precise mechanical motion. These motors rotate a specific incremental distance per each step. The number of steps e3ecuted controls the degree of rotation of the motor5s shaft. This characteristic makes step motors e3cellent for positioning applications. For e3ample( a 1.8= step motor e3ecuting 1!! steps will rotate e3actly 18!= with some small amount of non:cumulative error. The speed of step e3ecution controls the rate of motor rotation. A 1.8= step motor e3ecuting steps at a speed of &!! steps per second will rotate at e3actly 1 revolution per second. .tepper motors can be very accurately controlled in terms of how far and how fast they will rotate. The number of steps the motor e3ecutes is e>ual 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 fre>uency of its pulse commands. B+)"! St',,'r Motor S3)t'-

The diagram above shows a typical step motor based system. All of these parts must be present in one form or another. )ach component5s performance will have an effect on the others. 6y altering the fre>uency 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. ?e3t is the motor driver.

The driver takes the pulses from the pulse generator and determines how and when the windings should be energi0ed. The windings must be energi0ed in a specific se>uence to generate motion. Finally there is the step motor itself. A step motor has two primary parts2 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 se>uencing the flow of current through the stator windings. )ach ?86 step motor has two phases( which are groups of electrically connected windings. As current is passed through each phase( the motor takes QstepsR or small 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+*'): S Accuracy T 1epeatability U Ability to position accurately. S 1esponsiveness T Puick Acceleration U .tep motors have low rotor inertia( allowing them to get up to speed >uickly. This makes step motors an e3cellent choice for short( >uick moves. S )3cellent tor>ue for their si0e U .tep motors have the highest tor>ue per cubic inch of any motor. S /ositioning .tability U 7nlike other types of motors( step motors can be held completely motionless in their stopped position.

Con)tr !t"on +nd O,'r+t"n* t5' H32r"d STEP MOTOR Figure 1a depicts a 1.8= hybrid step motor. The rotor contains a permanent magnet similar to those found in permanent magnet step motors. ybrid rotors are a3ially magneti0ed( one end polari0ed north and the other polari0ed south. 6oth the rotor and the stator assemblies of hybrid motors have tooth:like projections. To understand the rotor5s interaction with the stator( e3amine the construction of a 1.8= #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 D.F=. .econd( the stator has a two:phase construction. The winding coils( $!= apart from one another( make up each phase. )ach phase is wound so that the poles 18!= apart are the same polarity( while the poles $!= 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. 1b below( when phase A is energi0ed( the windings at 1& o5clock and F o5clock are north poles and the windings at D o5clock and $ o5clock are south poles. The windings at 1& and F would attract the teeth of the magnetically south end of the rotor( and windings at D and $ would attract the teeth of the magnetically north end of the rotor. .

-.2 CAPACITORS
Introduction: An '&'!tro&3t"! !+,+!"tor is a type of capacitor typically with a larger capacitance per unit volume than other types( making them valuable in relatively high:current and low:fre>uency electrical circuits. This is especially the case in power:supply filters( where they store charge needed to moderate output voltage and current fluctuations( in rectifier output( and especially in the absence of rechargeable batteries that can provide similar low:fre>uency current capacity. They are also widely used as coupling capacitors in circuits where A% should be conducted but <% should not2 the large value of the capacitance allows them to pass very low fre>uencies. The electrolytic capacitor was invented in 188F by %harles /ollack. +t was largely responsible for the development of mains:powered radio receivers( since it permitted the filtering of the "!:F! hert0 power supplied to residences( after it was rectified to power the radio tubes. This was not practical without the small volume and low cost of electrolytic capacitors.

Construction
Aluminum electrolytic capacitors are constructed from two conducting aluminum foils( one of which is coated with an insulating o3ide layer( and a paper spacer soaked in electrolyte. The foil insulated by the o3ide layer is the anode while the li>uid electrolyte and the second foil act as cathode. This stack is then rolled up( fitted with pin connectors and placed in a cylindrical aluminum casing. The two most popular geometries are a3ial leads coming from the center of each circular face of the cylinder( or two radial leads or lugs on one of the circular faces. 6oth of these are shown in the picture

Polarity
+n aluminum electrolytic capacitors( the layer of insulating aluminum o3ide on the surface of the aluminum plate acts as the dielectric( and it is the thinness of this layer that allows for a relatively high capacitance in a small volume. The aluminum o3ide layer can

withstand an electric field strength of the order of 1! $ volts per meter. The combination of high capacitance and high voltage result in high energy density. 7nlike most capacitors( electrolytic capacitors have a voltage polarity re>uirement. The correct polarity is indicated on the packaging by a stripe with minus signs 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 the center layer of dielectric material via electrochemical reduction #see redo reactions'. Without the dielectric material the capacitor will short circuit( and if the short circuit current is e3cessive( then the electrolyte will heat up and either leak or cause the capacitor to e3plode. 8odern capacitors have a safety valve( typically either a scored section of the can( or a specially designed end seal to vent the hot gasAli>uid( but ruptures can still be dramatic. )lectrolytic can withstand a reverse bias for a short period of time( but they will conduct significant current and not act as a very good capacitor. 8ost will survive with no reverse <% bias or with only A% voltage( but circuits should be designed so that there is not a constant reverse bias for any significant amount of time. A constant forward bias is preferable( and will increase the life of the capacitor.

These are the different schematic symbols for electrolytic capacitors. The minus or ? marked side of the physical capacitor is e>uivalent to the node opposite to the plus sign on its symbolic e>uivalent. T",: Take notice of the shape of the symbols and the placement of the positive and negative nodes( because most schematics do not print the H@H( but rely on the symbol itself instead.

noteC caps in metal can have the color mark at the minus side V

/olarity of caps with wiresC


a3ialC the minus wire is connected to the case( the plus wire is isolated. radial M single endedC a vertical color stripe indicates the minus side.

For the polarity of .8< caps see picaC

Electrolyte
The electrolyte is usually boric acid or sodium borate in a>ueous solution together with various sugars or ethylene glycol which are added to retard evaporation. %are should be taken to avoid ingestion of or eye contact with the electrolyte( and any areas of the body where skin contact has occurred should be washed in good time. +t is important to follow safe working practice and to use appropriate protective e>uipment( notably gloves and safety glasses( when working with the electrolyte. .ome very old tantalum electrolytic( often called HWet:slugH( contain the more ha0ardous sulfuric acid( however most of these are no longer in service due to corrosion.

Capacitance
The capacitance value of any capacitor is a measure of the amount of electric charge stored per unit of potential difference between the plates. The basic unit of capacitance is a farad( however this unit has been too large for general use until the invention of the <ouble:layer capacitor( so microfarad( nanofarad and microfarad are more commonly used. These are usually abbreviated to if or of( no and puff 8any conditions determine a capacitorIs value( such as the thickness of the dielectric and the plate area. +n the manufacturing process( electrolytic capacitors are made to conform to a set of preferred numbers. 6y multiplying these base numbers by a power of ten( any practical capacitor value can be achieved( which is suitable for most applications. A standardi0ed set of capacitor base numbers was devised so that the value of any modern electrolytic capacitor could be derived from multiplying one of the modern conventional base numbers 1.7( 1.%( /./( 8.8( ?.> or =.# by a power of ten. Therefore( it is common to find capacitors with values of 1!( 1"( &&( DD( ;L( F8( 1!!( &&!( and so on. 7sing this method( values ranging from !.1 to ;L!! are common in most applications. Ealues are generally in microfarads #WF'. 8ost electrolytic capacitors have a tolerance range of &! B( meaning that the manufacturer is stating that the actual value of the capacitor lies within &! B of its labeled value. .election of the preferred series ensures that any capacitor can be sold as a standard value( within the tolerance.

S"0e# 1a0a1i%&#

8% and 6% series super capacitors #up to D!!! farad capacitance' produced by 8a3well Technologies S ,'r !+,+!"tor)( also known as &tr+ !+,+!"tor) or '&'!tro!5'-"!+& do 2&' &+3'r !+,+!"tor) #)<,%'( are electrochemical capacitors that have an unusually high energy density when compared to common capacitors( typically on the order of thousands of times greater than a high:capacity electrolytic capacitor. For instance( a typical <:cell si0ed electrolytic capacitor will have a storage capacity measured in microfarads( while the same si0e super capacitor would store several farads( an improvement of about 1!(!!! times. ,arger commercial super capacitors have capacities as high as "(!!! farads. .uper capacitors have a variety of commercial applications( notably in Henergy smoothingH and momentary:load devices. .ome of the earliest uses were motor startup capacitors for large engines in tanks and submarines( and as the cost has fallen they have started to appear on diesel trucks and railroad locomotives. 8ore recently they have become a topic of some interest in the green energy world( where their ability to >uickly soak up energy makes them particularly suitable for regenerative braking applications( whereas batteries have difficulty in this application due to slow charging times. +f the ,)). or )ster devices can be commerciali0ed( they will make an e3cellent replacement for batteries in all:electric cars and plug:in hybrids( as they combine >uick charging( temperature stability and e3cellent safety properties.

Concept
%omparison of construction diagrams of three capacitors. ,eftC HnormalH capacitor( middleC electrolytic( rightC super capacitor

+n a conventional capacitor( energy is stored by the removal of charge carriers( typically electrons( from one metal plate and depositing them on another. This charge separation creates a potential between the two plates( which can be harnessed in an e3ternal 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 conventional dielectric( as such. They are based on a structure that contains an electrical double layer. +n a double layer( the effective thickness of the HdielectricH is e3ceedingly thinXon the order of nanometersXand that( combined with the very large surface area( is responsible for their e3traordinarily high capacitances in practical si0es. +n an electrical double layer( each layer by itself is >uite conductive( but the physics at the interface where the layers are effectively in contact means that no significant 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 be made of matched series:connected individual super capacitors( much like series: connected cells in higher:voltage batteries.

History:
The super capacitor effect was first noticed in 1$"L by Jeneral )lectric engineers e3perimenting with devices using porous carbon electrode. +t was believed that the energy was stored in the carbon pores and it e3hibited He3ceptionally high capacitanceH( although the mechanism was unknown at that time. Jeneral )lectric did not immediately follow up on this work( and it was .tandard 9il of 9hio that eventually developed the modern version of the devices in 1$FF after accidentally re:discovering the effect while working on e3perimental fuel cell designs. Their cell design used two layers of activated charcoal separated by a thin porous insulator. .tandard 9il also failed to commerciali0e their invention( licensing the technology to ?)%( who finally marketed the results as Qsuper capacitorsR in 1$L8( to provide backup power for maintaining computer memory. +n &!!"( the ultra capacitor market was between 7. Y&L& million and Y;!! million( depending on the source. +t is rapidly growing( especially in the automotive sector. 1ecently( all solid state micrometer:scale super capacitors based on advanced supersonic conductors had been recogni0ed as critical electron component of future sub: voltage and deep:sub:voltage nanoelectronics and related technologies #&& nm technological node of %89. and beyond'.

Technology advantages
<ue to the capacitorIs high number of charge:discharge cycles #millions or more compared to &!!U1!!! for most commercially available rechargeable batteries' there were no disposable parts during the whole operating life of the device( which makes the device environmentally friendly. storing energy from other sources for load balancing purposes and then using any e3cess energy to charge the batteries only at opportune times. 9ther advantages of super capacitors compared with rechargeable batteries are e3tremely low internal resistance or ).1( high efficiency #up to $L:$8B'( high output power( e3tremely low heating levels( and improved safety. According to +T. #+nstitute of Transportation .tudies( <avis( %A' test results( the specific power of super capacitors can e3ceed F kWAkg at $"B efficiency The idea of replacing batteries with capacitors in conjunction with novel alternative energy sources became a conceptual umbrella of the Jreen )lectricity #J),' +nitiative( introduced by <r. Ale3ander 6ell.

Transportation applications
%hina is e3perimenting with a new form of electric bus #casabas' that runs without power lines using power stored in large onboard super capacitors( which are >uickly recharged whenever the electric bus stops at any bus stop #under so:called '&'!tr"! -2r'&&+)'( and fully charged in the terminus. A few prototypes were being tested in .hanghai in early &!!". +n &!!F( two commercial bus routes began to use super capacitor buses2 one of them is route 11 in .hanghai. +n &!!1 and &!!&( EAJ( the public transport operator in ?uremberg( Jermany tested a bus which used a diesel:electric drive system with super capacitors. 9ther companies from the public transport manufacturing sector are developing super capacitor technologyC The Transportation .ystems division of .iemens AJ is developing 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 %udgeled is also developing a super capacitor:based energy storage system.

Resistors, capacitors and inductors

1esistor values are always coded in ohms( capacitors in microfarads #pF'( inductors in micro henries #W '( and transformers in volts.

band A is first significant figure of component value band B is the second significant figure band C is the decimal multiplier band D if present( indicates tolerance of value in percent #no color means &!B'

For e3ample( a resistor with bands of yellow, violet, red, and gold will have first digit ; #yellow in table below'( second digit L #violet'( followed by & #red' 0erosC ;(L!! ohms. Jold signifies that the tolerance is Z"B( so the real resistance could lie anywhere between ;(;F" and ;($D" ohms. 1esistors manufactured for military use may also include a fifth band which indicates component failure rate #reliability'2 refer to 8+,: <6*:1$$ for further details. The .tandard )+A %olor %ode Table per )+A:1.:&L$ is as followsC

Co&or 1)t 2+nd /nd 2+nd 8rd 2+nd @- &t",&"'rA ?t5 2+nd @to&'r+n!'A T'-,. Co'11"!"'nt 6lack ! 6rown 1 1ed & ! 1 & D ; " F L 8 $ [1!! [1!1 [1!& [1!D [1!; [1!" [1!F [1!L [1!8 [1!$ [!.1 [!.!1 Z"B #]' Z1!B #*' Z&!B #8' Z!."B #<' Z!.&"B #%' Z!.1B #6' Z!.!"B #A' Z1B #F' Z&B #J' 1!! pap "! pap 1" pap &" pap

9range D \ellow ; Jreen " 6lue F

Eiolet L Jrey 8

White $ Jold .ilver ?one

NoteC red to violet are the colors of the rainbow where red is low energy and violet is higher energy.

7.3 POWER SUPPLY:

CIRCUIT DIAGRAM:
7805
1 % # $

IN4007
2

&D! E A% .7//, ; \ TRANS "! ^

1 100u

1&
1 LED

2 1000u
1f

!R"ER

IN400 7

POWER S.PPLY: To run the electronic gadget at home it is provided by some power supply. The microcontroller used #at8$c"1' re>uires 1&v <.% supply. The <T8F receiver used #mt88L!' re>uires "v <.%. so design of these regulated power supply is also an important part in hardware design. The A.% power supply from mains is taken and regulated using the rectifiers. For design of a regulated power supply components used areC Transformer. <iodes. 1ectifiers. 1egulated +% chips. %apacitive filters. Tr+n) 1or-'r: A transformer is re>uired to couple the mains to the actual power supply circuit. This is re>uired to isolate the mains from the actual regulated power supply circuit and the other part of the kit. This isolation eliminates the dame of the kit to any power supply variations or from a faulty shock.

For a transformer shown belowC C "1 V1 "/ V/

V1 B "/ B n1 V/ "1 n/

D"od'): +n bride rectifier four diodes are used. The specifications of diodes are chosen asC /+E _ input voltage. .i diode is better. /ower dissipation is kept fi3ed with respect to current through the diode. ]unction capacitance need not be considered for fre>uencies `1 k 0.

RECTIFIERS:
1ectification is a process of conversion of A% to <%. ere( the A% of transformer output is given to the rectifier input( which converts it to <% output. 6asically( bridge rectifiers or diodes arranged in bridge called <iode 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

C rr'nt F&o4 "n t5' Br"d*' R'!t"1"'r

For both positive and negative swings of the transformer( there is a forward path through the diode bridge. 6oth 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 as shownbelow( 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 #A%' input into direct current #<%' output( it is known as a bridge rectifier. The diagram describes a diode:bridge design known as a full:wave rectifier or Jraet0 circuit. This design can be used to rectify single phase A% when no transformer center tap is available Bridge Rectifier Circuit:

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:
%apacitive filters are used stabili0ed or perfect regulation of the voltage. The capacitive filters are opted because( they are more efficient. 6ut they are also more costly. <ifferent types of capacitors areC 1. %eramic capacitors. &. )lectrolyte capacitors. D. /aperA8ica capacitors. ;. .ilver capacitors. ". Tantalum capacitors. %eramic( /aperA8ica( .ilver are nonpolari0ed capacitors. )lectrolyte and Tantalum are polari0ed capacitors. For high fre>uency( %eramic capacitors are used. For low fre>uencies( )lectrolyte capacitors are used.

Linear regulated ICs:


,inear regulated +%5s are used for best regulated output. The output from these regulated +%5s is given to microcontroller and <T8F receiver. These linear regulated +%5s are self protective #any accidental shot circuit in the +% is grounded automatically'. L833 series +%s are used for 4@ve5 supply. L$33 series +%s are used for 4:ve5 supply. L833 and L$33 series +%s are fi3ed voltage regulators. ,8 D1L is a variable voltage regulator.

.LN/#782 11'r:
F'+t r'): "!!:mA 1ated %ollector %urrent #.ingle 9utput' igh:Eoltage 9utputs . . . "! E 9utput %lamp <iodes +nputs %ompatible With Earious Types of logic 1elay <river Applications %ompatible with 7,?&8!!A .eries

d')!r",t"on9ord'r"n* "n1or-+t"on: The 7,?&8!DA is a high:voltage( high: current <arlington transistor array. The device consists of eight nun <arlington pairs that feature high:voltage outputs with common: cathode clamp diodes for switching inductive loads. The collector:current rating of each <arlington pair is "!! mA. The <arlington pairs may be connected in parallel for higher current capability. Applications include relay drivers( hammer drivers( lamp drivers( display drivers #,)< and gas discharge'( line drivers( and logic buffers. The 7,?&8!DA has a &.L: kOseries base resistor for each <arlington pair for operation directly with TT, or ":E %89. devices.

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

LOGIC DIAGRAM FOR THE ULN2803buffer

M NEMONICS
A useful mnemonic for remembering the first ten color codes matches the first letter of the color code( by order of increasing magnitude. There are many variationsC

Bad Beer Rots Our Young Guts But Vodka Goes Well Bright Boys Rave Over Young Girls But Veto Getting Wed B. B. R O Y of 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 H6adH in the first mnemonic and H6rightH in the second mnemonic are often replaced with the word H6lackH since black comes before brown in the color code. While the second mnemonic is certainly the most offensive of these( all e3cept the third lack a sobriety that might be desirable( especially in a teaching conte3t. A more staid memory aide uses the fact that the central part of the code follows the color spectrum( without the i for indigo. That is(

Black Brown 1oy J. 6ig Gray White

The most common variation of the mnemonic for the )+A color code generally doesnIt stay posted on this page for long due to its choice of words which is more offensive to many today than when it was originated #mid 1$&!Is'. 1efer to the discussion for details. 6esides the ten colors of the main value code( the tolerance code is often remembered as Hfor Jold or .ilverH appended to the more offensive mnemonic( or HGet Some NowH where ?ow refers to none for &!B. +f it is difficult to recall that black comes before brown in the color code( it may be helpful to use the position of white at the end of the color code as a key to remember that black #and not brown' is at the beginning.

9ther languages have other mnemonics for this color code. A rough translation of the French is H<onIt eat anything or +Ill beat you violently( big animal.H

Examples

From top to bottomC


Jreen:6lue:6lack:6lack:6rown o "F! a Z 1B 1ed:1ed:9range:Jold o &&(!!! a Z "B \ellow:Eiolet:6rown:Jold o ;L! a Z "B 6lue:Jray:6lack:Jold o F8 a Z "B

?oteC The si0es of the resistors depend only on the power they can dissipate( and do not affect their value.

W5+t do r')")tor) doC


1esistors limit current. +n a typical application( a resistor is connected in series with an ,)<C

)nough current flows to make the ,)< light up( but not so much that the ,)< is damaged. ,ater in this %hapter( you will find out how to calculate a suitable value for this resistor. #,)<s are described in detail in %hapter ".' The Ibo3I symbol for a fi3ed resistor is popular in the 7* and )urope. A I0ig:0agI symbol is used in America and ]apanC

1esistors are used with tr+n)d !'r) to make )'n)or ) 2)3)t'-). Transducers are electronic components which convert energy from one form into another( where one of the forms of energy is electrical. A &"*5t d','nd'nt r')")tor( or LDR( is an e3ample of an "n, t tr+n)d !'r. %hanges in the brightness of the light shining onto the surface of the ,<1 result in changes in its resistance. As will be e3plained later( an input transducer is 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 which reflects changes in illumination. 8icrophones and switches are input transducers. O t, t tr+n)d !'r) include loudspeakers( filament lamps and ,)<s. %an you think of other e3amples of transducers of each typeG

-.4 COLOR CODING

ow can the value of a resistor be worked out from the colours of the bandsG )ach color represents a number according to the following schemeC N -2'r ! 1 & D ; " F L 8 $ Co&or black brown red orange yellow green blue violet grey white

The first band on a resistor is interpreted as the F+1.T <+J+T of the resistor value. For the resistor shown below( the first band is yellow( so the first digit is ;C

The second band gives the .)%9?< <+J+T. This is a violet band( making the second digit L. The third band is called the 87,T+/,+)1 and is not interpreted in >uite the same way. The multiplier tells you how many nougats you should write after the digits you already have. A red band tells you to add & nougats. The value of this resistor is therefore ; L ! ! ohms( that is( ; L!! ( or ;.L . Work through this e3ample again to confirm that you understand how to apply the color code given by the first three bands. The remaining band is called the T9,)1A?%) band. This indicates the percentage accuracy of the resistor value. 8ost carbon film resistors have a gold:colored tolerance band( indicating that the actual resistance value is with @ or : "B of the nominal value. 9ther tolerance colours areC To&'r+n!' Z1B Z&B Z"B Z1!B Co&or brown red gold silver

When you want to read off a resistor value( look for the tolerance band( usually gold( and hold the resistor with the tolerance band at its right hand end. 1eading resistor values >uickly and accurately isnIt difficult( but it does take practiceV

8.SOFTWARE DISCRIPTION
2.1 ,EIL MICROVISION
-An IDE for Microcontrollers

Introduction: *eil development tools for the 8!"1 8icrocontroller Architecture support every level of software developer from the professional applications engineer to the student just learning about embedded software development. The industry:standard *eil % %ompilers( 8acro Assemblers( <ebuggers( 1eal:time *ernels( .ingle:board %omputers( and )mulators support all 8!"1 derivatives and help you get your projects completed on schedule The *eil 8!"1 <evelopment Tools are designed to solve the comple3 problems facing embedded software developers.

When starting a new project( simply select the microcontroller you use from the <evice <atabase and the WEision +<) sets all compiler( assembler( linker( and memory options for you. ?umerous e3ample programs are included to help you get started with the most popular embedded 8!"1 devices. The *eil WEision <ebugger accurately simulates on:chip peripherals #+b%( %A?( 7A1T( ./+( +nterrupts( +A9 /orts( AA< %onverter( <AA %onverter( and /W8 8odules' of your 8!"1 device. .imulation helps you understand hardware configurations and avoids time wasted on setup problems. Additionally( with simulation( you can write and test applications before target hardware is available. When you are ready to begin testing your software application with target hardware( use the 89?"1( 89?D$!( 89?A<+( or Flash89?"1 Target 8onitors( the +.<"1 +n:.ystem <ebugger( or the 7,+?* 7.6:]TAJ Adapter to download and test program code on your target system.

The WEisionD +<) is a Windows:based software development platform that combines a robust editor( project manager( and make facility. WEisionD integrates all tools including the % compiler( macro assembler( linkerAlocator( and )- file generator.

WEisionD helps e3pedite the development process of your embedded applications by providing the followingC

Full:featured source code editor( <evice database for configuring the development tool setting( /roject manager for creating and maintaining your projects( +ntegrated make facility for assembling( compiling( and linking your embedded applications( <ialogs for all development tool settings( True integrated source:level <ebugger with high:speed %/7 and peripheral simulator( Advanced J<+ interface for software debugging in the target hardware and for connection to *eil 7,+?*( Flash programming utility for downloading the application program into Flash 198( ,inks to development tools manuals( device datasheets T user5s guides.

The WEisionD +<) offers numerous features and advantages that help you >uickly and successfully develop embedded applications. They are easy to use and are guaranteed to help you achieve your design goals. The DV")"on8 IDE +nd D'2 **'r is the central part of the *eil development tool chain. WEisionD offers a B "&d Mod' and a D'2 * Mod'. +n the WEisionD B "&d Mod' you maintain the project files and generate the application. +n the WEisionD D'2 * Mod' you verify your program either with a powerful %/7 and peripheral simulator or with the K'"& .LINK .SB<JTAG Ad+,t'r #or other AJ<+ drivers' that connect the debugger to the target system. The 7,+?* allows you also to download your application into Flash 198 of your target system.

ABOUT T.E ENVIRONMENT

T5' DV")"on8 )!r''n ,ro("d') 3o 4"t5 + menu bar for command entryE + too& 2+r 45'r' 3o !+n r+,"d&3 )'&'!t !o--+nd 2 tton)E +nd 4"ndo4) 1or )o r!' 1"&')E d"+&o* 2o0')E +nd "n1or-+t"on d"),&+3). DV")"on8 &'t) 3o )"- &t+n'o )&3 o,'n +nd ("'4 - &t",&' )o r!' 1"&').DV")"on8 5+) t4o o,'r+t"n* -od'): B "&d Mod': Allows you to translate all the application files and to generate e3ecutable programs. The features of the 6uild 8ode are described under %reating Applications. D'2 * Mod': /rovides you with a powerful debugger for testing your application. The <ebug 8ode is described in Testing /rograms. +n both operating modes you may use the source editor of WEisionD to modify your source code. The <ebug mode adds additional windows and stores an own screen layout. The following picture shows a typical configuration of WEisionD in the <ebug 8ode. The tabs of the ProF'!t Wor;),+!' give you access toC
o o o o o

F"&') and Gro ,) of the project. %/7 R'*")t'r) during debugging. Tool and project specific on:line Boo;). Te3t T'-,&+t') for often used te3t blocks. F n!t"on in the project for >uick editor navigation.

The tabs of the O t, t W"ndo4 providesC B "&d messages and fast error access2 <ebug Co--+nd inputAoutput console2 F"nd "n F"&') results with >uick file access. The M'-or3 W"ndo4 gives access to the memory areas in display various formats. The W+t!5 G C+&& St+!; W"ndo4 allows you to review and modify program variables and displays the current function call tree. The Wor;),+!' is used for the file editing( disassembly output( and other debug information. The P'r",5'r+& D"+&o*) help you to review the status of the on:chip peripherals in the microcontroller.

2.2 SOFT/ARE DEVELOPMENT CYCLE

ome c WEisionD 9verview c .oftware <evelopment %ycle When you use the *eil WEisionD( the project development cycle is roughly the same as it is for any other software development project. 1. %reate a project( select the target chip from the device database( and configure the tool settings. &. %reate source files in % or assembly. D. 6uild your application with the project manager. ;. %orrect errors in source files. ". Test the linked application. The following block diagram illustrates the complete WEisionD software development cycle. )ach component is described below.

Vision3 IDE
The WEisionD +<) combines project management( a rich:featured editor with interactive error correction( option setup( make facility( and on:line help. 7se WEisionD to create your source files and organi0e them into a project that defines your target application. WEisionD automatically compiles( assembles( and links your embedded application and provides a single focal point for your development efforts.

C Compiler & Macro Assembler


.ource files are created by the WEisionD +<) and are passed to the % or )%@@ %ompiler or 8acro Assembler. The compiler and assembler process source files and create reloadable object files.

Library Manager
The library manager allows you to create object library from the object files created by the compiler and assembler. ,ibraries are specially formatted( ordered program collections of object modules that may be used by the linker at a later time. When the linker processes a library( only those object modules in the library that are necessary to create the program are used.

Linker/Locator
The ,inkerA,ocator creates an e3ecutable program file using the object modules e3tracted from libraries and those created by the compiler and assembler. An e3ecutable program file #also called absolute object module' contains no reloadable code or data. All code and data reside at fi3ed memory locations.

This e3ecutable program file may be usedC


To program an Flash 198 or other memory devices( With the WEisionD <ebugger for simulation and target debugging( With an in:circuit emulator for the program testing.

Vision3 Debugger
The WEisionD symbolic( source:level debugger is ideally suited for fast( reliable program debugging. The debugger includes a high:speed simulator that let you simulate an microcontroller system including on:chip peripherals and e3ternal hardware. The WEisionD <ebugger provides several ways for you to test your programs on real target hardware.

7se the *eil 7,+?* 7.6:]TAJ adapter for Flash downloading and software test of your program via on:chip debugging system like the )mbedded +%) macro cell that is integrated in many A18 devices. 7se the AJ<+ interface to attach use the WEisionD <ebugger front end with your target system using other debuggers like 8onitor( +n:.ystem <ebugger( or )mulator.

At *eil .oftware( we are dedicated to provide you with the best embedded development tools and documentation available. +f you have suggestions or comments regarding any of the on:line manuals accompanying this product( please contact us. +f you think you have discovered a problem with the software( do the following before calling technical support. 1. 1ead the sections in this manual that pertains to the job or task you are trying to accomplish. &. 8ake sure you are using the most current version of the software and utilities. %heck 444.;'"&.!o-9 ,d+t' to make sure that you have the latest software version. D. +solate the problem to determine if it is a problem with the assembler( compiler( linker( debugger( or another development tool. ;. Further isolate software problems by reducing your code to a few lines.

+f you are still e3periencing problems after following these steps( report them to our technical support group. /lease include your product serial number and version number. We prefer that you send the problem via email. +f you contact us by fa3( be sure to include your name and telephone numbers #voice and fa3' where we can reach you. Try to be as detailed as possible when describing the problem you are having. The more descriptive your e3ample( the faster we can find a solution. +f you have a single: page code e3ample demonstrating the problem( please email it to us. +f possible( make

sure that your problem can be duplicated with the WEisionD .imulator. /lease try to avoid sending complete applications or long listings as this slows down our response to you. The WEisionD 7ser +nterface consists of menus( toolbar buttons( keyboard shortcuts( dialog bo3es( and windows that you use as you interact with and manage the various aspects of your embedded project.

The -'n 2+r provides menus for editor operations( project maintenance( development tool option settings( program debugging( e3ternal tool control( window selection and manipulation( and on:line help. The too&2+r 2 tton) allow you to rapidly e3ecute WEisionD commands. A St+t ) B+r provides editor and debugger information. The various toolbars and the status bar can be enabled or disabled from the Eiew 8enu commands. K'32o+rd )5ort! t) offer >uick access to WEisionD commands and may be configured via the menu command )dit U %onfiguration : .hortcut *ey.

The following sections list the WEisionD commands that can be reached by -'n !o--+nd)( too&2+r 2 tton)( and ;'32o+rd )5ort! t). The WEisionD commands are grouped mainly based on the appearance in the menu barC

File 8enu and File %ommands )dit 8enu and )ditor %ommands o 9utlining 8enu o Advanced 8enu o .electing Te3t %ommands Eiew 8enu /roject 8enu and /roject %ommands <ebug 8enu and <ebug %ommands Flash 8enu /eripherals 8enu Tools 8enu .E%. 8enu Window 8enu
Help Menu

CREATING APPLICATIONS
Home Creating Applications This chapter describes the Build Mode of ision! and is grouped into the follo"ing sections# Create a Project# e$plains the steps re%uired to setup a simple application and to generate HE& output.

Project Tar et and !ile "roups# sho"s ho" to create application 'ariants and organi(ed the files that belong to a pro)ect. Tips and Tric#s# pro'ides information about the ad'anced features of the ision! Pro)ect Manager.

CREATE PRO3ECT
Home Creating Applications Create Pro)ect ision! is a standard *indo"s application and started b+ clic,ing on the program icon. About the En'ironment describes 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 create a 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 a simple ision! pro)ect.

PRO3ECT TARGETS AND FILE GROUPS


Home Creating Applications Pro)ect Targets and 1ile 5roups 4+ using different Project Tar ets ision! lets +ou create se'eral programs from a single pro)ect. .ou ma+ need one target for testing and another target for a release 'ersion of +our application. Each target allo"s indi'idual tool settings "ithin the same pro)ect file. !iles "roups let +ou group associated files together in a pro)ect. *e ha'e alread+ used file groups in our e$ample to separate the CP2 related files from other

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 Components allo"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#space sho"s all groups and the related files. 1iles are built and 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 to to to set tool options remo'e the item add files to a group open the file.

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

PRO3ECT COMPONENTS
Home :ialogs Pro)ect .ou ma+ add; delete; or re-arran e the items "ith the list bo$ buttons in Project Tar ets; "roups; and !iles. Pro)ect Targets Sho"s all Project Tar ets in +our pro)ect. Project Tar ets let +ou create se'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

1iles

Sho"s all !ile "roups in +our current pro)ect. !ile "roups let +ou group associated files together in a pro)ect. This is useful for grouping files into functional bloc,s or for identif+ing engineers in +our soft"are team.

Sho"s all files of the selected !ile "roup. Set as Current Target Set the selected Pro)ect Target as the current target. Add 1iles Add files to the selected !ile "roup.

FILE E4TENSIONS
Home Creating Applications Tips and Tric,s 1ile E$tensions The dialog Project $ Components% En&ironment and Boo#s allo"s +ou to set the file e$tension for the 'arious file t+pes of a pro)ect. .ou can enter se'eral e$tensions "hen +ou separate them b+ semi3colon. The file e$tensions are pro)ect specific.

Selecting a Generic Device


2nder the 5eneric section in the de'ice database; +ou "ill find the follo"ing generic de'ices# <8!7 /all <8!= /all <8>7 /all <8>= /all C7?? /all C7?@ /all A-M@ /all ariants0 ariants0 ariants0 ariants0 ariants0 3 Supports CP2s "ith no e$tended instruction set ariants0 3 Supports CP2s "ith an e$tended instruction set ariants0 3 Supports A-M@ based microcontrollers

.ou ma+ select one of these de'ices and then specif+ an+ necessar+ chip options in the in the Options for Tar et $ Tar et dialog. 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=A! 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 C7?? dialogs. Ho"e'er; "e recommend that +ou use the dialog +,ision Options for Tar et $ Tar et to define the memor+ structure of the target hard"are. 6nce +ou ha'e done that; +ou should open the dialog Options for Tar et $ .-// 0 .*1- .ocate. Enable the option 2se Memory .ayout from Tar et and remo'e the settings for 2ser Classes; 2ser Se ments; or 2ser Sections in this dialog. >. Chec, carefull+ if all settings are copied correctl+ to the ne" ision pro)ect file. ?. .ou ma+ no" create file groups in the ne" ision pro)ect. Then +ou can :rag D :rop files into the ne" file groups.

De3u

in

Home :ebugging This chapter describes the De3u Mode of ision! and sho"s +ou ho" to use the user 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 Tar et $ De3u dialog.

2se Simulator configures the ision! :ebugger as software-only product that simulates most features of a microcontroller "ithout actuall+ ha'ing target hard"are. .ou can test and debug +our embedded application before the hard"are is read+. ision! simulates a "ide 'ariet+ of peripherals

including the serial port; e$ternal 9A6; and timers. The peripheral set is selected "hen +ou select a CP2 from the de'ice database for +our target. 2se Ad'anced 5:9 dri'ers; li,e the 2.IN4 De3u er to interface to +our target 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 on man+ e'aluation boards. o Emulator# "hich connects to the CP2 pins of the target hard"are. o In-System De3u er# "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 Pro rammin


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 Eeil 2C9NE 2S43FTA5 Adapter. The 1lash Programming 2tilities are configured under Project - Options - 2tilities. 1lash Programming ma+ be started from the !las8 Menu or before starting the ision! :ebugger "hen +ou enable Project - Options - 2tilities - 2pdate Tar et 3efore De3u in .

Measure - Project !ile


Home E$ample Programs Measure# A -emote Measurement S+stem Measure 3 Pro)ect 1ile The pro)ect file for the MEAS2-E sample program is called Measure'2,9. To load this pro)ect file; use Open Project from the Project menu and select Measure'2,9 in the folder ''':A;M:''':E*amples:Measure.

The 1iles page in the Pro)ect *or,space sho"s the source files that compose the MEAS2-E pro)ect. The three application related source files that are located in the Source !iles group. The function of the source files is described belo". To open a source file; double3clic, on the filename.

Measure<s# contains the main C function for the measurement s+stem and the interrupt routine for timer 8. The main function initiali(es all peripherals of the A-M and performs command processing for the s+stem. The timer interrupt routine; timer8; manages the real3time cloc, and the measurement sampling of the s+stem. MCommand'C# processes the displa+; time; and inter'al commands. These functions are called from main. The displa+ command lists the analog 'alues in floating3point format to gi'e a 'oltage bet"een 8.88 and >.88 . "et.ine'C# contains the command3line editor for characters recei'ed from the serial port. 9-G.S# is an interface module for the interrupt ser'ice routine.

Compilin

and .in#in

Measure

Home E$ample Programs Measure# A -emote Measurement S+stem Compiling and Cin,ing Measure *hen +ou are read+ to compile and lin, the MEAS2-E pro)ect; use the Build Tar et command from the Pro)ect menu or the toolbar. ision! begins to compile and lin, the source files in MEAS2-E and displa+s a message "hen the build is finished. 6nce the pro)ect is built; +ou are read+ to bro"se the s+mbol information or begin testing.

Testin

Measure

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

The MEAS2-E sample program is designed to accept commands from the on3 chip serial port. 9f +ou ha'e actual target hard"are; +ou can use a terminal simulation to communicate "ith the A-M CP2. 9f +ou do not ha'e target hard"are; +ou can use ision! to simulate the hard"are. .ou can also use the serial "indo" in ision! to pro'ide serial input. 6nce the MEAS2-E program is build; +ou can test it. 2se the Start0Stop De3u Session command from the De3u menu to start the ision! debugger.

emote Measurement System Comman!s


The serial commands that MEAS2-E supports are listed in the follo"ing table. These commands are composed of ASC99 te$t characters. CommandSerial Te*t Description Clear C Clears the measurement record buffer. :ispla+ : :ispla+s the current time and input 'alues. T Time Sets the current time in =B3hour format. hh:mm:ss Sets the inter'al time for the measurement samples. The 9nter'al 9 mm:ss.ttt inter'al time must be bet"een 8#88.887 /for 7ms0 and ?8#88.888 /for ?8 minutes0. Starts the measurement recording. After recei'ing the start Start S command; MEAS2-E samples all data inputs at the specified inter'al. :ispla+s the recorded measurements. .ou ma+ specif+ the number of most recent samples to displa+ "ith the read command. 9f no count is specified; the read command -ead - HcountI transmits all recorded measurements. .ou can read measurements on the fl+ if the inter'al time is more than 7 second. 6ther"ise; the recording must be stopped. Guit G Guits the measurement recording.

,ie7 Pro ram Code


Home E$ample Programs Measure# A -emote Measurement S+stem Program Code ie"

ision! lets +ou 'ie" the program code in the :isassembl+ *indo" that opens "ith the ie" menu or the toolbar button. The :isassembl+ *indo" sho"s intermi$ed source and assembl+ lines. .ou ma+ change the 'ie" mode or use other commands from the local menu that opens "ith the right mouse button.

,ie7 Memory Contents


Home E$ample Programs Measure# A -emote Measurement S+stem Memor+ Contents ie"

ision! displa+s memor+ in 'arious formats. The Memor+ *indo" opens 'ia the ie" menu or the toolbar button. .ou can enter the address of four different memor+ areas in the pages. The local menu allo"s +ou to modif+ the memor+ contents or select different output formats.

Pro ram 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 ,ie7 menu or the De3u toolbar. .ou ma+ disable other "indo"s if +our screen is not large enough. .ou can use the Step toolbar buttons on assembler instructions or source code 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 (indo7 sho"s the current function nesting. A double clic, 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

ision! also supports comple$ brea,points as discussed on page 78J. .ou ma+ "ant to halt program e$ecution "hen a 'ariable contains a certain 'alue. The e$ample sho"s ho" to stop "hen the 'alue ! is "ritten to current'time'sec. 6pen the Brea#points dialog from the De3u menu. Enter as e$pression current'time'sec>>?. Select the *rite chec, bo$ /this option specifies that the brea, condition is tested onl+ "hen the e$pression is "ritten to0. Clic, on the :efine button to set the brea,point. To test the brea,point condition perform the follo"ing steps# Sym3ol -eset CP2. 9f program e$ecution is halted begin e$ecuting the MEAS2-E program. After a fe" seconds; ision! halts e$ecution. The program counter line in the debug "indo" mar,s the line in "hich the brea,point occurred. Description

2sin

Perip8eral Dialo

Bo*es

ision! pro'ides dialogs for# 9A6 Ports; 9nterrupts; Timers; AA: Con'erter; Serial Ports; and chip3specific peripherals. These dialogs can be opened from the :ebug menu. 1or the MEAS2-E application +ou ma+ open 9A6 Ports#Port= and AA: Con'erter. Each of these dialogs lists the related S1- s+mbols and sho"s the current status of the peripherals. To change the inputs; change the 'alues of the Pins or Analog 9nput Channels.

2sin

,T;E" Sym3ols

In t8e Command pa e of t8e 6utput *indo"% you may ma#e assi nments to t8e ,T;E" sym3ols just li#e &aria3les and re isters' !or e*ample@ PORT2=0xDA00 set digital input PORT2 to 0xDA00 AIN1=! ! set analog input AIN1 to ! ! "olts

2sin

.ou ma+ combine the use of T-E5 s+mbols defined b+ the CP2 dri'er and ision! user and signal functions to create a sophisticated method of pro'iding e$ternal input to +our target programs. The Analog E$ample sho"s a signal function that pro'ides input to A9N8.

2ser and Si nal !unctions

5.CODING

Pro*r+- 4r"tt'n "n C &+n* +*'


dinclude`stdio.h_ dinclude`reg"1.h_ void delay#into'2 void medley#void'2 sit sen1M/1e!2 sit sen&M/1e12 sit bu00M/1eD2 sit sig1M/1e;2 sit sig&M/1e"2 sit laserM/1 eF2 void close#'2 void open#'2 void bu00er#'2 into mM1!!!!2 void main#' f /!M/&M/DM!3!!2 /1M!3ff2 bu00er#'2 sig1M!3!!2 AAtrain stopAroad go sig&M!3!12 open#'2 for#22' f if#sen1MM!3!!' f sig1M!3!12 sig&M!3!!2 AAtrain goAroad stop bu00er#'2 close#'2 medley#'2 while#sen&MM!3!1'fg while#sen&MM!3!!'fg sig1M!3!!2 sig&M!3!12 AAtrain stopAroad go bu00er#'2 open#'2 g if#sen&MM!3!!' f sig1M!3!12 sig&M!3!!2 AAtrain goAroad stop bu00er#'2 close#'2 medley#'2 while#sen1MM!3!1'fg while#sen1MM!3!!'fg

sig1M!3!!2 sig&M!3!12 AAtrain stopAroad go bu00er#'2 open#'2 g g g void medley#void' f into lM!2 for#lM!2l`M&!!2l@@' f T89<M!31!2 T,1M!3fe2 T 1M!3a"2 T11M12 while#TF1MM!' f if#laserMM!3!!' f sig1M!3!!2 sig&M!3!12 AAtrain stopAroad go bu00er#'2 open#'2 while#laserMM!3!!'fg sig1M!3!12 sig&M!3!!2 AAtrain goAroad stop bu00er#'2 close#'2 g g T11M!2 TF1M!2 g g void bu00er#' f into y2 for#yM!2y`M82y@@' f bu00M!3!12deley#1"!!!'2 bu00M!3!!2deley#1"!!!'2 g g void open#' f /&M!3112deley#m'2 /&M!3DD2deley#m'2

/&M!3&&2deley#m'2 /&M!3FF2deley#m'2 /&M!3;;2deley#m'2 /&M!3cc2deley#m'2 /&M!3882deley#m'2 /&M!3$$2deley#m'2 /&M!3112deley#m'2 /&M!3DD2deley#m'2 /&M!3&&2deley#m'2 /&M!3FF2deley#m'2 /&M!3;;2deley#m'2 /&M!3cc2deley#m'2 /&M!3882deley#m'2 /&M!3$$2deley#m'2 g void close#' f /&M!3$$2deley#m'2 /&M!3882deley#m'2 /&M!3cc2deley#m'2 /&M!3;;2deley#m'2 /&M!3FF2deley#m'2 /&M!3&&2deley#m'2 /&M!3DD2deley#m'2 /&M!3112deley#m'2 /&M!3$$2deley#m'2 /&M!3882deley#m'2 /&M!3cc2deley#m'2 /&M!3;;2deley#m'2 /&M!3FF2deley#m'2 /&M!3&&2deley#m'2 /&M!3DD2deley#m'2 /&M!3112deley#m'2 g void delay#k' f into iM!2 for#iM!2i`Mkid@@'fg g

PROGRAM .E4 CODE*

C!;!&&)!!!&!%&L1!8L C1!!1;6!!);F"6!F"A!F"8!L"$!FF1&!1);%&$;<&)) C1!!1"6!!$"1&!!8F&!$!1$1&!1)!1&!!)<1&!1$$FL C1!!1F6!!&!$1F<D!$1F<%&$;<&$"1&!1);1&!!8F%D C1!!1L6!!&!$1)11&!1)!1&!!)<1&!1$$&!$!F<D!FL C!)!186!!$!F<%&$;<&$"1&!1);1&!!8F8!%FD) C1!!1$$!!);F"!8F"!$F"!8F"!$L"8$1!L"86F)L"F6 C1!!1A$!!8<A"<&8)&!8F18&!$FFA%&$;<&$"1&!1F< C1!!16$!!);1&!!8FD!$FF<1&!1)!1&!!)<8!)"%&<" C1!!1%$!!8)%&8F!"!$)"!$L!!&!"!8<D$;%8)"!86! C!F!1<$!!F;8!$;8!;!%D&" C!1!1<F!!&&F< C!;!1)!!!<&$;%&$"") C1!!1);!!);F"!AF"!6<&$DLF$8L)DA1&!&1F%&$DL" C1!!1F;!!LF$8L)DA1&!&1F!"!6)"!6L!!&!"!A<DA) C!A!&!;!!$;!8)"!AF;8!$;8!;!<6"& C!1!&!)!!&&%< C1!!!8F!!L"A!111&!&1&1&!&!FL"A!&&1&!&1&L"&! C1!!!$F!!A!FF1&!&1&L"A!;;1&!&1&L"A!%%1&!&61 C1!!!AF!!1&L"A!881&!&1&L"A!$$1&!&1&L"A!11L& C1!!!6F!!1&!&1&1&!&!FL"A!&&1&!&1&L"A!FF1&F) C1!!!%F!!!&1&L"A!;;1&!&1&L"A!%%1&!&1&L"A!L& C!)!!<F!!881&!&1&L"A!$$AF!<A)!%!&!&1F&L C1!!!)<!!L"A!$$1&!&1&L"A!881&!&1&L"A!%%1&L$ C1!!!F<!!!&1&L"A!;;1&!&1&L"A!FF1&!&1&L"A!AA C1!!1!<!!&&1&!&1&1&!&!FL"A!111&!&1&L"A!$$L< C1!!11<!!1&!&1&L"A!881&!&1&L"A!%%1&!&1&L"F< C1!!1&<!!A!;;1&!&1&L"A!FF1&!&1&L"A!&&1&!&%% C!)!1D<!!1&1&!&!FL"A!11AF!<A)!%!&!&1F%$ C!L!&!F!!L"A!DDAF!<A)!%&A C1!!&1F!!);F<F%<D)<$F))F;8!F8)%F;8!$8"!!L1D C!L!&&F!!!<6<!!!1!%8!)%8) C!1!&&<!!&&A) C!D!!!!!!!&!!!DF8 C!%!!!D!!L8LF);FF<8F<L"81!<!&!!;AF% C1!!!!F!!!&!1;6);$DADF8);$DAD;!!DFF8!!1F&66 C1!!!1F!!!8<FF;8!&$);$DADF8";!L&;!%%8%DDDF& C1!!!&F!!%;";!F;;&!%88D;!!;F;"F8!!1;FFF<F%1 C1!!!DF!!);8!!6!1!&!;!81!&!;!8!$!!&&));L)&1 C1!!!;F!!!1$DF!6%ADFF";DFD!)"!$";1FF));$D6F C1!!!"F!!ADF!!1!)%F";%!&")!F!A8;!68);$DADL< C1!!!FF!!FA);$DADF8);$DAD%8%"8&%8%A%"8D%AA8 C1!!!LF!!F!AD%8%"8&%8%A%"8D%A<F)$<))L8!6)F! C!1!&D&!!!!%6 C!!!!!!!1FF

17. CONCL.SIONS :

ence the 7nmanned railway gates operate according to the data input from sensors to microcontroller. First an alarm is triggered and then the gate is operated. S,'!"1"!+t"on): 8echanical gate arrangement Atmel 8$%"1 an 8!"1 family microcontroller .?L;!; for microcontroller interfacing. +1 sensors for sensing train .tepper motor to operate gates 7,? &8!D for driving .tepper motor

11. BIBLIOGRAPHY N+-' o1 t5' )"t'):


1. www.mitel.data oo!.com
&. www.atmel.data oo!.com D. www."ran!lin.com

#. www.!eil.com

R'1'r'n!'):

www.8!"&.comAtutorial.phtml 8!"1 microcontroller by *enneth ]. Ayala


www.electronics'oru.com(electronics'oru(articles(hits.asp)id*1+,1

Programming Embedded .ystemsC With C and J?7 <evelopment Tools


by Michael Barr 6asic electronics 6yC J196 /ractical transistor circuit design and analysis 6yC J)1A,< ). W+,,+A8. .ensor : )lectronic circuit guide book U Eolume U 1 6yC ]9.)/ ].%A11
/rogramming and %ustomi0ing the 8!"1 8icro:controller 6yC 8ike /rado The concepts and Features of 8icro:controllers : 6yC 1aj *amala

The $0%1 "icro-controller Architecture. pro/rammin/ 0 Applications 1y2 3enneth 4. Ayala


%89.ATT, +% <ata 8anuals

Das könnte Ihnen auch gefallen