Let's Make Robots!

Robot gutless and slow....

Ok, so I finally got him put together, and it turns out that he doesnt move worth a damn.... I cant figure out what I did wrong. The tamiya twin motor is set for low range, but it still shouldnt be THIS slow... turning is almost impossible for him... Even on smooth flooring.... I shot a quick video for you all to see and hopefully help me figure out what is going on...

 

This is the H bridge I am using... SN754410   from sparkfun. The data sheet said i could save pins by hooking the enable pins up to a 5v source, so I did that..... VCC1 is connected to the 5v on the arduino, Vcc2 is hooked up to the same power source as the motors/IC, with common ground. My arduino has its own power source. Ignore the wire coloring, I only had 2 colors and the ones i used here were for my reference, not to indicate hot and ground.

 Power for the board is 4xAA alkaline batteries. Power for arduino is 1 9v battery. 

 

 grr


 
I have no idea what to do here....
 
Can anyone help? Thanks in advance.

Comment viewing options

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

Sounds like you got it right but the fact that the motors are so slow could indicate that you're trying to power them from the Arduino.

So double check your wiring:

* The 2 enable pins and VCC1 should be connected to the 5V Arduino output (this would probaly work hooked up to the battery too as long as it's ~5V)

 * VCC2 should be hooked up to the battery pack (this is important because the motors will draw the current from here)

* The motors should be hooked up to the terminal outputs on the H-bridge

* All the 4 grounds on the H-brigde should be connected to the Arduino ground

That should do it.

About PWM (pulse width modulation): In short it means that the power will be turned on and off very quickly. When we're talking motor control this means that you can simulate different voltages (from 0V to 5V) and therefore control the SPEED of the motors.

To do this from the Arduino you use the analogWrite() function instead of the digitalWrite() function. And instead of writing HIGH/LOW you write a number between 0 and 225 which indicates how much the PWM signal will be on or off. 0 means it will be off all the time thus the output is 0V. 225 means it is on all the time thus the output is 5V. 127 for example means that it is off 50% of the time and on 50% of the time. This would be like feeding the motors 2.5V.

PS: You don't (need to) use the pinMode() function when using analogWrite() unlike digitalWrite()...

There seems to be something wrong here:

VCC1 is connected to the 5v on the arduino, Vcc2 is hooked up to the same power source as the motors/IC, with common ground.

VCC1 should be connected to 5V on the Arduino.

But I don't get that VCC2 is hooked up to the same source as the motors/IC? The motors should not be hooked up directly to any powersource. They should be connected to the PWM outputs on the H-bridge.

VCC2 should be connected to the AA battery pack.

But I'm not even sure I understood you correctly? :/

Yes, I didnt explain correctly. VCC2 is hooked up to the power source that the h bridge is running off of. the motors are connected to the outputs on the chip. Sorry about that. 

 Now, about the PWM outputs....

 the wires that go to the inputs on the h bridge are connected to 4,5,6,7 on my arduino... only two of those are PWM. I never really understood what PWM was for...  Let me post the code i am using as well.... It isn't pretty, but i'm still new to coding....

 

#define leftDir1      7      // Left motor direction 1, to AIn1.

#define leftDir2      6      // Left motor direction 2, to AIn2.

#define rightDir1     5      // Right motor direction 1, to BIn1.

#define rightDir2     4      // Right motor direction 2, to BIn2.

 

 

void setup()                                                 

{

  pinMode(leftDir1, OUTPUT);        // Set motor direction pins as outputs.

  pinMode(leftDir2, OUTPUT);      

  pinMode(rightDir1, OUTPUT);      

  pinMode(rightDir2, OUTPUT); 

 

}

 

void loop()                    

{

 

drive_forward();

delay(8000);

motor_stop();

delay(2000);

turn_left();

delay(5000);

motor_stop();

delay(2000);

drive_forward();

delay(6000);

motor_stop();

delay(2000);

turn_left();

delay(5000);

motor_stop();

delay(2000);

drive_forward();

delay(8000);

motor_stop();

delay(2000);

turn_left();

delay(5000);

motor_stop();

delay(2000);

drive_forward();

delay(6000);

motor_stop();

delay(2000);

turn_left();

delay(4000);

 

}

 

// motor movements

 

void motor_stop(){

  digitalWrite(leftDir1, HIGH); 

  digitalWrite(leftDir2, HIGH); 

 

  digitalWrite(rightDir1, HIGH); 

  digitalWrite(rightDir2, HIGH);

}

 

void drive_forward(){

 

  digitalWrite(leftDir1, LOW); 

  digitalWrite(leftDir2, HIGH); 

 

  digitalWrite(rightDir1, HIGH); 

  digitalWrite(rightDir2, LOW); 

}

 

void turn_left(){

  digitalWrite(leftDir1, HIGH); 

  digitalWrite(leftDir2, LOW); 

 

  digitalWrite(rightDir1, HIGH); 

  digitalWrite(rightDir2, LOW); 

}

 

void turn_right(){

  digitalWrite(leftDir1, LOW); 

  digitalWrite(leftDir2, HIGH); 

 

  digitalWrite(rightDir1, LOW); 

  digitalWrite(rightDir2, HIGH);