LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error Using Array of Clusters on XY Graph

Solved!
Go to solution

I'm somewhat new to LabVIEW.  I'm trying to create an XY Graph of readings from 4 sensors (Y1-Y4 data) vs time (X data).  I thought I had followed the example from NI website but I'm getting this strange error.

 

These cannot be wired together because their data types (numeric, string, array, cluster, etc.) do not match. Show the Context Help window to see what data type is required.
The type of the source is 1D array of
cluster of 2 elements.
The type of the sink is 1D array of
cluster of 2 elements.

 

Any help will be greatly appreciated.  See attached VI

0 Kudos
Message 1 of 9
(262 Views)

Hi 
I wasn't able to open the file. Please save it for LV 2020. 

 

For plotting an XY series of data, you need 2 arrays of doubles, one for X points and the second for Y points. 

They should be then "bundled" as a cluster of 2 arrays to be ploted on XY plot 

LVNinja_0-1753300061402.png

If you want to plot 4 sets of  XY values, you need to 

create 4 separated bundles of Clusters, then build  an array of these clusters. 

LVNinja_1-1753300284174.png

 

 

Message 2 of 9
(242 Views)

Thank you for the reply.  I saved it as 20.0.  See if you can open this one.

 

 

0 Kudos
Message 3 of 9
(221 Views)
Solution
Accepted by topic author gemoco

You are mixing 1D and 2D arrays.

 

I cannot see how your IO is configured, but are you really reading N channels one sample each? Shouldn't that be only 1 channel, 1 sample? In that case you'll get 1D arrays and things will work.

If you really have N channels each (and N is different for each IO, you need to wrap all bundle as follows to get an array of xy.

altenbach_2-1753305635710.png

 

If N is the same for all, this will also work:

 

altenbach_1-1753305585139.png

 

 

Most of your shift registers are not initialized, meaning they will retain data between runs and grow forever. So fix that too!

 

I don't have any DAQ installed, so I cannot comment on your hardware configuration. Do you really have four different devices?

 

 

0 Kudos
Message 4 of 9
(217 Views)

Thank you for saving for 2020. 

 

In your code, you need to initialize the array like you did with the X array. 

Then Concatenate the inputs of the build array so that you will have a 1D array for Y values. Then you can bundle 2 x 1D arrays to plot XY. 

Ensure that you are getting same number of points from daq (Y) as the time (X). At every iteration you get 1 scalar for X (time): You will get then 1 scalar per reading from the Daq. If you are getting just 1 scalar, from daq, then you need to use Index array to get the first number of the array.

I did the modifications in your code for 1 channel so you can see how the wires should go together. Do the same for the other 3 channels and you will be able to plot your data. 

 

Be mindful that this solution consumes memory - build array creates a copy of the array in memory. 

 

LVNinja_1-1753306160334.png

 

 

Message 5 of 9
(212 Views)

If you concatenate the channel arrays, they will be N times longer than the time array, so this will not work right.

 

You could make your life significantly simpler by not allowing dt changes during the run. Now all you need is a plain waveform graph (or maybe even a chart).

Message 6 of 9
(206 Views)

Thank you both @LVNinja and @altenbach for your replies.  Good information on both accounts and as usual there is more than one way to accomplish anything in programming.  


@altenbach

Putting the reads back to 1 channel, 1 sample solved the error I was getting.  I had experimented with reading multiple channels on a single read in a previous version of the app and forgot to change back to 1 channel before I copied and pasted to add new inputs.  That error message was confusing to me and not very indicative as to the actual problem.  Probably just because of my lack of experience with LV.

 

My hardware for this app is a CompactDAQ cDAQ-9189 with modules for Thermocouples, RTDs, and AI 0-10V modules for differential pressure sensors, humidity sensors, and possibly other sensor types.  That is why I have different tasks for the different sensor types. I have created a Simulated cDAQ chassis because I don't currently have the actual hardware available.  The actual number and types of sensors has not been defined at this point in the project.

 

I actually did have all of my shift registers initialized in an earlier iteration of the app.  I will get that fixed.

 

The goal of this app is to run for some period of time (probably several minutes) capturing each sensor value (Ys) on every time interval (X), probably 1-60 seconds.  Then when the app terminates, generate a report (probably in MS Word or Excel) with a graph of the data included in the report.  So, for a LV newbie, I've got some learning to do.  LOL

 


@altenbach wrote:

If you concatenate the channel arrays, they will be N times longer than the time array, so this will not work right.

 

You could make your life significantly simpler by not allowing dt changes during the run. Now all you need is a plain waveform graph (or maybe even a chart).


My intent is not to change the dt during the run but to set the interval before the app is executed.  I guess I should disable that "Seconds per Data Point" control at runtime, huh?  I didn't even notice that.  🙄


Again, thank you both for your replies and for sharing your knowledge with struggling LV developers like myself!

 

0 Kudos
Message 7 of 9
(171 Views)

@gemoco wrote:

My intent is not to change the dt during the run but to set the interval before the app is executed.  I guess I should disable that "Seconds per Data Point" control at runtime, huh?  I didn't even notice that.  🙄


If dt is constant, I definitely would recommend to use a waveform graph. You can set dt for the x-axis before the loop based on the loop time using a property node. Now you only need one shift register containing a 2D array of all data where you append one row of data with each iteration. Many fewer cats to herd. 😄

Message 8 of 9
(157 Views)

@altenbach wrote:

@gemoco wrote:

My intent is not to change the dt during the run but to set the interval before the app is executed.  I guess I should disable that "Seconds per Data Point" control at runtime, huh?  I didn't even notice that.  🙄


If dt is constant, I definitely would recommend to use a waveform graph. You can set dt for the x-axis before the loop based on the loop time using a property node. Now you only need one shift register containing a 2D array of all data where you append one row of data with each iteration. Many fewer cats to herd. 😄


Thanks!  I'll have to see if I can figure out how to do that.  I like fewer cats! 😁

0 Kudos
Message 9 of 9
(138 Views)