Sunday, October 14, 2012

Stepper Motor Controller - Part 2

Continuing our saga from Part 1, We finished soldering up the controller shield with all the components. We have downloaded the library, and have connected the stepper motor. The motor has 4 wires, which we have attached to the M1/M2 connector. The wires connect top to bottom:

1. Orange
2. Yellow
3. N/C
4. Green
5. Brown

A 12v power supply connects to the motor external power connector. Make sure you do not enable the Arduino power jumper just to the right of the motor external power connector.


Video can be seen at http://youtu.be/ccX92HHZ5Vg

Discuss this project at http://tech.groups.yahoo.com/group/arduinohome/message/1888


Code:

#include <AFMotor.h>


AF_Stepper motor(48, 1);


void setup() {

  motor.setSpeed(10);  // 10 rpm   

  motor.step(100, FORWARD, SINGLE); 
  motor.release();
  delay(1000);
}

void loop() {
  motor.step(100, FORWARD, SINGLE); 
  motor.step(100, BACKWARD, SINGLE); 

  motor.step(100, FORWARD, DOUBLE); 
  motor.step(100, BACKWARD, DOUBLE);

  motor.step(100, FORWARD, INTERLEAVE); 
  motor.step(100, BACKWARD, INTERLEAVE); 

  motor.step(100, FORWARD, MICROSTEP); 
  motor.step(100, BACKWARD, MICROSTEP); 
}
 
Learn more by reading: 
Arduino Internals, by Dale Wheat 

 

Stepper Motor Controller

You don't need a fancy shield to control motors, but sometimes they are handy. This unit works with steppers, servos, and even regular dc motors.

This is stage one in our Stepper Motor Controller project. We are assembling the Motor Shield that Hacktronics sent us, then we will write the sketch to control it. This project would make a good starting point for a robot or even a cnc machine. Stay in touch for additional steps in the project.

Discuss this project at http://tech.groups.yahoo.com/group/arduinohome/message/1888

What are we reading this week? 

Practical Arduino Engineering, by Harold Timmis.