# How can I determine what type of resistor, transistor and, diode I need?

I'm trying to build the following circuit Given my solenoid draws 1.4A, how do I determine what type of resistor, transistor, and diode I should use? What if I were to change my power to 9V? I'd prefer to see answers accompanied by the math so I can understand what's going on.

Sorry to tell you this, but your circuit (as shown) won't work.

For a transistor to work as a switch (transistor dropping less than about 1/2 volt), you should design for a base current about 1/10 to 1/20 the collector current. In your case, this requires 70 to 140 mA, and there is no GPIO pin which will handle that.

So you have a choice: use a Darlington or a MOSFET. If you choose a Darlington, you can assume a gain in the vicinity of 100, for a base current around 1 to 1.5 mA. If your GPIO pin is 5 volt, this will require a base resistor of about $$R = \frac{5-1.4}{.001\text{ to }.0015} = 2.4\text{ k to } 3.6\text{ k}.$$ and allowing for the GPIO voltage being somewhat less than a nominal 5 volts suggests something like 2k.

If you use a MOSFET, you'll need to be careful about threshold voltage. If your GPIO has a 3.3 volt high level, a lot of MOSFETs are not guaranteed to turn on at this gate voltage, so you need to pay close attention to the Vgs(th) voltage, which must have a maximum value less than your minimum GPIO voltage.

Your diagram shows an NPN transistor. If you choose an NPN transistor, then you choose your base resistor based on the GPIO voltage, the supply voltage, the $\beta$ of the transistor, and the desired load current (1.4A) (hint: you can solve this easily with the basic model of a BJT).

However, a MOSFET is more appropriate in this situation, in which case the gate resistor (MOSFETs don't have bases) is simply to prevent fast edges from ringing, and can be pretty much anything in the 1k-100kΩ range. Additionally, you might want a pull-down resistor on the gate to ensure that it goes to a predictable state if the device driving your GPIO pin is disconnected.

This answer will help you with flyback diode selection. Basically, you need a diode that can handle at least 1.4A. However, it doesn't need to handle this for very long, which makes choosing your diode much easier.

• With a MOSFET would I need a resistor on the gate? I'm trying to release a drop of water so I need very fast control over the solenoid Jan 9, 2016 at 22:46
• As I said, with a MOSFET, the gate resistor is not necessary to limit current, but only to control slew rate/ringing. Here is a more complete answer. In your application, the MOSFET is not the limiting factor, the mechanical mass of the solenoid is going to be the slowest thing in the system. Jan 9, 2016 at 22:58
• Assuming I stick with a NPN, the load would be 12.5V/1.4A = 8.57 Ohms?. I'm kina in the same situation as this question but I don't have any parts in my kit. Jan 9, 2016 at 23:57
• As for your hint, are you talking about IC/B Jan 10, 2016 at 0:03
• If you need fast turn-off of the solenoid, you should add a zener diode in series with the flywheel diode -- ~ 40 V would work. This zener will make the solenoid current decay much faster and release the solenoid. A R on the FET gate helps with possible ringing; unless it is many Mohm, it won't have any appreciable effect on the solenoid speed. Jan 10, 2016 at 1:10