Vous êtes sur la page 1sur 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 to build 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 Line Following Bot. Firstly, we should always keep in mind that from an Engineering point of view our bot should be delicate and precise. So we should always go for the smallest possible design. A fairly small design has its own advantages what you will find as we proceed. However, you must try to make your bot as small as possible. Now for starters we need a structure that can actually move and we must be able to control its direction as we wish. We have quite a large number of choices here. We may build a 4-wheeler or a 3-wheeler or even a 2-wheeler.A 2-wheeler is quite spectacular, but just like everything else, what looks so great may actually prove very dumb when it really counts. What Im trying to say is that it looks great but controlling 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 toy cars) power is applied to one pair of wheels and the other pair is used to control the direction. The rear wheels (on a single shaft) are powered to provide intended speed rotating on a fixed position and the front wheels are steered). It is a quite good mechanism but if you have to build it yourself then it becomes fairly difficult. That leaves us with none but the Differential Drive scheme.

The Differential Drive scheme utilizes the difference between the speeds of the right and left wheel or wheels (coupled to different shaft and powered by different motors). Here the very same wheel pair is used for directional control which is also powered.

We may use both the rear and the front wheels for this. Then the front and rear right wheels are coupled together with some gear or timing belt arrangement and the left wheels on another like the following figure.

control the direction. The other pair of wheels will just be dragged. The wheels that are supposed to be dragged must be capable of free moving through an angle of 360. Caster wheels serve this purpose quite well, but caster balls are obviously better choice. Since dragged wheels are just meant to support the bot above the ground, we may as well use only one instead of two. Actually its the smarter thing to do. Obviously a gear or timing belt-arrangement complicates the mechanical design greatly. So well use either the front wheels or the rear to

Caster Ball

Caster Wheel

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 two identical 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 who didnt, 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 a geared DC motor ( Ask for Gear Motor, while purchasing ), but make sure that the speed of the motor is well suited for your line follower. The difference between a DC motor and a geared DC motor is that a DC motor is faster than a Geared DC motor, but a Geared DC motor provides greater torque. Otherwise speaking, it can carry a greater weight.

While buying the motors1. You must consider the size of the motor (Shouldnt be too large and the weight should be as light 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 source simultaneously. Observe the speed of the motors. You should not expect to get 2 motors with identical speed, but make sure that u pick the 2 motors with the closest speed. Its a good idea to 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 wheels from 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, then you wont have any trouble coupling the wheel with the motor shaft. To do that youll need to buy Nylon rod (Cylindrical plastic rod available in diameter size ranging from .5 to 12). First decide on the diameter of the wheel of your Line Follower. Then buy a piece of nylon rod with diameter 0.5 larger than that of your wheel (e.g. wheel diameter 1.5, then rod diameter 2). Youll get this nylon rod in Nababpur. They have a minimum amount that youll have to buy. So I suggest that consult with other teams 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 them to 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 are patient enough, go to BUET machine shop, but to get their service you have to fill up a job requisition form and get it authorized by a teacher. Alternatively, you can get it done from any machine shop in Lalbagh , 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 coupled excellently. 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 ball also comes with these pair of motor-gear-wheel set. Youll get these at Patuatuli (Store: Telecom Spares). Be very careful if you go for this motor-gearwheel set. You must check the speeds of the wheels in the exact same way previously described. Make sure that the speeds of the two wheel sets are fairly close.

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 the motor-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 the size 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-wheel arrangement, 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 prefer building a Line Follower with a PCB to another one containing a bread-board because PCB is safer and neat. There is always a probability with bread-board that the connections may get lose while operating and its messy as well as a bit ugly.

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

You may use particle board or Plexiglass. Plexiglass is lighter and nice to watch. You can buy Plexiglass at Kataban. 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 with a metal clamp and screws. You can get these clamps at plumbing store at Nababpur . If you have bought the motor-gear-wheel set, previously described then, you dont need these clamps. The gear box has a rectangular shape. So one of its plain surfaces can be easily glued to the chassis or the PCB. You may use super glue or you can use a Glue gun****.

Electrical Design
The key components of the electrical design I. II. III. IV. Battery Sensors Microcontroller Motor driver

Battery
You should choose your battery according to your motor requirements. The major power consuming components 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) seem to be the best choice. Its comparatively lighter and being flat surfaced very easy to place on the chassis surface. Such batteries are available with around 1200mAh or even more which is quite impressive. They are typically rated 3.7 volts. So you should use a series combination of such batteries to get the desired voltage. A frequently asked question so far is How do I recharge the batteries?.You may use universal charger(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 than 3.7*3,say 12 volts with the same polarity). Connect the battery +ve to supply +ve and battery ve to supply -ve. Then again another problem arises, Where do I get the supply voltage?. You may use an adapter 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 by different colored surfaces. Typically the track and the field are designed to have the maximum color contrast (e.g. Black & White) to aid the smooth operation of the line trackers.

The fundamental idea is very simple. A set of light source (Transmitter-TX) and a light sensitive circuit element (Receiver-RX) is used as a sensor. A number of such TX-RX sets are placed at suitable positions at the front of the line follower. The light transmitted from the TX is reflected by the surface below. If surface is white the reflected light intensity is high, but if the surface is black the reflected light intensity is very low. That is how the Bot senses the color of the surface, it is on.

You have two options at hand. You may use visible light or infrared light for this sensor mechanism. In case of visible light, an ordinary LED is used as TX and a LDR (Light Dependent Resistors) as RX. For infrared 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 a digital signal. For this purpose an Op-amp proves handy. A sample circuit configuration of a single sensor is given below-

10k

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 reference voltage, first measure the voltages at pin no. 3 (+ve or non-inverting input pin)of the op-amp placing that 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 or inverting input pin) of the op-amp equal to the reference. In this sample Ive used LED & LDR. For Infrared TX-RX pair, just replace the LED by Infrared transmitter & replace the LDR by a infrared receiver in opposite polarity. Connect the shorter pin of the receiver to the VCC (+5V). The digital output of the op-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 response of 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 sensors manually. You can program the uC to do the calibration itself. This is way more faster and accurate than manual calibration.

I used Atmega32(Microcontroller) for on board control. It has 8 ADC channels (PA0 to PA7). So a maximum 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<<REFS0)|(1<<ADLAR); // For Aref=AVcc; ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0); //Prescaler div factor =128 }

//Function to read ADC result uint16_t ReadADC(uint8_t ch) { //This function returns the ADC value of channel=ch ch=(ADMUX & 0xf0)|(ch & 0x0f); ADMUX=ch; ADCSRA|=(1<<ADSC); while(!(ADCSRA & (1<<ADIF)));

ADCSRA|=(1<<ADIF); return(ADCW); }

Use the InitADC() function to initialize ADC after the DDRX(B,C or D) & variable declarations. Then call the function ReadADC(uint8_t ch) to read the ADC value of channel no=ch. To get the exact value of the signalI. Declare: uint16_t w; double r; Read ADC of a channel, say channel0: w=ReadADC(0); r=(w/1024)*5;

II.

III.

The hardware connection:

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

Motor Driver
Since we are using DC motor an H-bridge is the appropriate choice for driving the motors. L293D is an Hbridge package that provides two channels with full directional control. So its best suited for our purpose 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

Microcontroller
Ive used Atmega32 chip with Int. RC Osc. 8MHz. All the codes provided here are written for AVR Studio 4. 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-

The left motor is on the left & the right motor on the right

A sample PWM code is provided below. Ive used 10 bit phase correct PWM mode of Timer/Counter1.
//this function initializes PWM pwm_init() { //Initialize 10 bit phase correct PWM of TC1 TCCR1A |= (1<< COM1A1) | (1<< COM1B1) | (1<< COM1A0) | (1<< COM1B0) | (1<< WGM10)| (1<< WGM11) ; TCCR1B |= (1<< CS12); //Pre-scaling div factor=256 TCNT1 = 0x0000;//Initialize TCNT1. }

//Function for controlling pulse width, in turn the motor speed. void pwm_set( int left_speed, int right_speed ) { OCR1A = left_speed; OCR1B = right_speed; }

The lower the argument of pwm_set(int left_speed, int right_speed) the higher the speed of the corresponding motor.(e.g. You need maximum speed for left motor and lowest speed for right motor, then you call pwm_set(1,1023))

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 a PCB 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 to operate your line follower. You may resort to PID algorithms. For real time hardware debugging you may 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 my effort will help you.

Prepared byM. A. Awal


email: ` awal0643@gmail.com

Vous aimerez peut-être aussi