> 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/rt-lab/simulink-blocks-reference/efpgasim-library/simulink-sps-workflow/power-measurement-controller.md).

# Power Measurement Controller

## Description

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-e44179d2e7d4562eb63ef1d75206d23534057837%2Fsps-ehs-power-measurement-controller-block.png?alt=media" alt=""><figcaption></figcaption></figure>

The **Power Measurement Controller** block, located in the **eFPGAsim/External circuit editor workflow/Monitoring** library, is used to get the instantaneous power on FPGA target.

It can be used with :

* SPS workflow
* Schematic Editor with S-Function workflow only

The firmware under use must have the RMS feature.

Communication is done between CPU and FPGA as follow :

* CPU → FPGA : Through the given LoadIn port specified in the Mask Parameters, the CPU transmits to the Power Measurement FPGA addon on which eHS outputs to perform calculation
* FPGA → CPU : Through the given DataOut port specified in the Mask Parameters, the FPGA transmits to the CPU Power Measurement Configuration block the results of computation

These port numbers are specified both in the firmware documentation and in the .conf file associated to the firmware.

## Mask parameters

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-a185d5e824145d553229d6aeb039332141c069ac%2Fsps-ehs-power-measurement-controller-mask.png?alt=media" alt="" width="392"><figcaption></figcaption></figure>

| Parameter                        | Description                                                                                                                                                                                                               |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Current Indices**              | One based vector where values are corresponding to eHS CPU block outputs indexes. These signals will be multiplied and accumulated one by one with the signal of **Voltage Indices** having the same index in the vector. |
| **Voltage Indices**              | One based vector where values are corresponding to eHS CPU block outputs indexes. These signals will be multiplied and accumulated one by one with the signal of **Current Indices** having the same index in the vector. |
| **Controller Name**              | Name of the OpCtrl Controller name which defines the FPGA by which the feature is provided.                                                                                                                               |
| **LoadIn port number \[1..32]**  | LoadIn port number of the feature. Specified both in the firmware documentation and in the .conf file associated to the firmware.                                                                                         |
| **DataOut port number \[1..32]** | DataOut port number of the feature. Specified both in the firmware documentation and in the .conf file associated to the firmware.                                                                                        |

## Inputs

This block has no inputs

## Outputs

| Output                | Description                                                                                                                                   |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| **PowerMeasurements** | A vector with the same size as **Current Indices** and **Voltage Indices.**                                                                   |
| **Config**            | This output displays the configuration stream to send to the feature to configure it. It reflect the user index selection of Mask Parameters. |
| **Status**            | This output displays the status of the LoadIn port used for the feature configuration. The block is ready when **Status** signal drops to 0.  |

## PowerMeasurements

$$
PowerMeasurements\_{i}=\frac{1}{n}\sum\_{k\mathop=1}^{n}(CurrentIndiceAssociatedSignal\_i \* VoltageIndiceAssociatedSignal\_i)
$$

Where :

* i is the index in the **PowerMeasurements**,**Current Indices** and **Voltage Indices** vectors
* n is the number of eHS FPGA timesteps where the accumulation of product is performed between two CPU timesteps
* CurrentIndiceAssociatedSignal is the eHS output signal with the index specified in **Current Indices** at index i
* VoltageIndiceAssociatedSignal is the eHS output signal with the index specified in **Voltage Indices** at index i

#### Example

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-99552cc823651c6f1d27efbc82454320887b4303%2Fsps-ehs-power-measurement-controller-ex.png?alt=media" alt=""><figcaption></figcaption></figure>

On the picture the eHS outputs are numbered in red, meaning :

* CurrentIndiceAssociatedSignal would be \[i1 i2 i2] based on the selection in **Current Indices**
* VoltageIndiceAssociatedSignal would be \[v1 v2 i2] based on the selection in **Voltage Indices**

{% hint style="danger" %}
When used with **eHS\_SE\_Sfunction\_Drivers**, it is possible not to connect an eHS output to Simulink, this implies that **eHS outputs indexes can be shifted**.

<img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-361f00fd003db0dcde232bc0d1de6d7c9e493e25%2Fimage.png?alt=media" alt="" data-size="original">

At any time you can see all the eHS outputs in the Build Report Tab of eHS\_SE\_Sfunction\_Drivers with zero based indices even if not visible as output of the block.
{% endhint %}

In this case, the **PowerMeasurements** output vector will be :

$$
PowerMeasurements =\frac{1}{n} \sum\_{k\mathop=1}^{n}\[P\_1:  P\_2:i\_2^2]
$$

Where

$$
P\_i=v\_i \cdot i\_i
$$


---

# 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/rt-lab/simulink-blocks-reference/efpgasim-library/simulink-sps-workflow/power-measurement-controller.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.
