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.

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

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()...

My enable pins are wired in with the +5 on Vcc2, not the arduino. Could they be pulling current away from the motors? my grounds are all common and wired to the ground on the arduino already.... Just to make sure before i do this (its going to take some doing to get at the driver board) I should wire both enables and the lead from VCC1 to the arduino's 5v?

 

I really want to make sure of this before i tear into the board. Am I clear on your instructions? 

ooh, and also....

 

On the arduino, there are 2 ground connections and only 1 5v connection. are the grounds common? can i use either one? 

Did you double-check the 4xAA batteries are new and up to full voltage? It looks like a low battery supply.

Sorry if this is obvious and you've already checked. Some times even the most experienced people forget to check the basics. 

based on your video, that looks about as fast as those motors are meant to go. the left turn is so slow because one motor is doing all the work. To turn, have one motor go forward, one backward.

So last night after my last post, i rebuilt his gearbox for higher speed. He doesnt move at all now with the treads on. I dont know what the heck is going on....

 

@ aniss, i did the re-wiring of my enable pins and it seems like it did nothing.

 

@ignoblegnome, yes i checked the batteries

 

@calculon, I think both motors are turning in opposite directions when hanging a left already.... check my code above.

 

I just woke up, and after some sleep, maybe i will be able to figure out what is going on... In the meantime, keep coming up with ideas for me to try. you guys are being very helpful. Thank you. 

That chip needs flyback diodes. It is not a direct replacement for the L293D as Sparkfun say because the L293D has the diodes internal. The output pin circuit diagram shows ESD protection diodes but flyback diodes should be added as shown in the schematic on page 6 of the datasheet.

This pic ishows the diode arrangement better and is easier to understand than the datasheet diagram. Any diodes at least 1A should be ok.

robot1.gif

Err.... can you dumb that down for me? Do I need to put diodes in line between the the output pins and the motors? Ive never done anything this intricate before... Sorry for the ignorance....

Take me to diode school please?