Shop OBEX P1 Docs P2 Docs Learn Events
Stepper Controller — Parallax Forums

Stepper Controller

PhilldapillPhilldapill Posts: 1,283
edited 2008-02-12 19:33 in Propeller 1
I'm going to be getting a huge lot of stepper motors tomorrow, and have been playing with one over the past few days. Now, before I start, I know there are stepper motor controls already out there that I can just grab off the shelf, but frankly, I'm cheap and I love to reinvent the wheel so I understand how things work.
What I want to do, is make a stepper controller that only needs one pin(and maybe a common clock or something for all of them...). I was thinking accomplishing this by using an 8-bit·serial-to-parallel IC. I figure using all 8 ouputs of the S-to-P·converter to drive my dual H-brdige for each motor. Currently, I'm using 2n3904 NPN bipolar transistors as a small H-bridge, but I realized that this is not a good configuration. If you'll refer to the attached schematic, you'll know what I'm talking about. When IO 2 is high, the voltage drop across the base of Q1 and the emitter of Q4 is about 1.2V, Plus the inductance of the motor winding. However, the voltage drop across the base of Q4 and the emitter, is only 0.6V and no inductance. I'm afraid of this inductance getting in the way of driving Q1 as fast, and that there is a high voltage drop across it to begin with. I know using MOSFETs would be better, but this is only a simple concept prototype after all. For now, would it be better to use PNP transistors as a replacement for Q1 and Q2 and have all the bases of each transistor seperate on their own IO pin? This way for a dual H-bridge, I will need 8 pins total, which is exactly what an 8-bit SP converter has. Any suggestions welcome.
«1

Comments

  • Nick MuellerNick Mueller Posts: 815
    edited 2008-02-08 17:23
    I feel you should read this:
    <http://www.mcmanis.com/chuck/robotics/tutorial/h-bridge/index.html&gt;

    Not specifically for steppers, but a nice H-bridge.

    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-02-08 18:02
    Hmmm, I like how they fixed the PNP transistors and only use 2 pins!
  • JoergJoerg Posts: 91
    edited 2008-02-08 19:24
    If you like it simple you may try the circuit shown in the attachement.
    The driver is almost ready to use! Just ask!


    Saluti Joerg
    2168 x 1538 - 40K
    423 x 687 - 15K
    423 x 687 - 17K
  • Nick MuellerNick Mueller Posts: 815
    edited 2008-02-08 19:48
    > Hmmm, I like how they fixed the PNP transistors and only use 2 pins!

    The thing quite clever is using opto-couplers. So the whole noisy power part is completely isolated. A drawback is, that you can't PWM it with high frequencies (1kHz max, IIRC). I'll try it with faster OCs (HCPL4502 or such).

    I'm in the process of building a traversal table feed (DC-motor) for my (not already ex-manual) surface grinder. Prop-driven, of course!
    May add two steppers for down and side feed, so I don't have to be standing by. Grinding is a sloooow process ...


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-02-08 20:00
    Joerg, I like your schematics! However, I'm looking at the H-bridge schematic and I understand how you control the NPN(low side) and PNP(highside) with a single NPN, however, don't you still have that voltage drop problem with the highside having a higher drop than the low?
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-02-08 20:00
    BTW, the steppers I'm working with are 3.3V so any drop is bad.
  • JoergJoerg Posts: 91
    edited 2008-02-08 20:37
    Dear Philldapill

    The voltage drop was exactly the reason to develop this circuit! The transistors are always operating in saturation
    which means minimal losses!

    Make sure the base current of the power transistors is about three times the minimal base current needed: Ib = Ic / hFE *3

    The base current of the steering transistor is about (Uout - 1,4V) / Rbase. The circuit works similar to a Darlington configuration
    with the advantage of a much lesser saturation voltage (~0.3V instead of ~1.5V!!).

    I hope this helps

    Saluti Joerg
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-02-08 20:41
    Fantastic! Exactly what I wanted... However, I have a ton of power mosfets with Rds_on = 0.0045 Ohms. I'd like to use these. I know I can't simply swap them out for the transistors, but is there any down side to using a mosfet in an H-bridge? The only problem I can see running into is the turn off delay which might lead to the left or right side being on at once, causing a short... Any thoughts?
  • JoergJoerg Posts: 91
    edited 2008-02-08 20:44
    BTW the original circuit you posted has several issues:

    - the lack of ANY base resistors!!!
    - the high side output voltage will be lat least 0.7V below the output voltage of the chip output and even more with the
    resistor needed in series so i would say the high side voltage is at least 1V below the chips output voltage -> 2.3V!!

    - so finally voltage you may use is 2.3v minus 0.3V = ~2.0V!!

    My circuit will reach 3.3V - (2*.3V) = 2.7V (if the resistors are well chosen!!)

    Saluti Joerg
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-02-08 20:50
    Thanks Joerg, I drew that circuit up in about 2 minutes just to show the gist of what I was talking about. Again, thanks for the circuit! I like the low voltage drops!
  • bot-manbot-man Posts: 22
    edited 2008-02-08 21:09
    Philldapill,

    Any chance you might sell off a few steppers to someone in Austex?

    I might be able to help with driving them. I suspect a 2n3904 is going to be a bit light for driving a reasonable sized stepper.
    I have used some 2n2222 for driving a floppy drive stepper at 12V. But these are still quite low current motors.

    Since you have some efficient FETs available, I'm sure they would be better. Do you know if your steppers are bipolar or
    unipolar?

    Paul

    Post Edited (bot-man) : 2/8/2008 10:34:01 PM GMT
  • JoergJoerg Posts: 91
    edited 2008-02-08 21:25
    Only for information: The ZTX753 and ZTX&53 are able to drive up to 2A in a TO92 case!!

    -> good night!

    Saluti Joerg
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-02-08 22:42
    Phildapill said...
    BTW, the steppers I'm working with are 3.3V so any drop is bad.
    When you mention that your steppers have to run on 3.3V, you may be laboring under a misconception about how steppers should be driven. The important stepper rating is the coil current. The voltage rating is insignificant by comparison. The reason for this is that if you were to drive the stepper at only its rated voltage, you would suffer a severely compromised running torque at the higher step rates. Why? Because a stepper coil is inductive and it takes some effort (and time) to get current to flow in it. And the amount of time it takes to reach its rated current, starting from zero, is inversely proportional to the applied voltage. In other words, the higher the applied voltage the quicker the coil reaches its rated current and the more torque it can provide at high switching rates. Of course, if you apply a too-high voltage for too long, the coil will eventually exceed its rated current, and that's bad.

    There are two ways to deal with this when driving the motor at higher-than-rated voltages:

    1. Use current feedback to PWM-regulate the drive circuitry, thus keeping the current at or below spec.

    2. Use a resistor in series with the coil.

    Number two is the simplest (but least power-efficient) method. Use a voltage supply that's four or five times the motor's rated voltage. The resistor should be chosen such that at full saturation, the motor is drawing its rated current. In your case, the voltage across the coil leads would be 3.3V. But here's why it works: When the coil is first switched on, it's drawing no current, so the voltage drop in the series resistor is zero, and the coil "sees" the entire (higher) supply voltage. This forces current into the coil more quickly. As the coil current rises, the voltage drop through the resistor also increases, and the voltage across the coil drops until it reaches its rated value.

    Here is an article that explains these issues in more detail.

    -Phil

    Post Edited (Phil Pilgrim (PhiPi)) : 2/8/2008 10:58:11 PM GMT
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-02-09 01:32
    Wow, now that I think about it, Phil, you're right. A normal DC motor is usually continuously running, generating a fairly constant back voltage. Steppers on the other hand, are basically going from no current, to full current... I like your idea about about the PWM. I believe the goal in achieving maximum torque at high speeds is not to feed the coils a square VOLTAGE wave, but a square CURRENT wave, or as close to it as possible. I understand what you mean when you say to give it 3-4 times the rated voltage at first, and then taper off as the current rises. Playing with this tiny disk drive stepper has showed me the drastic reduction in torque at higher speeds. In fact, I was thinking the same thing about the higher voltages. Thanks!

    Bot-man,
    Yes, I'd be willing to sell MANY of these off to you. You may not have read my previous post, but I will be picking up ~225 steppers of all different sizes. It's a hell of a deal too... $450 for THESE:
    http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=110217746972&ssPageName=ADME:X:RTQ:US:1123

    Let me know which ones you want and I'll sell them for fairly cheap. I gotta make SOME money for my time and investment.

    Thanks guys!
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-02-09 01:32
    Oh, Bot-Man, btw, where is Austex?
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-09 08:55
    I THINK it's Austin, Texas smile.gif
  • JoergJoerg Posts: 91
    edited 2008-02-09 09:54
    Comment to PhiPi solution #2:

    Adding a capacity in parallel of the series resistor speeds up the current thru the coil. But care has to be
    taken for the right value of the C. The C has to be discharged during the off time of the coil.

    Rule of thumb: C * R * 5 = off time.

    Saluti Joerg
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-02-09 14:40
    That's what I was thinking, too, desliva. If he hasn't read my post about the steppers I'm getting, then that's just odd. I'm actually GOING to Austin to pick these up. If he wants, I might just stop by his place, and turn into the traveling stepper salesman from a trunk. Well, for half an hour anyway... Anyone else that wants some steppers for cheap, let me know!
  • Chuck McManisChuck McManis Posts: 65
    edited 2008-02-09 15:35
    At some point I should post the FET version of that tutorial, the challenge is that using FETs is generally waaaay more complicated than one would like because nobody makes a decent P-FET, so you really want an N-channel based bridge, so you really need a Vgs on the high side transistors to be higher than your motor voltage which means your playing games with voltages or you've got multiple, floating, power supplies.

    However for driving steppers you don't really want an H-bridge, you really want a bunch of current sinks, which N-channel fets can do very nicely. As long as you turn them fully on, and do it fairly quickly, you can pass much more current through them than an equivalent bi-polar transistor with very little voltage drop. And as the other Phil in this thread points out what you really want is to put a fixed current through the stepper windings which is best done with something called a 'chopper' circuit.

    --Chuck
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-02-09 15:45
    Funny you say that about the chopper circuit... I JUST saw one in a random, non-related article and thought "gee, that would be great for this..." As for the FET's, to turn them on asap, I think I need a mosfet driver, which basically just pumps a large current into the gate, quickly. Is there a cheap, non-IC way of doing this or should I just go ahead and buy some of these at about $1 each?
  • Chuck McManisChuck McManis Posts: 65
    edited 2008-02-09 18:45
    Think of a FET gate as a capacitor and you'll be fine. Basically you want it to turn on quickly but the amount of current it will draw when you do is very short lived. So if you put a 10 ohm resistor in series with the gate and through 15volts at it then you'll briefly need to put 1.5A but it quickly drops to nano amps (like in about 130 - 150nS, really not very long at all). So turning it on with a reasonably fast transistor like the Zetex ones mentioned at the beginning of this thread would be fine. A typical "high end" stepper driver built out of discretes would have a full totem driver driving the gate of some appropriately sized n-channel FET.

    --Chuck
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-02-10 04:03
    Well, I got the motors today... WOW. If you'll check out the ebay page I posted above, you can see the list. In addition, the guy through in two 6N/m servos. These are big suckers... Probably 10lbs each. If anyone is interested in getting some steppers or a large servo, let me know!
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-02-10 04:08
    By the way, Joerg, many of my steppers have 8 wires, which I believe are 4 phase. These are amazing little motors. I hooked one phase up to a scope and spun it with my fingers and got about 50V out of it... I even wet my fingers, grabbed the leads and whoa... A shocking experience! Now, I'm wondering if these can be used as a small alternator. They are 4 phase, bipolar, and put out clean sine waves. Could I hook each phase up to a bridge rectifier and use it to generate juice?

    Oh, yeah, Joerg - Wanna trade some brand new steppers for some of those completed dual H-bridges, above? These motors have an '89 date code, but they haven't ever been used - still in styrofoam casing.
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-02-10 04:53
    Chuck,
    I've seen many power mosfets using a series resistor. However, I have never understood WHY. It seems that the resistor limits the amount of current going into the gate, thereby increasing the transistion time between off and fully on. The only thing I can think of is to reduce any resonance between the capacitance of the gate and stray inductance in the wire?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-02-10 09:17
    Eight-wire motors can be run either as bipolor or four-phase unipolar. Four-wire motors are bipolar only; six-wire motors, unipolar only.

    -Phil
  • Nick MuellerNick Mueller Posts: 815
    edited 2008-02-10 11:48
    BTW, Trinamic <http://www.trinamic.com&gt; has stepper-controllers and drivers with I2C and incredibly small packages capable of 0.8 A.

    Never used one, though.

    Edit: The current for the I2C-version is 0.8A peak. No external drivers possible. Just read through the manual. Interesting (ramping, position, almost stand-alone, etc) but not what I need.

    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO

    Post Edited (Nick Mueller) : 2/10/2008 4:15:42 PM GMT
  • JoergJoerg Posts: 91
    edited 2008-02-10 13:09
    Philldapill

    for unipolar motors i use the circuit shown in the attachment.

    to PhiPi:
    six wire motors can also driven as bipolar motors using the two wires at the "endpoints". This doubles the resistance but it works.

    Saluti Joerg
    2168 x 1538 - 22K
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-02-10 16:30
    In regards to what you guys said about having higher voltages applied at higher speeds, do you suppose I should have a cog devoted to a PWM signal? This way, I can adjust the PWM for a variable voltage source for the motors? i.e. increase duty cycle for higher voltage at higher speeds.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-02-10 17:45
    Joerg said...
    six wire motors can also driven as bipolar motors using the two wires at the "endpoints". This doubles the resistance but it works.
    Right. I neglected that combo. As a consolation to the resistance (and inductance) being doubled, at least you have all the windings active all the time (which is not the case with unipolar drive). And by doubling the unipolar drive voltage, there should not be a performance hit. In fact the performance should be better than unipolar.

    -Phil
  • JoergJoerg Posts: 91
    edited 2008-02-10 18:54
    To answer the PWM question:

    Simple applications can use simple drivers (like the ones i have posted).

    Sophisticated devices need sophisticated drivers!! (LM298 etc.)

    So probably it would be a good idea to explain what you plan to do!

    Saluti Joerg
Sign In or Register to comment.