Main Content

Parameter Tuning and Signal Logging with Universal Measurement and Calibration Protocol 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 Monitor and Tune 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 Monitor and Tune 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 Monitor and Tune 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.

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

Available Models

STM Nucleo: STMNucleoCommunication.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.

Prerequisites

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

Model

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 Modeling tab and press Ctrl+E to open Configuration Parameters dialog box.

4. Go to Hardware Implementation > Hardware board > 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.

  • Enable Use a dedicated timer to improve time stamp accuracy parameter for data logging inside ISR at ISR trigger rate. You can analyze the log data in Dashboard blocks or Data Inspector but not in Scope or Display blocks.

To see the list of available COM ports on your computer, select Start > Control Panel > Device Manager > Ports (COM & LPT).

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.

Monitor and Tune the Model

1. In the model, go to Hardware tab and Click Monitor & Tune as shown.

Note: In Monitor and Tune, the SCI0 module is reserved for Monitor and Tune 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 from Monitor and Tune. 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 Monitor and Tune simulation results.

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

Limitations

Performing Monitor and Tune over XCP has a few limitations. For a detailed list, see External Mode Simulation by Using XCP Communication.