> 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/basics/grounds/current-voltage-simscape-interface.md).

# Current Voltage Simscape Interface

## Description

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

The **Current Voltage Simscape Interface** bloc&#x6B;**,** located in the **OPAL-RT SPS Software/Utilities** library, connects SPS Software circuits with electrical elements from the Simscape Foundation library. This block preserves current through the block and voltage across the block, conserving electrical power.

* On the SPS Software side, the electrical connector ports +sps and -sps act like a controlled current source, feeding current from the Simscape Electrical side to the connected SPS Software elements, while maintaining the voltage across the block.
* On the Simscape Electrical side, the electrical connector ports +ssc and -ssc act like a controlled voltage source, feeding voltage from the SPS Software side to the connected Simscape Electrical elements, while maintaining the current through the block. The following figure gives an overview of the interface.
*

```
<figure><img src="../../../.gitbook/assets/current_voltage_simscape_interface_example.png" alt=""><figcaption></figcaption></figure>
```

The block measures the voltage between the +sps and -sps ports and propagates it to the +ssc and -ssc ports, preserving the polarity. The block also measures the current flowing from the +ssc to the -ssc port and propagates it from the -sps to the +sps port.

You can specify a filter to break the algebraic loop between SPS Software and Simscape Electrical ports. You can specify the filter as a first order continuous transfer function or as a discrete unit delay block. You can apply it on the SPS Software side, to the measured voltage, or on the Simscape Electrical side, to the measured current. Depending on the measured signal where the filter is applied, the other signal is always a direct feedthrough.

If you do not specify a filter, direct feedthrough is applied on both measured signals. However, this configuration results in an algebraic loop containing the Voltage Measurement, Controlled Voltage Source, Current Sensor, and Controlled Current Source blocks, which might cause numerical issues.

## Ports

### Conserving

<table data-header-hidden><thead><tr><th width="241.99993896484375"></th><th></th></tr></thead><tbody><tr><td><strong>+sps</strong> — Positive terminal of SPS Software circuit<br>SPS electrical</td><td>SPS electrical conserving port associated with the positive terminal of the SPS Software circuit.</td></tr><tr><td><strong>-sps</strong> — Negative terminal of SPS Software circuit<br>SPS electrical</td><td>SPS electrical conserving port associated with the negative terminal of the SPS Software circuit.</td></tr><tr><td><strong>+ssc</strong> — Positive terminal of Simscape Electrical circuit<br>Simscape electrical</td><td>Simscape electrical conserving port associated with the positive terminal of the Simscape Electrical circuit.</td></tr><tr><td><strong>-ssc</strong> — Negative terminal of Simscape Electrical circuit<br>Simscape electrical</td><td>Simscape electrical conserving port associated with the negative terminal of the Simscape Electrical circuit.</td></tr></tbody></table>

### Output

<table data-header-hidden><thead><tr><th width="209.99993896484375"></th><th></th></tr></thead><tbody><tr><td><strong>m</strong> — Measurement port<br>Simulink signal</td><td><p>Bus signal that contains the SPS current and voltage and the Simscape current and voltages.</p><p><strong>Dependencies</strong> To enable this port, select the <strong>Show measurement ports</strong> parameter.</p></td></tr></tbody></table>

### Parameters

<table data-header-hidden><thead><tr><th width="262.7999267578125"></th><th></th></tr></thead><tbody><tr><td><strong>Direct feedthrough (no filter)</strong> — Direct feedthrough<br>off (default) | on</td><td>When you select this parameter, the block applies direct feedthrough between SPS and Simscape ports on both sides.</td></tr><tr><td><strong>Filter type</strong> — Type of filter<br>Low pass filter (continuous) (default) | Unit delay (discrete) | First-order input filtering | Second-order input filtering</td><td><p>Set this parameter to Low pass filter (continuous) (default) to implement a first order continuous transfer function filter between SPS and Simscape ports. Set this parameter to Unit delay (discrete) to implement a discrete unit delay filter between SPS and Simscape ports. Set this parameter to First-order input filtering to implement a first order continuous transfer function filter with first-order filtering of the Simulink-PS Converter block that provides one derivative. You can apply this filter only on the SPS side. Set this parameter to Second-order input filtering to implement a first order continuous transfer function filter with second-order filtering of the Simulink-PS Converter block that provides derivatives one and two. You can apply this filter only on the SPS side.</p><p><strong>Dependencies</strong> To enable this parameter, clear the <strong>Direct feedthrough (no filter)</strong> parameter.</p></td></tr><tr><td><strong>Low pass filter time constant (s)</strong> — Time constant of low pass filter<br>1e-6 (default) | positive scalar</td><td><p>Time constant of low pass filter, in seconds.</p><p><strong>Dependencies</strong> To enable this parameter, set <strong>Filter type</strong> to Low pass filter (continuous), First-order input filtering, or Second-order input filtering.</p></td></tr><tr><td><strong>Sample time (s)</strong> — Sample time of unit delay filter<br>50e-6 (default) | positive scalar</td><td><p>Sample time of the unit delay filter, in seconds.</p><p><strong>Dependencies</strong> To enable this parameter, set <strong>Filter type</strong> to Unit delay (discrete).</p></td></tr><tr><td><strong>Initial voltage (V)</strong> — Initial voltage<br>0 (default) | nonnegative scalar</td><td><p>Initial voltage value of the measured SPS voltage.</p><p><strong>Dependencies</strong> To enable this parameter, set <strong>Apply filter on</strong> to SPS side.</p></td></tr><tr><td><strong>Initial current (A)</strong> — Initial current<br>0 (default) | nonnegative scalar</td><td><p>Initial current value of the measured Simscape current.</p><p><strong>Dependencies</strong> To enable this parameter, set <strong>Apply filter on</strong> to Simscape side.</p></td></tr><tr><td><strong>Apply filter on</strong> — Side to apply the filter on<br>inf (default) | nonnegative scalar</td><td><p>Set this parameter to SPS side to apply the filter on the measured SPS voltage. Set this parameter to Simscape side to apply the filter on the measured Simscape current.</p><p><strong>Dependencies</strong> To enable this parameter, clear the <strong>Direct feedthrough (no filter)</strong> parameter and set <strong>Filter type</strong> to Low pass filter (continuous) or Unit delay (discrete).</p></td></tr><tr><td><strong>Show measurement port</strong> — Option to show measurement port<br>off (default) | on</td><td>If selected, the block exposes a Simulink output that returns the SPS current and voltage and to the Simscape current and voltages in a bus signal.</td></tr></tbody></table>

### Limitations

When simulating SPS Software models along with Simscape Electrical blocks, select the Simulink solver carefully.

Use `ode23tb` solver for solving SPS Software circuits containing switches or nonlinear element. If you use other stiff solvers, SPS Software gives you the following warning:

> Warning: You have required continuous-time simulation of a system containing\` \`switches or nonlinear elements. The ode23tb variable-step stiff solver with\` \`relative tolerance set to 1e-4 is recommended in order to get best accuracy\` \`and simulation performance. For some highly nonlinear models it may be\` \`necessary to set the "Solver reset method" parameter to "Robust".\` \`See "Improving Simulation Performance" chapter in SPS documentation for\` \`additional information on how to select an appropriate integration method.\` \`'To ignore SPS warnings, select "Disable Simscape Electrical SPS warnings"\` \`in the Powergui Preferences tab.';

The SPS Software warning can be disabled, as described in the warning message. However, if you use the ode23tb solver for solving models containing Simscape Electrical blocks, Simscape Electrical software gives you the following warning:

> Warning: The solver chosen is not recommended if the model is stiff, which is\` \`typical for models containing Simscape components. These solvers are typically\` \`preferred for Simscape models:ode23t, ode15s or ode14x (fixed-step). To disable\` \`this diagnostic,
>
> change the explicit solver diagnostic setting on the Simscape\` \`panel of the model Configuration Parameters.

The Simscape Electrical warning can also be disabled, as described in the warning message.


---

# 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/basics/grounds/current-voltage-simscape-interface.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.
