# Motors for Makers: Introduction to Stepper Motors for Motion Control

This chapter is from the book

## 4.4 Stepper Control

Because VR steppers are so scarce, this section focuses on controlling PM and HY steppers, which are almost always two-phase motors. Some PM and HY steppers are bipolar and have four wires. Others are unipolar and have five or six wires.

The terms bipolar and unipolar identify how the wires are connected to the motor’s windings. Before you design a control circuit for a stepper, you should know whether it’s unipolar or bipolar as well as the difference between the two types. For this reason, the first part of this section discusses bipolar and unipolar steppers and how to control them.

The last part of this discussion presents different methods of delivering current to a stepper’s windings. These methods include half-stepping, which improves angular resolution but reduces torque, and microstepping, which improves angular resolution even further.

### 4.4.1 Bipolar Stepper Control

A two-phase bipolar stepper has four wires. Figure 4.10 shows how they’re connected inside the stepper.

This figure depicts electromagnets and their corresponding phases: A/A’ and B/B’. As explained in Chapter 3, “DC Motors,” the electromagnet’s poles are determined by the nature of the current flow. If current flows from the black wire to the green wire, A will be the north pole and A’ will be the south pole. If current flows from green to black, A will be the south pole and A’ will be the north pole.

Figure 4.10 identifies the colors of the wires entering the stepper, but these aren’t set by any standard. Instead, they follow a convention I’ve encountered in many bipolar steppers. If you find a stepper whose wires have different colors, the first place to look is the stepper’s datasheet. If this doesn’t help, you can test the wires with an ohmmeter—the resistance between A and A’, like that between B and B’, is very small. The resistance between wires in different phases is very high.

To design a circuit that drives a bipolar stepper, you need a means of reversing current in the wires. A common method of accomplishing this involves using H bridges, which were introduced in Chapter 3. An H bridge consists of four switches that, when opened and closed properly, make it possible to deliver current in the forward and reverse directions.

Figure 4.11 shows how an H bridge can be connected to control one phase (A/A’) of a bipolar motor. This uses four MOSFETs to serve as the switches.

The current’s direction is controlled by setting voltages on the MOSFET gates. When S0 and S3 are set high and S1 and S2 are low, current travels from A to A’, making A the north pole and A’ the south pole. When S1 and S2 are set high and S0 and S3 are low, current travels from A’ to A, making A’ the north pole and A the south pole. When S0 and S2 are left low, the winding is unenergized.

Chapter 9, “Motor Control with the Arduino Mega,” and Chapter 10, “Motor Control with the Raspberry Pi,” explain how stepper motors can be controlled with real-world circuitry. In both cases, the control circuit contains two H bridges capable of governing both phases of a bipolar stepper motor.

### 4.4.2 Unipolar Stepper Control

The wiring of a unipolar stepper motor is more complicated than that of a bipolar motor, but the goal is the same: to energize A, A’, B, and B’ and to set their north/south poles accordingly. To understand how this is done, consider the two circuits depicted in Figure 4.12.

In both figures, VPOWER is connected to the center of the electromagnet’s winding. This type of connection is called a center tap.

In Figure 4.12a, the bottom of the winding is connected to ground. Current flows from the center to ground, energizing the electromagnet and making the bottom of the winding (labeled A’) the south pole. The north pole is located at the center.

Now here’s the tricky part: The top of the winding isn’t connected to anything, so no current flows from the top of the winding to the center. However, the entire iron core is magnetized by the current in the lower wire, which means that the top of the winding also behaves as the electromagnet’s north pole. Therefore, in Figure 4.12a, A is north and A’ is south.

Figure 4.12b illustrates the reverse situation. The top of the winding is connected to the ground, so current flows from the winding’s center to the top. This makes the top of the winding (A) the south pole and the center of the winding the north pole. Because the entire iron core is magnetized, the bottom of the winding (A’) also behaves as the north pole.

From a circuit designer’s perspective, controlling a two-phase unipolar stepper requires three steps:

1. Provide VPOWER to the A/A’ and the B/B’ windings.
2. For each winding, connect one wire to ground to set the magnetic poles.
3. Leave other wires unconnected.

Figure 4.13 depicts the six wires entering the unipolar stepper: two carry power (VPOWERA and VPOWERB) and four are connected to A, A’, B, or B’. Each of the latter four wires is connected to a MOSFET. When the MOSFET’s gate voltage exceeds its threshold, the wire is connected to ground. Otherwise, the wire is left unconnected.

When a MOSFET switches on, the corresponding end of the winding becomes the south pole. The opposite end of the winding becomes the north pole. For example, when voltage is applied to S1, the resulting current makes B the south pole and B’ the north pole.

Many unipolar steppers have five wires instead of six. For these motors, the two supply wires, VPOWERA and VPOWERB, are connected together. The other four wires remain unchanged.

Unipolar steppers are easier to control than bipolar steppers because there’s no need to manage the switches of two H bridges. However, when a unipolar stepper is energized, only half of the electromagnet is used. Therefore, if a unipolar stepper and a bipolar stepper have the same windings, the unipolar stepper will be half as efficient. This is why I recommend using bipolar steppers whenever possible.

If you ignore the VPOWER wires of a unipolar stepper, you can deliver current directly between A and A’ and between B and B’. In essence, this is driving a unipolar stepper as a bipolar stepper.

I’d like to make one last point concerning unipolar and bipolar steppers. If you look at a stepper’s datasheet, the wiring diagrams won’t look like the diagrams presented in this chapter. They represent windings using simpler symbols, and Figure 4.14 shows a sample diagram for a bipolar stepper and a unipolar stepper.

Like many datasheets, this figure doesn’t identify which winding is A/A’ and which is B/B’. This isn’t a significant concern. If you replace A/A’ with B/B’ in a control sequence, the motor’s rotation won’t be seriously affected.

### 4.4.3 Drive Modes

This chapter has explained how to operate steppers by energizing one or two winding pairs at a time, but there are a number of different ways to drive a stepper, and this discussion touches on four of them:

• Full-step (one phase on) mode—Each control signal energizes one winding.
• Full-step (two phases on) mode—Each control signal energizes two windings.
• Half-step mode—Each control signal alternates between energizing one and two windings.
• Microstep mode—The controller delivers sinusoidal signals to the stepper’s windings.

Choosing between these modes requires making tradeoffs involving torque, angular resolution, and power.

#### Full-Step (One Phase On) Mode

The simplest way to control a stepper is to energize one winding at a time. This is the method discussed at the start of this chapter. Figure 4.15 shows what the signaling sequence looks like when controlling a stepper in this mode.

With each control signal, the rotor turns to align itself with the energized winding. The rotor always turns through the stepper’s rated step angle. That is, if a PM motor is rated for 7.5°, each control signal causes it to turn 7.5°.

#### Full-Step (Two Phases On) Mode

In the full-step (two phases on) mode, the controller energizes two windings at once. This turns the rotor through the stepper’s rated angle, and the rotor always aligns itself between two windings. Figure 4.16 illustrates one rotation of a stepper motor driven in this mode.

Figure 4.17 shows what the corresponding drive sequence looks like.

The main advantage of this mode over full-step (one phase on) is that it improves the motor’s torque. Because two windings are always on, torque increases by approximately 30%–40%. The disadvantage is that the power supply has to provide twice as much current to turn the stepper.

#### Half-Step Mode

The half-step mode is like a combination of the two full-step modes. That is, the controller alternates between energizing one winding and two windings. Figure 4.18 depicts three rotations of a stepper in half-step mode.

Figure 4.19 illustrates a control signal for a stepper motor driven in half-step mode.

In this mode, the rotor aligns itself with windings (when one winding is energized) and between windings (when two windings are energized). This effectively reduces the motor’s step angle by half. That is, if the stepper’s step angle is 1.8°, it will turn at 0.9° in half-step mode.

The disadvantage of this mode is that, when a single winding is energized, the rotor turns with approximately 20% less torque. This can be compensated for by increasing the current.

#### Microstep Mode

The purpose of microstep mode is to have the stepper turn as smoothly as possible. This requires dividing the energizing pulse into potentially hundreds of control signals. Common numbers of division are 8, 64, and 256. If the energizing pulse is divided into 256 signals, a 1.8° stepper will turn at 1.8°/256 = 0.007° per control signal.

In this mode, the controller delivers current in a sinusoidal pattern. Successive windings receive a delayed version of this sinusoid. Figure 4.20 gives an idea of what this looks like.

Using this mode reduces torque by nearly 30%, but another disadvantage involves speed. As the width of a control signal decreases, the ability of the motor to respond also decreases. Therefore, if the controller delivers rapid pulses to the stepper in microstep mode, the motor may not turn in a reliable fashion.

### InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

## Overview

Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

## Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

### Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

### Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

### Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

### Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

### Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

### Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

## Other Collection and Use of Information

### Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

### Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

### Do Not Track

This site currently does not respond to Do Not Track signals.

## Security

Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

## Children

This site is not directed to children under the age of 13.

## Marketing

Pearson may send or direct marketing communications to users, provided that

• Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
• Such marketing is consistent with applicable law and Pearson's legal obligations.
• Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
• Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

## Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

## Choice/Opt-out

Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

## Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

## Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

## Sharing and Disclosure

Pearson may disclose personal information, as follows:

• As required by law.
• With the consent of the individual (or their parent, if the individual is a minor)
• In response to a subpoena, court order or legal process, to the extent permitted or required by law
• To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
• In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
• To investigate or address actual or suspected fraud or other illegal activities
• To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
• To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
• To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.