Motor controller h bridge advice

I have two motors, not brushless, that pull 7.5amps each at stall.
I want to use them for tank style steering and drive.
I have my inputsheild with joystick connected to Uno and can make a circle of LEDs. but i digress..

My reading leads me a few different motor sheilds/pcbs in the $40-$120 range. I really thought this could be done cheaper as a h-bridge chip like the L298n is only a few bucks at sparkfun. Unfortunatly the 1 or 2 amp rating wont cut it. So I found this:

but it seems to use only PWM as input. I'm not comfortable with that yet so would like to stick with analog input. I understand 0-1023.

does everything which may be nice for other things in the future but at $100 it stings.
Then there is this:

it has a USB port to monitor and config wich actually seems like another step of complexity i dont want. but its cheaper.

I guess I could post links all day but what I'm really asking is what motor controller should I buy to simply control 2 motors and control speed and direction of each :wink:

thanks for any help, im just getting into motors and servos.

jointtech:
So I found this:
Pololu - Dual VNH3SP30 Motor Driver Carrier MD03A
but it seems to use only PWM as input. I'm not comfortable with that yet so would like to stick with analog input. I understand 0-1023.

Any chance we could get your over that fear? We'll be your support group. It'll be like going to an AA meeting :slight_smile:

To control the board you have four main pins. Looking at just the first driver:

1EN : Setting it high powers up the driver and low disables the driver. If you were going to implement a kill switch you would do that here.
1INa / 1INb : When INa is high and INb low, the motor will be set to turn in one direction, and when INa is low and INb is high it will be set to turn the other direction. Setting both high locks the motor and makes it resistant to turning, and setting both low allows the motor to freewheel.
1PWM: when you analogWrite(pwmPin, 0) the motor is stopped, and analogWrite(pwmPin, 255) the motor is full power. Selecting a value between 0 and 255 is a partial power; 64 would be 1/4 power, 128 would be 1/2 power, etc. "pwmPin" is any of the PWM pins on the Arduino: 3, 5, 6, 9, 10 or 11.

Does this seem straightforward?

lol well I used prison when I kicked. Meetings never did it for me. heh.

Hmm you do make it seem simple. For some reason I had in my head there were only 2 pwm pins which also shyed me away.

This is one of the cheaper ones as well so maybe ill give it a shot.
thanks for the kick.

So if I have this right:
to go forward full speed you would

killswitch = 1
leftspeed = 3
rightspeed = 5
frontbackleft= 2
frontbackright = 4

killswitch(high)
leftspeed(255)
rightspeed(255)
frontbackleft(low)
frontbackright(low)

to go left slow
killswitch(high)
leftspeed(90)
rightspeed(200)
frontbackleft(low)
frontbackright(low)

to do a spin to the left

killswitch(high)
leftspeed(255)
rightspeed(255)
frontbackleft(high)
frontbackright(low)

my input board uses 4,5,6,7 and analog 4,5 so looks like I have enough pins to do what i need for now. :slight_smile:

I should have explained more clearly that each motor has its own set of 4 pins to control it. 1EN, 1INa/1INb, and 1PWM control one motor, and 2EN, 2INa/2INb, and 2PWM control the second motor.

Ignoring the 1EN and 2EN pins (which always must be high to turn both sides of the thing "on"), for forward it would be
1INa = high
1INb = low
1PWM = 255
2INa = high
2INb = low
2PWM = 255

Right spin:
1INa = high
1INb = low
1PWM = 255
2INa = low
2INb = high
2PWM = 255

etc.

got it. thanks.
Before I make my order are there any other parts that need to be between the controller and the arduino? Or controller and motor? diodes etc? I keep seeing shotkey (sp?) diodes mentioned in posts about motor controllers.
I hate paying for shipping 3 times because I cant get my orders right :wink:

Greetings all,

Taking a quick look at the datasheet for the main chip on the "Dual VNH3SP30 Motor Driver Carrier MD03A" (specifically the block diagram), I don't see on-chip protection diodes. (Some MOSFETs come with protection diodes; I didn't check their datasheets.) Each MOSFET needs a diode to protect it from voltage spikes that are caused by abruptly turning off current through an inductive load, like a motor. I suggest emailing Pololu and asking whether this board has protection diodes on all the outputs. (I'd hope they included the diodes, especially since the product is intended for motor control, but I didn't see anything about protection in the online info.)

Shottkey diodes are not IMHO required to protect MOSFETs from motors, but you do need diodes that can handle at least the peak current involved and at least 400 PIV. 1000 (peak inverse) volts would be better. I think 1N4007s would be fine, or you could get diodes with even higher current ratings. FYI digikey.com part# 1N4007DICT-ND, $0.013 single quantity, less if you buy 10 or more. These are very handy. Adding them won't hurt, but no protection diodes would probably mean a dead motor controller sooner rather than later.

PiJoy:
...the datasheet for the main chip on the "Dual VNH3SP30 Motor Driver Carrier MD03A" (specifically the block diagram), I don't see on-chip protection diodes.

This is represented by "Clamp A" and "Clamp B" in the block diagram, isn't it?

i emailed polulu for clarification. we'll see what they say.

quick reply from pololu

Thank you for your interest in our motor driver carrier. Additional protection diodes are not necessary, so our carrier board does not add any to the VNH3SP30's outputs. The driver's H-bridge uses MOSFETs, which have body diodes that provide the flyback protection. These diodes are shown in the schematic diagram on page 7 of the datasheet. The datasheet can be found on the product page under the resources tab:

If you have any additional questions about our products, please let me know.

jointtech:
The driver's H-bridge uses MOSFETs, which have body diodes that provide the flyback protection.

Just to clarify:

A single mosfet driving a motor or other highly inductive load DOES need a flyback diode, because the mosfet body diode is not in the right place. However, when a motor is driven from a mosfet H-bridge, then when one mosfet turns off, the body diode of the other mosfet in the same half H-bridge is in the correct position to act as a flyback diode. So additional flyback diodes are not needed when using mosfet H-bridges to drive inductive loads. HOWEVER, the back emf from the motor gets dumped to the H-bridge supply through the body diodes. So you need a large capacitor across the motor supply input to the H-bridge to absorb this. Commercial H-bridge boards normally have a capacitor on-board, but you may need to add a larger one.

PiJoy:
Greetings all,

Taking a quick look at the datasheet for the main chip on the "Dual VNH3SP30 Motor Driver Carrier MD03A" (specifically the block diagram), I don't see on-chip protection diodes. (Some MOSFETs come with protection diodes; I didn't check their datasheets.)

All power MOSFETs have integral body diodes, its physically part of the structure of the FET, so they never need external diodes (in an H-bridge or half-H-bridge) - you can add schottky diodes to reduce the amount of heat generated though as the forward voltage is 0.4V instead of 1.2V or so.

I finally got around to soldering the board together. Before I blow it up just want to verify that this guys picture is correct. Ill test without a motor first.

http://forum.pololu.com/viewtopic.php?t=2116

Yes the scheme is correct.

The thread you have linked has a Pololu employee replying, so you can be pretty certain it is.

I tried with and without the EN1. Does nothing. no leds light up on the controller. Going to tinker some more this evening. I suppose it could be my crappy solders, which will be the theme of another post.

int InA1 = 8;
int InB1 = 9;
int EN1 = 10;
int PWM1 = 3;  //PWM1 connects to pin 3
int PWM1_val = 127; //(25% = 64; 50% = 127; 75% = 191; 100% = 255)

void setup() {
  Serial.begin(9600);
  pinMode(InA1, OUTPUT);
  pinMode(InB1, OUTPUT);
  pinMode(EN1, OUTPUT);
  pinMode(PWM1, OUTPUT);
}

void loop() {
    digitalWrite(InA1, HIGH);
    digitalWrite(InB1, LOW);
     digitalWrite(EN1, HIGH);
    analogWrite(PWM1, PWM1_val);
    
}

got it. the motor side has to have a separate input. I was trying to cheat and use the arduinos 5v to power both sides of the board since im just testing with a tiny motor. Plugged a wall wart into the motor side and its all working now.
Thanks!!!

My joystick goes from 0-1023 from bottom to top. the dead spot in the middle is actually around 500. This code spins one motor back and forwards by the joystick. Maybe it will help the next guy.

int joyPin1 = 4;
int InA1 = 8;
int InB1 = 9;
int EN1 = 10;
int PWM1 = 3;  //PWM1 connects to pin 3
int PWM1_val = 0; //(25% = 64; 50% = 127; 75% = 191; 100% = 255)

void setup() {
  Serial.begin(9600);
  pinMode(InA1, OUTPUT);
  pinMode(InB1, OUTPUT);
//  pinMode(EN1, OUTPUT);
  pinMode(PWM1, OUTPUT);
}

void loop() {
  analogRead(joyPin1);
    
 //    digitalWrite(EN1, HIGH);
 int val;
     val = analogRead(joyPin1);   // read the input pin
  analogWrite(PWM1,0);
if (val <= 485) {  
  digitalWrite(InA1, LOW);
  digitalWrite(InB1, HIGH);
  val = map(val,485,0,0,255);
  analogWrite(PWM1, val);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
Serial.println(val);

}
if (val >= 600) {  
  digitalWrite(InA1, HIGH);
  digitalWrite(InB1, LOW);
  val = map(val,600,1023,0,255);
  analogWrite(PWM1, val);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
Serial.println(val);
}

else
 {  
  digitalWrite(InA1, LOW);
  digitalWrite(InB1, HIGH);
  analogWrite(PWM1, 0);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255

}

    
}

And now I have 2 arduinos connected via Xbee S1s on sparkfun breakout boards.
heres the hello world:

Sending Arduino with joystick and xbee
verticalhigh / low are so it doesn't suck up battery sending a signal when the joystick is in the deadzone. I found my deadzone to be around 528.

int joyPin1 = 4;
int verticalzerolow = 520;
int verticalzerohigh = 535;

void setup() {
  Serial.begin(9600);
}

void loop() {
 
 int val;
     val = analogRead(joyPin1);   // read the input pin
     if (val <= verticalzerolow || val >= verticalzerohigh) {
Serial.print("A"); 
Serial.print(val);
Serial.print("Z");

     }

    
}

The receiving arduino with motor controller and motor and xbee

int InA1 = 8;
int InB1 = 9;
int PWM1 = 3;  //PWM1 connects to pin 3
int PWM1_val = 0; //(25% = 64; 50% = 127; 75% = 191; 100% = 255)
bool started = false;
bool ended = false;
char inData[10]; // Leave plenty of room
byte index;
int val;
void setup ()
{
 Serial.begin(9600) ;
  pinMode(InA1, OUTPUT);
  pinMode(InB1, OUTPUT);
  pinMode(PWM1, OUTPUT);
}

void loop()
{
  while(Serial.available() > 0)
  {
    char aChar = Serial.read();
    if(aChar == 'A')
    {
	// Start of packet marker read
	index = 0;
	inData[index] = '\0'; // Throw away any incomplete packet
	started = true;
	ended = false;
    }
    else if(aChar == 'Z')
    {
	// End of packet marker read
	ended = true;
	break; // Done reading serial data for now
    }
    else
    {
	if(index < 10) // Make sure there is room
	{
	  inData[index] = aChar; // Add char to array
	  index++;
	  inData[index] = '\0'; // Add NULL to end
	}
    }
  }

  // When we get here, there is no more serial data to read,
  // or we have read an end-of-packet marker
  if(started && ended)
  {
    // We've seen both markers - do something with the data here

val = atoi(inData);
if (val <= 485) {  
  digitalWrite(InA1, LOW);
  digitalWrite(InB1, HIGH);
  val = map(val,485,0,0,255);
  analogWrite(PWM1, val);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
Serial.println(val);

}
if (val >= 600) {  
  digitalWrite(InA1, HIGH);
  digitalWrite(InB1, LOW);
  val = map(val,600,1023,0,255);
  analogWrite(PWM1, val);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
Serial.println(val);
}

else
 {  
  digitalWrite(InA1, LOW);
  digitalWrite(InB1, HIGH);
  analogWrite(PWM1, 0);  

}
    index = 0;
    inData[index] = '\0';
    started = false;
    ended = false;
  }
}

Bringing this back to life.
I have an issue with my power supplies. I have a servo which runs at 6V. My motors run at 12v and my arduino runs at somewhere under 12v. I dont want 2 different batteries.
If I hookup my cicuit like this the motor controller works.

But if I use just a single power supply with a voltage regulator (or in testing I just run the motor and servo at only 6v) it doesnt work. Seems like if the grounds on the motor side are connected it doesnt work.

Is this by design or am i thinking incorrectly>?
doesnt work:

EDIT There is a ground wire from Arduino to Servo in both cases. I forgot to put that wire in the fritzing. Obviously neither screenshot would work without the ground.