line following robot


Published on

Published in: Education

line following robot

  1. 1. CHAPTER 1 INTRODUCTION1.1 INTRODUCTION TO LINE FOLLING ROBOTA line follower robot is basically a robot designed to follow a ‘line’ or path alreadypredetermined by the user. This line or path may be as simple as a physical white line onthe floor or as complex path marking schemes e.g. embedded lines, magnetic markers andlaser guide markers. In order to detect these specific markers or ‘lines’, various sensingschemes can be employed. These schemes may vary from simple low cost line sensingcircuit to expansive vision systems. The choice of these schemes would be dependentupon the sensing accuracy and flexibility required. From the industrial point of view, linefollowing robot has been implemented in semi to fully autonomous plants. In thisenvironment, these robots functions as materials carrier to deliver products from onemanufacturing point to another where rail, conveyor and gantry solutions are notpossible. Apart from line following capabilities, these robots should also have thecapability to navigate junctions and decide on which junction to turn and which junctionignore. This would require the robot to have 90 degree turn and also junction countingcapabilities. To add on to the complexity of the problem, sensor positioning also plays arole in optimizing the robots performance for the tasks mentioned earlier.Line-following robots with pick- and- placement capabilities are commonly used inmanufacturing plants. These move on a specified path to pick the components fromspecified locations and place them on desired locations. Basically, a line-following robotis a self-operating robot that detects and follows a line drawn on the floor. The path to betaken is indicated by a white line on a black surface. The control system used must sensethe line and man oeuvre the robot to stay on course while constantly correcting the wrongmoves using feedback mechanism, thus forming a simple yet effective closed- loopsystem. 1
  2. 2. ADVANTAGES• Robot movement is automatic.• Fit and Forget system.• Used for long distance applications.• Defense applications.• Used in home, industrial automation.• Cost effective.• Simplicity of building.DISADVANTAGES• Line following robot follows a black line about 1 or 2 inches in width on a whitesurface.• Line tracing robots are simple robots with an additional sensors placed on them.• It always needs a path to run either white or black since the IR rays should reflectfrom the particular path.• Slow speed and instability on different line thickness or hard angles.APPLICATIONS: • Guidance system for industrial robots moving on shop floor etc. • Industrial applications. • Home applications. 2
  3. 3. 1.2 BLOCK DIAGRAM: Power Supply Unit Photo Sensor Array Crystal AT89S52 Microcontroller Reset circuit H-Bridge To all sections 12 V Lead Acid Left Right Moto Motor Battery r Fig.1.2 Block diagram of line follower 3
  4. 4. 1.3 INTRODUCTION TO EMBEDDED SYSTEMSAn embedded system is a system which is going to do a predefined specified task is theembedded system and is even defined as combination of both software and hardware. Ageneral-purpose definition of embedded systems is that they are devices used to control,monitor or assist the operation of equipment, machinery or plant. "Embedded" reflectsthe fact that they are an integral part of the system. At the other extreme a general-purpose computer may be used to control the operation of a large complex processingplant, and its presence will be obvious.All embedded systems are including computers or microprocessors. Some of thesecomputers are however very simple systems as compared with a personal computer.The simplest devices consist of a single microprocessor (often called a "chip”), whichmay itself be packaged with other chips in a hybrid system or Application SpecificIntegrated Circuit (ASIC). Its input comes from a detector or sensor and its output goes toa switch or activator which (for example) may start or stop the operation of a machine or,by operating a valve, may control the flow of fuel to an engine.As the embedded system is the combination of both software and hardware Embedded System Software Hardware ALP Processor C Peripherals VB memory Etc., Figure:1.3 Block diagram of Embedded System 4
  5. 5. Software deals with the languages like ALP, C, and VB etc., and Hardware deals withProcessors, Peripherals, and Memory.Memory: It is used to store data or address.Peripherals: These are the external devices connectedProcessor: It is an IC which is used to perform some taskApplications of embedded systems • Manufacturing and process control • Construction industry • Transport • Buildings and premises • Domestic service • Communications • Office systems and mobile equipment • Banking, finance and commercial • Medical diagnostics, monitoring and life support • Testing, monitoring and diagnostic systems 5
  6. 6. CHAPTER:2 HARDWARE EXPLANATION2.1 BASIC HARDWARE2.1.1 BLOCK DIAGRAM FOR REGULATED POWER SUPPLY (RPS): Fig:2.1 Power Supply2.1.2 DESCRIPTION OF TRANSFORMERA transformer is a device that transfers electrical energy from one circuit to anotherthrough inductively coupled conductors—the transformers coils. A varying current in thefirst or primary winding creates a varying magnetic flux in the transformers core, andthus a varying magnetic field through the secondary winding. This varying magnetic fieldinduces a varying electromotive force (EMF) or "voltage" in the secondary winding. Thiseffect is called mutual induction. Basic Principle 6
  7. 7. A transformer makes use of Faradays law and the ferromagnetic properties of an ironcore to efficiently raise or lower AC voltages. It of course cannot increase power so thatif the voltage is raised, the current is proportionally lowered and vice versa. transformer consists of two coils (often called windings) linked by an iron core, asshown in figure below. There is no electrical connection between the coils; instead theyare linked by a magnetic field created in the core. Fig:2.2.2 Basic TransformerTransformers are used to convert electricity from one voltage to another with minimalloss of power. They only work with AC (alternating current) because they require achanging magnetic field to be created in their core. Transformers can increase voltage(step-up) as well as reduce voltage (step-down).Alternating current flowing in the primary (input) coil creates a continually changingmagnetic field in the iron core. This field also passes through the secondary (output) coiland the changing strength of the magnetic field induces an alternating voltage in thesecondary coil. If the secondary coil is connected to a load the induced voltage will make 7
  8. 8. an induced current flow. The correct term for the induced voltage is inducedelectromotive force which is usually abbreviated to induced e.m.f.The iron core is laminated to prevent eddy currents flowing in the core. These arecurrents produced by the alternating magnetic field inducing a small voltage in the core,just like that induced in the secondary coil. Eddy currents waste power by needlesslyheating up the core but they are reduced to a negligible amount by laminating the ironbecause this increases the electrical resistance of the core without affecting its magneticproperties. Transformers have two great advantages over other methods of changingvoltage: 1. They provide total electrical isolation between the input and output, so they can be safely used to reduce the high voltage of the mains supply. 2. Almost no power is wasted in a transformer. They have a high efficiency (power out / power in) of 95% or more. Classification of Transformer  Step-Up Transformer  Step-Down Transformer2.1.3 Rectifier The purpose of a rectifier is to convert an AC waveform into a DC waveform(OR) Rectifier converts AC current or voltages into DC current or voltage. There are twodifferent rectification circuits, known as half-wave and full-wave rectifiers. Both usecomponents called diodes to convert AC into DC. 8
  9. 9. The Half-wave RectifierThe half-wave rectifier is the simplest type of rectifier since it only uses one diode, asshown in figure. Fig:2.3.1(a) Half Wave RectifierWhile the output of the half-wave rectifier is DC (it is all positive), it would not besuitable as a power supply for a circuit. Firstly, the output voltage continually variesbetween 0V and Vs-0.7V, and secondly, for half the time there is no output at all. The Full-wave RectifierThe circuit in figure addresses the second of these problems since at no time is the outputvoltage 0V. This time four diodes are arranged so that both the positive and negativeparts of the AC waveform are converted to DC. Fig:2.3.2(a) Full-Wave Rectifier 9
  10. 10. When the AC input is positive, diodes A and B are forward-biased, while diodes C and Dare reverse-biased. When the AC input is negative, the opposite is true - diodes C and Dare forward-biased, while diodes A and B are reverse-biased.While the full-wave rectifier is an improvement on the half-wave rectifier, its output stillisnt suitable as a power supply for most circuits since the output voltage still variesbetween 0V and Vs-1.4V. So, if you put 12V AC in, you will 10.6V DC out.2.1.4 Capacitor FilterThe capacitor-input filter, also called "Pi" filter due to its shape that looks like theGreek letter pi, is a type of electronic filter. Filter circuits are used to remove unwanted orundesired frequencies from a signal. Fig:2.4(a) Capacitor FilterA typical capacitor input filter consists of a filter capacitor C1, connected across therectifier output, an inductor L, in series and another filter capacitor connected across theload. 1. The capacitor C1 offers low reactance to the AC component of the rectifier output while it offers infinite reactance to the DC component. As a result the capacitor shunts an appreciable amount of the AC component while the DC component continues its journey to the inductor L 10
  11. 11. 2. The inductor L offers high reactance to the AC component but it offers almost zero reactance to the DC component. As a result the DC component flows through the inductor while the AC component is blocked. 3. The capacitor C2 bypasses the AC component which the inductor had failed to block. As a result only the DC component appears across the load RL.2.1.5Voltage Regulator A voltage regulator is an electrical regulator designed to automatically maintain aconstant voltage level. It may use an electromechanical mechanism, or passive or activeelectronic components. Depending on the design, it may be used to regulate one or moreAC or DC voltages. There are two types of regulator are they.  Positive Voltage Series (78xx) and  Negative Voltage Series (79xx)78xx: ’78’ indicate the positive series and ‘xx’indicates the voltage rating. Suppose 7805produces the maximum 5V.’05’indicates the regulator output is 5V.79xx: ’78’ indicate the negative series and ‘xx’indicates the voltage rating. Suppose 7905produces the maximum -5V.’05’indicates the regulator output is -5V.These regulators consists the three pins there arePin1: It is used for input pin.Pin2: This is ground pin for regulatorPin3: It is used for output pin. Through this pin we get the output. 11
  12. 12. Fig:2.5 Regulator2.1.6 SWITCH INTERFACING: CPU accesses the switches through ports. Therefore these switches are connectedto a microcontroller. This switch is connected between the supply and ground terminals.A single microcontroller (consisting of a microprocessor, RAM and EEPROM andseveral ports all on a single chip) takes care of hardware and software interfacing of theswitch. These switches are connected to an input port. When no switch is pressed, readingthe input port will yield 1s since they are all connected to high (Vcc). But if any switch ispressed, one of the input port pins will have 0 since the switch pressed provides the pathto ground. It is the function of the microcontroller to scan the switches continuously todetect and identify the switch pressed. The switches that we are using in our project are 4 leg micro switches ofmomentary type. Vcc R P2.0 12
  13. 13. Gnd Fig:2.6 Interfacing switch with the microcontroller By reading the pin status, the microcontroller identifies whether the switch ispressed or not. When the switch is pressed, the corresponding related to this switch presswritten in the program will be executed.2.2 AT89S52 MICROCONTROLLERS: The AT89S52 is a low-power, high-performance CMOS 8-bit microcontrollerwith 8K bytes of in-system programmable Flash memory. The device is manufacturedusing Atmel’s high-density nonvolatile memory technology and is compatible with theindustry- standard 80C51 instruction set and pinout. The on-chip Flash allows theprogram memory to be reprogrammed in-system or by a conventional nonvolatilememory programmer. By combining a versatile 8-bit CPU with in-system programmableFlash on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller whichprovides a highly-flexible and cost-effective solution to many embedded controlapplications.2.2.1 Standard Features • 8K bytes of Flash, • 256 bytes of RAM, • 32 I/O lines, • Watchdog timer, • two data pointers, • three 16-bit timer/counters, • a six-vector two-level interrupt architecture, • a full duplex serial port, on-chip oscillator, and • clock circuitry. 13
  14. 14. In addition, the AT89S52 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serialport, and interrupt system to continue functioning. The Power-down mode saves theRAM contents but freezes the oscillator, disabling all other chip functions until the nextinterrupt or hardware reset.2.2.2 PIN CONFIGURATIONS 14
  15. 15. 15
  16. 16. Fig:3.3 block diagram of microcontroller2.2.2.1 PIN DESCRIPTIONVCC 16
  17. 17. Supply voltage.GNDGround.Port 0Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can sinkeight TTL inputs. When 1s are written to port 0 pins, the pins can be used as highimpedance inputs. Port 0 can also be configured to be the multiplexed low orderaddress/data bus during accesses to external program and data memory. In this mode, P0has internal pullups. Port 0 also receives the code bytes during Flash programming andoutputs the code bytes during program verification. External pullups are required duringprogram verification.Port 1Port 1 is an 8-bit bidirectional I/O port with internal pullups. The Port 1 output bufferscan sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled highby the internal pullups and can be used as inputs. As inputs, Port 1 pins that are externallybeing pulled low will source current (IIL) because of the internal pullups. In addition,P1.0 and P1.1 can be configured to be the timer/counter 2 external count input (P1.0/T2)and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown in thefollowing table. Port 1 also receives the low-order address bytes during Flashprogramming and verification. 17
  18. 18. Table:3.3.1(a) port 1 alternate pin functionsPort 2Port 2 is an 8-bit bidirectional I/O port with internal pullups. The Port 2 output bufferscan sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled highby the internal pullups and can be used as inputs. As inputs, Port 2 pins that are externallybeing pulled low will source current (IIL) because of the internal pullups. Port 2 emits thehigh-order address byte during fetches from external program memory and duringaccesses to external data memory that use 16-bit addresses (MOVX @ DPTR). In thisapplication, Port 2 uses strong internal pull-ups when emitting 1s. During accesses toexternal data memory that use 8-bit addresses (MOVX @ RI), Port 2 emits the contentsof the P2 Special Function Register. Port 2 also receives the high-order address bits andsome control signals during Flash programming and verification.Port 3Port 3 is an 8-bit bidirectional I/O port with internal pullups. The Port 3 output bufferscan sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled highby the internal pullups and can be used as inputs. As inputs, Port 3 pins that are externallybeing pulled low will source current (IIL) because of the pullups. Port 3 also serves thefunctions of various special features of the AT89S52, as shown in the following table.Port 3 also receives some control signals for Flash programming and verification. 18
  19. 19. Table:3.3.1(b) port 3 alternate functionsRSTReset input. A high on this pin for two machine cycles while the oscillator is runningresets the device. This pin drives High for 96 oscillator periods after the Watchdog timesout. The DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. Inthe default state of bit DISRTO, the RESET HIGH out feature is enabled.ALE/PROGAddress Latch Enable (ALE) is an output pulse for latching the low byte of the addressduring accesses to external memory. This pin is also the program pulse input (PROG)during Flash programming. In normal operation, ALE is emitted at a constant rate of 1/6the oscillator frequency and may be used for external timing or clocking purposes. Note,however, that one ALE pulse is skipped during each access to external data memory. Ifdesired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bitset, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin isweakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is inexternal execution mode. 19
  20. 20. PSENProgram Store Enable (PSEN) is the read strobe to external program memory. When theAT89S52 is executing code from external program memory, PSEN is activated twiceeach machine cycle, except that two PSEN activations are skipped during each access toexternal data memory.EA/VPPExternal Access Enable. EA must be strapped to GND in order to enable the device tofetch code from external program memory locations starting at 0000H up to FFFFH.Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset.EA should be strapped to VCC for internal program executions. This pin also receives the12-volt programming enable voltage (VPP) during Flash programming.XTAL1Input to the inverting oscillator amplifier and input to the internal clock operating circuit.XTAL2Output from the inverting oscillator amplifier.2.2.3 MEMORY ORGANIZATIONThe microcontroller memory is divided into Program Memory and Data Memory.Program Memory (ROM) is used for permanent saving program being executed, whileData Memory (RAM) is used for temporarily storing and keeping intermediate resultsand variables. Depending on the model in use (still referring to the whole 8052microcontroller family) at most a few Kb of ROM and 128 or 256 bytes of RAM can beused. However all 8052 microcontrollers have 16-bit addressing bus and can address 64kb memory. It is neither a mistake nor a big ambition of engineers who were working onbasic core development. It is a matter of very clever memory organization which makesthese controllers a real “programmers’ tidbit“. Program MemoryThe oldest models of the 8052 microcontroller family did not have any internal programmemory. It was added from outside as a separate chip. These models are recognizable bytheir label beginning with 803 (for ex. 8031 or 8032). All later models have a few KbytesROM embedded, Even though it is enough for writing most of the programs, there are 20
  21. 21. situations when additional memory is necessary. A typical example of it is the use of socalled lookup tables. They are used in cases when something is too complicated or whenthere is no time for solving equations describing some process. The example of it can betotally exotic or totally common. In those cases all needed estimates and approximatesare executed in advance and the final results are put in the tables (similar to logarithmictables).EA=0 In this case, internal program memory is completely ignored, only a programstored in external memory is to be executed.EA=1 In this case, a program from built-in ROM is to be executed first (to the lastlocation). Afterwards, the execution is continued by reading additional memory.In both cases, P0 and P2 are not available to the user because they are used for data andaddress transmission. Besides, the pins ALE and PSEN are used too. Data MemoryData Memory is used for temporarily storing and keeping data and intermediate resultscreated and used during microcontroller’s operating. Besides, this microcontroller familyincludes many other registers such as: hardware counters and timers, input/output ports,serial data buffers etc. The previous versions have the total memory size of 256 locations,while for later models this number is incremented by additional 128 available registers. Inboth cases, these first 256 memory locations (addresses 0-FFh) are the base of thememory Common to all types of the 8052 microcontrollers. Locations available to theuser occupy memory space with addresses from 0 to 7Fh. First 128 registers and this partof RAM are divided in several blocks.The first block consists of 4 banks each including 8 registers designated as R0 to R7.Prior to access them, a bank containing that register must be selected. Next memoryblock (in the range of 20h to 2Fh) is bit- addressable, which means that each bit beingthere has its own address from 0 to 7Fh. Since there are 16 such registers, this blockcontains in total of 128 bits with separate addresses (The 0th bit of the 20h byte has thebit address 0 and the 7th bit of the 2Fh byte has the bit address 7Fh). The third groups of 21
  22. 22. registers occupy addresses 2Fh-7Fh (in total of 80 locations) and does not have anyspecial purpose or feature.In case on-chip memory is not enough, it is possible to add two external memory chipswith capacity of 64Kb each. I/O ports P2 and P3 are used for their addressing and datatransmission.Similar occurs when it is a needed to read some location from external Data Memory.Addressing is performed in the same way, while reading or writing is performed viasignals which appear on the control outputs RD or WR. 22
  23. 23. Fig:3.4.2(b) memory organisation 23
  24. 24. 2.2.4 AddressingWhile operating, processor processes data according to the program instructions. Eachinstruction consists of two parts. One part describes what should be done and another partindicates what to use to do it. This later part can be data (binary number) or addresswhere the data is stored. All 8052 microcontrollers use two ways of addressing dependingon which part of memory should be accessed: Direct AddressingOn direct addressing, a value is obtained from a memory location while the address ofthat location is specified in instruction. Only after that, the instruction can process data(how depends on the type of instruction: addition, subtraction, copy…). Obviously, anumber being changed during operating a variable can reside at that specified address.For example:Since the address is only one byte in size ( the greatest number is 255), this is how onlythe first 255 locations in RAM can be accessed in this case the first half of the basicRAM is intended to be used freely, while another half is reserved for the SFRs. Indirect AddressingOn indirect addressing, a register which contains address of another register is specifiedin the instruction. A value used in operating process resides in that another register. Forexample:Only RAM locations available for use are accessed by indirect addressing (never in theSFRs). For all latest versions of the microcontrollers with additional memory block(those 128 locations in Data Memory), this is the only way of accessing them. Simply,when during operating, the instruction including “@” sign is encountered and if thespecified address is higher than 128 (7F hex.), the processor knows that indirectaddressing is used and jumps over memory space reserved for the SFRs.On indirect addressing, the registers R0, R1 or Stack Pointer are used for specifying 8-bitaddresses. Since only 8 bits are available, it is possible to access only registers of internalRAM in this way (128 locations in former or 256 locations in latest versions of the 24
  25. 25. microcontrollers). If memory extension in form of additional memory chip is used thenthe 16-bit DPTR Register (consisting of the registers DPTRL and DPTRH) is used forspecifying addresses. In this way it is possible to access any location in the range of 64K.2.2.5 REGISTERS2.2.5.1 SFRs (Special Function Registers)SFRs are a kind of control table used for running and monitoring microcontroller’soperating. Each of these registers, even each bit they include, has its name, address in thescope of RAM and clearly defined purpose ( for example: timer control, interrupt, serialconnection etc.). Even though there are 128 free memory locations intended for theirstorage, the basic core, shared by all types of 8052 controllers, has only 21 such registers.Rest of locations are intentionally left free in order to enable the producers to furtherimproved models keeping at the same time compatibility with the previous versions. Italso enables the use of programs written a long time ago for the microcontrollers whichare out of production now. A Register (Accumulator) This is a general-purpose register which serves for storing intermediate resultsduring operating. A number (an operand) should be added to the accumulator prior toexecute an instruction upon it. Once an arithmetical operation is preformed by the ALU,the result is placed into the accumulator. If a data should be transferred from one registerto another, it must go through accumulator. For such universal purpose, this is the mostcommonly used register that none microcontroller can be imagined without (more than ahalf 8052 microcontrollers instructions used use the accumulator in some way). B Register B register is used during multiply and divide operations which can be performedonly upon numbers stored in the A and B registers. All other instructions in the programcan use this register as a spare accumulator (A).During programming, each of registers is called by name so that their exact address is notso important for the user. During compiling into machine code (series of hexadecimal 25
  26. 26. numbers recognized as instructions by the microcontroller), PC will automatically,instead of registers’ name, write necessary addresses into the microcontroller. R Registers (R0-R7) This is a common name for the total 8 general purpose registers (R0, R1, R2...R7). Even they are not true SFRs, they deserve to be discussed here because of theirpurpose. The bank is active when the R registers it includes are in use. Similar to theaccumulator, they are used for temporary storing variables and intermediate results.Which of the banks will be active depends on two bits included in the PSW Register.These registers are stored in four banks in the scope of RAM.2.3 IR SECTION:2.3.1 IR GENERATION To generate a 36 KHz pulsating infrared is quite easy, more difficult is to receiveand identify this frequency. This is why some companies produce infrared receives, thatcontains the filters, decoding circuits and the output shaper, that delivers a square wave,meaning the existence or not of the 36kHz incoming pulsating infrared. It means that those 3 dollars small units, have an output pin that goes high (+5V)when there is a pulsating 36kHz infrared in front of it, and zero volts when there is notthis radiation. Fig: 4.1(a) IR transmitter 26
  27. 27. A square wave of approximately 27uS (microseconds) injected at the base of a transistor,can drive an infrared LED to transmit this pulsating light wave. Upon its presence, thecommercial receiver will switch its output to high level (+5V).If you can turn on and offthis frequency at the transmitter, your receivers output will indicate when the transmitteris on or off. Fig: 4.1(b) waveform for transmitterThose IR demodulators have inverted logic at its output, when a burst of IR is sensed itdrives its output to low level, meaning logic level = 1.The TV, VCR, and Audio equipment manufacturers for long use infra-red at their remotecontrols. To avoid a Philips remote control to change channels in a Panasonic TV, theyuse different codification at the infrared, even that all of them use basically the sametransmitted frequency, from 36 to 50 KHz. So, all of them use a different combination ofbits or how to code the transmitted data to avoid interference.RC-5 Various remote control systems are used in electronic equipment today. The RC5control protocol is one of the most popular and is widely used to control numerous homeappliances, entertainment systems and some industrial applications including utilityconsumption remote meter reading, contact-less apparatus control, telemetry datatransmission, and car security systems. Philips originally invented this protocol andvirtually all Philips’ remotes use this protocol. Following is a description of the RC5. 27
  28. 28. When the user pushes a button on the hand-held remote, the device is activated and sendsmodulated infrared light to transmit the command. The remote separates command datainto packets. Each data packet consists of a 14-bit data word, which is repeated if the usercontinues to push the remote button. The data packet structure is as follows: • 2 start bits, • 1 control bit, • 5 address bits, • 6 command bits.The start bits are always logic ‘1’ and intended to calibrate the optical receiver automaticgain control loop. Next, is the control bit. This bit is inverted each time the user releasesthe remote button and is intended to differentiate situations when the user continues tohold the same button or presses it again. The next 5 bits are the address bits and select thedestination device. A number of devices can use RC5 at the same time. To excludepossible interference, each must use a different address. The 6 command bits describe theactual command. As a result, a RC5 transmitter can send the 2048 unique commands.The transmitter shifts the data word, applies Manchester encoding and passes the createdone-bit sequence to a control carrier frequency signal amplitude modulator. Theamplitude modulated carrier signal is sent to the optical transmitter, which radiates theinfrared light. In RC5 systems the carrier frequency has been set to 36 kHz. Figure belowdisplays the RC5 protocol. The receiver performs the reverse function. The photo detector converts opticaltransmission into electric signals, filters it and executes amplitude demodulation. Thereceiver output bit stream can be used to decode the RC5 data word. This operation isdone by the microprocessor typically, but complete hardware implementations arepresent on the market as well. Single-die optical receivers are being mass produced by anumber of companies such as Siemens, Temic, Sharp, Xiamen Hualian, Japanese Electric 28
  29. 29. and others. Please note that the receiver output is inverted (log. 1 corresponds toillumination absence).2.3.2 IR TRANSMITTER:The IR LED emitting infrared light is put on in the transmitting unit. To generate IRsignal, 555 IC based astable multivibrator is used. Infrared LED is driven throughtransistor BC 548. IC 555 is used to construct an astable multivibrator which has two quasi-stablestates. It generates a square wave of frequency 38 kHz and amplitude 5Volts. It isrequired to switch ‘ON’ the IR LED. The IR transmitter circuit is as shown below: 555 TIMER: Fig:4.2.1(a) 555- timer The 555 is an integrated circuit (chip) implementing a variety of timer andmultivibrator applications. It was designed in 1970 and introduced in 1971 by Signetics 29
  30. 30. (later acquired by Philips). The original name was the SE555/NE555 and was called"The IC Time Machine". It is still in wide use, thanks to its ease of use, low price andgood stability. As of 2003, 1 billion units are manufactured every year. The 555 timer is one of the most popular and versatile integrated circuits everproduced. It includes 23 transistors, 2 diodes and 16 resistors on a silicon chip installed inan 8-pin mini dual-in-line package (DIP-8). The 556 is a 14-pin DIP that combines two555s on a single chip. Fig:4.2.1(b) 555 timer pinPin Functions - 8 pin packageGround (Pin 1) This pin is connected directly to ground.Trigger (Pin 2) This pin is the input to the lower comparator and is used to set the latch, which in turncauses the output to go high.Output (Pin 3) 30
  31. 31. Output high is about 1.7V less than supply. Output high is capable of sourcing up to200mA while output low is capable of sinking up to 200mA.Reset (Pin 4)This is used to reset the latch and return the output to a low state. The reset is anoverriding function. When not used connect to V+.Control (Pin 5)Allows access to the 2/3V+ voltage divider point when the 555 timer is used in voltagecontrol mode. When not used connect to ground through a 0.01 uF capacitor.Threshold (Pin 6)This is an input to the upper comparator.Discharge (Pin 7)This is the open collector to Q14.V+ (Pin 8)This connects to Vcc and the Philips data book states the ICM7555 CMOS versionoperates 3V - 16V DC while the NE555 version is 3V - 16V DC.The 555 has three operating modes: • Monostable mode: in this mode, the 555 functions as a "one-shot". Applications include timers, missing pulse detection, bounce free switches, touch switches, Frequency Divider, Capacitance Measurement, Pulse Width Modulation (PWM) etc • Astable mode: Free Running mode: the 555 can operate as an oscillator. Uses include LED and lamp flashers, pulse generation, logic clocks, tone generation, security alarms, pulse position modulation, etc. 31
  32. 32. • Bistable mode: The 555 can operate as a flip-flop, if the DIS pin is not connected and no capacitor is used. Uses include bounce free latched switches, etc. This circuit diagram shows how a 555 timer IC is configured to function as anastable multivibrator. An astable multivibrator is a timing circuit whose low andhigh states are both unstable. As such, the output of an astable multivibrator togglesbetween low and high continuously, in effect generating a train of pulses. Thiscircuit is therefore also known as a pulse generator circuit. In this circuit, capacitor C1 charges through R1 and R2, eventually building upenough voltage to trigger an internal comparator to toggle the output flip-flop. Oncetoggled, the flip-flop discharges C1 through R2 into pin 7, which is the discharge pin.When C1s voltage becomes low enough, another internal comparator is triggered totoggle the output flip-flop. This once again allows C1 to charge up through R1 and R2and the cycle starts all over again. C1s charge-up time t1 is given by: t1 = 0.693(R1+R2) C1. C1s discharge timet2 is given by: t2 = 0.693(R2) C1. Thus, the total period of one cycle is t1+t2 = 0.693C1 (R1+2R2). The frequency f of the output wave is the reciprocal of this period, andis therefore given by:f = 1.44/ (C1 (R1+2R2))where f is in Hz if R1 and R2 are in megaohms and C1 is in microfarads. 32
  33. 33. Fig:4.2.1(c) astable multivibrater2.3.3 IR RECEIVER The TSOP17.. – Series are miniaturized receivers for infrared remote controlsystems. PIN diode and preamplifier are assembled on lead frame, the epoxy package isdesigned as IR filter. The demodulated output signal can directly be decoded by a microprocessor.TSOP17.. is the standard IR remote control receiver series, supporting all majortransmission codes.Features • Photo detector and preamplifier in one package • Internal filter for PCM frequency • Improved shielding against electrical field disturbance • TTL and CMOS compatibility • Output active low 33
  34. 34. • Low power consumption • High immunity against ambient light • Continuous data transmission possible (up to 2400 bps) • Suitable burst length .10 cycles/burst Fig: 4.3(a) block diagram of IR receiver Fig: 4.3(b) application circuitSuitable Data Format The circuit of the TSOP17 is designed in that way that unexpected output pulsesdue to noise or disturbance signals are avoided. A bandpass filter, an integrator stage andan automatic gain control are used to suppress such disturbances. The distinguishingmark between data signal and disturbance signal are carrier frequency, burst length andduty cycle. The data signal should fulfill the following condition:• Carrier frequency should be close to center frequency of the bandpass (e.g. 38 KHz). 34
  35. 35. • Burst length should be 10 cycles/burst or longer.• After each burst which is between 10 cycles and 70 cycles a gap time of at least 14cycles is necessary.• For each burst which is longer than 1.8ms a corresponding gap time is necessary atsome time in the data stream. This gap time should have at least same length as the burst.• Up to 1400 short bursts per second can be received continuously. Some examples for suitable data format are: NEC Code, Toshiba Micom Format,Sharp Code, RC5 Code, RC6 Code, R–2000 Code and Sony Format (SIRCS). When adisturbance signal is applied to the TSOP17.. It can still receive the data signal. Howeverthe sensitivity is reduced to that level that no unexpected pulses will occur. Someexamples for such disturbance signals which are suppressed by the TSOP17 are:• DC light (e.g. from tungsten bulb or sunlight)• Continuous signal at 38 kHz or at any other frequency• Signals from fluorescent lamps with electronic ballast2.3.4 IR Emitter and phototransistor: An infrared emitter is an LED made from gallium arsenide, which emits near-infrared energy at about 880nm. The infrared phototransistor acts as a transistor with thebase voltage determined by the amount of light hitting the transistor. Hence it acts as avariable current source. Greater amount of IR light cause greater currents to flow throughthe collector-emitter leads.The variable current traveling through the resistor causes a voltage drop in the pull-upresistor. This voltage is measured as the output of the device 35
  36. 36. Fig: Photo Sensors array:IR reflectance sensors contain a matched infrared transmitter and infrared receiver pair.These devices work by measuring the amount of light that is reflected into the receiver.Because the receiver also responds to ambient light, the device works best when wellshielded from ambient light, and when the distance between the sensor and the reflectivesurface is small(less than 5mm). IR reflectance sensors are often used to detect white andblack surfaces. White surfaces generally reflect well, while black surfaces reflect poorly.One of such applications is the line follower of a robot. 36
  37. 37. Fig:4.5(a) IR emitterdetector circuit fig: 4.5(b) Schematic Diagram for a Single Pair of Infrared Transmitter andReceiver 37
  38. 38. Fig:4.5(c) schematic of a single sensor2.4 LM 3242.4.1 FEATURES: • Wide gain bandwidth . : 1.3MHZ input common-mode voltage range • Includes ground .largevoltage gain : 100DB .very lowsupply current/ampli : 375ma .low input bias current : 20NA low input offset voltage : 5mv max. • Low input offset current : 2NA wide power supply range : • Single supply : +3v to +30v • Dual supplies : ±1.5v to ±15v2.4.2 DESCRIPTIONThese circuits consist of four independent, high gain, internally frequency compensatedoperational amplifiers .They operate from a single power supply over a wide range ofvoltages. Operation from split power supplies is also possible and the low power supplycurrent drain is independent of the magnitude of the power supply voltage. 38
  39. 39. Fig:6.2(a) pin configuration (top view)2.5 DC GEARED MOTORSDC motorA DC motor is an electric motor that runs on direct current (DC) electricity.DC Motor ConnectionsFigure shows schematically the different methods of connecting the field and armaturecircuits in a DC Motor. The circular symbol represents the armature circuit, and thesquares at the side of the circle represent the brush commutator system. The direction ofthe arrows indicates the direction of the magnetic fields. 39
  40. 40. Fig:7 DC motor connections2.5.1 Principles of operationIn any electric motor, operation is based on simple electromagnetism. A current-carryingconductor generates a magnetic field; when this is then placed in an external magneticfield, it will experience a force proportional to the current in the conductor, and to thestrength of the external magnetic field. As you are well aware of from playing withmagnets as a kid, opposite (North and South) polarities attract, while like polarities(North and North, South and South) repel. The internal configuration of a DC motor isdesigned to harness the magnetic interaction between a current-carrying conductor and anexternal magnetic field to generate rotational motion.Lets start by looking at a simple 2-pole DC electric motor (here red represents a magnetor winding with a "North" polarization, while green represents a magnet or winding witha "South" polarization). Fig:7.1(a) internal structure of motorEvery DC motor has six basic parts -- axle, rotor (a.k.a., armature), stator, commutator,field magnet(s), and brushes. In most common DC motors (and all that Beamers will see),the external magnetic field is produced by high-strength permanent magnets. The stator isthe stationary part of the motor -- this includes the motor casing, as well as two or morepermanent magnet pole pieces. The rotor (together with the axle and attached 40
  41. 41. commutator) rotates with respect to the stator. The rotor consists of windings (generallyon a core), the windings being electrically connected to the commutator. The abovediagram shows a common motor layout -- with the rotor inside the stator (field) magnets.The geometry of the brushes, commutator contacts, and rotor windings are such thatwhen power is applied, the polarities of the energized winding and the stator magnet(s)are misaligned, and the rotor will rotate until it is almost aligned with the stators fieldmagnets. As the rotor reaches alignment, the brushes move to the next commutatorcontacts, and energize the next winding. Given our example two-pole motor, the rotationreverses the direction of current through the rotor winding, leading to a "flip" of therotors magnetic field, driving it to continue rotating.In real life, though, DC motors will always have more than two poles (three is a verycommon number). In particular, this avoids "dead spots" in the commutator. You canimagine how with our example two-pole motor, if the rotor is exactly at the middle of itsrotation (perfectly aligned with the field magnets), it will get "stuck" there. Meanwhile,with a two-pole motor, there is a moment where the commutator shorts out the powersupply (i.e., both brushes touch both commutator contacts simultaneously). This wouldbe bad for the power supply, waste energy, and damage motor components as well. Yetanother disadvantage of such a simple motor is that it would exhibit a high amount oftorque "ripple" (the amount of torque it could produce is cyclic with the position of therotor). Fig:7.1(b) motor rotation in clockwise direction 41
  42. 42. So since most small DC motors are of a three-pole design, lets tinker with the workingsof one via an interactive animation. Fig:7.1(c) 3 pole designYoull notice a few things from this -- namely, one pole is fully energized at a time (buttwo others are "partially" energized). As each brush transitions from one commutatorcontact to the next, one coils field will rapidly collapse, as the next coils field willrapidly charge up (this occurs within a few microsecond). Well see more about theeffects of this later, but in the meantime you can see that this is a direct result of the coilwindings series wiring: Fig:7.1(d) iron core amatureThe use of an iron core armature (as in the Mabuchi, above) is quite common, and has anumber of advantages. First off, the iron core provides a strong, rigid support for thewindings -- a particularly important consideration for high-torque motors. The core also 42
  43. 43. conducts heat away from the rotor windings, allowing the motor to be driven harder thanmight otherwise be the case. Iron core construction is also relatively inexpensivecompared with other construction types.But iron core construction also has several disadvantages. The iron armature has arelatively high inertia which limits motor acceleration. This construction also results inhigh winding inductances which limit brush and commutator life.In small motors, an alternative design is often used which features a coreless armaturewinding. This design depends upon the coil wire itself for structural integrity. As a result,the armature is hollow, and the permanent magnet can be mounted inside the rotor coil.Coreless DC motors have much lower armature inductance than iron-core motors ofcomparable size, extending brush and commutator life. Fig:7.1(e) parts of motorDC motor behaviorHigh-speed outputThis is the simplest trait to understand and treat -- most DC motors run at very highoutput speeds (generally thousands or tens of thousands of RPM). While this is fine forsome BEAM bots (say, photo poppers or solar rollers), many BEAM bots (walkers,heads) require lower speeds -- you must put gears on your DC motors output for theseapplications.2.6 H-BRIDGE: 43
  44. 44. An H-bridge is an electronic circuit which enables DC electric motors to be run forwardsor backwards. These circuits are often used in robotics. H-bridges are available asintegrated circuits, or can be built from discrete components. Fig:8 H-bridge switch diagram The two basic states of a H-bridge. The term "H-bridge" is derived from thetypical graphical representation of such a circuit. An H-bridge is built with four switches(solid-state or mechanical). When the switches S1 and S4 (according to the first figure)are closed (and S2 and S3 are open) a positive voltage will be applied across the motor.By opening S1 and S4 switches and closing S2 and S3 switches, this voltage is reversed,allowing reverse operation of the motor. Using the nomenclature above, the switches S1 and S2 should never be closed at thesame time, as this would cause a short circuit on the input voltage source. The sameapplies to the switches S3 and S4. This condition is known as shoot-through.2.6.1 OperationThe H-Bridge arrangement is generally used to reverse the polarity of the motor, but canalso be used to brake the motor, where the motor comes to a sudden stop, as the motorsterminals are shorted, or to let the motor free run to a stop, as the motor is effectivelydisconnected from the circuit. The following table summarizes operation. 44
  45. 45. S1 S2 S3 S4 Result 1 0 0 1 Motor moves right 0 1 1 0 Motor moves left 0 0 0 0 Motor free runs 0 1 0 1 Motor brakes Table: 8.1 H-bridge switch operation2.6.2 H-Bridge Driver:The switching property of this H-Bridge can be replaced by a Transistor or a Relay or aMosfet or even by an IC. Here we are replacing this with an IC named L293D as thedriver whose description is as given below.Features: • 600mA OUTPUT CURRENT CAPABILITY • PER CHANNEL • 1.2A PEAK OUTPUT CURRENT (non repetitive) • PER CHANNEL • ENABLE FACILITY • OVERTEMPERATURE PROTECTION • LOGICAL "0" INPUT VOLTAGE UP TO 1.5 V • (HIGH NOISE IMMUNITY) • INTERNAL CLAMP DIODES 45
  46. 46. DESCRIPTIONThe Device is a monolithic integrated high voltage, high current four channel driverdesigned to accept standard DTL or TTL logic levels and drive inductive loads (such asrelays solenoides, DC and stepping motors) and switching power transistors. To simplifyuse as two bridges each pair of channels is equipped with an enable input. A separatesupply input is provided for the logic, allowing operation at a lower voltage and internalclamp diodes are included. This device is suitable for use in switching applications atfrequencies up to 5 kHz. The L293D is assembled in a 16 lead plastic package which has4 center pins connected together and used for heat sinking The L293DD is assembled in a20 lead surface mount which has 8 center pins connected together and used for heatsinking. 46
  47. 47. 2.6.3 BLOCK DIAGRAM: Fig: 8.5(a) block diagram of H-bridge2.6.4 PIN CONNECTIONS fig:8.5(b) pin configuration of H-bridge 47
  48. 48. CHAPTER:3 WORKING PROCEDURE3.1 WORKING PROCEDURERobotics is an interesting subject to discuss about and in this advanced world Robots arebecoming a part of our life. In this project we are going to discuss about a robot which iscapable of following a line without the help of any external source. The Embedded Line following robot uses two motors to control rear wheels and thesingle front wheel is free. It has 3-infrared sensors on the bottom for detection of blacktracking tape. When the middle sensor detects the black color, this sensor output is givento the comparator LM324. The output of comparator compares this sensor output with areference voltage and gives an output. The output of comparator will be low when itreceives an input from the sensor. We follow a simple logic to implement this project. As we know that black colour iscapable of absorbing the radiation and white colour or a bright colour reflects theradiation back. Here we use 3 pairs of IR TX and Rx .The robot uses these IR sensors tosense the line and the arrangement is made such that sensors face the ground. The outputfrom the sensors is an analog signal which depends on the amount of light reflected backand this analog signal is given to the comparator to produce 0s and 1s. Internally we have an OTP (one time programmable) processor which is used tocontrol the rotation of the wheels. The rotation of these wheels depends up on theresponse from the comparator. Let us assume that when a sensor is on the black line itreads 0 and when it is on the bright surface it reads 1.Here we can get three different cases, they are: 1. Straight direction 2. Right curve 3. Left curve 48
  49. 49. 3.1.1 Straight direction: We can expect our robot to move in straight direction when the middle sensors responseis low and the remaining two sensors response is high. i.e., according to our arrangementthe middle sensor will always be on the line and as the line is black in colour it will notreflect the emitted radiation back and the response of the sensor will be low and theresponse of the remaining two sensors will be high as they will be on the bright surface.3.1.2 Right curve:When a right curve is found on the line the responses will change i.e. the response of thefirst sensor which is to the right will become low as that sensor will be facing the blackline and the reaming sensors response will be high. We this data is achieved the controlof the wheels is changed i.e. the right wheel is held and the left wheel is made to movefreely until the response from the middle sensor becomes low. Then the same processrepeats again.3.1.3 Left curve:When a left curve is found on the line the response of the left most sensor will bechanged from high to low as the sensor will now face the black or the dark surface. Thenthe control of the wheel changes i.e. by holding the left wheel and allowing the rightwheel to move freely until the middle sensor changes it’s response fro high to low.The same process continues for all the turns and the robot moves continuously until thesupply is remove3.2 STEPS TO FOLLOW THE LINE (USING SINGLE SENSOR): • Start • Check for line • Line detected go right • Check for line • If no line turn left till line detected 49
  50. 50. CHAPTER: 4 SOFTWARE TOOLS4.1 KEIL SOFTWARE: Keil compiler is a software used where the machine language code is written andcompiled. After compilation, the machine source code is converted into hex code whichis to be dumped into the microcontroller for further processing. Keil compiler alsosupports C language code.4.2 STEPS TO WRITE AN ASSEMBLY LANGUAGE PROGRAM IN KEIL ANDHOW TO COMPILE IT: 1. Install the Keil Software in the PC in any of the drives. 2. After installation, an icon will be created with the name “Keil uVision3”. Just drag this icon onto the desktop so that it becomes easy whenever you try to write programs in keil. 3. Double click on this icon to start the keil compiler. 4. A page opens with different options in it showing the project workspace at the leftmost corner side, output window in the bottom and an ash coloured space for the program to be written. 5. Now to start using the keil, click on the option “project”. 6. A small window opens showing the options like new project, import project, open project etc. Click on “New project”. 7. A small window with the title bar “Create new project” opens. The window asks the user to give the project name with which it should be created and the destination location. The project can be created in any of the drives available. You can create a new folder and then a new file or can create directly a new file. 50
  51. 51. 8. After the file is saved in the given destination location, a window opens where a list of vendors will be displayed and you have to select the device for the target you have created.9. The most widely used vendor is Atmel. So click on Atmel and now the family of microcontrollers manufactured by Atmel opens. You can select any one of the microcontrollers according to the requirement.10. When you click on any one of the microcontrollers, the features of that particular microcontroller will be displayed on the right side of the page. The most appropriate microcontroller with which most of the projects can be implemented is the AT89S52. Click on this microcontroller and have a look at its features. Now click on “OK” to select this microcontroller.11. A small window opens asking whether to copy the startup code into the file you have created just now. Just click on “No” to proceed further.12. Now you can see the TARGET and SOURCE GROUP created in the project workspace.13. Now click on “File” and in that “New”. A new page opens and you can start writing program in it.14. After the program is completed, save it with any name but with the .asm extension. Save the program in the file you have created earlier.15. You can notice that after you save the program, the predefined keywords will be highlighted in bold letters.16. Now add this file to the target by giving a right click on the source group. A list of options open and in that select “Add files to the source group”. Check for this file where you have saved and add it.17. Right click on the target and select the first option “Options for target”. A window opens with different options like device, target, output etc. First click on “target”.18. Since the set frequency of the microcontroller is 11.0592 MHz to interface with the PC, just enter this frequency value in the Xtal (MHz) text area and put a tick on the Use on-chip ROM. This is because the program what we write here in the keil will later be dumped into the microcontroller and will be stored in the inbuilt ROM in the microcontroller. 51
  52. 52. 19. Now click the option “Output” and give any name to the hex file to be created in the “Name of executable” text area and put a tick to the “Create HEX file” option present in the same window. The hex file can be created in any of the drives. You can change the folder by clicking on “Select folder for Objects”.20. Now to check whether the program you have written is errorless or not, click on the icon exactly below the “Open file” icon which is nothing but Build Target icon. You can even use the shortcut key F7 to compile the program written.21. To check for the output, there are several windows like serial window, memory window, project window etc. Depending on the program you have written, select the appropriate window to see the output by entering into debug mode.22. The icon with the letter “d” indicates the debug mode.23. Click on this icon and now click on the option “View” and select the appropriate window to check for the output.24. After this is done, click the icon “debug” again to come out of the debug mode.25. The hex file created as shown earlier will be dumped into the microcontroller with the help of another software called Proload. 52
  53. 53. 4.3 PROLOAD: Proload is software which accepts only hex files. Once the machine code isconverted into hex code, that hex code has to be dumped into the microcontroller placedin the programmer kit and this is done by the Proload. Programmer kit contains amicrocontroller on it other than the one which is to be programmed. This microcontrollerhas a program in it written in such a way that it accepts the hex file from the keilcompiler and dumps this hex file into the microcontroller which is to be programmed. Asthis programmer kit requires power supply to be operated, this power supply is givenfrom the power supply circuit designed above. It should be noted that this programmer kitcontains a power supply section in the board itself but in order to switch on that powersupply, a source is required. Thus this is accomplished from the power supply board withan output of 12volts or from an adapter connected to 230 V AC. 1. Install the Proload Software in the PC. 2. Now connect the Programmer kit to the PC (CPU) through serial cable. 3. Power up the programmer kit from the ac supply through adapter. 4. Now place the microcontroller in the GIF socket provided in the programmer kit. 5. Click on the Proload icon in the PC. A window appears providing the information like Hardware model, com port, device type, Flash size etc. Click on browse option to select the hex file to be dumped into the microcontroller and then click on “Auto program” to program the microcontroller with that particular hex file. 6. The status of the microcontroller can be seen in the small status window in the bottom of the page. 7. After this process is completed, remove the microcontroller from the programmer kit and place it in your system board. Now the system board behaves according to the program written in the microcontroller. 53
  54. 54. CHAPTER: 5 RESULTThe objective of the line following robot is to follow a line on its given path which isobtained for which it uses IR sensors which detects the line and sends the information toLM324 comparator and then to H bridge which controls the working of the wheel’s.Microcontroller controls the other operations. 54
  55. 55. CHAPTER :6 CONCLUSION AND FUTURE SCOPECONCLUSION:In this project we have studied and implemented a Line Following Robot using aMicrocontroller for blind people. The programming and interfacing of microcontrollerhas been mastered during the implementation.FUTURE SCOPE: • Smarter versions of line followers are used to deliver mails within office building and deliver medications in a hospital. • This technology has been suggested for running buses and other mass transit systems and may end up as a part of autonomous cars navigating the freeway.REFERENCES: 1. 2. EMBEDDED SYSTEM BY RAJ KAMAL 3. 8051 MICROCONTROLLER AND EMBEDDED SYSTEMS BY MAZZIDI 4. Magazines-Electronics for you 5. Electrikindia. 6. www.electronic 55