Let's Make Robots!

Problem with Arduino and SN754410 circuit

I arranged this circuit to prevent wires from crossing each other... I'm using using paperclips to make the circuit =). This is what I have so far: 

snDriver_bb.jpg

I tested the circuit and it works! Just one problem: during the "void setup()"part of my code (Arduino), the motor starts to run without any input. I tried to set the PWM pin low, but it didn't worked. How could I fix this? Pull-down resistors? Here's the code I'm using:

//Motor Fade Test

const int pwm=12;
const int dir=13;
int i=0;

void setup() {
  pinMode(pwm, OUTPUT);
  pinMode(dir, OUTPUT);
  delay(5000);
}

void loop() {
  digitalWrite(dir, LOW);
  for(i=0; i<=255; i+=5) {
    analogWrite(pwm, i);
    delay(50);
  }
  for(i=255; i>=0; i-=5) {
    analogWrite(pwm, i);
    delay(50);
  }
  digitalWrite(pwm, LOW);
  delay(75);
  digitalWrite(dir, HIGH);
  for(i=0; i<=255; i+=5) {
    analogWrite(pwm, i);
    delay(50);
  }
  for(i=255; i>=0; i-=5) {
    analogWrite(pwm, i);
    delay(50);
  }
  digitalWrite(pwm, LOW);
  delay(75);
}

Comment viewing options

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

I don't know yet how to read Fritz schematics, but you could try adding

analogWrite(pwm, 0);

digitalWrite(dir, LOW);

right before your delay(5000).

Everything looks fine to me. Since you've got the pull-up resistors and NPN inverter controlling the 'direction' inputs, a pull-down resistor on the enable line is probably the way to go. As well as keeping everything settled during the startup phase, it'll help disable the motor driver if there's an error/short/broken connection or if you disconnect the microcontroller.

I'd also suggest adding the same pull-up and pull-down resistors on the enable/direction pins for the 2 unused half H-bridges - if left 'floating' those inputs can oscillate wildly which consumes extra power and generates electrical noise. It's not really critical, but for the cost of 3 resistors you might as well.

In what part of the circuit goes the pull-down resistor and how do I keep "everything settled"? ...capacitors... .1 to .3μF? Thanks.

EDIT: a cap from .1 to .3μF would be to eliminate noise right? Is that what you mean by "settled"?

The pull-down goes from the enable pin to ground. You probably don't need to worry about the capacitors for this circuit, unless you run into specific problems - the pull-down resistors should be enough.