Developing a two phase permanent magnet stepper motor class with ArduinoTB6612FNG - VGavara/arduino-TB6612FNG GitHub Wiki

Table of contents

Abstract

This document exposes the basics and implementation of a C++ class addressed to control a two-phase permanent-magnet stepper motor based on the ArduinoTB6612FNG Arduino library.

Background

Motor construction

A two-phase permanent-magnet (PM) stepper, is a motor that:

  • Being a two-phase motor, it has at least four windings in its stator, designated A, A', B, and B'. In a more general way, a two-phase stepper motor stator contains one or more set of windings, each set being composed by four windings. Windings A and A' are connected together, but its polarity is inverted. The same applies to windings B and B' (see figure 6 on Reference 2).
  • Being a permanent-magnet motor, the rotor of the simplest two-phase motor (that with one set of four windings) is a cylindrical permanent magnet with the magnetic poles divided laterally. If the coil A is energized, so that the portion closest to the rotor becomes a north pole, the south pole of the rotor will be attracted to it, turning until the two line up, driving the torque to zero. This constitutes a step, with an step angle of 90° (360° divided by 4 windings). If the motor is based not in one but in two or more sets of windings, the rotor will be structurally different but will behave in the same way explained above, being the step angle 360°/(4 * number of winding sets) (see figure 3 on Reference 1).

Given that a two-phase stepper motor is, in last term, a set of n windings divided in two groups, this kind of motor can be controlled by using a Toshiba TB6612FNG as far as the motor voltage and current were under the Toshiba TB6612FNG controller maximum ratings, ie, 15V, 2,4A (1,2A per channel).

Controlling the motor

Full-step single-coil mode

The simplest way of driving a two-phase PM motor is following a sequence of four steps. In each step, windings A-A' and B-B' can be fully energized with a given polarity, or not energized (see figure 3 on Reference 1):

  1. In the step 1 windings A-A' are positively energized, so the winding A attracts the rotor positive pole while the winding A' attracts the rotor negative pole.
  2. In the step 2 windings B-B' are positively energyzed, so the winding B attracts the rotor positive pole while the winding B' attracts the rotor negative pole. This makes the rotor rotating in clockwise direction.
  3. Step 3 is similar to step 1, but this time windings A-A' are negatively energized, so now the winding A' attracts the rotor positive pole while the winding A attracts the rotor negative pole. Again, this makes the rotor rotating clockwise.
  4. Finally, step 4 is similar to step 2 but this time windings B-B1 are negatively energized, what makes winding B' attract the rotor positive pole while winding B attracts the rotor negative pole.

This way of driving an stepper motor is called full-step single-coil mode, since the rotor moves from one coil (winding) to another in a single step. This mode provides minimal torque, and so it cannot be used with high loads. However, it does minimize power consumption. With this mode, the minimum motor resolution is 360°/(4 * number of winding sets), ie, in the case of a stepper motor with 4 windings, each step would rotate the motor 90°.

Half-step dual-coil mode

Instead of fully energizing one winding group (A-A' or B-B') whereas not energizing the other, and therefore moving the rotor from one winding to the adjacent in each step, half-step dual-coil mode modulates the energy on each winding group, so the transition from one winding to other is done not in one step but in two (see figure 7 on reference 1).

In this way, motor resolution is higher (two times the resolution of full-step single-coil mode), motor vibration is reduced and exciting resonances are avoided, getting a smoother, quieter motion. However, in this mode the motor consumes more energy and its control becomes more complex.

Half-step dual-coil mode motion is based in a sequence of eight stages:

  1. Windings A-A' are fully positively energized while windings B-B' are not energized. This stage is equivalent to the step 1 in full-step single-coil mode.
  2. Windings A-A' and B-B' are partially, positively energized. This makes the rotor positive pole to be attracted by the coil A and B (negative pole is attracted by coils A' and B'), so it performs a half step.
  3. Windings B-B' are fully positively energized while windings A-A' are not energized. This makes the rotor fully facing windings B (positive pole) and B' (negative pole). This stage is equivalent to the step 2 in full-step single-coil mode.
  4. Windings B-B' are partially positively energized while windings A-A' are partially negatively energized. This makes the positive rotor to stay in an intermediate position between windings B and A'.
  5. Windings A-A' are fully negatively energized whereas windings B-B' are not energized. This stage is equivalent to step 3 in full-step single-coil mode.
  6. Windings A-A' and B-B' are partially negatively energized, what makes the rotor positive pole to move to an intermediate position between windings A' and B'.
  7. Windings B-B' are fully negatively energized while windings A-A' are not energized. This stage is equivalent to step 4 in full-step single-coil mode.
  8. Windings B-B' are partially negatively energized while windings A-A' are partially positively energized, what makes the rotor positive pole moving to an intermediate position between windings B' and A.

Microstepping

Microstepping is the generalization of the concept behind the half-step dual-coil mode: Instead of performing full steps from one winding to another by fully energyzing one winding while stop energizing the other, one or several intermediate positions can be reached by partially energizing the winding. In this way, half-step dual-coil mode performs 1 microstep (stages 2, 4, 6 and 8) between two steps (stages 1, 3, 5 and 7).

As expected, microstepping improves the stepper nominal resolution, defined by its phisical construction, by increasing the stepper precision in a magnitude of m+1, being m the supported microsteps. Therefore, driving an stepper motor in half-step dual-coil mode (1 microsteps) would increase the motor precision by 50% (1/(microsteps+1)), what would mean a resolution of 45° in a stepper motor with a nominal resolution of 90°.

Using the TB6612FNG as stepper driver

Based on that exposed, driving a two-pole PM stepper motor with a Toshiba TB6612FNG is basically the same that driving two motors, representing each motor an stepper winding type (A-A' or B-B'). Rotating a motor at a given duty cycle clockwise or counterclockwise is equivalent to fully (100% duty cycle) or partially energizing an stepper winding positively or negatively, whereas stopping a motor is equivalent to not energizing a winding. Microstepping, or winding partial energization, can by achieved by stating different PWM dutty cycles in each driver motor PWM input.

The TB6612FNG is referred in the paragraph above as driver, and therefore a controller is necessary for optimally implementing the stepper control. In that sense, the next section introduces the basics for controlling, from a software point of view, a two-phase PM stepper motor. In last term, this information will be used for creating a C/C++ Stepper class as part of the ArduinoTB6612FNG Arduino library that will allow controlling a two-phase PM stepper motor using a TB6612FNG as driver and an Arduino as controller.

Implementation

References

  1. Tutorial: The Basics of Stepper Motors
  2. Stepper Motors Basics: Types, Uses, and Working Principles