Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Storing samples of multiple analog channels (continuous acquisition)

Solved!
Go to solution

I am using a USB6356 to read 5 analog channels (plus digital input port A)) simultaneously until a stop button is pressed. The idea is to represent all the captured signals on a time-based scale after the acquisition.

 

I am transposing and storing the 2D array that is captured in each loop iteration into another 2D array in order to have an output array of 5 rows (one for each input signal).

 

However, Labview can't handle so much array processing in such a short time (I think the main bottleneck is the Transpose 2D array VI) and crashes pretty soon (I have to kill the whole process and restart Labview). Is there a more efficient way of doing this?

 

Cheers 

0 Kudos
Message 1 of 10
(4,816 Views)
Solution
Accepted by thehun

Your problem is you have horrible memory management here.  Each time you add to the array, more memory is allocated and then the array is copied.  You are basically running out of memory.

 

1. Use the N Samples, N Channels, 1D Array of Waveforms for your DAQmx Read

2. Change your graph to a chart and move it to be inside of your loop.  The chart keeps a history, so you can always see the last X samples on it (1024 by default).

3. Log your data to a file.  I recommend using the DAQmx Configure Logging before you start the task.  This will allow you to stream the data straight to a TDMS file for later processing.


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 2 of 10
(4,813 Views)

Thank you crossrulz,

 

 

that has solved the problem of analog acquisition; however, I am now logging to two TDMS files simultaneously (one for analog and one for digital signals) and when acquiring longer than about 5 seconds I run out of memory when trying to plot the digital samples after a long wait. If I only plot the analog signals it all happens relatively fast. I have to say though that digital sampling takes place at 1MHz and analog samples are collected at only 168KHz. 

 

Apart from that, any manipulation of the chart where the samples are depicted takes an eternity, even when the program isn't running.

0 Kudos
Message 3 of 10
(4,794 Views)

Hello thehun,

have you implemented the suggestion by crossrulz about using the "DAQmx Configure Logging.vi"? Here's a white paper about how to integrate the function in your code:

http://www.ni.com/white-paper/9574/en/
There's also a community-provided example for continuous acquisition:

https://decibel.ni.com/content/docs/DOC-11300

 

Could you please provide a screenshot or a VI, so that we can better understand what your VI is doing?

Jacques Scheller
Staff Applications Engineer, NI Germany
Certified LabVIEW Developer, Certified TestStand Developer
0 Kudos
Message 4 of 10
(4,767 Views)

jacquess,

 

yes that is exactly what I'm doing. The problem is not so much with logging as with plotting. I am capturing the digital samples in raw U8 format and before I was just converting the array of U8 to an array of arrays of booleans once after the capture had finished. But now, for consistency reasons with the analog capture I am also logging these samples to a TDMS file and it seems that the process of generating 8 individual digital signals out of the raw samples os what takes an awful lot of time.

 

 

0 Kudos
Message 5 of 10
(4,762 Views)

Try reading a small section of the log and display that.  When the user scrolls over in the graph, load in the section that needs viewed.  There is also the option of decimation.


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 6 of 10
(4,748 Views)

I support crossrulz's suggestion about plotting.
I want to make two more remarks about your code:
- If you want to initialize the Stop shared variable before starting acquisition, you have to enforce execution of that piece of code before your while loops, otherwise it is executed at an undefined moment and your program might misbehave.
- You can wire the error wire directly to the Or-function, there's no need to unbundle the error status.

Jacques Scheller
Staff Applications Engineer, NI Germany
Certified LabVIEW Developer, Certified TestStand Developer
Message 7 of 10
(4,735 Views)

Thanks,

 

If I store the samples in an array at the same time as logging, and then convert this array to a 2D array of booleans it gets plotted almost immediately. 

 

Now the problem I am trying to solve is recovering the information from that file (converting the array of waveforms to a 2D array of booleans again). I'm having trouble converting from a DBL Waveform to a digital waveform (which is what the DWDT Digital to Boolean Array requires at its input)

0 Kudos
Message 8 of 10
(4,707 Views)

You could try using the Analog to Digital.vi to convert from an analog to a digital waveform, which in turn can be wired to the DWDT Digital to Boolean Array.vi.

Jacques Scheller
Staff Applications Engineer, NI Germany
Certified LabVIEW Developer, Certified TestStand Developer
0 Kudos
Message 9 of 10
(4,698 Views)

I found out that I can specify the data type of the signals to recover from the file, so I just needed to wire a Boolean Array constant to  Read From TDMS File vi

 

 

0 Kudos
Message 10 of 10
(4,660 Views)