This example demonstrate how use a state machine to have a data acqusition system with configuraple sample rate and save data in a log file.
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.