12
Building a Line Follower Robot CPP Robotics Club Following the Line 1

SnapPagescloud2.snappages.com... · Web viewCPP Robotics Club Following the Line A Line Follower Robot uses a series of sensors (whether it is light reflection, color detection, etc.)

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: SnapPagescloud2.snappages.com... · Web viewCPP Robotics Club Following the Line A Line Follower Robot uses a series of sensors (whether it is light reflection, color detection, etc.)

Building a Line Follower Robot

CPP Robotics Club

Following the LineA Line Follower Robot uses a series of sensors (whether it is light reflection, color detection, etc.) to detect a line drawn on a surface. This particular Line Follower uses two sensors that send two separate signals to the Arduino Microcontroller, which is the brain of the robot, and then the Arduino reads these signals and computes what to do next. The code depends on the user,

1

Page 2: SnapPagescloud2.snappages.com... · Web viewCPP Robotics Club Following the Line A Line Follower Robot uses a series of sensors (whether it is light reflection, color detection, etc.)

whether to tell the Arduino to slow down one motor or speed up the motor, or simultaneously slow down one and speed up the other.

List of Parts- Pololu Chassis RRC01A- Tamiya 7010 Truck Tire Set (has enough for two kits)- Tamiya 70144 Ball Caster Kit (has enough for two kits)- Tamiya 700 Twin Motor Gear Box- AP1117T33L-U Voltage Regulator- 2x TIP102 NPN Transistor- 2.1mm Inner Diameter DC plug connector (male)- Arduino (with PWM signals and works off a 9Volt battery)- PCB Breadboard 400 point- 9 volt battery snap- 9 volt battery- Wire

Tools- Pliers- Soldering iron- Solder- Screwdriver- Wire strippers

Program- Arduino programmer (www.arduino.cc)

Step 1: Build BaseThe platform that the robot is going to be built on is a premade chassis body with a gearbox, ball caster (to allow steering), and tires. It will be easy to put together and the gearbox will only be the hardest part to put together (at least for the chassis only).

Chassis:We are going to be using a premade chassis with precut holes for mounting various pieces of hardware. For now, we will be using the mounting holes that will hold the gear box and the set of 4 holes for the ball caster. The circled areas are where we are going to be mounting:

2

Page 3: SnapPagescloud2.snappages.com... · Web viewCPP Robotics Club Following the Line A Line Follower Robot uses a series of sensors (whether it is light reflection, color detection, etc.)

http://www.pololu.com/catalog/product/256

Ball Caster: This will be the front-turning wheel that will allow the robot to swivel one way or the other without scraping the chassis. The ball caster is easy to mount; add the spacer to give it enough height so that the platform stays level with the ground (or you can leave it out as long as the sensors that will be mounted are not too close to the ground). Then add the ball caster and use the bolts and nuts to mount it to the chassis. There is an instructions manual to put the ball caster together that came in the box.

3

Ball Caster, sensors (front end)

Wheels

Gearbox

NOTE: The picture shown here is the prototype, the one you will be making will differ for some parts.

Page 4: SnapPagescloud2.snappages.com... · Web viewCPP Robotics Club Following the Line A Line Follower Robot uses a series of sensors (whether it is light reflection, color detection, etc.)

Gearbox and wheels: This gearbox has 2 different speed settings and we will be using the slowest speed (the higher number ratio). There are four large gears and one very small white-grey gear that we will be using to get the slow speed. There is a diagram that came with the gearbox that shows how to mount the gears in what order.

NOTE: There are 3 possible wholes that the axel can go through shown in the diagram. The one that will be used in this project is the center hole (C) between the set of 3 holes (2 of them labeled A and B) towards the front of the gearbox housing and the one lone hole near the motors that does not go through the outside pieces (the center main piece of the housing has the hole going through each side).

When mounting the axel to drive the wheel, instead of using one long rod to spin the wheels, use 2 short rods so that each motor assembly spins independent of each other.

Once the gearbox is put together, mount the wheels by sliding them on the end of each axel (make sure they are all the way on the axel or they will not fit through the wheel holes in the chassis).

4

Set of 3 holes towards the front of the robot (2 are A and B)

The hole that doesn’t go all the way through (for outside pieces)

Hole C is where the axel will go for the wheels to properly fit onto the chassis.

Page 5: SnapPagescloud2.snappages.com... · Web viewCPP Robotics Club Following the Line A Line Follower Robot uses a series of sensors (whether it is light reflection, color detection, etc.)

Step 2: Understanding the Electronics

http://www.pololu.com/catalog/product/958

The sensors are an Infrared (IR) LED and phototransistor pair that work together to determine the reflectance of a surface. The theory is that the sensors will shine light to a surface and, depending on the type of surface and the color, the reflected light will be determined by the phototransistor and return a certain value to the microcontroller. Infrared light cannot be seen by the human eye, but almost all digital cameras can (even phone cameras).

http://www.sparkfun.com/commerce/product_info.php?products_id=9950

The Arduino is already pre-built out of the box; that will be used later when we finally build the program and test out the robot. This is the brain of the robot; this will hold the code that will allow the robot to follow the line and this will have most of the signal connections plugged in from the motor control board and sensors.

Wiring:Figure 1 is a diagram of how the electronics will be wired (theoretically). Figure 2 will show the actual wiring; meaning which actual pin of each component is wired to another.

5

Page 6: SnapPagescloud2.snappages.com... · Web viewCPP Robotics Club Following the Line A Line Follower Robot uses a series of sensors (whether it is light reflection, color detection, etc.)

Figure 1: Diagram of circuit

Figure 2: Layout of circuit

6

AP1084 Voltage Regulator TIP102

Arduino negative (“-“)

ArduinoPositive (“+”)

The silver bar on the black transistors is the heatsink (the silver metal tab on the actual transistor).

Page 7: SnapPagescloud2.snappages.com... · Web viewCPP Robotics Club Following the Line A Line Follower Robot uses a series of sensors (whether it is light reflection, color detection, etc.)

For the “Vin,” the Arduino will also be connected to it since the microcontroller can operate between 9-12V. Be careful when putting together the plug for it, because the Arduino will not work with the Negative wire connecting to the Positive wire; it has to be “Positive – to – Positive” and “Negative – to – Negative” (in general terms, connect red – to – red wire and black – to – black wire).

Figure 3. Plug to Arduino

Fugire 4. Sensor wiring

Step 3: Soldering parts

Transistors:To solder all the components, start with the Transistors (the ones with the screw hole and

metal tab) to the PCB board. There are 2 different types of transistors that will be used; a TIP 102 NPN Transistor and an AP1117T33L-U Voltage Regulator. The Voltage regulator will have a thicker metal tab than the 102s so make sure to tell the difference. Leave enough room for the

7

Page 8: SnapPagescloud2.snappages.com... · Web viewCPP Robotics Club Following the Line A Line Follower Robot uses a series of sensors (whether it is light reflection, color detection, etc.)

signal and motor wires as well as jumper wires (in Figure 2, if your board has more holes than the picture, leave one space in between transistors to ensure you have enough holes for wiring). Bend the legs so that the transistors don’t slide out in the process of soldering. While soldering, use your pliers and clamp on the leg that is being solder. If you have self clamping pliers, use those.

NOTE: Reason for clamping the leg is to keep the transistor from overheating, which can make the component useless if it gets too hot and melts the insides.

DC Barrel Jack (plug) and 9 volt connector:To set up the plug for the Arduino, first unscrew the plastic cover off. You will see 2 tabs

(one longer than the other) sticking out the rear of the main plug section. The smaller tab in the middle is the “Positive (+)” tab; that will be connected to the “Arduino+” rail in the board diagram (refer to Figures 1, 2, and 3). Solder a wire (usually red is the default color for power, but any color will do) to the tab but do not solder the other end yet. Then solder another wire to the longer tab (“Negative (-)”) but do not solder the other end yet; this will later be soldered to the “-“ rail on the motor control board (refer to Figures 1, 2, and 3). After both wires are soldered to the plug, feed the free ends through the plastic screw cap and screw it back on the plug. Then solder the other ends to the correct rails on the motor control board.

Solder the positive wire (usually red) of the 9 volt battery snap to the “9 volt” rail and solder the black negative wire to the Negative terminal (refer to Figure 2).

Wiring Jumper Wires:The only jumper wires you will need on the motor control board are connecting the

power supply to the transistors (refer to Figure 2). Make sure to clamp to the leg of the transistor to keep them from overheating!

Wiring Transistors:After all the Transistors are soldered add and solder wires to the signal rail of the

2 TIP102 transistors (refer to Figure 2 and solder where the blue dots indicate on the PCB board). Look on the diagram (Figure 2) and find the 2 signal wires from the TIP102 transistors; solder a separate header to each of them.

Wiring Sensor Wires:Then solder 3 separate wires to the sensors, but be careful because these can easily melt

due to their size; make sure to only hold the soldering iron for a short period of time! On the sensors, take the wires connected to “VIN” on each sensor and solder both to 1 header pin. Take the 2 “GND” wires and do the same. For the “OUT” wires, solder a separate header to both, do not solder both wires to one header. Then mount the sensors to the open holes on the ball caster bracket as long as they are close (at least a penny thick) but not touching the ground (you can hot glue them on).

Wiring Motor Wires:On the motors there will be 2 tabs that stick out of the back end. Solder a wire to each;

theoretically, we need to have both motors spin in opposite directions of each other because of

8

Page 9: SnapPagescloud2.snappages.com... · Web viewCPP Robotics Club Following the Line A Line Follower Robot uses a series of sensors (whether it is light reflection, color detection, etc.)

the orientation of the gearbox. The top wire (closest to the chassis when the gearbox is mounted) on each motor we will consider to be the positive wire and those will be connected to the motor controller. The bottom terminal (closest to the ground) of each motor will be soldered to the ground (or negative) rail on the motor control board (refer to Figure 2). Then place the chassis with the mounted gearbox on a surface with the motor tabs facing you. Imagining that your driving it, take the left wire of the positive motor tab and solder it to the motor controller (refer to Figure 2). Then do the same to the right positive motor wire.

BIG NOTE: Before applying power to the boards, check to make sure that none of the wiring or soldering is crossing over to the wrong component. This will possibly damage either the motor controller or the Arduino or both. So always double check to make sure nothing is crossing over!

Connect the 9V battery and check to see if any of the components are starting to get really hot. If just one gets hot, disconnect the 9V battery immediately and look for any shorts.

Connecting Electroncis to Arduino:Now that everything is wired and ready to work, the wires will need to be plugged into

the Arduino. For the sensor wires, the VIN wire will go into the “5V” pin on the Arduino located near the analog pins. The GND wire from the sensors will go into the “GND” pin next to the “5V” pin. Depending which sensor is on what side, take the right sensor’s signal wire and plug it into analog pin 2. Take the left sensor’s signal wire and plug it into analog pin 0. Locate the transistor signal wires and determine which one is the right motor and which is the left motor (refer to Figure 2 and look for the 2 blue wires; those are the signal wires to vary the speed of the motors). Take the left motor signal wire and plug it into digital pin 3 on the Arduino. Then take the right motor signal wire and plug it into digital pin 6.

9