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.

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? 

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