Main Content

Log Signals on an SD Card

You can use SD card logging to save signals from Simulink® models on an SD card mounted on a Pixhawk Series hardware. The signals from these models are saved as data points in MAT-files. With the data that you log, you can apply fault analysis, search for transient behavior, or analyze sensor data collected over a long period. The data points can be saved in: Structure, Structure with time, or Array format. Simulink supports logging signals on the target hardware from only these three blocks:

sd card logging

Note

This topic is for UAV Toolbox Support Package for PX4® Autopilots. The SD card logging feature requires you to additionally install Embedded Coder®.

Without MAT-file logging on SD card, you can only log and analyze the data on the target hardware through External mode or by sending the signal to a computer (using Serial) and storing it in MATLAB®. These mechanisms need an active connection between a computer and the target hardware when logging data. With SD card logging, you can log data without any need to connect the target hardware to a computer. Other advantages of logging data to SD card over other mechanisms are:

  • The ability to collect data over a long duration for analysis.

  • The ability to store the data in a well-structured MAT-file, including timestamp information.

Note

  • The SD card should be formatted with FAT32 format to support the logging from Pixhawk Series processors. Refer to this link to see the list of supported SD cards for MAT-File logging.

  • MAT-File Logging on SD Card does not support the following modes of operation:

    • PIL (Processor in the loop) Mode simulation

    • Monitor and Tune (External mode)

    • Setting the Hardware board as PX4 Host Target

Before you start to save the signals from Simulink models on an SD card, complete the steps listed in Prerequisites for Logging Signals.

  1. Configure Model to Log Signals on SD Card: SD card logging is supported in models containing To Workspace (Simulink) block. You must specify the values for several block parameters.

  2. Prepare Model for Simulation and Deployment

  3. Run Model on Target Hardware: Simulink deploys code and logs signals on the SD card. These signals are saved as MAT-files on the target hardware.

  4. Import MAT-Files into MATLAB: After logging is complete, you can open MAT-files in MATLAB and use them for further analysis.

Related Topics