> 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/scpi/scpi-example.md).

# SCPI Example

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

The **SCPI\_RP79xx** 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\_ > SCPI** and select **SCPI\_RP79xx**, then click **Finish**. This example illustrates how measurement and control commands can be exchanged with one Keysight RP79xx SCPI device during runtime using standard SCPI commands.

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

In this example, the model communicates with an SCPI device using:

* Initial commands to configure the instruments at simulation start
* Periodic or triggered measurement queries to retrieve numeric data
* Control commands driven by model outputs to update device parameters during runtime
* Reset commands to restore the instruments to a defined state at the end of the simulation

## Requirements <a href="#requirements" id="requirements"></a>

In addition to the requirements stated in the SCPI **Requirements, Features & Limitations** section, this example requires a Keysight RP79xx SCPI device. Alternatively, the user can adapt the SCPI commands in the SCPI interface to the SCPI device used. Each such device has a specific set of commands that may not be compatible with other devices.

## Detailed explanation <a href="#detailedexplanation" id="detailedexplanation"></a>

This example illustrates how to perform real‑time interaction with external SCPI devices from a simulation model. The SCPI interface runs in a dedicated communication thread operating in parallel with the real‑time simulation. Measurements are obtained by issuing SCPI query commands either cyclically, at a user‑defined rate, or based on a model trigger. Control commands are sent from the model to the SCPI device to adjust instrument parameters dynamically during execution. Initial and reset commands are used to ensure a known device state before and after simulation.

### Model preparation and configuration <a href="#modelpreparationandconfiguration" id="modelpreparationandconfiguration"></a>

1. Adjust the SCPI interface parameters (device type, TCP port, IP address, etc.) as required.
2. Build the SCPI model.
3. Load and execute the model.
4. Power on and enable network access on the external SCPI device.

## Simulation and results <a href="#simulationandresults" id="simulationandresults"></a>

Once the TCP connection is established, the model and the SCPI device begin exchanging commands and responses. Measurement values retrieved from the device are propagated to the model. Control values produced by the model are translated into SCPI commands and sent to the device according to the configured cycle rate or trigger conditions.

Users can observe the effect of real‑time model signals on the external instrument (such as changing setpoints or output states) and confirm that measurement values reported by the device are correctly reflected in the simulation. When enabled, SCPI traffic can be logged to a CSV file for debugging and verification purposes. At the end of the simulation, reset commands are issued to return the SCPI device to the desired post‑simulation state.


---

# 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/scpi/scpi-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.
