Go Down

Topic: Loading/stalling DC motor temporarily breaks serial communication to PC over USB (Read 3317 times) previous topic - next topic



I'm trying out the simple PWM DC motor speed control circuit and code shown at the following site, using an Arduino Uno:  http://itp.nyu.edu/physcomp/Tutorials/HighCurrentLoads

The only differences between my circuit and the one shown are the motor and power supply.  I'm using a 6v motor and a 6v power supply.  My Uno is powered by a 12V, 2A power supply and it is also connected to the PC via USB.

Everything works great while the motor is spinning with no load attached.  However, when I add a non-trivial load or stall the motor, the serial communication between the Uno and my PC fails.  I can no longer upload sketches or read the results of any serial.write() on the serial monitor.  The IDE says that the com port is already in use.  The motor control sketch continues to work and I can still control the speed via the potentiometer.  The only way I can restore serial communication to the Arduino is to close the IDE, unplug the Uno from the USB port, reconnect it, then start the IDE again.

I'm stumped.  The only two likely causes that I can think of are that either the load on the motor is somehow drawing current from the PWM port (even though it's effectively isolated by a transistor) or I have a grounding problem that manifests itself whenever the current draw from the motor increases (even though the circuit has common ground shared between the Uno and the external power supply).




A couple of questions:

1) Are you using a bipolar transistor or mosfet?
2) If you are using a bipolar transistor - do you have a base resistor (you better!)?
3) Probably not related to your issue, but a small-value cap across the motor leads (at the motor frame) will reduce brush noise (this may save you frustration in the future).

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.


Hi cr0sh,

I don't have a base resistor and I am using a bipolar transistor - a TIP120 to be exact.  This lack of a base resistor sounds like the cause of my problem, but I don't understand why. Apparently there's a large hole in my understanding of how transistors work, and I think I just fell though it. 

Thanks for the speedy reply, cr0sh.  I await enlightenment.


It is strange that the tutorial doesn't include a resistor. I would vote for that being fixed.

For a Darlington transistor like the TIP120 the base-to-emitter junction looks like a diode with a forward voltage of about 1.4V nearly independent of current. The Arduino is putting out 5V. How does the 5V output of the Arduino get reduced to the 1.4V base-emitter voltage of the TIP120? By drawing lots and lots of current out of the Arduino so that its output voltage goes down to 1.4V. That is very bad for the Arduino and would certainly explain your loss of communication.

With a resistor in between the Arduino and the TIP120 base the difference between 5V and 1.4V is taken care of by a voltage drop across the resistor. The 3.6V difference divided by base current is the resistance (or more practically, the 3.6V difference divided by the resistance you choose is the base current). This base current should be enough to allow enough current to flow in the your motor (hardly a problem with a Darlington transistor) but not so much as to harm the Arduino (<20mA or so). I'd start with a 1k resistor.

The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, speaker, microphone, light sensor, potentiometer, pushbuttons



The resistor is found on the "How to Drive Solenoids with the Arduino" in the Playground.


That page can be a bit hard to find.



Do you have to reboot your computer to get the serial port to work again?
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0


Hi everyone, and thanks for the help. 

zoomkat: I don't have to reboot the PC in order to get the communications back up.  Unplugging the Uno ,connecting it again, then restarting the IDE is enough.

RuggedCircuits:  Your reply sent me on a long, winding journey of discovery about transistors and basic electronics - I'm mostly a software guy - and for that I'm grateful.  I think I learned a lot, but I'm still stumped.  Even though I put 3 kOhms between the Uno's 5V and the base pin, I can still cause the oddball behavior by stalling the motor.  The interesting thing is that it doesn't happen at the slightest hint of a load, as it did before.

I found the following formula for calculating base resistor values at http://forums.parallax.com/attachment.php?attachmentid=37701

My motor is rated at 100mA max.  I'm not sure if this is the stall current rating.  Assuming that it is, based on the formula R=((Vsource - 1.4)*Hfe)/(Stall Current), with the 1.4 being the voltage drop across a Darlington, I get:  R=((5V-1.4)*1000)/(.1A) = 36kOhms.  Does this make sense to you, or am I just horribly confused?


100mA is likely the operating current, not stall current (which can be much higher and is generally bad for the motor).

The 36k makes sense numerically but practically it doesn't hurt to let 1-2mA of current into the base no matter what the hFE just because you can. At least eliminate this variable for now. And drawing 1-2mA from an Arduino pin is no big deal.

Now as to the oddball behavior, with the base resistor there my next best guess is ground bounce. If you'd like another long winding journey then read about "star grounding". Lots of Google hits on this. This one looks pretty good (just about all of them have to do with audio though):


The basic idea is to ensure that electrons that travel over the "motor loop" (from the power supply, to the motor, through the transistor, and back to the power supply) do NOT (as much as possible) travel over any bit of wire in the "Arduino loop" (from the power supply, to the Arduino, back to the power supply).

Beat707: MIDI drum machine / sequencer / groove-box for Arduino


Thanks for the pointers on grounding.  I tried star grounding (running all grounds to the same rail on the breadboard in this case) but no dice.  It's a good practice, though, and I'll continue to use it.  How can I test for ground bounce?  My test equipment consists of a Craftsman digital multimeter.

I also took the step of rewiring the circuit as shown here http://luckylarry.co.uk/arduino-projects/arduino-control-a-dc-motor-with-potentiometer-and-multiple-power-supplies/.  I changed all the grounds to be on the same rail, and I even added about 6kOhms of base resistance.  Same problem.

I'm beginning to wonder if this is an EMF problem.  As a test (ok, in frustration actually) I took the motor out of the circuit and shorted together the leads that feed it.  I figure if it was a current draw problem, that should cause the Uno to lose serial communication.  It din't.  With the leads shorted, the Uno was happily chatting away to the serial monitor.  Put the motor back in, run it, and then load it or stall it and presto! serial communication goes haywire.

Has anyone on this forum built a circuit like this and experience similar behavior?


As a test (ok, in frustration actually) I took the motor out of the circuit and shorted together the leads that feed it.

Whaaaaat??!? Never a good idea.

OK, working on the principle that it is EMI, how far away can you move your motor from everything else? If you can get it a couple of feet away and you still have this problem then it's not EMI.

Being pessimistic, you've put your circuitry through some fairly major stresses (running a transistor without a base resistor, running a transistor with a shorted load). There's a reasonable chance that 1 or more of your components are malfunctioning due to this stress (esp. the transistor). Rather than chasing this down you may want to start with a fresh Arduino and fresh transistor, use a base resistor, don't short out the motor leads, etc. and see if it still happens.

The Rugged Motor Driver: two H-bridges, more power than an L298, fully protected


Sounds like a good idea.  I'll get another TIP120 and try a different pin on the Uno to drive the base.  I don't have another Uno handy, and this one works fine with the exception of this particular scenario, so hopefully that's not the root cause.



I added a 0.1 µF capacitor across the leads of the motor, and a 470µF capacitor across the power and ground rails on the breadboard, right next to the Uno's ground lead insertion point.  I no longer lose serial communication to the Uno when the motor comes under load or stalls.

I was coming close to building an isolator circuit in order to completely decouple the motor side from the Arduino/PC side, using an ADUM1402 (http://www.analog.com/en/interface/digital-isolators/adum1402/products/product.html), but I figured that this couldn't be the only solution.  I did some more research and found that it's good practice to filter out the noise and spikes from DC motors by using capacitors as shown at http://www.pololu.com/docs/0J15/9 and in many other sites.  A glaring display of ignorance on my part, but now I know better. 

I'm not sure how (i.e. what's the theory behind it) this fixes the problem, because I'm still not sure what the cause of the problem was.
If any one can shed some light on this, I'd be grateful.  I don't like doing things without having and understanding of why I'm doing them.  I'll keep reading until I figure out how this actually fixes things.

In any case, thanks to everyone that tried to help out!

Go Up