problem running DC motor

Hello,

So I just got started with arduino, and I am trying to learn stuff in small steps. I did some stuff with LED blinking and controlling an LED from PWM with a variable resistor. Still basic stuff, so the problem I am having might seem a bit… simple :slight_smile:

I am trying to run a DC motor from a separate circuit, using a transistor to switch that circuit on and off. The circuit is attached.

The parts I used are:

2N2222 transistor, datasheet is here: http://www.marcelsplace.nl/download/24010/P2N2222A-D.PDF
1N4001 diode, datasheet is here: http://www.marcelsplace.nl/download/14005/1n4007_154747.pdf
2k2 resistor
T010160 DC motor, datasheet is here: http://arduino.cc/documents/datasheets/T010160_DCmotor6_9V.pdf
4 AA battery’s in a battery pack

I could post the code, but it’s really simple. The arduino sends 5v for a second over pin 9, and then switches the power off for a second. This loops indefinitely. The result should be that the motor spins for a second, then stops for a second.

What happens is the motor sort of tries to turn, but doenst engage. I’ve seen it work, but only for 1 or 2 tries. It’s almost as if the battery is almost flat. What I tried so far:

  • replace the motor by a resistor and an LED, this works (the led is turned on for a second, and turned off for a second).
  • run the motor directly from the power source, this works as well.
  • test the output voltage from the battery, this is a little over 6v.

If anybody could shed some light on this, I’d be very happy. Thanks in advance!

Your problem is most likely the AA batteries, they can't supply the current required.

Try using a 240V wall plug DC power pack.

Ken

Thanks! This would be because the DC motor needs to start right?
Once it's running it draws about 250 mA, which the battery's can provide easily.

And could you explain why the motor runs fine on the battery alone? Is this because the transistor draws some current as well?

The transistor doesn't draw extra current but it does drop some voltage. So if you have 6V from the battery around 1V maybe dropped in the transistor, more if you're not driving it hard enough, leaving only 5V for the motor.

So you should be measuring the voltage across the motor terminals. And you might get better results if you increase the timing. One second isn't very much time for a motor to spin up to speed.

Steve

I just changed to code so it just turns on the motor.
However, if I try to measure the voltage across the motor in this config I get almost no reading (set the multimeter to 20V reading). I just push-started it, and I get something like 0.5V across the motor.

If I connect the motor directly to the power source I measure 6.1V across the motor terminal. Needless to say, it runs fantastically.

Sounds like you're not actually switching the transistor. And if your picture is correct you don't actually have the Arduino pin connected to anything so that would certainly explain it. If you've corrected that, a better circuit diagram would be in order. One that shows the Arduino getting power from somewhere would be good.

Other things...are you sure you have the transistor connected the right way round ? And the diode is the right way round ? Oh and if you're expecting that transistor to switch 250mA the resistor on the base should be less than 2k2. How did you calculate that value ?

Also it's perhaps time for a look at your code (I have been known to spend a lot of time thinking my code was doing something really simple when sometimes it wasn't at all).

Steve

slipstick:
Sounds like you're not actually switching the transistor. And if your picture is correct you don't actually have the Arduino pin connected to anything so that would certainly explain it. If you've corrected that, a better circuit diagram would be in order. One that shows the Arduino getting power from somewhere would be good.

Other things...are you sure you have the transistor connected the right way round ? And the diode is the right way round ? Oh and if you're expecting that transistor to switch 250mA the resistor on the base should be less than 2k2. How did you calculate that value ?

Also it's perhaps time for a look at your code (I have been known to spend a lot of time thinking my code was doing something really simple when sometimes it wasn't at all).

Steve

Well, this is embarrassing. The transistor was the wrong way around. I checked it multiple times against the data sheet, but never tried to fit it the other way around. So sorry! Thanks for the help though :slight_smile:

Johan

You're still going to have trouble reliably switching 250mA with that resistor but if it's doing something now that's a real advance.

And no need for embarrassment...we've all done it. That's why these forums work so well. You can look at something wrong for ages until someone else prompts you and then it's suddenly obvious.

Steve

change the delay time to 5 seconds and check , because the problem might be that when the motor is trying to engage you are already switching it off

You have a motor rated at 5A starting current, that will simply damage/degrade your 2N2222
if the batteries can supply that current.

A logic-level MOSFET would be more appropriate.

Having said that you definitely need a base resistor of 120 or 150 ohms, not 2k2, if you
want to switch any plausible amount of current through a 2N2222.