# Stepper Motor

Permanent magnet stepper motor suitable for whole-, half- and micro-stepping

**Libraries:**

Simscape /
Electrical /
Electromechanical /
Reluctance & Stepper

## Description

The Stepper Motor block represents a stepper motor. Stepper motors have a permanent magnet rotor and two wound stator windings. If your stepper motor has a center tap on each of the stator windings, use the Unipolar Stepper Motor block instead.

Stepper motors with smaller step sizes typically have north and south pole rotors with teeth. Stepper motors with larger step sizes typically have multiple magnets distributed around the rotor circumference. You can model both types of device using the Stepper Motor block and drive the motor using the Stepper Motor Driver block.

You can use stepper motors to avoid the need for a position measurement. You use stepper motors in devices, such as printers, and in applications like robotics and factory automation.

The block uses the input pulse trains, A and B, to control the mechanical output according to these equations,

$${e}_{A}=-{K}_{m}\omega \mathrm{sin}({N}_{r}\theta )$$

$${e}_{B}={K}_{m}\omega \mathrm{cos}({N}_{r}\theta )$$

$$\frac{d{i}_{A}}{dt}=\left({v}_{A}-R{i}_{A}-{e}_{A}\right)/L$$

$$\frac{d{i}_{B}}{dt}=\left({v}_{B}-R{i}_{B}-{e}_{B}\right)/L$$

$$J\frac{d\omega}{dt}+B\omega ={T}_{e}$$

$${T}_{e}=-{K}_{m}\left({i}_{A}-\frac{{e}_{A}}{{R}_{m}}\right)\mathrm{sin}\left({N}_{r}\theta \right)+{K}_{m}\left({i}_{B}-\frac{{e}_{B}}{{R}_{m}}\right)\mathrm{cos}\left({N}_{r}\theta \right)-{T}_{d}\mathrm{sin}\left(4{N}_{r}\theta \right)$$

$$\frac{d\theta}{dt}=\omega $$

where:

*e*and_{A}*e*are the back electromotive forces (emfs) induced in the A and B phase windings, respectively._{B}*i*and_{A}*i*are the A and B phase winding currents._{B}*v*and_{A}*v*are the A and B phase winding voltages._{B}*K*is the motor torque constant._{m}*N*is the number of teeth on each of the two rotor poles. The_{r}**Full step size**parameter is (π/2)/*N*_{r}.*R*is the winding resistance.*L*is the winding inductance.*R*is the magnetizing resistance._{m}*B*is the rotational damping.*J*is the inertia.*ω*is the rotor speed.*Θ*is the rotor angle.*T*is the detent torque amplitude._{d}*T*is the electrical torque._{e}

If the initial rotor is zero or some multiple of
(π/2)/*N*_{r}, the rotor is aligned with the
phase winding of pulse A. This happens when there is a positive current flowing from the
**A+** to the **A-** ports and there is no current
flowing from the **B+** to the **B-** ports.

Use the Stepper Motor Driver block to create the pulse trains for the Stepper Motor block.

The Stepper Motor block produces a positive torque
acting from the mechanical **C** to **R** ports when
the phase of pulse A leads the phase of pulse B.

### Averaged Mode

If you set the **Simulation mode** parameter to
`Averaged`

, both for a Stepper
Motor block and for the Stepper Motor
Driver block that controls it, then the individual steps are not
simulated. This can be a good way to speed up simulation. In Averaged mode, under
nonslipping conditions, the motor and driver are represented by a second-order
linear system that tracks the specified step rate. The demanded step rate is
determined directly from voltage across **A+** and
**A-**. So, for example, a voltage of +10 V across the
**A+** and **A-** terminals is interpreted as
a step rate demand of 10 steps per second. See the Stepper Motor Driver block reference page for more information
on how to connect the driver block to your step angle controller.

Averaged mode includes a slip estimator to predict whether the stepper motor would
have slipped if running in Stepping simulation mode. Slip is predicted if the motor
torque exceeds the **Vector of maximum torque values** parameter
value for longer than one step period, the step period being determined from the
current step rate demand. Upon detecting slip, the simulation will proceed or stop
with an error, according to the **Action on slipping** parameter
value. If you choose the action that lets the simulation continue, note that
simulation results may be incorrect. When slipping occurs, the torque generated by
the motor is not generally the maximum available torque; the maximum torque is only
achieved if the stepper controller detects slip and adjusts the step rate command
accordingly.

The dynamics of the equivalent second-order system are determined from the values
that you specify for the **Approximate total load inertia** and
**Maximum step rate command** parameters. It is important that
you set as accurate values as possible for these parameters, so that the step rate
command is tracked, and the block does not generate false slipping warnings or
errors.

If you run the motor in Averaged mode with the optional thermal ports exposed (see
Model Thermal Effects), then heat is added to the thermal ports, assuming that
the windings are always powered even when the step rate command is zero. The block
makes adjustments for half stepping and for reduced torque (and winding currents) at
higher speeds. For these adjustments to be correct, the **Vector of maximum
torque** parameter values must be correct. For half stepping, at zero
speed the heat generated by the block is the average of that generated when stopped
at a half step and at a full step.

To validate Averaged mode model configurations where you predict slip to occur, compare results with the same simulation performed in stepping mode.

### Model Thermal Effects

You can expose thermal ports to model the effects of losses
that convert power to heat. To expose the thermal ports, set the **Modeling
option** parameter to either:

`No thermal port`

— The block does not contain thermal ports.`Show thermal port`

— The block contains multiple thermal conserving ports.

For more information about using thermal ports in actuator blocks, see Simulating Thermal Effects in Rotational and Translational Actuators.

If you expose these ports, winding resistance is assumed linearly dependent on temperature, and is given by:

*R* = *R _{0}* (1 +
α (

*T*–

*T*))

_{0}where:

*R*is the resistance at temperature*T*.*R*is the resistance at the measurement (or reference) temperature_{0}*T*. Specify the reference temperature using the_{0}**Measurement temperature**parameter.α is the resistance temperature coefficient, which you specify with the

**Resistance temperature coefficients, [alpha_A alpha_B]**parameter. A typical value for copper is 0.00393/K.

The block calculates temperature of each of the windings and the rotor by

$$M\frac{dT}{dt}=Q$$

where

*M*is the thermal mass. Specify this value for the windings using the**Winding thermal masses, [M_A M_B]**parameter, and for the rotor using the**Rotor thermal mass**parameter.*T*is the temperature. Specify the initial values for the windings using the**Winding initial temperatures, [T_A T_B]**parameter, and for the rotor using the**Rotor initial temperature**parameter.*Q*is the heat flow, which is calculated from the iron losses of the windings:$$\begin{array}{l}{Q}_{A}={i}_{a}{}^{2}{R}_{A}\left(1-{\rho}_{m}/100\right)\\ {Q}_{B}={i}_{B}{}^{2}{R}_{B}\left(1-{\rho}_{m}/100\right)\\ {Q}_{R}={Q}_{A}\left({\rho}_{m}/100\right)+{Q}_{B}\left({\rho}_{m}/100\right)\end{array}$$

where

*ρ*is the percentage of magnetizing resistance associated with the rotor. Specify this percentage using the_{m}**Percentage of magnetizing resistance associated with the rotor**parameter.

### Predefined Parameterization

There are multiple available built-in parameterizations for the Stepper Motor block.

This pre-parameterization data allows you to set up the block to represent a
specific supplier component. To load a predefined parameterization, double-click the
Stepper Motor block, click the **<click to select>**
hyperlink of the **Selected part** parameter and, in the Block
Parameterization Manager window, select the part you want to use from the list of
available components.

**Note**

The predefined parameterizations of Simscape™ components use available data sources for the parameter values. Engineering judgement and simplifying assumptions are used to fill in for missing data. As a result, expect deviations between simulated and actual physical behavior. To ensure accuracy, validate the simulated behavior against experimental data and refine component models as necessary.

For more information about pre-parameterization and for a list of the available components, see List of Pre-Parameterized Components.

## Examples

## Assumptions and Limitations

The model is based on the following assumptions:

This model neglects magnetic saturation effects and any magnetic coupling between phases.

When you select the

**Start simulation from steady state**check box in the Simscape Solver Configuration block, this block will not initialize an**Initial rotor angle**value between –π and π.To use Averaged mode, the Stepper Motor block must be directly connected to a Stepper Motor Driver block also running in Averaged mode.

The Averaged mode is an approximation, and exact step tracking compared to the Stepping mode should not be expected.

Slip detection in Averaged mode is approximate, and depends on a good estimate for load inertia and maximum step rate. Incorrect values may result in false slip detection.

When simulating slip in Averaged mode, it is assumed that the stepper motor controller adjusts the step rate command so as to achieve maximum possible torque.

You cannot use this block to model a hybrid stepper motor where the torque comes from both the permanent magnet and from variable reluctance effects.

## Ports

### Conserving

## Parameters

## References

[1] M. Bodson, J. N. Chiasson, R. T. Novotnak and R. B. Rekowski. “High-Performance Nonlinear Feedback Control of a Permanent Magnet Stepper Motor.” IEEE Transactions on Control Systems Technology, Vol. 1, No. 1, March 1993.

[2] P. P. Acarnley. *Stepping Motors: A Guide to
Modern Theory and Practice*. New York: Peregrinus, 1982.

[3] S.E. Lyshevski. *Electromechanical Systems,
Electric Machines, and Applied Mechatronics*. CRC, 1999.

## Extended Capabilities

## Version History

**Introduced in R2008a**