Workshop (1)

109
ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91- 40-65555388 Page 1

description

Workshop (1)

Transcript of Workshop (1)

Page 1: Workshop (1)

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 1

Page 2: Workshop (1)

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 2

Line Follower Robot

Robotics Workshop Under Assure Global solutions.

Developed By:T. Abhignan,Azharuddin Mohd.

Page 3: Workshop (1)

We are glad to have an opportunity to share our knowledge with interested robotics enthusiasts. In this book we have attempted to provide a brief compilation of our experiences in robotics (participating and winning in Technical Festivals all over the country), extending over last three years.

The prospect of practically implementing engineering concepts is the hallmark of robotics. By reading the basics in this book you will gain a significant insight into various tools employed in shaping a robot. However to participate in technical festivals with ever changing problem statements you will be required to apply these basics concepts and come up with innovative algorithms and superior designs.

Do not expect this book to be a panacea for all robotic problems, rather you will have to sit and work for hours to get a functioning robot. Transform each failure into a stepping stone instead of stumbling over it. We appreciate the beauty of diamond but little do we wonder how it became so bright? Its perseverance extending thousands of years transformed it into its present sparkling state.

Your valuable suggestions and inquisitive doubts are welcome. You can contact us at

Abhignan. T ( [email protected])

Azharuddin Mohd([email protected])

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 3

To Our Readers

Page 4: Workshop (1)

INTRODUCTION

What is a line follower?Line follower is a machine that can follow a path. The path can be visible

like a black line on a white surface (or vice-versa) or it can be invisible like a magnetic field.

Why build a line follower?Sensing a line and maneuvering the robot to stay on course, while constantly

correcting wrong moves using feedback mechanism forms a simple yet effective closed loop system. As a programmer you get an opportunity to ‘teach’ the robot how to follow the line thus giving it a human-like property of responding to stimuli. Practical applications of a line follower: Automated cars running on roads with embedded magnets; guidance system for industrial robots moving on shop floor etc.

To start with first of all we will be discussing a small concept of light. We believe you all know that the light that strikes any platform is reflected. The reflection and absorption coefficient of light depend upon material, color of platform and other factors. In simple words the black surface absorbs the light and the white surface reflects it, this is the basic concept behind making a line follower.

BASIC DESIGN AND REQUIREMENTS:The robot is built using ATMEL 89S52, L293D, IR sensors, LM358,

platform consisting of a toy car chassis (or handmade Aluminum, sheet chassis), two motors and controlling wheels. It has infrared sensors on the bottom for detecting black tracking tape. Line position is captured with the help of optical sensors called opto-couplers mounted at the front end of the robot (Each opto-coupler consists of an IR LED and an IR Sensor). When the sensors detect black surface, output of comparator, LM358 is low while for white surface the output is high. It is sent as input to the microcontroller for accurate control and steering of motors. Microcontroller ATMEL 89s52 and Motor driver L293d are use to drive

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 4

Page 5: Workshop (1)

the motors

BLOCK DIAGRAM:

BASIC PRINCIPLE:

The basic operations of the line follower are as follows:1. Capture line position with optical sensors mounted at front end of the robot. For this a combination of IR LED and Photo Transistor called an opto-coupler is used. The line sensing process requires high resolution and high robustness.2. Steer robot to track the line with a suitable steering mechanism. To achieve this we use two motor that govern the motion of the wheels on either side.

Each opto-coupler has one emitter (IR LED) and one receiver (Photo-Transistor or photo diode). If white surface is present beneath the IR LED IR rays are reflected and are sensed by the receiver, while in case of black surface the light gets absorbed and hence receiver does not sense IR rays.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 5

Page 6: Workshop (1)

So the line follower has an emitter and a reflector. The reflector receives the light and generates a voltage proportional to the intensity of the light, if this voltage is above a threshold it means SIGNAL=1 (logic one) else SIGNAL=0 (logic zero).

Let’s take up simple example where we have to move our bot on black surface having white line. Suppose I have two Infrared sensor pairs that are on different halves of a bot with respect to geometrical central axis of the bot. The sensors are placed in such a way that the white line lies in between both the sensors when the bot is placed on the white track painted on black surface to move. Now if the white line is between both the sensors while moving forward both the sensors will be on black surface to move. Now if the white line is between both the sensors while moving forward both the sensors will be on black surface and the

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 6

Page 7: Workshop (1)

detectors/receivers will receive less amount of light since black absorbs light and hence signal provided by both the infrared receivers will be low.

DESIGN OF INFRARED SENSOR CIRCUIT:

Principle of operation of the I.R L.E.D and Phototransistor: -A Photodiode is a p-n junction. When an infrared photon of sufficient energy

strikes the diode, it excites an electron thereby creating a mobile electron and a positively charged electron hole. If the absorption occurs in the junction's depletion region, or one diffusion length away from it, these carriers are swept from the junction by the built-in field of the depletion region, producing a photocurrent. Photodiodes can be used under either zero bias (photovoltaic mode) or reverse bias (photoconductive mode). Reverse bias induces only little current (known as saturation or back current) along its direction. But a more important effect of reverse bias is widening of the depletion layer (therefore expanding the reaction volume) and strengthening the photocurrent when infrared falls on it. There is a limit on the distance between I.R. L.E.D. and infrared sensor for the pair to operate in the desired manner. In our case distance is about 5mm. Infra-Red emitter sends out IR pulses. Position calculation is done through intensity of reflected light received by the detector. Ambient interference is negligible

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 7

Page 8: Workshop (1)

Photo diode has a property that if IR light falls on it, its electrical resistance decreases (from say 150kΩ to 10kΩ). For sensing the change in resistance we use voltage divider circuit (as shown in figure below).

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 8

Page 9: Workshop (1)

ComparatorComparator is a device which compares two input voltages and gives output

as high or low. In a circuit diagram it is normally represented by a triangle having Inverting (negative) Input (-), Non-Inverting (positive) Input (+), Vcc, Ground, Output.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 9

Sample Calculation:Say Receiver has resistance-Rs=150kΩ without light (on black surface)Rs=10kΩ with light (on white surface)The voltage that goes to comparatorWithout light: (on black surface)Vp= Rs/ (Rs+ R)* Vcc= 150/ (150+10) *5 V=4.6875 V

With light: (on white surface)Vp= Rs/ (Rs+ R)* Vcc= 10/ (10+150) *5 V=2.500 V

Properties of comparator: If V+ > V then

Vo =Vcc (Digital High 1 output)

If V+ < V then Vo =0 (Digital Low 0 output)

Page 10: Workshop (1)

Let’s see examples:

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 10

Sample Calculation:Let V+ = 3.5875 VWith light :( on white surface)V- = 0.9090 VThus V+>V- and Vo= Vcc = 5 VThus we get digital HIGH output.Without light : (on black surface)V- = 3.333 VThus V+<V- and Vo = 0 VThus we get digital LOW

Page 11: Workshop (1)

POSITIONING OF SENSORS:-

The resistance of the sensor decreases when IR (infrared) light falls on it. A good sensor will have near zero resistance in presence of light and a very large resistance in absence of light. Whether the sensors are Light Dependent Resistors, laser diode, Infrared Sensors, Ultrasonic Sensors or anything else, the outputs of the sensor modules are fed to the Non-inverting input of a comparator. The reference voltage of the comparator is fed to the inverting input of the comparator by a trim pot or a tuning device connected between the supply lines.

LM358 is a comparator IC that digitizes the analog signal from the sensor array. Since the output of LM358 is TTL compatible it can be directly fed to the master microcontroller. The generalized connection diagram of Sensor Interfacing with microcontroller is shown below:-

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 11

Page 12: Workshop (1)

ELECTRONICS COMPONENTS

LM7805 Voltage Regulator The LM7805 voltage regulators of three terminal positive regulators are available in the TO-220 package and with several fixed output voltage, making them useful in a wide range of application. Each type employs internal current limiting, thermal shut down and safe operating area protection, making it essentially indestructible. Figure below is proving the graphical diagram of LM7805 voltage regulator.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 12

Page 13: Workshop (1)

Infrared Sensor (IR Sensor)

An infrared sensor is an electronic device that transmitter (white) and receiver (black) infrared radiation in order to sense some aspect of its surroundings. Infrared sensors can measure the heat of an object, as well as detect motion. The function of infrared sensor in the robot is corrected move on the route when the routes are curved. Figure below shows graphical diagram of infrared sensor; figure below shows the schematic diagram of infrared sensor.

CAPACITORS:

Capacitors store electric change. They are used to smooth varying DC power supplies by acting as a reservoir of charge. Basically, capacitors easily pass AC (changing) signals but they block DC (constant) signals. There have three type capacitor are Polarized Capacitors, Unpolarized Capacitors and Variable Capacitors.

Polarized Capacitors are polarized and must be connected in the correct way, because a leads have separated two leads they are ‟+‟ and ‟-‟. The voltage rating of polarized capacitors can supply minimum 25V, to supply large values and up to 1μF ++. Figure below shows the graphical diagram of Polarized Capacitors; figure below shows the schematic diagram of Polarized Capacitors.

Unpolarized Capacitors is small value capacitors and connected either way round. But it has high voltage ratings of at least 50V, usually 250V or so, to supply small value and up to 1μF only. Figure below shows the graphical diagram of

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 13

Page 14: Workshop (1)

Unpolarized Capacitors; figure shows the schematic diagram of Unpolarized Capacitors.

Variable capacitors are mostly used in radio tuning circuit. It has very small capacitance values, generally between 100pF and 500pF. The type illustrated usually has trimmers built in as well as the main variable capacitor. Figure below shows the graphical diagram of Variable Capacitors; figure below shows the schematic diagram of Variable Capacitors.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 14

Page 15: Workshop (1)

Light Emitting Diodes (LEDs) LED when an electric current flow through them. LED is same as diodes connection. The application of LED is indicating what frequency signal transmit out. Figure below shows the graphical diagram of LED; figure below shows the schematic diagram of LED.

Resistors Resistors restrict the flow of electric current, for example a resistor is places in series with a light-emitting diode (LED) to limit the current flowing through the LED. In addition, resistor values are normally shown using color bands. The following below is a table of each color represents a number.

Figure below shows the graphical diagram of resistors; figure below shows the schematic diagram of resistors.

Variable Resistors

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 15

Page 16: Workshop (1)

Variable resistors consist of a resistance track with connect at both ends and a wiper which moves along the track as you turn the spindle. The track may be made from carbon, ceramic and metal mixture or a coil of wire. The Figure below is a terminal diagram of variable resistors. Besides that, variable resistors have separated two type are potentiometer and preset variable resistors.

The potentiometer and preset variable resistors have all three terminals connected. However, presets are much cheaper than potentiometer so we are used this preset in our project. Figure below shows the graphical diagram type of variable resistors; figure below shows the schematic diagram type of variable resistors.

Crystal Oscillator A crystal oscillator is an electronic component that uses the mechanical resonance of a vibrating crystal of piezoelectric material to create an electrical signal with a very accurate frequency. Figure below shows the graphical diagram of crystal oscillator; figure below shows the schematic diagram of crystal oscillator.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 16

Page 17: Workshop (1)

USB PROGRAMMER:

First of all select the device you want to program. Rests of the functions are easy to understand. As a list they are as below

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 17

Page 18: Workshop (1)

o Flash Memory Read : Read data from AT 89s52 device to hex fileo Flash Memory Write : Write data from hex file to 89s52 deviceo Flash Memory Verify : Verify the AT 89s52 device against hex fileo Flash Memory Erase-Write-Verify : Erases flash memory from 89s52, burns hex file content to 89s52 device and Verify after writing. – We suggest this option to program 89s52 for failsafe programmingo EEPROM Read – Write : Read EEPROM contents to eep file or writes to EEPROM from eep file.o Fusebits and Lockbits Read –Write : Read Fusebits or Lockbits from device or write to deviceo Erase Device : Erase flash (& EEPROM if fusebits are set for that – see datasheet of device)

Strip board Strip board is used to hope up permanent, soldered circuits. It is ideal for small circuits with one or two ICs (chips) but with large number of holes it is very easy to connect a component in the wrong place. However, it is cheaper than PCB. Figure below shows the graphical diagram of Strip board.

Printed Circuit Boards (PCBs) Printed Circuit Boards have copper tracks connecting the holes where the components are placed. They are design especially for each circuit and make construction very easy. Figure below shows the graphical diagram of Printed Circuit Boards (PCBs).

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 18

Page 19: Workshop (1)

Soldering Iron Equipments Soldering Iron Equipment helps us to build up a circuit on fixed position. For electronics work the best type is one powered by mains electricity’s 230V, it should be a heatproof cable for safety. Figure below shows the graphical diagram of Soldering Iron.

When we are desoldering a joint to correct a mistake or replace a component, must used a tool for removing solder is called Solder Sucker (Desoldering Pump). Figure below shows the graphical diagram of Solder Sucker (Desoldering Pump).

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 19

Page 20: Workshop (1)

Reel of solder is the most important to melt into the circuit, make it fixed position. Solder is alloy of tin and lead, typically 60% tin and 40% lead. It melts at a temperature of about 200°C. ). Figure shows the graphical diagram of Reel of Solder.

Solder paste also known as solder cream is used connecting the termination of integrated chip packages with land patterns on the printed circuit board. Figure below shows the graphical diagram of Solder paste.

Portable Mini Torque Electric Drill Portable mini torque electric drill is used to drill holes on Print Circuit Board

when want to insert component on the Print Circuit Board. This is more convenient

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 20

Page 21: Workshop (1)

than small electric drill machine with stand. Figure below shows the graphical diagram of Portable Mini Torque Electric Drill.

Sandpaper Sandpaper is a form of paper to sharpen materials and fixed to its surface. Purposely, we have been using sandpaper to remove the mask of PCB. Figure below shows the graphical diagram of Sandpaper.

Battery An electrical battery is one or more electrochemical cells that convert stored chemical energy into electrical energy. It also portable power supplier to the circuit and become common power source for many household and industrial applications. There have two type of battery are rechargeable and disposable battery. The rechargeable battery designed to use repeatedly and to be recharged. However, the disposable battery is designed to use each time. Figure below shows the graphical diagram of Rechargeable Battery; figure below shows the graphical diagram of Disposable Battery.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 21

Page 22: Workshop (1)

Black Carpet: We used a black carpet become line follower robot’s route. Wherefore, the

infrared sensor couldn’t detect black color surface, this will cause the line follower robot can’t turn to others side and just follow the black line to move. Figure below shows the graphical diagram of Black Carpet.

Hot Melt Adhesive Hot melt adhesive (HMA), also known as hot glue that is melt a solid cylindrical sticks paste the components on the fixed place. Figure below shows the graphical diagram of Hot Melt Adhesive.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 22

Page 23: Workshop (1)

Mahjong Paper Mahjong paper is drawn and designed the specified route on the paper. Figure below shows the graphical diagram of Mahjong Paper

Sticker Paper This is a white matter paper for use paste on the PCB surface. Figure below shows the graphical diagram of Sticker Paper.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 23

Page 24: Workshop (1)

Ironing Ironing is the work of using a heated tool and used it to heat sticker paper involved route paste into the PCB surface. Figure below shows the graphical diagram of Ironing.

Maker Pen Maker Pen is used for modify and redesigns the circuit on the Printed Circuit Board surface. Figure below shows the graphical diagram of Maker Pen.

Iron Robot Chassis Iron Robot Chassis is used to platform of several circuits and protect them from damage. The base or the material of the platform of robot can be made with any easily available material like switch board, wood, acrylic sheet or steel sheet. As our robot will be very light, we don’t have to think a lot about strength and other such factors. We recommend you to make small size and light weight bot. Figure below shows the graphical diagram of Iron Robot Chassis.

Screw A screw is type of fastener to fix some component in the fixed place. Figure below shows the graphical diagram of Screw.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 24

Page 25: Workshop (1)

Laser Printer Laser Printer is used to print out the PCB diagram on sticker paper for make the Printed Circuit Board. Figure below shows the graphical diagram of Laser Printer.

MICROCONTROLLER:-

Definition:

A Microcontroller is a single-chip microcomputer that contains all the components such as the CPU, RAM, some form of ROM, I/O ports, and timers.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 25

Page 26: Workshop (1)

Unlike a general purpose computer, which also includes all of these components, a microcontroller is designed for a very specific task -- to control a particular system. Microcontrollers are sometimes called embedded microcontrollers, which just means that they are part of an embedded system. A microprocessor is a general-purpose digital computer with central processing unit (CPU), which contains arithmetic and logic unit (ALU), a program counter (PC), a stack pointer (SP), some working registers, a clock timing circuit, and interrupts circuits. The main disadvantage of microprocessor is that it has no on-chip memory. So we are going for micro controller since it has on-board programmable ROM and I/O that can be programmed for various control functions

ATMEL 89S52 MICROCONTROLLER

The microcontroller development effort resulted in the 8051 architecture, which was first introduced in 1980 and has gone on to be arguably the most popular micro controller architecture available. The 8051 is a very complete micro controller with a large amount of built in control store (ROM & EPROM) and RAM, enhanced I/O ports, and the ability to access external memory. The maximum clock frequency with an 8051 micro controller can execute instructions is 20MHZ.

Microcontroller is a true computer on chip. The design incorporates all of the features found in a microprocessor: CPU, ALU, PC, SP and registers. It also has the other features needed to, make complete computer: ROM, RAM, parallel I/O, serial I/O, counters and a clock circuit.

The 89C51/89C52/89C54/89C58 contains a non-volatile FLASH program memory that is parallel programmable. For devices that are serial programmable (In-System Programmable (ISP) and In Application Programmable (IAP) with a boot loader). All three families are Single-Chip 8-bit Microcontrollers manufactured in advanced CMOS process and are Derivatives of the 80C51 microcontroller family. All the devices have the same instruction set as the 80C51.

FEATURES• 8K Bytes of In-System Reprogrammable Flash Memory• Endurance: 1,000 Write/Erase Cycles• Fully Static Operation: 0 Hz to 33 MHz

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 26

Page 27: Workshop (1)

• Three-level Program Memory Lock• 256 x 8-bit Internal RAM• 32 Programmable I/O Lines• Three 16-bit Timer/Counters• Eight Interrupt Sources• Programmable Serial Channel• Low-power Idle and Power-down Modes

DESCRIPTION:

The AT89s52 is a low power, high performance CMOS 8-bit micro computer with 8Kbytes of flash programmable and erasable read only memory(PEROM).The device is manufactured using Atmel’s high density nonvolatile memory technology and is compatible with the industry standard 80c51 and 80C52 instruction set and pin out.The on-chip flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with flash on a monolithic chip, the Atmel AT89s52 Is a powerful microcomputer which provides a highly flexible and cost effective solution to many embedded control applications. The main advantages of 89s52 over 8051 are

Software Compatibility Program Compatibility Rewritability

The 89s52 microcontroller has an excellent software compatibility, i.e. the software used can be applicable to any other microcontroller. The program written on this microcontroller can be carried to any base.Program compatibility is the major advantage in 89s52. The program can be used in any other advanced microcontroller. The program can be reloaded and changed for nearly 1000 times.

AT89S52 ARCHITECTURE:

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 27

Page 28: Workshop (1)

The AT89s52 provides the following standard features: 8K bytes of Flash, 256 bytes of RAM, 32 I/O lines, three 16-bit timer/counters, a six-vector two-level interrupt architecture, a full-duplex serial port, on-chip oscillator, and clock circuitry. 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, serial port, and interrupt system to continue functioning. The Power-down mode saves the RAM

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 28

Page 29: Workshop (1)

contents but freezes the oscillator, disabling all other chip functions until the next hardware reset.

PIN DIAGRAM OF 89S52

PIN DESCRIPTION:

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 29

Page 30: Workshop (1)

VCCSupply voltage.

GNDGround.

Port 0Port 0 is an 8-bit open drain bi-directional I/O port. As an output port, each

pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high impedance inputs. Port 0 can also be configured to be the multiplexed lower order address/data bus during accesses to external program and data memory. In this mode, P0 has internal pull-ups. Port 0 also receives the code bytes during Flash programming and outputs the code bytes during program verification. External pull-ups are required during program verification.

Port 1Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1

output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. 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

Port 2Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 30

Page 31: Workshop (1)

internal pull-ups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that uses 16-bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal pull-ups when emitting 1s. During access to external data memory that uses 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives the high-order address bits and some control signals during Flash programming and verification.

Port 3Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pull-ups. Port 3 also serves the functions 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.

RSTReset input. A high on this pin for two machine cycles while the oscillator is running resets the device. The DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the default state of bit DISRTO, the RESET HIGH out feature is enabled.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 31

Page 32: Workshop (1)

ALE/PROGAddress Latch Enable (ALE) is an output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode.

PSEN Program Store Enable (PSEN) is the read strobe to external program memory.When the AT89S52 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory.

EA/VPPExternal Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. EA should be strapped to VCC for internal program executions. This pin also receives the 12-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

Memory OrganizationMCS-51 devices have a separate address space for Program and Data Memory. Up to 64K bytes each of external Program and Data Memory can be addressed.

Program MemoryIf the EA pin is connected to GND, all program fetches are directed to external memory. On the AT89S52, if EA is connected to VCC, program fetches to addresses 0000H through 1FFFH are directed to internal memory and fetches to addresses 2000H through FFFFH are to external memory.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 32

Page 33: Workshop (1)

Data MemoryThe AT89S52 implements 256 bytes of on-chip RAM. The upper 128 bytes occupy a parallel address space to the Special Function Registers. This means that the upper 128 bytes have the same addresses as the SFR space but are physically separate from SFR space. When an instruction accesses an internal location above address 7FH, the address mode used in the instruction specifies whether the CPU accesses the upper 128 bytes of RAM or the SFR space. Instructions which use direct addressing access of the SFR space. For example, the following direct addressing instruction accesses the SFR at location 0A0H (which is P2). MOV 0A0H, #dataInstructions that use indirect addressing access the upper 128 bytes of RAM. For example, the following indirect addressing instruction, where R0 contains 0A0H, accesses the data byte at address 0A0H, rather than P2 (whose address is 0A0H).MOV @R0, #dataNote that stack operations are examples of indirect addressing, so the upper 128 bytes of data RAM are available as stack space.

Idle ModeIn idle mode, the CPU puts itself to sleep while all the onchip peripherals remain active. The mode is invoked by software. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. The idle mode can be terminated by any enabled interrupt or by a hardware reset. Note that when idle mode is terminated by a hardware reset, the device normally resumes program execution from where it left off, up to two machine cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin when idle mode is terminated by a reset, the instruction following the one that invokes idle mode should not write to a port pin or to external memory.

Power-down ModeIn the Power-down mode, the oscillator is stopped, and the instruction that invokes Power-down is the last instruction executed. The on-chip RAM and Special Function Registers retain their values until the Power-down mode is terminated. Exit from Power-down mode can be initiated either by a hardware reset or by an

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 33

Page 34: Workshop (1)

enabled external interrupt. Reset redefines the SFRs but does not change the on-chip RAM.

CONNECTING INFRARED MODULE WITH MICROCONTROLLER

When the sensor/emitter pair is on shining surface sensor is on i.e. in low impedance mode which one can easily view as L.E.D. corresponding to that sensor doesn’t glow. The output of the op-amp is HIGH SIGNAL and this HIGH SIGNAL is given to the microcontroller and when the sensor is on normal non-reflecting surface it’s off i.e. in HIGH IMPEDANCE state which one can easily view as L.E.D corresponding to that sensor glows up and LOW SIG NAL is given to the microcontroller.

Infra-Red Sensor Array

An array of sensors arranged in a straight row pattern is bolted under the front of the robot. It is used to locate the position of line below the robot. We can use any number of sensors. If we have lesser number of sensors then the robot movement will not be smooth and it may face problems at sharp turns. If we use high number of sensors robot movement will become smooth and reliable for sharp turns, however it requires complex programming and more hardware. Thus we must choose optimum number of sensors. The distance between sensor depend on 1. Number of sensors used 2. Width of straight line 3. Distance between sensors may not be constant (it depends on the logic).

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 34

Page 35: Workshop (1)

DC MOTORS

These are very commonly used in robotics. DC motors can rotate in both directions depending upon the polarity of current through the motor. These motors have free running torque and current ideally zero. These motors have high speed which can be reduced with the help of gears and traded off for torque. Speed Control of DC motors is done through Pulse Width Modulation techniques, i.e. sending the current in intermittent bursts. PWM can be generated by 555 timer IC with adjusted duty cycle. Varying current through the motor varies the torque.

Why two motors?

By using two motors we can drive robot in any direction this mechanism is called differential drive (the third wheel is used as support and called as caster wheel which is not connected to motor)

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 35

Page 36: Workshop (1)

The following steps are to be noted in driving of motors:

We will need a set of two motors that have same rpm (revolution per minute).

We will be using differential drive mechanism. When the bot is moving straight both the motors should have equal speed. For turning one of the motor is switched off. If we switch off the left motor,

the bot will turn left and vice versa.

MOTOR DRIVER:-L293D

L293D is a bipolar motor driver IC. This is a high voltage, high current push pull four channel driver compatible to TTL logic levels and drive inductive loads. It has 600 mA output current capabilities per channel and internal clamp diodes.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 36

Page 37: Workshop (1)

The L293 is designed to provide bidirectional drive currents of upto 1 A at voltages from 4.5 V to 36 V. Both devices are designed to drive inductive loads such as relays, solenoids, dc and bipolar stepping motors, as well as other high-current/high-voltage loads in positive supply applications. All inputs are TTL compatible. Each output is a complete totem-pole drive circuit, with a Darlington transistor sink and a pseudo-Darlington source. Drivers are enabled in pairs, with drivers 1 and 2 enabled by 1,2EN and drivers 3 and 4 enabled by 3,4EN. When an enable input is high, the associated drivers are enabled, and their outputs are active and in phase with their inputs. When the enable input is low, those drivers are disabled, and their outputs are off and in the high-impedance state. With the proper data inputs, each pair of drivers forms a full-H (or bridge) reversible drive suitable for solenoid or motor applications.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 37

Page 38: Workshop (1)

For one motor:

PIN CONNECTIONS:

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 38

Page 39: Workshop (1)

Printed Circuit Board

When making the circuit with the electronic parts of the resistors, the capacitors, the transistors, the ICs and so on, it is necessary to connect the lead line of each part appropriately. Also, each part must be fixed, too. The printed circuit board is used to do the wiring among the parts and the fixation of the part.

Making PCB Steps Involved

Prepare the required circuit diagram. List out the components in the eagle software. Drawn the connection of circuit diagram in PCB format. Finish the drawn connection of circuit diagram then print out the circuit

diagram on sticker paper using by laser printer. Cut the board to final size and shape using by handsaw or jet saw. Ironing the circuit diagram pasted on the bare board (coated with a thin layer

of copper) from sticker paper and carefully take out the sticker paper from bare board and fixer the back line is not clear.

After that, drill holes on the specified places using by Portable Mini Torque Electric Drill.

This stage is removing all non-masked copper using by Etching Powder and give the board a good wash under boiling water to remove all trances of the etchant.

Carefully scrub off the mask with sandpaper on PCB. Used soldering iron to solder each component into PCB and test each

soldering point have short the circuit or not using by multimeter. Complete the PCB in this stage.

Advantages: Reliability and durability due to compact nature of the circuit especially

needed for mobile applications like robotics. Easy debugging. Large number of circuits can be made with a greater accuracy and at a cheap

cost.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 39

Page 40: Workshop (1)

Chances of loose connections get eliminated.

Disadvantages Once the circuit is made on a PCB its layout cannot be changed. PCB leads can burn at higher values of current rendering it useless for

further use PCB designing can be a tedious and time consuming process.

NOTE: The other way of making the layout on the PCB is through the use of PCB layout CAD software like Express PCB etc.

SOFTWARE OVERVIEW

Programming the Microcontroller using KEIL C-Compiler

µVision3 Overview

The µVision3 IDE is a Windows-based software development platform that

combines a robust editor, project manager. µVision3 integrates all tools including

the C compiler, macro assembler, linker/locator, and HEX file generator. µVision3

helps expedite the development process of your embedded applications by

providing the following:

Full-featured source code editor,

Device database for configuring the development tool setting,

Project manager for creating and maintaining your projects,

Integrated make facility for assembling, compiling, and linking your

embedded applications,

Dialogs for all development tool settings,

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 40

Page 41: Workshop (1)

True integrated source-level Debugger with high-speed CPU and

peripheral simulator,

Advanced GDI interface for software debugging in the target hardware

and for connection to Keil ULINK,

Flash programming utility for downloading the application program

into Flash ROM,

Links to development tools manuals, device datasheets & user’s

guides.

The following block diagram illustrates the complete µVision3 software

development cycle. Each component is described below.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 41

Page 42: Workshop (1)

Program and Description

Software for write to AT89S52 is Hex. Code, which was written by C-

language, the source code is compiled by using MC51.

Steps followed:

1. Open Keil from the Start menu

2. The Figure below shows the basic names of the windows referred in this

document

Starting a new assembler project

1. Select New Project from the Project Menu.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 42

Page 43: Workshop (1)

2. Name the project ‘Toggle.a51’

3. Click on the Save Button.

4. The device window will be displayed.

5. Select the part you will be using to test with. For now we will use the Dallas

Semiconductor part DS89C420.

6. Double Click on the Dallas Semiconductor.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 43

Page 44: Workshop (1)

7. Scroll down and select the DS89C420 Part

8. Click OK

CREATING SOURCE FILE

1. Click File Menu and select New.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 44

Page 45: Workshop (1)

2. A new window will open up in the Keil IDE.

3. Copy the example into the new window.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 45

Page 46: Workshop (1)

4. Click on File menu and select Save As…

5. Name the file Toggle.a51

6. Click the Save Button

CREATING HEX FOR THE PART

1. Click on Target 1 in Tree menu

2. Click on Project Menu and select Options for Target 1

3. Select Target Tab

4. Change Xtal(Mhz) from 50.0 to 11.0592

5. Select Output Tab

6. Click on Create Hex File check box

7. Click OK Button.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 46

Page 47: Workshop (1)

8. Click on Project Menu and select Rebuild all Target Files

9. In the Build Window it should report ‘0 Errors (s), 0 Warnings’

10. You are now ready to Program your Part.

RUNNING THE KEIL DEBUGGER:

1. The Keil Debugger should be now be Running.

2. Click on Peripherals. Select I/O Ports, Select Port 1

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 47

Page 48: Workshop (1)

2. A new window should port will pop up. This represent the Port and Pins

3. A new window should port will pop up. This represents the Port and Pins

4. Step through the code by pressing F11 on the Keyboard. The Parallel Port 1 Box should change as you completely step through the code.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 48

Page 49: Workshop (1)

5. To exit out, Click on Debug Menu and Select Start/Stop Debug Session

PROGRAMMING EXAMPLES:

From the C program to the machine language

The C source code is very high level language, meaning that it is far from being at the base level of the machine language that can be executed by a processor. This machine language is basically just zero’s and one’s and is written in Hexadecimal format, that why they are called HEX files.

figure 2.1.AThere are several types of HEX files; we are going to produce machine code in the INTEL HEX-80 format, since this is the output of the KEIL IDE that we are going to use. Figure 2.1.A shows that to convert a C program to machine language, it takes several steps depending on the tool you are using, however, the main idea is to produce a HEX file at the end. This HEX file will be then used by the ‘burner’ to write every byte of data at the appropriate place in the EEPROM of the 89S52.

Variables and constants

Variables

One of the most basic concepts of programming is to handle variables. knowing the exact type and size of a variable is a very important issue for microcontroller programmers, because the RAM is usually limited is size. There are two main

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 49

Page 50: Workshop (1)

design considerations to be taken in account when choosing the variables types: the occupied space in ram and the processing speed. Logically, a variable that occupies a big number of registers in RAM will be more slowly processed than a small variable that fits on a single register.

For you to choose the right variable type for each one of your applications, you will have to refer to the following table:

Data Type Bits Bytes Value Range

Bit 1 – 0 to 1

signed char 8 1 -128 to +127

unsigned char 8 1 0 to 255

signed int 16 2 -32768 to +32767

unsigned int 16 2 0 to 65535

signed long 32 4 -2147483648 to 2147483647

unsigned long 32 4 0 to 4294967295

Float 32 4 ±1.175494E-38 to ±3.402823E+38

This table shows the number of bits and bytes occupied by each types of variables, noting that each byte will fit into a register. You will notice that most variables can be either ‘signed’ or unsigned ‘unsigned’, and the major difference between the two types is the range, but both will occupy the same exact space in memory.

The names of the variables shown in the table are the same that are going to be used in the program for variables declarations. Note that in C programming language, any variable have to be declared to be used. Declaring a variable, will attribute a specific location in the RAM or FLASH memory to that variable. The size of that location will depend on the type of the variable that have been declared.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 50

Page 51: Workshop (1)

To understand the difference between those types, consider the following example source code where we start by declaring three ‘unsigned char’ variables, and one ‘signed char’ and then perform some simple operations:

unsigned char a,b,c;

signed char d;

a = 100;

b = 200;

c = a - b;

d = a - b;

In that program the values of ‘c’ will be equal to ’155′! and not ‘-100′ as you though, because the variable ‘c’ is an unsigned type, and when a the value to be stored in a variable is bigger than the maximum value range of this variable, it overflows and rolls back to the other limit. Back to our example, the program is trying to store ‘-100′ in ‘c’, but since ‘c’ is unsigned, its range of values is from ’0 to 255′ so, trying to store a value below zero, will cause the the variable to overflow, and the compiler will subtract the ‘-100′ from the other limit plus 1, from ’255 + 1′ giving ’156′. We add 1 to the range because the overflow and roll back operation from 0 to 255 counts for the subtraction of one bit. On the other hand, the value of ‘d’ will be equal to ‘-100′ as expected, because it is a ‘signed’ variable. Generally, we try to avoid storing value that are out of range, because sometime, even if the compiler doesn’t halt on that error, the results can be sometimes totally un-expected.

Note that in the C programming language, any code line is ended with a semicolon ‘;’, except for the lines ending with brackets ‘‘ ‘’.

Like in any programming language, the concept of a variables ‘array’ can also be used for microcontrollers programming. an array is like a table or a group of

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 51

Page 52: Workshop (1)

variables of the same type, each one can be called by a specific number, for example an array can be declared this way:

char display[10];

This will create a group of 10 variables. Each one of them is accessible by its number, example:

display[0] = 100;

display[3] = 60;

display[1] = display[0] - display[3];

Where ‘display[1]‘ will be equal to ’40′. Note that ‘display’ contains 10 different variables, numbered from 0 to 9. In that previous example, according to the variable declaration, there is not such variable location as ‘display[10]‘, and using it will cause an error in the compiler.

Constants

Sometimes, you want to store a very large amount of constant values, that wouldn’t fit in the RAM or simply would take too much space. you can store this DATA in the FLASH memory reserved for the code, but it wont be editable, once the program is burned on your chip. The advantage of this technique is that it can be used to store a huge amount of variables, noting that the FLASH memory of the 89S52 is 8K bytes, 32 times bigger than the RAM memory. It is, however, your responsibility to distribute this memory between your program and your DATA.

To specify that a variable is to be stored in the FLASH memory, we use exactly the same variable types names but we add the prefix ‘code’ before it. Example:

code unsigned char message[500];

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 52

Page 53: Workshop (1)

This line would cause this huge array to be stored in the FLASH memory. This can be interesting for displaying messages on an LCD screen.

To access the pins and the ports through programming, there are a number of pre-defined variables (defined in the header file, as you shall see later) that dramatically simplifies that task. There are four ports, Port 0 to Port 3, each one of them can be accessed using the char variables P0, P1, P2 and P3 respectively. In those char types variables, each one of the 8 bits represents a pin on the port. Additionally, you can access a single pin of a port using the bit type variables PX_0 to PX_7, where X takes a value between 0 and 3, depending on the port being accessed. For example P1_3 is the pin number 3 of port 1.

You can also define your own names, using the ‘#define’ directive. Note that this is compiler directive, meaning that the compiler will use this directive to read and understand the code, but it is not a statement or command that can be translated to machine language. For example, you could define the following:

#define LED1 P1_0

With the definition above, the compiler will replace every occurrence of LED1 by P1_0. This makes your code much more easier to read, especially when the new names you give make more sense.

You could also define a numeric constant value like this:

#define led_on_time 184

Then, each time you write led_on_time, it will be replaced by 184. Note that this is not a variable and accordingly, you cannot write something like:

led_on_time = 100; //That's wrong, you cannot change a constant's value in code.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 53

Page 54: Workshop (1)

The utility of using defined constants, appears when you want to adjust some delays in your code, or some constant variables that are re-used many times within the code: With a predefined constant, you only change it’s value once, and it’s applied to the whole code. that’s for sure apart from the fact that a word like led_on_time is much more comprehensive than simply ‘184‘!

Along this tutorial you will see how port names, and special function registers are used exactly as variables, to control input/output operations and other features of the microcontroller like timers, counters and interrupts.

Mathematical & logic operations

Now that you know how to declare variables, it is time to know how to handle them in your program using mathematical and logic operations.

Mathematical operations

The most basic concept about mathematical operations in programming languages, is the ‘=’ operator which is used to store the content of the expression at its right, into the variable at its left. For example the following code will store the value of ‘b’ into ‘a’ :

a = b;

And subsequently, the following expression in totally invalid:

5 = b;

Since 5 in a constant, trying to store the content of ‘b’ in it will cause an error.

You can then perform all kind of mathematical operations, using the operators ‘+’,'-’,'*’ and ‘/’. You can also use brackets ‘( )’ when needed. Example:

a =(5*b)+((a/b)*(a+b));

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 54

Page 55: Workshop (1)

If you include ‘math.h’ header file, you will be able to use more advanced functions in your equations like Sin, Cos and Tan trigonometric functions, absolute values and logarithmic calculations like in the following example:

a =(c*cos(b))+sin(b);

To be able to successfully use those functions in your programs, you have to know the type of variables that those functions take as parameter and return as a result. For example a Cosine function takes an angle in radians whose value is a float number between -65535 and 65535 and it will return a float value as a result. You can usually know those data types from the ‘math.h’ file itself, for example, the cosine function, like all the others is declared in the top of the math header file, and you can read the line:

extern float cos (float val);

from this line you can deduce that the ‘cos’ function returns a float data type, and takes as a parameter a float too. (the parameter is always between brackets.). Using the same technique, you can easily know how to deal with the rest of the functions of the math header file. the following table shows a short description of those functions:

Function Description

char cabs (char val);

Return the absolute value of a char variable.

int abs (int val); Return the absolute value of a int variable.

long labs (long val);

Return the absolute value of a long variable.

float fabs (float val);

Return the absolute value of a float variable.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 55

Page 56: Workshop (1)

Function Description

float sqrt (float val);

Returns the square root of a float variable.

float exp (float val);

Returns the value of the Euler number ‘e’ to the power of val

float log (float val);

Returns the natural logarithm of val

float log10 (float val);

Returns the common logarithm of val

float sin (float val);

A set of standard trigonometric functions. They all take angles measured in radians whose value

have to be between -65535 and 65535.

float cos (float val);

float tan (float val);

float asin (float val);

float acos (float val);

float atan (float val);

float sinh (float val);

float cosh (float val);

float tanh (float val);

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 56

Page 57: Workshop (1)

Function Description

float atan2 (float y, float x);

This function calculates the arc tan of the ratio y / x, using the signs of both x and ytodetermine the quadrant of the angle and return a number ranging

from -pi to pi.

float ceil (float val);

Calculates the smallest integer that is bigger than val. Example: ceil(4.3) = 5.

float floor (float val);

Calculates the largest integer that is smaller than val. Example: ceil(4.8) = 4.

float fmod (float x, float y);

Returns the remainder of x / y. For example: fmod(15.0,4.0) = 3.

float pow (float x, float y);

Returns x to the power y.

Logical operations

You can also perform logic operations with variables, like AND, OR and NOT operations, using the following operators:

Operator Description

! NOT (bit level) Example: P1_0 = !P1_0;

~ NOT (byte level) Example: P1 = ~P1;

& AND

| OR

Note that those logic operation are performed on the bit level of the registers. To understand the effect of such operation on registers, it’s easier to look at the bits of a variable (which is composed of one or more register). For example, a NOT operation will invert all the bit of a register. Those logic operators can be used in many ways to merge different bits of different registers together.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 57

Page 58: Workshop (1)

For example, consider the variable ‘P1′, which is of type ‘char’, and hence stored in an 8-bit register. Actually P1 is an SFR, whose 8 bits represents the 8 I/O pins of Port 1. It is required in that example to clear the four lower bits of that register without changing the state of the four other which may be used by other equipment. This can be done using logical operators according to the following code:

P1 = P1 & 0xF0; //Adding '0x' before a number indicates that it is a hexadecimal one

Here, the value of P1 is ANDed with the variable 0xF0, which in the binary base is ’11110000′. Recalling the two following relations:

1 AND X = X0 AND X = 0(where ‘X’ can be any binary value)

You can deduce that the four higher bits of P1 will remain unchanged, while the four lower bits will be cleared to 0.

By the way, note that you could also perform the same operation using a decimal variable instead of a hexadecimal one, for example, the following code will have exactly the same effect than the previous one (because 240 = F0 in HEX):

P1 = P1 & 240;

A similar types of operations that can be performed on a port, is to to set some of its bits to 1 without affecting the others. For example, to set the first and last bit of P1, without affecting the other, the following source code can be used:

P1 = P1 | 0x81;

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 58

Page 59: Workshop (1)

Here, P1 is ORed with the value 0×81, which is ’10000001′ in binary. Recalling the two following relations:

1 OR X = 10 OR X = X(where ‘X’ can be any binary value)

You can deduce that the first and last pins of P1 will be turned on, without affecting the state of the other pins of port 1. Those are just a few example of the manipulations that can be done to registers using logical operators. Logic operators can also be used to define very specific conditions, as you shall see in the next section.

The last types of logic operation studied in this tutorial is the shifting. It can be useful the shift the bit of a register the right or to the left in various situations. this can be done using the following two operators:

Operator Description

>> Shift to the right

<< Shift to the left

The syntax is is quite intuitive, for example:

P1 = 0x01; // After that operation, in binary, P1 = 0000 0001

P1 = (P1 << 7) // After that operation, in binary P1 = 1000 0000

You can clearly notice that the content of P1 have been shifted 8 steps to the left.

Conditions and loops

In most programs, it is required at a certain time, to differentiate between different situations, to make decision according to specific input, or to direct the flow of the code depending on some criteria. All the above situation describe an indispensable aspect of programming: ‘conditions’. In other words, this feature allows to execute

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 59

Page 60: Workshop (1)

a block of code only under certain conditions, and otherwise execute another code block or continue with the flow of the program.

The most famous way to do that is to use the ‘if’ statement, according to the following syntax.

if (expression)

...

code to be executed

...

It is important to see how the code is organized in this part. The ‘expression’ is the condition that shall be valid for the ‘code block’ to be executed. the code block is all delimited by the two brackets ‘‘ and ‘’. In other words, all the code between those two brackets will be executed if and only if the expression is valid. The expression can be any combination of mathematical and logical expressions, as you can see in the following example:

if ( (P1 == 0) & (a <= 128) )

...

code to be executed

...

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 60

Page 61: Workshop (1)

Notice the use of the two equal signs (==) between two variables or constants, In C language, this means that you are asking whether P1 equals 0 or not. writing this expression with only one equal sign, would cause the the compiler to store 0 in P1. This issue is a source of logical error for many beginners in C language, this error wont generate any alert from the compiler and is very hard to identify in a big program, so pay attention, it can save you lot of debugging time. Otherwise it is clear that in that previous example, the code block is only executed if both the two expressions are true. Here is a list of all the operators you can use to write an expression describing a certain condition:

Operator Description

== Equal to

<, > Smaller than, bigger than.

<=, >= Smaller than or equal to, bigger than or equal to.

!= Not equal to

The ‘If’ code block can get a little more sophisticated by introducing the ‘else’ and ‘else if’ statement. Observe the following example source code:

if (expression_1)

...

code block 1

...

else if(expression_2)

...

code block 2

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 61

Page 62: Workshop (1)

...

else if(expression_3)

...

code block 3

...

else

...

code block 4

...

Here, There are four different code blocks, only one shall be executed if and only if the corresponding condition is true. The last code block will only be executed if none of the previous expression is valid. Note that you can have as many ‘else if’ blocks as you need, each one with its corresponding condition, BUT you can only have one ‘else’ block, which is completely logical. However you can chose not to have and ‘else’ block at all if you want.

There are some other alternatives to the ‘if…else’ code block, that can provide faster execution speeds, but also have some limitations and restrictions like the ‘Select…case’ code block. For now, it is enough to understand the ‘if…else’ code block, whose performance is quite fair and have a wide range of applications.

Another very important tool in the programming languages is the loop. In C language like in many others, loops are usually restricted to certain number of

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 62

Page 63: Workshop (1)

loops like in the ‘for’ code block or restricted to a certain condition like the ‘while’ block.

Let’s start with the ‘for’ code block, which is a highly controllable and configurable loop. consider the following example source code:

for(i=0;i<10;i++)

P0 = i;

Here the code between the the two brackets ‘‘ ‘’ will be be executed a certain number of times, each time with the counting variable ‘i’ increasing by 1 according to the statement ‘i++’. The code will keep looping as long as the condition ‘i<10′ is true. Usually the counting value ‘i’ is reused in the body of the loop, which makes the particularity of this loop. The ‘for’ loop functioning can be recapitulated by the following syntax:

for(start;condition;step)

...

code block

...

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 63

Page 64: Workshop (1)

Where start represents the start value assigned to the count value before the loop begins. The condition is the expression that is is to remain true for the loop to continue; as long as this conditions is satisfied, the code will keep looping. Finally, step is the increase or decrease of the counting variable, it can be any statement that changes its value, whether by an addition or subtraction.

The second type of loop that we are going to study is the ‘while’ loop. the syntax of this one is simpler than the previous one, as you can observe in the following example source code, that is equivalent to the previous method:

while(i < 10)

P0 = i;

i = i +1;

Here there is only one parameter to be defined, which is the condition to keep this loop alive, which is ‘i < 10′ in our example. Then, it is the responsibility of the programmer to design the software carefully to provide an exit for that loop, or to make it an infinite loop. Both techniques are commonly used in microcontroller programs, as you shall see later on along this tutorial.

Functions

Functions are way of organizing your code, reducing its size, and increasing its overall performance, by grouping relatively small parts of code to be reused many times in the same program. A new function can be created according to the following syntax:

Function_name(parameter_1, Parameter_2, Parameter_3)

...

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 64

Page 65: Workshop (1)

function body

...

return value //optional

...

This is the general form of a function. The number of parameters of the function can be more than the three parameters of the examples above, as it can be zero, all depends on the type and use of the function. The function’s body is usually a sub program that implies the parameters to produce the required result. some functions will also generate an output, like the cos() function, through the ‘return’ command, which will output the value next to it. Usually the ‘return’ command is used at the end of the function.

A very common use of functions without return value is to create delays in a software, consider the following function:

delay(unsigned int y)

unsigned int i;

for(i=0;i<y;i++)

;

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 65

Page 66: Workshop (1)

In this last piece of code a function named ‘delay’ is created, with an unsigned integer ‘y’ as a parameter, and implying a locally defined unsigned int ‘i’. the function will repeat a loop for a couple hundreds or thousand of times to generate precise delays in a program. A function like this can be called from anywhere in the program according to the following syntax:

delay(30000);

this line of code would cause the program to pause for approximately one second on a 12 MHz clock on a 8051 microcontroller.

A common example of a function with a return value, is a function that will calculate the angle in radian of a given angle in degrees, as all the trigonometric functions that are included by default take angles in radians. This function can be as the following:

deg_to_rad(float deg)

float rad;

rad = (deg * 3.14)/180;

retrun rad;

This function named ‘deg_to_rad’ will take as a parameter an angle in degrees and output an angle in radians. It can be called in your program according to this syntax:

angle = deg_to_rad(102,18);

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 66

Page 67: Workshop (1)

Where angle should be already defined as a float, and where will be stored the value returned by the function, which is the angle in radians equivalent to 102.18°

Another important note about functions in the ‘main’ function. Any C program must contain a function named ‘main’ which is the place where the program’s execution will start. more precisely, for microcontrollers, it were the execution will start after a reset operation, or when a microcontroller circuit is turned ON. The ‘main’ function has no parameters, and is written like this:

main()

...

code of the main functions

...

Organization of a C program

All C programs have this common organization scheme, sometimes it’s followed, sometimes it’s not, however, it is imperative for this category of programming that this organization scheme be followed in order to be able to develop your applications successfully. Any application can be divided into the following parts, noting that is should be written in this order:

1. Headers Includes and constants definitionsIn this part, header files (.h) are included into your source code. those headers files can be system headers to declare the name of SFRs, to define new constants, or to include mathematical functions like trigonometric functions, root square calculations or numbers approximations. Header files can also contain your own functions that would be shared by various programs.

2. Variables declarationsMore precisely, this part is dedicated to ‘Global Variables’ declarations. Variables declared in this place can be used anywhere in the code. Usually in

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 67

Page 68: Workshop (1)

microcontroller programs, variables are declared as global variables instead of local variables, unless your are running short of RAM memory and want to save some space, so we use local variables, whose values will be lost each time you switch from a function to another. To summarize, global variables as easier to use and implement than local variables, but they consume more memory space.

3. Functions’ bodyHere you group all your functions. Those functions can be simple ones that can be called from another place in your program, as they can be called from an ‘interrupt vector’. In other words, the sub-programs to be executed when an interrupt occurs is also written in this place.

4. InitializationThe particularity of this part is that it is executed only one time when the microcontroller was just subjected to a ‘RESET’ or when power is just switched ON, then the processor continue executing the rest of the program but never executes this part again. This particularity makes it the perfect place in a program to initialize the values of some constants, or to define the mode of operation of the timers, counters, interrupts, and other features of the microcontroller.

5. Infinite loopAn infinite loop in a microcontroller program is what is going to keep it alive, because a processor have to be allays running for the system to function, exactly like a heart have to be always beating for a person to live. Usually this part is the core of any program, and its from here that all the other functions are called and executed.

Simple C program for 89S52

Here is a very simple but complete example program to blink a LED. Actually it is the source code of the example project that we are going to construct in the next part of the tutorial, but for now it is important to concentrate on the programming to summarize the notions discussed above.

#include <REGX52.h>

#include <math.h>

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 68

Page 69: Workshop (1)

delay(unsigned int y)

unsigned int i;

for(i=0;i<y;i++);

main()

while(1)

delay(30000);

P1_0 = 0;

delay(30000);

P1_0 = 1;

After including basic headers for the SFR definitions of the 8952 microcontroller (REGX52.h) and for mathematical functions (math.h), a function named ‘delay’ is created, which is simple a function to create a delay controlled via the parameter ‘y’. Then comes the main function, with an infinite loop (the condition for that loop to remain will always be satisfied as it is ’1′). Inside that loop, the pin number 0 of port 1 is constantly turned ON and OFF with a delay of approximately one second.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 69

Page 70: Workshop (1)

As you will see in the next part, A simple circuit can be constructed and a LED can be connected to the pin P1_0 to see how software and hardware adjustments can affect the behavior of you circuits.

Using the KEIL environment

KEIL uVision is the name of a software dedicated to the development and testing of a family of microcontrollers based on 8051 technology, like the 89S52 which we are going to use along this tutorial. You can can download an evaluation version of KEIL at their website: http://www.keil.com/c51/. Most versions share merely the same interface, this tutorial uses KEIL C51 uVision 3 with the C51 compiler v8.05a.

To create a project, write and test the previous example source code, follow the following steps:

Open Keil and start a new project:

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 70

Page 71: Workshop (1)

2.8.A You will prompted to chose a name for your new project, Create a separate folder

where all the files of your project will be stored, chose a name and click save. The following window will appear, where you will be asked to select a device for Target ‘Target 1′:

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 71

Page 72: Workshop (1)

figure 2.8.B From the list at the left, seek for the brand name ATMEL, then under ATMEL,

select AT89S52. You will notice that a brief description of the device appears on the right. Leave the two upper check boxes unchecked and click OK. The AT89S52 will be called your ‘Target device’, which is the final destination of your source code. You will be asked whether to ‘copy standard 8051 startup code‘ click No.

Click File, New, and something similar to the following window should appear. The box named ‘Text1′ is where your code should be written later.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 72

Page 73: Workshop (1)

figure 2.8.C Now you have to click ‘File, Save as’ and chose a file name for your source code

ending with the letter ‘.c’. You can name is ‘code.c’ for example, and click save. Then you have to add this file to your project work space at the left as shown in the following screen shot:

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 73

Page 74: Workshop (1)

figure 2.8.D After right-clicking on ‘source group 1‘, click on ‘Add files to group…‘, then you

will be prompted to browse the file to add to ‘source group 1′, chose the file that you just saved, eventually ‘code.c’ and add it to the source group. You will notice that the file is added to the project tree at the left.

In some versions of this software you have to turn ON manually the option to generate HEX files. make sure it is turned ON, by right-clicking on target 1, Options for target ‘target 1′, then under the ‘output‘ tab, by checking the box ‘generate HEX file‘. This step is very important as the HEX file is the compiled output of your project that is going to be transferred to the micro-controller.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 74

Page 75: Workshop (1)

You can then start to write the source code in the window titled ‘code.c’ then before testing your source code, you have to compile your source code, and correct eventual syntax errors. In KEIL IDE, this step is called ‘rebuild all targets’ and has this icon: .

figure 2.8.E You can use the output window to track eventual syntax errors, but also to check

the FLASH memory occupied by the program (code = 49) as well as the registers occupied in the RAM (data = 9). If after rebuilding the targets, the ‘output window’ shows that there is 0 error, then you are ready to test the performance of your code. In KEIL, like in most development environment, this step is called

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 75

Page 76: Workshop (1)

Debugging, and has this icon: . After clicking on the debug icon, you will notice that some part of the user interface will change, some new icons will appear, like the run icon circled in the following figure:

figure 2.8.F You can click on the ‘Run’ icon and the execution of the program will start. In our

example, you can see the behavior of the pin 0 or port one, but clicking on ‘peripherals, I/O ports, Port 1′. You can always stop the execution of the program by clicking on the stop button ( ) and you can simulate a reset by clicking on the ‘reset’ button .

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 76

Page 77: Workshop (1)

You can also control the execution of the program using the following icons: which allows you to follow the execution step by step. Then, when you’re finished with the debugging, you can always return to the programming interface by clicking again on the debug button ( ).There are many other features to discover in the KEIL IDE. You will easily discover them in first couple hours of practice.

we are going to study the basic structure and configuration of I/O ports. Then we are going to apply this

theory on simple experimental projects, using a LED and switch, to experiment with the different I/O

features of the micro-controller.

At this point of the tutorial, we are going to transfer programs to the microcontroller, using an ISP (In

System Programmer). If you don’t have one, you can build one here. Along all the tutorial, we are going

to use our ISP connector.

I/O port detailed structureIt is important to have some basic notions about the structure of an I/O port in the 8051 architecture. You

will notice along this tutorial how this will affect our choices when it comes to connect I/O devices to the

ports. Actually, the I/O ports configuration and mechanism of the 8051 can be confusing, due to the fact

that a pin acts as an output pin as well as an input pin in the same time.

figure 3.1.A

Figure 3.1.A shows the internal diagram of a single I/O pin of port 1. The first thing you have to notice, is

that there are two different direction for the data flow from the microcontroller’s processor and the external

pin: The Latch value and the Pin value. The latch value is the value that the microcontroller tries to output

on the pin, while the pin value, is the actual logic state of the pin, regardless of the latch value that was

set by the processor in the first place. The microcontroller reads the state of a pin through the Pin value

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 77

Page 78: Workshop (1)

line, and writes through the latch value line. If you imagine the behavior of the simple circuit in figure

3.1.A, you’ll notice that the I/O pin should follow the voltage of the Latch value, providing 5V through the

pull-up resistor, or 0V by connecting the pin directly to the GND through the transistor.

When the pin is pulled high by the pull-up resistor, the pin can output 5V but can also be used as an input

pin, because there is no any risk of short-circuit due to the presence of a resistor. This can be easily

verified by connecting the pin to 0V or to 5V, the two possible outcomes are both unharmful for the

microcontroller, and the PIN value line will easily follow the value imposed by the external connection.

Now imagine the opposite configuration, where the latch value would be low, causing the pin to provide

0V, being directly connected to GND through the transistor. If in this situation, an external device tries to

raise the pin’s voltage to 5V, a short circuit will occur and some damage may be made to the micro-

controller’s port or to the external device connected to that pin.

To summarize, in the 8051 architecture, to use a PIN as an input pin, you have to output ’1′, and

the pin value will follow the value imposed by the device connected to it (switch, sensor, etc…). If

you plan to use the pin as an output pin, then just output the required value without taking any of

this in consideration.

Even if some ports like P3 and P0 can have a slightly different internal composition than P1, due to the

dual functions they assure, understanding the structure and functioning of port 1 as described above is

fairly enough to use all the ports for basic I/O operations.

Simple output project: Blinking a ledA first simple project to experiment with the output operations is to blink a LED. Assuming you have

successfully written and compiled the code as explained in the previous part of the tutorial, now we are

going to transfer the HEX file corresponding to that code on the 89s52 microcontroller. Let us recall that

the HEX file is a machine language file, generated by the compiler, originally from a C code.

The code for blinking a LED is as follow:

#include <REGX52.h>

#include <math.h>

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 78

Page 79: Workshop (1)

delay(unsigned int y)

unsigned int i;

for(i=0;i<y;i++);

main()

while(1)

delay(30000);

P1_0 = 0;

delay(30000);

P1_0 = 1;

Before transferring the HEX file to the target micro-controller, the hardware have to be constructed. First

you have to provide a clean (noiseless) 5V power supply, by connecting the Vcc pin (40) to 5V and the

GND pin (20) to 0V. Then you have provide a mean of regulating or generating the clock of the processor.

The easiest and most efficient way to do this is to add a crystal resonator and two decoupling capacitors

of approximately 30 pF (see the crystal X1 and the capacitors C1 and C2 on figure 3.2.A). Then, you have

connect pin 31 (EA) to 5V. The EA pin is an active low’ pin that indicate the presence of an external

memory. Activating this pin by providing 0V on it will tell the internal processor to use external memories

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 79

Page 80: Workshop (1)

and ignore the internal built-in memory of the chip. By providing 5V on the EA pin, its functionality is

deactivated and the processor uses the internal memories (RAM and FLASH). At last, you have to

connect a standard reset circuitry on pin 9 composed of the 10 Kohm resistor R2 and the 10 uF capacitor

C3, as you can see in the schematic. You can also add a switch to short-circuit pin 9 (RST) and 5V giving

you the ability to reset the microcontroller by pressing on the switch (the processor resets in a high level is

provided on the RST pin for more than 2 machine cycles).

Those were the minimum connections to be made for the microcontroller to be functional and able to

operate correctly. According to the fact that we are going to use an ISP programmer, A connector is

added by default to allow easy in system programming.

For our simple output project, a LED is connected to P1.0 through a 220 ohm resistor R1, as you can see

in figure 3.2.A below. Note that there are other ways to connect the LED, but now that you understand

the internal structure of the port, you can easily deduce that this is the only way to connect the LED so

that the current is fully controlled by the external resistor R1. Any other connection scheme would involve

the internal resistor of the port, which is ‘uncontrollable’.

Note that the reset switch and R/C filter are not present on this breadboard, the reset functionality of the

ISP cable was used instead.

At this stage, you can finally connect your ISP programmer, launch the ISPprog software, browse the

HEX file for programming the FLASH, and transfer it to the micro-controller, as described in the ISP page.

You can eventually use any other available programming hardware and/or software.

If all your connections are correct, you should see the LED blinking as soon as the programming

(transfer) is finished. You can experiment with different delay in the code to change the blinking

frequency. Don’t forget that for any change to take place, you have to rebuild your source code,

generating a new hex file (replacing the old one) and retransfer the freshly generated HEX file to the

micro-controller.

FINDINGS / PROBLEMThis is intended as a step-by step guide to what to do when things go wrong. One of the projects successful is debug the solution from failure, for example like line

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 80

Page 81: Workshop (1)

tracking of line follower robot must know how to calculate the degree of turning, interrupt of infrared sensor circuit, wire socket’s connection problem, front motor of racing toy car spoiled and etc. The following below is showing list of the troubleshooting to build line follower robot.

1. Make sure the voltage regulator LM7805 convert largest voltage like 30V to 5V, and used the multimeter for measure voltage output of LM7805.

2. Infrared sensor (transmitter and detector) must give some distance and cannot too close together.

3. Used a black tape put on the infrared sensor – transmitter and detector surface and observed a LED is lighted or not. (please refer to appendix figure 3c) If the LED is lighted that means the infrared sensor – transmitter in the bad condition because infrared sensor cannot detect any black colour surface. In opposite case, the infrared sensor is the good condition when the LED is lighted up.

4. Used camera and mobile phone camera to capture the infrared sensor, when it connected with 5V power supply. This is test for infrared sensor functioning or not, if the purple light will come out from the transmitter when camera sighted it. This is a good condition of infrared sensor.

5. In the sunshine condition, the infrared sensor will be dysfunction because ultraviolet light affect the infrared sensor and always detected ultraviolet light to make the reflection to infrared sensor.

6. An infrared sensor place in the correct side, for example such as left infrared sensor detect the white surface

7. Make sure all IC chip pins not spoiled, this will affect the operated of line follower robot. Insert and pull out all IC chip from breadboard with carefully to avoid IC chip pin spoiled.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 81

Page 82: Workshop (1)

8. Make sure wire connected with the Printed Circuit Board (PCB) are not loose for dysfunction. The large number of wire connection in the circuit made it too difficult to solder.

9. Please double check the soldering point in Printed Circuit Board (PCB) for confirm all soldering point on the Printed Circuit Board (PCB) are corrected and without short circuit.

10. Soldering iron/gun place in the safety area when soldering component into the Printed Circuit Board (PCB).

11. All wire must keep into fixed place for avoid any blocking example like wheel of racing toy car, base racing toy car and etc.

12. A variable resistor must connect with one resistor before to 5V power supply because protection and prevent burn off the variable resistor.

13.Connected the diode with DC Motor (toy racing car) for avoid feedback current spoiled the whole circuit.

14. Cut the black carpet must careful because route have a turning point, if wrongly cut then will make racing toy car out of the route.

15. The distance between two pair of infrared sensors is 2cm; the path for line follower robot must be over 2cm.

16. The surface of route without any white dot or else, this will affect result of operated.

17. Make sure connection of the AT89S52 in the correct position, if not there will spoil the microcontroller.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 82

Page 83: Workshop (1)

18. The program will be difficult to implement microcontroller programming in assembly language. So prefer C language.

19. Used the screw to fix the position of motor and wheel for prevent the wheel loose and lost when line follower robot operated.

20. In the model designed to show line follower robot, DC motor should be decreased high voltage by diode and should draw less current otherwise high motor current will damage the entire circuit.

21. Make sure drill holes on strip boards with carefully, because this will make the strip board shock circuits.

Practical applications of a line follower

Automated cars running on roads with embedded magnets; guidance system for industrial robots moving on shop floor etc.

Line follower robot is machines that can be follow a specified route. For example as a black line on a white surface can become the route. The line follower robot’s application is an automated car running road with petrol free. This is harmless to our environment protection and save natural resources.

ASSURE GLOBAL SOLUTIONS E-MAIL:[email protected]. ph.no:+91-40-65555388 Page 83