Introduction: Simple, Cheap Motor Controller

I've used this simple circuit several times to drive motors (like in my Stair Climbing robot) as well as solenoids. I originally picked it up from this instructable which is focused on controlling a solenoid. I wanted to isolate this circuit in its own Instructable as a motor driver so I could easily reference it from other future instructables and also provide example code to show how to use it in this manner.

Step 1: Parts List

The parts list is pretty short:

  • A 1N4001 Diode
    adafruit has a 10 pack for $1.50
  • A small solderless breadboard
  • Jumper wires
  • A 1K resistor
    (you'll need 2 if you want to add an optional LED which I'll cover later)
  • A DC brushed motor
    (When choosing a motor for this project, note that the TIP120 transistor can handle 5A continuous and 8A peak.)
  • A battery with enough power to run your motor and enough voltage to power the arduino (7-12V)
  • An arduino uno (or other flavor of your choice)... really anything that can supply a pwm signal.

Step 2: Operation Principle

PWM stands for pulse width modulation. This basically means it is a circuit that is being turned on and off (pulsing) and you can change how long it is on and how long it is off (that's the modulation part).

In the world of servos, a PWM signal acts as sort of Morse code... a micro-controller in the servo reads the duration of each pulse and uses that to decide where to turn the motor to.

However, this speed controller is simply fully proportional... that is to say: you can change (modulate) the pulse from all the way off to all the way on and the motor will go from standstill to running at full speed. If the pulse is such that is is on half the time and off half the time the motor will turn at 50% of its maximum speed.

The transistor is using that low voltage / low amp pwm signal and using it to switch a higher voltage, higher amp signal going from the battery to the motor. It is acting as an amplifier in this sense.

An advantage of using this method to alter the motor's speed vs changing the voltage is that you maintain the motor's torque. This is because at any given time the motor is either completely off or completely on.

Step 3: Connecting the Circuit

I've posted the circuit on fritzing:
http://fritzing.org/projects/super-simple-motor-co...

(Look for the "downloads" section in the lower right.)

I also have the example code on codebender:

Step 4: Options

LED:
You can optionally add an LED. The PWM signal will control how bright it glows. So the faster the motor goes the brighter the LED will be!

Just connect the anode (the + side with the longer leg ) middle transistor leg or negative side of the motor - then connect the cathode (the - side of the LED with the shorter leg) to the a 1k transistor which is then connected to the positive power rail.

Power:
Powering the arduino with the same battery as the motor is optional but convenient. You don't have to disconnect the Vin pin when you connect the USB to program the arduino since "The Arduino Uno can be powered via the USB connection or with an external power supply. The power source is selected automatically.... external power will be chosen if it's above 7.4V or so, otherwise USB power." - source

Reverse?
This circuit is very simple and only drives one motor in one direction. Though I have duplicated the circuit and driven a Bogie Runt Rover with it (which has 6 motors - I drove the left 3 motors with one of these circuits and the right 3 motors with the other). Since there is no reverse you don't get a full tank style steering but it is certainly maneuverable (in fact I built a line follower using this setup).

Comments

author
kastymizilian made it!(author)2016-06-15

Hi All, I want to do the same think but regulating around 60V input, is this circuit applicable? should I change transistor for MOSFET? if so what type?

btw. I am tottaly green with this stuff so go gentel on me :P

author
Autodesk+Circuits made it!(author)2015-10-14

Cool Instructable! We thought it'd be fun to make the simulation in 123D Circuits. Instead of a TIP120 we used an N-MOSFET. We also added an oscilloscope to show your PIN3 PWMing live! If you visit the page press "Start Simulation" to kick it off. https://123d.circuits.io/circuits/1117055

NMOS Motor Controller.jpg
author
TeamJaeger made it!(author)2015-10-15

awesome!

author
Autodesk+Circuits made it!(author)2015-10-19

TeamJaeger - you inspired us to add a simulate-able TIP120 to the 123D Circuits Electronics Lab (simulator) so we did that, and we built your exact circuit. Here it is: https://123d.circuits.io/circuits/1133854

TIP120 Motor Controller.jpg
author
TeamJaeger made it!(author)2015-12-07

oops looks like this link is not working

author
Autodesk+Circuits made it!(author)2015-12-07

We can't edit the original comment but this is the circuit from the image with the TIP120: https://123d.circuits.io/circuits/1148270-simple-cheap-tip-120-motor-controller

author
TeamJaeger made it!(author)2015-10-20

Super cool. Thanks guys!

author
rapamar made it!(author)2015-11-21

Thanks ! this is really helpful . Any recommendations for controlling multiple motors by this method? @elephlab

author
TeamJaeger made it!(author)2015-11-21

If you need them to be controlled independently you would want one of these circuits for each. Otherwise you can just connect more than one motor into the screw terminals. For example I've controlled a small 6 wheel drive rover with two of these circuits - one connected to the 3 motors on the left, the other connected to the three motors on the right.

author
yvan+den+bossche made it!(author)2015-12-01

hi, in step 2, you say: "However, this speed controller is simply fully proportional... that is
to say: you can change (modulate) the pulse from all the way off to all
the way on and the motor will go from standstill to running at full
speed. If the pulse is such that is is on half the time and off half the
time the motor will turn at 50% of its maximum speed." So the arduino gives the pulse, and you command this motor driver instructable to accellerate the motor slow until top speed by regulating the pwm signal with the arduino?

author
yvan+den+bossche made it!(author)2015-12-01

oh, i think u made an on/off switch, commanded by pwm?

author
yvan+den+bossche made it!(author)2015-12-01

great!

author
vanderaalle made it!(author)2015-10-24

I'm using it since extensively. Just for reference, it's discussed in O'Sullivan and Igoe, Physical computing
http://www.amazon.com/Physical-Computing-Sensing-Controlling-Computers/dp/159200346X

author
TeamJaeger made it!(author)2015-10-24

cool :)

author
McPeppr made it!(author)2015-10-15

Hi Folks. I think the scematics wrong. You short circuit VIN and GND by the 9V battery and will probably demage your arduino. Plus scematics and break board graphic are different.
Can anyone explain why there's a diode parallel to the motor?

author
askjerry made it!(author)2015-10-17

When you spin an electric DC motor, it becomes a generator... so when this circuit gets the motor moving at high speed, then suddenly switched off... the motor continues to spin a short time... during this time there is a feedback voltage. The reversing diode allows this voltage to have a path to ground.

Additionally... when driving a coil... either a motor or a solenoid... when power is applied, a magnetic field is created. When power is removed, this magnetic field collapses. When a magnetic field collapses, there is a reverse power spike... again, this reverse diode allows it to have a path.

author
TeamJaeger made it!(author)2015-10-15

A 9v is well within the 7-12v recommended input voltage of an arduino. In fact 6V is the absolute minimum and 20V is the absolute max ( https://www.arduino.cc/en/Main/ArduinoBoardUno ). I have actually powered arduinos this way with 2S or event 3S LiPos without problems.


In what way is the schematic different?

Full disclosure: I am by no means an electrical engineer- I just like to make things. My understanding is that the diode will prevent kickback voltage (like if the motor breaks fast) from damaging the circuit by giving it a place to go -- almost like a relief valve on a water heater.

author
lcroisez made it!(author)2015-10-16

When the voltage drops to zero, there is no torque any more. In fact, the mean torque if you integrate the torque value for a whole PWM period is equal to the torque you could get if you set an intermediate continuous voltage.
Consequently, I think you are wrong when you can say that the torque is maintained.

author
cardmarc made it!(author)2015-10-14

how about driving a linear actuator in both directions? What to do?

author
Atomic3xplosion made it!(author)2015-10-13

Great circuit and write-up. I plan on utilizing this to control my sons modified power wheels.

One thing I noticed when you described adding an LED you noted "the a 1k transistor", should be resistor.

Thanks for the write up.

author
seth+hettinga made it!(author)2015-10-13

Cool controller! One question, how did you do that code thing at step 4? I like it really much and I thought I use it but how?

author
TeamJaeger made it!(author)2015-10-13

I used codebender.cc (which is awesome btw) to write the code. Here is one way to do it: https://www.instructables.com/id/Include-your-codeb...

You could also:
1. in codebender choose "share"

2. choose the "embed" tab and copy the code

3. in the wysiwyg editor in instructables choose the </> (HTML) button to edit the source code.

4. paste in the code you copied

2015-10-13_08h06_29.png2015-10-13_08h06_52.png2015-10-13_08h07_30.png2015-10-13_08h07_49.png
author
seth+hettinga made it!(author)2015-10-13

One question how do I enter the wysiwyg editor in instructables?

author
TeamJaeger made it!(author)2015-10-13

It might be something that comes with a pro level account. Although this page: https://www.instructables.com/account/gopro does not specifically mention it... the welcome email says "...Your Pro status means
you now have enhanced abilities on the site such as rich editing..."

author
seth+hettinga made it!(author)2015-10-13

Thank you very very very much!! I could use it for me projects now. Thanks again!

author
tashen made it!(author)2015-10-12

What a brilliant little circuit.

I'll be able to use this for so much.

One thing I noticed is that there's a connection missing to the transistor in the second circuit diagram. It's in he first and the image, but not the second.

Again, what a fantastic little motor controller.

author
TeamJaeger made it!(author)2015-10-13

Thanks tashen! I've updated the second diagram - good catch!

author
TeamJaeger made it!(author)2015-10-13

I'm afraid not.

author
donaldhwong made it!(author)2015-10-13

What transistor did you use for your "stair climbing drive"? at what amperage?

Thank you.

author
TeamJaeger made it!(author)2015-10-13

I used a TIP120. I used a motor that has a stall current of 20A https://www.servocity.com/html/313_rpm_hd_precisio...

but my battery could only dish out 2A.

author
donaldhwong made it!(author)2015-10-13

Thank you for this instruction. If I needed to drive 30A continuous, do I need to change the circuit? Or just the transistor? Would you recommend a MOSFET for 30A?

Thank you very much.

author
TeamJaeger made it!(author)2015-10-13

I've thought about trying it with one of these: http://www.newark.com/international-rectifier/irfb...

or one of these: http://www.newark.com/ixys-semiconductor/ixfh120n1...

but I have not tried it yet. You'd also have to choose a resistor and diode that could handle that much power. You'd probably be exceeding what a solderless breadboard can handle at that point also :)

author
clazman made it!(author)2015-10-13

30A? Shouldn't you power that by adding a 40A SSR to the circuit?

author
gtoal made it!(author)2015-10-13

I presume you specified 7.4V as that means you can use any 2S LiPo. I like those rechargable lithiums that are in the 9V battery format such as these: http://www.amazon.com/gp/product/B0088R79RE which I find quite convenient for portable projects - in my case with the Raspberry Pi (although that requires and 5V buck converter for $3, eg http://www.aliexpress.com/snapshot/6050379977.html )

author
TeamJaeger made it!(author)2015-10-13

I've actually been using it with a 3S LiPo... I've also used it with an old 12v sealed lead acid. But any 7-12v battery should power the arduino just fine... if you want to go with more than 12v you'd want to power the arduino separately (but keep the grounds connected). The TIP120 can handle up to 60V.

author
russ_hensel made it!(author)2015-10-13

Pictorials are good, but schematics are even better, could you add one?

author
pcarew made it!(author)2015-10-13

https://www.instructables.com/file/FASR25WI4CMQF8F/

author
Atomic3xplosion made it!(author)2015-10-12

for the code :

analogWrite(pwmPin, maxSpeed);

should be:

analogWrite(pwmPin, speed);

otherwise the motor will just be spinning all the time.

author
TeamJaeger made it!(author)2015-10-13

Typo caught and corrected... thanks much Atomic3xplosion

author
billbillt made it!(author)2015-10-12

great idea...

About This Instructable

47,674views

593favorites

License:

Bio: I work at RobotZone ( the folks behind Actobotics and ServoCity.com ) in Winfield, KS. I love working on projects with my kids and seeing what ... More »
More by TeamJaeger:DeathGrip: Robot Claw GauntletLightweight Weed WhackerRC Fireworks Truck
Add instructable to: