Tuesday, December 31, 2013

Introduction to Motor Control (Workshop 4) - Detailed Guide

Guide Contents

I. DC Motors
II. Servo Motors
III. Stepper Motors
IV. Demo Part 1: Assembling the Circuit
V. Demo Part 2: The Code

I. DC Motors

DC Motors come in two variants - brushed and brush-less. Most DC motors are brushed, especially small motors. They use graphite brushes, magnets, and coils of wire to create motion when a voltage is applied. Brushed motors are good when positional actuary is not important. Brush-less motors do not have graphite brushes and use sensors or a separate motor driver. They have less friction but are more complex to use. (See Workshop Guide 3 for a demo involving a DC motor.)





II. Servo Motors

Servo Motors use a small DC motor, a potentiometer, and a gear train. The gear reduction applied to the DC motor increases the output torque, making the motor easy to use. Servos specialize in high positional accuracy.





III. Stepper Motors

Stepper motors are comprised of two things - a rotor and a stator. The rotor is a permanent magnet and the stator has several arms with coils. Both components have teeth that are lined up with each other. A 'step' occurs when the rotor moves one tooth. Stepper motors can be uni-polar (one coil per arm) or bi-polar (two coils per arm, wound oppositely).


IV. Demo Part 1: Assembling the Circuit

 Wire your breadboard to your Arduino and add a push button to the board:


Wire the button to the Arduino:


Finish wiring the button. Put a resistor between the button and ground. Ignore the diode setup on the left and the capacitor on the right.



Set up the wiring for the Servo Motor:




Install the Servo Motor. Pay careful attention to how it is connected - the servo has three terminals: ground (brown), high (red), and signal (yellow). Attach these accordingly to the Arduino (signal) and the power arrangement on your board. The servo is attached backwards in the picture below:




V. Demo Part 2: The Code

Load the code into the Arduino IDE and run it:


#include <Servo.h>

Servo servo1;
int button = 0;
int pos = 0;

void setup() 
{
       servo1.attach(9);
       pinMode(6, OUTPUT);
       pinMode(11, INPUT);
}

void loop() 
{
       button = 0;
       button = digitalRead(11);
       if (button == 1) 
      {
              if (pos == 180) 
              {
                    pos = 0;
              }
              else
              {
                   pos = pos + 10;
              }
              servo1.write(pos);
              delay(300);
      }
}


Push the button and the motor should move by a small increment and continue to do this for each press until it completely resets itself back to the original position.


No comments:

Post a Comment