From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

XY- Graph: Y axis plots values from multiple channels that are not wired to the graph

Hi everyone,

I have made a VI to log values of data on xy graphs coming from the output channels of a phidget 4 channel board (1046). I found a sub VI on one of the knowledge base pages that would allow my graphs to work as charts. The trouble that I am facing is that the y-axis of each of my graphs respond to changes in channels that are not even wired to them. I have 3 graphs which are supposed to function as follows :

1. Horizontal load (y axis) vs Horizontal displacement (x axis)

2. Vertical displacement (y axis) vs Horizontal displacement (x axis)

3. Vertical load (y axis) vs Horizontal displacement (x axis)

So, for example if I was to make a change in my vertical displacement input then the problem is that I would see that being plotted on graph 1 and 3 also and similarly for the other graphs. I cannot find a solution to it and have checked my VI multiple times to make sure I did not wire things into the wrong places. The VI is attached here for reference. Would really appreciate all the help anyone can offer.

 

Thanks

0 Kudos
Message 1 of 7
(3,247 Views)

Hi Abhi,

 

I'm guessing that this is the article you're talking about? How Do I Make an XY Graph Behave as an XY Chart?

 

This example uses a LabVIEW construct called an Uninitialized Shift Register. The idea here is that the SubVI you're calling will use a While loop with True wired to the stop condition - every time you call the SubVI, it only runs once.

 

The left side (on the outside) of the Shift Register (the VI actually has two, but I will just explain for one, the other is the same) is unwired - meaning it is not initialized (hence Uninitialized Shift Register). The Shift Register will take the last output value from the right hand side of the shift register when it is not initialized. This means, every time the VI runs, it has some 'memory' of the last time it ran.

 

When you call it in 3 places in the same code, it doesn't distinguish what should be done with separate data streams - although the knowledge base article doesn't mention it, this code should only be used once per VI. You can change this by making the VI 'Pre-allocated Reentrant' on the VI Properties under Execution (right click on the icon and select VI Properties) or you can directly implement the code using a shift register (actually, 4 shift registers) in the main VI which you uploaded.

 

In that case, you would want to have something like the following (I only make 2 Y measurements here, and don't include any of the data gathering VIs because I don't have the toolkit!):

Example_VI_BD.png

This however doesn't control the maximum length of the array - it is unbounded. You can easily implement this if it is important to you using the VI you described in the article I linked to - simply delete from the front of the array if it becomes larger than some value.

 

As an additional comment - it looks like a lot of your code is the same. You might consider creating a (optionally parallelized) For loop with auto-indexing array inputs to simplify the block diagram and make it clearer you're doing the same thing to multiple channels.


GCentral
0 Kudos
Message 2 of 7
(3,155 Views)

Since you are not interpolating on the "xy-charts", the order of the points in the history buffer does not matter. All you need to do is initialize a 2D array of the right size with NaN (NaN values are not plotted!) and replace the oldest column with the newest data and slice out the various rows for graphing. Here's a very simple draft using simulated data. Modify as needed.

 

 

Of course if you want the history length to be adjustable, you need to add code to juggle the existing data whenever the history is changed (trim or grow the array making sure that the insert point and existing data is shuffled and padded properly so the newest new-N points are retained).

 

 

Download All
0 Kudos
Message 3 of 7
(3,144 Views)

Hello,

Thank you so much for your reply. Could you suggest a way by which I could some how obtain a trend line (History of all data points) on my XY graphs without having to use the XY Graph as XY chart VI. I changed my data logging device due to a misdiagnosis that there was something wrong with my Phidget 1046 board. But now,  I am using simple arrays and clusters to wire the data samples to the XY graphs. The graphs are functioning fine, except that I am not sure how to see a trend line (all points being plotted on the graph) which I could in case of using the XY graph as chart VI. I am new to lab view so I am not well aware with all the things that you mentioned in the reply to my initial query and am still trying to figure that out. If you could show me a more step by step solution with reference from my VI then that would really make things easier for me to understand. Thank you once again for all your help.  

Download All
0 Kudos
Message 4 of 7
(3,126 Views)

What is a trend line? How does the data look like? If the data is not too crazy, maybe a low order polynomial of the xy data would be sufficient. You could even do a polynomial for the x and y arrays as a function of index to get a curve in 2D space, the re-evaluate the polynomial on a finer scale before plotting. For some reason you are no longer interested in earlier history data. Is this now a new task?

0 Kudos
Message 5 of 7
(3,113 Views)

abhi@yorku wrote:

Hello,

Thank you so much for your reply. Could you suggest a way by which I could some how obtain a trend line (History of all data points) on my XY graphs without having to use the XY Graph as XY chart VI. I changed my data logging device due to a misdiagnosis that there was something wrong with my Phidget 1046 board. But now,  I am using simple arrays and clusters to wire the data samples to the XY graphs. The graphs are functioning fine, except that I am not sure how to see a trend line (all points being plotted on the graph) which I could in case of using the XY graph as chart VI. I am new to lab view so I am not well aware with all the things that you mentioned in the reply to my initial query and am still trying to figure that out. If you could show me a more step by step solution with reference from my VI then that would really make things easier for me to understand. Thank you once again for all your help.  


Your VI looks similar to the snippet I posted because of the thick, orange 'dbl array' lines you get from your measurement - you're now taking 1 channel N samples instead of 1 channel 1 sample (which is fine). However, it's not actually the same!

 

In my snippet, there were Build Array nodes, which added the new point to the old points in an array using the Concatenate Inputs option on the right click menu. Here, you don't have this node, so there is no concatenation - you only have the newest points (which looks like your N is actually 1). 

 

You can keep the old points by re-adding the Build Array node, in between measurement and the Bundle Array. Take another look at the snippet and you should be able to see what I mean.

 

As a further (unrelated) note, you're starting and stopping the acquisition tasks in every iteration of the loop. Probably, you should create the tasks before the loop, end them after the loop, and only actually measure them inside the loop. To quote an amusing analogy I saw yesterday:

 

GerdW wrote:

What would you do if you want to read a book? Would you open and close the whole book for each new paragraph? Or would you open the book once before reading and close it, when you have finished the chapter?


GCentral
Message 6 of 7
(3,104 Views)

In response to a private message, I want to note that I failed to comment above on the importance of Shift Registers - these are the arrows on the edge of the While loop (right click on the loop to add) that hold the history. Whatever is connected to the right hand side on the inside, is passed to the left hand side inside on the next loop iteration. 


GCentral
0 Kudos
Message 7 of 7
(3,090 Views)