Go Down

Topic: Diecimila and SN754410 H-Bridge (Read 7248 times) previous topic - next topic

daharde1

Feb 04, 2008, 10:43 pm Last Edit: Feb 04, 2008, 10:43 pm by daharde1 Reason: 1
I have a Diecimila and a SN754410 H-bridge.

I was trying to follow this tutorial:

http://itp.nyu.edu/physcomp/Labs/DCMotorControl

But I'm not sure how to attach the Motor Power Supply.

In this photo, it shows a yellow wire going from the Vcc2 of the H-bridge (Motor Power Supply) to what looks like a 9V power pin on the Arduino:



But I do not see a 9V power pin on my Diecimila.

Am I totally off base here?  The tutorial makes referrence to a 12V power supply: "The example above uses 12V, run in parallel with the 5V voltage regulator that supplies the Arduino board. "

Is there a better tutorial I should be following?  

daharde1

I'll answer my own post:

I found this tutorial that uses the older arduino and an L293 h-bridge:

http://www.toddholoubek.com/classes/pcomp/hbridge/Hbridgel293.html

I followed that one and was able to get the motor moving in both directions.

I modified it to move based on a serial command: A for left and B for right.

nkcelectronics

Quote
I have a Diecimila and a SN754410 H-bridge.

I was trying to follow this tutorial:

http://itp.nyu.edu/physcomp/Labs/DCMotorControl

But I'm not sure how to attach the Motor Power Supply.

In this photo, it shows a yellow wire going from the Vcc2 of the H-bridge (Motor Power Supply) to what looks like a 9V power pin on the Arduino:



But I do not see a 9V power pin on my Diecimila.

Am I totally off base here?  The tutorial makes referrence to a 12V power supply: "The example above uses 12V, run in parallel with the 5V voltage regulator that supplies the Arduino board. "

Is there a better tutorial I should be following?  

I don't see a ground wire going from the Arduino board to the breadboard

nkcelectronics

Quote
I have a Diecimila and a SN754410 H-bridge.

I was trying to follow this tutorial:

http://itp.nyu.edu/physcomp/Labs/DCMotorControl

But I'm not sure how to attach the Motor Power Supply.

In this photo, it shows a yellow wire going from the Vcc2 of the H-bridge (Motor Power Supply) to what looks like a 9V power pin on the Arduino:



But I do not see a 9V power pin on my Diecimila.

Am I totally off base here?  The tutorial makes referrence to a 12V power supply: "The example above uses 12V, run in parallel with the 5V voltage regulator that supplies the Arduino board. "

Is there a better tutorial I should be following?  

I think in the Diecimila it says "Vin", as it is not necessarily 9V, but the actual input voltage (before the 5V regulator)

daharde1

Oh.  I was looking at this site:  http://www.arduino.cc/en/Main/ArduinoBoardDiecimila, and it says "Leads from a battery can be inserted in the Gnd and Vin pin headers of the POWER connector."

I thought this meant that Vin was a voltage input.  I'm going to run some basic tests with my multimeter and figure out the power pins.

mellis

The VIN pin is connected to the input voltage of the board (before the regulator).  That means that if you plug a wall-wart power supply into the power jack on the board, the VIN pin will provide the voltage of that power supply (less a 0.6V or so drop across a diode).  If  you don't plug in a wall-wart power supply, you can use the VIN pin to supply power to the board (from a battery for example).  So it can be either an input or output pin.

daharde1

Wow, thanks mellis!

That is the answer I was looking for!

rcottiss

Quote

I don't see a ground wire going from the Arduino board to the breadboard


If you go to the original article (http://itp.nyu.edu/physcomp/Labs/DCMotorControl) there are some earlier steps that show the 5V and GND connections from the Arduino. This photo comes from a section discussing the motor connections - so I guess they are left out for clarity. I just followed the article and it worked fine.

Robin

cmdowns

Not sure if anyone will read this, as this thread is several months old.

I'm attempting a similar project as the one described. I'm having some problems driving the motors with my SN754410 H-bridge using PWM.

Setup is basically as follows: Arduino Diecimilia wired to one side of the H-bridge, driving an FA-130 motor. I'm supplying 5v from the Arduino's 5v pin to the H-bridge's pin 16 (Vcc1, according to the datasheet) and approx 3v to the H-bridge's motor supply pin from 2 AA batteries.

This seems to work alright if I do a simple digitalWrite to the H-bridge's enable pin (pin1). But I can't get my motor to run if I attempt to analogWrite a PWM signal to the, even at the full 255.

Does anyone know a reason why the H-bridge would send more power to the motor with a standard digital signal controlling the enable pin versus maximum PWM signal?

nkcelectronics

Quote
Not sure if anyone will read this, as this thread is several months old.

I'm attempting a similar project as the one described. I'm having some problems driving the motors with my SN754410 H-bridge using PWM.

Setup is basically as follows: Arduino Diecimilia wired to one side of the H-bridge, driving an FA-130 motor. I'm supplying 5v from the Arduino's 5v pin to the H-bridge's pin 16 (Vcc1, according to the datasheet) and approx 3v to the H-bridge's motor supply pin from 2 AA batteries.

This seems to work alright if I do a simple digitalWrite to the H-bridge's enable pin (pin1). But I can't get my motor to run if I attempt to analogWrite a PWM signal to the, even at the full 255.

Does anyone know a reason why the H-bridge would send more power to the motor with a standard digital signal controlling the enable pin versus maximum PWM signal?

Make sure that the Arduino pin you selected can do PWM.

qweety

hello: )

I hope someone can help , as i am a bit stuck : )

i have managed to make my h bridge work, the motor spins one way and the other at the fixed speed: ) (so the code for the H bridge works fine on my arduino )

however i tried to include a variable pot to control a PWM signal from pin 9 going into the enable pin of the h- bridge.

to do this i need to join together the two codes below so they work together.

*****the h bridge code is  >>>


 const int switchPin = 2;    // switch input
 const int motor1Pin = 3;    // H-bridge leg 1 (pin 2, 1A)
 const int motor2Pin = 4;    // H-bridge leg 2 (pin 7, 2A)
 const int enablePin = 9;    // H-bridge enable pin
 const int ledPin = 13;      // LED

 void setup() {
   // set the switch as an input:
   pinMode(switchPin, INPUT);

   // set all the other pins you're using as outputs:
   pinMode(motor1Pin, OUTPUT);
   pinMode(motor2Pin, OUTPUT);
   pinMode(enablePin, OUTPUT);
   pinMode(ledPin, OUTPUT);

   // set enablePin high so that motor can turn on:
   digitalWrite(enablePin, HIGH);

   // blink the LED 3 times. This should happen only once.
   // if you see the LED blink three times, it means that the module
   // reset itself,. probably because the motor caused a brownout
   // or a short.
   blink(ledPin, 3, 100);
 }

 void loop() {
   // if the switch is high, motor will turn on one direction:
   if (digitalRead(switchPin) == HIGH) {
     digitalWrite(motor1Pin, LOW);   // set leg 1 of the H-bridge low
     digitalWrite(motor2Pin, HIGH);  // set leg 2 of the H-bridge high
   }
   // if the switch is low, motor will turn in the other direction:
   else {
     digitalWrite(motor1Pin, HIGH);  // set leg 1 of the H-bridge high
     digitalWrite(motor2Pin, LOW);   // set leg 2 of the H-bridge low
   }
 }

 /*
   blinks an LED
  */
 void blink(int whatPin, int howManyTimes, int milliSecs) {
   int i = 0;
   for ( i = 0; i < howManyTimes; i++) {
     digitalWrite(whatPin, HIGH);
     delay(milliSecs/2);
     digitalWrite(whatPin, LOW);
     delay(milliSecs/2);
   }
 }


*****> the variable PWM code is this:

int potPin = 0;    // Analog input pin that the potentiometer is attached to
int potValue = 0;   // value read from the pot
int led = 9;    // PWM pin that the LED is on.  n.b. PWM 0 is on digital pin 9

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
  // declare the led pin as an output:
  pinMode(led, OUTPUT);
}

void loop() {
  potValue = analogRead(potPin); // read the pot value
  analogWrite(led, potValue/4);  // PWM the LED with the pot value (divided by 4 to fit in a byte)
  Serial.println(potValue);      // print the pot value back to the debugger pane
  delay(10);                     // wait 10 milliseconds before the next loop
}


*****>>I joined them together in this way :


 const int switchPin = 2;    // switch input
 const int motor1Pin = 3;    // H-bridge leg 1 (pin 2, 1A)
 const int motor2Pin = 4;    // H-bridge leg 2 (pin 7, 2A)
 const int enablePin = 9;    // H-bridge enable pin
 const int ledPin = 13;      // LED

int potPin = 0;    // Analog input pin that the potentiometer is attached to
int potValue = 0;   // value read from the pot
int led = 9;    // PWM pin that the LED is on.  n.b. PWM 0 is on digital pin 9


 void setup() {
   // set the switch as an input:
   pinMode(switchPin, INPUT);

   // set all the other pins you're using as outputs:
   pinMode(motor1Pin, OUTPUT);
   pinMode(motor2Pin, OUTPUT);
   pinMode(enablePin, OUTPUT);
   pinMode(ledPin, OUTPUT);

   // set enablePin high so that motor can turn on:
   digitalWrite(enablePin, HIGH);

   // blink the LED 3 times. This should happen only once.
   // if you see the LED blink three times, it means that the module
   // reset itself,. probably because the motor caused a brownout
   // or a short.
   blink(ledPin, 3, 100);
 // initialize serial communications at 9600 bps:
  Serial.begin(9600);
  // declare the led pin as an output:
  pinMode(led, OUTPUT);
}

 }

 void loop() {
   // if the switch is high, motor will turn on one direction:
   if (digitalRead(switchPin) == HIGH) {
     digitalWrite(motor1Pin, LOW);   // set leg 1 of the H-bridge low
     digitalWrite(motor2Pin, HIGH);  // set leg 2 of the H-bridge high
   }
   // if the switch is low, motor will turn in the other direction:
   else {
     digitalWrite(motor1Pin, HIGH);  // set leg 1 of the H-bridge high
     digitalWrite(motor2Pin, LOW);   // set leg 2 of the H-bridge low
   }
 }

 /*
   blinks an LED
  */
 void blink(int whatPin, int howManyTimes, int milliSecs) {
   int i = 0;
   for ( i = 0; i < howManyTimes; i++) {
     digitalWrite(whatPin, HIGH);
     delay(milliSecs/2);
     digitalWrite(whatPin, LOW);
     delay(milliSecs/2);
   }potValue = analogRead(potPin); // read the pot value
  analogWrite(led, potValue/4);  // PWM the LED with the pot value (divided by 4 to fit in a byte)
  Serial.println(potValue);      // print the pot value back to the debugger pane
  delay(10);                     // wait 10 milliseconds before the next loop
}




any help would be great as i dont think i have it just right


peace

:  )







Grumpy_Mike

Quote
as i dont think i have it just right


You don't have it at all.
First off use the # button when posting code.

Next to merge two sketches make sure you have no pins used in both sketches, if you do the assign different ones in one sketch.
Rename your setup() functions setup1() and setup2(), the same with your loop functions.
Then make new setup and loop functions that call up the original functions:-
Code: [Select]
void setup() {
setup1();
setup2();
}
void loop() {
loop1();
loop2();
}

Put them into one file and run them. If the don't do what you want then think about what you do want.

qweety

hello : )

thanks i just made it work : )  pheww. so glad.

i shall test this code upload thing your mention here goes .
the code below worked for me  ( pin 9 has pwm out for the h bridge enable pin to allow variable speed on the motor.

thanks for your reply.

Code: [Select]

 const int switchPin = 2;    // switch input
 const int motor1Pin = 3;    // H-bridge leg 1 (pin 2, 1A)
 const int motor2Pin = 4;    // H-bridge leg 2 (pin 7, 2A)
 const int enablePin = 9;    // H-bridge enable pin
 const int ledPin = 13;      // LED
int potPin = 0;    // Analog input pin that the potentiometer is attached to
int potValue = 0;   // value read from the pot
int led = 9;    // PWM pin that the LED is on.  n.b. PWM 0 is on digital pin 9

 void setup() {
// initialize serial communications at 9600 bps:
  Serial.begin(9600);
  // declare the led pin as an output:
  pinMode(led, OUTPUT);

   // set the switch as an input:
   pinMode(switchPin, INPUT);

   // set all the other pins you're using as outputs:
   pinMode(motor1Pin, OUTPUT);
   pinMode(motor2Pin, OUTPUT);
   pinMode(enablePin, OUTPUT);
   pinMode(ledPin, OUTPUT);

   // set enablePin high so that motor can turn on:
   digitalWrite(enablePin, HIGH);

   // blink the LED 3 times. This should happen only once.
   // if you see the LED blink three times, it means that the module
   // reset itself,. probably because the motor caused a brownout
   // or a short.
   blink(ledPin, 3, 100);
 }

 void loop() {

potValue = analogRead(potPin); // read the pot value
  analogWrite(led, potValue/4);  // PWM the LED with the pot value (divided by 4 to fit in a byte)
  Serial.println(potValue);      // print the pot value back to the debugger pane
  delay(10);                     // wait 10 milliseconds before the next loop


   // if the switch is high, motor will turn on one direction:
   if (digitalRead(switchPin) == HIGH) {
     digitalWrite(motor1Pin, LOW);   // set leg 1 of the H-bridge low
     digitalWrite(motor2Pin, HIGH);  // set leg 2 of the H-bridge high
   }
   // if the switch is low, motor will turn in the other direction:
   else {
     digitalWrite(motor1Pin, HIGH);  // set leg 1 of the H-bridge high
     digitalWrite(motor2Pin, LOW);   // set leg 2 of the H-bridge low
   }
 }

 /*
   blinks an LED
  */
 void blink(int whatPin, int howManyTimes, int milliSecs) {
   int i = 0;
   for ( i = 0; i < howManyTimes; i++) {
     digitalWrite(whatPin, HIGH);
     delay(milliSecs/2);
     digitalWrite(whatPin, LOW);
     delay(milliSecs/2);
   }
 }




qweety

hello

i find when i connect my 10v motor directly to a 10v psu it spins at a fair ol' rate. But when i use this h bridge with pwm at full the acceleration/ torque and full speed is reduced slightly, is that a normal thing? Should i try and increase my power supply voltage to compensate for the resistance in the H-bridge?

thanks for any help  on this : )

qweety


hello .

At the moment i use a 10v regulator for the power of my 10v motor . But as the h bridge reduces its energy is some way. I wonder, would a 12v regulator be a wise idea to compensate for this resistance?

thanks for advice on this.
qweety : P


Go Up