Pages: [1] 2   Go Down
Author Topic: can anyone help me with prgraming the DFRobot 4WD Arduino Mobile Platform?  (Read 3363 times)
0 Members and 1 Guest are viewing this topic.
Visalia CA
Offline Offline
Newbie
*
Karma: 0
Posts: 7
building robots for the purpose of world domination
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

« Last Edit: January 01, 2012, 05:30:32 pm by Megalomaniac_victim » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 553
Posts: 46299
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Visalia CA
Offline Offline
Newbie
*
Karma: 0
Posts: 7
building robots for the purpose of world domination
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 553
Posts: 46299
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What a crappy site. No links to any documentation for the ROMEO clone. However, google to the rescue:
http://www.dfrobot.com/wiki/index.php?title=DFRduino_Romeo-All_in_one_Controller_%28SKU:DFR0004%29
Logged

Visalia CA
Offline Offline
Newbie
*
Karma: 0
Posts: 7
building robots for the purpose of world domination
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Espoo, Finland
Offline Offline
God Member
*****
Karma: 6
Posts: 586
"Oops, try again..."
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


The only law for me; Ohms Law: U=R*I       P=U*I
Note to self: "Damn! Why don't you just fix it!!!"

Visalia CA
Offline Offline
Newbie
*
Karma: 0
Posts: 7
building robots for the purpose of world domination
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
       }
     
}
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 553
Posts: 46299
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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.

Code:
    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.
Logged

Espoo, Finland
Offline Offline
God Member
*****
Karma: 6
Posts: 586
"Oops, try again..."
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
//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
Logged


The only law for me; Ohms Law: U=R*I       P=U*I
Note to self: "Damn! Why don't you just fix it!!!"

Visalia CA
Offline Offline
Newbie
*
Karma: 0
Posts: 7
building robots for the purpose of world domination
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
.
« Last Edit: January 02, 2012, 11:30:44 am by Megalomaniac_victim » Logged

Espoo, Finland
Offline Offline
God Member
*****
Karma: 6
Posts: 586
"Oops, try again..."
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

...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
« Last Edit: January 02, 2012, 11:41:10 am by GaryP » Logged


The only law for me; Ohms Law: U=R*I       P=U*I
Note to self: "Damn! Why don't you just fix it!!!"

Visalia CA
Offline Offline
Newbie
*
Karma: 0
Posts: 7
building robots for the purpose of world domination
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you! swapping the wires did the job.
Logged

Espoo, Finland
Offline Offline
God Member
*****
Karma: 6
Posts: 586
"Oops, try again..."
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

But can you control the speed?
Logged


The only law for me; Ohms Law: U=R*I       P=U*I
Note to self: "Damn! Why don't you just fix it!!!"

Visalia CA
Offline Offline
Newbie
*
Karma: 0
Posts: 7
building robots for the purpose of world domination
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
}

}
« Last Edit: January 02, 2012, 07:44:20 pm by Megalomaniac_victim » Logged

Espoo, Finland
Offline Offline
God Member
*****
Karma: 6
Posts: 586
"Oops, try again..."
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


The only law for me; Ohms Law: U=R*I       P=U*I
Note to self: "Damn! Why don't you just fix it!!!"

Pages: [1] 2   Go Up
Jump to: