3
\$\begingroup\$

I got an Arduino Pro Micro and some parts to play with. I want to control a little 5v motor from an external power supply by using the Arduino to trigger a transistor. Like this:

enter image description here

Is that at all correct? Will it work? I want to experiment but I don't want to break my new toy in the process. The transistor I am using is an NPN, 2N3904.

\$\endgroup\$
6
\$\begingroup\$

You want to use your transistor as a switch. I found a nice site about that which gives this circuit:

enter image description here

Now forget about all the garbage and strip the design down to this:

schematic

simulate this circuit – Schematic created using CircuitLab

Your circuit is correct, except that it's missing the base resistor (R1) and the pull-down resistor (R2). Also, the load (your motor) has to be on the collector of the transistor, not on the emitter. At last, use a flyback or flywheel diode with the cathode to Vcc, like in the first image, to avoid high voltages.

So in the end, your schematic would look like:

schematic

simulate this circuit

Explanation of the circuit:

  • R1 is required to limit the current on the base of the resistor and thereby the current drawn from the Arduino. If you do not use the base resistor, your Arduino might break.
  • R2 is a pull-down resistor which makes sure the voltage on the base of the transistor is low enough to not conduct whenever there is no input signal from the Arduino. So this resistor makes sure you know in what state the circuit is when the Arduino is disconnected. This resistor is not required, but recommended.
  • D1 is a flyback diode which eliminates the voltage spike when the motor stops or starts working. It goes too far to explain why, but whenever you let a current flow through a coil or when you stop letting the current flow, a voltage spike may occur. With the flyback diode, you make sure that spike is eliminated immediately. Usage of this diode is highly recommended.

One last thing to explain: why the motor has to be on the collector side and not on the emitter side of the transistor. Wouter explains this in his answer, in short: with the load on the collector side you are in charge of what voltage the motor gets; with the load on the emitter side, this voltage cannot be higher than the voltage on the base (minus something).

\$\endgroup\$
  • \$\begingroup\$ Hi Camil, I appreciate all of the work you put into the post and most of what you said makes sense to me. However, I do have a couple of questions: 1. If the Arduino input is off, why is the R2 resistor needed? Won’t the base have no voltage and there for the transistor wont trip? 2. My understanding is that diodes prevent current from flowing in a direction, but why does it tie the + and - poles of the motor? Why wouldn’t it just be on the negative pole since that is that part connected to the Arduino? \$\endgroup\$ – Madagascared May 5 '13 at 7:25
  • \$\begingroup\$ @Madagascared most of the time it works without R2 as well, but with this resistor you always know what happens. It isn't required, but recommended. Your understanding of diodes is correct. When the DC motor gets disconnected, a voltage spike may occur on the transistor side. With the flyback diode, you directly eliminate the spike by letting it flow to V_cc. If you do not do this, the transistor gets the spike on his collector and he may not like this. \$\endgroup\$ – user17592 May 5 '13 at 7:28
  • \$\begingroup\$ @Madagascared please do not accept an answer so quickly. Just wait a few days - an accepted answer discourages others from answering whilst they may have interesting things to say as well! \$\endgroup\$ – user17592 May 5 '13 at 7:29
  • \$\begingroup\$ @CamilStaps pull down resistor is not necessary if you drive the BJT with an ATmega output, since it goes to 0, not to high impedence. \$\endgroup\$ – Felice Pollano May 10 '13 at 5:02
  • \$\begingroup\$ @FelicePollano correct, but what if you change the pin to input or disconnect the uC? Then it's a good thing to have the pull-down. It's just good practice of course as well. \$\endgroup\$ – user17592 May 10 '13 at 6:14
3
\$\begingroup\$

It might work (at least for some time), but there are a few issues:

  • you did not mention how much current the motor will draw. a 2N3904 is a small-signal transistor, it might not survive the motor current (note that a stalled motor draws a much higher current)

  • like a relay, a motor can generate voltage spikes. I would put a diode in parallel to the motor. (observe the polarity!)

  • you use the transistor as emitter follower, hence the voltage on the motor can only be as high as the output voltge of the arduino (minus 0.6V or so). This might work, but I would prefer the motor 'in' the collector wire. This would require a suitable resistor in the base 'wire'.

\$\endgroup\$
1
\$\begingroup\$

I wouldn't even use a NPN tranistor to begin with due to heat dissipation (Pd). Pd can be calculated using:

NPN/PNP -> Pd = Vf*I = 0.7V*I As you can see here, if you're drawing 1A, then that transistor will heat up like there's no tomorrow. (0.7V)*(1A) = 700mW.

MOSFET -> Pd = I^2*Ron = small number As you can see here, even at 1A, there's essential no heat giving off. Since the on resistance is typically in the milliohms. (1A)^2*10mOhm = 10mW.

Also, most MOSFETs have built in flyback diode!

\$\endgroup\$
1
\$\begingroup\$

Here is a question: you say that the 5V power supply for the motor is not connected to the Arudino at all. In this case, I have my doubts that the circuit will work, unless it happens to be ground coupled somewhere else (for example, if your Arduino is powered by USB, which is coupled to the AC ground, and the motor power supply is coupled to the same ground through the outlet). In any case, relying on stuff to be coupled through mains power unintentionally is not how you want to design circuits (for example, it will stop working if either the Arudino or the motor goes to battery power). For example, in this circuit, the V_be (base-emitter voltage) is undefined.

A simple fix is to connect the ground of the Arduino to the ground of the motor power supply. If you really insist on not having a ground coupling, you need to have some other form of coupling, whether optically (opto-isolator) or magnetically (transformer).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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