DC motor disconnects and reconnects USB

Hi guys,

I'm completely new to Arduino and to this forum, got my starter kit last week and have been working through some tutorials to get to grips with all the components.

I purchased a 'For Dummies' book to follow along with, and have just reached a section covering the use of DC motors. The circuit uses a transistor to power the motor and includes a diode to prevent any unwanted reverse voltage through the circuit.

I've attached the schematic for reference, the only different potentially worth noting is that I had to change the resistor value to 5.1k, as I didn't have a 2.2k.

I have built the circuit and written the code to spin the motor for one second, then power it down for one second and repeat.

In the tutorial, it said to be careful wiring up the transistor, as getting the Collector and Emitter the wrong way round could result in a short circuit, which could damage my USB port or the Arduino itself.

I'm now worrying, because when I upload the sketch everything works fine, but my laptop is bleeping to signal that the USB drive is disconnecting and then reconnecting continuously.

Is this likely just a result of feedback from the circuit, or is this affect only a possibility if things have been wired up wrong and may have damaged my board? I made sure to check the datasheet for my transistor and was careful when wiring to ensure I got the legs the correct way round, and haven't had any error message on my laptop to say that the USB drive was drawing too much power.

There was another tutorial I read online which said you should never power a motor from the board directly and should use an additional power supply module instead. Is that true?

I'm worried now that I might have damaged my new favourite toy! :fearful:

DC_Motor.PNG

Motors takes loads of current, never power them form a logic supply rail, they inject all sorts of spikes and
dropouts on the power and can cause resets, or even damage.

A separate supply for the motor, presumably 6V or so would be reasonable here. Common the grounds.

That circuit is wrong, the resitor should be 150 ohms, not 2k2, or you'll simply fry your transistor. 5k1 is
hopelessly large and cannot possibly put the transistor into saturation unless its a darlington, but the circuit diagram shows a plain BJT, not a darlington.

You also need to use a transistor that can handle the current the motor takes at stall. Most small transistors cannot.
Also you need a transistor that only needs 30mA of base current to reach saturation when carrying the motor
current.

So questions:

What motor?
What transistor?
What stall current does the motor take direct from a suitable power supply?

Thanks very much, Mark. That was a really helpful answer.

Whilst it might be possible to power the motor using the right transistor, I've taken heed of your advice and avoided this method to mitigate any risk to my board!

I found an alternative tutorial which walks me through using an L293D chip (which my starter kit thankfully came with!) and power supply module to run the circuit safely, and I've been playing around with this without any warning signs from my USB drive this time!

Moral of the thread is, don't try and power a motor directly through the Arduino. Regardless of what a tutorial tells you!

stotty146:
Moral of the thread is, don't try and power a motor directly through the Arduino. Regardless of what a tutorial tells you!

Even this tutorial at the highly regarded adafruit powers a motor from the Uno 5V pin, although they do at least have a caveat about current. But they don't go as far as mentioning a separate supply: they should.

And the servo knob and sweep tutorials here on arduino.cc power the servos from the board too.

So it's no wonder the bad habit perpetuates.

wilfredmedlin:
And the servo knob and sweep tutorials here on arduino.cc power the servos from the board too.

Potentially daft question, but just to double check, is it all types of motors which should be powered externally then?

I'm about to start playing about with servos and stepper motors next, so am I to apply the same rule of ignoring the tutorial if it says to power these through the board and use an external supply again?

Many thanks

According to this, even micro servos are up in the 700mA area at stall. I do sometimes power one from an Arduino for just a quick test of something, but it's not worth the risk.

Have a search for "servo problems Arduino" or similar: almost all are power related, and the problems go away with external power.

Thanks very much, I'll have a read through some examples and be wary in the future! :slight_smile:

I'm a newbie as well and just done the same tutorial and had weak motor power. After some searching I noticed the transistor pin image (Emitter pin etc) in the book was the opposite way around compared to an article I read.

"Transistors typically have one round side and one flat side. If the flat side is facing you, the Emitter leg is on the left, the Base leg is in the middle, and the Collector leg is on the right."

Completing the circuit using the note above fixed my issue and it worked as expected.

mystrey2010:
"Transistors typically have one round side and one flat side. If the flat side is facing you, the Emitter leg is on the left, the Base leg is in the middle, and the Collector leg is on the right."

No, transistor pinouts vary considerably, you must check the datasheet for the particular
transistor you are using.