Kinetic Sculpture Club

NYU ITP club Kinetic Sculpture Club main website

MainPage
Schedule
Club Spirit
ITP alumni's super cool work
content
Gear
linkage design
Fusion 360 workshop
Fusion 360 and CNC
balance
flower
string control
DC Motor control
Shop Motor Accesorries
Stepper Motor control A4988
Stepper Motor control Silent TMC2209
Inventory
our work
Resources

This project is maintained by

Stepper motor

slide link

Stepper motor types from ITP physical computing site

4/6 wire steppers how to wire it to stepper driver?


A typical stepper motor would have 4 wires. Some might have 6 wires. But to use it with our drivers, we can just use 4 wires of the stepper motor.

4 wire steppers

Or it might be a 6 wire with the two center taps tied together.

6 wire stepper motor

6 wire stepper how to connect as a 4 wire stepper

See this tutorial here: connecting stepper motors with different numbers of wires

When we use a bipolar stepper driver, we can see its pin configuration has A1 A2 B1 B2. A1 A2 is for the Coil 1 of the stepper motor. B1 B2 is for the Coil 2 of the stepper motor.

The only thing matters is that you should pair them into the right group. The polarity doesn’t matter.

 

How do we know the stepper motor A1 A2 B1 B2 pins of a stepper motor?

Sometimes, the stepper motors are manufactured with different standard and the order of the wire can be totally different. For example, the stepper motor I have and the stepper motor Jason gave me looks similar, and they can use the same mount, but they are wired differently.

Jason and lulu's stepper motor is actually different! what a difficult world

So I use a multimeter! The coil A is not connected with coil B in a bipolar stepper motor. If you measure the 2 resistance of coil A1 and coil A2, it should be very small. In this case, the resistance is just 3.2 Ω.

Or we can spin the motor. (credit here)

To find the two wires from one coil, do the following with the motor disconnected:

If you feel a lot of resistance, you have found a pair of wires from the same coil. If you can still spin the shaft freely, try another pair of wires. Now connect the two coils to the pins shown in the wiring diagram above.

 


Step 1: figure out the Vref

Vref is a voltage reference that would correspond to the maxinum current that will flow to your stepper motor.

We need to use a screw driver to adjust the small screw on our board and measure the voltage from Vref to Ground.

Also, before measure, we need to connect the external power supply to the stepper motor driver. For this stepper driver, we just need to connect VCC.

Sense resistor value

Our Sense resistor value is 100(0.1) in this case. We can find it out by examine our motor driver.

Foe A4988 driver, Vref= 8 * Max current of a stepper motor * Sense resistor value.

let’s suppose we are using this stepper motor stepper motor from pololu

Max current of a stepper motor

Current rating: 600 mA per coil

Voltage rating: 3.9 V

When we look at the parameters for a stepper motor, it would says a rated voltage and current. For this stepper motor, it would drive 600 mA under 3.9V. Unlike dc motors, stepper motors can operate under higher voltage if we use stepper motor driver. Stepper motors are designed to work this way and it is safe to run the motors at up to 20 times the rated voltage. You will actually get better performance by running at a higher voltage than the rated voltage. If you hook it up to to 12V, for example, the motor while attempt to draw more current, but the stepper motor driver will not allow that to happen and use high frequency pulses to limit the average current to the desired maximum value.

Our max current is 600 mA. Note: If you want to use stepper motor in Full step mode, the max current needs to be 1.4 * Imax.

So the Vref we desired should be around 0.5V. Use a screw driver to adjust the value until we measure the Vref to be 0.5V. Clockwise for reduce Vref and Counter-clockwise to increase.

Additional Video: [Pololu stepper motor set Vref tutorial] (https://youtu.be/89BHS9hfSUk)

 

Step 2: Schematics

schematics of arduino and stepper motor and driver

MS1 MS2 MS3 Microstep Resolution
Low Low Low Full step
High Low Low Half step
Low High Low Quarter step
High High Low Eighth step
High High High Sixteenth step

 

Step 3: Code

Direction Pin

When Direction pin is high, the stepper motor would rotate clockwise. When its low, it would rotate counter-clockwise

{
    // Set the spinning direction clockwise:
    digitalWrite(dirPin, HIGH);
}

Stepper Pin

To make a step motor rotate one step, we need to create one pulse on the stepper pin.

{
    // these four lines would result in the stepper motor to rotate 1 microstep, it creates one pulse
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(1000);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(1000);
}

To make a step motor rotate one revolution, we repeat it 1600 times, which is the number of steps it needs for a full revolution.

{
    //stepper would rotate clockwise for one revolution
    digitalWrite(dirPin, HIGH);
    for (int i = 0; i < stepsPerRevolution; i++) {
        digitalWrite(stepPin, HIGH);
        delayMicroseconds(1000+i);
        digitalWrite(stepPin, LOW);
        delayMicroseconds(1000+i);
    }
}

By changing the parameters for delayMicroseconds, we can have fun by controlling stepper speed.

Example code found here code

/* Example sketch adapted by Lulu from a tutorial to control a stepper motor with TB6600 stepper motor driver https://www.makerguides.com/tb6600-stepper-motor-driver-arduino-tutorial/
// More info: https://www.makerguides.com */
// Define stepper motor connections and steps per revolution:
#define dirPin 2
#define stepPin 3
#define stepsPerRevolution 3200

const int intervalTime=1000;

void setup() {
  // Declare pins as output:
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
}
void loop() {
  // Set the spinning direction clockwise:
  digitalWrite(dirPin, HIGH);
  // Spin the stepper motor 1 revolution:
  for (int i = 0; i < 1 * stepsPerRevolution; i++) {
    // These four lines result in 1 step:
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(intervalTime);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(intervalTime);
  }
  delay(1000);
  // Set the spinning direction counterclockwise:
  digitalWrite(dirPin, LOW);
  // Spin the stepper motor 1 revolution:
  for (int i = 0; i < 1 * stepsPerRevolution; i++) {
    // These four lines result in 1 step:
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(intervalTime);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(intervalTime);
  }
  delay(1000);
}