2019年10月30日星期三

Circuit diagram to control Nema 17 stepper motor with Arduino

Circuit Diagram
Circuit diagram to control Nema 17 motor with Arduino is given in the above image. As A4988 module has a built-in translator that means we only need to connect the Step and Direction pins to Arduino. Step pin is used for controlling the steps while the direction pin is used to control the direction. Stepper motor is powered using a 12V power source, and the A4988 module is powered via Arduino. Potentiometer is used to control the direction of the motor.

Circuit diagram to control Nema 17 stepper motor with Arduino


If you turn the potentiometer clockwise, then stepper will rotate clockwise, and if you turn potentiometer anticlockwise, then it will rotate anticlockwise. A 47 µf capacitor is used to protect the board from voltage spikes. MS1, MS2, and MS3 pins left disconnected, that means the stepper driver will operate in full-step mode.

Circuit diagram to control Nema 17 stepper motor with Arduino


Complete connections for Arduino Nema 17 A4988 given in below table.
S.NO.
A4988 Pin
Connection
1
VMOT
+ve Of Battery
2
GND
-ve of Battery
3
VDD
5V of Arduino
4
GND
GND of Arduino
5
STP
Pin 3 of Arduino
6
DIR
Pin 2 of Arduino
7
1A, 1B, 2A, 2B
Stepper Motor

Code Explanation

Complete code with working video control Nema 17 with Arduino is given at the end of this tutorial, here we are explaining the complete program to understand the working of the project.
First of all, add the stepper motor library to your Arduino IDE. You can download the stepper motor library from here.
After that define the no of steps for the NEMA 17.  As we calculated, the no. of steps per revolution for NEMA 17 is 200.
#include <Stepper.h>
#define STEPS 200

After that, specify the pins to which driver module is connected and define the motor interface type as Type1 because the motor is connected through the driver module.
Stepper stepper(STEPS, 2, 3);
#define motorInterfaceType 1

Next set the speed for stepper motor using stepper.setSpeed function. Maximum motor speed for NEMA 17 is 4688 RPM but if we run it faster than 1000 RPM torque falls of quickly.
void setup() {
    stepper.setSpeed(1000);

Now in the main loop, we will read the potentiometer value from A0 pin. In this loop, there are two functions one is potVal, and the other is Pval. If the current value, i.e., potVal is higher than the previous value, i.e., Pval than it will move ten steps in the clockwise direction and if the current value is less than previous value than it will move ten steps in the counter-clockwise direction.
potVal = map(analogRead(A0),0,1024,0,500);
  if (potVal>Pval)
      stepper.step(10);
  if (potVal<Pval)
      stepper.step(-10);

Pval = potVal;

Now connect the Arduino with your laptop and upload the code into your Arduino UNO board using Arduino IDE, select the Board and port no and then click on the upload button.
Now you can control the direction of Nema17 stepper motor using the potentiometer. The complete working of the project is shown in the video below. If you have any doubts regarding this project, post them in the comment section below.   
Code
#include <Stepper.h> 
#define STEPS 200
// Define stepper motor connections and motor interface type. Motor interface type must be set to 1 when using a driver
Stepper stepper(STEPS, 2, 3); // Pin 2 connected to DIRECTION & Pin 3 connected to STEP Pin of Driver
#define motorInterfaceType 1
int Pval = 0;
int potVal = 0;
void setup() {
  // Set the maximum speed in steps per second:
  stepper.setSpeed(1000);
}
void loop() {
 
  potVal = map(analogRead(A0),0,1024,0,500);
  if (potVal>Pval)
      stepper.step(10);
  if (potVal<Pval)
      stepper.step(-10);
Pval = potVal;

2019年10月25日星期五

Which is better for 4-Wire, 6-Wire and 8-Wire Stepping Motor

I have a stepper motor with either 4, 6, or 8 lead wires available to connect to a stepper drive. What is the difference between these wiring types, and does this affect how I connect the motor to my drive?

Solution

The basic operation of any stepper motor relies on the use of inductive coils which push or pulls the rotor through its rotation when they are energized. A pair of wire leads coming from a stepper motor will correspond to at least one of these windings and possibly more depending on the motor type. In each of the following cases a chassis ground lead is also pictured to ensure the motor is correctly grounded.
 
  • 4-Wire Stepper Motors
While many motors take advantage of 6- and 8-wire configurations, the majority of bipolar (one winding per phase) stepper motors provide four wires to connect to the motor windings. A basic 4-wire  Nema 34 - 86 x 86m stepper motor is shown in Figure 1. Connecting this motor type is very straightforward and simply requires connecting the A and A' leads to the corresponding phase outputs on your motor drive.
 
Figure 1: 4-Wire Stepper Motor
 
  • 6-Wire Stepper Motors
A 6-wire stepper motor is similar to a 4-wire configuration with the added feature of a common tap placed between either end of each phase as shown in Figure 2. Stepper motors with these center taps are often referred to as unipolar motors. This wiring configuration is best suited for applications requiring high torque at relatively low speeds. Most National Instruments stepper motor interfaces do not support 6-Wire stepper motors, although some motors do not require the center taps to be used and can be connected normally as a 4-wire motor.
 
Figure 2: 6-Wire Stepper Motor (Left) 8-Wire Stepper Motor in Parallel (Right)
 
  • 8-Wire Stepper Motors
Some motors are also offered in 8-Wire configurations allowing for multiple wiring configurations depending on whether the motor's speed or torque is more important. An 8-wire stepper motor can be connected with the windings in either series or parallel. Figure 3 shows an 8-Wire stepper motor with both windings of each phase connected in series. This configuration is very similar to the 6-wire configuration and similarly offers the most torque per amp at the expense of high speed performance.
 
Figure 3: 8-Wire Stepper Motor (Series Configuration)
 
It is also possible to connect an 8-wire stepper motor with the windings of each phase connected in parallel as shown in Figure 4. This configuration will enable better high speed operation while requiring more current to produce the rated torque. This connection type is sometimes known as parallel bipolar wiring.
 
Figure 4: 8-Wire Nema Stepper Motor (Parallel Configuration)

Although every stepper motor operates in the same basic way, it is important to understand the difference between each wiring type and when each should be used.