Simple, Cheap Motor Controller

50,189

602

40

About: 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 they create.

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).

Share

    Recommendations

    • Make it Glow Contest 2018

      Make it Glow Contest 2018
    • Big and Small Contest

      Big and Small Contest
    • Toys Contest

      Toys Contest

    40 Discussions

    0
    None
    kastymizilian

    2 years ago

    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

    0
    None
    Autodesk Circuits

    3 years ago

    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
    5 replies
    0
    None
    Autodesk CircuitsTeamJaeger

    Reply 3 years ago

    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
    0
    None
    rapamar

    3 years ago

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

    3 replies
    0
    None
    TeamJaegerrapamar

    Reply 3 years ago

    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.

    0
    None
    yvan den bosscheTeamJaeger

    Reply 3 years ago

    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?

    0
    None
    vanderaalle

    3 years ago

    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

    1 reply
    0
    None
    McPeppr

    3 years ago

    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?

    2 replies
    0
    None
    askjerryMcPeppr

    Reply 3 years ago

    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.

    0
    None
    TeamJaegerMcPeppr

    Reply 3 years ago

    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.

    0
    None
    lcroisez

    3 years ago

    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.

    0
    None
    cardmarc

    3 years ago

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

    0
    None
    Atomic3xplosion

    3 years ago

    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.