Robot with Two Wheeled Mobile Platform

Building Robot with Two-Wheeled Mobile Platform

Robot Hardware Required

• Tools listed in “Tools”:
  • These are the tools you need to assemble the robot chassis.
  • Phillips Screwdriver
  • A small Phillips screwdriver from your local hardware store.
  • Small long-nose or needle-nose pliers
  • For example, Radio Shack 4.5-inch mini long-nose pliers, part number
  • 64-062 (see Figure 1-10) or Xcelite 4-inch mini long-nose pliers, model L4G.
  • Small wire cutters
  • For example, Radio Shack 5” cutters, part number 64-064 (Figure 1-11) or
  • Jameco 161411
  • Soldering iron
  • For example, Radio Shack 640-2070 (Figure 1-12) or Jameco 2094143 are
  • low cost irons suitable for beginners. But if you are serious about electronics,
  • a good temperature controlled iron is worth the investment, such
  • as Radio Shack 55027897 or Jameco 146595.
  • Solder 22 AWG (.6mm) or thinner
  • For example, Radio Shack 640-0013 or Jameco 73605.
• The assembled electronics
• 2WD Mobile Platform (two wheeled robot kit made by DFRobot)
• Two 0.1uF ceramic capacitors
• Two lengths of 3 conductor ribbon cable, two 3 way 0.1” headers for edge sensors
• Optional: charging circuit resistors and diode, see detailed parts list

Mechanical Robot Assembly

  • Lay Out the Chassis Parts
Figure 3-2 depicts all of the components included in the 2WD chassis package.
Robot
Figure 3-2. 2WD Chassis Parts
Figure 3-3 depicts the contents of the mounting hardware bag.
Locate the two flat-headed bolts and set them aside for mounting the battery case. Determine the two thicker (M4) bolts that will be used to secure the caster. This pack’s remaining short bolts are identical.
Robot
Figure 3-3 Contents of the 2WD hardware pack.
  • Motor Assembly
Attach each motor to the chassis lower plate using two long bolts with lock washers and nuts, as shown in Figure 3-5. Tighten the nuts snugly, but take care not to overstress the plastic motor housing.
Lock washers are used to keep a nut from becoming loose due to vibration. This is especially important when connecting the motor and switch. When tightened, these washers have a split ring or serrations that add extra friction.
 
If things continue to come loose, don’t overtighten the nuts; instead, retighten the nut and apply a dab of nail polish to the point where the threads emerge from the nut.
Figure 3-4 depicts the motors in position, with the nut in the upper right ready to be tightened.
Robot
Figure 3-4: Motors mounted on the lower plate of the chassis
Figure 3-5. Motor Robot Assembly
  • Assemble the Chassis Parts
Align the slots in the wheels with the flat section of the motor shaft as you push the wheels onto the motor assembly shafts. Two M4 bolts and nuts are used to secure the caster. Figures 3-6 and 3-7 demonstrate this.
Figure 3-6. Motor Assembly
Figure 3-7: Mounted wheels and casters
As shown in Figures 3-8 and 3-9, attach the sensor bracket to the underside of the lower chassis plate.
The sensor plate on this robot is sometimes mounted at the opposite end of the chassis (furthest from the caster). You can build it any way you want, but the orientation shown here allows the servo-mounted distance scanner to be attached in front of the robot.
Furthermore, by positioning the sensor bracket in this location, the distance between the wheels and the line sensors is increased, which improves line following sensitivity.
Figure 3-9 depicts the chassis’s underbelly after the sensor bracket has been attached.
Keep in mind that the sensor bracket is fastened to the chassis plate’s bottom.
 
             Figure 3-8. Viewed from the robot’s right side, the sensor bracket                  Figure 3-9. The robot’s sensor bracket as seen from the side.
According to Figures 3-10 and 3-11, two countersunk (flat headed) Phillips bolts are used to attach the battery pack to the bottom base plate. To make it simpler to arrange all the wires, you might wish to postpone this step until after the battery leads have been soldered.
   
           Figure 3-10 shows the motor assembly.                         Figure 3-11. Attached Battery Pack to Chassis
Cut two red/black wire sections that are each about 7 1/2 inches long. At one end of the wires, strip to expose about 3/16 inch of bare wire, then connect to the motor terminals. The pairs of wires, which will be attached to the motor shield, should have 1/4 inch cut off of the other end. As shown in Figure 3-12, connect a 0.1uF capacitor across each motor terminal. The capacitors reduce electrical spikes that the motor produces and could potentially conflict with signals on the Arduino board.
Figure 3-12. Soldered wires and capacitors to motors
The large (M8) lock washer and nut are used to secure the DC power jack to the top plate. Two (M6) nuts and a lock washer are used to secure the switch. Install one nut on the switch, leaving approximately 3/16″ of thread above the nut. Then, with the lock washer on the thread, push it through the opening in the back plate and secure it with the second M6 nut.
Figure 3-13. Assembly of a Switch and a Jack
As shown in Figures 3-13 and 3-14, position the switch so that the toggle moves towards the jack (Figure 3-15 shows the view from beneath).

Figure 3- 14. The top panel shows the location of the switch and the DC jack.

Figure 3- 15. The orientation of the switch and jack is shown on the top panel’s underside.
The battery can be connected in the manner indicated in Figures 3-16 and 3-17. When the robot is not in use, the power switch will disconnect the battery. The DC jack is only utilized as a junction point for the black ground wires in this design. When the toggle is closer to the DC jack, as indicated (the toggle is a lever; when the exposed end is up, as shown in the image, the contact at the bottom is connected and the contact tied to the shield is open), the switch is turned off.
Figure 3-16. shows how to wire a switch (no trickle charger)
Figure 3-17. Connect the battery cables to the switch using solder.
If you want to use rechargeable NiMH batteries, you may include a simple trickle charger inside the robot. The charger may be made using the circuits seen in Figures 3-18 and 3-19.
Figure 3-18: Wiring for an optional trickle charger

Figure 3-19. the wiring for the supplemental charger jack

Using a Velcro strip is the most straightforward method of mounting the Arduino board. The Rovera 2W (Arduino-Controlled 2 Wheel Robotics Platform) kit includes a 2.5″ x 1.5″ strip. Apply insulating tape to the underside of the Arduino board to stop the pins from unintentionally shorting to the chassis. Gaffer tape works great, but you may also use heavy-duty electrical tape or duct tape that isn’t conductive. The hooked side of the Velcro is secured as illustrated in Figure 3-20. Attach the Velcro’s “hairy” side to the taped Arduino board.
Figure 3-20. Positioned on the 2WD chassis is a Velcro pad. The Arduino board is shown with Velcro applied in the inset.
The mounted boards are shown in Figure 3-21. When the robot is moving, the Velcro will hold the boards in place, but when you put in the shield or unhook it, be careful not to apply too much downward pressure since that might drive the Arduino pins through the tape.
Fig. 3-21. Velcro is used to attach an Arduino board.
If you prefer a more solid installation, use two of the 10mm brass standoffs included with the chassis, as well as two M3 bolts and nuts (seen on the right side of the board in Figure 3-22). In the hole near the reset switch, insert a 10mm spacer and M2.5. (The hole near the DC jack on the lower left is not utilized.)
Figure 3-22 shows how to mount the Arduino board from the top of the chassis.
A spacer is required for a Leonardo board because there is insufficient space in the mounting hole near the switch for an M3 bolt. Because the Uno board has extra space, you may install it using another of the 10mm spacers and M3 hardware.
 
Figure 3-23 depicts the mounting locations as seen from the panel’s bottom.
Fig. 3-23. The three Arduino mounting points are shown on the underside.
 
 
Figure 3-24 shows how to attach the top plate with four M3 bolts.
Figure 3-24: Assembly of the Top Plate
 
 
Putting the Control Electronics Together Figure 3-25 depicts the location of the battery and motor cables. Left and right are from the perspective of the robot (the right wheel is closest to the switch). The essential electronics are shown in Figure 3-26.
  • Putting the Control Electronics Together
Figure 3-25 depicts the location of the battery and motor cables. Left and right are from the perspective of the robot (the right wheel is closest to the switch). The essential electronics are shown in Figure 3-26.
Figure 3-25. Connections for the motor and the battery
Figure 3–26. 2WD is complete and ready to instal sensors.
  • Mounting the IR sensors
This section describes how to attach infrared (IR) reflectance sensors for edge detection or line following. Modifying the Robot to React to Edges and Lines, you’ll learn how to employ infrared sensors. This section describes how to attach them to the 2WD platform and link them to Arduino. The sensors should be installed as explained in the section on edge detection for the first projects in this book.
The stripboard mount described in “Making a Line Sensor Mount” simplifies the attachment and wiring of the sensors for line detection, and it may also be used for edge detection, but keep in mind that the robot performs better with the sensors wider apart. When the sensors are close together, the robot may have problems calculating the ideal angle to turn when it comes into contact with an edge.

Installing the Infrared Sensors for Edge Detection

Edge detection necessitates the use of two QTR-1A sensors installed on the front of the robot. These should be as evenly spaced as feasible. Each sensor should be placed in front of a wheel such that an edge may be detected before the wheel falls off a ‘cliff’. However, if ease of construction is more important than precision of edge detection, you can use the same mount described in the next section on line detection.
The sensor side is grounded, and the header pins are oriented upwards. Mount each sensor with a 2-56 bolt and nut (M2 bolts and nuts are also suitable) and a 1/2″ plastic spacer so that the sensor’s face is 3/8″ or closer to the ground. Suggestions for mounting are shown in Figures 3-27, 3-28, 3-29, and 3-30.
Figure 3–27. Location of the Reflectance Sensor for Edge Detection
Figure 3-28. Edge Detection Sensor Mounting Detail

Figure 3-30. The placement of the Edge Detection Sensors is shown in the front view.

Figure 3-30. Edge sensors are connected and ready to use.

Installing the Infrared Sensors for Line Following

Line following necessitates the use of three QTR-1a sensors. The section “Making a Line Sensor Mount” (page 17) explains how to construct a stripboard mount for line sensing. However, if you wish to experiment with how different sensor spacing impacts line following, you can instal and attach each sensor as suggested in this section.
The sensors may be connected via either 2-56 or M2 hardware. The component side is facing down, while the header pins are facing up. They are installed at the front, evenly spaced, with about 1/2 inch between the center and the left and right bolts (Figure 3-31).
Figure 3-31. Reflectance Sensor location for Line Following
Building the Electronics, you can mount the stripboard above or below the sensor bracket, allowing you to experiment with sensor distance to the ground—but make sure the tracks with sensor connections are not shorted to the bracket. Figures 3-32 and 3-33 demonstrate how to attach the stripboard.
Figure 3-32. Reflectance Location of the line-following sensor

Figure 3-33. Reflectance Location of the line-following sensor and an alternative perspective

Figure 3-27 shows how to connect the stripboard wires to the motor shield.

Next Steps

Tutorial: How to Begin with The Arduino documentation describes how to set up and utilise the development environment that will be used to upload code to the robot.
need assistance with the libraries used in the code for this book.
If you have the libraries loaded and want to perform a quick test to ensure that the motors are operating properly, use the sketch in Example 3-1.
Example 31.
Initial motor test for 2WD
/*******************************************
* MotorTest2wd.ino
* Initial motor test for 2WD – robot rotates clockwise
* Left motor driven forward, right backward
* then counter-clockwise
* Michael Margolis 24 July 2012
********************************************/
const int LED_PIN = 13;
const int speed = 60; // percent of maximum speed
#include <AFMotor.h> // adafruit motor shield library (modified my mm)
AF_DCMotor Motor_Left(1, MOTOR12_1KHZ); // Motor 1
AF_DCMotor Motor_Right(2, MOTOR12_1KHZ); // Motor 2
int pwm;
void setup()
{
Serial.begin(9600);
blinkNumber(8); // open port while flashing. Needed for Leonardo only
// scale percent into pwm range (0-255)
pwm= map(speed, 0,100, 0,255);
Motor_Left.setSpeed(pwm);
Motor_Right.setSpeed(pwm);
}
// run over and over
void loop()
{
Serial.println(“rotate cw”);
Motor_Left.run(FORWARD);
Motor_Right.run(BACKWARD);
delay(5000); // run for 5 seconds
Serial.println(“rotate ccw”);
Motor_Left.run(RELEASE); // stop the motors
Motor_Right.run(RELEASE);
delay(5000); // stop for 5 seconds
}
// function to indicate numbers by flashing the built-in LED
void blinkNumber( byte number) {
pinMode(LED_PIN, OUTPUT); // enable the LED pin for output
while(number–) {
digitalWrite(LED_PIN, HIGH); delay(100);
digitalWrite(LED_PIN, LOW); delay(400);
}
}
This design turns the motors in opposing directions for 5 seconds, causing the robot to rotate clockwise, then reverses direction to revolve counter-clockwise.
This will continue until the power is turned off.

Leave a Reply

Your email address will not be published. Required fields are marked *