04-30-2015 09:09 PM
I have a state machine running a data-acquisition system. In one state, the system waits for an external trigger to occur (which happens about once every 100 seconds). In the same "waiting" state, I have an oscilloscope displaying continuous data from a NI MyDAQ. I'd like to be able to write the most recent segment of the oscope data to a file.
Exploring the issue, I found the "Write to a Measurement File" subVI as a starting point. I'd thought a viable approach would be continuously outputting the OScope data one segment at a time, and each write would then simply overwrite what came before. However, the data output appears to be appending which leads to large files. I didn't see an option to simply write a single segment, either on the subVI or when I opened the front panel to look under the hood.
Rather than uploading the whole complex system, I've attached a simplified version of what I'm trying to test.
Any leads on where else I could look?
Thanks!
05-01-2015 02:58 PM
Hi gpsmith,
If you're only needing the most recent data immediately before the trigger, you can use a case structure where the True case executes if the trigger is seen and the False case executed otherwise. In the true case, the data segment is written to a file. In the false case, the data is not written.
05-01-2015 04:22 PM
Your "requirements" are unclear. You mention "data acquisition system" and "external trigger", "waiting state", "oscilloscope", and "write most recent segment to file".
Am I correct that your data acquisition system is continuously acquiring (and displaying) data? What is the purpose of the external trigger? Do you want to save data that is acquired after the trigger? It sounds (also) like you want to acquire data that arrives before the trigger, but how much, and why, is anyone's guess.
Assuming that you do want to acquire (and save) data that occurs, say, 2 seconds preceding the trigger, do you want each data segment to be saved in its own file?
It is, in fact, possible to save data that occurs before an Event -- you just use the LabVIEW "Predict Future Events" function. I've done this, myself, with a video capture system where I want to save videos from 3 seconds before an event to 5 seconds after. The trick is to use a fixed-length Queue as a buffer and do a Lossy Enqueue to it. When the Trigger arrives, you start dequeuing the data on the Queue in a parallel "write the data to file" routine. Works like a charm.
Bob Schor