Category:Stepper

From ElectroDragon
(Redirected from Category:Stepper motor)
Jump to: navigation, search

Stepper Introduction

Stepper motor.jpg Stepper motor 1.jpg

A stepper motor is an electromechanical device which converts electrical pulses into discrete mechanical movements. The shaft or spindle of a stepper motor rotates in discrete step increments when electrical command pulses are applied to it in the proper sequence. The motors rotation has several direct relationships to these applied input pulses. The sequence of the applied pulses is directly related to the direction of motor shafts rotation. The speed of the motor shafts rotation is directly related to the frequency of the input pulses and the length of rotation is directly related to the number of input pulses applied.One of the most significant advantages of a stepper motor is its ability to be accurately controlled in an open loop system. Open loop control means no feedback information about position is needed. This type of control eliminates the need for expensive sensing and feedback devices such as optical encoders. Your position is known simply by keeping track of the input step pulses.

Understand the pin defintion of stepper Motor

Stepper Motor.jpg

From the picture above we can know that the A and ~A are connected, B and ~B are connected, so let's say A and ~A are group a, B and ~B are group b.

Whether two-phase four-wire, four-phase five-wire, four-phase six-wire stepper motor. Internal structure is the same. As to whether it is four , five, or six lines, depends on whether there are comm line between A and ~A, B and ~B. If group a and b each have a com-side, then it is the six-wire stepper motor, if a and b group together common terminal, it is five lines.
Therefore, to understand how the stepper motor wiring, just need to separate group a and b by using a multimeter.

Four-wire

Four-wire without the com common pumping line, so, a and b groups are absolutely insulated, not communicating. Therefore, measured with a multimeter, not connected to a group.

Five-wire

For five lines, the a and b group common terminal are connected together. Measured with a multimeter, when the line with other lines have the all the same value, then, this line is in the public com side. For the five-wire stepper motor drives, leaving com-side not wired is possible to drive a stepper motor.

Six-wire

  • The comm line of group a and b is not connected in this case.
  • Firstly, need to separate the six line into two groups, three the lines have connection to each other should be in a group, and other three which can't connect to these three should be another group.
  • Similarly, the measured resistance with a multimeter and found a line and the other two lines stop is the same, then this line is com-side, and the other two lines belong to a group. For the six-lane four-phase stepper motor, two comm lines does not connected can also drive the stepper motor.

Connection of four phase six wires stepper

  • Connect two groups to normal signal pins, and leave two common lines NC, then in this case the stepper run as a two phase and four wires motor
  • Connect two comm lines connect to VCC, and two groups connect to normal signal pins, then the stepper run as a normal four phase, six wires motor.
  • Note: The comm line should connect to the VCC power supply pin.

Find the phase sequency

  1. Connect the comm pin to VCC
  2. Connect one of the rest wires to the GND, if the motor jumps once, then let's say it is A
  3. Let's then try the rest of the wires except comm. and A, if one the wire connects to GND and the motor move clockwise then Let's say it is B.
  4. Repeat the step 3, until you find C, D, E....
  5. Finally, you can programm your stepper in sequence AB--BC--CD--DA--AB or (AB / B~A / ~A~B / ~BA / AB)

Specification

Size: NEMA 17 is a common size used in 3D printers and smaller CNC mills.

Examples

Type Step Angle Holding Torque Nm Drive Voltage Nominate Current Shaft Phase Induction Phase Resistance Weight Length Rotor Interia
Nema 8 (20mm dia.)
Nema 11 (28mm dia.)
Nema 16 (39mm dia.)
Nema 17 (42mm dia.) 1.8 0.46 - 1.7A - 4 2.1 0.28kg 39.5mm 55 g.cm^2
Nema 23 (57mm dia.)
Nema 34 (86mm dia.) 1.8 2.4-12 24/48V 4/6A 14mm dia. 5mm Key 3.1-7.8 0.5-1 2.2-5.2kg 68-150mm 1.92-4.57 kg.cm^2

Stepper 28BJY-48

Features

  1. The rotation angle of the motor is proportional to the input pulse.
  2. The motor has full torque at standstill(if the windings are energized)
  3. Precise positioning and repeatability of movement since good stepper motors have an accuracy of – 5% of a step and this error is non cumulative from one step to the next.
  4. Excellent response to starting/stopping/reversing.
  5. Very reliable since there are no contact brushes in the motor. Therefore the life of the motor is simply dependant on the life of the bearing.
  6. The motors response to digital input pulses provides open-loop control, making the motor simpler and less costly to control.
  7. It is possible to achieve very low speed synchronous rotation with a load that is directly coupled to the shaft.
  8. A wide range of rotational speeds can be realized as the speed is proportional to the frequency of the input pulses.

Stepper motor 28BYJ-48 Parameters

  • Model : 28BYJ-48
  • Rated voltage : 5VDC
  • Number of Phase : 4
  • Speed Variation Ratio : 1/64
  • Stride Angle : 5.625° /64
  • Frequency : 100Hz
  • DC resistance : 50Ω±7%(25℃)
  • Idle In-traction Frequency : > 600Hz
  • Idle Out-traction Frequency : > 1000Hz
  • In-traction Torque >34.3mN.m(120Hz)
  • Self-positioning Torque >34.3mN.m
  • Friction torque : 600-1200 gf.cm
  • Pull in torque : 300 gf.cm
  • Insulated resistance >10MΩ(500V)
  • Insulated electricity power :600VAC/1mA/1s
  • Insulation grade :A
  • Rise in Temperature <40K(120Hz)
  • Noise <35dB(120Hz,No load,10cm)

Pin Definition

  • Red = Common Pin (This pin connecting to any other pins has 30ohm value)
  • Orange = Pin1
  • Yellow = Pin2
  • Purple = Pin3
  • Blue = Pin4


Arduino Simple Demo Dode

Direct digital write - L9110, ULN2003

Code 1

Unipolar stepper bb.jpg
int motorPin1 = 2;
int motorPin2 = 3;
int motorPin3 = 4;
int motorPin4 = 5;
int delayTime = 500;
 
void setup() {
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorPin3, OUTPUT);
  pinMode(motorPin4, OUTPUT);
}
 
 
void loop() {
direction1();
}
 
void direction1(){
// think about the clock direction here, A at 0:00, BB at 3:00, AA at 6:00; B at 9:00
A();
BB();
AA();
B();
}
 
void direction2(){
B();
AA();
BB();
A();
}
 
void A() {
  digitalWrite(motorPin1, HIGH);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delayTime);
}
 
void AA() {
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(delayTime);
}
 
void BB() {
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, HIGH);
  delay(delayTime);
}
 
void B() {
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin4, LOW);
  delay(delayTime);
}

Code 2

 int Pin0 = 10; // or use pin 8
 int Pin1 = 11; // or use pin 9
 int Pin2 = 12; // or use pin 10
 int Pin3 = 13; // or use pin 11
 int _step = 0; 
 boolean dir = true;// change the direction of the motor
 void setup() 
 { 
  pinMode(Pin0, OUTPUT);  
  pinMode(Pin1, OUTPUT);  
  pinMode(Pin2, OUTPUT);  
  pinMode(Pin3, OUTPUT);  
 } 
  void loop() 
 { 
  switch(_step){ 
    case 0: 
      digitalWrite(Pin0, LOW);  
      digitalWrite(Pin1, LOW); 
      digitalWrite(Pin2, LOW); 
      digitalWrite(Pin3, HIGH); 
    break;  
    case 1: 
      digitalWrite(Pin0, LOW);  
      digitalWrite(Pin1, LOW); 
      digitalWrite(Pin2, HIGH); 
      digitalWrite(Pin3, HIGH); 
    break;  
    case 2: 
      digitalWrite(Pin0, LOW);  
      digitalWrite(Pin1, LOW); 
      digitalWrite(Pin2, HIGH); 
      digitalWrite(Pin3, LOW); 
    break;  
    case 3: 
      digitalWrite(Pin0, LOW);  
      digitalWrite(Pin1, HIGH); 
      digitalWrite(Pin2, HIGH); 
      digitalWrite(Pin3, LOW); 
    break;  
    case 4: 
      digitalWrite(Pin0, LOW);  
      digitalWrite(Pin1, HIGH); 
      digitalWrite(Pin2, LOW); 
      digitalWrite(Pin3, LOW); 
    break;  
    case 5: 
      digitalWrite(Pin0, HIGH);  
      digitalWrite(Pin1, HIGH); 
      digitalWrite(Pin2, LOW); 
      digitalWrite(Pin3, LOW); 
    break;  
      case 6: 
      digitalWrite(Pin0, HIGH);  
      digitalWrite(Pin1, LOW); 
      digitalWrite(Pin2, LOW); 
      digitalWrite(Pin3, LOW); 
    break;  
    case 7: 
      digitalWrite(Pin0, HIGH);  
      digitalWrite(Pin1, LOW); 
      digitalWrite(Pin2, LOW); 
      digitalWrite(Pin3, HIGH); 
    break;  
    default: 
      digitalWrite(Pin0, LOW);  
      digitalWrite(Pin1, LOW); 
      digitalWrite(Pin2, LOW); 
      digitalWrite(Pin3, LOW); 
    break;  
  } 
  if(dir){ 
    _step++; 
  }else{ 
    _step--; 
  } 
  if(_step>7){ 
    _step=0; 
  } 
  if(_step<0){ 
    _step=7; 
  } 
  delay(1);  // change this delay to control the speed of your stepper, delay to 100 you can see the signal LEDs blinking.
 }

Drive Board with DIR, STEP Pin (A3967, A4988)

  • A3967
Easy-Driver Stepper Motor Driver 08.JPG

Once you have everything hooked up correctly, you can upload firmware to the Arduino. The following is some very simple example code to get you up and running. There are numerous examples online, as well as a Stepper library included with the Arduino IDE. Feel free to play around with this code, changing values to see what happens, and feel free to explore other code.

Demo code 1

int dirpin = 2;
int steppin = 3;
 
void setup() 
{
pinMode(dirpin, OUTPUT);
pinMode(steppin, OUTPUT);
}
void loop()
{
 
  int i;
 
  digitalWrite(dirpin, LOW);     // Set the direction.
  delay(100);
 
 
  for (i = 0; i<4000; i++)       // Iterate for 4000 microsteps.
  {
    digitalWrite(steppin, LOW);  // This LOW to HIGH change is what creates the
    digitalWrite(steppin, HIGH); // "Rising Edge" so the easydriver knows to when to step.
    delayMicroseconds(500);      // This delay time is close to top speed for this
  }                              // particular motor. Any faster the motor stalls.
 
  digitalWrite(dirpin, HIGH);    // Change direction.
  delay(100);
 
 
  for (i = 0; i<4000; i++)       // Iterate for 4000 microsteps
  {
    digitalWrite(steppin, LOW);  // This LOW to HIGH change is what creates the
    digitalWrite(steppin, HIGH); // "Rising Edge" so the easydriver knows to when to step.
    delayMicroseconds(500);      // This delay time is close to top speed for this
  }                              // particular motor. Any faster the motor stalls.
 
}

Demo Code 2

//simple A4988 connection
//jumper reset and sleep together
//connect  VDD to Arduino 3.3v or 5v
//connect  GND to Arduino GND (GND near VDD)
//connect  1A and 1B to stepper coil 1
//connect 2A and 2B to stepper coil 2
//connect VMOT to power source (9v battery + term)
//connect GRD to power source (9v battery - term)
 
 
int stp = 13;  //connect pin 13 to step
int dir = 12;  // connect pin 12 to dir
int a = 0;     //  gen counter
 
void setup() 
{                
  pinMode(stp, OUTPUT);
  pinMode(dir, OUTPUT);       
}
 
 
void loop() 
{
  if (a <  200)  //sweep 200 step in dir 1
   {
    a++;
    digitalWrite(stp, HIGH);   
    delay(10);               
    digitalWrite(stp, LOW);  
    delay(10);              
   }
  else 
   {
    digitalWrite(dir, HIGH);
    a++;
    digitalWrite(stp, HIGH);  
    delay(10);               
    digitalWrite(stp, LOW);  
    delay(10);
 
    if (a>400)    //sweep 200 in dir 2
     {
      a = 0;
      digitalWrite(dir, LOW);
     }
    }
}

Use accelstepper library

//This is an example of how you would control 1 stepper
 
#include <AccelStepper.h>
 
int motorSpeed = 600; //maximum steps per second (about 3rps / at 16 microsteps)
int motorAccel = 10000; //steps/second/second to accelerate
 
int motorDirPin = 2; //digital pin 2
int motorStepPin = 3; //digital pin 3
 
//set up the accelStepper intance
//the "1" tells it we are using a driver
AccelStepper stepper(1, motorStepPin, motorDirPin); 
 
 
 
void setup(){
 stepper.setMaxSpeed(motorSpeed);
 stepper.setSpeed(motorSpeed);
 stepper.setAcceleration(motorAccel);
 
 stepper.moveTo(320); //move 32000 steps (should be 10 rev)
}
 
void loop(){
 
 //if stepper is at desired location
 if (stepper.distanceToGo() == 0){
  //go the other way the same amount of steps
  //so if current position is 400 steps out, go position -400
  stepper.moveTo(-stepper.currentPosition()); 
 }
 
 
 
 //these must be called as often as possible to ensure smooth operation
 //any delay will cause jerky motion
 stepper.run();
}

Stepper library

The Arduino programming environment comes with a function library for controlling a stepper motor. To use the library, in the Arduino Editor from the top menu bar: Sketch > Import Library > Stepper. Copy the example code below into an Arduino program.

Arduino Example Code Notes :

  1. The example code assumes that the stepper is being controlled by Arduino pins 8, 9, 10 and 11, but you can use any set of four pins.
  2. The "#define STEPS 100" line defines the number of steps per rev. A 3.75 deg motor has 96 steps/rev while a 7.2 deg motor has 48 steps/rev.
  3. The "Stepper stepper(STEPS, 8, 9, 10, 11)" line is where you enter the four pins used to control the stepper.
  4. The "stepper.setSpeed(x)" command sets the motor speed to x rpm.
  5. The "stepper.step(x)" command turns the motor x steps at the speed last set in the stepper.setSpeed() command. The motor turns one direction for postive x and the reverse direction for negative x.

Wiring

Bipolar and Unipolar Stepper

  • Bipolar 4-wire Stepper

The bipolar stepper motor usually has four wires coming out of it. Unlike unipolar steppers, bipolar steppers have no common center connection. They have two independent sets of coils instead. You can distinguish them from unipolar steppers by measuring the resistance between the wires. You should find two pairs of wires with equal resistance. If you’ve got the leads of your meter connected to two wires that are not connected (i.e. not attached to the same coil), you should see infinite resistance (or no continuity).

  • Unipolar 5-wires Stepper

The simplest way of interfacing a unipolar stepper to Arduino is to use a breakout for ULN2003A transistor array chip. The ULN2003A contains seven darlington transistor drivers and is somewhat like having seven TIP120 transistors all in one package. The ULN2003A can pass up to 500 mA per channel and has an internal voltage drop of about 1V when on. It also contains internal clamp diodes to dissipate voltage spikes when driving inductive loads.To control the stepper, apply voltage to each of the coils in a specific sequence.

The sequence would go like this, the following example code will follow this sequence:

Stepper sequence.jpg


Wiring with Arduino

Here are schematics showing how to interface a unipolar stepper motor to four controller pins using a ULN2003A, and showing how to interface using four TIP120's.

Stepper schematic.jpg
  • IN1-4 to the MCU IOs
  • The pins in the white jack (from left to the right) are: Motor VCC, A, B, C, D (to the stepper motor)
  • Power switch pins: GND, VCC, VCC, Motor VCC, use jumper to choose using shared VCC or not.


Documentation

Subcategories

This category has only the following subcategory.

Pages in category "Stepper"

This category contains only the following page.