Monday, January 21, 2008

Arduino Motor Driving Discussion

Some people are having issues with resets when driving DC motors from their Arduinos. It has been suggested that previous Arduinos (without auto reset) are less sensitive to noise than the current ones. Lets not talk about the difference in Arduino makes for right now. Instead lets concentrate on whats happening with the motor setup and why this could cause problems. Finally, we'll suggest a proposal to reduce the noise in the circuit.

First, the different components involved are
1.) DC motor
2.) Output drive circuitry
3.) Arduino (of course)

In it's most simple form (forgetting back EMF) the motor would look like this circuit:

The Arduino would be driving this motor with an external transistor configuration shown below using a fixed frequency and variable PWM (pulse width modulation) to control motor speed,

Now, lets put them together and we have our basic motor drive circuit,

Now lets look at how the current flows when the transistor is on,

Notice the clamping diode installed around the motor. This will help clamp any energy coming from the coil in the reverse direction when the transistor switches off.

Now that we understand the basic setup. Lets see if we can shed some light as to why resets are happening.

Lets start off with making sure we still have a clean 5v supply running the Arduino when we're running the motor...

DC motors can suck a lot of juice from the 500mA limited USB supply. Lets look at the high side of the motor's supply to make sure we're doing anything nasty to the poor USB.

The below image shows how a capacitor is used to bucket the energy.

So maybe, we should limit the capacitor's ability to draw too much current from the supply by adding a series resistor. Using a passive component like a resistor has some efficiency implications. There are much better ways to limit current through the use of active components.

For our purposes of trying to clean up the 5v supply, we can entertain the idea. See the image below.
Say for instance, the bucket capacitor is 10uF. On power up, it will take 25ohms * 10uF = 250 microseconds to charge up to 62% or 1 time constant. After that, the voltage ripple on your 5V supply should be much less than before because the current is safely limited to motor.


Unknown said...

Hé thanks for illustrated explanation !! good work

Anonymous said...
This comment has been removed by a blog administrator.