To download NI software, including the products shown below, visit ni.com/downloads.
This example shows an efficient way to capture events from a continuous data stream. This example assumes a continuous DAQmx task and is currently set to acquire from a simulated cDAQ chassis.
The example allows for variable pre and post-trigger capture sizes, regardless of the data packet size. Immediate re-triggering is possible, even allowing for pre-trigger overlap.
Any number of channels can be accommodated. The trigger condition is currently just a positive going edge with hysteresis, but could easily be expanded to cover multiple channel triggering.
I couldn’t find an existing showing how to do this, so I created this to demonstrate the principle. Note that the middle loop can process any data stream with any size data packets. The data packets are appended until sufficient pre-trigger is available and then the analysis is applied after this point.
The bottom loop collects the event data and currently shows the latest completed event, but you would replace this with whatever logging or further processing is required.
Description-Separate-2
To run as-is, configure a DAQmx device (real or simulated) and define the relevant channels and acquisition rates. The samples/cycle would usually be set to the rate / 10 but it depends on the specific application.
How-Separate-2Written in LabVIEW 2025 but saved back to 2020 for compatibility
Additional-Separate-2Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.