baby steps to a line tracking bot (using part readily available in bangladesh)

Upload: amman1234

Post on 05-Apr-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 Baby Steps to a Line Tracking Bot (using part readily available in bangladesh)

    1/13

    Baby steps to a Line tracking bot Line tracking is one of the initial steps to basic Robotics. In this tutorial Ill try to illustrate all the steps tobuild a line tracker of your own. Ill try to tell you about what little I learned from our countless mistakes

    and a little success at the end of the tunnel. Hope that you find this useful in constructing your own LineFollowing Bot.

    Firstly, we should always keep in mind that from an Engineering point of view our bot should be delicateand precise. So we should always go for the smallest possible design. A fairly small design has its ownadvantages what you will find as we proceed. However, you must try to make your bot as small aspossible.

    Now for starters we need a structure that can actually move and we must be able to control its directionas we wish. We have quite a large number of choices here. We may build a 4-wheeler or a 3-wheeler oreven a 2-wheeler.A 2-wheeler is quite spectacular, but just like everything else, what looks so great mayactually prove very dumb when it really counts. What Im trying to say is that it looks great butcontrolling it precisely is quite a different story. That takes it out off the table.

    Then we decide on how to control the direction. In a steering system (i.e Used in actual cars and toycars) power is applied to one pair of wheels and the other pair is used to control the direction. The rearwheels (on a single shaft) are powered to provide intended speed rotating on a fixed position and thefront wheels are steered ). It is a quite good mechanism but if you have to build it yourself then itbecomes fairly difficult. That leaves us with none but the Differential Drive scheme.

    The Differential Drive scheme utilizes thedifference between the speeds of the right andleft wheel or wheels (coupled to different shaftand powered by different motors). Here thevery same wheel pair is used for directionalcontrol which is also powered.

    We may use both the rear and the front wheelsfor this. Then the front and rear right wheelsare coupled together with some gear or timingbelt arrangement and the left wheels onanother like the following figure.

  • 7/31/2019 Baby Steps to a Line Tracking Bot (using part readily available in bangladesh)

    2/13

    Obviously a gear or timing belt-arrangementcomplicates the mechanical design greatly. Sowell use either the fro nt wheels or the rear to

    control the direction. The other pair of wheelswill just be dragged. The wheels that aresupposed to be dragged must be capable of freemoving through an angle of 360. Caster wheelsserve this purpose quite well, but caster balls

    are obviously better choice. Since draggedwheels are just meant to support the bot abovethe ground, we may as well use only oneinstead of two. Actually its the smarter thing todo.

    Caster WheelCaster Ball

  • 7/31/2019 Baby Steps to a Line Tracking Bot (using part readily available in bangladesh)

    3/13

    Two wheels powered with two motors and a caster wheel

    So in a nutshell for the mechanical structure you need:

    2 DC or geared DC motors (For high torque, causing high weight handling capacity). 2 wheels. An arrangement to couple the wheels with the motors. 1 or 2 caster wheels/balls. A strong platform that holds the full arrangement. It is the main body of the bot. An arrangement to place the motor and the wheel system on or below the main platform.

    Motors & wheels

    There are some options that we can choose from. Consider yourself very lucky if you can salvage twoidentical motors and wheels from an old toy of yours, but its highly unlikely that you will be that lucky.So we, the ordinary unlucky human beings, may purchase the motors from Dholaikhal or patuatuli. Those who have already experienced the Dholai, they know, but a word of advice for those whodidnt, Nothing is as costly as they are asked for, so keep hustling until they are ready to pass.

    You may use an ordinary DC motor, but youll find that at rated voltage it has a very high rpm (speed),but the torque is quite low. It may not prove suitable for your Line Following Bot. Then you should buy ageared DC motor ( Ask for Gear Motor, while purchasing ), but make sure that the speed of the motor iswell suited for your line follower. The difference between a DC motor and a geared DC motor is that aDC motor is faster than a Geared DC motor, but a Geared DC motor provides greater torque. Otherwisespeaking, it can carry a greater weight.

  • 7/31/2019 Baby Steps to a Line Tracking Bot (using part readily available in bangladesh)

    4/13

    While buying the motors-

    1. You must consider the size of the motor (Shouldnt be too large and the weight should be aslight as possible).

    2. Test the motors by supplying them exactly the same voltage that you intend to use on your line

    follower. While testing connect both the motors in parallel with the voltage sourcesimultaneously. Observe the speed of the motors. You should not expect to get 2 motors withidentical speed, but make sure that u pick the 2 motors with the closest speed. Its a good ideato take your own battery to check.

    Now that we have the motors, where do we find the wheels? You may buy plastic wheels or use wheelsfrom toy cars, but whatever you do, the challenge here is to couple the wheel with the motor shaft.Keep that in mind while selecting the wheel.

    You have another option. You can in fact have a customized wheel according to your requirements, thenyou wont have any trouble coupling the wheel with the motor shaft. To do that youll need to buyNylon rod (Cylindrical plastic rod available in diameter size ranging from .5 to 12). First decide on thediameter of the wheel of your Line Follower. Then buy a piece of nylon rod with diameter 0.5 largerthan that of your wheel (e.g. wheel diameter 1.5, then rod diameter 2). Youll get this nylon rod inNababpur . They have a minimum amount that youll have to buy. So I suggest that consult with otherteams who also intend to use the same sized nylon rod and buy together. Itll save you some money.

    What do I do with the Nylon rod?....Go to a machine shop with the Nylon rod and the Motors. Tell themto make you a pair of wheel with diameter X, thickness Y and also tell them to make necessary arrangements to couple the wheels with the motor shafts. Theyll take care of everything. If you arepatient enough, go to BUET machine shop, but to get their service you have to fill up a job requisitionform and get it authorized by a teacher. Alternatively, you can get it done from any machine shop inLalbagh , though it may be costly.

    As the third option, you can get a light-weight motor with a gear box and a quite good wheel all coupledexcellently. In this case you dont need to do anything by yourself, just buy two of these sets (@

    Tk.350/set) and youre good to go. A metal caster ba ll also comes with these pair of motor-gear-wheelset. Youll get these at Patuatuli (Store: Telecom Spares). Be very careful if you go for this motor-gear-wheel set. You must check the speeds of the wheels in the exact same way previously described. Makesure that the speeds of the two wheel sets are fairly close.

  • 7/31/2019 Baby Steps to a Line Tracking Bot (using part readily available in bangladesh)

    5/13

    You may wonder, Why bother with all that Nylon rod or machine shop , if I can get it done so easily? I just wanted to lay all the options before you and let you pick one. Personally, I would prefer buying themotor-gear-wheel sets if the speeds are close enough.

    The Body (Chassis) of the BOT

    The chassis holds the control circuit, sensors, battery and also the motors. If your motors, gear box,battery are small enough you may just use the PCB*** (Printed Circuit Board) as the chassis. It keeps thesize of the BOT small and saves you the trouble to find a separate chassis if you already have a PCB.

    In the above figure you can see the PCB containing the control circuit holds the motor-wheelarrangement, batteries and also the sensors. The visible steel structure is a part of the moto-gear.

    But the question arises what if we dont use a PCB. Firstly, Id obviously pref er building a Line Followerwith a PCB to another one containing a bread-board because PCB is safer and neat. There is always aprobability with bread- board that the connections may get lose while operating and its messy as well asa bit ugly.

  • 7/31/2019 Baby Steps to a Line Tracking Bot (using part readily available in bangladesh)

    6/13

    If your components are too heavy to be supported by merely a PCB, you should use a simple chassis likethis-

    You may use particle board or Plexiglass. Plexiglass is lighter and nice to watch. You can buy Plexiglass atKataban. Its not that costly.

    Now that weve all the mechanical components, the question is how we assemble them together.Youve already seen an arrangement in the above figure. The motor is positioned below the chassis witha metal clamp and screws. You can get these clamps at plumbing store at Nababpur . If you havebought the motor-gear-wheel set, previously described then, you dont need these clamps. The gear boxhas a rectangular shape. So one of its plain surfaces can be easily glued to the chassis or the PCB. Youmay use super glue o r you can use a Glue gun****.

  • 7/31/2019 Baby Steps to a Line Tracking Bot (using part readily available in bangladesh)

    7/13

    Electrical DesignThe key components of the electrical design

    I. BatteryII. Sensors

    III. MicrocontrollerIV. Motor driver

    Battery

    You should choose your battery according to your motor requirements. The major power consumingcomponents of the design is the motors and the sensors. The microcontroller consumes a very low

    amount of power. Of all the batteries available at the market, mobile phone batteries(Lithium-ion) seemto be the best choice. It s comparatively lighter and being flat surfaced very easy to place on the chassissurface. Such batteries are available with around 1200mAh or even more which is quite impressive. Theyare typically rated 3.7 volts. So you should use a series combination of such batteries to get the desiredvolt age. A frequently asked question so far is How do I recharge the batteries?.You may use universalcharger(known as Auto-chargers) or just apply a slightly larger voltage to the series combination.(e.g. If you have a series combination of 3 batteries, then you has to apply a voltage slightly larger than3.7*3,say 12 volts with the same polarity). Connect the battery +ve to supply +ve and battery ve tosupply - ve. Then again another problem arises, Where do I get the supply voltage?. You may use anadapter or make your own DC power supply with a small transformer, rectifier, voltage regulator ICs(e.g.7805, 7812 etc.) and a couple of capacitors.

    There are some better options than the previously described. You may use rechargeable battery packs,but theyre quite hard to find.

    Sensors

    To differentiate between black and white well use the quantitative difference of reflection of light bydifferent colored surfaces. Typically the track and the field are designed to have the maximum colorcontrast (e.g. Black & White) to aid the smooth operation of the line trackers.

  • 7/31/2019 Baby Steps to a Line Tracking Bot (using part readily available in bangladesh)

    8/13

    The fundamental idea is very simple. A set of light source (Transmitter-TX) and a lightsensitive circuit element (Receiver-RX) is used

    as a sensor. A number of such TX-RX sets areplaced at suitable positions at the front of theline follower. The light transmitted from the TXis reflected by the surface below. If surface iswhite the reflected light intensity is high, but if the surface is black the reflected light intensityis very low. That is how the Bot senses the colorof the surface, it is on.

    You have two options at hand. You may use visible light or infrared light for this sensor mechanism. Incase of visible light, an ordinary LED is used as TX and a LDR (Light Dependent Resistors) as RX. Forinfrared light, you have to use an Infrared transmitter as TX and Infrared receiver as RX.

    Since well be using a digital control circuit, we have to convert the analogue response of the sensor to adigital signal. For this purpose an Op-amp proves handy. A sample circuit configuration of a singlesensor is given below-

    10k

  • 7/31/2019 Baby Steps to a Line Tracking Bot (using part readily available in bangladesh)

    9/13

    You may wonder why Ive used a POT. This POT is required to set the reference voltage. This process of setting the reference voltage is called Sensor Calibration. In order to calibrate a sensor referencevoltage, first measure the voltages at pin no. 3 (+ve or non-inverting input pin)of the op-amp placingthat sensor on a black surface and then on a white surface ( Given your field and track are colored black& white). Take the average of these two voltages and set the POT to give a voltage at pin no. 2 (-ve orinverting input pin) of the op-amp equal to the reference. In this sample Ive used LED & LDR. ForInfrared TX-RX pair, just replace the LED by Infrared transmitter & replace the LDR by a infrared receiverin opposite polarity. Connect the shorter pin of the receiver to the VCC (+5V). The digital output of theop-amp can be directly fed into the desired I/O pin of the microcontroller.

    There is a better choice. Since typical microcontrollers provide ADC (Analogue to Digital Conversion)features, we can avoid all the hardware ambiguity previously described. We feed the analogue responseof the sensors directly to the predefined ADC pins of the microcontroller and the microcontroller itself does the conversion. Then the circuit comes down to this-

    The transmitter is not shown here. If you use ADC, it saves you the troubles to calibrate all the sensorsmanually. You can program the uC to do the calibration itself. This is way more faster and accurate thanmanual calibration.

  • 7/31/2019 Baby Steps to a Line Tracking Bot (using part readily available in bangladesh)

    10/13

    I used Atmega32(Microcontroller) for on board control. It has 8 ADC channels (PA0 to PA7). So amaximum number of 8 sensors can be used with this chip. Here is a sample code to get the ADC result of any channel. This code is written for AVR studio 4. I used Internal RC osc. 8MHz.

    //Initialize ADC with reference VCC=5V(vcc & Avcc shorted. A capacitor between Aref & GND)

    void InitADC(){DDRA=0X00;ADMUX=(1

  • 7/31/2019 Baby Steps to a Line Tracking Bot (using part readily available in bangladesh)

    11/13

    The hardware connection:

    The transmitter is not shown here. This sums up the sensor part.

    Motor DriverSince we are using DC motor an H-bridge is the appropriate choice for driving the motors. L293D is an H-bridge package that provides two channels with full directional control. So its best suited for ourpurpose here. For further details on DC motor driver try this video tutorial-

    1st seg: http://www.youtube.com/watch?v=A7vMx2xz6Y0&feature=youtu.be

    2nd seg: http://www.youtube.com/watch?v=LG_7OfsoxFo&feature=youtu.be

    http://www.youtube.com/watch?v=A7vMx2xz6Y0&feature=youtu.behttp://www.youtube.com/watch?v=A7vMx2xz6Y0&feature=youtu.behttp://www.youtube.com/watch?v=A7vMx2xz6Y0&feature=youtu.behttp://www.youtube.com/watch?v=LG_7OfsoxFo&feature=youtu.behttp://www.youtube.com/watch?v=LG_7OfsoxFo&feature=youtu.behttp://www.youtube.com/watch?v=LG_7OfsoxFo&feature=youtu.behttp://www.youtube.com/watch?v=LG_7OfsoxFo&feature=youtu.behttp://www.youtube.com/watch?v=A7vMx2xz6Y0&feature=youtu.be
  • 7/31/2019 Baby Steps to a Line Tracking Bot (using part readily available in bangladesh)

    12/13

    MicrocontrollerIve used Atmega32 chip with Int. RC Osc. 8MHz. All the codes provided here are written for AVR Studio4. Ive used PWM feature of the uC along with the L293D to control the speed of the motors. The complete circuit diagram of the simplest on board controller-

    A sample PWM code is provided below. Ive used 10 bit phase correct PWM mode of Timer/Counter1.

    //this function initializes PWMpwm_init(){

    //Initialize 10 bit phase correct PWM of TC1TCCR1A |= (1

  • 7/31/2019 Baby Steps to a Line Tracking Bot (using part readily available in bangladesh)

    13/13

    Now that we have all the components and code segments, we have to implement the designed circuit.As Ive said before, you should use a PCB. Once you have designed your circuit in PROTEUS, designing aPCB is quite easy. For further details on designing PCB-

    That was a detail description of the simplest form of Line follower. You yet need an algorithm tooperate your line follower. You may resort to PID algorithms . For real time hardware debugging youmay also add a 16*2 LCD on your line follower. Above all, your prime target is to reach a point of compromise between speed and precision, between size and difficulty of construction. Hope that myeffort will help you.

    Prepared by-M. A. Awalemail: ` [email protected]