<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFCC" text="#3333FF">
    <div class="moz-cite-prefix">I would like to backtrack this
      discussion with a little more electronics theory than has been
      discussed thus far.<br>
      <br>
      Design considerations:<br>
      - PWM output drive from controller<br>
      - driving the motor indirectly and not from the controller pins
      themselves (load current consideration)<br>
      - motor current requirements<br>
      - back-EMF protection, and motor sparks noise generation<br>
      <br>
      <img class="aligncenter size-full wp-image-10661" title="pwm motor
        speed control using arduino"
        src="cid:part1.845491E6.9BAA49A3@gmail.com" alt="dc motor speed
        control using arduino"
srcset="http://www.circuitstoday.com/wp-content/uploads/2014/04/pwm-motor-speed-control-using-arduino.png
        519w,
http://www.circuitstoday.com/wp-content/uploads/2014/04/pwm-motor-speed-control-using-arduino-300x144.png
        300w" sizes="(max-width: 519px) 100vw, 519px" height="250"
        width="519"><br>
      <br>
      <i>{ image courtesy of a discussion of using PWM to control motor
        speed:</i><i><br>
           <a
href="http://www.circuitstoday.com/pwm-generation-and-control-using-arduino">PWM
          Control using Arduino - How to Control DC Motor and LED using
          PWM</a><br>
      </i><i>   <a
href="http://www.circuitstoday.com/pwm-generation-and-control-using-arduino"><a class="moz-txt-link-freetext" href="http://www.circuitstoday.com/pwm-generation-and-control-using-arduino">http://www.circuitstoday.com/pwm-generation-and-control-using-arduino</a></a>
        ;<br>
           PDF available at: <a
href="http://www.idc-online.com/technical_references/pdfs/electronic_engineering/PWM_Control_using_Arduino.pdf"><a class="moz-txt-link-freetext" href="http://www.idc-online.com/technical_references/pdfs/electronic_engineering/PWM_Control_using_Arduino.pdf">http://www.idc-online.com/technical_references/pdfs/electronic_engineering/PWM_Control_using_Arduino.pdf</a></a><br>
           same circuit design in Simon Monk's article on Adafruit:<br>
           <a
href="https://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors/overview">Arduino
          Lesson 13, DC motors</a><br>
           <a
href="https://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors/overview"><a class="moz-txt-link-freetext" href="https://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors/overview">https://learn.adafruit.com/adafruit-arduino-lesson-13-dc-motors/overview</a></a>
        }<br>
      </i><br>
      Looking at this image, a motor capable of being driven from a 9V
      battery is motor-speed controlled by an Arduino microcontroller
      board.  Though you mention a different controller and motor
      voltage (4.5V via AA batteries), the primary design are there:<br>
      <br>
      - a bipolar transistor to handle the motor current switching<br>
      - a current limiting resister to protect the base of the
      transistor<br>
      - a capacitor to snub the spark noise from the motor<br>
      <br>
      Note that the main design point is to switch the motor current
      directly, and not have it pass through the controller's output,
      and to protect the switch from the back "electromotive force"
      generated by the inductive motor.  Note that the back-EMF can be
      considerably higher than the supply voltage -- in this case
      upwards of tens of volts, and appears in the opposite polarity of
      the supply voltage.  The 2N2222 transistor is fairly tolerant of
      these kinds of reverse voltage and other "noise" spikes generated
      by the motor.<br>
      <br>
      If it were me, I would instead substitute a darlington
      matched-pair of transistors, such as a TIP120, and a snubbing
      diode:<br>
      <br>
      <img class="aligncenter size-full wp-image-6371"
        alt="TIP120-dcmotor" src="cid:part7.8A989D71.E4B0A3EC@gmail.com"
srcset="http://www.devacron.com/wp-content/uploads/2014/01/TIP120-dcmotor.jpg
        645w,
http://www.devacron.com/wp-content/uploads/2014/01/TIP120-dcmotor-300x232.jpg
        300w" sizes="(max-width: 645px) 100vw, 645px" height="500"
        width="645"><br>
      <br>
      <i>{ image courtesy of: <a
          href="http://www.devacron.com/arduino-tip120-control-dc-motor/">Using
          Arduino and TIP120 to control a DC motor</a></i><i><br>
           <a
          href="http://www.devacron.com/arduino-tip120-control-dc-motor/"><a class="moz-txt-link-freetext" href="http://www.devacron.com/arduino-tip120-control-dc-motor/">http://www.devacron.com/arduino-tip120-control-dc-motor/</a></a>
        }<br>
      </i><br>
      Note that in this case a diode is used to control the back-EMF.  I
      disagree with this designer where he places the diode across
      darlington, but instead I would put it across the motor leads,
      stripe toward the supply positive (green wire in this figure).<br>
      <br>
      This designer uses both:<br>
      <img src="cid:part10.2F7136AE.977B0326@gmail.com"><br>
      <br>
      <i>{ image courtesy of: </i><i><a
href="http://www.pcbway.com/project/share/Use_Arduino_with_TIP120_transistor_to_control_motors_and_high_power_devices.html">Use
          Arduino with TIP transistor to control motors and high power
          devices</a></i><i>:</i><i><br>
      </i><i>   </i><i><a
href="http://www.pcbway.com/project/share/Use_Arduino_with_TIP120_transistor_to_control_motors_and_high_power_devices.html"><a class="moz-txt-link-freetext" href="http://www.pcbway.com/project/share/Use_Arduino_with_TIP120_transistor_to_control_motors_and_high_power_devices.html">http://www.pcbway.com/project/share/Use_Arduino_with_TIP120_transistor_to_control_motors_and_high_power_devices.html</a></a></i><i>
        }</i><i><br>
      </i><br>
      If you read his description, he explains the roll of both:<br>
      <blockquote>
        <div><font color="#660000"> ENTER THE 1K RESISTOR & 1N4004
            DIODE & 1UF CAPACITOR!</font></div>
        <div><font color="#660000"> The TIP120 is a very robust item. It
            can handle lots of power (see specs) but the Arduino can't.
            So we must protect the Arduino from potential party
            crashers. For starters, we use a 1K Ohm resistor between the
            Arduino pins and the TIP120 Base pin. This is insurance
            against electric shorts. The TIP120 can handle 60V and 5A
            but I assure you the Arduino won't.</font></div>
        <div><font color="#660000">  </font></div>
        <div><font color="#660000"> Then we have those DC motors. The
            internal brushes on toy/hobby DC motors generate lots of
            potentially harmful sparks and stray electricity that needs
            to be blocked. Instead of guessing which motor is safe and
            which is not, we simply add a $0.20 diode and $0.10 1uF
            ceramic capacitor to our circuit. Some electromechanical
            devices such as solenoids may require different capacitors.</font></div>
        <div><font color="#660000">  </font></div>
        <div><font color="#660000"> Placing the ceramic capacitor on the
            + & - poles of the motor will act as suppressor of
            sparks and surges generated by motor brushes, which can be
            harmful to your circuit.</font></div>
        <div><font color="#660000">  </font></div>
        <div><font color="#660000"> A small ceramic capacitor in the
            range of .01 to 0.1 uF is probably sufficient to offer
            protection from hobby DC motors. But If you are using
            brushless motors, such as the PC fan I am using in this
            tutorial, don't use a capacitor.</font></div>
        <div><font color="#660000">  </font></div>
        <div><font color="#660000"> As for the 1N4004 diode, it allows
            current to pass in one direction from positive to negative
            but will block any stray current that tries to go in the
            opposite direction, which might have undesirable effects on
            your circuit.</font></div>
        <div><font color="#660000">  </font></div>
        <div><font color="#660000"> Unlike resistors which allow current
            to flow in both directions, diodes were designed to let
            current pass from positive into negative, not the other way
            around. When you look closely at those small diodes we use
            in our projects, you will see a ring on one end of the diode
            cylinder. This tough guy can block high voltage (400V) with
            high current (1A). Again, no need to understand all this
            stuff so long as you connect the circuit properly.</font></div>
      </blockquote>
      Here is my preferred hookup, and one I use in a lot of control
      circuits:<br>
      <img src="cid:part13.DA823E1E.A1A1ED0F@gmail.com" alt="Motor
        driven by TIP122"><br>
      <br>
      And this is published in Arduino.CC's own website:<br>
      <img src="cid:part14.26745B6F.1806F9AD@gmail.com" alt="" title=""><br>
      <br>
      <img src="cid:part15.23E4052B.59E74C47@gmail.com" alt="" title=""
        height="300px"><br>
      <br>
      <i>{ source: </i><i><a
          href="https://www.arduino.cc/en/Tutorial/TransistorMotorControl">Arduino:
          Transistor Motor Control</a></i><i><br>
      </i><i>   </i><i><a
          href="https://www.arduino.cc/en/Tutorial/TransistorMotorControl"><a class="moz-txt-link-freetext" href="https://www.arduino.cc/en/Tutorial/TransistorMotorControl">https://www.arduino.cc/en/Tutorial/TransistorMotorControl</a></a></i><i>
        }</i><i><br>
      </i><br>
      The takeaway from all this is:<br>
      <ul>
        <li>Wire the Arduino PWM pin to the Base of the TIP120 through a
          1kOhm, or at least 270 Ohm, resistor in series. </li>
        <li>Wire the TIP120 Emitter to Ground of the Arduino.</li>
        <li>Wire one lead of the motor to the positive side of your
          battery pack, the other lead to the Collector of the TIP120</li>
        <li>Put a diode across the leads of the motor, perhaps a 1N4007,
          wired <strong>reverse biased</strong> (cathode towards
          battery positive in previous point).</li>
        <li>Add a disk capacitor of say 0.10 uF 12 Volts in parallel
          with the diode, connected with its negative lead (usually
          marked) towards the Collector of the TIP120</li>
        <li>Wire the negative of the battery pack to the Arduino ground.</li>
      </ul>
      A couple more references:<br>
      <ul>
        <li><a
href="http://luckylarry.co.uk/arduino-projects/arduino-control-a-dc-motor-with-potentiometer-and-multiple-power-supplies/">Arduino
            - Control a DC motor with TIP 120, potentiometer and
            multiple power supplies</a><br>
          <a
href="http://luckylarry.co.uk/arduino-projects/arduino-control-a-dc-motor-with-potentiometer-and-multiple-power-supplies/"><a class="moz-txt-link-freetext" href="http://luckylarry.co.uk/arduino-projects/arduino-control-a-dc-motor-with-potentiometer-and-multiple-power-supplies/">http://luckylarry.co.uk/arduino-projects/arduino-control-a-dc-motor-with-potentiometer-and-multiple-power-supplies/</a></a></li>
        <li><a
href="http://duino4projects.com/arduino-control-dc-motor-tip120-potentiometer-multiple-power-supplies/">Arduino
            - Control a DC motor with TIP 120, potentiometer and
            multiple power supplies</a><br>
          <a
href="http://duino4projects.com/arduino-control-dc-motor-tip120-potentiometer-multiple-power-supplies/"><a class="moz-txt-link-freetext" href="http://duino4projects.com/arduino-control-dc-motor-tip120-potentiometer-multiple-power-supplies/">http://duino4projects.com/arduino-control-dc-motor-tip120-potentiometer-multiple-power-supplies/</a></a><br>
        </li>
      </ul>
      - sgh<br>
      <br>
      On 01/07/2017 09:37 PM, Craig Cook via TriEmbed wrote:<br>
    </div>
    <blockquote
      cite="mid:1940118862.424594.1483843059060@mail.yahoo.com"
      type="cite">
      <div style="color:#000; background-color:#fff;
        font-family:HelveticaNeue-Light, Helvetica Neue Light, Helvetica
        Neue, Helvetica, Arial, Lucida Grande,
        sans-serif;font-size:16px">
        <div id="yui_3_16_0_ym19_1_1483239526576_552932">At my cub pack
          we have a "Dad's race" the night before the boys race.  Dads
          don't have to comply to the same rules the boys do.  i.e. if
          we can get a motor on the car and it weighs more than 5oz,
          thats fine.  Purely for engineering fun.</div>
        <div id="yui_3_16_0_ym19_1_1483239526576_553058"><br>
        </div>
        <div dir="ltr" id="yui_3_16_0_ym19_1_1483239526576_553056">I
          have a donor RC dump truck I am going to take the motor and
          axel out of.  I have a NTC CHIP I was going to strap on to
          control the motor.</div>
        <div dir="ltr" id="yui_3_16_0_ym19_1_1483239526576_553063"><br>
        </div>
        <div dir="ltr" id="yui_3_16_0_ym19_1_1483239526576_553126">I've
          got the kernel upgraded to 4.4 and PWM working.</div>
        <div dir="ltr" id="yui_3_16_0_ym19_1_1483239526576_553132"><br>
        </div>
        <div dir="ltr" id="yui_3_16_0_ym19_1_1483239526576_553134">Am I
          correct in thinking if I can hook up the motor to the CHIP
          board I could use PWM to "slow" it down? i.e. if I let the
          motor spin at full speed the derby car wheels may just sit and
          spin.  If I can send the right amount of pulses I should be
          able to control the motor speed.<br>
        </div>
        <div dir="ltr" id="yui_3_16_0_ym19_1_1483239526576_553168"><br>
        </div>
        <div dir="ltr" id="yui_3_16_0_ym19_1_1483239526576_553170">The
          dump truck was powered by 3 x AA batteries, which makes me
          believe the motor accepts 5V or less, so using the CHIP should
          not fry it.  The motor has a 1 ohm resistor attached and a
          capacitor with 104 written on it.</div>
        <div dir="ltr" id="yui_3_16_0_ym19_1_1483239526576_553295"><br>
        </div>
        <div dir="ltr" id="yui_3_16_0_ym19_1_1483239526576_553305">I'm
          ready to attach the motor to the CHIP, any reason I shouldn't
          and see what happens?<br>
        </div>
        <div dir="ltr" id="yui_3_16_0_ym19_1_1483239526576_553230"><br>
        </div>
        <div dir="ltr" id="yui_3_16_0_ym19_1_1483239526576_553229">Thanks</div>
        <div dir="ltr" id="yui_3_16_0_ym19_1_1483239526576_553238"><br>
        </div>
        <div dir="ltr" id="yui_3_16_0_ym19_1_1483239526576_553239">Craig<br>
        </div>
      </div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="80">-- 
Scott G. Hall
Raleigh, NC, USA
<a class="moz-txt-link-abbreviated" href="mailto:ScottGHall1@GMail.Com">ScottGHall1@GMail.Com</a></pre>
  </body>
</html>