Stepper Motor Driver Problem
Philldapill
Posts: 1,283
Hey, simple question. I'm making a CNC rig and my steppers just aren't that powerful... Well, they are, but I can't get enough current to them. I'm using a simple TO-92 transistor based H-bridge, and if my input signal from the prop is 0-3.3V, then my steppers are only getting at most, 3.3V across them. I can barely step at 300 steps per second with NO LOAD. The only thing I can think of, is using a quad op-amp as a voltage amp to drive the transistors - the 0-3.3V signal being the input of course. Any thoughts?
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Post Edited (Paul Baker (Parallax)) : 2/19/2008 1:00:23 AM GMT
Maybe I just don't understand bipolar transistors correctly... If I have 12V at the collector, and a 3.3V source at the base(prop output·with resistor in series), then the voltage at the emitter is going to be the same as at the base, minus ~0.6V drop = 2.7V
If this is the case, then at most(not counting the drop on the low end of the H-bridge) I will only have 2.7V being applied to the motor coils. I connected a 12V battery to one phase of my stepper and after 5 minutes, it was a little warm. I'm assuming 12V is probably the upper bound of how much continuous voltage(current) can be applied across a coil for this motor. I've constructed a prototype Y-axis table for my CNC, but when it comes in contact with a little resistance from whatever source, the motor tends to bog down and not rotate. A simple hand measurement of the torque of the motor shows that it has far less torque than with 12V. Plus, I measured the voltage across the phase of the motor when connected to the prop/Hbridge combo and it measures about 3.1V.
Sorry to keep rambling on, but I'm not that experienced with this stuff.
What is the single coil resistance rating of your motor? You need that to calculate the current you're actually delivering to the motor. At the moment it seems you're dumping an appreciable amount of current into your transistor. Your understanding of the base-emitter voltage and transistor biasing seems correct - however you also need to keep in-mind that roughly, the current you need to supply to the base through the current limit resistor is roughly equal to the collector current divided by the transistor current gain which is specified on your transistor's data sheet. You may find you don't have enough drive current without adding a drive op-amp or another transistor in Darlington configuration, for-example.
Check out this link for some good driver circuits, take note of the 7486 XOR protection circuit on the H-bridge control input - highly recommended:
http://eio.com/jasstep.htm
This link is to a .pdf that provides good insight into drive circuit analysis:
www.solarbotics.net/library/pdflib/pdf/drive.pdf
Finally there are stepper motor driver IC's... Take a look at ST Microelectronics' L298 dual full-bridge driver IC which marries nicely to their L297 stepper motor controller IC. Search for them at:
www.st.com.
You might want to model your driver in SPICE first. The completely free LTSpice/SwitcherCADIII from Linear Technologies is perfect for this - it's a Windows application. Download from:
www.linear.com
There's an excellent LTSpice user forum at:
http://tech.groups.yahoo.com/group/LTspice/
Check out the tutorials and examples in the LTSpice Forum files area, I'm pretty sure you'll find stepper motor drivers you can start from.
Good Luck, David
did you connect the motor between ground and emitter?
that's wrong for NPN-Transistors
if you use an NPN-Transistor usually the driven device is connected between +-Supply and the collector
The emitter is connected to ground
the current flowing from collector to emitter is detemined mostly by the current flowing from base to emitter
If the Base-Emitter-current is big enough the voltage-drop across Collector-Emitter is only 0,6-0,7V
At an NPN-Transistor it is that way:
as soon as the potential of the base is +0,7V above the potential of the emitter the transistor is switched on "completely"
If the base-resistor is very big there's only flowing a small current from base to emitter.
and if the base-emitter-current (B-E) is small the collector-emitter-current (C-E) will be small too.
(of course there is an amplifiing factor between B-E-current and C-E-current.
so by changing the B-E-current you can change the C-E-current
Now it depends on the transistor-type which B-E-current is causing which C-E-current
therefore you have to look into the datasheet of the transistor.
There are diagrams about that
could you post your circuit and the datasheet of the transistor ?
best regards
Stefan
This is only a rough setup for driving the stepper - nothing permanent. I have taken some measurements though. My transistors are rated for 200ma, and I'm pushing about 170mA. I calculated the limiting resistor correctly and gave it about 15% under the maximum rating(200/170mA). When I apply the 12V directly to the coil, it pulls about 1.8A. Quite a difference. My main concern with all this is actually getting the rpm of the motor up, and I believe to do that, I need to supply more current - faster(higher di/dt). For this, I believe someone(Joerg) mentioned a driver circuit specifically for this. Remember, at MOST, I want to be able to pull 2A from the driver, so I'm thinking it needs to be fairly high-power. A schematic is attached of a circuit I designed recently, but haven't built yet. Last time I posted something like this, I didn't get much feedback, so please, comment away and give suggestions.
BTW, wow, I like that L298... 2A each channel, continuous! Sounds perfect. Know of any suppliers? Oh, and I have multisim 10...
StefanL38,
The transistors I'm using are 2N3906(or 2n3904 - whatever is NPN). I know this is not the correct way of doing this as there are many problems with energizing the base of the highside, etc., but like I said, a simple prototype to make sure it can work. As for the B-C-E stuff, I was pretty sure that was right. It would make sense that the emitter will always be at the base voltage level, minus the 0.6V drop. As for the schematic, well, here it is.
there are two basic schematics how a transistor can be build up
NPN and PNP. And it makes a really GREAT difference to use them. It's almost vice versa how you use them correctly
at a NPN-Transistor the Emitter is connected to GND. at A PNP-Transistor the emitter is connected to plus supplyvoltage !
Also the base of an NPN has to be 0,7V ABOVE Emitter. The base of an PNP has to be 0,7V UNDER the potential of the emitter !
In your schematic Q1 and Q2 are PNP all others NPN-Transitors
The coil L1 is only supplied by 5V. Could this be the reason of the low current?
coils do not like to CHANGE the current that is flowing trough them.
if you apply AC-current or a pulsed DC-current (which is "alternating" somehow too) there is an additional resistance that reduces
the current that is flowing. So you have to measure the current that is flowing at maximum speed = maximum switch-frequency
super-professional steppermotordrivers are working with current limiting curcuits in chopper-mode.
This means they apply a quite high voltage to the coil to boost the currentCHANGNING (dI/dt)
If the current that is "middled" over time reaches a maximum-level, the voltage is switched of for a short moment. Then switched on/off all the time with a defined dutycycle
About time the current stays at the rated level. If you would apply this voltage to the coil ALL the time the current would rise up over the rated limit and would burn through !
Using a higher voltage makes the current rising faster. So the current "middled" over time can be higher.
I don't know how big the improvement is by using choppering.
Do you have an oscilloscope to watch how the current is going up and down by switching on/off at different frequencies?
here i found a link especially about the basics of transistor h-bridges
http://www.mcmanis.com/chuck/robotics/tutorial/h-bridge/bjt-bridge.html
best regards
Stefan
I have just plugged in my prop for the first time! I bought this with the intention of building a stepper motor driver for controlling a 3 axis (x,y,z ) cnc router. My plan is to use uni-polar stepper motors driven by 4 IRF540 n-channel mosfets,
(100v , 22A! should be plenty of power) which will be driven by a darlington array off of the prop.
Phil are you using bipolar steppers? I would guess so from your description of using an h-bridge. I think a unipolar design seems much simpler.
Eventually, I want to be able to microstep the motors by balancing the pwm signal (after I get it to full step) with software running on the prop. (Each motor would get its own cog which would control the 4 pins driving the mosfets)
Anyway I was just putting this out there to see if anybody else is doing something similar and would like to share ideas and/or code. I have several ideas on the final design. (like reading a shaft encoder; "closed loop" and prop-based g-code interpretor )
I better get started....
Thanks ,Paul
The STMicro L297 and L298 are available (seemingly) ready-stock from Mouser and Jameco, Digikey seems to have only bulk-buy, as such prices seem lower. I'll leave it to you to source the parts, further as they seem available in a quick Web search. But note, if you go to production with your design, RoHS compliant parts may be more difficult to find for the L297/298.
Alternative(?) A quick Web-search comes up with nice H-bridge stepper drivers from Allegro MicroSystems:
www.allegromicro.com
Look under Power IC's > Motor Drivers. Many nice stepper driver IC's, with inputs from parallel, serial, and two-wire (step-direction) smart interface options as well as Micro-stepping. I Haven't sourced/priced the Allegro parts.
I assume from your schematic posted that your stepper motor is unipolar bipolar (two wires per winding). Is that correct? Can you provide us with the the datasheet for your motor including specifications for nominal voltage, current, series resistance, and (most importantly) single-winding inductance?
If not, (as often is the case) then you're using a surplus motor and need to derive the above parameters before modeling/designing a driver (I urge you to move to LTSpice/SWitcherCADIII for this particular application, it is free & uncrippled and optimized for power & motor-control).
If you can't provide datasheet specs for your motor (as mentioned above), then I may be able to help you with deriving the required specifications by measurement.
But as StefanL38 said in this thread,"Do you have an oscilloscope..." to do the measurements? A digital storage oscilloscope (DSO) is preferrable over an analog scope for these time-domain measuremenets.
You can derive how to roughly measure winding inductance from a time-domain RL circuit step-response. Derive the technique from the page at:
http://en.wikipedia.org/wiki/RL_circuit
Scroll down to "3.8 Time domain considerations".
Basically what you do is put a step input at voltage and current you want to operate at (often 1/10th current will be OK, you just want to saturate the core) with a series resistor to ground and measure the time response across the series resistor. Measure the time to half the stead-state (long-term) maximum voltage and derive the equivalent inductance.
Note, NEVER measure across a motor winding (inductor) with an oscilloscope without a "clamping" diode across the winding, otherwise you may damage your instrument (especially with PC-based instruments). A 1N4001 diode has 50V reverse breakdown, but I'm not sure it can handle a 2A/12V motor winding open-circuit discharge without putting an uncacceptably large voltage across your instrument's input (diode burn-out). Be careful.
If you need more help with the algebra of deriving the inductance from the step-response I can help. Let me know.
Post Edited (Drone) : 2/21/2008 12:10:51 PM GMT
www.motioncontrolproducts.co.uk/index.php?cPath=5&osCsid=5586656e684809c5ac04a7c30b9cf6fd
Regards,
John
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Necessity is the mother of invention'
I'm soldering up the circuit right now, and just thought of a major problem that might happen. The signals going to the two pots are always going to be inverses, so neither will be high at the same time. However, I got to thinking about how the op-amps are governing the current flow on each side of the H-bridge. Let's say that the right opamp is getting a high signal, and the left, a low signal. The right side op-amp will be fine, as it will try to boost the current in order to balance the voltage dropped across the shunt resistor with the voltage from the pot. As the voltage rises, the left opamp should stay off. However, I'm thinking that the left op-amp will see a very high voltage across the shunt and a low voltage across it's signal/pot. This may be a problem as the left op-amp will try to balance this by making the ouput as low as possible. This is just fine, and in fact may be a good thing as it ensures that it's side stays fully off. On the other hand, I think that the voltage from emitter to base of one of the transistors will be very high - so high that it exceeds the maximum V_eb rating of the transistor. Keep in mind that the voltages given in the schematic are probably not correct. I'm thinking I will have the voltage supplied to the opamps and the main Vcc at 18V or so.
Virtual slaps across the face and calling me a fool if I'm wrong are welcome.
--Chuck
Smack!
Did you post somewhere what transistors you were using?
Regarding your schematic, there are a couple of things that you need to be careful of here Phil. The first is that you may exceed the max base current for the switching transistors. The resistor in series with the emitter will limit that of course but still.
The second thing is that you may find that the opamps merely bias the power transistors to pass the desired current. What that means is that they will essentially be operating in their linear region and may in fact be dissipating much more heat than you expect. Many H-bridges use PWM because it keeps the transistors (or FETs) fully saturated as much as possible which minimizes the power loss. Only losses during switching are an issue (which is why you want nice clean switching from on/off.)
Lastly, the 12v supply on the OpAmp vs the 5v Vcc supply will reverse bias your top transistor, not sure how that will affect the circuit though.
--Chuck
BTW - VERY little heat! My shunt resistor is the smallest 5W I had - 1 ohm. That's probably the hottest part and even it is comfortable to the touch. I also doubled up on the transistors and just lopped two together in parallel for every one in the schematic.
The Transistors are just some I had lying around in a large quantity - 2SA2023(PNP) and MH8100C(NPN). I'm only pushing at most about 1A and probably less, but I imagine the voltage drop across the transistors ups the dissipation.
Sounds like you've got a successful circuit there. Its probably not an issue for your transistors, but you should not assume parallel junction transistors will work in all cases. The problem is that the temperature coefficients of transistors are such that as one heats up it will conduct more current than the other. So in essence one of the transistors will heat up first and take all the current, and then at some point fail.
Not that this is not the case for FETs, which can be paralleled, as the current will decrease as temperature goes up, and thus limit the thermal runaway problem.
Just for fun I quickly simulated the circuit you posted earlier but with some minor modifications. It seems to behave well. I've only done an electrical simulation though.
The circuit attached as shown feeds a 12V/2A winding from a 15V supply and can be driven directly from a Propeller 3.3V pin. No op-amps are needed.
The BOM is also attached, around $5 USD per H-bridge using unit-quantity pricing. Vendors and RoHS part-numbers are provided for all the active components. The transistors are 60V/10A Darlingtons. The attached .zip file has the transistor and diode electrical models should you wish to simulate the circuit yourself.
Regards,
David
Thanks again for the schematic/BOM.
Notice that in Drone's schematic he has Vm (V motor) connected to the emtters of the top two PNP transistors. The 3.3V is just providing enough current into the base of the 2n2222's to switch on the bridge transistors. Those transistors are switching the 12v (or 15v) being supplied to the motors. There isn't any current monitoring of the motor so you'd be constrained with such a design to not supply more voltage than the motors internal resistance could safely limit the current.
@Drone - The H-bridge you drew is the same design as one I back engineered out of a R/C toy once. I was trying to convert it to be a robot and wanted to know where to put the control signals into the board (I was prepared to cut traces and leave just the control lines open). As it turns out there is also a pretty clever PCB pattern you can use (single sided no less) that puts the transistors into a tight group (this is no doubt why the toy manufacturer loved it).
I'm glad to see someone gets decent behavior out of Pspice. I've got the Proteus package from Lab Center Electronics and setting up simulations seems overly painful.
--Chuck
If you examine the schematic, the motor winding voltage source V1 is connected as Vm to the top of the H-bridge at 15VDC. I'm driving one leg of the full H-bridge with V2 which is a 3.3V 20ms pulse (from a Propeller pin, presumably). The other leg of the bridge is turned off (grounded) for simple analysis, but the circuit is symmetrical.
Losses in the circuit may be less with typical MOSFET's, but probably impossible to drive with 3.3V as shown using MOSFET's without an op-amp or similar to drive Vgs higher, (discounting the likes of HEXFETs and/or specialized "logic-level" compatible MOSFETs, that are difficult if not imipossible to model in SPICE - but maybe be modelled using Hendrik's VDMOS app/model generator for LTSpice, Hmm...)
Hi Chuck McManis; highly respected in this topic IMHO... Have you used Hendrik's latest VDMOS model utility with the likes of logic-compatible MOSFETs and/or IR's HEXFETs? I value your opinion. Let's take this to PM if-so.
The circuit as shown does have relatively slow rise-time, 20ms is about as fast as you can go to turn-on one leg of the bridge due to the RC values I've selected for the winding (guessing something like 17mH and 6 Ohms Rs for 12V/2A), numbers that may be reasonable for a 12V/2A winding as I think you mentioned previously in this post.
At first glance I don't see how adding an op-amp will improve the on-time switching speed, it seems the speed is limited by the RC values of the winding I've chosen (it would really help us if you can post your motor specs, but I've mentioned this previously in this post - maybe you don't have the specs with a "surplus motor" but I can help with a method to mesure them.) Just to verify this, I increased the V2 drive-pulse to 15V vs. 3.3V and the rise-time is pretty-much the same.
Again, you mentioned a 12V/2A motor winding. This is seemingly not typical for actual motors IMHO. It seems like steppers (especially for high-res/high-speed) are lower voltage/higher-current, and therefore lower inductance/series-resistance; like 3 or 5 Volt windings. This will improve speed, which you mentioned may be a requirement as well as ability to drive with MOSFETs at-current. This BJT curcuit will collapse at such low winding voltages & currents. The more we know about your motor, the more we can optimize the design. Optimized yet simple H-bridges are seemingly highly dependant on specific motor specifications.
I should have posted the LTSpice simulation file as part of the .zip. I'll do so tomorrow (I'm away from the machine that has the files right now and there's no possibility of remote access, welcome to my 3rd-World Internet connectivity nightmare).
Best Regards, David - Jakarta
I'm not using PSPICE; you may have thought this from the .._PSpice.lib models called out in the schematic's SPICE driectives.
I'm using LTSpice/SwitcherCADIII from Linear Technologies (completely free - unencumbered). www.linear.com. Great vendor-independant user forum at http://tech.groups.yahoo.com/group/LTspice/. I can't emphasize enough how valiable LTSpice is. I have NO connection whatsoever with Linear Technologies. But it has to be said that LTSpice is a Windows application and is NOT open-source. But again - it IS free and unencumbered/crippled.
The .zip in my post includes both PSPICE and SPICE3 models (subcircuits for the BJT's) for the active components. Both usually work with LTSpice but I haven't tried the SPICE3 models yet.
The Darlington BJT models do not contain thermal parms (from OnSemi). BTW, I just threw in the BJT's fom OnSemi from a Digi-Key catalog because I saw they were still current and affordable. But they're old and getting hard to source. Like I said to Phillpill - I did a "quick" simulation. I knew I'd need Darlingtons to get to a 3.3V pin-compatible drive input. I"m sure there are better-newer Darlingtons out there (suggestions anyone IGBJT's?).
-David
In summary, I'm using the opamps to keep a constant current through the windings. My motor has no specs, and I cannot find any specs, BUT I have about 107 more of them, plus 150 or so more of other small and larger types(anyone interested in buying some?).
I want the highest speed possible for my motors, without the chance of stalling even 1 step. I've gotten them to step at a rate of 1600 steps/second very reliably. The way the switching works, is the program holds the outputs and then sets the ouputs to the next phase, then the next, and so on. I'm thinking I can get a little more speed if I actually switch ALL the windings off for just a split second - however long it takes for the current to fall x amount. I think the downside to this, is that for that period of current fall, the torque will drastically be reduced, which may again limit the speed.
Grrr.
Short answer is no I haven't used them. I looked them up and plugged them into LTSpice and at first glance they appear to generate the same gate drive waveforms that I have observed in practice so to a first approximation they clearly work. (and yes i figured out they were for LTSpice which I went and down loaded, sad that its better than the simulator built into my $1000 E-CAD system )
@Phil, you've made a basic chopper circuit which we mentioned earlier. Given the 1600 steps/second you're probably good to go at that point as most steppers of this ilk are 7.5degree/step ones so you're doing 33RPS or 2000RPM on your stepper motor which, even with a .250" lead screw will move things along at 200"/min for a .100/turn screw and even faster on a .200/turn leadscrew. Remembering that the lead screw is "worm drive" it gets good mechanical advantage and so at this point you can probably start looking at motion curves (accelerate - hold - decellerate type stuff) Most CNCs use the stepper to do backlash compensation and so you want to be able to come to a new position with exactly 0 overshoot.
--Chuck
1/4-20 will work fine as an inexpensive leadscrew however you may find that eventually you want a leadscrew with an ACME thread, both for repeatability and for better wear resistance. In one of my robots I use two brass tubes with a 1/4-20 rod down the middle, one floating and one attached to the bot, to create a simple linear acuator, its got good torque.
Your attachment solution seems reasonable. If you had access to a shop I'd suggest you mill a flat on the stepper shaft and then use a piece of brass rod you've bored out to the correct diameter for the coupler. If you get lazy (as I tend to you can just buy the motor mounts from Sherline and use the couplers they provide. What you won't want is for your attachment to the stepper to either slip (which would make your CNC calculations end up wrong) or have any significant play as that would add to any backlash error the nut was giving you.
On the topic of backlash, as long as you come far enough from one direction to be past any backlash effects you'll be fine. One of the things I've discovered about machinists however is they seem to be constantly using their current machine to build their next machine which is going to be better still . You are correct in that backlash is not cumulative, however all of the components in the drive system contribute to it so if you end up with a lot you will find you're backing out and then going in again more than you might like (or can do in tight places!) and that can compromise what your machine can build. I find that on the Sherline mill if I am careful I can hold a tolerance of .001" and it has a backlash of about .0025".
--Chuck
As for ACME threads, I was just looking at them in McMaster. Not too bad, price wise and I'm sure they are straighter too. My motors already have the bevealed part on the shaft, so my set screw really has an easy time locking it.
I think I understand. Backlash itself isn't cummulative, but the backlash ERROR is. I guess all the play in each part starts to add up, so it's not just the play in the drive nut that gives me backlash, but the play in the rails, flex of the frame, etc. etc. that adds up. That's impressive about the sherline mill. My steppers are 400 turns per rev, and at 1/4-20 screwdrive, that's 0.00025" movement per step. Now, of course I won't have that great precision because of things mentioned just prior, but it's nice having that much control, even if it's bottlenecked by something else.
I understand what you're saying about your op-amps. But your op-amp output can not be higher than 12V in your diagram, and provided you have enough current into the base of the transistors to saturate them (I ensure this by using Darlingtons), then I don't see how the op-amps are going to improve the rise time (and hence speed) of the bridge.
Therefore, when I simulated the bridge, I left the op-amps out and verified what I suspected, that driving the input transistor with 3.3V or 15V didn't make any difference in rise time. You can see the results in the two attached traces. IL-3V.jpg is the current through the winding with 3.3V drive, IL15V.jpg is the current through the winding with 15V drive.
Maybe I'm missing something here. If I get time later today maybe I'll throw the op-amps and the current shunt into the simulation just for fun.
As mentioned in my previous post - I also attach a new .zip file, this time including the the LTSpice schematic (H-Bridge_04.asc file) along with the component models.
Regards, David
Yes - Chuck is right, what you've got with the op-amps is a chopper.
Basically the idea is to drive the winding with a much higher voltage, this decreases the rise time to charge the winding inductance. But unless you limit the current, you'll overdrive the winding. The op-amps sense the current and turn off the bridge when the rated current is reached. The winding discharges below rated current, and then op-amp turns the bridge back on. Hence the drive voltage is "chopped". An efficient way to limit current while decreasing rise time.
Note the attached schematic and waveform of the current through the winding. The supply voltage has been increased from 15V to 36V to decrease rise time. The op-amp inverting input senses the current via the 0.1 Ohm shunt (approx. 0.2V). The propeller pin at 3.3V is dropped to approximately 0.2V by a resistor divider and applied to the non-inverting input of the op-amp, which is acting essentially as a voltage comparator.
As you can see from the waveform of the winding current, the rise time has been dramatically improved. Once the rated 2A is reached, the op-amp starts chopping the applied voltage keeping it at approximately 2A. The saw-tooth at 2A is due to the inductor charging and discharging as the bridge is "chopped".
The attached VL_Chop_01.jpg is the voltage across the winding. Some chopper limiters have oscillators and gates and/or flip-flops that are driven by the voltage comparators. This one seems to work ok as-is.
I ran the op-amp off a single 5V rail. The LT1490 is a cheap micropower rail-to-rail I/O op-amp. You might want to replace the op-amp with a comparator/reference, current-sense amp, or differential/instrumentation amp instead.k I changed the 2N2222's to the ubiquitous BC546, cheaper & higher Vceo.
Well... I learned something today!
Thanks, David
Post Edited (Drone) : 2/25/2008 3:24:33 PM GMT