This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Parameter Tuning and Signal Logging in External Mode Using STMicroelectronics Nucleo Boards

This example shows how to tune the parameters and monitor the signals of an algorithm running on an STMicroelectronics Nucleo board.

Simulink Coder Support Package for STMicroelectronics Nucleo boards enables you to monitor and tune algorithms running on STMicroelectronics Nucleo board from the same Simulink models from which you developed the algorithms.

Simulink External mode feature enables you to accelerate the process of parameter tuning by letting you change certain parameter values while the model is running on target hardware, without stopping the model. When you change parameter values from within Simulink, the modified parameter values are communicated to the target hardware immediately. The effects of the parameters tuning activity may be monitored by viewing algorithm signals on scopes or displays in Simulink. This example introduces the Simulink External mode feature by showing you how to:

  • Set up communication between Simulink and STMicroelectronics Nucleo board.

  • Use a Simulink model to tune parameters of an algorithm that is running on the STMicroelectronics Nucleo board.

  • Use Simulink scopes or Simulation Data Inspector to monitor the state of an algorithm running on the STMicroelectronics Nucleo board.

The STMicroelectronics Nucleo boards support External mode over Universal Measurement and Calibration Protocol (XCP).

Simulink provides these additional features for the targets that support XCP:

  • Dashboard objects such as Slider and Dashboard Scope. For more information, see Dashboard (Simulink).

  • Simulation Data Inspector (SDI) for visualizing the logged signals. For more information, see Simulation Data Inspector.

Available Models

STM Nucleo: stmnucleo_communication.slx

The provided model is pre-configured for the STMicroelectronics Nucleo F401RE board. You can run this model on any of the boards listed in the "Supported Hardware" section, by changing the Configuration Parameters > Hardware Implementation > Hardware board of the model. However, for STMicroelectronics Nucleo F031K6, External mode is not supported because of the memory constraint of the processor.


We recommend completing the Getting Started with Simulink Coder Support Package for STMicroelectronics Nucleo Boards example.

Required Hardware

  • Supported STMicroelectronics Nucleo board

  • USB cable type A to Mini-B cable


The following figure shows the example model:

Configuring the Model for the STMicroelectronics Nucleo Board

In this task, you will configure and run your model on the STMicroelectronics Nucleo board.

1. Open the communication model. This model has been configured for the Nucleo F401RE board. Follow the steps shown in the figure below to configure the model for the appropriate Nucleo board:

2. Connect the STMicroelectronics Nucleo Board to your computer with a USB cable.

3. Open the Configuration Parameters in the model. Set the Hardware Implementation > Hardware board parameter to STM Nucleo board, which is connected to your computer.

4. Browse to Configuration Parameters > Hardware Implementation > Target hardware resources > External Mode, and set the Serial port parameter the same as the COM port of the serial interface on Windows, as shown.

Note: The name of the serial port may appear as USB Serial Device in some versions of Windows.

5.. Click Apply and OK.

6. This example model has one signal selected for logging. To select additional signals, right-click the required signal and select the Log Selected Signals option.

Running the Model in External Mode

1. In the model, change the Simulation mode on the toolbar to External, and click the Run button, as shown.

Note: In external mode, the SCI0 module is reserved for external mode communication and cannot be used by the SCI Read or SCI Write block.

At this point, your model is running on the STMicroelectronics Nucleo board and communicating with Simulink via External mode. You can select the Simulation Data Inspector button to view the logged signals, as shown.

2. You can tune the parameters and visualize the signals selected for logging by:

  • Double-clicking the Manual Switch block to change the input source.

  • Using the Slider to change the signal gain.

  • Double-clicking the Scope block to view the External mode simulation results.

The model is running in real-time on the target while performing these actions.


Running External mode over XCP has a few limitations. For a detailed list, see External Mode Simulation with XCP Communication (Simulink Coder).