Arduino Nano to control motor using transistor

I'm planning to control my dc motor (3-6V, 120-220 ma operating range) using my arduino nano and 2N2222 transistor. Using this example for reference http://www.circuitstoday.com/dc-motor-speed-control-arduino-pwm).

Now my question is for 220ma , should I consider hfe as 10 or 40 for calculation of base resistor value.

If I consider it as 10, RB considering drops of input voltage would be (5-0.6-0.7)/0.22/10 =168 ohms
If I consider it as 40, RB considering drops of input voltage would be (5-0.6-0.7)/0.22/40 =672 ohms

Start with a standard resistor value 180 ohms, measure the voltage VCE(sat).

If the transistor is saturated (~.8v) and doesn’t get hot you are good to go.


If your desire is to keep the base current as low as possible, you can raise the base resistor value and monitor the VCE(sat) voltage and case temperature.

Hfe only applies when a transistor is being used in its linear region. When you’re looking to drive the transistor into saturation, as you are doing when using it as a switch, you use 10% of the desired collector current for driving the base. Yes, the result may be the same but the reasons are quite different.

Most switching transistor datasheets will show the relationship between different base currents and the resulting collector voltage at different load currents. If this is not available, go with the 10% number and check the results, the want the dissipation to be as low as possible which means the the collector voltage needs to be as low as possible. Larryd explained the proper way to do it if the datasheet isn’t available or doesn’t define things for you.

For switching more than ~200mA, use as much base current as the Arduino pin can comfortably handle.
That means a 220 ohm resistor for a Nano (<=20mA).
The last thing you want is for the transistor to get out of saturation, and pop it’s heated top.

Are you sure it’s 120-220mA motor current.
Maybe that’s the free-running current draw, which is not relevant.
Stall (start-up) current could be a lot higher.
Leo…

This is the motor

Wawa:
For switching more than ~200mA, use as much base current as the Arduino pin can comfortably handle.
That means a 220 ohm resistor for a Nano (<=20mA).
The last thing you want is for the transistor to get out of saturation, and pop it’s heated top.

Are you sure it’s 120-220mA motor current.
Maybe that’s the free-running current draw, which is not relevant.
Stall (start-up) current could be a lot higher.
Leo…

I have used a 180 ohms resistor and the transistor doesn’t seem to be heating up. So, this should be good to go, right ?

(5-0.7-0.7)*10/0.2 = 180 ohms.

larryd:
Start with a standard resistor value 180 ohms, measure the voltage VCE(sat).

If the transistor is saturated (~.8v) and doesn’t get hot you are good to go.


If your desire is to keep the base current as low as possible, you can raise the base resistor value and monitor the VCE(sat) voltage and case temperature.

You mean VBE=0.8 is sat voltage ? and VCE should be between 0.1 and 0.3 at saturation ?

Try 180R

Measure the voltage ‘collector to emitter’, Vce(sat) when the transistor is on.

If this voltage is between .2 to .8 you’ll be good.

Maximum transistor power .8v X 200mA = .16 Watts

EDIT

Yes it could be .2v thru .8 depends on the NPN used and the collector current.

larryd:
Try 180R

Measure the voltage ‘collector to emitter’, Vce(sat) when the transistor is on.

If this voltage is between .2 to .8 you’ll be good.

Maximum transistor power .8v X 200mA = .16 Watts

EDIT

Yes it could be .2v thru .8 depends on the NPN used and the collector current.

Thanks for the reply. Also, I need to connect a RO solenoid (24V DC 500mA) from my arduino nano. I am going to use a TIP120 NPN for driving this. For this transistor, VBe=1.4V and should hfe considered as 10 or 2000 (as per datasheet) to calculate base resistance. ?

Since I am planning to drive this 24V solenoid with a 12V supply, the current needed I believe would be doubled. Hence I believe I need 1A from TIP120.

Vce(sat) can be quite high let’s assume 2 volts.

To start with let’s use 1000 for HFE.

Your load resistance looks like 24v/.5A= 48 ohms (double check with DVM)

“ Since I am planning to drive this 24V solenoid with a 12V supply, the current needed I believe would be doubled. ”

No.


Gain = Ic/Ib = 1000 = 500ma/Ib

Ib = 500mA/1000 = .5mA

I usually will multiply Ib by ‘10 or more’ to guarantee the transistor goes into saturation.

Let’s use 5mA. Rb = (5v - 1.4Vbe) / .005A = 720Ω use 680.

Now with the transistor turned on confirm the Vce(sat) is 2v or less.

At 2v P=2V * .5A = 1 watt. confirm the transistor does not get hot, if so add a heatsink.

However, suggest you use a ‘logic level’ MOSFET such as one from this PDF list.

larryd:
Vce(sat) can be quite high let’s assume 2 volts.

To start with let’s use 1000 for HFE.

Your load resistance looks like 24v/.5A= 48 ohms (double check with DVM)

“ Since I am planning to drive this 24V solenoid with a 12V supply, the current needed I believe would be doubled. ”

No.


Gain = Ic/Ib = 1000 = 500ma/Ib

Ib = 500mA/1000 = .5mA

I usually will multiply Ib by ‘10 or more’ to guarantee the transistor goes into saturation.

Let’s use 5mA. Rb = (5v - 1.4Vbe) / .005A = 720Ω use 680.

Now with the transistor turned on confirm the Vce(sat) is 2v or less.

At 2v P=2V * .5A = 1 watt. confirm the transistor does not get hot, if so add a heatsink.

However, suggest you use a ‘logic level’ MOSFET such as one from this PDF list.

https://forum.arduino.cc/index.php?action=dlattach;topic=445951.0;attach=354033

Thank you. Will try it out and see if a heat sink is needed. Also, I'm planning to test a 12V water pump (R385 diaphragm type) which has an operating current of 0.5-0.7 amps. So, as per your calculations I believe i should use a 330 ohm resistor in place of 680 ohm resistor for 1 amp of current for the motor.

Also, I will try both the solenoid and motor with a logic level N channel mosfet, IRLB8748 or stp90nf03l. Is there a necessity of connecting any resistor while using this mosfet with the arduino nano pins. I will be using snubber diode (IN4007) across motor and solenoid when using MOSFET. But for TIP120, I believe it has internal snubber protection built in.

Another question I had was, what will the max current that the TIP120 be able to provide for a 12V DC motor or 24V solenoid ? It says its rated for 5 amps in the datasheet.

A similar resistor configuration as C1 in this image should work.


A TIP120 circuit driving an ‘inductive load’ needs a kickback diode across that load.


Remember to always, confirm your switching BJT or MOSFET go into saturation by measuring the Vce(sat)or Vds(sat).


5 amps thru a TIP120 is pushing things; 5A is at the absolute max current. Suggest you stay @ 4 amps or less.

larryd:
A similar resistor configuration as C1 in this image should work.


I believe that you mean "Q1" reference in the attached image instead of "C1" for connecting resistors (220R and 10k) when a logic level N channel mosfet like IRLB8748 or stp90nf03l is used to drive the 12V 1amp motor or 24V 500mA solenoid.

Coordinates “C” “1”
Q2 is your N channel MOSFET circuit.

Coordinates “B” “1”
Q3 is your darlington transistor.

larryd:
Coordinates “C” “1”
Q2 is your N channel MOSFET circuit.

Coordinates “B” “1”
Q3 is your darlington transistor.

Thank you.

larryd:
Coordinates “C” “1”
Q2 is your N channel MOSFET circuit.

Coordinates “B” “1”
Q3 is your darlington transistor.

As per C1, I connected P90Nf03L (STP90NF03L) mosfet, snubber diode (IN4007) and the solenoid (12V) works when connected with the arduino. But sometimes, the solenoid is not turning on. I am trying to figure out whether it is due to poor soldering/wiring (loose conenctions) from my side or there is some other issue. I check the voltage of the pin going from the arduino pin to mosfet which shows as 5V. When I set a high from arduino to the pin connected to the solenoid, what voltage should I measure across the mosfet pins to make sure it has turned on ?

Also, I am powering the arduino via LM2586 board (Buy LM2596 DC-DC Adjustable Step Down Power Supply Module online in India - ElectronicsComp.com), and even connected the 12V input -ve to 5V output -ve together to make sure common grounds are connected, but still issue persists.

Note: I am using a 24V solenoid with 12V and it works with 12V.