[Arduino] Simple hobby motor and transistor circuit not working

Discussion in 'Embedded Systems and Microcontrollers' started by HunterDX77M, Mar 12, 2016.

  1. HunterDX77M

    Thread Starter Active Member

    Sep 28, 2011
    104
    2
    So I'm trying to construct this simple motor circuit, where the motor spins and doesn't spin in an alternating pattern. The circuit diagram is attached and the sketch is below.

    Code (Text):
    1. int motorPin = 9;
    2. void setup() {
    3.   // Pin 9 is an output pin
    4.   pinMode(motorPin, OUTPUT);
    5.  
    6. }
    7.  
    8. void loop() {
    9.   digitalWrite(motorPin, HIGH);
    10.   delay(1000);
    11.   digitalWrite(motorPin, LOW);
    12.   delay(1000);
    13. }
    So obviously the problem is that the circuit isn't working as intended. I took a multimeter and began probing around. I found that:
    • The VDD line is about 5V, but alternates between ~4.7V and 5.0V every second (a little weird).
    • The voltage at Pin 9 alternates between 0 and 5V (that's correct).
    • The voltage across the motor alternates between 0V and 0.07 volts every second (totally wrong).
    The diode I am using is 1N4003. When I tested it out in my multimeter, the forward voltage was 600 to 700 mV, which sounds correct. I'm thinking my transistor might be wrong or not functioning. The diagram calls for what looks like an NPN, so I am using a 2N4124, which is an NPN according to the datasheet. The hFE I measured falls within the minimum/maximum listed. I'm using a 2K resistor instead of a 2.2K, as shown in the diagram.

    The motor itself is working. I attached both ends to a plain AA battery briefly and it spun.

    At this point, I'm not sure what else could be wrong in the circuit. Any tips on where else I should focus my debugging efforts?
     
  2. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,377
    494
    I am thinking you are powering the motor badly. How much current can Uno source from its 5 Volt socket?
     
  3. HunterDX77M

    Thread Starter Active Member

    Sep 28, 2011
    104
    2
    Hey, shteii01. Thanks for replying.

    According to this page, the absolute max per pin is 40 mA. How much do you think a hobby motor would need?

    http://playground.arduino.cc/Main/ArduinoPinCurrentLimitations
     
  4. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,377
    494
    I don't know. Do you know what hobby motor is? Who made it? What voltage it uses? What current it uses?

    I can tell you that dc motor fans in pc need 100 to 140 mA. If I send 40 mA to one of them, they will simply laugh and point finger at me.

    Have you tried this tutorial:
     
    absf likes this.
  5. John P

    AAC Fanatic!

    Oct 14, 2008
    1,632
    224
    Try shorting C and E of the transistor, so the motor is running directly off 5V. If it runs, the problem is that the transistor isn't working or isn't being turned on. If it doesn't run, the power supply isn't adequate to make it work.
     
  6. dannyf

    Well-Known Member

    Sep 13, 2015
    1,768
    357
    Too many - as you have given very little information about your set-up.

    An obvious question would be what kind of motor and how much current it draws and what kind of voltage source it needs to drive it. I would re-route the motor to the power source directly but knowing what you are dealing with first would be key in finding out the source of your troubles.
     
  7. ScottWang

    Moderator

    Aug 23, 2012
    4,850
    767
    As a hobby motor and assuming it's current as this needs 110 mA,
    When you using the bjt as switch then the hFE will be count it as 10.
    Ib = 110 mA/hFE
    = 110 mA/10
    = 11 mA.

    You could prepare a little more current for Ib as 15 mA.
    Rb = (V_d9 - Vbe)/Ib
    = (5V - 0.7V)/15 mA
    = 286.7Ω

    You could using 270Ω for Ib = 16 mA or 300Ω for Ib = 14.3 mA.
     
  8. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,377
    494
    i don't think they can source 110 mA from Arduino board.
     
  9. ScottWang

    Moderator

    Aug 23, 2012
    4,850
    767
    Please read my posted again.
     
  10. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,377
    494
    You made an assumption that motor needs 110 mA.
    Based on this assumption you calculated Ib of 11 mA, you then modified this Ib to 15 mA, which is fine because Uno can normally source 20 mA from its pins.
    Using Ib of 15 mA you calculated base resistor Rb to be 286 Ohm, then you gave OP the choice of using standard 270 Ohm or standard 300 Ohm base resistors, which is also fine.

    But here is the thing. All this calculations are based on that initial assumption that Ic will be 110 mA. The way OP wired his motor, the Ic will come from Uno and Uno CAN NOT produce 110 mA. So, yes, the Uno will send 15 mA into the base, it will turn motor on, the motor will try to draw 110 mA from the Uno, Uno will peak at about 40 mA and that is it, it can not supply any more current to the motor.
     
  11. ScottWang

    Moderator

    Aug 23, 2012
    4,850
    767
    Max current out of 5v pin on UNO?
     
  12. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,377
    494
    If I am reading Arduino schematic for Uno right, they are using NCP1117 for regulator that outputs 5 volts. It seems it will output 1 A when powered by 10 or more volts. My mistake at looking at Arduino documentation, which generally is not very good.
     
Loading...