0
\$\begingroup\$

I am trying to control a 6v DC motor using Arduino, by feeding a PWM signal to the base of an NPN transistor hooked up to the motor circuit as shown in the schematic below.

schematic

simulate this circuit – Schematic created using CircuitLab

Individually, both circuits work fine; if I remove the transistor the motor spins and if I try to control the brightness of an LED using the output of D5 that also works, but when I introduce the transistor, it fails. I've tried both with the motor + transistor and an LED + transistor, but same problem: nothing happens.

My assumption is that it has to do with my choice of transistor - that a 2N4401 is just not the right kind for this - but if that's the case, I don't really understand why this one doesn't work, or what to look for in one that would work.

(I would also be willing to accept that I have completely misunderstood how transistors work and that there is something else wrong.)

\$\endgroup\$
5
  • 5
    \$\begingroup\$ Do you have the minus pole of the 6 V supply connected to the Arduino ground? Your schematic doesn't show them to be connected, but they need to be connected for the Arduino to be able to drive the transistor. \$\endgroup\$
    – JRE
    Jul 31, 2020 at 9:16
  • 3
    \$\begingroup\$ Also, there's no resistor between the Arduino and the transistor base. That is not good. \$\endgroup\$
    – JRE
    Jul 31, 2020 at 9:17
  • \$\begingroup\$ I think the diode is wrong, too. \$\endgroup\$
    – JRE
    Jul 31, 2020 at 9:18
  • \$\begingroup\$ That is more wrong than I realized then! I was working under the assumption that connecting the battery to the arduino at all could damage it? And is the point of the diode not to cause a loop between the motor's negative and positive pole in order to avoid flyback current to damage the transistor when it switches off? \$\endgroup\$
    – JimJam
    Jul 31, 2020 at 9:19
  • 1
    \$\begingroup\$ The diode's fine. \$\endgroup\$
    – Andy aka
    Jul 31, 2020 at 10:23

1 Answer 1

7
\$\begingroup\$

schematic

simulate this circuit – Schematic created using CircuitLab

Figure 1. Make sure that you have a ground connection between the two power supplies.

Without the V1- connection to the 5V- there is no return path for Q1's base current.

schematic

simulate this circuit

Figure 2. The circuit re-drawn in the conventional format.

With the redrawn layout it is more clear what is happening.

  • We can see that R1 is pulling D2 down to ground and that SW1 will pull it high when pressed.
  • Positive voltages are at the top of the schematic. See +5 V and V1+.
  • Base resistor added for Q1 to limit the current drawn from D5. Without it the output will be overloaded.
  • DC motor coil current flows from top to bottom.
  • It's now very clear that D1 is normally reverse biased (since it's point upwards). It will allow a circulating current through the motor when Q1 switches off. This will protect Q1.
  • Using the ground symbols makes it instantly clear which points are connected to 0 V and eliminates some wires.
\$\endgroup\$
4
  • \$\begingroup\$ I feel a bit sheepish that I forgot how ground works, thanks a bunch for the answer and extra thanks for the schematics pointers, that's super helpful. \$\endgroup\$
    – JimJam
    Jul 31, 2020 at 10:23
  • \$\begingroup\$ Out of curiosity, which parameters would I use to arrive at the value of R2? \$\endgroup\$
    – JimJam
    Jul 31, 2020 at 10:24
  • \$\begingroup\$ Oh, wait, that's just straight from the documentation, isn't it. \$\endgroup\$
    – JimJam
    Jul 31, 2020 at 10:54
  • \$\begingroup\$ You might find this transistor base resistor calculator useful. Read the post a couple of times to understand the details. \$\endgroup\$
    – Transistor
    Jul 31, 2020 at 11:05

Your Answer

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

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