Go Down

Topic: I need help running a small DC motor with the arduino (Read 2629 times) previous topic - next topic

I can't seem to figure this out, and I know it must be simple enough to do.

I have the arduino pin 9 connected to the base on a p2n2222a transistor through a 22K resistor. I connected the 5V and ground to the rails on my bread board. The collector is connected to ground, and the emitter is connected through my DC motor to the positive rail. I also have a diode connected in parallel across the motor as you should do with any inductive load.

Nothing happened when I powered on the arduino and wrote some code to turn pin 9 on. (I tried using USB power and a wall wort)
I wasn't positive that I knew my collector from my emitter, so I switched it and still nothing.

I measured the current through the transistor circuit and it was at about 5 mA, which obviously isn't enough to run the motor. And to top it all off my ATMega was getting really hot, so I unplugged it and am now stumped.

Here is a picture of my circuit set up. Any advice?
http://i.imgur.com/EKZ8n.jpg

Hello,

if you didn't make a mistake on the transistor reference, and if I got the right manual off of the internet, that is an NPN transistor.
Therefore, the collector should be connected to 5V and the emitter should be connected to the ground. I'd use the motor connected on the collector side instead of the Emitter side... but it should work either way as long as it is powered properly.

By the way, do remember to reverse the diode, otherwise you'll be "short circuiting" the motor.
Eu não sou o teu criado. Se respondo no fórum é para ajudar todos mediante a minha disponibilidade e disposição. Responder por mensagem pessoal iria contra o propósito do fórum e por isso evito-o.
Se realmente pretendes que eu te ajude por mensagem pessoal, então podemos chegar a um acordo e contrato onde me pagas pela ajuda que eu fornecer e poderás então definir os termos de confidencialidade do meu serviço. De forma contrária toda e qualquer ajuda que eu der tem de ser visível a todos os participantes do fórum (será boa ideia, veres o significado da palavra fórum).
Nota também que eu não me responsabilizo por parvoíces escritas neste espaço pelo que se vais seguir algo dito por mim, entende que o farás por tua conta e risco.

Dito isto, mensagens pessoais só se forem pessoais, ou seja, se já interagimos de alguma forma no passado ou se me pretendes convidar para uma churrascada com cerveja (paga por ti, obviamente).

Magician

The resistor you've mention is pretty high,
put something 220 Ohm - may be 300 Ohm

CrossRoads

Here's an example circuit of an NPN transistor like 2N2222 driving  relay to drive a higher current motor.
Put your smaller motor between +5 and the collector.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

AWOL

Quote
The collector is connected to ground, and the emitter is connected through my DC motor to the positive rail

The 2n2222 is an NPN
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

CrossRoads

"And to top it all off my ATMega was getting really hot, so I unplugged it and am now stumped."

Usually a good sign that ATMega has been damaged by excessive current draw. Might be dead.
With external stuff unhooked, does a basic sketch like Blink upload & run?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Thanks for the answers guys. I dropped the resistor and put the transistor in the right orientation, and still nothing. I also checked to make sure it still runs the blink sketch, and it does.

I then disconnected everything from the arduino, loaded the blink sketch and just connected my multimeter to measure how many volts it is putting out. Here is the strange thing, most times I measured it, 5.6V high, 0V low, but sometimes when I measured it, there would be 1.2V high and 0V low. Also it once read 3.5V high. What does this mean? Did I fry my ATMega?

Since I was worried my pins did not work, I connected the base through a 330 resistor directly to my 5V out, and the circuit still did not work. I tried multiple transistors. I was able to get a LED blinking through the transistor, but there was still not enough current to drive a motor.

I watched this video: http://www.youtube.com/watch?v=cEz1i5xzGEE&feature=related and did everything he did exactly, and my motor did not run. I have no idea what to do next.

AWOL

A DC motor could be anything from a phone vibra to a diesel truck starter motor.
You need to find out the characteristics of your motor.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

polishdude20

Quote


I watched this video: http://www.youtube.com/watch?v=cEz1i5xzGEE&feature=related and did everything he did exactly, and my motor did not run. I have no idea what to do next.


ok well did you connect the collector and motor to the 5v pin on the arduino and not the digital pins? Also what kind of motor is it?
If you have access to a multimeter measure the current the motor draws when it is connected DIRECTLY to the power supply, that means putting the multimeter in SERIES with the motor and battery/power source.

Laslty, it depends on what power source you are using for your arduino. If you are using something higher than 5v then the arduino's regulator must work harder to bring it down to 5v. That is probably why it gets so hot.

Luckily I had a problem similar to yours and I have a whole post about it and my trials and it happens that I got everything to work.

Here's the link: http://arduino.cc/forum/index.php/topic,54761.0.html

@polishdude20

Thanks for the response. I did try connecting the transistor directly to the arduino 5V out. It is a pretty small DC motor, 1.5V if I remember correctly. I measured the current draw on the motor connected directly to a 9V battery and it was pretty high, about 650 mA if I remember correctly. The 2n2222a is rated to 600 mA, but I figured that would be enough to run the motor just a little slower. Is this logic wrong?

The ATMega itself was getting hot, not he voltage regulator. I am guessing this means it was drawing too much current through itself, which makes no sense to me.

I read through your thread, you found out you just needed to use MOSFETS? Maybe I will go buy some of those tomorrow.

polishdude20


@polishdude20

Thanks for the response. I did try connecting the transistor directly to the arduino 5V out. It is a pretty small DC motor, 1.5V if I remember correctly. I measured the current draw on the motor connected directly to a 9V battery and it was pretty high, about 650 mA if I remember correctly. The 2n2222a is rated to 600 mA, but I figured that would be enough to run the motor just a little slower. Is this logic wrong?

The ATMega itself was getting hot, not he voltage regulator. I am guessing this means it was drawing too much current through itself, which makes no sense to me.

I read through your thread, you found out you just needed to use MOSFETS? Maybe I will go buy some of those tomorrow.


yes but my problem was that the transistors where getting too hot and not the atmega itself. hmm. I also  had a 1k resistor in series with the base of the transistor, try that. Also it would  help if you posted some code maybe? The MOSFETs I use I found in an old UPS
(Uninterruptible power supply) and they are the IRFZ44V, I know how confused I was when I was trying to buy parts and didn't know which ones exactly s there's that name for you, I'm sure there's other equivalent ones that will work but there ya go.

Oh and that logic isn't wrong your right, at 9 volts the current averaged at around 650 mA so approximatly at 5 volts lets say the current would go down to around 350mA at 5v using ohms law so yeah that should be fine, BUT, you might find that the motors use maybe almost an amp when they spike right when they start from a full stop. Check the current through the motor again with 9v or 5v if you want, and this time, like crossroads told me in my post , measure the current while the motor is stopped with your fingers, then also check  that spike in the current when the motor first starts from a stop. Because if it does that you may find that the transistor can't provide that high spike current to get the motor to even start.

Lastly, try and "help" the motor by spinning it with your fingers while you have the transistor providing current.

Nick Gammon


Here is a picture of my circuit set up. Any advice?
http://i.imgur.com/EKZ8n.jpg


I've got a board like that. The black sides are made of metal (aluminium I think). It looks from the photo the metal side is very close to, if not touching, a row of pins on the side of the Arduino. That won't help if it does.

Also judging by the photo you have run Vin to the minus (blue) rail, and Gnd to the positive (red) rail. That's OK if you are consistent, but as long as you don't get confused later on.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Nick Gammon


Here's an example circuit of an NPN transistor like 2N2222 driving  relay to drive a higher current motor.
Put your smaller motor between +5 and the collector.


Crossroads, I always like your posts because I often learn something new from them. :)

Just a question though, in the circuit you posted you had the load between +5 and the collector. What would the practical difference be if you had the load between emitter and ground? The same current, roughly, would flow through it wouldn't it? Or are there subtle reasons why you wouldn't do that?
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

CrossRoads

One way to think of BJT (NPN & PNP) is like this for the way we using them as digital switches:

NPN transistors like to sink current, so have the emitter to ground.
PNP transistors like to source current, so have the emitter tied to +V.
This has to do with the way current froms the base and out of the transistor.
Effectively the voltage difference between base and emitter is hosed when you try to source a high voltage out of the emitter vs having the emitter at basically ground in an NPN, and similar for a PNP.

http://www.opamp-electronics.com/tutorials/introduction_3_04_01.htm
This is a good explanation.  The arrows for current flow are backwards from how we normally think of them  - from electricity going from positive to negative. The electrons actually from the negative terminal of a battery to the positive for example.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up