Writing to a USB Drive or SD from NI Real-Time Device

Updated Jul 30, 2023

Reported In


  • cRIO-9063
  • cDAQ-9134


  • LabVIEW Real-Time Module

Issue Details

I want to write to an external USB drive or SD Card from my Real-Time CompactRIO, CompactDAQ, or PXI Controller for data logging purposes. How can I achieve this?


There are a few things to consider when making an application that accesses an external USB drive or SD Card on a Real-Time target:
  • The drive must be formatted to a compatible file system for the specific real-time operating system. All NI Real-Time devices support FAT32, and this format is recommended for ease of transfer to Windows. PharLap targets also support Reliance file systems and NI Linux Real-Time targets also supports ext2 or ext3 file systems.
  • You must point to the drive that is enumerated when the USB drive or SD Card is connected. By default, the external drive should be named with drive letter U: for the first drive, V: for the second, and so on.
  • You must follow the file structure conventions of the operating system (ie, forward slashes, colons). See the Working with File Paths on Real-Time Targets for more information on working with file paths for the different real-time operating systems.
  • If you're seeing permission errors after completing the above steps while using an SD card, check to see if the card is set to Read-Only. With most SD cards, the lock direction will be on the front of the card.

The same LabVIEW functions are used for writing to a specific drive in LabVIEW Real-Time as in Windows. The following is an example program that would write to the primary external drive on a VxWorks or PharLap target. To write to a the same location on a Linux RT target, you would need to change the file path to /u/Example Folder/test.txt.