7
\$\begingroup\$

I'm trying to control a stepper motor using transistors to switch the different phases (am I using the correct terminology?) on and off at the correct times. I'm going to use my Raspberry Pi to do this (only for testing/learning purposes).

The transistors that I am using are 2N5550 (datasheet). The stepper motor is a M42SP-5P (datasheet). So as far as I understand, the stepper motor needs 259mA for each phase? (If I'm incorrect, could you please explain why?)

The bit I'm struggling with is understanding how much current I need to supply the transistor's base with to get the required 259mA flowing from the collector to the emitter. I know I need a resistor between the base of the transistor and the Pi, but I don't know how much current I need to supply the base with to be able to work the resistor value out.

Stepper motor circuit (The diagram above is showing only one phase connected up, but I actually have 4)

\$\endgroup\$
6
  • 1
    \$\begingroup\$ I'm not convinced those transistors will do the job. Given you're just switching each pole, I'd suggest an N-channel MOSFET makes better sense than a NPN BJT. If you pick something that has "logic level drive" capability then you should be able to drive it directly off the Pi's I/O. \$\endgroup\$
    – markt
    Commented Aug 19, 2013 at 10:28
  • \$\begingroup\$ Could you possibly explain why? It doesn't have logic level drive (if I'm correctly understanding what that means), that's why I need a transistor isn't it? \$\endgroup\$
    – OdinX
    Commented Aug 19, 2013 at 10:31
  • \$\begingroup\$ The MOSFET would have logic level drive, not the motor. \$\endgroup\$ Commented Aug 19, 2013 at 10:43
  • 3
    \$\begingroup\$ Your chosen transistor is not a good choice because it has a low current gain (the ratio of base current to collector current). The Pi may be able to drive it, or it may not, and the transistor may or may not do a good job of switching the stepper motor pole. A logic-level MOSFET will definitely be able to be driven by the Pi, and it will definitely be able to switch the stepper motor pole. \$\endgroup\$
    – markt
    Commented Aug 19, 2013 at 10:52
  • 1
    \$\begingroup\$ Ok, thanks. So did you get that information from the first graph on the 3rd page of the transistors datasheet? If so, I don't really understand what that's showing, so could you explain it? If not, where did you get that information? \$\endgroup\$
    – OdinX
    Commented Aug 19, 2013 at 10:59

1 Answer 1

8
\$\begingroup\$

BJTs tend towards either amplification (Ic increases with Ib) or switching (Ic is on, or off). Amplifier transistors have good gain linearity, but DC gain is moderate, and switching time and Vce(sat) may not be very low (e.g. the 2n5550). Switching transistors have very fast switching time, high DC gain and low Vce(sat) but gain linearity is not much of a concern (e.g. MMBT4401. Then there are general purpose transistors that are middle of the road for both types of operation (e.g. 2n3904).

Unfortunately none of these three example BJTs are suitable for the purpose of the specified circuit, for a multitude of reasons:

  • For driving the load represented by the motor specified, a sustained current rating of 240 mA (12 V / 50 Ohm DC resistance) or 259 mA (from datasheet) is needed. The 2n5550 will handle about 50 mA sustained current with ease, with Vce(sat) hitting 0.25 Volts. At higher continuous currents, heating becomes an issue: Note the derating values for device dissipation above 25 degrees C.
  • Even if we were to drive 259 mA, the transistor would need heaps of base drive current, depending on the worst-case DC gain characteristic of the transistor of choice. More than 20 mA typically for the examples mentioned above, to drive 250 mA Ic. The anemic outputs of the Raspberry Pi are simply not designed for that kind of abuse. One would hesitate to draw more than single-digit current from its GPIO, if that.
  • A high-gain moderate current switching transistor such as NTE2503 might serve the purpose, with its 800 minimum DC gain, and 700 mA continuous current rating.
  • A Darlington pair might sound like another good alternative, but Darlington pairs have a larger voltage drop between collector and emitter, as they have two sets of NPN (or PNP) potentials in the current path. This means more heat generated when current is being passed, therefore need for larger packages and / or heat sinks and cooling.

That leaves a MOSFET as an excellent alternative. For instance, the inexpensive IRLML2502 enhancement mode N-type MOSFET will very comfortably drive over 2 Amperes with a gate voltage of 2.8 Volts, and will not feel warm to the touch at 259 mA Id. Negligible gate drive current is needed except at switching, and this gate current can be limited to a couple of mA using a gate resistor, if very fast switching is not required.

If the motor is to be driven with PWM, then a gate driver could be used as an interim stage to drive the MOSFET gate, either a discrete solution using one of those 2n5550 BJTs that you already have and won't be needing, or using a gate driver IC if truly stupendous PWM frequencies are intended.

\$\endgroup\$
8
  • 1
    \$\begingroup\$ Quality answer, thank you! It sounds like MOSFETs are the way to go. Thanks for the detailed reply. \$\endgroup\$
    – OdinX
    Commented Aug 19, 2013 at 14:23
  • \$\begingroup\$ Having thought about it, a transistor that can only take 50mA is pretty pathetic really isn't it? 1 red LED draws about 100mA so it couldn't even take that?! so what would you ever use a transistor like the 2N5550 for? \$\endgroup\$
    – OdinX
    Commented Aug 19, 2013 at 15:18
  • 1
    \$\begingroup\$ @Chief17 The generic red LED would usually be rated for 20mA, not 100. In any case, a signal amplifier BJT, as opposed to a power amplifier of some sort, would rarely be needed to drive a 100mA load. The signal amplification part generally works with medium to high impedance loads, with low impedance / higher current being limited to a power driver or output stage. So they each have their place. \$\endgroup\$ Commented Aug 19, 2013 at 15:28
  • \$\begingroup\$ So, just so I've got it straight in my head, a transistor like the 2N5550 is better for higher voltage, lower current? \$\endgroup\$
    – OdinX
    Commented Aug 19, 2013 at 15:42
  • 1
    \$\begingroup\$ @Chief17 Low to medium voltage, low current, signal amplification tasks are its forte. For high voltages, an IGBT beats a BJT hands down. \$\endgroup\$ Commented Aug 19, 2013 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.