LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multi plot sampled data

I'm trying to plot sampled data from two analog channels on the same plot.  I'm reading in the data inside a while loop.  Then I feed the data into an auto-indexing tunnel.  When I connect the tunnel to a graph outside of the the while loop, I will get an error that the dimension of the data source (the tunnel) and the dimension of the sink (the graph) are mismatched.  If I connect the graph inside the while loop, there is no error; however, the graph doesn't accumulate the data.  I think it's just plotting the data for the current loop iteration and refreshes with each iteration.  I've attached what I have so far. Can someone help with this this?

0 Kudos
Message 1 of 5
(1,856 Views)

When data goes through an auto indexing tunnel it gains an extra dimension, so your 2D array is turning into a 3D array. You can change the tunnel to concatenate so that each loop's data gets tacked on to the previous loop's data. In the end, you want an array with 2 rows, so you might have to add some "transpose 2D array" functions in there to get the dimensions to look right.

 

capture.png

0 Kudos
Message 2 of 5
(1,839 Views)

Expanding on some of Gregory's excellent points:

  • You are doing continuous sampling of multiple channels (judging by the DAQmx Read, NChan NSamp), but you failed to specify Number of Samples/Chan in the Timing VI and in the DAQmx Read.  For something like this, you should not use Default values (particularly if they are different for these two functions).
  • Do you intend to collect all of the data, press the Stop button, and when data collection stops, only then plot all of the data?  In other words, do you intend to not "see the data as they are collected"?  The Principle of Data Flow says that no data will appear out the right side of the While Loop until the loop exits.
  • There are two ways to acquire and plot "almost-simultaneously".  One is to put the plotting of new data inside the While Loop with the DAQmx Read.  The other is to use something called the Producer/Consumer Design Pattern.  You do this by having two loops that run at the same time -- one only does the DAQmx Read, and as fast as the data comes in, it "exports" it (via a Queue or a Stream Channel) to the second loop, where the incoming data are plotted (or saved to disk, or whatever other "simultaneous" processing you need to do).  The first loop that "produces" the data is called the Producer, and the second loop that consumes is it called ... well, I'll let you guess.
  • Because you have continuous sampling of a fixed number of samples at a fixed rate, the Producer Loop will be "clocked" at the rate determined by the DAQmx Read timing.  As long as the Consumer Loop can "consume" the data at least as fast as the Producer, the two will both run at the same rate, the Producer because it is timed by the DAQmx Read, the Consumer because it is timed by the data sent from the Producer.

Bob Schor

0 Kudos
Message 3 of 5
(1,791 Views)

I would replace your graph with a  chart.  A chart has history built into it.  Then you can just put the chart inside of the While loop.


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
0 Kudos
Message 4 of 5
(1,751 Views)

I found out that my version of LabVIEW, 8.5.1, does not have the concatenate array tunnel when it is right clicked. Instead I built an array of my data using a concatenating build array and shift registers.  This fixed the non-matching dimension error.  However, now when I plot it outside the while loop with a graph, it displays six plots.  I've attached a picture of an array indicator attached to the same shift register as the graph. It has n columns and 6 rows. I don't understand how it is getting 6 rows.   I assume I am building the array incorrectly but I don't know how to fix it.  I've attached my vi as well

 

I also tried adding a chart inside the while loop.  It did plot correctly, but the data will scroll of screen after I hit the stop button.

Download All
0 Kudos
Message 5 of 5
(1,735 Views)