Engineering

Outreach

Resources

Enrichment

Green Engineers

Mechatronics Studio

Contact Us

Mechatronics Learning Studio

 

 

 Path Following Robot

 

Joshua Dalphy, Alex Germano, and Zeyad Kandil, Mechanical Engineering, University of Ottawa

 

 

Introduction

 

The objective of this project was to design a mechatronics system that would include both mechanical and electrical components.  With this in mind, the group decided to design and build a path following robot. However, to increase the projectís complexity, the robot had to not only follow a straight path but also follow a curved path, navigate through an intersection, and correct its position in the event that it went off course. This was accomplished by using a microcontroller, sensor, DC motors, motor controllers and the material listed in section 2 of the report.

 

Materials and Tools

    

         4 x 65mm diameter wheels

         1 x DC dual motor controller

         1 x Arduino Mega 2560 micro-   controller

         2 x DC motor

         4 x Wheel-motor adapters

         2 x Motor back shafts

 

         1 x Cytron line tracking sensor

         1 x Caster wheel

         Plumbing strapping

         Thin particle board

         1 x Battery pack

         1 x External power supply

 

Tools

         Chop saw                   -  Wire Strippers

         Screw Drivers           

         Soldering Iron          

         Pliers                         

Design

Robot Frame

The base of the robot was built using particleboard. This material was used because itís easy to acquire and to cut, and is the lightest material which was available and strong enough to support the weight of all the components.  The wheels purchased online were connected to the motor back shafts using the wheel-motor adapters. The back shafts themselves have a DC motor already build in and are mounted on both sides of the base (see Figure 1) and are secured using brackets that were made using basic plumbing strapping, which were then fastened using small screws.  The caster wheel, which is a wheel that may rotate 360į about its own axis, was then mounted and centered to the backend of the base to allow free movement and the option for rotation.

 

Figure 1

Sensing

The sensor used in this project was the Cytron line-tracking sensor (which can be seen in Figure 2). The Cytron sensor uses 5 infrared sensors to detect the presence of a black line; if a black line is detected, the infrared sensor is turned on and sends a high signal (1) to the Arduino and if it does not detect a black line, the sensor remains off and send a low signal (0) to the Arduino. In order to obtain an accurate reading, the sensor needed to be located directly on top of the path and needed to be in close proximity to the line. This was accomplished by mounting the sensor to a small wooden block which was then screwed to the base (see Figure 2).

Figure 2

Controllers

Two types of controllers were used in the design of this robot: a dual motor controller and an Arduino micro-controller.  The dual motor controller is used to control the speed of both DC motors.  This is done by regulating the amount of current going to each motor. By increasing the current to a motor, that motor will turn faster and alternatively, by cutting off the current going to a motor, that motor will be stopped. The control of the current going to each motor as well as receiving and outputting signals are all done by the Arduino micro-controller, which is the brain of the robot. Figure 3 shows how all the various components are connected to the Arduino. It is important to note that the Arduino requires a power supply to function, therefore an external power supply was used.  The setup for the Arduino and motor controller are shown in Figure 3.

Figure 3

Driving Mechanism

Combing all the components explained in the previous sections, the overall driving mechanism allows the robot to follow a straight line, curved line, and even navigate through an intersection. When turned on, the line-tracking sensor detects the black line and sends a digital signal to the Arduino, which allows the dual motor controller to pass current to the DC motors. Depending on the various combinations of sensors which are activated, the robot will either go straight, turn or stop. When the robot arrives at a curve in the path, a signal is sent to the Arduino which in turns sends an instruction to the dual motor controller to decrease the speed of the inside motor while maintaining the speed of the outside motor, turning the robot along its path.  When the robot is on a straight path all motors are turning at the same speed. Image of the final product can be seen in Figure 4.

Figure 4

 

 

Coding

 

#define o1 52

#define o2 53

#define o3 9

#define o4 10

#define o5 11

int E1 = 7;

int M1 = 6;

int E2 = 4;                        

int M2 = 5;

int out1=0;

int out2=0;

int out3=0;

int out4=0;

int out5=0;

 

void setup()

{

pinMode(M1, OUTPUT);  

pinMode(M2, OUTPUT);

 

pinMode(o1, INPUT);

pinMode(o2, INPUT);

pinMode(o3, INPUT);

pinMode(o4, INPUT);

pinMode(o5, INPUT);

   

}

 

void loop()

 

{

 out1 = digitalRead(o1);

 out2 = digitalRead(o2);

 out3 = digitalRead(o3);

 out4 = digitalRead(o4);

 out5 = digitalRead(o5);

 

  if(out3==1)

{

digitalWrite(M1,HIGH);  

digitalWrite(M2,HIGH);      

analogWrite(E1,60);   //PWM Speed Control

analogWrite(E2,60);   //PWM Speed Control

 else if(out4==1 && out3==0)

 {

 if(out3 != 1)

  {

  digitalWrite(M2,LOW);//stops right motor

  digitalWrite(M1,HIGH);//turns on the left motor

  analogWrite(E1,10);

  }

 }

  else if(out4==1 && out3==1)

  {

  if(out4 != 0)

   {

   digitalWrite(M2,LOW);//stops right motor

   digitalWrite(M1,HIGH);//turns on the left motor

   analogWrite(E1,10);

   }

  }

 

  else if(out5 ==1 && out3==0)

  {

 if(out3 != 1)

  {

  digitalWrite(M2,LOW);//stops right motor

  digitalWrite(M1,HIGH);//turns on the left motor

  analogWrite(E1,10);

  }

  }

  else if(out5==1 && out3==1)

  {

  if(out5 != 0)

   {

   digitalWrite(M2,LOW);//stops right motor

   digitalWrite(M1,HIGH);//turns on the left motor

   analogWrite(E1,10);

   }

  }

 

     else if(out2==1 && out3==0)

   {

   if(out3 != 1)

   {

   digitalWrite(M1,LOW);//stops right motor

   digitalWrite(M2,HIGH);//turns on the left motor

   analogWrite(E2,10);

   }

   }

    else if(out2==1 && out3==1)

    {

    if(out2 != 0)

    {

    digitalWrite(M1,LOW);//stops right motor

    digitalWrite(M2,HIGH);//turns on the left motor

    analogWrite(E2,10);

    }

    }

   else if( out2==1 && out1==1)

    {

      if(out3 !=1)

      {

      digitalWrite(M1,HIGH);//stops right motor

      digitalWrite(M2,LOW);//turns on the left motor

      analogWrite(E1,10);

    }

   

    }

   else if(out1==1)

   {

   if(out3 !=1)

   {

     digitalWrite(M1,HIGH);//stops right motor

      digitalWrite(M2,LOW);//turns on the left motor

      analogWrite(E1,10);

   

   }

  

  

   }

  

   

     else if(out1==0 && out2==0 && out3==0 && out4==0 && out5==0)

      {

      digitalWrite(M2,LOW);//stops right motor

      digitalWrite(M1,LOW);//turns on the left motor

      }

 delay(30);

}