Is it possible to log an entire signal to a single workspace variable when running a Simulink model in external mode on a C2000 target?

2 views (last 30 days)
Is it possible to log an entire signal to a single workspace variable when running a Simulink model in external mode on a C2000 target?
I was able to log an entire signal as a single workspace variable when I was simulating models in external mode with Arduino hardware. However with C2000 targets it seems that only a small number of recent samples appear in the workspace instead of the whole signal. I can save the signal into several MAT files when I turn on Data Archiving in the External Mode Control Panel, however then I would have to combine the data manually.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 1 Apr 2024 at 0:00
Edited: MathWorks Support Team on 13 Apr 2023
Unfortunately it is not possible to log an entire signal as a single variable into the workspace with C2000 targets. As explained in the documentation page Parameter Tuning and Signal Logging with Serial External Mode, data is logged in real-time buffers. The length of each buffer can be adjusted by changing the "Duration" parameter in the External Mode Control Panel under Signal & Triggering.
If you have too much data that will not fit in a single buffer due to memory limitations, you can use "normal" mode in the External Mode Control Panel to write out individual MAT files containing one packet each, then stitch the data together into a contiguous signal using a for loop. 
The following documentation page has instructions for logging directly to an onboard SD card, which is compatible with R2019b and onward. The documentation page also include a link to a "stitcher" example which will combine data from multiple MAT file segments into a contiguous signal.
One workaround is to generate a MATLAB figure from the Scope using the "Print to Figure" functionality. The data on the scope can then be accessed through the line object in the figure. Please note this workaround has some issues, for example the data in the Figure may appear down-sample from what is shown in the scope.
For more information on the "Print to Figure" workflow, refer here:

More Answers (0)

Products


Release

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!