> 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/hypersim/model-and-simulation/create-oem-controller-code/integrate-controller-into-hypersim.md).

# Integrate Controller into HYPERSIM

## Overview

HYPERSIM supports four standardized approaches for integrating OEM controller code into real-time simulations. Each approach leverages the User Code Module (UCM) framework, providing a unified mechanism for code integration, real-time execution, IP protection, and performance optimization.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-efb6bb9c2989a6b550360f2c6f3265933630bfea%2Foem-integration-approches.jpg?alt=media" alt=""><figcaption></figcaption></figure>

## IEEE/CIGRÉ B4.82 dll interface - Recommended

The IEEE/CIGRÉ B4.82 working group introduced TB 958, a standardized framework for integrating OEM controller code into EMT simulation platforms. Building on standards such as IEC 61400-27-1, it improves interoperability, flexibility, and cross-platform compatibility.

Under this approach, OEMs package their controller logic as a CIGRÉ-compliant dynamic library (typically a .dll file) that follows a standardized interface defining:

* Function signatures
* Inputs, outputs, and parameters
* An execution interface for offline and real-time simulation

HYPERSIM supports version 1.1 of the standard through the dedicated [**CIGRÉ Interface block**](https://www.opal-rt.com/docs/hypersim/library-blocks-reference/control-interfaces/cigre-interface.md), enabling seamless integration of compliant controller models. This standardization enables the same controller binary to be used across multiple simulation platforms, eliminating the need to maintain tool-specific code versions. It also promotes consistent execution behavior and simplifies model validation and benchmarking across Software-in-the-Loop (SIL) and Hardware-in-the-Loop (HIL) environments.

The CIGRÉ interface is particularly well suited for OEMs that already comply with the standard or can expose their models through the defined API. This approach streamlines integration, improves model fidelity, and facilitates collaboration among utilities, equipment manufacturers, and simulation tool providers.

### Key features

* Standardized API for controller integration across simulation software
* Automated process to integrate CIGRÉ library into HYPERSIM
* Supports dynamic parameterization and signal mapping
* Version 1.1 of the IEEE/CIGRÉ B4.82 recommendations

### Usages

* OEMs providing standardized controller libraries to utilities and integrators
* Accelerating model deployment by reusing certified control binaries
* Supporting regulator-mandated testing and multi-vendor interoperability​​

## Simulink-generated code

HYPERSIM supports the integration of code generated from Simulink models using standard workflows. This approach differs from the UCM-based methods in that the generated code is structured and packaged by Simulink's code generation tools.

This is a preferred method for teams with Simulink development workflows who seek minimal adaptation effort.

### Key features

* Automatically generated C code via Simulink Coder or Embedded Coder
* Automated process to integrate Simulink library into HYPERSIM
* MATLAB versions: R2015b to R2024a
* Tunable parameters
* Compatible with various Simulink toolboxes, such as Simscape or SPS Software (formerly SimPowerSystems)
* Multiple rates within one model
* Multiple time step code generation

### Usages

* Seamless for Simulink users familiar with code generation
* No manual UCM configuration required
* Real-time compatible if code is generated with proper constraints

## User Code Module (UCM) interface

The [**User-Coded Model (UCM)**](https://www.opal-rt.com/docs/hypersim/model-and-simulation/import-models-from-external-software-or-code/create-user-coded-models-ucm.md) is HYPERSIM's most flexible framework for integrating external code. It allows users to incorporate custom or precompiled C, C++, and Fortran code directly into the simulation environment.

UCM blocks are created using the UCM Builder, where users define inputs, outputs, parameters, and execution routines such as initialization and real-time calculations. UCMs can also load and execute external dynamic libraries (for example, .dll or .so files) through standard operating system APIs, enabling seamless integration of existing controller implementations and proprietary code.

### Key features

* Direct C/Fortran code execution (source or binary)
* Customizable input and output parameters
* Allow to simulate control logic and electrical behavior
* Fully customizable block behavior
* Support for initialization, step execution, and finalization routines (and more)
* Ideal for users with access to source code or self-contained libraries

### Usages

* Direct integration of OEM code where no standard wrapper is available
* Rapid prototyping of new control algorithms in C or Fortran
* Ideal for developers needing full transparency and control over execution phases​

## FMI (Functional Mock-up Interface) - Comming soon

The **Functional Mock-up Interface (FMI)** is an open standard developed by the Modelica Association for the exchange and co-simulation of dynamic models across simulation platforms. Originally created through the MODELISAR project, FMI has become widely adopted across engineering disciplines, including power systems, as a tool-independent method for integrating and deploying dynamic models.

Under this standard, an OEM controller is packaged as a **Functional Mock-up Unit (FMU)**, a self-contained archive that typically includes:

* A compiled shared library (for example, .dll or .so)
* A standardized XML model description
* Optional resources such as configuration files and documentation

The XML file defines the controller interface, including its inputs, outputs, parameters, and execution functions. To comply with the FMI standard, the controller must implement the required lifecycle functions, such as initialization, execution, and termination.

HYPERSIM supports FMI through a dedicated FMU Interface block, enabling users to import and execute validated FMUs directly within the simulation environment.

FMI is particularly well suited for OEMs that already use FMU-based workflows or need to deploy models across multiple simulation platforms. The standardized FMU format facilitates model reuse, simplifies integration, and preserves model structure, making it an effective solution for validation and deployment in both Software-in-the-Loop (SIL) and Hardware-in-the-Loop (HIL) applications.

### Key features

* Standardized format for tool-independent code reuse
* Supports Co-Simulation (CS)
* Supports parameter tuning and signal interfacing
* Allows mixing of FMUs with native HYPERSIM models and other control interfaces
* FMI v2.0 (most common) – v3.0
* Co-Simulation (CS) mode: FMU runs with its solver/scheduler

### Usages

* Integration of third-party FMUs into EMT simulations
* Deployment of vendor-neutral controller libraries into SIL or HIL workflows
* Flexible co-simulation scenarios involving other simulation engines or tools
* Interoperability with tools like Dymola, OpenModelica, and AMESim


---

# 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/hypersim/model-and-simulation/create-oem-controller-code/integrate-controller-into-hypersim.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.
