LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to record and play back a signal (without saving to file)?

Hi - this is admittedly a novice question that stems from me not understanding how variables work in LabVIEW (I'm much more used to Matlab).

 

I want to write a simple VI of my own that will do a few simple things:

 

1) Display a signal real-time from an analog input using "Start" and "Stop" buttons. I've figured that much out using the "DAQ Assistant" and my limited Labview knowledge (see attached).

 

2) Save that data to an array, also controlled by the "Start" and "Stop" buttons. I do NOT need to write it to a saved data file - just a local array that can be lost when the program is closed.

 

3) Have a separate "Playback" button that will replay the waveform (a) on a graph in the GUI (it doesn't have to be the same one that plays the real-time data, if that makes life easier) and (b) through an analog output.

 

I've Googled around for this and most of what I can find relates to logging data to a file, which I don't need to do.

 

Can anyone provide me with some help, primarily on Step 2? I literally just don't know where to go in the Functions palette...there's Programming -> Array...not sure which one of those I want to use to continuously log data to an array from inside a while loop, or if I need something different.

 

Thanks.

0 Kudos
Message 1 of 4
(2,515 Views)

If your signal capture is enclosed in a loop, and it sounds like it is, then building an array, prior to the loop, feeding it into a shift register on the edge of the loop, then having a case statement (or "state machine") inside the loop with at a minimum the "capture" case where the read signal values are inserted into the array, and a "playback" case, where they previously recorded values are displayed. It is more complex than that with keeping track of the index of the array, etc., but" that will be left for the industrious student".   Do they engineering textbooks still include that at the end of the chapter?

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 4
(2,508 Views)

I believe life might be easier than that in Labview 2012, at least according to the "Automatically Concatenating Arrays Leaving Loops" section here: http://zone.ni.com/reference/en-XX/help/371361J-01/lvupgrade/labview_features/

 

Point being, I need to use "Initialize Array" at the start no matter what, and then "Build Array" to add data to it (with or without the shift registers and case statements if they turn out not to be necessary in 2012)?

0 Kudos
Message 3 of 4
(2,503 Views)

Depending on your data rate, build array, particularly as the array gets bigger, starts causing real performance issues. LabVIEW, with a build array (vs replace array element) has know way to know how big the ultimate array may be, so it has to reallocate memory as the array grows. If there is a block of contiguous memory available it has less of an impact, otherwise there may be a pretty big hit. If you "know" how long you expect to observe the signal you can preallocate the array before that part runs, creating an empty array, and then just replace the appropriate elements. The case statement is to allow adding to the array during data capture, then reading it back seperately.

 

P

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 4 of 4
(2,482 Views)