08-19-2008 01:30 PM
Hello,
I have two devices ( PXI-6123 in slot2 and PXI-6221 in slot3) to do analog and quadrature measurements. I am using Measurement Studio 8.5 and C# in Visual Studio 2008. The Analog In and Counter In acquisitions are done by two callbacks. Each time the digital edge trigger arrives, the program will do a 50ms measurement.
My question is:
-How do I save the data into one file after each measurement is finished?
If I only have one callback, I can do the file I/O in the callback. For two callbacks, I don't know how to handle this.
I am attaching my project in this post. Can somebody show me how do save the data?
Thanks,
JSInc
08-21-2008 12:15 PM
Hi,
What version of DAQmx are you using? Also, what kind of file do you want to save the data into? Do you just want to save the data into an ASCII file? The analog data and the counter data will return two different waveform arrays. There are a few ways in which you can save the data. You could possibly just combine the data and keep appending it to a file. It depends on what format you want to save the data in. If you can post back with a few more details on the way you want to save the data and the format in which you want to save we can take it from there.
Thank you,
08-21-2008 02:45 PM
Hello Raajit,
I am using DAQmx 8.8.0f2 now.
I want to save the data into an ASCII file, e.g. "datafile_001.txt". The format should be the first column X data (time), second column Y data of Voltage1, third column Y data of Voltage2, fourth column counter data. And the next (trigger) acquisition will save the data into a different file named "datafile_002.txt".
Thank you,
JSInc
08-25-2008 12:19 PM
Thank you for that information. Measurement Studio itself does not have special functions for writing to or reading from files. That would be a native c# functionality (or whatever programming language you are in). I would post on the msdn forums to get more information about that. However, on the DAQmx side of things you can take a look at the DAQmx C Reference File which is located under Start >> Programs >> National Instruments >> NI DAQ >> NI DAQ C Reference File. Here if you look at the Read Functions under DAQmx functions you can find the parameters for the exact function that you are using. You probably have already seen this because you are displaying the data in your code that you posted, but the data is returned as an array which you can then write to your file.
Example: int32 DAQmxReadAnalogF64 (TaskHandle taskHandle, int32 numSampsPerChan, float64 timeout, bool32 fillMode, float64 readArray[], uInt32 arraySizeInSamps, int32 *sampsPerChanRead, bool32 *reserved);
Let me know if you have any questions on the DAQmx side of things.
Regards,
08-25-2008 12:57 PM
Hello Raajit,
In Message 2 you mentioned "combine the data", how do you do that? I think there is a synchronization issue here.
Thanks,
JSInc
09-03-2008 03:09 PM
All right, I found the solution myself, it is not the best one, but it works for me.
I use led StateChanged event to synchronize the file saving. The project is attached.