Transistor + DC motor = problems..

Discussion in 'General Electronics Chat' started by Captain E, Jun 28, 2015.

  1. Captain E

    Thread Starter Member

    Jun 16, 2015
    81
    6
    Hi..
    I'm having some trouble learning how to control DC motors. It feels like I know how to do it, as some of my practice circuits work perfectly, but next day they dont. (so I'm doing something wrong)
    Here is a circuit I just made, that doesn't seems to work.

    What I know:
    A normal DC motor need more than the 5V the Arduino UNO can give, so I need a external power supply for the motor, for example the batteries, which in my case is one 9V battery.
    My arduino needs to control the 9V flow to power the motor, which is where the transistor comes in.
    Transistors (in my case, a NPN bjt) have got three pins. From left, flat side towards you, mine has: COLLECTOR - BASE - EMITTER.
    Collector collects voltage, and depending on the voltage given to the base, different amount of current is allowed to flow from collector to emitter. So by connecting my pin 3 on the arduino, I can use a small voltage from the Arduino to make a large voltage from the battery run my motor. The arduino is also protected by the 9V with a resistor.
    The diode is there because of "back EMF" or "back voltage" that the DC motor can produce when turned off but still spinning. If any back voltage, the diode creates a short circuit, ending the back voltage.

    That is what I think I know, so if anything is incorrect, please say so.

    This is my code, simply switching the voltage of the output pin 3 from HIGH to LOW and vice versa each second.

    Code (Text):
    1. void setup() {
    2.   pinMode(3, OUTPUT);
    3. }
    4. void loop() {
    5.    digitalWrite(3, LOW);
    6.    delay(500);
    7.    digitalWrite(3, HIGH);
    8.    delay(500);
    9. }
    Using a multimeter:
    - Only about 0.13V and 9mA is flowing through the motor, which is not enough I guess.
    - Pin 3 is switching between 3-5V to 0-0.5V which seems right.

    I've tried changing resistor for pin 3, removing the diode, etc.

    The thing is that everything about me and npn transistors works perfectly when using this exact method, but controlling a LED on/off.
    So I guess there is something missing in my knowledge on DC motor controllers, so I hope someone one you might know what it is I'm missing.

    If any information you need to help me is missing, please say so and I'll give it.

    Thank you in advance! :)
    ~ Captain


    [​IMG]
     
  2. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    Learn to use schematics instead of cartoons
    Looks to me that your battery is 3V; not 9. It appears to be wired backwards.

    This is what it should look like:
    m.gif
    Depending on the required motor current, a TO92 plastic NPN transistor is too small in power dissipation. More likely you need a TO220 package. Also, if the motor current exceeds ~400mA, the Arduino cannot provide enough current to drive the base of the transistor. In that case, you will need an NFET (logic gate) or a Darlington transistor.
     
    Captain E likes this.
  3. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,813
    1,105
    Removing the diode (why??) is likely to kill the transistor. If the transistor were to fail with a collector-base short you would risk having 9V applied to the micro. Reducing the base resistor also risks stressing the micro.
     
    Captain E likes this.
  4. Captain E

    Thread Starter Member

    Jun 16, 2015
    81
    6
    Hi! Okay, I'm now using a IRF520 mosfet instead. I'm using a 9V supply for the motor, and everything should be placed correctly, because everything works IF: I put my finger on the output from pin 3 to gate. I guess it wants to be grounded, but if I put it to ground using WIRE, nothing goes through the mosfet. What is this??
     
  5. Captain E

    Thread Starter Member

    Jun 16, 2015
    81
    6
    EDIT!
    (ITS NOW WORKING)

    The finger-makes-it-work thing was the last problem and got solved by having two resistors to the gate. Smaller one to the output pin, and a bigger on directly to the shared ground.

    Why is this working? Is it because the output pin will randomly output voltages if there is no connection? (i've read something like this, I remember) so if there is no voltage from the output pin, it will not be random, because of the ground?
     
  6. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,073
    3,856
    An output pin should (will) put out either 5V or be grounded. The problem can be your code (is that pin ever set to an input?). If it is ever an input, it is not grounded, it is floating - can't tell or can't know at what voltage. Also, when the device is off, you are in jeopardy of killing your mosfet by static if it is not connected to the source pin with a resistor (eg 100k).

    Finally, back EMF from your spinning motor can also cause issues with your circuit (depending how it is wired and what diode protection you have.
     
    Last edited: Jun 28, 2015
    Captain E likes this.
  7. Captain E

    Thread Starter Member

    Jun 16, 2015
    81
    6
    Thank you guys, for the help! :D :D
    I got these things working now and I understand it. (=success!)
    Stay awesome, thanks again :D
     
  8. Lag

    New Member

    Apr 2, 2016
    3
    0
    Hi man, this is a long shot, but i'm having almost the same issue than OP, but i'm using a TIP122 and a 5v line from an ATX PSU, so i should have enoug current to move a 3.6V dc motors, but nothing happens, i tried the circuit with a LED it does work, i belive my problem is on my current flow, but can't figure out a way to solve, What do you think i could do?
     
  9. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,073
    3,856
    Post a schematic with resistor values.
     
  10. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,813
    1,105
    Welcome to AAC!
    When the TIP122 is turned on the collector voltage may not drop below about 2V, so with a 5V supply that leaves only ~3V for the motor. I would expect it to at least try to start if everything is wired correctly.
    What is the current drawn by the motor when it is stalled?
    What value resistor do you have in series with the base of the '122?
    What is driving that resistor?
     
  11. bertus

    Administrator

    Apr 5, 2008
    15,649
    2,348
    Hello,

    Looking at the drawing in the openings post, I see that the + of the battery pack is connected to the GND of the arduino.
    Is the battery pack connected correctly?

    Bertus
     
  12. Lag

    New Member

    Apr 2, 2016
    3
    0
    The motor draws around 1.2 Amps
    I have a 1 kOmh in series with the transistor base
    Right now for driving i'm using the 5V from an arduino connect to a buttom for easy switching

    My Schematics is bassically this:
    https://itp.nyu.edu/physcomp/wp-content/uploads/LabHighCurrentLoadSwitch_schem1.png

    But without the voltage regulator, instead i'm using a 5V rail from a ATX PSU to power the motor and the 5V from the arduino to power the base.
     
  13. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,813
    1,105
    Vbe(on), the voltage needed at the base to turn the '122 on, is ~2V, so the base current through 1k is ~3mA. In theory that's enough to allow ~3A of collector current, so 1.2A shouldn't be a problem. Perhaps you have a higher-than-expected resistance somewhere in the motor supply path. Is your circuit built on a breadboard or a proper PCB?
     
  14. Lag

    New Member

    Apr 2, 2016
    3
    0
    On a breadboard!
     
  15. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,813
    1,105
    Then poor contact and flimsy connections could account for failure to get enough motor current.
     
Loading...