> 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/configure-ios/communication-protocol-ios/can/can-multiplexer-two-channels-example.md).

# CAN Multiplexer Two Channels Example

## Description <a href="#description" id="description"></a>

The **CAN\_2\_channels** example can be created by starting a new RT‑LAB project. From the menu bar, select **File > New > RT‑LAB Project**. Enter a name and location for your project, then click **Next**. From the available templates list, navigate to **IO > Generic > CAN > Kvaser** and select **CAN\_multiplexer\_2\_channels**, then click **Finish**. This example demonstrates how to use the CAN interface with **multiplexed messages**. It shows how a single CAN message can carry different sets of signals based on the value of a **multiplexer signal**, allowing efficient use of the CAN payload.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-b53a857201d8f2223661fb96c0facf1e6fcbab84%2FDR-rtlab-can-ex4.png?alt=media" alt="" width="383"><figcaption></figcaption></figure>

The example uses two CAN channels connected in a physical loopback configuration, enabling messages transmitted on one channel to be received on the other.

## Requirements

The simulator must be equipped with a **Kvaser PCIe CAN interface card (**[**OP3411**](https://www.opal-rt.com/docs/pcie-cards-and-connector-kits/pcie-cards/op3411-kvaser-pcie-can-bus-kits.md)**)** providing at least **two CAN channels**. Physical CAN **loopback connections** must be installed between:

* **Channel 1 and Channel 2**

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-ca8dca8c143626db3c231ad33609be0255e0c496%2FDR-rtlab-can-ex2.jpg?alt=media" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
The CAN loopback cable shown above includes **internal 120 Ω termination resistors at both ends**, providing proper bus termination for loopback operation.
{% endhint %}

[Verify that an active RT-LAB license](https://www.opal-rt.com/docs/rt-lab/licensing-reference/simulator-license.md) with the following features is installed on the simulator:

<table><thead><tr><th width="245">Feature Name</th><th width="175">Required Status</th><th width="320">Description</th></tr></thead><tbody><tr><td>CAN</td><td>enabled</td><td>Enables CAN</td></tr><tr><td>CAN_CHANNEL_NB</td><td>2 enabled (or more)</td><td>Number of activated CAN channels</td></tr></tbody></table>

## Detailed explanation

In this example, **CAN Channel 1** is configured to **transmit a non‑cyclic CAN message** (`Bus_1 / Node_1 / MCU1`) with a fixed **CAN ID 3**, while **CAN Channel 2** is configured to **receive** the same message (`Bus_1 / Node_2 / MCU2`) using the same CAN identifier.

The transmitted message is configured with **multiplexed signals**, including:

* One **multiplexer signal**
* One **normal (non‑multiplexed) signal**
* Two groups of **multiplexed data signals**:
  * `Multiplexed_Data_1` to `Multiplexed_Data_3`
  * `Multiplexed_Data_4` to `Multiplexed_Data_6`

The value of the multiplexer signal determines which group of multiplexed signals is included in the CAN data frame:

* When the multiplexer signal value is **0**, signals `Multiplexed_Data_1` to `Multiplexed_Data_3` are transmitted.
* When the value is **1**, signals `Multiplexed_Data_4` to `Multiplexed_Data_6` are transmitted.

This message is configured as **non‑cyclic** and is transmitted only when the **Enable Message** signal is asserted. While enabled, the message is transmitted at each model time step.

With the physical loopback in place, **Channel 2 receives the multiplexed message transmitted by Channel 1**, allowing verification of correct multiplexing behavior and signal selection.

### Model preparation and configuration

1. Review and adjust CAN interface parameters as desired.
2. Build the CAN\_multiplexer\_2\_channels model.
3. Load the model and verify that all CAN interface connections are correctly established.
4. Execute the model.

## Simulation and results

Once the simulation is running, asserting the **Enable Message** signal causes the multiplexed CAN message to be transmitted from Channel 1 and received on Channel 2 through the loopback connection.

By changing the value of the **multiplexer signal** during execution, different sets of multiplexed signals become active in the transmitted CAN frame. The received data reflects the selected signal group, allowing validation of multiplexing behavior.

The **Console subsystem** can be used to:

* Modify transmitted signal values
* Change the multiplexer signal value
* Enable or disable message transmission and reception
* Monitor received data and message status information

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-f8f65b73239bbfbac7c6083dcaf2b306f8c10dd9%2FDR-rtlab-can-ex5.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-a2f074ecd0f18ed83e04a019ada844518e0ad5d4%2FDR-rtlab-can-ex6.png?alt=media" alt=""><figcaption></figcaption></figure>

Successful execution confirms correct configuration of **multiplexed CAN messages**, proper signal selection based on the multiplexer value, and reliable CAN communication through the physical loopback.


---

# 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/configure-ios/communication-protocol-ios/can/can-multiplexer-two-channels-example.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.
