> 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/pe-add-on-simulink/examples/scim-local-control.md).

# SCIM Local Control

## Description

The **SCIM Local Control** example demonstrates an open-loop control implementation for a 220-horsepower squirrel-cage induction machine.

The example is available as two separate VeriStand projects, one providing support for the PXIe-7868R FPGA card and the other for the PXIe-7891 FPGA card. Both projects demonstrate the same concepts and behave almost identically.

## Detailed explanation

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2FeM3enraayDhkMtXw3JJl%2FSCIM%20local%20controler.jpg?alt=media&amp;token=683eb415-c253-466c-a7a6-4434cdac0319" alt=""><figcaption><p>Components of the SCIM Local Control example</p></figcaption></figure>

* On the target FPGA, the **eHS Solver** simulates a three-phase, two-level inverter that drives the **Induction Machine / Synchronous Machine** **IM SM** machine model.

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2FmjadhkalBERfd43ZizPf%2Fimage.png?alt=media&amp;token=528a10e6-b0ba-46b1-a941-21fa1691375a" alt=""><figcaption><p>Inverter_SCIM</p></figcaption></figure>

* A unidirectional **Voltage/frequency controller** runs on the real-time CPU, sending gating signals to the inverter through the FPGA-based **PWM Generators**.

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2FSR68ExspC2ao3Noqfnzq%2Fimage.png?alt=media&amp;token=927242b7-cd17-4feb-9135-dd3936acea12" alt=""><figcaption><p>Scalar Controller</p></figcaption></figure>

## Configuration

<details>

<summary><strong>Hardware Configuration</strong></summary>

* In the Configuration Tree, expand **Controller >> Custom Devices** and click the **Power Electronics Add-On** custom device to open its configuration page.
* The **Hardware Configuration** selected in the **Configuration** dropdown depends on the FPGA card targeted by the project.

| NI FPGA Card      | Hardware Configuration                           |
| ----------------- | ------------------------------------------------ |
| **NI PXIe-7868R** | eHSx64\_Quad\_IM\_SM\_IO\_7868R                  |
| **NI PXIe-7891**  | eHSx64\_Dual\_PMSM\_VDQ\_Quad\_IM\_SIM\_IO\_7891 |

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2FunZWCt67jsPuYnZd56gd%2Fimage.png?alt=media&amp;token=177aa279-f5ca-465c-8759-49369608dde0" alt="" width="563"><figcaption></figcaption></figure>

</details>

<details>

<summary><strong>Circuit Model</strong></summary>

The **Circuit Model** in this example consists of a three-phase, two-level inverter, complete with the necessary components and snubbers for coupling to a machine model. The inverter is powered by a DC voltage source.

1. In the Configuration Tree, expand **Power Electronics Add-On** and click **Circuit Model.**
2. The **Circuit Model File Path** points to the currently loaded Circuit Model. Open the file in Simulink to observe the circuit.

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2F5N6fMrBTY96t7fIYpRrp%2Fimage.png?alt=media&amp;token=e7c4f330-4817-4c2b-ac97-397a3ae2912c" alt="" width="563"><figcaption></figcaption></figure>

</details>

<details>

<summary><strong>Sources</strong></summary>

The **Sources page** maps signals to each source of the circuit model. In this example, the machine phase currents are fed back to the inverter. The two halves of the DC voltage source are controlled using VeriStand channels.

* In the Configuration Tree, expand **Circuit Model** and click **Sources**. This page is populated with a list of sources from the circuit model.
* The mappings are configured as shown below.

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2FVyxIdj9Ualeb77J8aDkY%2Fimage.png?alt=media&amp;token=bcda8997-a3dd-423c-8d75-34a3643ca004" alt="" width="563"><figcaption></figcaption></figure>

</details>

<details>

<summary><strong>Switches</strong></summary>

The **Switches page** maps signals to each switch of the circuit model. In this example, the six inverter switches are controlled using the FPGA-based **PWM Generators**.

* In the Configuration Tree, expand **Circuit Model** and click **Switches**. This page is populated with a list of switches from the circuit model.
* The mappings are configured as shown below.

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2FEOy7HzeSFdL4z1EtlWcR%2Fimage.png?alt=media&amp;token=88bfc70d-f8ab-42b8-aac3-5cf1e922c582" alt="" width="563"><figcaption></figcaption></figure>

</details>

<details>

<summary><strong>Machine model</strong></summary>

In this example, the **IM SM** model simulates a 220-Horsepower, 550-Volt squirrel cage induction machine. The model receives three phase voltages from the two-level inverter **Circuit Model** also simulated on the FPGA.

* In the configuration tree, expand **Circuit Model** and click **IM SM 1** to open the configuration page for the machine.\
  The unused models, **IM SM 2**, **IM SM 3**, and **IM SM 4**, are disabled to allow **IM SM 1** to achieve a **Minimum Solver Timestep** of 1.2E-7s.
* The **Machine Configuration** and **Input Mapping Configuration** parameters are configured as summarized below.

| Machine configuration parameters  | Value                           |
| --------------------------------- | ------------------------------- |
| **Machine Type**                  | Squirrel-Cage Induction Machine |
| **Stator Resistance (Ohm)**       | 0.0256                          |
| **Stator Leakage Inductance (H)** | 0.00032879                      |
| **Rotor Resistance (Ohm)**        | 0.0207                          |
| **Rotor Leakage Inductance (H)**  | 0.00032879                      |
| **Pole Pairs**                    | 2                               |
| **Mutual Inductance (H)**         | 0.0133                          |
| **Zero-Sequence**                 | Don't Include                   |
| **Solver Timestep (s)**           | 1.2E-7                          |

| Input Mapping Configuration | Value                   |
| --------------------------- | ----------------------- |
| **Voltage Phase A**         | Circuit Model 1.Va\_inv |
| **Voltage Phase B**         | Circuit Model 1.Vb\_inv |
| **Voltage Phase C**         | Circuit Model 1.Vc\_inv |

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2FNBOYkpgWw8dwMR0S3eMy%2Fimage.png?alt=media&amp;token=2b4307f4-1b8f-4c4f-a361-a9e4446e872b" alt="" width="563"><figcaption></figcaption></figure>

**For the mechanical model:**

* In the configuration tree, expand **IM SM 1** and click **Mechanical Model** to view the mechanical model parameters.
* In the configuration tree, expand **Mechanical Model** and click the **Mechanical Model Mode** channel. The **Default Value** of the **Mechanical Model Mode** channel is set to 1 (Torque Controlled).
* The **Initial Values** and **Configuration** parameters are configured as summarized below.

| Mechanical Model - Configuration parameters | Value  |
| ------------------------------------------- | ------ |
| **Viscous Damping**                         | 0.0489 |
| **Static Friction**                         | 0      |
| **Inertia**                                 | 2.5239 |

| Mechanical Model Mode - Initial Values parameter | Value |
| ------------------------------------------------ | ----- |
| **Initial Rotor Angle (Deg)**                    | 1     |

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2FsQ5XNPHvGOw3bJwD4zBL%2Fimage.png?alt=media&amp;token=64ba190c-0281-429b-bd29-619a8850520d" alt="" width="563"><figcaption></figcaption></figure>

</details>

<details>

<summary><strong>PWM Generators</strong></summary>

In this example, the FPGA-based **PWM Generators** control the six IGBTs of the simulated inverter at a switching frequency of 2000Hz. The duty cycle of each PWM is commanded by the simulated controller.

* In the configuration tree, expand **Circuit Model** and click **PWM Generators**.
* The **PWM Generators** parameters for **PWM 0**, **PWM 1**, and **PWM 2** are configured as summarized below.

| PWM Generators parameters | Value      |
| ------------------------- | ---------- |
| **Freq (Hz)**             | 2000       |
| **Duty Cycle**            | 0%         |
| **Dead Time (s)**         | 1E-7       |
| **Phase Shift**           | 0          |
| **Polarity**              | High       |
| **Wave Mode**             | Asymmetric |
| **Update Moment**         | Both       |

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2FCBg8VgTMmsYP0JSCt0YB%2Fimage.png?alt=media&amp;token=ee5d1eb1-ebda-463a-9c9a-36db8e4fb141" alt=""><figcaption></figcaption></figure>

</details>

<details>

<summary><strong>Waveform Channels</strong></summary>

**Waveform Channels** allow signals to be streamed from the FPGA at a rate faster than that of the CPU execution.

* In the Configuration Tree, expand **Circuit Model** and click **Waveforms**.
* The signals in the example are mapped to the Waveform channels as shown below. The data from these channels will be streamed at the **Sample Rate (S/s)** specified at the bottom of the page.

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2F1YC6EYXtBCDD0s6IFGBK%2Fimage.png?alt=media&amp;token=c1908ea7-0710-417f-bb32-72979c6b59d4" alt="" width="563"><figcaption></figcaption></figure>

</details>

<details>

<summary><strong>Local Controller</strong></summary>

The squirrel cage induction machine simulated in this example is controlled using an **open-loop scalar controller**. The controller logic is pre-compiled and the model must be executed at a rate of 10kHz on the real time CPU of the target. The source code for the controller model has also been made available.

* In the configuration tree, navigate to **Targets >> Controller,** the **Target Rate** is set to 10000Hz.
* In the configuration tree, expand **Simulation Models >> Models.** The **Controller** model in the project has been loaded from the file path shown below and is configured to run at 10kHz.
* Expand **Controller >> Inports**. The **Default Value** of the **PolePairs** channel is 2 and the **Default Value** of the **RampRate** channel is 750.

**Controller Model File Path:** *\<SCIM Local Control>\Local Controller\libScalarController.so*

**Controller Source Code File Path:** *\<SCIM Local Control>\Local Controller\ScalarController.slx*

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2FaJsO7hqrvfNsklRNJPht%2Fimage.png?alt=media&amp;token=074640dc-bdee-4588-b327-eabfc9b905e5" alt="" width="563"><figcaption></figcaption></figure>

</details>

<details>

<summary><strong>VeriStand Channel Mapping</strong></summary>

Signals and channels external to the **Power Electronics Add-On** custom device, such as the inputs and outputs of the **Local Controller** model, can be mapped to other channels in the System Definition file.

In this example, the duty cycle commands from the Local Controller are mapped to the **Duty Cycle** channels of the three **PWM Generators**. The Vdc\_link measurement from the **Circuit Model** is also mapped back to the Local Controller. The mapping diagram is shown below.

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2F0zKPnv0OQyhKxQlj5VkG%2Fimage.png?alt=media&amp;token=4411ecb0-05ae-4eb9-961b-3ce256fde769" alt=""><figcaption></figcaption></figure>

</details>

## Simulation

Open the VeriStand Screen (Mai&#x6E;*.nivsscr*) files and manipulate the parameters in the blue boxes to observe the resulting output signals.

The configuration information displayed in grey is for informational purposes only; these parameters can only be modified from the System Definition file while the project is undeployed.

To control the machine, configure the **Speed Setpoint** to a value between 0 and 1800RPM. Note that the controller model used in this example is unidirectional and does not support negative speeds. Observe the **Speed** and **Stator Current** responses of the machine.

Apply a **Load Torque** to the machine and observe its effects on the **Electromagnetic Torque** and **Slip**.

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2F45EoJ5jlwPWOrBd5wEHr%2Fimage.png?alt=media&amp;token=0f0008db-c687-4ad6-a4b3-58160ddced04" alt=""><figcaption></figcaption></figure>


---

# 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/pe-add-on-simulink/examples/scim-local-control.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.
