Maker Pro
Maker Pro

Huge trouble driving a stepper motor with an h-bridge

loamobn1

Feb 23, 2012
10
Joined
Feb 23, 2012
Messages
10
I'm trying to drive a stepper motor with an h-bridge. The motor has four input leads, so uses two h-bridges. I need to be able to reverse the current through the coils (thats why I'm using the h-bridges), and control the mosfets on either side of the h-bridge with one 5V output pulse from an Arduino.

My first attempt was to put P-Channel mosfets on the top half, N-Channel mosfets on the bottom half, and have one signal feed the gate of the correct N-Channel and go through an inverter and feed the corresponding P-Channel. That didn't work, because (for some reason unknown to me) the Hex Inverter IC's LOW was about 1V, and didnt put the P-Channel into conduction.

Then I tried the circuit that I have attached, to actively drive the P-Channel gate low. The output (either side of the coil) looks fine from an oscilloscope when the motor isn't connected, but when it IS, the voltage at these points dies out.

I've seen a half dozen H-bridge circuits, and tried most of them (the simpler ones), but none of them have worked. I think that the problem may be that the P-Channel drain voltages are about equal to the gate voltage...but the gate threshold voltage is 2V, so it doesn't turn on.


I've been working on this thing non-stop for weeks, asked a handful of EE students, and no one knows....any help or suggestions would make you a celebrity around here.

(P.S. The "resistance" of the coil is 12 ohms. The control voltages come from an arduino [5v] and feed into the bases of Q5 and Q6 as well as the gates of the n-channel mosfets)

Thanks
 

Attachments

  • p-chan hbridge pic.jpg
    p-chan hbridge pic.jpg
    119.2 KB · Views: 325

jackorocko

Apr 4, 2010
1,284
Joined
Apr 4, 2010
Messages
1,284
the Hex Inverter IC's LOW was about 1V, and didnt put the P-Channel into conduction

were you using logic level mosfets? What was the voltage applied to the source/gate of the p-channel mosfet?

From the schematic it looks like your p-channel mosfets are wired wrong. You need the gate to be more negative then the source for a p-channel to turn on yet you have the source attached to ground? Hard to see, maybe I need glasses.
 
Last edited:

loamobn1

Feb 23, 2012
10
Joined
Feb 23, 2012
Messages
10
Not your fault, the diagram is tiny.

I have the top side p-channel sources connected to supply voltage.

The threshold voltage for my N-Channels is 3-5V, and P-Channel threshold voltage is -2 to -4V. I suppose that would classify them as logic level?
 

jackorocko

Apr 4, 2010
1,284
Joined
Apr 4, 2010
Messages
1,284
I have the top side p-channel sources connected to supply voltage

it doesn't look it, enlarge that schematic and post another picture.

H-Bridge.gif
 
Last edited:

loamobn1

Feb 23, 2012
10
Joined
Feb 23, 2012
Messages
10
I'm actually at the lab now (with the circuit), not near my schematic computer. I may have done the schematic wrong...the sources of the P-Channels are at Vcc in reality, and the drains of the N-Channels are connected to the drains of the P-Channels. Its a 'generic' h-bridge circuit, except for the BJTs driving the P-Channel gates.

When I test this circuit with LEDS (that is, but LEDS facing both ways at the points where the coil would be), they blink correctly and at a decent intensity. If I plug a motor in, the circuit consumes almost no current (according to my power supply), but if I listen hard I can hear some clicking inside the thing...
 

loamobn1

Feb 23, 2012
10
Joined
Feb 23, 2012
Messages
10
its really simple:

void setup() {
pinMode(0, OUTPUT); //Red
pinMode(1, OUTPUT); //Blue
pinMode(2, OUTPUT); //Green
pinMode(3, OUTPUT); //Black
}

void loop() {
digitalWrite(0, HIGH);// Phase 1F
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
delay(50);
digitalWrite(0, LOW);// Phase 2F
digitalWrite(1, LOW);
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
delay(50);
digitalWrite(0, LOW);// Phase 1R
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
digitalWrite(3, LOW);
delay(50);
digitalWrite(0, LOW);// Phase 2R
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
delay(50);
}

Pin 0 and Pin 2 are connected to one h-bridge, Pin 1 and Pin 3 to the other.
 

jackorocko

Apr 4, 2010
1,284
Joined
Apr 4, 2010
Messages
1,284
I wonder if a mosfet driver would help you? You are trying to drive two mosfets from the same arduino pin.


delay() is in what mS uS?

edit: I am going to bed, later on the experts will come on as they live in australia and are sleeping. If you haven't got it figured out, take a nap and check back in the morning. Someone will have an idea
 
Last edited:

loamobn1

Feb 23, 2012
10
Joined
Feb 23, 2012
Messages
10
Thanks for your help so far...

delay is indeed in milliseconds.

I'm going to try the circuit you posted and see if that works.
 

loamobn1

Feb 23, 2012
10
Joined
Feb 23, 2012
Messages
10
jackorocko:

Your circuit worked (with some n-channel pulldown resistors)!

Why did you choose the resistor values you did? Whats the purpose of the 100ohm between the p-channel gate and the NPN collector? Why can't you just connect the two without a resistor?
 
Last edited:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Whats the purpose of the 100ohm between the p-channel gate and the NPN collector?

It will limit the current through the transistor to a safe value.
 
Top