02-10-2016 05:11 AM
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
Solved! Go to Solution.
02-10-2016 05:21 AM
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.
02-10-2016 11:03 AM - edited 02-10-2016 11:10 AM
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.
02-11-2016 04:23 AM
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?
02-11-2016 04:32 AM - edited 02-11-2016 04:32 AM
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.
02-11-2016 05:03 AM
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.
02-11-2016 09:50 AM
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.
02-12-2016 08:06 AM - edited 02-12-2016 08:08 AM
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)
02-12-2016 09:23 AM
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.
02-16-2016 08:40 AM
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