Dual-H-Bridge-DC-Stepper-DC-Motor-Drive-Controller

1381.2.jpg (76529Bytes)
1381.5.jpg (35176Bytes)
L1.JPG (67079Bytes)
L4.JPG (60205Bytes)
1381.5.jpg (35176Bytes)
IMGA0041.JPG (869229Bytes)
IMGA0040.JPG (897970Bytes)
IMGA0039.JPG (949918Bytes)
IMGA0038.JPG (886846Bytes)

Im trying to use these module/shield to run 2 DC Motors it that simple ......i thought..... (at moment Arduino sketch only to run one to see if i can get to work) I have attached pictures of my set up and as much tech detail about Bridge as I have hop helps thanks a lot to any who can help/guide me in right direction

Connection to ardunio clone

enable A on pin 5 (needs to be a pwm pin)

enable B on pin 3 (needs to be a pwm pin)

N1 on pin 2 conrtols one side of bridge A

IN2 on pin 4 controls other side of A

N3 on pin 6 conrtols one side of bridge B

N4 on pin 7 controls other side of B

 

what happens nothing ...... sketch down loads ok....... i have got power etc to arduino the power light to h bridge is on....... I'm very new to C/C++ programming more than likely is what's the problem ...... but always best show everything i have done as might be something very simple i have missed

 

I have add code now and pictures total new conection set up problem solved

Where can i get decent Batterys from........................ 


 

Another thing, before you
Another thing, before you get the H-Bridge all hooked up, see if you can light up an LED (with the proper resister) with each pin. It’s best if you do this one at a time. If the LED won’t light up at all, then there is more troubles.

The LED test gives you the best chance of making sure that the PIN numbers you use are the pins you think they are.

I tend to use the Enable pins to enter the PWN and the In1 and In2 pins to control the motor behavior. There are other ways to do this.

It would be best to see the entire code in a *.txt file attachment. Making the effort to make your code readable will get you more help. Really.

**Please post your code as html **

Post your code as html not as dogs breakfast

int pinIN1=8;//define In1 port 
int pinIN2=9;//define In2 port

void setup()

  pinMode(pinIN1,OUTPUT);//define this port as output
  pinMode(pinIN2,OUTPUT);

void loop()

  digitalWrite(pinIN1,HIGH);// DC motor rotates clockwise
  digitalWrite(pinIN2,LOW);
  delay(2000); digitalWrite(pinIN1,LOW);// DC motor rotates anticlockwise
  digitalWrite(pinIN2,HIGH); delay(2000);
  digitalWrite(pinIN1,LOW);// DC motor stop rotating
  digitalWrite(pinIN2,LOW); delay(2000);
}

 

 

What have you done to set
What have you done to set the enable pins high?

Also, from your final image, it looks like the PWM is supposed to be applied to the Enable pins.

update

Thanks to every on site,especially  to  Duane Degan that walk through link was spot on help alot  and  BDK6   for battery comment yes it was smoke detector battery and the coment on the ENA inputs

Sorry about code i tried to add it as file  would not let me

heres completed code  sorted problem out bit code and my 9v ni-mh was not man enough

iv included copy of code… few pictures…

the  idea im playing with is i got a small 6 leg on/off crawler robot  for christams…want connect it to one of the smaller arduinos nano or pro mini … to have control of it 

Code

#define ENA 5  //enable A on pin 5 (needs to be a pwm pin)

#define ENB 3  //enable B on pin 3 (needs to be a pwm pin)

#define IN1 2  //IN1 on pin 2 conrtols one side of bridge A

#define IN2 4  //IN2 on pin 4 controls other side of A

#define IN3 6  //IN3 on pin 6 conrtols one side of bridge B

#define IN4 7  //IN4 on pin 7 controls other side of B

void setup()

{

  //set all of the outputs

  pinMode(ENA, OUTPUT);

  pinMode(ENB, OUTPUT);

  pinMode(IN1, OUTPUT);

  pinMode(IN2, OUTPUT);

  pinMode(IN3, OUTPUT);

  pinMode(IN4, OUTPUT);

}

void loop()

{

  motorA(1, 15);  //have motor A turn clockwise at 15% speed

  delay(5000);  //let motor A run for 5 seconds

  motorA(3, 100);  //brake motor A with 100% braking power

  motorB(1, 15);  //have motor B turn clockwise at 15% speed

  delay(5000);  //let motor B run for 5 seconds

 //have motor A turn counter-clockwise at 15% speed

  motorA(2, 15);  

  delay(5000);  //let motor A and motor B run for 5 seconds

  motorB(3, 50);  //brake motor B with 50% braking power

  motorA(0, 100);  //let motor A coast

  delay(5000);  //wait 5 seconds

}

//******************   Motor A control   *

void motorA(int mode, int percent)

{

  //change the percentage range of 0 -> 100 into the PWM

  //range of 0 -> 255 using the map function

  int duty = map(percent, 0, 100, 0, 255);

  switch(mode)

  {

    case 0:  //disable/coast

      digitalWrite(ENA, LOW);  //set enable low to disable A

      break;

    case 1:  //turn clockwise

      //setting IN1 high connects motor lead 1 to +voltage

      digitalWrite(IN1, HIGH);   

      //setting IN2 low connects motor lead 2 to ground

      digitalWrite(IN2, LOW);  

      //use pwm to control motor speed through enable pin

      analogWrite(ENA, duty);  

      break;

    case 2:  //turn counter-clockwise

      //setting IN1 low connects motor lead 1 to ground

      digitalWrite(IN1, LOW);   

     //setting IN2 high connects motor lead 2 to +voltage

      digitalWrite(IN2, HIGH);  

      //use pwm to control motor speed through enable pin

      analogWrite(ENA, duty);  

      break;

    case 3:  //brake motor

      //setting IN1 low connects motor lead 1 to ground

      digitalWrite(IN1, LOW);   

      //setting IN2 high connects motor lead 2 to ground

      digitalWrite(IN2, LOW);  

      //use pwm to control motor braking power 

      //through enable pin

      analogWrite(ENA, duty);  

      break;

  }

}

//   Motor B control   *******************

  void motorB(int mode, int percent)

{

  //change the percentage range of 0 -> 100 into the PWM

  //range of 0 -> 255 using the map function

  int duty = map(percent, 0, 100, 0, 255);

  switch(mode)

  {

    case 0:  //disable/coast

      digitalWrite(ENB, LOW);  //set enable low to disable B

      break;

    case 1:  //turn clockwise

      //setting IN3 high connects motor lead 1 to +voltage

      digitalWrite(IN3, HIGH);   

      //setting IN4 low connects motor lead 2 to ground

      digitalWrite(IN4, LOW);  

      //use pwm to control motor speed through enable pin

      analogWrite(ENB, duty);  

      break;

    case 2:  //turn counter-clockwise

      //setting IN3 low connects motor lead 1 to ground

      digitalWrite(IN3, LOW);   

      //setting IN4 high connects motor lead 2 to +voltage

      digitalWrite(IN4, HIGH);  

      //use pwm to control motor speed through enable pin

      analogWrite(ENB, duty);  

      break;

    case 3:  //brake motor

      //setting IN3 low connects motor lead 1 to ground

      digitalWrite(IN3, LOW);   

      //setting IN4 high connects motor lead 2 to ground

      digitalWrite(IN4, LOW);  

      //use pwm to control motor braking power 

      //through enable pin

      analogWrite(ENB, duty);  

      break;

  }

}

Batteries
For small robots I’ve used rechargeable AA NiMN batteries. You can get these pretty much anyplace in the US such as Walmart or even large grocery stores. In the UK, I don’t know the stores.

You can also use Lithium Polymer (LiPo), available at hobby stores or Amazon. They are available in a variety of sizes; I like bigger ones, but a 2,000 mAmp hr battery will normally work for most small robots.

Note that you will need a charger that is specific to the type (not brand) of batteries you get. There are chargers that will handle multiple types of batteries, but you have to make sure that it will charge your type of batteries; these chargers are more expensive than the ones that charge one single type.

And to repeat ossipee, thank you for following up and letting us know you progress.

Do you have a robot page for this?