Follow up on the Stepper Question: H-Bridge

I had posted recently about stepper motor control. Since that post and the replies I received I have come to the point of building the actual motor controller. Plenty of H-Bridges exist but I wanted to use some components I had. I posted this on my first posting but received no replies; with all the spam I see show up in the group I feared it might have gotten lost so I'm reposting as a new post.

Here's the post:

Hello, all. Where I am now is I have learned a fair bit about programming Micrchip PICs and think I've got that well enough to finally implement a test design. I'm taking the suggestion that I start with rated voltages initially, so no need for current sensing yet.

I started looking for an H Bridge circuit for my test motor because running it bipolar yields higher holding torque than unipolar operation. I have a number of BUZ11 N-Channel MOSFETs that I wanted to use and, I've read, they offer less resistance to the load so less heat is generated when they are operating, particularly switching. Plus, I don't think I have a P-Channel MOSFET in captivity and I live in the sticks so I can't just run to the store and grab one.

So, after reading tons of stuff on H Bridges I kind of cobbled together a piece that works and I wanted to fly it out there and see if I've done any good or if I'm screwing up. I have the schematic done up and saved on Photo Bucket:

formatting link
nunyabusiness11). I hope that link works. If not you can hit the site and search for my username listed at the end of that link.

I've wired it up and it works. It is simply 1/4 of an H Bridge, one of the upper legs supplying positive voltage to the motor. Currently I did not put in any clamping diodes around the motor because the MOSFET has one and it'll work for just seeing if the circuit works.

Basically, I'm using 5Vdc from the PIC (simulating it now by just touching the input to +5Vdc or Gnd) to activate a NPN phototransistor. That switches +12Vdc to ground via a 3k3 pull-up resistor (it is located before the phototransistor). That line (before the phototransistor) is connected via a 10k resistor to the base of a PNP 2N3906. The collector is tied to +12Vdc via a 1k resistor. The emitter is connected to ground via a 2k2 pull-down resistor. The N Channel MOSFET gate is tied to the line after the

2N3906 but before the 2k2 pull-down resistor. The N Channel MOSFET is tied to +12Vdc on the drain and the source ties to the motor which itself is tied to ground.

I used the phototransistor (SFH615A) to isolate the 5Vdc circuit from the 12Vdc circuit. When the input to it gets +5Vdc it switches on the phototransistor which allows the base of the 2N3906 to go low switching it on. That switches voltage to the leg with the 2k2 pull- down resistor and to the gate on the MOSFET.

I've tested it a few times, just powering the system up and touching the input directly to +5Vdc or Gnd. The motor holds securely when the input is energized and seems to freewheel correctly when the input is grounded (after I changed the pulldown resistor on the MOSFET gate from a 3k3 to a 2k2).

I'd appreciate input as to whether or not this is a good idea or if I simply got lucky that nothing smoked. I'm not an EE by any means and this circuit could be the silicon equivalent to a crack-baby.

Thank you.

--HC

Reply to
HC
Loading thread data ...

--
Errors:

1. Q1 is wired backwards.

2. R4 won't be needed with Q1 wired right.

3. With Q2's source grounded,and its drain connected to +12V, what's
   likely to happen when its gate is driven high?

4. Even with the ground removed from Q2's source, since it's configured
   as a follower, it's gate will need to be driven substantially  more
positive than
   +12V in order to get 12V into the stepper winding.

5. There probably isn't enough current out of your µC to drive the opto
   LED directly and get a snappy output from the optotransistor.


Plus, I'm pretty sure that in bipolar mode, in order to drive the
stepper backwards and forwards and maintain the high holding torque
you'll need _two_ full  bridges...


View in Courier:

            +12
             |
     +-------+------+
     |              |
   [Q1A]          [Q3A] 
     |  +--------+  |
     +--|--[L1]--|--+
     |  |        |  |
   [Q2A]|        |[Q4A]
     |  |        |  |
GND--+  | MOTOR  |  +-GND
     |  |        |  |
   [Q2B]|        |[Q4B] 
     |  |        |  |
     +--|--[L1]--|--+
     |  +--------+  |
   [Q1B]          [Q3B]
     |              |
     +------+-------+
            |
           +12

JF
Reply to
John Fields

ore

Hey, John, thank you for your reply. First, you are correct (in my understanding) that there will need to be two FULL bridges. This part of the circuit I'm floating out there is only one quadrant of one full H Bridge. The lower quadrants are easy, simply control two N-Channel MOSFETs. It's the upper quadrants that I'm not sure about and which I have posted here (simply one, knowing I'll need one on each side of the H).

Second, I realize in a point you made a mistake that I made. In the diagram where I show 'MOTOR HERE' what I meant to illustrate is that the motor is actually there; the source of the MOSFET does *not* tie directly to ground, it ties directly to the motor winding I'm testing the circuit on which, in turn, is connected to ground. When I was using the diagramming software (my first time with it) I could not find a motor symbol so I just used a wire and connected it in like a label; I'm sorry, that was confusing and easily (and correctly) read differently than I intended.

So, basically this is just one upper leg of an H and the motor winding actually resides between the source of the MOSFET and ground. In the final design there will be two of these pieces for each of two H bridges. For testing there is simply the one.

I have built this circuit, but I'm not sure that it's right...it just worked for the few m1) Q1 is a 2N3906 PNP transistor so I have it in my mind that is switching on and off current to the gate of the MOSFET which needs a positive input to turn on. Therefore it should be before the load I thought. The 1K above it is to limit current through it 'just in case', and the 2K2 below it is to allow the gate of the MOSFET to go HI when Q1 is on and to pull the gate of the MOSFET LO when Q1 is turned off. How should it be correctly wired (assuming the diagram/ circuit is viable at all)?

2) Okay

3) Poor diagram convention on my part

4) With the motor in place like I should have drawn it it should (and has for brief tests) work.

5) I have not measured the current draw of the optoisolator. That is a good point and something I will need to do. I could add *another* Q to drive that load ... but that seems to be getting a lot of components involved to avoid using one P-Channel MOSFET. First I'll see where the end of my current circuit design ends (either I scrap it or it lives) and then I'll check that. I'd still like to go forward with my circuit for now if for no other reason that I'll learn more as I go through it.

Okay, I looked at the diagram you posted. That would be the complete pseudo circuit for a bipolar reversing stepper motor driver. With that diagram as reference, the little circuit I have drawn (and am trying to design/hammer out) would be in the positions of Q1A, Q3A, Q1B, and Q3B, each one an instance of the circuit I have 'designed' and am discussing here.

That image was a pill to get to (thank you for your efforts). I tried the link and I'm not happy with it. Here's a tinyurl that may make it easier to get there:

formatting link

Thank you again for your time and help.

--HC

Reply to
HC

--
Responding to 1 and 5, View in Courier:


+12>----------------------------+-----------+-----+
                                |           |     |
                              [10K]         |     |
                    +-------+   |           E     | 
+5>------[100]------|A     C|---+--[10K]--B PNP   |
                    | -->B  |               C     |
                 +--|K     E|               |     D
                 |  +-------+               +---G NCH
                 C                          |     S
µC I/O>--[1K]--B NPN                       [1K]   |                   
                 E                          |   [LOAD]
                 |                          |     |
GND>-------------+--------------------------+-----+
Reply to
John Fields

d

=A0 =A0 =A0 | =A0 =A0 |

=A0 =A0 | =A0 =A0 |

=A0 E =A0 =A0 |

=A0 =A0 C =A0 =A0 |

=A0 =A0 | =A0 =A0 D

=A0 +---G NCH

=A0 =A0 =A0 =A0| =A0 =A0 S

| =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0

=A0 =A0 =A0 =A0| =A0 [LOAD]

=A0 =A0 =A0 =A0| =A0 =A0 |

Hi, John, thank you for your reply. I have posted a new diagram at that link with the motor winding in proper place. I did not make the change to the transistor because I'm sure there will be more changes yet; I just wanted to get the original idea documented correctly. (edit, now I have added a new drawing with the PNP oriented correctly)

In the diagram you've sent the emitter from the optoisolator is not connected; I assume that would still be connected to ground.

No offense taken, thank you for your help and there's lots I don't understand...even some of the basics, see below.

An admission on my part; I didn't understand how the transistors should be wired in (to my surprise). I took quite a bit of time to go and read and re-read about transistors, particularly PNP transistors since your post and found my basic understanding was wrong. First, I didn't know that the emitter went to the +V. It's frustrating when schematic convention is to have +V at the top and -V or Gnd at the bottom and the emitter is shown at the bottom of the schematic symbol yet it is to be connected to +V at the top. My datasheet on the

2N3906 did not have example or test circuit schematics in it for me to use as a guideline so I just used my experience (+ up and - down) and that's how I got it the way it was (wrong). Since my reading I know how to orient it correctly as you show. Another frustrating thing is that I found some circuits with the PNP before the load and some with it after the load; I thought a transistor acted as a switch and either switched the load to ground (NPN) or switched the positive to the load (PNP). But some schematics show the load before the PNP. Having a NPN before the load or having the load before a PNP would seem to make biasing the transistor (getting the right amount of current to flow through the base) difficult (since the base would need to be more positive than the emitter on a NPN but with the emitter before the load (the voltage drop) would be at V+ and vice versa for a PNP).

I don't know but it was a frustrating misunderstanding on my part.

Okay, so if I apply +V plus 4 to the gate I should get it fully (enhanced?) switched on. I'm confused reading the datasheet; it says that the threshold voltage between the gate and source Vgs(th) is between 2.1 and 4 volts. I took that to mean that it began to switch on at between 2.1 and 4 volts (variance by each part I presume) across the gate-source junction. I do not recognize a parameter in the list that to me equates to the Vbe(sat) saturation voltage spec I find in the 2N3906 datasheet. That is, to my reading, a 'threshold voltage of

2.1 to 4 volts' is not synonymous with 'this device is fully enhanced when 2.1 to 4 volts is placed across the gate-source pins.' Should it be? Should I read 'threshold voltage of gate-source juncture' to be 'the device is fully switched on when the gate-source juncture has between 2.1 and 4 volts'?

I understand the bit about the 16 volts; the source, connected to the motor winding would be at +12V when energized (before the voltage drop of the load) so 12+4, no sweat. But in order to pull that off I need three voltages for this circuit: 5V for the TTL/IC end, 12V for the motor, and 16V for driving an N-Channel MOSFET in the positive supply. Since it uses very little current I could use two 8V regs (78L08 I think is the part ID I'm referring to) with one floating on the first (there's a PIC programmer called the PIC16PRO40 that uses a similar setup for achieving 13Vdc with one 8V reg riding on the output of a 5V reg (13Vdc output).

Okay, then I need another Q to switch the optoisolator. I checked the draw of my optoisolator and it's roughly 34mA. Maximum source/sink current on any IO, according to the datasheet on the PIC16F684 I'm using, is 25mA. Good call on the Q to switch that. I've redrawn the circuit now using your suggestions. The PNP is correctly oriented, I upped the pull-up from 3k3 to 10k, added the NPN for the optoisolator, removed the unnecessary resistor on the PNP, tightened the drawing up to make more room and then added a voltage supply that uses the two

78L08's I mentioned. I left off any and all filter capacitors just to keep the drawing tidy for now and because I may have to make numerous changes yet and I don't want to have to shuffle filter caps around the screen. Suffice it to say, if I build this new circuit I will use filter caps as per the datasheet for the 78L08's.
formatting link
nr

Oh, and when I said something about doing all this to avoid using a P- Channel, what I meant was all this time and effort and the components here exist because I don't want to use a P-Channel MOSFET to switch the high-side of the H-Bridge. I still want to use the all-N-Channel solution and, if nothing else, I've learned a lot in the process.

Thanks again for your help and time.

--HC

Reply to
HC

--
Oops... yup.
Reply to
John Fields

--
For a real learning treat, if you don't already have LTspice, download
it, free, from:

http://www.linear.com/designtools/software/

JF
Reply to
John Fields

e

yhv2onr

Hey, John, sorry for the delay. I've been busy with a few other projects and also kind of letting this cook in my mind.

What you're calling a "common-emitter" layout is what I always thought of as the "right way" to wire a transistor (not saying it *is* the right way, just the way I always thought of it)...I just blew the detail about PNP's connecting the emitter to +V. Anyway it's the orientation that "clicks" with my mind.

Silly basic (maybe) question: you say the base-emitter voltage would need to be between 0.7 to 1.0 volts to fully saturate the transistor. I see in the datasheet on the 2N3906 that the "Base-Emitter Saturation Voltage" (Vbe) is between 0.85 and 0.95 volts for that particular part. How do you calculate the necessary base resistor to do that? If I knew what the V was and the Current I could calculate the R...I know the V but not the R or the C...so I looked at the datasheet from Discrete Power and Signal Technologies which I had and there's a graph of base-emitter voltage vs. collector current for full saturation. I can see from that figure that if you have 20 mA current through the collector at 25 degrees C you'd need 0.7 volts across BE. Great, but with neither of the other two values I don't know what to do. I found a datasheet from On Semiconductor for the same part and they have a figure (Figure 14, theirs are numbered) that shows the amount of base current compared to the voltage across the collector-emitter junction with the amount of current across the collector. So, if you will carry Ic 1.0 mA your Vce will be 1.0 if you have a base current of

0.01 mA. The higher the base current, the lower the Vce and (I think) the lower the power dissipation in the transistor. For 5V input, easy calculation: R =3D V/I, R=3D5/0.00001 (0.01 mA), R=3D500,000 ohms. For a 100mA Ic it shows you'd need a 3.5 mA base current to achieve the 1.0 Vce so for 5 volts input: R=3D5/0.0035, R=3D1429 ohms, nearest standard value would be (I think) 1500 ohms.

Anyway....

Looking at figure 5 of the datasheet I see that the higher the drain current, the higher the drain to source voltage needs to be to lower the drain-source voltage (the lower the Vds the lower the power dissipation I believe, which is good). There is a superimposed 75W Pd I see...so that's the max Pd of the device I see...kind of a redline on that graph. Okay, higher Vg =3D lower Vds =3D lower power dissipation. So, what if I drive the BUZ11 with Vdrain +20V? So, for switching +12V (drain) with the BUZ11 use +32V for the gate. IIRC, HP switch-mode power supplies for their printers (some of the bubble jets) have both +16 and +32V outputs with beaucoup current. Regardless, it's doable.

Well, I wasn't sure how the 78L0x did it's job...it was a nice idea... But if I have a higher voltage source it can scale it down...so that would work.

I think I'm happy now with the circuit design. I will draw it up once more as a quarter of the final design with the new voltages and after considering using a ULN2803 or similar as a buffer to the drive circuitry instead of the opto isolator. A couple of more revisions and some more time to think about it and I'll be ready to breadboard another try.

Thanks for the info on LTspice. That looks cool. Says it can do real- time simulations of switch-mode power supplies...that's got to be some intense work. I've started drawing up my circuit in it but I'll wait until I'm a bit more solid on what the circuit will be finally.

Thanks again.

--HC

Reply to
HC

that transistor should be labeled PNP

--- news://freenews.netfront.net/ - complaints: snipped-for-privacy@netfront.net ---

Reply to
Jasen Betts

--- You don't, since the base-to-emitter junction is just a diode, and whatever current you put through it will result in one diode drop (Vbe) across the junction, just like in any other diode.

What you do is select the base resistor depending on how much current you need to force into the base in order to get the collector current you want, and then live with the Vbe(sat) and Vce(sat) since they'll be whatever they'll be.

Rule of thumb for switches is to force 10% of the collector current into the base (called: "forcing a beta of 10", since beta = Ic/Ib), and what the data sheet is telling you is that with the CE junction of the transistor fully saturated there'll be between 0.85 and 0.95 volts across the BE junction.

Just for grins, let's assume we have something like this,:

12V Ic--> / V+>------------+ | [120R] R1 | +--0.3V | C Vin>---[R1]--B E | GND>-----------+

and that with the transistor fully saturated we have 0.3V across the CE junction.

Then, with a 12V supply, we'll have a collector current of:

(V+) - Vce 11.7V Ic = ------------ = ------- = 0.0975A = 97.5 mA 120R 120R

If we force beta to 10, then, we'll need 9.75mA into the base to turn on the transistor.

Also, let's say that Vin is coming from a logic supply and is either 5V or 0V.

Then, to get the value of R1 with the transistor turned on, we say:

Vin - Vbe 5V - 0.95V R1 = ----------- = ------------- = 415 ohms Ib 0.00975A

If we did the math with Vbe equal to 0.85V, then R1 would be equal to about 426 ohms, and with the "natural" beta of the transistor being so much higher than 10, a standard 430 ohm 5% resistor would be fine, and it would dissipate:

Pd = (Vin - Vbe) * Ib ~ 0.040 watts,

so a 1/4 watt carbon film would be great.

---

--- See above. :-)

---

--- Something's wrong there...

The higher the drain current, the higher the gate-to-source voltage needs to be in order to lower the drain-to-source resistance, the Vds, and the dissipation. Good thing, unless you're building a temp-controlled heater of some kind...

---

--- Since you can fully enhance the channel with 10V Vgs and you want 12V into the load using a source follower, you should be able to do it like this:

+12v>----------------+ | | D +22---[R]----+-----G NCH | S C | I/O>--[R]--B NPN [LOAD] E | | | GND>---------+-------+

Caveat here is that Vgs can only safely be +/- 20V.

Run it in LTspice and see what happens... :-)

---

--- You're welcome again. :-)

JF

Reply to
John Fields

--
Why, thank you Jasen, that's exactly right, and your sentence should
have started with a capital and ended with a period.

JF
Reply to
John Fields

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.