Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

synchronize Analog In and Counter In with File I/O

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

0 Kudos
Message 1 of 6
(4,449 Views)

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,

Raajit L
National Instruments
0 Kudos
Message 2 of 6
(4,419 Views)

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

0 Kudos
Message 3 of 6
(4,415 Views)

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,

Raajit L
National Instruments
0 Kudos
Message 4 of 6
(4,386 Views)

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

0 Kudos
Message 5 of 6
(4,382 Views)

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.

0 Kudos
Message 6 of 6
(4,315 Views)