02-20-2016 11:00 AM
Hello,
Quick question about the block diagram (attached). I have 2 inputs I want to plot on one graph. I have been following this link for guidance (Broken_Arrow's post): http://forums.ni.com/t5/LabVIEW/Plotting-two-different-analog-inputs-onto-a-graph/td-p/1109492 but the wires are broken because of different input types.
Would appreciate any suggestions 🙂
Thank you!
traindoor
02-20-2016 11:12 AM
For a chart, you can only use the bundle for single data points. Since you already have an array of points, you need to use Build Array to make a 2D array to wire up to the chart.
02-20-2016 11:55 AM - edited 02-20-2016 11:57 AM
I always use one of these methods
02-20-2016 03:36 PM
... (echoing Hatef) and I never use those two methods, but rather a (small) modification to Crossrulz's method. Crossrulz noted that if you already have each channel's worth of points in a 1D array, you could simply use Build Array to create a 2D array (row 1 being Channel 1's points, row 2 being Channel 2's points).
However, it makes a difference to what you wire the 2D array. Suppose you wire it to a (Waveform) Chart. Recall that Charts expect to get their points one-at-a-time, and processes 2D arrays by row. So if you have two channels of 500 points and Build Array, you will have a 2-row, 500-column 2D array, and the Chart will think you are plotting 500 channels (all the data in Row 1) with two data points (the rows). Oops. Fortunately, there's the Transpose 2D Array function on the Array Palette which changes the array to one of two columns (= 2 Channels) and 500 rows (= 500 points), which plots just fine.
Got it? OK, here's a Quiz -- what if (knowing you are dealing with 500 points-at-a-time instead of one-at-a-time) you decide to use a Graph instead of a Chart? [Warning -- this is a Trick Question]. Because the Graph expects rows to be Channels (or "plots"), you do not want to use the Transpose 2D Array when plotting multi-channel graphs.
A fun thing to do is to take Hatef's nice example and add on the Crossrulz/Schor Method, and to "expand" both by creating a set of Graphs in addition to Charts.
I hope the somewhat-long-winded explanation of "Why did they do it that way?" that I provided makes sense to you. Just remember that 2D arrays are usually processed a row at a time, and ask yourself how LabVIEW made the 2D Array, was it a point-at-a-time (= Charts) or a plot-at-a-time (= Graphs). And, if you can't figure it out, just try it and see if it makes sense -- if you instead see hundreds of different plots, haul out Transpose 2D Arrays and see if that fixes things.
Bob Schor
02-20-2016 03:46 PM
You need to build 2D array from two 1D arrays of data channels and make sure that chart is not set to "Transpose Array".
Attached you can find modified version of your VI.
Thanks,
Arev
CTO | RAFA Solutions