> For the complete documentation index, see [llms.txt](https://www.opal-rt.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.opal-rt.com/docs/smart-power-simulation-software-sps/blocks-functions-tools/machines/blocks/stepper-motor.md).

# Stepper Motor

## Description

<figure><img src="https://799605156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdlNg8IbOdahCpFCyzxSN%2Fuploads%2Fgit-blob-0c080eb47bdbe0ee07fba41332419c9b3689bb44%2Fstepper_motor_block.png?alt=media" alt=""><figcaption></figcaption></figure>

The **Steam Stepper Motor** block, located in the **OPAL-RT SPS Software/Electrical Machines** library, implements a generic model that represents two most popular families of stepper motors:

* Variable-reluctance stepper motors
* Permanent-magnet or hybrid stepper motors The Stepper Motor model consists of electrical and mechanical sections. The electrical section is represented by an equivalent circuit, configuration of which depends on the motor type. The equivalent circuits assume that the magnetic circuit is linear (no saturation) and the mutual inductance between phases is negligible. The mechanical section is represented by a state-space model based on inertia moment and viscous friction coefficient.

This figure shows the equivalent circuit for one phase in a variable-reluctance stepper motor.

<figure><img src="https://799605156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdlNg8IbOdahCpFCyzxSN%2Fuploads%2Fgit-blob-cd00cca2c298e989fe6dc2866225b1c64a802a44%2Fstepper_motor_equivalent_circuit.png?alt=media" alt=""><figcaption></figcaption></figure>

In this model, *R*<sub>*a*</sub> and *L*<sub>*a*</sub>(*θ*), respectively, represent the resistance and the inductance of phase A winding. The winding inductance varies as a function of the rotor position:

$$
La(θ) = L0 + L1cos(Nrθ)
$$

where,

* *L*<sub>0</sub> is the average inductance.
* *L*<sub>1</sub> is the maximum inductance variation.
* *N*<sub>*r*</sub> is the rotor teeth number.

The total electromagnetic torque produced by the motor is the sum of the torques produced by the motor phases:

$$
T\_e = \sum\_{x=1}^{m} 0.5, i\_x^{2}, \frac{dL\_x}{d\theta}
$$

where,

* *m* is the number of phases.
* *ix* is the winding current in phase *x*.
* *Lx* is the inductance function of phase *x* winding.

This figure shows the equivalent circuit for one phase in a permanent-magnet (PM) or hybrid stepper motor.

<figure><img src="https://799605156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdlNg8IbOdahCpFCyzxSN%2Fuploads%2Fgit-blob-7fa63011ff99bc8842aa80b684a89b48645786c1%2Fstepper_motor_equivalent_circuit_PM.png?alt=media" alt=""><figcaption></figcaption></figure>

In this model, *R*<sub>*a*</sub> and *L*<sub>*a*</sub>, respectively, represent the resistance and inductance of A-phase winding. Due to the large value of the air gap introduced by the magnets, the winding inductance of the PM or hybrid stepper motor can be considered to be independent of the rotor position. The voltage source *e*<sub>*a*</sub>(*θ*) represents the motor back electromotive force (EMF), which is a sinusoidal function of the rotor position:

$$
e\_a(\theta) = -p,\psi\_m \sin(p\theta),\frac{d\theta}{dt}
$$

where,

* *p* is the number of pole pairs. The number of pole pairs *p* is given by *p* = *Nr*/2.
* *ψ*<sub>*m*</sub> is the motor maximum magnetic flux.

Note that at the reference position (*θ* = 0), the north pole on the rotor is fully aligned with the A-axis pole to achieve zero value of the A-phase back EMF.

The electromagnetic torque produced by a two-phase PM or hybrid stepper motor is equal to the sum of the torque resulting from the interaction of the phase currents and magnetic fluxes created by the magnets and the detent torque, which results from the saliency of the rotor:

$$
Te = – pψ\_mi\_a sin(pθ) – p, ψ\_m i\_b sin(pθ – π/2) – T\_{dm}sin(mNrθ).
$$

where,

* *m* is the number of phase (*m*=2) of the motor.
* *Nr* the number of teeth on the rotor (*Nr* = 2\**p*).

### How to Get Stepper Motor Parameters

The parameters used in the stepper model are usually obtained from the manufacturer data sheets. In case the parameters are not available, you can determine them from experimental measurements.

#### **Variable-Reluctance Stepper Motor Parameters**

The parameters provided by manufacturer data sheets are usually: number of phases, holding torque, step angle, voltage per phase, current per phase, winding resistance, *R*<sub>*a*</sub>, maximum inductance, *L*<sub>*max*</sub>, average inductance, *L*<sub>*0*</sub>, and rotor inertia, *J*.

#### **Permanent-Magnet/Hybrid Stepper Motor Parameters**

The parameters provided by manufacturer data sheets are usually:

* number of phases
* holding torque
* step angle
* voltage per phase
* current per phase
* winding resistance, *R*<sub>*a*</sub>
* winding inductance, *L*<sub>*a*</sub>
* rotor inertia, *J*

The maximum detent torque, *T*<sub>*dm*</sub>, is not always specified. This parameter can be assumed to be equal to 1-10% of the maximum holding torque.

The maximum flux linkage, *ψ*<sub>*m*</sub>, is not always specified. This parameter can be obtained experimentally by driving the motor to a constant speed, *N*, in rpm, and by measuring the maximum open-circuit winding voltage, *E*<sub>*m*</sub>, in V.

The parameter ψ<sub>m</sub> is then computed by the following relation:

$$
ψm = (30/pπ)(Em/N)
$$

where *p* is the number of pole pairs given by *p* =360 / (2\_m\_·*step*). Here *m* = phase number, *step* = step angle in degrees.

## Ports

### Input

| <p><strong>TL</strong> — Mechanical load torque<br>Scalar</p> | Mechanical load torque, in N.m. `TL` is positive in motor operation and negative in generator operation. |
| ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |

### Output

<table data-header-hidden><thead><tr><th width="239.88885498046875"></th><th></th></tr></thead><tbody><tr><td><strong>m</strong> — Motor outputs<br>Vector of five elements</td><td>The Simulink<sup>®</sup> output of the block is a vector containing five signals. You can demultiplex these signals by using the Bus Selector block provided in the Simulink library.</td></tr></tbody></table>

<table data-header-hidden><thead><tr><th width="239.6666259765625"></th><th></th></tr></thead><tbody><tr><td><strong>Measurement signal name</strong></td><td><strong>Definition</strong></td></tr><tr><td><strong>1</strong></td><td>Phase voltage V<sub>ph</sub> (V)</td></tr><tr><td><strong>2</strong></td><td>Phase current I<sub>ph</sub> (A)</td></tr><tr><td><strong>3</strong></td><td>Electromagnetic torque T<sub>e</sub> (Nm)</td></tr><tr><td><strong>4</strong></td><td>Rotor speed w (rad/s)</td></tr><tr><td><strong>5</strong></td><td>Rotor position Theta (rad)</td></tr></tbody></table>

### Conserving

<table data-header-hidden><thead><tr><th width="240.22222900390625"></th><th></th></tr></thead><tbody><tr><td><strong>A+</strong> — Positive phase A<br>SPS electrical</td><td>SPS electrical conserving port associated with the positive terminal of phase A.</td></tr><tr><td><strong>A-</strong> — Negative phase A<br>SPS electrical</td><td>SPS electrical conserving port associated with the negative terminal of phase A.</td></tr><tr><td><strong>B+</strong> — Positive phase B<br>SPS electrical</td><td>SPS electrical conserving port associated with the positive terminal of phase B.</td></tr><tr><td><strong>B-</strong> — Negative phase B<br>SPS electrical</td><td>SPS electrical conserving port associated with the negative terminal of phase B.</td></tr><tr><td><strong>C+</strong> — Positive phase C<br>SPS electrical</td><td><p>SPS electrical conserving port associated with the positive terminal of phase C.</p><p><strong>Dependencies</strong> To enable this port, set the <strong>Motor type</strong> parameter to Variable reluctance and the <strong>Number of phases</strong> parameter to 3, 4, or 5.</p></td></tr><tr><td><strong>C-</strong> — Negative phase C<br>SPS electrical</td><td><p>SPS electrical conserving port associated with the negative terminal of phase C.</p><p><strong>Dependencies</strong> To enable this port, set the <strong>Motor type</strong> parameter to Variable reluctance and the <strong>Number of phases</strong> parameter to 3, 4, or 5.</p></td></tr><tr><td><strong>D+</strong> — Positive phase D<br>SPS electrical</td><td><p>SPS electrical conserving port associated with the positive terminal of phase D.</p><p><strong>Dependencies</strong> To enable this port, set the <strong>Motor type</strong> parameter to Variable reluctance and the <strong>Number of phases</strong> parameter to 4 or 5.</p></td></tr><tr><td><strong>D-</strong> — Negative phase D<br>SPS electrical</td><td><p>SPS electrical conserving port associated with the negative terminal of phase D.</p><p><strong>Dependencies</strong> To enable this port, set the <strong>Motor type</strong> parameter to Variable reluctance and the <strong>Number of phases</strong> parameter to 4 or 5.</p></td></tr><tr><td><strong>E+</strong> — Positive phase E<br>SPS electrical</td><td><p>SPS electrical conserving port associated with the positive terminal of phase E.</p><p><strong>Dependencies</strong> To enable this port, set the <strong>Motor type</strong> parameter to Variable reluctance and the <strong>Number of phases</strong> parameter to 5.</p></td></tr><tr><td><strong>E-</strong> — Negative phase E<br>SPS electrical</td><td><p>SPS electrical conserving port associated with the negative terminal of phase E.</p><p><strong>Dependencies</strong> To enable this port, set the <strong>Motor type</strong> parameter to Variable reluctance and the <strong>Number of phases</strong> parameter to 5.</p></td></tr></tbody></table>

## Parameters

<table data-header-hidden><thead><tr><th width="240.33331298828125"></th><th></th></tr></thead><tbody><tr><td><strong>Motor type</strong> — Type of motor<br>Permanent-magnet / Hybrid (default) | Variable reluctance</td><td>Option to implement a permanent-magnet/hybrid stepper motor or a variable-reluctance stepper motor.</td></tr><tr><td><strong>Number of phases</strong> — Number of phases to model<br>2 (default) | 3 | 4 | 5</td><td>Number of phases to model. If you set <strong>Motor type</strong> to Permanent-magnet / Hybrid, you can set this parameter only to 2 and 4. If you set <strong>Motor type</strong> to Permanent-magnet / Hybrid, you can set this parameter only to 3, 4, and 5.</td></tr><tr><td><strong>Maximum winding inductance (H)</strong> — Maximum inductance of each phase winding<br>10e-3 (default)</td><td><p>Maximum inductance, <em>L</em><sub><em>max</em></sub>, in H, of each phase winding.</p><p><strong>Dependencies</strong> To enable this parameter, set <strong>Motor type</strong> to Variable reluctance.</p></td></tr><tr><td><strong>Winding Inductance (H)</strong> — Inductance of each phase winding<br>10e-3 (default)</td><td><p>Inductance, in H, of each phase winding.</p><p><strong>Dependencies</strong> To enable this parameter, set <strong>Motor type</strong> to Permanent-magnet / Hybrid.</p></td></tr><tr><td><strong>Minimum winding inductance</strong> — Minimum inductance of each phase winding<br>2e-3 (default)</td><td><p>Minimum inductance, <em>L</em><sub><em>min</em></sub>, in H, of each phase winding.</p><p><strong>Dependencies</strong> To enable this parameter, set <strong>Motor type</strong> to Variable reluctance.</p></td></tr><tr><td><strong>Winding resistance (Ohm)</strong> — Resistance of each phase winding<br>1.2 (default)</td><td>Resistance, <em>R</em><sub><em>a</em></sub>, in ohms, of each phase winding.</td></tr><tr><td><strong>Maximum Flux Linkage (Vs)</strong> — Maximum flux linkage produced by magnets<br>0.04 (default)</td><td><p>Maximum flux linkage, <em>ψ</em><sub><em>m</em></sub>, in V.s, produced by the magnets</p><p><strong>Dependencies</strong> To enable this parameter, set <strong>Motor type</strong> to Permanent-magnet / Hybrid.</p></td></tr><tr><td><strong>Maximum Detent Torque (N.m)</strong> — Maximum detent torque from rotor saliency<br>0.02 (default)</td><td><p>Maximum detent torque, <em>T</em><sub><em>dm</em></sub>, in N.m, resulting from the saliency of the rotor.</p><p><strong>Dependencies</strong> To enable this parameter, set <strong>Motor type</strong> to Permanent-magnet / Hybrid.</p></td></tr><tr><td><strong>Step angle (degree)</strong> — Step angle of rotor movement<br><code>30</code> (default)</td><td>Step angle, in degrees, of the rotor movement.</td></tr><tr><td><strong>Total inertia (Kg.m.m)</strong> — Total inertia momentum of motor and load<br>1e-4/5 (default)</td><td>Total inertia momentum, <em>J</em>, in kg.m<sup>2</sup>, of the motor and the load.</td></tr><tr><td><strong>Total friction (N.m.s)</strong> — Total viscous friction coefficient of motor and load<br>1e-3 (default)</td><td>Total viscous friction coefficient, <em>B</em>, in N.m.s, of the motor and the load.</td></tr><tr><td><strong>Initial speed (rad/s)</strong> — Initial rotation speed<br>0 (default)</td><td>Initial rotation speed, <em>ω</em><sub><em>0</em></sub>, in rad/s.</td></tr><tr><td><strong>Initial position (degrees)</strong> — Initial rotor position<br>0 (default)</td><td>Initial rotor position, <em>Θ</em><sub><em>0</em></sub>, in degrees.</td></tr><tr><td><strong>Sample time (-1 for inherited)</strong> — Stepper motor sample time<br>–1 (default)</td><td>Stepper motor sample time, in s. Specify <code>–1</code> to inherit the sample time of the powergui block in your model.</td></tr></tbody></table>

## Examples <a href="#examples" id="examples"></a>

The [Stepper Motor Drive](https://www.opal-rt.com/docs/smart-power-simulation-software-sps/blocks-functions-tools/machines/blocks/stepper-motor.md) (power\_steppermotor) example illustrates the operation of a stepper motor drive using a two-phase hybrid stepper motor model.

## References <a href="#references" id="references"></a>

\[1] T. Kenjo, A. Sugawara, *Stepping Motors and Their Microprocessor Controls*, 2nd Edition, Oxford University Press, Oxford, 2003.

\[2] P. Acarnley, *Stepping Motors - A guide to theory and practice*, 4th Edition, The Institution of Electrical Engineers, London, 2002.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.opal-rt.com/docs/smart-power-simulation-software-sps/blocks-functions-tools/machines/blocks/stepper-motor.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
