can anyone help me with prgraming the DFRobot 4WD Arduino Mobile Platform?

Hello, I have just entered the word of hobby robotics and Arduino hardware and softwear. I just recently have finished constructing the DFRobot 4WD Arduino Mobile Platform using the recommended Arduino romeo Microcontroller. The robot is currently hooked up to my desktop. I have gotten the LED on the board to blink but I have no idea how to get robot move. Any help that you could provide would be greatly appreciated. Thank you

Well, victim, if you post some links to the devices you have, you are likely to get more responses.

Ok, thank you

link for my project: http://www.diybin.com/products/DFRobot-4WD-Arduino-Powered-Mobile-Platform-with-Romeo.html

The above url includes description of the kit and the Microcontroller that I used thanks again for any help you are willing to give

What a crappy site. No links to any documentation for the ROMEO clone. However, google to the rescue:

Thank you very much, I now am able to control it from my keyboard. Now I just need to adjust the wiring so that the motors arent driving in different directions. And again, thank you very much.

We have that same board in our project, driving main motors. Took a while to understand how it (Romeo) works, since it was our first of a kind, but now that is like a bad dream in the past.

Motor control jumper pins are using Digital pins 5 and 6 to control the speed. Well thats kind of ok, but those pins uses Timer0. So they are tied to low PWM frequency. You should use pins 9 and 10 instead, and change the frequency to more usable 31kHz.

http://www.arduino.cc/playground/Main/TimerPWMCheatsheet

It is worthed.

Cheers,
Kari

Thank you for your support, but it seems i have run into yet another problem. The back and front motors are driving away from eachother, even though i connected the right side motors and left side motors into different terminals. If anyone can explain what I am doing wrong I would be quite thankful.

here is the code i am using to control the rover using a keyboard:

int E1 = 4; //M1 Speed Control
int E2 = 7; //M2 Speed Control
int M1 = 5; //M1 Direction Control
int M2 = 6; //M1 Direction Control

///For previous Romeo, please use these pins.
//int E1 = 6; //M1 Speed Control
//int E2 = 9; //M2 Speed Control
//int M1 = 7; //M1 Direction Control
//int M2 = 8; //M1 Direction Control

//When m1p/m2p is 127, it stops the motor
//when m1p/m2p is 255, it gives the maximum speed for one direction
//When m1p/m2p is 0, it gives the maximum speed for reverse direction

void DriveMotorP(byte m1p, byte m2p)//Drive Motor Power Mode
{

digitalWrite(E1, HIGH);
analogWrite(M1, (m1p));

digitalWrite(E2, HIGH);
analogWrite(M2, (m2p));

}

void setup(void)
{
int i;
for(i=6;i<=9;i++)
pinMode(i, OUTPUT);
Serial.begin(19200); //Set Baud Rate
}
void loop(void)
{
char val = Serial.read();
if(val!=-1)
{
switch(val)
{
case 'w'://Move Forward
DriveMotorP(0xff,0xff);
break;
case 'x'://Move Backward
DriveMotorP(0x00,0x00);;
break;
case 's'://Stop
DriveMotorP(0x7f,0x7f);
break;

}
delay(40);
}

}

int E1 = 4;     //M1 Speed Control
int E2 = 7;     //M2 Speed Control
int M1 = 5;    //M1 Direction Control
int M2 = 6;    //M1 Direction Control

Speed control requires PWM pins - 4 and 7 are not PWM pins. Direction control does not. So, these comments are wrong.

    digitalWrite(E1, HIGH);
   analogWrite(M1, (m1p));
       
   digitalWrite(E2, HIGH);
   analogWrite(M2, (m2p));

The parentheses around m1p and m2p are not required. You do not necessarily need to set the directions the same. Set the direction pins so that the motors both move the robot the same way.

Right. This is direct copy behind the link that PaulS gave:

//Standard PWM DC control

int E1 = 5;     //M1 Speed Control
int E2 = 6;     //M2 Speed Control
int M1 = 4;    //M1 Direction Control
int M2 = 7;    //M1 Direction Control

Is this your code you show us, or is it found elsewhere?

If you swap motor's wires, the direction will change, try just one motor at a time. You could also draw a diagram to satisfy our curiosity, and making helping a bit easier.

Cheers,
Kari

sorry, when i said "the code i am using" i should have stated that it was the same code that PaulS had show me throgh the link he posted earlier. I guess I should have clarified the source
.

Megalomaniac_victim:
...it was the same code that PaulS had show me throgh the link he posted earlier....
.

Are you sure? Check motor control pin names and digital pins they are connected.

But you should also check wires, swapping +/- will change rotation direction, if some motor is running wrong.

Cheers,
Kari

Thank you! swapping the wires did the job.

But can you control the speed?

yes, using the code I found in the romeo manual here-->http://ro-botica.com/img/Arduino/PDF/RoMeoManual.pdf

I made a few changes, which include adding a stop key and changing the motor speed. Here is the excect code I am using now:

int E1 = 5; //M1 Speed Control
int E2 = 6; //M2 Speed Control
int M1 = 4; //M1 Direction Control
int M2 = 7; //M1 Direction Control

void advance(char a,char b) //Move forward
{
analogWrite (E1,a); //PWM Speed Control
digitalWrite(M1,HIGH);
analogWrite (E2,b);
digitalWrite(M2,HIGH);
}
void back_off (char a,char b) //Move backward
{
analogWrite (E1,a);
digitalWrite(M1,LOW);
analogWrite (E2,b);
digitalWrite(M2,LOW);
}
void turn_L (char a,char b) //Turn Left
{
analogWrite (E1,a);
digitalWrite(M1,LOW);
analogWrite (E2,b);
digitalWrite(M2,HIGH);
}
void turn_R (char a,char b) //Turn Right
{
analogWrite (E1,a);
digitalWrite(M1,HIGH);
analogWrite (E2,b);
digitalWrite(M2,LOW);
}
void stop_all (char a, char b) //stop
{
analogWrite (E1,a);
digitalWrite(M1,LOW);
analogWrite (E2,b);
digitalWrite(M2,LOW);
}

void setup(void)
{
int i;
for(i=6;i<=9;i++)
pinMode(i, OUTPUT);
Serial.begin(19200); //Set Baud Rate
}
void loop(void)
{
char val = Serial.read();
if(val!=-1)
{
switch(val)
{
case 'w'://Move Forward
advance (500,500); //PWM Speed Control
break;
case 's'://Move Backward
back_off (500,500);
break;
case 'a'://Turn Left
turn_L (500,500);
break;
case 'd'://Turn Right
turn_R (500,500);
break;
case 'x'://stop
stop_all (000,000);
break;
}
delay(40);
}

}

My friend! You are not asking the questions, pay more attention.

Here's one:

When you add code to your post, click "#"-button, and add your code between "code"-blocks. Somebody might get nervous when the code gets longer, it's hard to read.
Let's see how you handle that.

Now, can you control the speed correctly now?

Cheers,
Kari

analogWrite (E1,a); //PWM Speed Control
digitalWrite(M1,HIGH);

Step on the gas, then put it into gear. Oooh. That's hard on the transmission.

advance (500,500); //PWM Speed Control

How well do you suppose 500 fits into a char? Not well at all.

analogWrite() won't do what you expect with a value of 500, even if it did fit in a char, either.

Mega...victim, do you see anything funny here?

int E1 = 5; //M1 Speed Control
int E2 = 6; //M2 Speed Control
int M1 = 4; //M1 Direction Control
int M2 = 7; //M1 Direction Control

You should clear some things, and maybe even give names that are more logical.
I understand you, I have lot's of problems with my naming habit in my own code, but that's another story...

And what are the limits for PWM output? You have one byte to use.

Cheers,
Kari

An off topic question, but I have the same chassis and mine came with yellow motors. Apparently there are different specs for the yellow motors and the green motors. According to the specs of the yellow motors, that Romeo won't work with the 2A current draw, but the specs on the site you provided are the specs of the green motors.

http://www.robotshop.com/ca/dfrobot-4wd-arduino-mobile-platform-4.html. this shows the specs for both of the motors.

Can you give specs for these ... colourful motors? Does they really draw 2A each? Or what?

Link won't open at the moment, they are servicing the website.

Cheers,
Kari

Green Motor

  • Gear Ratio 1:120
  • No-load speed(3V):100RPM
  • No-load speed(6V):200RPM
  • No-load current(3V):60mA
  • No-load current(6V):71mA
  • Stall current(3V):260mA
  • Stall current(6V):470mA
  • Torgue (3V): 1.2Kgcm
  • Torque (6V): 1.92Kgcm
  • Size: 55mm x 48.3mm x 23mm
  • Weight:45g

Yellow Motor

  • Motor Model: 130 Motor
  • Output Mode: Two-way shaft output
  • Gear ratio: 1:120
  • No-load speed (3V): 90RPM
  • No-load speed (6V): 180RPM
  • No load current (3V): 120mA
  • No load current (6V): 160mA
  • Locked-rotor current (3V): 1.5A
  • Locked-rotor current (6V): 2.8A
  • Size: Long 55MM W 48.3MM high-23MM
  • Weight: About 45g