Example Code

Start and Stop Datalogging and Create a New File Each Time

Code and Documents

Attachment

Download All

Introduction

This example code will allow you to run a program continously, and have the option to log the data to file. When you click "Start Logging" the VI will create a new file and start logging your data to disk. When you click stop logging it will close the file and wait untill you start again.

Code

This code uses a state machine aritecture, to navigate between 5 states:

Initilize

Idle

Create File

Log Data
Close File

Start Stop File Log.png

Start Stop File Log BD.png

NOTE:

You will get an error if the given file name allready exists. If you want to make sure it generates a new file name everytime take a look at: Generate Unique File Path and Create File

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors