NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
new_programmer
Posts: 15
0 Kudos

acquire and save data with PXI-5122 for 3 hours of real-time

Attached find a simple code that acquire and saves data.  Unfortunately  since the duration of the time is 3 hours realtime, there is no sufficient memory locally.  How can I save while the data is being acquired withougt overflowing the buffer?
 
 
Knight of NI
Dennis_Knutson
Posts: 29,306
0 Kudos

Re: acquire and save data with PXI-5122 for 3 hours of real-time

I don't see how your program can acquire anything more than a single acquisition. It has no loop to keep recording and saving. I hope you are not using the run continuous button. That is not correct and if you are, you are plobably having problems because you do not call the NI-Scope Close. Put a loot around the read and include the file write function inside the loop. You will need to put some sort of delay in the loop. How many acquisitions per second do you need? With the Write to Spreadsheet File and an extended acquisition period, you could soon create an enormous file. A binary file much be a better option. Look at the TDM/TDMS options for saving data.
Member
new_programmer
Posts: 15
0 Kudos

Re: acquire and save data with PXI-5122 for 3 hours of real-time

Thanks for your help!  One more question, the case we have is a continous 3 hour acquisitoin without any access to the application.  Therefore, I'm guessing any delay would cause some data to be lost.  Idealily we would like to set the program to run for 3 hours for continous acquisition and therefore saving of the data.  Does your solution still hold? 

Thanks a bunch!

Knight of NI
Dennis_Knutson
Posts: 29,306
0 Kudos

Re: acquire and save data with PXI-5122 for 3 hours of real-time

For continuous saves, the TDM/TDMS solution makes even more sense. You might even want to have separate loop that handles the file I/O and pass the from the acquisition loop via a queue.
Member
new_programmer
Posts: 15
0 Kudos

Re: acquire and save data with PXI-5122 for 3 hours of real-time

Dennis,
 
Attached, I have created a file that continously fetches and write data in a binary format.  I know there is a delay issue in writing to the file.  That became obvious when I noticed that when I left the program to run for some time, the file was not getting the data but once I ran it again with the light bulb on, I'm guessind due to some delay, the data was being saved. 
Q1) Where and how do I introduce delay if after all the issue is delay
Q2) How much delay would be enough and how can you figure that out?
 
Thanks
Knight of NI
Dennis_Knutson
Posts: 29,306

Re: acquire and save data with PXI-5122 for 3 hours of real-time

According to the help for the Write to Binary File, if you wire a path to the file input as you have, it opens the file and replaces the contents with the new data. If you wire your path to a Open/Create/Replace File function and pass the reference to the Write to Binary File, then the new data will be appended. You also have to use the Set File Position to set the position to the end of the file before writing.
Member
new_programmer
Posts: 15
0 Kudos

Re: acquire and save data with PXI-5122 for 3 hours of real-time -- now adding a timestamp --

Hello Dennis,
 
Thanks for all your help so far.  I only have one last question:
 
I would like to store time as well!  I understand that one way is to store the first sample time and since we have delta t, then the rest can be calculated.  The other way would be to have a loop to timestamp all the samples and then store. Please let me know which you think is the better way and briefly direct me to implement it.
 
Thanks again!
Knight of NI
Dennis_Knutson
Posts: 29,306
0 Kudos

Re: acquire and save data with PXI-5122 for 3 hours of real-time -- now adding a timestamp --

You can get a timestamp by selecting a different niScope Fetch. If you right click on the one you have and do a Select Type>Single Waveform>Waveform Data Type, you will get a waveform instead of an I8 array. The Export Waveforms to Spreadsheet File or Write LabVIEW Measurement File can save a waveform data type to a text file which is what you seem to be doing now.
Member
new_programmer
Posts: 15
0 Kudos

Re: acquire and save data with PXI-5122 for 3 hours of real-time -- now adding a timestamp --

Dennis,
 
I followed your instructions and created Fetch WDT instread.  Labview does not allow me to connect that wfm output to write to spreadsheet file meaning that they're not compatible ( my preference is to write to a txt file.)
 
If I used Fetch WDT combined with Write LabVIEW Measurement File, then I'm not able to connect to the lower part of code (the part labeled as 7) since it required an array input.  Please refer to the attached VI file for reference.
 
Thanks!
Member
new_programmer
Posts: 15
0 Kudos

Re: acquire and save data with PXI-5122 for 3 hours of real-time -- now adding a timestamp --

Dennis, following up on my previous email, what do you think of the attached file  which addresses my second comment.  I still need help on the first comment.
 
 
By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page