I'm very new to electronics and just want to get some feedback on a circuit + hopefully some explanation about a couple of points:

I have a digital pulse (PWM from controller ranging from ~0-300Hz) which needs to control a proportional solenoid (inductive load/coil) (the base resistor R2 would be hooked to a PWM pin on a microcontroller by the way not directly to the +24 I was just doing it in a simulation)

I'm used to using NPN as a switch and believe I need to use a MOSFET due to the 2A rating of the coil so think I should do something like the diagram:

You'll probably note that

i) I have schemed the coil as a resistor (R3) - if the coil is 24v I assume that it's load is calculated from its coild resistance? (confused on this)

ii) I have put another resistor R1 which I think I don't need as a current limiting resistor - does R3(the coil) do this on it's own?

iii) The NPN should almost certainly be a mosfet as it is switching +2000mA - correct?

iv) I have put in a flyback diode - ignore if polarity is wrong I do understand the concept.

What else should I do? Any advice?

  • \$\begingroup\$ Put solenoid where R1 is. Reverse diode polarity. IF you want current limiting you can use a resistor where R3 is now but usually not wanted in this application. MOSFET is easier for playing. BJTs can be had that are very fast and very powerful but at low frequencies (which this is) then MOSFET is good. \$\endgroup\$
    – Russell McMahon
    May 19, 2012 at 14:21
  • 1
    \$\begingroup\$ Your circuit should look more like this one \$\endgroup\$
    – m.Alin
    May 19, 2012 at 14:29

3 Answers 3


Ditch R1. Yes, 0.001\$\Omega\$ resistors exist, but what would you do with it? At 2A it will drop 2mV. The collector current is defined by the base current, there's no need to limit it this way (if that would have been the purpose).

You don't necessarily need a MOSFET to switch 2A, but if you use a BJT it will probably have to be a Darlington. OTOH a MOSFET is much faster than a BJT, so better suited for PWM work.

Then the flyback diode. It's wrong polarized, but you mention that in the question, so I won't say anything about that.

If the solenoid is a 24V/2A type its resistance will be 12\$\Omega\$, not 5.6.

I missed the line that says you'll be driving it from a microcontroller. The following assumes you drive it from 24V, like in the schematic. Later I'll make a note about the microcontroller.

Then R2. Assuming a solenoid of 12\$\Omega\$, and an \$H_{FE}\$ for your Darlington of 100, then from the base this will look as a 1200\$\Omega\$ resistance. You'll need 20mA of base current. With a voltage of 22V (24V minus a couple BE junctions) that would mean you should have maximum 1100\$\Omega\$ for R2 + \$H_{FE}\$ \$\times\$R3. So even without R2 you won't get the 2A. You'll need a transistor with a higher \$H_{FE}\$.
But even then R2 won't be necessary. With an \$H_{FE}\$ of 1000, if the base current would be higher than 2mA the transistor will saturate and the solenoid will limit the collector current to 2A.

Important notice on the common collector configuration you're using. Even if you would drive it from 24V the emitter voltage won't be 24V, but 22V. The base voltage will be 24V maximum, and if it would drive the emitter higher than 24V minus 2 BE junctions there wouldn't be no current anymore.
If you drive it from a 5V microcontroller the emitter voltage won't go higher than 3V! Again, if it would be higher there wouldn't flow any base current. You might use a common collector with a 24V input, but not with 5V.

Usually you'll use a common emitter configuration, where the solenoid comes at the place of R1. In that case you'll need R2. If your microcontroller runs at 5V and you're using the KSD1222 (see below), you'll have a voltage drop of 5V - 2V = 3V across R2. You'll need at least 2mA, but let's play safe and give it 10mA. Then R2 should be maximum 3V/10mA = 300\$\Omega\$.

If you want to use a MOSFET the Si2318DS is suitable. It's a 40V FET which can drive 3A at less than 4V \$V_{GS}\$. \$R_{DS(ON)}\$ is 45m\$\Omega\$, so at 2A it will only dissipate 180mW. That sounds safe, but when you're going to PWM this will rise due to switching losses. At 300Hz this will not really be a problem, however.

If you would want to use the Darlington, the KSD1222 is also a 40V type, with \$H_{FE}\$ of minimum 1000. Can drive 3A. But here saturation voltage can be as high as 1.5V. At 2A this means the transistor will dissipate 3W, so you'll need a heatsink. The MOSFET is the better solution.

  • \$\begingroup\$ Thanks @stevenh - A lot of great info there and am digesting \$\endgroup\$ May 19, 2012 at 14:44
  • 1
    \$\begingroup\$ +3 for everything, but only +1 is possible, so let it be for placing the load on the collector where it belongs. I would add that if, on a positive supply, you want the load to be ground-based, then use a PNP transistor. \$\endgroup\$
    – Kaz
    May 19, 2012 at 15:08
  • \$\begingroup\$ @Kaz - Thanks. You're right about the PNP, but I don't think it will be necessary for this kind of load. \$\endgroup\$
    – stevenvh
    May 19, 2012 at 15:14
  • \$\begingroup\$ @stevenvh Agreed; exactly: it's unlikely that we care at what potential is a solenoid. \$\endgroup\$
    – Kaz
    May 19, 2012 at 16:29
  • 1
    \$\begingroup\$ @m.Alin - I'm the one who's right, of course! :-). You're right, not everyone seems to agree. Anyway, this source says "BJTs normally have less switching di/dt and dv/dt". You'll find others confirming this. \$\endgroup\$
    – stevenvh
    May 20, 2012 at 5:43

As in your last question, you exhibit major misconceptions about how transistors work and how they can be applied to circuits. Since it's not clear what you were thinking in coming up with the circuit you posted, I won't go into all the things wrong with it but instead show how to solve the problem.

To be clear, I'll assume the problem is to control a 24 V 2 A solenoid proportionally from a 5 V digital PWM output. The PWM duty cycle is intended to be roughly the solenoid drive level. A 24 V supply with at least 2 A capability is available.

Since you need considerable current, a FET is easier to drive in this case. A NPN as low side switch would work, but even assuming a generous gain of 50 for a power transistor that can handle 2 A, that still requires 40 mA base current. That is more than can be expected from a ordinary digital output, so would require additional gain. The IRLML0030 is a easy solution since it is voltage driven instead of current driven and can hanlde this voltage and current. It is guaranteed to have no more than 40 mΩ channel resistance at 4.5 Volts gate drive, which dissipates only 160 mW at the full 2 A load. It will get warm, but that's still doable for a SOT-23 package.

D1 is there to provide a path for the solenoid current immediately after Q1 switches off. The solenoid coil looks like a inductor to the driving circuit. Without this diode, the voltage at SOL- would rise to whatever level it takes to force the same current as before the FET switched off. This would destroy the FET rather quickly. Note the orientation of D1. It does not conduct when the FET is on. It is also Schottky for low forward drop, but more importantly for fast reverse recovery time. The solenoid will surely still have current thru it when switched on again to start the next pulse. A slow recovery diode would get major backwards current thru it for a while. This would eventually damage both the diode and the FET.

  • 1
    \$\begingroup\$ Thanks @Olin - you are right, I am a hobbyist and am trying to learn what you have probably spent a lifetime accumulating ;) \$\endgroup\$ May 19, 2012 at 14:43
  • \$\begingroup\$ Apparently the problem with the BJT is not the base current, but the dissipation. At least with stevenvh's darlington. \$\endgroup\$ May 19, 2012 at 15:19
  • 2
    \$\begingroup\$ @federico - Non-Darlingtons may have a bit lower \$V_{CE(SAT)}\$, so a bit lower dissipation, but base current is really a problem there. Power transistors often just suck. The TIP31 has an \$H_{FE}\$ of 10(!) minimum. It needs 200mA for 2A collector current. (Maximum allowed base current is 1A). While a high current output from a microcontroller or logic IC may be able to do 40mA, for 200mA you'll need enforcement. The obvious solution is indeed a Darlington, either discrete (you can place a BC817 before the TIP31), or as a single component. \$\endgroup\$
    – stevenvh
    May 19, 2012 at 16:24

I would drop the pointless tiny collector resistor, and put the load in its place. Connect the emitter to ground with no resistance.

If you must have one end of your load at ground potential (while keeping with the positive power supply), then use a PNP-transistor-based circuit instead.

You do not want any resistance in the emitter circuit because that creates negative feedback, which greatly increases the impedance of the base circuit, making it harder to drive in the required base current for saturation. (Feedback reduces gain, opposing the drive to saturation, which is bad in pure switching.) From the point of view of the base, the resistance through the emitter is approximately multiplied by the gain, so 100 ohms looks like 10,000 if the current gain is 100!

In switching, you want hard saturation, which keeps the voltage across the transistor to a minimum and hence power dissipation.

The 2SD882 NPN medium power transistor can handle the 2A of collector current, has a high \$H_{FE}\$ and low saturation voltages. Look for the NEC ones; don't even bother looking at other manufacturers' datasheets for the same part number. The NEC ones are graded by DC current gain with a letter grade, E being the highest (200-400). (This is given in the datasheet from NEC and marked on the part, but not others I have looked at). I bought the NEC ones before, over the counter from a local supply. All their \$H_{FE}\$ values tested at around 360, and these only marked as P grade (second highest).

At \$H_{FE}\$ 300 you need 6mA of base current to turn on 2A. Say we double that to 12 mA. To get that much of base current, we would need about a 2K resistor for R2. \$(24V - 0.7V)\over .012\$ (assuming, again, no resistance at the emitter!). The power dissipation of the resistor would be a little over .25W, so choosing at 1/2W resistor would be wise.

The \$V_{CE}(sat)\$ of this transistor is cited as only about 0.3V at 2A of collector current. This gives a 600 mW power dissipation at saturation, which is not down to MOSFET levels, but respectable. According to the graphs, in the datasheet, 0.6W is within the range that requires no heat sink, up to an ambient temp of around 70C. It's easy to bolt a small heat-sink onto this part.

  • \$\begingroup\$ That 2SD882 looked promising, so I dived into the datasheet. Unfortunately that high \$H_{FE}\$ is only for low currents (100mA). At 3A it's only 30 minimum. \$\endgroup\$
    – stevenvh
    May 19, 2012 at 16:42
  • \$\begingroup\$ I specifically linked to the NEC datasheet, not to the ST one. The HFE verus Ic curve is quite different in the NEC datasheet. It shows a curve that starts at about 140 at low current, reaches a peak of around 170 at around .8A and then trails down to 140 at around 3A. I have one of the higher-HFE ones left in my parts box and could test it empirically. It could be that the higher HFE degrades a lot more. Based on the ST datasheet, the ST part looks like a crappy knock-off, indeed. Also, that datasheet mentions nothing about grading by HFE. \$\endgroup\$
    – Kaz
    May 19, 2012 at 17:56
  • \$\begingroup\$ Be advised that the OP wants to control the solenoid from a microcontroller, so the base of the transistor will see 5/3.3V instead of 24V \$\endgroup\$
    – m.Alin
    May 19, 2012 at 18:14
  • 1
    \$\begingroup\$ @Kaz - I'll have to believe you on your word. I changed the link because the other one didn't work. (First got a CAPTCHA, which I hate, then an error that the document couldn't be opened.) But I find it strange that they would be so different. Same part numbers from different manufacturers may show minor differences, but main parameters should be the same. \$H_{FE}\$ at a given current is crucial. \$\endgroup\$
    – stevenvh
    May 20, 2012 at 5:34

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.