Let's Make Robots!

Rover 5 with Audrino and Dagu 4 Channel DC Motor Controller

 

Hello

Myself and a few friends have been trying to build a robot for our university assignment which is due in about two weeks time. We were just having a few problems and were hoping we could get some help.

We require this robot to use sensors to drive thought a course avoid a few simple obstacles and place a softball in a bucket.

We currently have an audrino UNO SMD edition attached to a Dagu 4 Channel DC Motor Controller in the following configuration.

Channel One
PWM pin 3~
DIR pin 4

Channel Two
PWM pin 5~
DIR pin 7

Channel 3
PWM pin 10~ 
DIR pin 8

Channel 4
PWM pin 11~
DIR pin 12 


We do not have any of the encoders or the current sensors attached yet we are just trying to take all of this one step at a time since it is our first robot We dont really plan on using the encoders.

We have 6 AA batteries to a breadboard which powers the audrino and the motor controller. We have a 5V voltage regulator to power the Logic part of the Dagu motor controller. We have not yet attached any sensors to the robot because as i said we are just trying to build up to getting this thing ready.

Our current problem is that we cannot get the motor to drive forwards they only drive backwards.

At the moment this is the code we are currently running on the aurdino which one of my group members wrote.

int PinPWM_b1 = 3;   // make sure these pin numbers are correct !!! ch1

int PinPWM_b2 = 5;   //ch2

int PinPWM_y1 = 10;   //ch3

int PinPWM_y2 = 11;  //ch4

 

int PinRot_g1 = 4;   //ch1

int PinRot_g2 = 7;   //ch2

int PinRot_r1 = 8;    //ch3

int PinRot_r2 = 12;   //ch4

 

// 2 is right motors 1 is left motors

 

void setup()

{

Serial.begin(9600);

pinMode(PinPWM_b1,OUTPUT);    // back left motor pwm

pinMode(PinPWM_b2,OUTPUT);   // back right motor pwm

pinMode(PinPWM_y1,OUTPUT);   // front left motor pwm

pinMode(PinPWM_y2,OUTPUT);    // front right motor pwm

 

pinMode(PinRot_g1,OUTPUT);     // back left motor dir

pinMode(PinRot_g2,OUTPUT);     // back right motor dir

pinMode(PinRot_r1,OUTPUT);     // front left motor dir

pinMode(PinRot_r2,OUTPUT);     // front right motor dir

}

 

void loop()

{

digitalWrite(PinRot_g1,HIGH);   // turn all motors backwards

digitalWrite(PinRot_g2,HIGH);  

digitalWrite(PinRot_r1,LOW); 

digitalWrite(PinRot_r2,LOW); 

digitalWrite(PinPWM_b1,230);     // provide power to all motors

digitalWrite(PinPWM_b2,230);

digitalWrite(PinPWM_y1,230);

digitalWrite(PinPWM_y2,230);      

delay(1000);

digitalWrite(PinPWM_b1,LOW); // stop motors

digitalWrite(PinPWM_b2,LOW); 

digitalWrite(PinPWM_y1,LOW); 

digitalWrite(PinPWM_y2,LOW); 

delay(1000);

//analogWrite(PinRot_g1,LOW);   // turn all motors forward

//analogWrite(PinRot_g2,LOW);  

analogWrite(PinRot_r1,HIGH); 

analogWrite(PinRot_r2,HIGH); 

//digitalWrite(PinPWM_b1,200);     // provide power to all motors

//digitalWrite(PinPWM_b2,200);   // test using HIGH or 255/200/etc HIGH is full power.

digitalWrite(PinPWM_y1,200); 

digitalWrite(PinPWM_y2,200); 

delay(1000);

//analogWrite(PinPWM_b1,LOW); // stop motors

//analogWrite(PinPWM_b2,LOW); 

digitalWrite(PinPWM_y1,LOW); 

digitalWrite(PinPWM_y2,LOW); 

delay(1000);

//digitalWrite(PinRot_r2,HIGH);   // turn right motors 

//digitalWrite(PinRot_g2,LOW);  

digitalWrite(PinRot_r1,LOW);   // turn left motors

digitalWrite(PinRot_g1,HIGH); 

//digitalWrite(PinPWM_y2,200);   // provide power to right motors

//digitalWrite(PinPWM_b2,200);  

digitalWrite(PinPWM_y1,230);   // provide power to left motors

digitalWrite(PinPWM_b1,230);  

delay(1000);

digitalWrite(PinPWM_b1,LOW); // stop motors

digitalWrite(PinPWM_b2,LOW); 

digitalWrite(PinPWM_y1,LOW); 

digitalWrite(PinPWM_y2,LOW); 

delay(1000);

} 

 I will upload some pictures as soon as i get them from a fellow team member. Thankyou for looking any help would be greatly appreciated. 

 Luke

 

AttachmentSize
Audrino(new).jpg391.65 KB
Dagu(new).jpg356.94 KB
image_3(new).jpg330.98 KB
image(new).jpg373.76 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Hi guys,

im new into this web site, but i have been reading your comments, it helpd alot. i have rover 5 , 4 motors, im trying to make it simple and easy to go forward and make few turns, the codes im using it just make it go forward and backward, when u take the output high or low, any help with codes will be very helpful, 

Many thanks

Yeah this was my first project aswell the rover is defenitly a good way to start.

Heres some tips of problems i encountered making this project
-Make sure you have good batteries in it i have spent days messing around with bad batteries
-Make sure you have a nice clean 5V supply going into your logic. I would recomend using the 5v supply off the audrino to power the motor controllers logic. Whatever you do dont run 9V throught it like a freind of mine did, you will find yourself up for another one.

What kind of trouble are you having with your code?

The best way to understand the code is to just think of each command you give it lasting for the duration of the delay for example:

 digitalWrite(PinRot_g1,LOW); // turn all motors forward
 digitalWrite(PinRot_g2,LOW); 
digitalWrite(PinRot_r1,HIGH);
  digitalWrite(PinRot_r2,HIGH);
  analogWrite(PinPWM_b1,200); // provide power to all motors
  analogWrite(PinPWM_b2,200); // test using HIGH or 255/200/etc HIGH is full power.
  analogWrite(PinPWM_y1,200);
  analogWrite(PinPWM_y2,200);
  delay(1000); 

This here will turn my roover forward for around about one second. The value 200 is the pwm output of the pin. Make sure you know your diffrence between digitalwrite and analog write and that you have you pins connected from your audrino to your dagu correctly.

The best way to get the roover to turn is to turn the tracks on oposite sides in oposite directions. which can be done by adding another segment of code with diffrent direction values and a delay.

yeah thats just some basic stuff there hope it helps mate, if you get stuck with the code the audrino website is great for examples, audrino is pretty simular to C++.

goodluck 

Most likely your motor battery is flat or your wiring has a problem. Make sure your power wiring is thick enough to handle the current and make sure you do not have any loose connections.

Why are you using 9V for the 6V motors? what sort of battery are you using? The maximum voltage rating of the Rover 5 motors is 7.5V!

just using 6 AA batteries. i mean it is 9V going throught the motor supply in the dagu 4 channel, arent they meant to handle up to 12 volts? i have also used diffrent batteries to test if they were flat.

yeah i am using jumper leads i have some copper wire i could proberly switch them back to jumper leads and see if it helps. i used my multimeter an the voltage going in the logic was 5V and the voltage going in the motor supply was about 7.6Volts.

Your code looks ok so I suspect your wiring.

Your 5V logic supply is terrible. No filtering capacitors and all on breadboard. Without filtering capacitors it will be very unstable.

You would be much better feeding it straight from the UNO's 5V supply which will be properly filtered. The motor driver logic only needs a few mA.

 

 

cheers mate plugging it into the UNOs 5V supply works.

I was just wondering how do you set uo filtering capacitors? i have looked everywhere if you could point me in the right direction it would be great. I need a stable 5V supply to run my sensores off.

Using shoort distance Sharp IR Proximity, everytime we run it as it is the roover will just turn like heeps early oor not at all. 

here is the new code

int PinPWM_b1 = 3; //ch1
int PinPWM_b2 = 5; //ch2
int PinPWM_y1 = 10; //ch3
int PinPWM_y2 = 11; //ch4

int PinRot_g1 = 4; //ch1
int PinRot_g2 = 7; //ch2
int PinRot_r1 = 8; //ch3
int PinRot_r2 = 12; //ch4

int sensorPin=0; // The signal pin for the sensor
//int prox_min_short =    // about 4cm
//int prox_max_short =    // about 30cm
//int prox_min_mid =      // about 5cm
//int prow_max_mid =        // about 80cm

#define HIGH 0x1
#define LOW 0x0

// 2 is right motors 1 is left motors

void setup()
{
  Serial.begin(9600);
  pinMode(PinPWM_b1,OUTPUT); // back left motor pwm
  pinMode(PinPWM_b2,OUTPUT); // back right motor pwm
  pinMode(PinPWM_y1,OUTPUT); // front left motor pwm
  pinMode(PinPWM_y2,OUTPUT); // front right motor pwm

  pinMode(PinRot_g1,OUTPUT); // back left motor dir
  pinMode(PinRot_g2,OUTPUT); // back right motor dir
  pinMode(PinRot_r1,OUTPUT); // front left motor dir
  pinMode(PinRot_r2,OUTPUT); // front right motor dir
}

void loop()
{

  delay(2000);
 digitalWrite(PinRot_g1,LOW); // turn all motors forward
 digitalWrite(PinRot_g2,LOW); 
digitalWrite(PinRot_r1,HIGH);
  digitalWrite(PinRot_r2,HIGH);
  analogWrite(PinPWM_b1,200); // provide power to all motors
  analogWrite(PinPWM_b2,200); // test using HIGH or 255/200/etc HIGH is full power.
  analogWrite(PinPWM_y1,200);
  analogWrite(PinPWM_y2,200);
  delay(1000);
  digitalWrite(PinRot_g1,LOW); // turn all motors forward
  digitalWrite(PinRot_g2,LOW); 
  digitalWrite(PinRot_r1,HIGH);
  digitalWrite(PinRot_r2,HIGH);
  analogWrite(PinPWM_b1,200); // provide power to all motors
  analogWrite(PinPWM_b2,200); // test using HIGH or 255/200/etc HIGH is full power.
  analogWrite(PinPWM_y1,200);
  analogWrite(PinPWM_y2,200);
  delay(1000);

  float volts = analogRead(sensorPin)*0.00322265624; // Reads the signal from the sensor, returning a number.  The number is higher the closer an object gets.
  float distance = 12.21*pow(volts,-1.15);
  Serial.println(distance);
  delay(1000);

  if (distance > 200 ) // we have tried all sorts of values for this
  { 
    digitalWrite(PinPWM_b1,LOW); // stop motors
    digitalWrite(PinPWM_b2,LOW);
    digitalWrite(PinPWM_y1,LOW);
    digitalWrite(PinPWM_y2,LOW);
    delay(1000);
    digitalWrite(PinRot_r2,HIGH); // turn right motors
    digitalWrite(PinRot_g2,LOW); 
    digitalWrite(PinRot_r1,LOW); // turn left motors
    digitalWrite(PinRot_g1,HIGH); 
    analogWrite(PinPWM_y2,200); // provide power to right motors
    analogWrite(PinPWM_b2,200); 
    analogWrite(PinPWM_y1,200); // provide power to left motors
    analogWrite(PinPWM_b1,200); 
    delay(200);
    digitalWrite(PinRot_r2,HIGH); // turn right motors
    digitalWrite(PinRot_g2,LOW); 
    digitalWrite(PinRot_r1,LOW); // turn left motors
    digitalWrite(PinRot_g1,HIGH); 
    analogWrite(PinPWM_y2,200); // provide power to right motors
    analogWrite(PinPWM_b2,200); 
    analogWrite(PinPWM_y1,200); // provide power to left motors
    analogWrite(PinPWM_b1,200); 
    delay(200);
    digitalWrite(PinRot_r2,HIGH); // turn right motors
    digitalWrite(PinRot_g2,LOW); 
    digitalWrite(PinRot_r1,LOW); // turn left motors
    digitalWrite(PinRot_g1,HIGH); 
    analogWrite(PinPWM_y2,200); // provide power to right motors
    analogWrite(PinPWM_b2,200); 
    analogWrite(PinPWM_y1,200); // provide power to left motors
    analogWrite(PinPWM_b1,200); 
    delay(1000);
  }
  else
  {
    digitalWrite(PinRot_g1,LOW); // turn all motors forward
    digitalWrite(PinRot_g2,LOW); 
    digitalWrite(PinRot_r1,HIGH);
    digitalWrite(PinRot_r2,HIGH);
    analogWrite(PinPWM_b1,200); // provide power to all motors
    analogWrite(PinPWM_b2,200); // test using HIGH or 255/200/etc HIGH is full power.
    analogWrite(PinPWM_y1,200);
    analogWrite(PinPWM_y2,200);
    delay(1000);
    digitalWrite(PinRot_g1,LOW); // turn all motors forward
    digitalWrite(PinRot_g2,LOW); 
    digitalWrite(PinRot_r1,HIGH);
    digitalWrite(PinRot_r2,HIGH);
    analogWrite(PinPWM_b1,200); // provide power to all motors
    analogWrite(PinPWM_b2,200); // test using HIGH or 255/200/etc HIGH is full power.
    analogWrite(PinPWM_y1,200);
    analogWrite(PinPWM_y2,200);
    delay(1000);
  }

  //digitalWrite(PinPWM_b1,LOW); // stop motors
  //digitalWrite(PinPWM_b2,LOW);
  //digitalWrite(PinPWM_y1,LOW);
  //digitalWrite(PinPWM_y2,LOW);
  //delay(1000);
  //digitalWrite(PinRot_g1,HIGH); // turn all motors backwards
  //digitalWrite(PinRot_g2,HIGH); 
  //digitalWrite(PinRot_r1,LOW);
  //digitalWrite(PinRot_r2,LOW);
  //analogWrite(PinPWM_b1,200); // provide power to all motors
  //analogWrite(PinPWM_b2,200);
  //analogWrite(PinPWM_y1,200);
  //analogWrite(PinPWM_y2,200); 
  //delay(1000);
  //digitalWrite(PinRot_g1,HIGH); // turn all motors backwards
  //digitalWrite(PinRot_g2,HIGH); 
  //digitalWrite(PinRot_r1,LOW);
  //digitalWrite(PinRot_r2,LOW);
  //analogWrite(PinPWM_b1,200); // provide power to all motors
  //analogWrite(PinPWM_b2,200);
  //analogWrite(PinPWM_y1,200);
  //analogWrite(PinPWM_y2,200); 
  //delay(1000);
  //digitalWrite(PinPWM_b1,LOW); // stop motors
  //digitalWrite(PinPWM_b2,LOW);
  //digitalWrite(PinPWM_y1,LOW);
  //digitalWrite(PinPWM_y2,LOW);
  //delay(1000);
  //digitalWrite(PinRot_r2,HIGH); // turn right motors
  //digitalWrite(PinRot_g2,LOW); 
  //digitalWrite(PinRot_r1,LOW); // turn left motors
  //digitalWrite(PinRot_g1,HIGH); 
  //analogWrite(PinPWM_y2,200); // provide power to right motors
  //analogWrite(PinPWM_b2,200); 
  //analogWrite(PinPWM_y1,200); // provide power to left motors
  //analogWrite(PinPWM_b1,200); 
  //delay(1000);
  //digitalWrite(PinRot_r2,HIGH); // turn right motors
  //digitalWrite(PinRot_g2,LOW); 
  //digitalWrite(PinRot_r1,LOW); // turn left motors
  //digitalWrite(PinRot_g1,HIGH); 
  //analogWrite(PinPWM_y2,200); // provide power to right motors
  //analogWrite(PinPWM_b2,200); 
  //analogWrite(PinPWM_y1,200); // provide power to left motors
  //analogWrite(PinPWM_b1,200); 
  //delay(1000);
  //digitalWrite(PinRot_r2,HIGH); // turn right motors
  //digitalWrite(PinRot_g2,LOW); 
  //digitalWrite(PinRot_r1,LOW); // turn left motors
  //digitalWrite(PinRot_g1,HIGH); 
  //analogWrite(PinPWM_y2,200); // provide power to right motors
  //analogWrite(PinPWM_b2,200); 
  //analogWrite(PinPWM_y1,200); // provide power to left motors
  //analogWrite(PinPWM_b1,200); 
  //delay(1000);
  //digitalWrite(PinPWM_b1,LOW); // stop motors
  //digitalWrite(PinPWM_b2,LOW);
  //digitalWrite(PinPWM_y1,LOW);
  //digitalWrite(PinPWM_y2,LOW);
  //delay(1000);
}
 

How you mount your Sharp IR sensor can make a difference to how it responds. If it is too close to the ground or pointed slightly downward then it might react to the floor, especially with a rough surface like carpet.

As for your power supply. Start by reading my tip/walkthrough here: http://letsmakerobots.com/node/3880

You should also read the data sheets for common regulators such as the LM7805. They often specify minimum capacitance values and typical wiring diagrams.

 

Hey

We got all the sensors working and the rover was driving around advoiding objects and stuff and everythign was working well.However one time we switched it on to go and it is now not even moving at all. The audrino light still turns on i have checked the wiring and the motorcontroller is being supplied with both 5V logic and ~9V for motor supply.

Any ideas of what it could be or suggestions on what to do? 

Thankyou

p.s. will be uploading more photos

int PinPWM_b1 = 3; //ch1
int PinPWM_b2 = 5; //ch2
int PinPWM_y1 = 10; //ch3
int PinPWM_y2 = 11; //ch4

int PinRot_g1 = 4; //ch1
int PinRot_g2 = 7; //ch2
int PinRot_r1 = 8; //ch3
int PinRot_r2 = 12; //ch4

#define HIGH 0x1
#define LOW 0x0

// 2 is right motors 1 is left motors

void setup()
{
Serial.begin(9600);
pinMode(PinPWM_b1,OUTPUT); // back left motor pwm
pinMode(PinPWM_b2,OUTPUT); // back right motor pwm
pinMode(PinPWM_y1,OUTPUT); // front left motor pwm
pinMode(PinPWM_y2,OUTPUT); // front right motor pwm

pinMode(PinRot_g1,OUTPUT); // back left motor dir
pinMode(PinRot_g2,OUTPUT); // back right motor dir
pinMode(PinRot_r1,OUTPUT); // front left motor dir
pinMode(PinRot_r2,OUTPUT); // front right motor dir
}

void loop()
{
digitalWrite(PinRot_g1,HIGH); // turn all motors backwards
digitalWrite(PinRot_g2,HIGH); 
digitalWrite(PinRot_r1,LOW);
digitalWrite(PinRot_r2,LOW);
analogWrite(PinPWM_b1,200); // provide power to all motors
analogWrite(PinPWM_b2,200);
analogWrite(PinPWM_y1,200);
analogWrite(PinPWM_y2,200); 
delay(1000);
digitalWrite(PinPWM_b1,LOW); // stop motors
digitalWrite(PinPWM_b2,LOW);
digitalWrite(PinPWM_y1,LOW);
digitalWrite(PinPWM_y2,LOW);
delay(1000);
digitalWrite(PinRot_g1,LOW); // turn all motors forward
digitalWrite(PinRot_g2,LOW); 
digitalWrite(PinRot_r1,HIGH);
digitalWrite(PinRot_r2,HIGH);
analogWrite(PinPWM_b1,200); // provide power to all motors
analogWrite(PinPWM_b2,200); // test using HIGH or 255/200/etc HIGH is full power.
analogWrite(PinPWM_y1,200);
analogWrite(PinPWM_y2,200);
delay(1000);
digitalWrite(PinPWM_b1,LOW); // stop motors
digitalWrite(PinPWM_b2,LOW);
digitalWrite(PinPWM_y1,LOW);
digitalWrite(PinPWM_y2,LOW);
delay(1000);
digitalWrite(PinRot_r2,HIGH); // turn right motors
digitalWrite(PinRot_g2,LOW); 
digitalWrite(PinRot_r1,LOW); // turn left motors
digitalWrite(PinRot_g1,HIGH); 
analogWrite(PinPWM_y2,200); // provide power to right motors
analogWrite(PinPWM_b2,200); 
analogWrite(PinPWM_y1,200); // provide power to left motors
analogWrite(PinPWM_b1,200); 
delay(1000);
digitalWrite(PinPWM_b1,LOW); // stop motors
digitalWrite(PinPWM_b2,LOW);
digitalWrite(PinPWM_y1,LOW);
digitalWrite(PinPWM_y2,LOW);
delay(1000);
}

Hey this is my revised code i still cant seem to get it to go in reverse tho, is it possible i am having a problem with my audrino or motor controller? 

First problem I see is you are using digitalWrite to control the PWM pins. This will just make the motors go full speed or stop. You need to use analogWrite for the PWM pins.