> 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/op8666/demo-project/create-a-matlab-simulink-model/build-the-model.md).

# Build the Model

## Browse the TI C2000 processors library <a href="#browse-the-ti-c2000-processors-library" id="browse-the-ti-c2000-processors-library"></a>

* Click on **Library Browser** in the **SIMULATION** tab.

<figure><img src="https://1188700823-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSz7qPxQbRFCsCnF5Xtl%2Fuploads%2FWCC9Kh2jE0I1O9GjVoTy%2Fimage.png?alt=media&amp;token=d81cd243-6617-4ae1-b028-5d95f5ff2fe9" alt="" width="563"><figcaption></figcaption></figure>

* Browse to **Simulink Library Browser** -> **Embedded Coder Support** … -> **F2837xD**
* Library **F2837xD** is the library (lib) **to be used for the microcontroller**.

<figure><img src="https://1188700823-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSz7qPxQbRFCsCnF5Xtl%2Fuploads%2FjwcKECII9OcrDSPdc2Am%2Fimage.png?alt=media&amp;token=e4112843-5a69-4ce7-bbc6-69ee1cce15c1" alt="" width="563"><figcaption></figcaption></figure>

## Add memory blocks <a href="#adding-memory-blocks" id="adding-memory-blocks"></a>

### Add “Input” memory blocks <a href="#adding-input-memory-blocks" id="adding-input-memory-blocks"></a>

* Browse to Simulink Library Browser → **Memory Operations**.

<figure><img src="https://1188700823-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSz7qPxQbRFCsCnF5Xtl%2Fuploads%2FzYxy6W2oeKiOvHckRmzd%2Fimage.png?alt=media&amp;token=99beb8a1-4565-4b89-8fe2-896f5c0ad321" alt="" width="563"><figcaption></figcaption></figure>

* Add a **Memory Allocate** block.
* Add a **Memory Copy** block.
* For clarity, let rename them:
  * Rename the **Memory Allocate** block “**Save\_Input**”.
  * Rename the **Memory Copy** block “**Read\_Input**”.

<figure><img src="https://1188700823-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSz7qPxQbRFCsCnF5Xtl%2Fuploads%2FfyCCzJ6aqPXRIjpT7CKu%2Fimage.png?alt=media&amp;token=26efe5c6-e99d-4bba-b0a7-9c2dcf972ec6" alt="" width="563"><figcaption></figcaption></figure>

* **Memory Allocate** Block Parameters: **Create an “input” variable**.

{% tabs %}
{% tab title="Memory tab" %}

<figure><img src="https://1188700823-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSz7qPxQbRFCsCnF5Xtl%2Fuploads%2FBUumpcKGsM6gfGNhEfN7%2Fimage.png?alt=media&amp;token=38c6d598-94e4-4a45-b64d-e8d082b9613d" alt="" width="375"><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Section tab" %}

<figure><img src="https://1188700823-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSz7qPxQbRFCsCnF5Xtl%2Fuploads%2FA1W8CiPcBNvDBHwo6TWT%2Fimage.png?alt=media&amp;token=5f7841c5-2c04-4382-9b8f-f6a636e3324d" alt="" width="375"><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

* **Memory Copy** Block Parameters: **Configure to read input variable from CCStudio**.

{% tabs %}
{% tab title="Source tab" %}

<figure><img src="https://1188700823-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSz7qPxQbRFCsCnF5Xtl%2Fuploads%2Fa7QYlNXcC401qzKlwFit%2Fimage.png?alt=media&amp;token=abedab81-3e10-49e5-9377-945ac25fe619" alt="" width="375"><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Destination tab" %}

<figure><img src="https://1188700823-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSz7qPxQbRFCsCnF5Xtl%2Fuploads%2FMGWSo3NjBAYUrUiTq2UT%2Fimage.png?alt=media&amp;token=c211b7e3-d3e3-4006-ab8e-ed13b2abf07d" alt="" width="375"><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

### Add “Output” memory blocks <a href="#adding-output-memory-blocks" id="adding-output-memory-blocks"></a>

* Add another **Memory Allocate** block.
* Add another **Memory Copy** block.
  * These blocks will let us see the “output” variable in CCStudio by storing its value.
* For clarity, let rename them:
  * Rename the **Memory Allocate** block “**Save\_Output**”.
  * Rename the **Memory Copy** block “**Read\_Output**”.
* Add a **multiplication block** and **connect** the **Read\_Input** and the **Read\_Output** as shown below.

<figure><img src="https://1188700823-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSz7qPxQbRFCsCnF5Xtl%2Fuploads%2FARNKjmYAzxuqIFOUQMoU%2Fimage.png?alt=media&amp;token=bf97fe2e-73bf-4c01-b5c5-b47beadafd30" alt="" width="563"><figcaption></figcaption></figure>

* **Memory Allocate** Block Parameters: **Create an “output” variable**.

{% tabs %}
{% tab title="Memory tab" %}

<figure><img src="https://1188700823-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSz7qPxQbRFCsCnF5Xtl%2Fuploads%2FYxLsa0KJGPpTmMEdIbiP%2Fimage.png?alt=media&amp;token=595965f5-441b-472b-ad7a-ca0f53dddf57" alt="" width="375"><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Section tab" %}

<figure><img src="https://1188700823-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSz7qPxQbRFCsCnF5Xtl%2Fuploads%2FfXvjFX0ZjLwiSwonUG0y%2Fimage.png?alt=media&amp;token=fa90bb40-2459-4cb3-8210-61823c276549" alt="" width="375"><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

* **Memory Copy** Block Parameters: **Configure to read output variable from CCStudio**.

{% tabs %}
{% tab title="Source tab" %}

<figure><img src="https://1188700823-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSz7qPxQbRFCsCnF5Xtl%2Fuploads%2FwC4oZ1LRKms8SQ357VcR%2Fimage.png?alt=media&amp;token=985eb82b-d8b6-4407-ad95-a67cee8a4b9a" alt="" width="375"><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Destination tab" %}

<figure><img src="https://1188700823-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSz7qPxQbRFCsCnF5Xtl%2Fuploads%2FvNWRUzCwKiTuuu4QXSnA%2Fimage.png?alt=media&amp;token=60d503b9-3d0b-4c67-bacf-c9450846a8ed" alt="" width="375"><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

### Add a “Gain” variable and initializing it to 1 <a href="#adding-a-gain-variable-and-initialize-it-to-1" id="adding-a-gain-variable-and-initialize-it-to-1"></a>

* Add another **Memory Allocate** block.
* Add another **Memory Copy** block.
  * This block will let us see the “gain” variable in CCStudio by storing its value.
* For clarity, let rename them:
  * Rename the **Memory Allocate** block “**Save\_Gain**”.
  * Rename the **Memory Copy** block “**Read\_Gain**”.
* **Memory Allocate** Block Parameters: **Create a “Gain” variable**.
  * **Check** the **Initialize memory** box.
  * Enter “1” as the **Initial value**.

{% tabs %}
{% tab title="Memory tab" %}

<figure><img src="https://1188700823-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSz7qPxQbRFCsCnF5Xtl%2Fuploads%2FoXTwoT5GASRbhCOOyBmn%2Fimage.png?alt=media&amp;token=31626b2e-48c9-4e32-ba3d-b85e6c00f137" alt="" width="375"><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Section tab" %}

<figure><img src="https://1188700823-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSz7qPxQbRFCsCnF5Xtl%2Fuploads%2FuWiHokFiw41zWWMmpm7p%2Fimage.png?alt=media&amp;token=cfa91f83-a188-44c6-bed1-b1a1a424f398" alt="" width="375"><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

* **Memory Copy** Block Parameters: **Configure to read Gain variable from CCStudio**.

{% tabs %}
{% tab title="Source tab" %}

<figure><img src="https://1188700823-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSz7qPxQbRFCsCnF5Xtl%2Fuploads%2FWkTCnNySKwDYxlBK8UI4%2Fimage.png?alt=media&amp;token=d185694e-c350-4d4f-a9db-6ef1bb18736d" alt="" width="318"><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Destianation tab" %}

<figure><img src="https://1188700823-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSz7qPxQbRFCsCnF5Xtl%2Fuploads%2FGrHGmkaqRU7YpkB9X84C%2Fimage.png?alt=media&amp;token=f617d2f4-1841-4f40-ad9c-6bd66364c8bd" alt="" width="318"><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

## Set the port data types <a href="#set-the-port-data-types" id="set-the-port-data-types"></a>

* Set the Port Data Types from **DEBUG** -> **Information Overlays** -> **Ports** -> **Base Data Types**
  * This is to show data types for the signals, as shown in the final image of this page.
  * We have to define data types when we use memory allocate and memory copy blocks above.

{% columns %}
{% column %}

<figure><img src="https://1188700823-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSz7qPxQbRFCsCnF5Xtl%2Fuploads%2FZUxQPp5UV0KA10u1mfHy%2Fcdn.webp?alt=media&amp;token=c003aefa-0c75-4bc8-b765-73c3d5ef9d48" alt=""><figcaption></figcaption></figure>

{% endcolumn %}

{% column %}

<figure><img src="https://1188700823-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSz7qPxQbRFCsCnF5Xtl%2Fuploads%2FyDQEN5xK0nPR4ReBYSGg%2Fcdn.webp?alt=media&amp;token=5056b818-5813-4617-9b48-7991b5659de2" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

* The finished model looks like this.

<figure><img src="https://1188700823-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqSz7qPxQbRFCsCnF5Xtl%2Fuploads%2FxUazTNbkUfNFwcFI6r9g%2Fimage.png?alt=media&amp;token=cf9ceef9-74e1-4361-8a7d-d0a270635096" 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/op8666/demo-project/create-a-matlab-simulink-model/build-the-model.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.
