Motor Controller Mini-workshop – Applying PWM for Speed Control

Last Tuesday we had a mini workshop on controlling DC brushed motors using an Arduino.  We covered controlling the speed and direction of a DC motor (in both directions) using an H-bridge. Some important take-aways from this are:

  • The motor cannot be connected directly to the Arduino, motors typically require more current and voltage.  The ATmega328 (the chip inside the Arduino) can handle a maximum of 40mA of current.  Motors (even small ones) pull 100mA to 10′s or 100A.  If this much current was pulled from the processor it would likely blow up the output port.
  • Approximated to the first order, the speed of a motor is porportional to the voltage applied to the motor.
    • This is a very first-order approximation, the speed will change when a load is applied to the resistance drops in the drive circuitry and the motor.
  • Approximated to the first order, the load on the motor (how hard it is pushing against a load), is proportional to the current through the motor.
  • In order to change the voltage on the motor, a voltage is switched on/off quickly at a certian duty cycle (on some of the time, off the other).  This is known as PWM (pulse-width modulation)
  • On an arduino, the PWM functions are called using the functions “analogWrite”

Example code from the class is:

 void setup() {                
   // initialize the digital pin as an output.
   pinMode(3, OUTPUT);
   pinMode(5, OUTPUT);  
 }
 // the loop routine runs over and over again forever:
 void loop() {
   digitalWrite(3, LOW);   // turn the LED on (HIGH is the voltage level)
   analogWrite(5, 200);
   delay(5000);               // wait for a second
   digitalWrite(5, LOW);    // turn the LED off by making the voltage LOW
   analogWrite(3, 200);
   delay(5000);               // wait for a second
 }

PDF Presentation: Controlling_DC_Brushed_Motors_Using_Arduino

Schematic of the circuit we breadboarded: Motor_workshop_1_Schemtic

from on November 2nd, 2013Comments0 Comments


Leave a Reply


  • × 4 = 28