> 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/library-specific-guides/motor-drives/building-your-own-drive.md).

# Building Your Own Drive

## Introduction

The following information describes how to build a motor drive model using Simulink® and SPS blocks. You will build the field-oriented-control motor drive, very similar to the AC3 model. The following figure shows the block diagram of the drive.

<figure><img src="https://799605156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdlNg8IbOdahCpFCyzxSN%2Fuploads%2Fgit-blob-0c4c9c7daed39ed568900973bcdd33d7fe8b5454%2Fimage.png?alt=media" alt=""><figcaption><p>Field-Oriented Variable-Frequency Induction Motor Drive</p></figcaption></figure>

## Description of the Drive

The induction motor is fed by a current-controlled PWM inverter, which operates as a three-phase sinusoidal current source. The motor speed ω is compared to the reference ω\* and the error is processed by the speed controller to produce a torque command Te\*.

As shown below, the rotor flux and torque can be separately controlled by the stator direct-axis current i<sub>ds</sub> and quadrature-axis current i<sub>qs</sub>, respectively.

<figure><img src="https://799605156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdlNg8IbOdahCpFCyzxSN%2Fuploads%2Fgit-blob-5e528308ac719cb2c1091e7fdc52a126ae9f9768%2Fimage.png?alt=media" alt=""><figcaption><p>Field-Oriented Control Principle</p></figcaption></figure>

The stator quadrature-axis current reference i<sub>qs</sub>\* is calculated from torque reference T<sub>e</sub>\* as

$$
i\_{qs}^\* = \frac{2}{3} \cdot \frac{2}{p} \cdot \frac{L\_r}{L\_m} \cdot \frac{T\_e^\*}{|\psi\_r|\_{\text{est}}}
$$

where L<sub>r</sub> is the rotor inductance, L<sub>m</sub> is the mutual inductance, and |ψ<sub>r</sub>|<sub>est</sub> is the estimated rotor flux linkage given by

$$
|\psi\_r|*{\text{est}} = \frac{L\_m \cdot i*{ds}}{1 + \tau\_r \cdot s}
$$

where τ<sub>r</sub> = L<sub>r</sub>/ R<sub>r</sub> is the rotor time constant.

The stator direct-axis current reference i<sub>ds</sub>\* is obtained from rotor flux reference input |ψ<sub>r</sub>|\*.

$$
i\_{ds}^\* = \frac{|\psi\_r|^\*}{L\_m}
$$

The rotor flux position Θ<sub>e</sub> required for coordinates transformation is generated from the rotor speed ω<sub>m</sub> and slip frequency ω<sub>sl</sub>.

$$
\theta\_e = \int (\omega\_m + \omega\_{sl}), dt
$$

The slip frequency is calculated from the stator reference current i<sub>qs</sub>\* and the motor parameters.

$$
\omega\_{sl} = \frac{L\_m}{|\psi\_r|*{\text{est}}} \cdot \frac{R\_r}{L\_r} \cdot i*{qs}^\*
$$

The i<sub>qs</sub>\* and i<sub>ds</sub>\* current references are converted into phase current references i<sub>a</sub>\**, i*<sub>*b*</sub>*\**, i<sub>c</sub>\* for the current regulators. The regulators process the measured and reference currents to produce the inverter gating signals.

The role of the speed controller is to keep the motor speed equal to the speed reference input in steady state and to provide a good dynamic during transients. The controller can be a proportional-integral type.

#### Modeling the Induction Motor Drive

Open the power\_acdrive model and save it as case3 in your working directory so that you can make further modifications without altering the original file.

The next figure shows the power\_acdrive model in which blocks from SPS and Simulink libraries are used to model the induction motor drive.

<figure><img src="https://799605156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdlNg8IbOdahCpFCyzxSN%2Fuploads%2Fgit-blob-bea3efe185a97c07dbf8b02adc607e78b348e0bb%2Fimage.png?alt=media" alt=""><figcaption><p>Vector Control of AC Motor Drive (power_acdrive)</p></figcaption></figure>

The induction motor is modeled by an [Asynchronous Machine](https://www.opal-rt.com/docs/smart-power-simulation-software-sps/blocks-functions-tools/machines/blocks/asynchronous-machine.md) block. The motor used in this case study is a 50 HP, 460 V, four-pole, 60 Hz motor having the following parameters:

| **Rs**  | `0.087` Ω |
| ------- | --------- |
| **Lls** | `0.8 mH`  |
| **Lm**  | `34.7 mH` |
| **Rr**  | `0.228` Ω |
| **Llr** | `0.8 mH`  |

The reference speed and the load torque applied to the motor shaft can be both selected by a Manual Switch block in order to use either a constant value or a step function. Initially the reference speed is set to a constant value of 120 rad/s and the load torque is also maintained constant at 0 N.m

The field-oriented control is modeled by the Vector Control block, as shown in [Vector Control of AC Motor Drive (power\_acdrive)](https://opal-rt.atlassian.net/wiki/spaces/PSPS/pages/1551827498/Building+Your+Own+Drive#Vector-Control-of-AC-Motor-Drive-\(power_acdrive\)). This block consists of Simulink blocks shown in the following figure.

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

The IGBT inverter is modeled by a [Universal Bridge](https://opal-rt.atlassian.net/wiki/spaces/PSPS/pages/1551828422/Universal+Bridge) block in which the **Power Electronic device** and **Port configuration** options are selected as `IGBT/Diode` and `ABC` as output terminals respectively. The DC link input voltage is represented by a 780 V DC voltage source.

The current regulator consists of three hysteresis controllers and is built with Simulink blocks. The motor currents are provided by the measurement output of the [Asynchronous Machine](https://opal-rt.atlassian.net/wiki/spaces/PSPS/pages/1551697577/Asynchronous+Machine) block.

The conversions between abc and dq reference frames are executed by the [abc\_to\_dq0 Transformation](https://opal-rt.atlassian.net/wiki/spaces/PSPS/pages/1551797693/abc_to_dq0+Transformation) and [dq0\_to\_abc Transformation](https://opal-rt.atlassian.net/wiki/spaces/PSPS/pages/1551699202/dq0_to_abc+Transformation) blocks

**abc\_dq**

**dq\_abc**

The rotor flux is calculated by the Flux\_Calculation block.

The rotor flux position (Θe) is calculated by the Teta Calculation in [Vector Control Block](https://opal-rt.atlassian.net/wiki/spaces/PSPS/pages/1551827498/Building+Your+Own+Drive#Vector-Control-Block). The motor speed is provided by the measurement output of the [Asynchronous Machine](https://opal-rt.atlassian.net/wiki/spaces/PSPS/pages/1551697577/Asynchronous+Machine) block.

The stator quadrature-axis current reference (iqs\*) is calculated by the iqs\*\_Calculation block.

The stator direct-axis current reference (ids\*) is calculated by the id\*\_Calculation block.

The speed controller is of proportional-integral type and is implemented using Simulink blocks.

## Simulating the Induction Motor Drive

In order to increase simulation speed, this model is discretized using a sample time of 2 µs. The variable `Ts = 2e-6` automatically loads into your workspace when you open this model. This sample time Ts is used both for the power circuit (`Ts` specified in the Powergui) and the control system.

Run the simulation.

The motor voltage and current waveforms as well as the motor speed and torque are displayed on four axes of the scope connected to the variables Vab, Iabc, ωm, and Te.

#### Starting the Drive

You can start the drive by specifying `[1,0,0,0,0,0,0,0]` as the initial conditions for the [Asynchronous Machine](https://opal-rt.atlassian.net/wiki/spaces/PSPS/pages/1551697577/Asynchronous+Machine) block (initial slip = 1 and no currents flowing in the three phases). The speed reference is 120 rad/s.

The motor speed, electromechanical torque, and currents observed during the starting of the induction motor drive are shown in [Starting the Induction Motor Drive](https://opal-rt.atlassian.net/wiki/spaces/PSPS/pages/1551827498/Building+Your+Own+Drive#Starting-the-Induction-Motor-Drive).

Note that you can save the final system state vector and use it as the initial state in a subsequent simulation so that the simulation can start under steady-state conditions.

**Starting the Induction Motor Drive**

#### Steady-State Voltage and Current Waveforms

When the steady state is attained, you can stop the simulation and zoom on the scope signals.

This figure shows the motor voltage, current, and torque waveforms obtained when the motor is running at no load (torque = 0 N.m) at a speed of 120 rad/s.

The 20 A band imposed by the hysteresis current regulator is clearly seen on the three motor currents.

**Steady-State Motor Current, Voltage, and Torque Waveforms**

#### Speed Regulation Dynamic Performance

You can study the drive dynamic performance (speed regulation performance versus reference and load torque changes) by applying two changing operating conditions to the drive: a step change in speed reference and a step change in load torque.

Use the Reference Speed selection switch and the Torque selection switch to set speed reference steps from 120 rad/s to 160 rad/s at t = 0.2 s and the load torque steps from 0 N.m to 200 N.m at t = 1.8 s. The final state vector obtained with the previous simulation can be used as the initial condition so that the simulation starts from steady state. Load the `power_acdrive_init.mat` file, which creates the `xInitial` variable. In the **Simulation** tab, click **Model Settings**. Select **Data Import/Export**. Select **Initial state** and then click **OK**. Restart the simulation.

The response of the induction motor drive to successive changes in speed reference and load torque is shown here.

**Dynamic Performance of the Induction Motor Drive**

## **References**

\[1] Leonhard, W., *Control of Electrical Drives*, Springer-Verlag, Berlin, 1996.

\[2] Murphy, J. M. D., and Turnbull, F. G., *Power Electronic Control of AC Motors*, Pergamon Press, Oxford, 1985.

\[3] Bose, B. K., *Power Electronics and AC Drives*, Prentice-Hall, Englewood Cliffs, N.J., 1986.


---

# 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/library-specific-guides/motor-drives/building-your-own-drive.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.
