Introduction: Arduino Stepper Drivers Tutorial-1/2

Picture of Arduino Stepper Drivers Tutorial-1/2

Stepper motors are truly interesting, some might say amazing, and they are certainly useful. They appear in many, if not most, precision electronic machines such as 3D printers, flatbed image scanners, plotters, engravers, robotic vacuums, robotic lawn mowers, and other robots, automobile speedometers, disk drives, CNC equipment, camera focusing mechanisms, laser and plasma cutters, etc.

Steppers can go to a specific angular position and stay there with a holding torque (see discussion of holding torque in my previous tutorial, https://www.instructables.com/id/DC-Motors-Tutorial...)

Assuming current to the stepper still flows. Stepper speed is easy to control in Arduino sketches, as will be seen in this tutorial.

A stepper motor's resolution depends on the size of its basic step, i.e., its pole count. Not only is greater accuracy possible with more poles, but with a higher pole count motor vibration/shake is also reduced, as each step is shorter. For most Maker projects high resolution is not needed, so, cost savings are possible with the appropriate stepper selection.

Steppers can offer a significant amount of torque, particularly if geared. However, there is a torque/speed trade-off (see below when the 28BYJ-48, a small geared stepper, is discussed). Unlike servos, steppers can rotate continuously through a full 360 degrees, i.e., 2 pi radians. Most servos are restricted to 180 degrees, pi radians, of rotation, although that need not be the case. If you are not familiar with stepper motors (also called stepping motors, step motors, or simply steppers) you may want to read Part 3 of my tutorial on D.C. Motors. It can be found at,

https://www.instructables.com/id/DC-Motors-Tutorial...

It is titled, DC Motors, Tutorial-3/3: Steppers.

Care must be taken if you are using steppers with an Arduino. Steppers normally should not be driven directly from an Arduino, as this is likely to result in damage. In fact, an excellent habit to develop is to run all steppers from a separate power supply rather than an Arduino, even if the Arduino can provide enough power for the stepper you have. Although, this is quite unlikely. Rather, there should be a stepper driver module between the Arduino and the stepper motor. This first Part of the tutorial covers three of the more popular stepper driver modules for the Arduino. Additional popular stepper drivers are covered in the second Part.

I generally use bipolar steppers, where possible, to maximize torque. Both unipolar and bipolar stepping motors are commonly found. With bipolar steppers it is necessary to reverse the current flow, or order of coil activation, to reverse the direction of stepper rotation. With a bipolar stepper a coil’s full length can be used, so that the torque is typically higher. In a unipolar stepper, center taps are used, so coils are only half the length when compared to the same stepper coil used in a bipolar mode.

It is easy to leave the common wire(s), on e.g., a six wire unipolar stepper, unconnected to obtain a bipolar stepper, as can be seen in some of the examples below. As already noted, a bipolar stepper allows us to use a coil’s full length to obtain more torque, although at the cost of some operational complexity. The stepper driver modules discussed in the examples below make using steppers fairly easy.

In a bipolar stepper there are two wires per coil, i.e., two wires per phase. There are multiphase steppers that typically turn more smoothly, but they are more costly. My personal experience matches those of many others, in that for the vast majority of Maker applications multiphase steppers are not needed, and in some cases may not even work as expected.

This tutorial presents stepper driver modules that can be, and often are, used with Arduinos, and are used with Arduino UNOs here. The stepper driver used is important. The same motor running with different drivers may have a different torque-speed curves. However, for a given voltage and current the same stepper will perform in the same way. For example, if current is increased by 25%, it is likely torque also will see a 25% increase, assuming we do not exceed the motor's specified current by more than 200%.

Many stepper drivers and steppers have built-in thermal overload protection that will turn the motor off if it gets too hot, until it cools. If you hear sounds, that do not seem normal for your stepper, they may indicate that the stepper is switching to thermal overload mode. If so, it may be prudent to reduce the current sent to the coils. Less current than the motor was designed for will result in torque reduction, compared to using greater current, but it will not damage the stepper. It is never a good idea to send more current to a stepper than it was designed to handle. Reduced current can be achieved using lower voltage, and/or a resistor.

In some examples in this tutorial, and in general, I use steppers made by Japanese or American companies. Some steppers are quite inexpensive, but unfortunately inexpensive steppers generally do not hold up well. The price for steppers is really an example of “you get what you pay for”. Many steppers use bushings or inexpensive bearing instead of high-quality ball bearings.

With steppers, and other motors, the closer the rotor is to the stator the higher the torque, as the inverse square law applies. That is, if we half the distance we quadruple the strength. So, a small air gap between rotor and stator is desirable. With inexpensive steppers when the bushings or less expensive bearings wear, the rotor that is separated from the stator by a relatively small air gap starts to brush against the stator, this causes the stepper to malfunction. In the more severe cases, these brush against the stator so strongly that coils are abraded and destroyed.

For less important applications inexpensive, no-name, steppers may suffice, but for critical uses name brand steppers made by Japanese or American companies are often better choices. Special caution should be used if purchasing unbranded Chinese stepper motors. Remember, as said earlier, with steppers, it is usually true that “you get what you pay for”.

As previously noted for a stepper it is the current through its coils that typically determines torque. Current through a coil is dependent on the resistance (R) of the coil, and the coil’s inductance (L).

In Part 3 of the tutorial referenced above, it was noted that steppers usually are driven by one of four methods:

1. Wave Drive

2. Full Step

3. Half Step

4. Microstepping

As discussed in that tutorial the wave drive method is used less frequently. In the remainder of this tutorial the half step method is used in sketches, where we alternate between using one phase (coil) at a time and two phases (coils). This will be easy to see in the examples of this method used below. Using the half step method, the resolution of a stepper is doubled, but this method results in less torque at some positions, i.e., the wave drive locations where only a single coil is activated.

In the project that follows, and the ones following that, LCDs are used to display rotation direction, degrees, and relative RPMs. By keeping essentially the same Sketch, with modifications as needed, it is easier to see how the driver boards discussed here can be used.

When a stepper motor steps it does not immediately move to the next step position and stop. Rather, it overshoots that position, adjusts backwards and overshoots that position, etc. This undesired back and forth repetitive effort to find the correct position is called "ringing", and "ringing" depends on, among other parameters, the stepper's load and basic step angle. If the step angle is small and/or the load is relatively high (a one to one ratio between the inertia of the rotor and the load is possibly ideal for several reasons), the "ringing" that occurs will be reduced in magnitude. As "ringing" is not cumulative, a stepper should be selected based on the speed and accuracy needed, and the load it will encounter. Remember greater accuracy, speed, and torque will raise the price of a stepper. If increased torque is needed, this requirement may increase the size of the stepper needed as well.

Stepper speed is easy to control in sketches, as speed for a stepper can be controlled by timing activation pulses to the coils. In the examples that follow, speed is controlled by having a delay between each step, thereby delaying the activation of the succeeding pulse. In the last example, using the L9110S, this delay is changed to three different values to show how RPM can be controlled by your sketch.

Before leaving this Introduction, let me mention some general guidelines (more information about some of these guidelines is discussed in separate locations in this tutorial, but it was felt appropriate to bring them together here):

1. A stepper should not be disconnected from a stepper motor driver while the driver has current flowing to it, as this may damage the driver module.

2. A separate power supply should be used for a stepper. It should not be driven directly from an Arduino.

3. Do not handle a stepper's case while it is running, or shortly after. Steppers are designed to run hot, some exceeding 175-degrees fahrenheit, and can cause burns if handled inappropriately.

4. In choosing a stepper, select the least costly one that meets your torque requirements, and can move the stepper to the position needed in the time required. "Overspecification" can result in increased cost.

5. It is easy to convert a five-wire or a six-wire unipolar stepper to a four wire bipolar stepper driver, by not using the center taps, whether these taps are separate or joined. Most stepper drivers will work with four wire bipolar steppers, although many stepper driver modules will also work directly with 5-lead, 6-lead, or 8-lead steppers.

Step 1: A ULN2003 Driver, Version 1, With a 28BYJ-48 Stepper

Picture of A ULN2003 Driver, Version 1, With a 28BYJ-48 Stepper

The 28BYJ-48 stepper (Part 3 of my tutorial on DC Motors shows this stepper disassembled), and the ULN2003 driver module work well together to produce a frequently used combination of stepper driver and stepper. For this reason, the ubiquitous ULN2003 is the first driver module covered in this tutorial.

We will cover two versions of this module. One in this Step and Part 1 of this tutorial, and another in the subsequent tutorial Part. There are more than two versions of a ULN2003 module. However, a discussion of the two versions presented in this tutorial should allow you to use any ULN2003 driver module you have, as all modules are similar. ULN2003 modules are named after their on-board ULN2003 IC. (See photographs for a picture of this IC.)

Just as the ULN2003 module designation does not represent one stepper driver, the 28BYJ-48 stepper motor designation does not represent just one stepper, although the designation might suggest otherwise. Rather, there are a variety of steppers that are designated 28BYJ-48. The one used here was designed for 5 volts and has a basic step of approximately 1/2,048th of 360 degrees (owing to its reduction gear ratio the exact value appears to have a fractional part).

The ULN2003 driver module used here has a plug to accept the connector from the 28BYJ-48 stepper (see photographs). The 4 phase, 5 wire 28BYJ-48 stepper, with shared common wires, is driven by our first version of the ULN2003 module. Here the stepper is not used as a 4-wire bipolar stepper, although that is the mode I most frequently use with stepper motors, but as a four (4) coil unipolar stepper.

Although I usually follow a policy of using steppers made by Japanese or American companies, the 28BYJ-48 stepping motor used here was made in China. These steppers are very inexpensive to obtain. They have plastic reduction gears, so they can provide high torque relative to size. However, this higher torque comes at the cost of slower speed. (See the movie attached to the sketch below.)

If the torque provided by the 28BYJ-48 stepper used here is opposed by a heavy load, so that the reduction gears cannot turn, i.e., the torque applied to the stepper equals or exceeds the stepper’s stalling torque, the gears will likely be stripped. As configured, the 28BYJ-48 version used here produced somewhat more than 4 oz-in of torque.

For many applications using an Arduino, these stepper motors work well. For example, they can often be used when building robots, analog clocks, panoramic camera platforms, and for less expensive laboratory equipment, etc. However, the load on these steppers cannot be too great. For critical uses with heavier loads, other steppers should certainly be considered.

The connections used in the example here are as follows:

Stepper Motor to Driver Module

1. Insert female plug from 28BYJ-48 stepper into male connector on the ULN2003 driver module.

Driver Module (see attached photos to see how this was implemented for this example)

2. Connect IN1 (driver module) ---------- Digital socket 2 on the UNO

3. Connect IN2 (driver module) ---------- Digital socket 3 on the UNO

4. Connect IN3 (driver module) ---------- Digital socket 4 on the UNO

5. Connect IN4 (driver module) ---------- Digital socket 5 on the UNO

6. Provide 5 volts power from a wall adapter to pins marked 5-12v on the ULN2003 driver module.

LCD Module (see attached photo for one example of how this looks when implemented)

7. VSS (LCD) ---------- GND

8. VDD (LCD) ---------- 5volts

9. VO (LCD) ------------ Center tap, 10k potentiometer

10. RS (LCD) ---------- Digital socket 13 on the UNO

11. RW (LCD) --------- GND

12. E (LCD) ------------ Digital socket 12 on the UNO

13. D4 (LCD) ---------- Digital socket 11 on the UNO

14. D5 (LCD) ---------- Digital socket 10 on the UNO

15. D6 (LCD) ---------- Digital socket 9 on the UNO

16. D7 (LCD) ---------- Digital socket 8 on the UNO

17. A (LCD) ------------ 5volts

18. K (LCD) ------------ GND

LCD pins D0 through D3 are unconnected, as are module locations IN5, IN6, and IN7. I provided power for the potentiometer at both its ends using 5 volts and ground inputs. Note, the center tap of the potentiometer goes to VO on the LCD. The 10K potentiometer is used to control the LCD’s contrast. I used a breadboard and connected the 5v and ground connectors on the UNO to the breadboard’s power rails. I then used these rails to connect to the LCD.

Again, and it is worth repeating, it is not a good idea to power a stepper directly from a UNO. So, when using steppers always use a wall adapter to power the stepper driver module, or another external power source, to be certain that the Arduino will not be damaged.

Step 2: Sketch Using One Version of the ULN2003 Driver Module

In the sketch that follows an LCD is used to display rotation direction (i.e., clockwise or anti-clockwise), angular rotation (where a minus sign is used to show angles during counterclockwise rotation), and approximate, integer RPM.

RPM is calculated here by counting the number of turns and displayed as an integer after the stepper has made 10 turns, to reduce transients and other start-up factors. Thus, we must wait for the stepper to complete ten full rotations. The RPM calculated is only approximate. The calculation does not properly account for any fractional portion of turns made in a minute, etc.

The RPMs shown on the LCDs in this tutorial are primarily to compare relative results for the steppers driven by the driver modules discussed. In that role, the RPM calculated is a useful, although only approximate, measure. Here the RPM value, even though calculated roughly, shows that the 28BYJ-48 geared stepper is primarily useful in low speed application (The first video in Step 7 shows a stepper capable of a much higher rotational speed.).

Fortunately, a more accurate RPM value can be calculated using, e.g., a RTC (real time clock, such as the one used in my Instructable, Day of The Week, Calendar, Time, Humidity & Temperature w Battery Saver), and calculating RPM as a decimal number, etc. However, the use of a RTC would add to the complexity of the sketches and examples presented in this tutorial, and possibly obscure the main points here.

Readers, after completion of this tutorial, may want to add a RTC to their project, if they are working with a stepper, and calculate a more accurate value for RPM if needed.

To see details of the sketch presented here exactly as it was written with the whitespace used, please download the attached text file.

----------Sketch----------

// Sketch by R. Jordan Kreindler, written October 2016, to rotate

// a stepper motor using the Half Step Method and reverse direction

// after approximately a full revolution. An LCD is used to show

// rotation direction, angle(s) turned, and RPM.

float RPM;

unsigned long time;

int rotationsAveraged = 5; // Rotations to be averaged

// time first two rotation ignored

#include

// LiquidCrystal (RS, E, d4, d5, d6, d7)

LiquidCrystal lcd(13, 12, 11, 10, 9, 8); // For standalone, non-shield, LCD

// Pin assignments

int aPin = 2; //IN1: coil a one end

int bPin = 3; //IN2: coil b one end

int aPrimePin = 4; //IN3: coil aPrime other end of coil a

int bPrimePin = 5; //IN4: coil bPrime other end of coil b

// We do not connect IN5, IN6, or IN7

int degrees = 0;

int delay1 = 2; // The delay between each step in milliseconds

int delay2 = 200; // The delay after each full revolution, in milliseconds

int count = 0; // The number of steps

int numberOfRotations = 1; // The number of times the rotor has

// turned 360 degrees

void setup() {

Serial.begin(9600);

// Set all pins as output to send output signals from the Arduino

// UNO to the coil windings of the stator

lcd.begin(16, 2); // Sets the size of the LCD in characters and lines

lcd.clear(); // Clear the LCD screen of characters and symbols

pinMode(aPin, OUTPUT);

pinMode(bPin, OUTPUT);

pinMode(aPrimePin, OUTPUT);

pinMode(bPrimePin, OUTPUT);

lcd.setCursor(0, 0);

lcd.print(" Clockwise");

// Start with all coils off

digitalWrite(aPin, LOW);

digitalWrite(bPin, LOW);

digitalWrite(aPrimePin, LOW);

digitalWrite(bPrimePin, LOW);

}

void loop() {

// Send current to

// 1. The aPin

// 2. The aPin, and the bPin

// 3. The bPin

// 4. Then to the bPin and the aPrimePin

// 5. Then to the aPrimePin

// 6. Then to the aPrimePin and the bPrime Pin

// 7. Then to the bPrimePin

// 8. Then the bPrimePin and the aPin.

// Thus producing steps using the half step method

//Reversive direction after each turn

if ((numberOfRotations) % 2 == 0) { // Check if number of rotations is even

// if so reverse direction

aPin = 5;

bPin = 4;

aPrimePin = 3;

bPrimePin = 2;

}

else { // If number of rotations is an odd number

aPin = 2;

bPin = 3;

aPrimePin = 4;

bPrimePin = 5;

}

// 1. Set the aPin High

digitalWrite(aPin, HIGH);

digitalWrite(bPin, LOW);

digitalWrite(aPrimePin, LOW);

digitalWrite(bPrimePin, LOW);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

// 2. Energize aPin and bPin to HIGH

digitalWrite(aPin, HIGH);

digitalWrite(bPin, HIGH);

digitalWrite(aPrimePin, LOW);

digitalWrite(bPrimePin, LOW);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

// 3. Set the bPin to High

digitalWrite(aPin, LOW);

digitalWrite(bPin, HIGH);

digitalWrite(aPrimePin, LOW);

digitalWrite(bPrimePin, LOW);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

// 4. Set the bPin and the aPrimePin to HIGH

digitalWrite(aPin, LOW);

digitalWrite(bPin, HIGH);

digitalWrite(aPrimePin, HIGH);

digitalWrite(bPrimePin, LOW);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

// 5. Set the aPrime Pin to high

digitalWrite(aPin, LOW);

digitalWrite(bPin, LOW);

digitalWrite(aPrimePin, HIGH);

digitalWrite(bPrimePin, LOW);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

// 6. Set the aPrimePin and the bPrime Pin to HIGH

digitalWrite(aPin, LOW);

digitalWrite(bPin, LOW);

digitalWrite(aPrimePin, HIGH);

digitalWrite(bPrimePin, HIGH);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

// 7. Set the bPrimePin to HIGH

digitalWrite(aPin, LOW);

digitalWrite(bPin, LOW);

digitalWrite(aPrimePin, LOW);

digitalWrite(bPrimePin, HIGH);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

// 8. Set the bPrimePin and the aPin to HIGH

digitalWrite(aPin, HIGH);

digitalWrite(bPin, LOW);

digitalWrite(aPrimePin, LOW);

digitalWrite(bPrimePin, HIGH);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

count = count + 8;

degrees = (360.0 * (count / 4096.0));

if ((numberOfRotations % 2) == 1) { // Check if number of rotations is even

lcd.setCursor(0, 0); // Move the cursor to 1th position on 1st line

lcd.print(" Clockwise ");

lcd.setCursor(0, 1); // Move the cursor to 1th position on 2nd line

lcd.print(" "); // Print a space

lcd.print(degrees); // Print angular position in degrees

lcd.print((char)223); // Print degree symbol

lcd.print(" "); // Print a space

}

else { // If numberOfRotations is odd number

lcd.setCursor(0, 0); // Move the cursor to 1th position on 1st line

lcd.print(" Anti-Clockwise ");

degrees = 360 - degrees;

lcd.setCursor(0, 1); // Move the cursor to 1th position on 2nd line

lcd.print(" -"); // Print a minus sign

lcd.print(degrees); // Print angular position in degrees

lcd.print((char)223); // Print degree symbol

lcd.print(" "); // Print a space

}

if (count == 4096) { // A full revolution of the stepper

numberOfRotations = ++numberOfRotations;

time = millis();

RPM = time / numberOfRotations; // Average time of a rotation

RPM = (60000.00 / RPM); // Number of rotations per minute

if (numberOfRotations >= 10) {

lcd.setCursor(7, 1);

lcd.print("RPM:");

lcd.print(round(RPM)); //Print RPM as integer

lcd.print(" ");

}

delay(delay2); // delay2/1000 second(s) after each full rotation

count = 0; // Reset step counter to zero

}

}

Step 3: Working With Steppers Whose Coils and Lead Assignments Are Initially Unknown

Picture of Working With Steppers Whose Coils and Lead Assignments Are Initially Unknown

In Part 3 of my tutorial on DC Motors I discussed how to use an unknown stepper. That is, a stepper where the number of coils are not known nor are the leads connected to these coils. As we need this information to connect a stepper to a stepper motor driver module, some of the information from Part 3 of that DC motors tutorial is presented here.

A second stepper, whose coil configuration was also unavailable, is used here as well. Its coils and associated leads are identified using a partially filled-in resistance matrix. That second, and somewhat larger and heavier stepper will be connected to a L298N driver module in a subsequent Step.

Working with two unknown steppers helps clarify how we can work with steppers for which we have no data sheets, and how we can obtain the information we need to appropriately connect them to stepper motor drivers.

With a typical stepper we do not have an absolute zero position, so we set the starting position as the location where the stepper is when we begin coil activations. We then calculate the stepper angle turned by counting the number of steps from that position. This provides accurate information on the angle the stepper has turned.

If you have a stepper that you do not have a data sheet for, you need to determine the number of coils present and identify the leads to those coils. This is relatively easy to do, and can be done in a variety of ways. For example, by holding lead pairs together manually and checking how difficult it is to turn the stepper, connecting an LED and turning the stepper to see which lead pairs light the LEDs, and what their relative brightness is, etc.

Here a multimeter set to the resistance scale was used. This method is, in this author's opinion, the most appropriate way to work with steppers for which a data sheet is not available. Here, resistance measurements were taken of all lead pairs, and a matrix prepared (see attached photographs).

For a stepper for which a datasheet is not available, working voltage may also be unknown and not stated on a paper or metal label associated with the stepper. Although this is unusual, we can use a variable power supply connected to a stepper driver module to find a voltage that works and moves the stepper.

Even if the voltage is printed on the stepper, that can be "taken with a grain of salt", as most stepper drivers will work at a variety of voltages. The printed voltage simply tells us that if we connected a DC voltage source, of the value printed on the label, directly to a stepper coil, we can be assured that we would be staying within the stepper's acceptable current range. Fortunately, the stepper driver controls the current provided, so as long as the voltage provided to the driver does not exceed a value the driver can handle we can use the voltage we have available.

It is generally a good thing if the stated voltage appearing on a stepper's label is low, This indicates that the coils have a relatively low impedance and will likely deliver more torque than another stepper of the same configuration but requiring a higher voltage. It does not mean the stepper must be run at that low voltage if a stepper driver is used.

Fortunately, a stepper's voltage rating is not typically something we need be concerned with, as most stepper drivers can work, as noted above, with a variety of voltages. A stepper motor driver module controls the current flowing into the stepper, and generally will limit the current to acceptable values. So, if we use a stepper driver our main concern with voltage is that its value does not exceed that which can be handled by the stepper driver module.

Voltage tolerance is typically built into the design of many stepper motor drivers, and these drivers can often be used to activate stepper coils with voltages as high as 20 times the nominal voltage ratings.

Remember that stepper motors, unlike continuous DC motors, require current even when not moving. Steppers typically get quite hot, as they are always on. Stepper heat is not a major concern for motor life, as most stepper's are designed to run hot. It is, however, a safety concern for anyone handling a hot stepper, and for other components in close proximity to a heated stepper. It is possible to burn yourself if you attempt to handle some steppers while they are still running or shortly after. Touching some working steppers can feel almost like touching the eye of a working stove, not quite as bad but unfortunately much too similar, so caution is required.

I have a number of steppers for which data sheets are not readily available. One of them, a NEMA 17 with mounted heat sink, is used here for an example (NEMA is a named for the National Electrical Manufacturers Association, a US organization). A NEMA 17 stepper is a size typical for steppers found in 3D printers, e.g., RepRap 3D printers. The NEMA 17 presented here, is an example of a stepper without an available data sheet. The same stepper was used in Part 3 of my DC Motors tutorial.

The NEMA 17 designation used here, refers to this square stepper's size. Specifically, a NEMA 17 stepper has a face plate that is approximately 1.7 x 1.7 inches, if square. While a square NEMA 24 stepper, is approximately 2.4 x 2.4 inches, and a round NEMA 34 stepper has an approximately 3.4 inch diameter. These designations, i.e., NEMA 17, 24, 34, etc are also know as NEMA frame sizes.

For square steppers, a side's length is used instead of the stepper's diameter. These values can be accompanied by other characters that tell us a bit more about a stepper's physical characteristics, e.g., the stepper's maximum safe operating temperature. Typically NEMA steppers range from the small NEMA 8 to the large NEMA 42, from approximately 4 oz-in (2.8 N-cm) to over 5,000 oz-in (3,530.8 N-cm) of nominal holding torque.

The resistance values between lead pairs for the NEMA 17 can be seen in the attached photographs. Note that this matrix is symmetrical around the diagonal going from the upper left to the lower right. Thus, only part of this matrix, e.g., the portion above the diagonal, is needed.

After taking resistance measurements, we are able to identify the number of coils, and the lead colors associated with these coils. From the matrix we can see there are two coils here. One we can call coil1 or A-A’ (Yellow-Blue) with common tap Red, and the other coil2, or B-B’ (White-Orange) with common tap Black.

As can be seen, the greatest resistances were found between the Yellow-Blue and White-Orange pairs - we ignored opens, which occurs when leads are connected to different coils. It was the resistances we measured that allowed us to identify the two coils present.

The wire pairs with the greatest resistance are connected to the coils. The leads having a coil's end colors, and with somewhat less resistance, is the center tap.

This is the information we need to connect a stepper without data sheet, to a stepper driver module.

In the first example, the resistances found and the number of stepper wires identify this as a Unipolar stepper with two center taps. For these 6-wire steppers we can ignore the center taps to obtain a 4-lead, two phase, Bipolar stepper.

The process for dealing with an unknown stepper is to first find all leads from the motor and take resistance measurements between all lead pairs. The measurements obtained should be entered into a partially filled-in matrix whose headings are the lead colors, if colors are present. Once done we can identify the number of coils and their associated leads. As previously noted, the pairs that have the greatest resistance are the coils, and the pairs with the lower resistance will, in the case of unipolar steppers, have one of their colors in common, and that color identifies the common lead(s).

In this example, we had six leads with the colors: Red, Black, White, Yellow, Orange, and Blue. (Note some steppers may have leads that are all the same color, although this is not common.) If leads are all one color, one end should be identified as the point from which all lead resistances are measured, if such a point exists.

In an earlier example we used a 28BYJ-48 stepper and noted that the version of this stepper we used had reduction gearing so that it took approximately 2,048 steps (4086 half-steps) to complete one full 360 degree rotation. We used this information to find the angle through which the shaft of the stepper turned by counting the number of steps taken, so that we could reverse direction after each full 360 degree revolution.

Step information is often shown on a stepper motor's label, even if a data sheet is not available. If not, we can count the steps in a full turn to find a stepper's basic step angle. Knowing this angle will allow us to properly write a sketch. Typically there are 48 to 400 or more steps in a full stepper revolution. Forty-eight, two hundred, and four hundred steps per revolution are particularly common. Microstepping is generally avoided where we need to determine basic step information.

The second stepper motor, a larger NEMA 23, whose data sheet was also unavailable is used for our second example. This stepper is a Vexta PH268-22 made by Oriental Motor Co. Ltd. of Japan. It is a 2-Phase, 6-wire, stepper with 200 basic steps in a full revolution. A reduced resistance matrix, shown in the attached photographs, was prepared after resistance measurements were taken between lead pairs. As noted in Part 3 of my D.C. Motors tutorial, and mentioned above, we only need to enter resistance values for lead pairs into the matrix above the upper left to lower right diagonal.

From this reduced matrix, for the NEMA 23, it was determined that there are two coils, coil1 (Blue-Red) and coil2 (Black-Green). Also from the resistance values measured, and displayed in the matrix, we were able to determine that there were two center taps (CTs), one for coil1, and one for coil2. These CTs are the Yellow and White leads. The layout in consonance with the resistances found is shown in the last attached photograph.

This NEMA 23 stepper will be connected to a L298N stepper motor driver in the next example.

Step 4: Using an L298N Stepper Motor Module

Picture of Using an L298N Stepper Motor Module

This stepper driver module is named for the its L298N IC, mounted here on a heat sink. There is some variety in the L298N modules that are available, but knowledge of the module used here should allow you to use any other L298N module. The L298N module has a dual H-bridge. An H-bridge was explained in Part 1 of my tutorial on D.C. Motors. See the attached photograph of an H-bridge copied from that tutorial. An H-bridge allows us to reverse current to a motor, and thus reverse motor direction.

The pictures attached show how this module was used.

The components were connected as follows:

Stepper Motor to Driver Module

1. Insert Blue and Red wires from stepper coil into stepper driver connections Out 1 and Out 2 respectively.

2. Insert Green and Black wires from stepper coil into stepper driver connections Out 3 and Out 4 respectively.

Driver Module (see attached photos for how this was implemented in this example)

3. Connect Orange wire (driver module) --------- Digital socket 2 on the UNO

4. Connect Green wire (driver module) ----------- Digital socket 3 on the UNO

5. Connect White wire (driver module) ------------ Digital socket 4 on the UNO

6. Connect Gray wire (driver module) ------------- Digital socket 5 on the UNO

7. Provide 12 volts DC power from a wall adapter to pins (see underside of module for markings) marked GND and +12V.

LCD Module (same as previously)

8. VSS (LCD) ---------- GND

9. VDD (LCD) ---------- 5volts

10. VO (LCD) ---------- Center tap, 10k potentiometer

11. RS (LCD) ---------- Digital socket 13 on the UNO

12. RW (LCD) --------- GND

13. E (LCD) ------------ Digital socket 12 on the UNO

14. D4 (LCD) ---------- Digital socket 11 on the UNO

15. D5 (LCD) ---------- Digital socket 10 on the UNO

16. D6 (LCD) ---------- Digital socket 9 on the UNO

17. D7 (LCD) ---------- Digital socket 8 on the UNO

18. A (LCD) ------------ 5volts

12. K (LCD) ------------ GND

LCD pins D0 through D3 are unconnected. Note, the center tap of the potentiometer goes to VO on the LCD. The 10K potentiometer is used to control the LCD’s contrast. I used a breadboard and connected the 5v and ground connectors on a UNO to the breadboard’s power rails. I then used these rails to connect to the LCD.

As noted previously, do not power a stepper directly from a UNO. When using steppers use a wall adapter for power for the stepper driver module, as used here, or another external power source to be certain that the Arduino will not be damaged.

The next sketch uses the L298N module, as connected above, to drive a NEMA 23 stepper, the Vexta PH268-22.

Step 5: Sketch Using the L289N Stepper Driver Module and a NEMA 23 Step Motor

Picture of Sketch Using the L289N Stepper Driver Module and a NEMA 23 Step Motor

The NEMA 23 motor is a larger size than the 28BYJ48 previously used, as a comparison with the previous stepper shows (see first attached photograph). Thus, we can appropriately conclude from the significant size difference that the rotor of the Vexta stepper has greater rotational inertia.

Owing to the greater mass of the NEMA 23 motor (the step length is also longer than in the previous example), the time between steps was slowed to allow the stepper's rotor to sync with the activations sent from the sketch. It takes some time for the current provided to enter the coils, and the stepper to move to its step positions. If the stepper is turned at a high speed, the current in the coils will not reach its maximum value. As torque depends on current, torque will be reduced, compared to the maximum torque possible if the stepper was turned more slowly.

If high speed and torque is not a requirement, a stepper with low inductance (inductance is a significant factor affecting current flow) is also not a requirement. Typically, the lower the coil inductance the higher the cost. That is, a low cost stepper may be fully appropriate, depending on the speed and torque requirements of the application.

Through trial and error, it was found that a 30 ms delay here between steps assured that the motor did not lose any steps, and was able to rotate fully without problems. A slightly shorter delay is also possible with out losing steps. The delay between complete revolutions was set to 50 ms. Remember that since a stepper provides no feedback, we should visually observe the stepper. In fact, we can run the stepper sketches provided here without an attached stepper. The sketch, as written, receives no feedback from the stepper and has no way of knowing if a stepper is connected or not.

In addition to compensating for the greater inertia of this stepper, the coil assignments were changed from our earlier sketch to appropriately handle coil activation for the connected Vexta stepper.

Please download the text file to see the sketch exactly as written, including less than and greater than symbols and whitespace.

----------Sketch----------

// Sketch by R. Jordan Kreindler, written October 2016, to rotate

// a stepper motor using the Half Step Method and reverse direction

// after approximately a full revolution. A 200 basic step stepper

// motor is used, yielding 400 steps for the half step method.

// An LCD is used to show rotation direction, angle(s), and RPM.

// A NEMA 23 Stepper, Vextra PH268-22, is used

float RPM;

unsigned long time;

#include LiquidCrystal.h

// Include LiquidCrystal.h inside less and greater than symbols as this site removes these symbols and

// any text included between them

// LiquidCrystal (RS, E, d4, d5, d6, d7)

LiquidCrystal lcd(13, 12, 11, 10, 9, 8); // A standalone, non-shield, LCD was used.

// Pin assignments

int aPin = 2; //IN1: coil a one end

int bPin = 5; //IN2: coil b one end

int aPrimePin = 3; //IN3: coil aPrime other end of coil a

int bPrimePin = 4; //IN4: coil bPrime other end of coil b

int one = aPin;

int two = bPin;

int three = aPrimePin;

int four = bPrimePin;

int degrees = 0;

int delay1 = 30; // The delay between each step in milliseconds

int delay2 = 50; // The delay after each full revolution, in milliseconds

int count = 0; // The number of steps

int numberOfRotations = 1; // The number of times the rotor has

// turned 360 degrees.

void setup() {

// Set all pins as output to send output signals from the Arduino

// UNO to the coil windings of the stator

lcd.begin(16, 2); // Sets the size of the LCD in characters and lines

lcd.clear(); // Clear the LCD screen of characters and symbols

pinMode(aPin, OUTPUT);

pinMode(bPin, OUTPUT);

pinMode(aPrimePin, OUTPUT);

pinMode(bPrimePin, OUTPUT);

lcd.setCursor(0, 0);

lcd.print(" Clockwise");

// Start with all coils off

digitalWrite(aPin, LOW);

digitalWrite(bPin, LOW);

digitalWrite(aPrimePin, LOW);

digitalWrite(bPrimePin, LOW);

}

void loop() {

// Send current to

// 1. The aPin

// 2. The aPin, and the bPin

// 3. The bPin

// 4. Then to the bPin and the aPrimePin

// 5. Then to the aPrimePin

// 6. Then to the aPrimePin and the bPrime Pin

// 7. Then to the bPrimePin

// 8. Then the bPrimePin and the aPin.

// Thus producing steps using the half step method

// 1. Set the aPin High

digitalWrite(aPin, HIGH);

digitalWrite(bPin, LOW);

digitalWrite(aPrimePin, LOW);

digitalWrite(bPrimePin, LOW);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

// 2. Energize aPin and bPin to HIGH

digitalWrite(aPin, HIGH);

digitalWrite(bPin, HIGH);

digitalWrite(aPrimePin, LOW);

digitalWrite(bPrimePin, LOW);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

// 3. Set the bPin to High

digitalWrite(aPin, LOW);

digitalWrite(bPin, HIGH);

digitalWrite(aPrimePin, LOW);

digitalWrite(bPrimePin, LOW);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

// 4. Set the bPin and the aPrimePin to HIGH

digitalWrite(aPin, LOW);

digitalWrite(bPin, HIGH);

digitalWrite(aPrimePin, HIGH);

digitalWrite(bPrimePin, LOW);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

// 5. Set the aPrime Pin to high

digitalWrite(aPin, LOW);

digitalWrite(bPin, LOW);

digitalWrite(aPrimePin, HIGH);

digitalWrite(bPrimePin, LOW);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

// 6. Set the aPrimePin and the bPrime Pin to HIGH

digitalWrite(aPin, LOW);

digitalWrite(bPin, LOW);

digitalWrite(aPrimePin, HIGH);

digitalWrite(bPrimePin, HIGH);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

// 7. Set the bPrimePin to HIGH

digitalWrite(aPin, LOW);

digitalWrite(bPin, LOW);

digitalWrite(aPrimePin, LOW);

digitalWrite(bPrimePin, HIGH);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

// 8. Set the bPrimePin and the aPin to HIGH

digitalWrite(aPin, HIGH);

digitalWrite(bPin, LOW);

digitalWrite(aPrimePin, LOW);

digitalWrite(bPrimePin, HIGH);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

count = count + 8;

degrees = (360.0 * (count / 400.0));

if ((numberOfRotations % 2) == 1) { // Check if number of rotations is even

lcd.setCursor(0, 0); // Move the cursor to 1th position on 1st line

lcd.print(" Clockwise ");

lcd.setCursor(0, 1); // Move the cursor to 1th position on 2nd line

lcd.print(" "); // Print a space

lcd.print(degrees); // Print angular position in degrees

lcd.print((char)223); // Print degree symbol

lcd.print(" "); // Print a space

}

else { // If numberOfRotations is odd number

lcd.setCursor(0, 0); // Move the cursor to 1th position on 1st line

lcd.print(" Anti-Clockwise ");

degrees = 360 - degrees;

lcd.setCursor(0, 1); // Move the cursor to 1th position on 2nd line

lcd.print(" -"); // Print a minus sign

lcd.print(degrees); // Print angular position in degrees

lcd.print((char)223); // Print degree symbol

lcd.print(" "); // Print a space

}

if (count == 400) { // A full revolution of the stepper

numberOfRotations = ++numberOfRotations;

time = millis();

RPM = time / numberOfRotations; // Average time of a rotation

RPM = (60000.00 / RPM); // Number of rotations per minute

if (numberOfRotations >= 10) {

lcd.setCursor(7, 1);

lcd.print("RPM:");

lcd.print(round(RPM)); //Print RPM as integer

lcd.print(" ");

}

delay(delay2); // delay2/1000 second(s) after each full rotation

count = 0; // Reset step counter to zero

//Reversive direction after each turn

if ((numberOfRotations) % 2 == 0) { // Check if number of rotations is even

// if so reverse direction

aPin = four;

bPin = three;

aPrimePin = two;

bPrimePin = one;

}

else { // If number of rotations is an odd number

aPin = one;

bPin = two;

aPrimePin = three;

bPrimePin = four;

}

}

}

Step 6: Using an L9110S DC Stepper Motor Driver

Picture of Using an L9110S DC Stepper Motor Driver

This compact, and small, stepper motor module has two L9110 H-bridge ICs. It is ideal for driving a small stepper motor, but it has a limited current handling capacity as might be expected from its size. It can handle about 800mA, which is only about 40% of that available for the L298N driver module discussed above. This module would not have appropriately driven the NEMA 23 stepper previously used. The L9110S module can only drive a small DC stepper motor. It has two, green, blocks with two screws each, for connections to a stepper's coils. However, it is quite inexpensive; I obtained mine for less than $0.20 each. So, if your stepper motor does not require more current than this module can handle, this driver may be a good selection.

Although current for the stepper used here is relatively low, I used a 5V wall adapter to insure I did not damage the Arduino UNO. The L9110S module can use voltages as low as 2.5V and higher voltages than that used in this tutorial.

The LL9110S stepper driver was used in an Arduino UNO circuit as follows:

Stepper Motor to Driver Module
1. Insert the two wires from stepper coil 1 into one pair of the stepper driver's screw blocks.

2. Insert the two wires from stepper coil 2 into the other pair of the stepper driver's screw blocks.

Driver Module (see attached photos for how this was implemented in this example)

3. Connect Orange wire (driver module) --------- Digital socket 2 on the UNO

4. Connect Green wire (driver module) ----------- Digital socket 3 on the UNO

5. Connect White wire (driver module) ------------ Digital socket 4 on the UNO

6. Connect Gray wire (driver module) ------------- Digital socket 5 on the UNO

7. Provide 5 volts DC power from a wall adapter to power pins on the L9110S stepper. These pins are marked GND and VCC.

LCD Module (same as previously)

8. VSS (LCD) ---------- GND

9. VDD (LCD) ---------- 5volts

10. VO (LCD) ---------- Center tap, 10k potentiometer

11. RS (LCD) ---------- Digital socket 13 on the UNO

12. RW (LCD) --------- GND

13. E (LCD) ------------ Digital socket 12 on the UNO

14. D4 (LCD) ---------- Digital socket 11 on the UNO

15. D5 (LCD) ---------- Digital socket 10 on the UNO

16. D6 (LCD) ---------- Digital socket 9 on the UNO

17. D7 (LCD) ---------- Digital socket 8 on the UNO

18. A (LCD) ------------ 5volts

19. K (LCD) ------------ GND

LCD pins D0 through D3 on the 1602 LCD are left unconnected. Note, the 10K's potentiometer center tap goes to VO on the LCD. This potentiometer is used to control the LCD’s contrast. I used a breadboard and connected the 5v and ground connectors on the UNO to the breadboard’s power rails. I then used these rails to connect to the LCD.

Again a caution: Do not power a stepper motor directly from a UNO. When using steppers, develop the habit of using a wall adapter for stepper motor power, as used here. Alternatively, you can use another external power source.

A sketch using this circuit is provided in the next Step.

Step 7: Sketch Using the L9110S Stepper Driver Module and Small Step Motor

In the sketch below an LCD, as was employed previously, is used to display rotation direction (i.e., clockwise or anti-clockwise), angular rotation (where a minus sign is used to show angles during counterclockwise rotation), and approximate RPM.

In the attached videos, the delay between steps was changed to three different values: 7ms, 20ms, and 60ms. The attached videos are presented above in this order, to show how speed can be controlled by changing the timing of the pulses sent to the stepper for coil activation. In the last of the three videos, the time between steps is sufficiently long to insure each step is clearly visible.

Please download the text file to see the sketch exactly as written, including less than and greater than symbols and whitespace.

----------Sketch----------

// Sketch by R. Jordan Kreindler, written October 2016, to rotate

// a stepper motor using the Half Step Method and reverse direction

// after approximately a full revolution. A 48 basic step stepper

// motor is used, yielding 96 steps for the half step method.

// An LCD is used to show rotation direction, angle(s), and RPM.

float RPM;

unsigned long time;

#include LiquidCrystal.h

// Be sure to include LiquidCrystal.h in less and greater than symbols, to correct for site issues.

// LiquidCrystal (RS, E, d4, d5, d6, d7)

LiquidCrystal lcd(13, 12, 11, 10, 9, 8); // A standalone, non-shield, LCD

// was used.

// Pin assignments

int aPin = 4; //IN1: coil a one end

int bPin = 3; //IN2: coil b one end

int aPrimePin = 5; //IN3: coil aPrime other end of coil a

int bPrimePin = 2; //IN4: coil bPrime other end of coil b

int one = aPin;

int two = bPin;

int three = aPrimePin;

int four = bPrimePin;

int degrees = 0;

int delay1 = 20; // The delay between each step in milliseconds

int delay2 = 50; // The delay after each full revolution, in milliseconds

int count = 0; // The number of steps

int numberOfRotations = 1; // The number of times the rotor has

// turned 360 degrees.

void setup() {

// Set all pins as output to send output signals from the Arduino

// UNO to the coil windings of the stator

lcd.begin(16, 2); // Sets the size of the LCD in characters and lines

lcd.clear(); // Clear the LCD screen of characters and symbols

pinMode(aPin, OUTPUT);

pinMode(bPin, OUTPUT);

pinMode(aPrimePin, OUTPUT);

pinMode(bPrimePin, OUTPUT);

lcd.setCursor(0, 0);

lcd.print(" Clockwise");

// Start with all coils off

digitalWrite(aPin, LOW);

digitalWrite(bPin, LOW);

digitalWrite(aPrimePin, LOW);

digitalWrite(bPrimePin, LOW);

}

void loop() {

// Send current to

// 1. The aPin

// 2. The aPin, and the bPin

// 3. The bPin

// 4. Then to the bPin and the aPrimePin

// 5. Then to the aPrimePin

// 6. Then to the aPrimePin and the bPrime Pin

// 7. Then to the bPrimePin

// 8. Then the bPrimePin and the aPin.

// Thus producing steps using the half step method

// 1. Set the aPin High

digitalWrite(aPin, HIGH);

digitalWrite(bPin, LOW);

digitalWrite(aPrimePin, LOW);

digitalWrite(bPrimePin, LOW);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1

// 2. Energize aPin and bPin to HIGH

digitalWrite(aPin, HIGH);

digitalWrite(bPin, HIGH);

digitalWrite(aPrimePin, LOW);

digitalWrite(bPrimePin, LOW);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

// 3. Set the bPin to High

digitalWrite(aPin, LOW);

digitalWrite(bPin, HIGH);

digitalWrite(aPrimePin, LOW);

digitalWrite(bPrimePin, LOW);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

// 4. Set the bPin and the aPrimePin to HIGH

digitalWrite(aPin, LOW);

digitalWrite(bPin, HIGH);

digitalWrite(aPrimePin, HIGH);

digitalWrite(bPrimePin, LOW);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

// 5. Set the aPrime Pin to high

digitalWrite(aPin, LOW);

digitalWrite(bPin, LOW);

digitalWrite(aPrimePin, HIGH);

digitalWrite(bPrimePin, LOW);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

// 6. Set the aPrimePin and the bPrime Pin to HIGH

digitalWrite(aPin, LOW);

digitalWrite(bPin, LOW);

digitalWrite(aPrimePin, HIGH);

digitalWrite(bPrimePin, HIGH);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

// 7. Set the bPrimePin to HIGH

digitalWrite(aPin, LOW);

digitalWrite(bPin, LOW);

digitalWrite(aPrimePin, LOW);

digitalWrite(bPrimePin, HIGH);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

// 8. Set the bPrimePin and the aPin to HIGH

digitalWrite(aPin, HIGH);

digitalWrite(bPin, LOW);

digitalWrite(aPrimePin, LOW);

digitalWrite(bPrimePin, HIGH);

// Allow some delay between energizing the coils to allow

// the stepper rotor time to respond.

delay(delay1); // So, delay1 milliseconds

count = count + 8;

degrees = (360.0 * (count / 400.0));

if ((numberOfRotations % 2) == 1) { // Check if number of rotations is even

lcd.setCursor(0, 0); // Move the cursor to 1th position on 1st line

lcd.print(" Clockwise ");

lcd.setCursor(0, 1); // Move the cursor to 1th position on 2nd line

lcd.print(" "); // Print a space

lcd.print(degrees); // Print angular position in degrees

lcd.print((char)223); // Print degree symbol

lcd.print(" "); // Print a space

}

else { // If numberOfRotations is odd number

lcd.setCursor(0, 0); // Move the cursor to 1th position on 1st line

lcd.print(" Anti-Clockwise ");

degrees = 360 - degrees;

lcd.setCursor(0, 1); // Move the cursor to 1th position on 2nd line

lcd.print(" -"); // Print a minus sign

lcd.print(degrees); // Print angular position in degrees

lcd.print((char)223); // Print degree symbol

lcd.print(" "); // Print a space

}

if (count == 96) { // A full revolution of the stepper

numberOfRotations = ++numberOfRotations;

time = millis();

RPM = time / numberOfRotations; // Average time of a rotation

RPM = (60000.00 / RPM); // Number of rotations per minute

if (numberOfRotations >= 10) {

lcd.setCursor(7, 1);

lcd.print("RPM:");

lcd.print(round(RPM)); //Print RPM as integer

lcd.print(" ");

}

delay(delay2); // delay2/1000 second(s) after each full rotation

count = 0; // Reset step counter to zero

//Reversive direction after each turn

if ((numberOfRotations) % 2 == 0) { // Check if number of rotations is even

// if so reverse direction

aPin = four;

bPin = three;

aPrimePin = two;

bPrimePin = one;

}

else { // If number of rotations is an odd number

aPin = one;

bPin = two;

aPrimePin = three;

bPrimePin = four;

}

}

}

Step 8: Afterwards

Picture of Afterwards

If you have come to this point congratulations. You should now have a basic understanding of some of the important elements of the stepper motor drivers covered in this Part of the tutorial: what stepper driver and stepper motor parameters are important, the general rules to know when dealing with stepper motors and their drivers, how to adjust stepper speed in your sketch, and how a stepper motor can be driven by the modules discussed.

I hope you found this Part both interesting and informative. Additional stepper motor drivers will be covered in Part 2.

Comments

JoeK17 (author)2016-10-20

GREAT!!!!! very nice :) ... thank you very much for sharing... good to know there is still part 2 :) ....

Dear JoeK17,

Thank you for your very pleasant comments. They are certainly appreciated and they, and the number of times this tutorial has been "Favorited" by readers, continue to make this effort worthwhile.

Part 2 should be completed and posted by the end of next month. I hope you find that Part of the tutorial as interesting as you found Part 1.

The very best.

Vassilis (author)2016-10-20

Hi Jordan!

So detailed and so sipmle tutorial! I admire your knowledge and you kindness to share with us! Thank you!

Dear Vassilis,

It is super to hear such nice comments from you again. I am
pleased to share, and I hope you will enjoy Part 2 of this tutorial (it has yet
to be posted) as much as you enjoyed Part 1.

Thank you once again.

The very best.

I can't wait :)

Hi,

Thank you for the follow-up. I hope you will not have to wait too
long, I plan to have Part 2/2 posted before the end of next month.

As always, the very best.

papy33 (author)2016-10-20

bonjour Jordan

excellent tutoriel

merci !!!

Nous vous remercions d'avoir pris le temps de poster votre commentaire et vos aimables paroles.

Je vous en prie.

Le meilleur

bluswede (author)2016-10-19

Hey Jordan ...

Nice job on this .... It was well done and I enjoyed it very much. I also downloaded some other work of yours and I've just started to review my downloads. I want to "Thank You" for your time in posting all of theses. They truly are well done. I've just recently retired from 3M and want to spend more time on my hobbies which involve steppers and servo's. Thanks again ... !!!!!!

Rick

Dear bluswede (Rick),

Thank you for your kind and generous comments. They are sincerely appreciated. I hope you find Part 2 of this tutorial, when it’s published, just as enjoyable as you found Part 1.

You are certainly fortunate to have recently retired, so you now will have time to spend on your hobbies. I think you will find Maker activities are fun and fascinating, and will keep you well occupied, perhaps even too well occupied – if you let them, during your retirement.

I, obviously, do not know your background at 3M, but regardless of what it was, it should not be too long before you are able to make your own contributions here.

The very best.

Hi Jordan ...

My job at 3M was as a engineering tech. My job consisted of bridging a gap that 3M saw as a problem and how to correct it. How does a large company bridge the gap between a machine designed by "ADVANCED MANUFACTURING" to actually being controlled by people off the street. I guess it all boils down to how to make an advanced machine controllable by people with might not have the educational back ground in this discipline. For me it was a labor of love. I worked to create an even playing field for the people hired and what was expected of them. I loved my job and loved the people. 3M paid we well for my efforts.

I have an advanced education which clearly allowed me to help these people and also recognize the value of your time and efforts in your posts. The photos in your post are so professional.

Again "Thank You" Jordan

Dear bluswede (Rick).

As an engineering tech with advanced education, the learning curve for you to become a productive Maker will undoubtedly be considerably shorter than it is/was for some others.

It would seem that your job at 3M has provided you with just the right background to make contributions here, and/or construct projects for yourself.

Good luck in your retirement, and again thank you for your kind comments.

As always, the very best.

About This Instructable

31,770views

545favorites

License:

More by R Jordan Kreindler:Arduino Stepper Drivers Tutorial-2/2Arduino Stepper Drivers Tutorial-1/2DC Motors Tutorial-3/3: Steppers
Add instructable to: