LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with saving all the data from graph.

Hello,

 

I am transferring data from lock-in amplifier to labview via ADC. I have built a labview data acquisition VI for this. My problem is that I am saving the data in waveform function. When I export the data to excel sheet, it only saves the data that is presented on the graph at that time. While, I want to export all the data. 

 

I am attaching the VI here for reference. Any help would be appreciated.

 

Mehr

Download All
0 Kudos
Message 1 of 3
(1,831 Views)

There are several "strange" things about this VI:

  • When doing (almost) anything that is unusual, I strong recommend not using the Dreaded DAQ Assistant, but using the 3-5 simple DAQmx Functions that you need (along with defining a Task in MAX or your Project).
  • Even more important, don't use the DDA's Evil Twin, the Dynamic Data Wire.  DAQmx will give you a choice of output formats, typically simple arrays or Waveforms -- you use the latter in your code, but because you use the DDA, you need to "undo" the Dynamic Data wire.
  • Charts and Waveforms have their own (interesting) Rules.  Notice what you are doing in your code -- you are acquiring Waveforms, concatenating them (to make ever-longer Waveforms), then plotting these on a Waveform Chart.  I must confess that until I actually wrote a little demo routine and tried it, I "guessed wrong" how the Chart would behave.  Note that when you plot non-Waveform data on a Chart, the new data gets added at the end of the Chart, so if you acquired data as an Array of Dbls, 100 at a time, you would be plotting 100 points, adding 200 points, adding 300 points, ... so at the end of 4 samples (of 100 points each), you'd have plotted 100 + 200 + 300 + 400 = 1000 points!  What happens when you do this with a Chart?  You plot 100 points, you plot 200 points ("on top of" the earlier 100 points), you plot 300 points, so you end up with ... 300 points!  How is this possible?  Because the Waveform contains t0, so the "origin" of the Plot stays fixed.  I must confess I didn't expect this!
  • Note, however, that plotting "concatenated" Waveforms means that each plot requires plotting more and more points, so updating gets slower and slower (unless LabVIEW does some very fancy things "under the covers").  Much more efficient and much simpler to code is to simply plot the latest Sample of 100 points, which will have the same Chart appearance, but be simpler and faster.
  • I recommend you make the following changes:
    1. Get rid of the Shift Register.
    2. (Optional) Get rid of the Dreaded DAQ Assistant (DDA) and the Dynamic Data Wire, substituting DAQmx Start Task, DAQmx Read (with Waveform output), and DAQmx Stop Task.
    3. Wire 100-point Waveform data to Chart, and bring Waveform to edge of While Loop using an Indexing Tunnel (which creates an Array of Waveforms.
    4. On the Output of the While Loop, you can use a For Loop to convert the Array of Waveforms into a Concatenated Waveform, suitable for writing.  Note I'd recommend using Delete from Array to remove the first Element, use that to initialize your Shift Register, then use the remaining Array and an Indexing Tunnel to concatenate the remaining Waveforms onto the end of the Waveform in the Shift Register.

You'll note I'm not providing any VIs or Snippets.  You should be able to do all of these steps yourself (except, perhaps, replacing the DDA with DAQmx functions, but you can learn about that by doing a Google search for "Learn 10 Functions in NI-DAQmx ...") as they use functions you have in your original code.  If you get stuck, post what you have and someone (I, if noone else chimes in) will make suggestions.

 

Bob Schor

Message 2 of 3
(1,781 Views)

@Bob_Schor wrote:
On the Output of the While Loop, you can use a For Loop to convert the Array of Waveforms into a Concatenated Waveform, suitable for writing.  Note I'd recommend using Delete from Array to remove the first Element, use that to initialize your Shift Register, then use the remaining Array and an Indexing Tunnel to concatenate the remaining Waveforms onto the end of the Waveform in the Shift Register.

I would recommend a Producer/Consumer setup in order to log the data as it is acquired.  Or, even simpler, is to use the DAQmx Configure Logging (or the "Logging" tab in the DAQ Assistant) to have DAQmx automagically log the data for you to a TDMS file.  You should have a plugin to open the TDMS file in Excel.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 3
(1,766 Views)