Cognoscis

Think. Understand. Apply

Simple line follower

Posted by cognoscis on 6th November 2009

I have covered the sensors part in detail in previous posts. Now I will go ahead and describe how to build a very simple line follower (Something I should have done a long time ago). There are a few important things that you must consider before actually building a line-follower. First and foremost, what kind of sensors are you going to use? LDRs are easy to build and very cheap but are not efficient in noisy environment. If the environment in which you intend to use it is noiseless (Has uniform lighting or illumination) then you can go ahead and use LDRs. On the other hand, if you are looking at a sensor that can withstand high noise, then IR sensors are the way to go. The choice of sensor is independent of the rest of the circuit. It is only important from the sensitivity point of view.

Now that you have chosen a sensor, always remember that it will give you a HIGH or a LOW output at the end. Now you can make this high to represent either a presence or absence of a white line (say). It is completely in your control. For the sake of example let us consider a white line on a black background. Now, you place your sensors so that it is on the background, then the sensor sees black. Now set your comparator such that it will output a high when this voltage is fed at its input. A NOT gate can be used to reverse this if you want to. It is completely flexible and in your hands to modify. Next is to decide on a logic circuit to drive the bot. Depending on your logic, the number of sensors will vary. In this example, I am going a use a very simple logic that requires only two sensors. Next, you must consider the placement of sensors. Lastly, the motor driver, meaning, the circuit that will enable you to drive the motors. So, lets start building now.

I will build a white line follower (White line on a black background). For this, LDR or IR sensors can be used. For construction of LDR sensor click here and for IR click here. Now, we have two sensors which are like two eyes of our bot. Using these “eyes” we make it see the line and make it follow the line. Once you have built the sensors’ circuits and tested them individually as explained in those posts, you must no consider their placement. Placement is very very important. Make sure you place them towards the front of the vehicle and they must be on the black background when stationary and not on white line. Now you may wonder why that would be? That is because, its the best way to follow any line. Always, try to locate the background (this I learnt from experience). Refer the figure below to understand it

Placement of the sensors

Placement of the sensors

In the figure, the green circles are the two sensors that hover over the sides of the central white line that is to be followed. The yellow part to which we attach all our circuits, motors and batteries is called the chassis (Pronounced cha-see). Anyway, Now that the placement of the sensors is taken care of, i.e., the eyes have been placed. Now, you need to give it “legs” that being the motors and wheels.

For this purpose, there are many methods that are used. first lets see our “driving force” that is given by the motors. Two important considerations are to be kept in mind. First, what will be the total weight that will be driven by these motors. That will help you in choosing the right torque for the motors. Generally speaking, most of the motors are rated in terms of rpm (rotations per minute). One thumb rule is that lower the rpm of a motor, higher is its torque for the same voltage. So, for starters, I would suggest you to go for 150 – 200 rpm 12 V motors. This will give you reasonable torque and controllable speed for our primitive logic circuit. Second, consideration is the battery power. As suggested above, if you use 12 V motors, you can run them on a 9 V battery, but its rpm and torque will be reduced because the energy supplied by the battery is not what the motor expects for full performance. Of course, you can use 9 V + 3 V to make 12 V and supply it to the motors. That time the motors will run at full speed. But once the battery drains (which is fast if the robot is heavy) the rpm will reduce. You need to consider these things when you start building high precision robots. But for now, we can ignore it for time being.

For wheels, you can use wooden wheels. I use wooden wheel that we got from a wood works shop after a lot of requesting. You can also try toy wheels and use adhesives to fix the wheel to the shaft. You might go for the commercial wheels sold in shops along with the motors if you can access them. When using wooden wheels do remember to put a piece of cycle tube around it for frictional purposes. As for the front, you get Caster wheels wheel that are the best suited for such applications, the ones that are used in movable chairs and stools, but only very small in size. This can be seen in the image below

Ball caster wheels

Ball caster wheels

Then depending on your motors you can use either L-clamp or U-clamp to fix the motors to your chassis. Now comes the electronics part of the robot. Remember, if you use 12 V DC motors, then you will need two separate power supplies. One 12 V for your motors, and the other 5 V for your sensor and control circuit ICs. Since this is not feasible, we will use a “Voltage Regulator” that will take 12 V as input and give 5 V as output. There are many such ICs, we will use the popular LM 7805 voltage regulator (its datasheet can be downloaded from here). The circuit diagram and the image of the IC is as shown in the figure below. The two capacitors are very crucial and must not be omitted from the circuit.

LM 7805 IC with Circuit Diagram

LM 7805 IC with Circuit Diagram

Once we have over come the issue of dual power supply, we can now go ahead and try to run the motors. But, there is a problem, the output of sensors is 5 V but the motors need 9-12 V at least to run. That means, we need to have some kind of a mechanism to convert that 5 V signal to 12 V signal. A number of options are available for this. Pure mechanical relays can be used but these are bulky and not preferred by many. We can then turn to what are called as motor driver ICs which are specially made for this purpose. One more advantage of using them is that we will get some familiarity at the initial stage itself and we will be one step ahead while designing more complex robots as we may require to operate the motors in two different directions (ex. Remote controlled vehicle). That time, these motor drivers come in very handy and will considerably reduce the circuit size. There are a number of motor drivers in the market, many beginners prefer ULN 2003, but I think we can go for L293D motor driver or rather quadraple half H-Drivers as they are called. Datasheet can be found here. Just observe the circuit diagram of the IC in the figure below

L293D internal circuitry

L293D internal circuitry

As seen in the internal diagram, this driver IC has 4 half H-drivers (Triangular buffers in the figure). Each of this driver is made up of transistors to form a H-bridge (totally 6 transistors) that are capable of driving the motors in one direction. So, to drive a motor in both the directions, we need to utilize two such half bridges. As shown above, the pins 4, 5, 13 and 12 are ground pins that must be connected to your circuit ground. Pin 16 is Vcc1 which supplies for the IC. So, we connect it to 5 V as shown in figure below. Now, a 5 V at pin 1 will enable the driver 1 and driver 2 where as a 5V at pin 9 will enable driver 3 and driver 4. In our circuit below, we are using drivers 1 and 4 for the convenience of connection and hence we connect pin 1 and pin 9 to Vcc1 which is 5 V. Since we only go forward following the line, we will use only half the bridge. So, we connect one end of the motor to output of the driver which is pin 3 for driver 1 and pin 14 for driver 4. The other end of the motor is grounded. Make sure that same ends of motor are grounded and the motor is rotating in the forward direction only. If it is rotating in reverse direction, just interchange the connections and you will be able to drive the motors forward all the time. Now, the output of your two sensors must be given as input to these motor driver bridges. That is pin 2 for driver 1 and pin 15 for driver 4 as shown in the figure below. Finally, the most important part is the 12V connection must connected to pin 8 which is Vcc2. Make sure you connect the left sensor output to left motor driver and right sensor output to right motor driver.

L293D with Circuit Diagram

L293D with Circuit Diagram

Thats all! Now just to clarify, for the chassis you can use almost anything. You can use a piece of plywood sheet, or a switch board plate which is a Bakelite plastic or you can use Aluminium sheet or perforated sheets that you gets in some shops. It totally depends on you and what materials are available to you. Now that we are done, its time to try out the line follower. Take a big sheet and paint it black and make a white track. Then calibrate your sensors ( on how to calibrate refer the sensor related posts that here towards the end of the post). Once that is done, just place your robot on the track and watch it go. Once you actually make this first robot, you will become aware of all the practical difficulties that one faces during making a robot work. This is the first step one must take to enter the field of robotics. The first one I ever made, I made it “see” the white line (which I advised you to avoid) and hence it was not very successful when it was presented with obstacle. Watch the 3gp video of the same :D

Any problems, suggestions, broken links; please notify using the comments :)

Tags: , , , , , , , , , , , , , , ,
Posted in Robotics | 2 Comments »