Signal Logging and Parameter Tuning in XCP External Mode with Packed Mode
This example shows how to perform parameter tuning and data logging with a Simulink® model enabled with Packed Mode running on an Arduino® board.
Packed Mode leads to enhanced signal logging performance in models containing signals of high sample rates. However, the enhanced performance comes at an additional cost because Packed Mode requires higher RAM on the target as multiple samples need to be stored on the target before transmission.
XCP External Mode is used to log signal data and tune parameters on the Arduino board in real-time. However, there is a limited bandwidth available for communication between the host and target. This limits the data that can be sent from the target. With Packed Mode, multiple data points of multiple signals are combined in a single packet which is sent over a transport. This reduces the overhead introduced by additional bytes of framing the packet.
Complete the Getting Started with Arduino Hardware example.
Required MathWorks Products
Simulink Support Package for Arduino Hardware
Any Arduino board as listed in the Supported Hardware section of Arduino Support from Simulink.
This example uses a preconfigured model. Open the model using this command.
This model is a multi-rate model with signals that are being logged at sample rates of 0.5 millisecond and 1 millisecond. It is preconfigured to run on Arduino Uno board at a Baud Rate of 921600 bits per second.
Configuring the Model
In this example, you will configure a Simulink model and enable packed mode.
Note: These steps are not required in the pre-configured model. Perform these steps if you have changed the hardware or not using the pre-configured model.
1. Open the model.
2. In the Hardware tab, in the Prepare gallery, select Control Panel.
3. In the External Model Control Panel, click Signal & Triggering.
4. In the External & Signal Triggering dialog box, select Send multiple contiguous samples in same packet and enter a value for Duration.
Note: Clearing the Send multiple contiguous samples in same packet option might lead to data drops. To optimize the performance and memory utilization, tune the value of the Duration parameter.
This enables the XCP Packed mode and multiple contiguous samples are sent in a single packet whose length is the value specified for Duration parameter.
5. Click Apply and OK.
Initiate Monitor and Tune Action for the Model
On the Hardware tab of the Simulink toolstrip, click Monitor & Tune to monitor signals and tune parameters.