LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing an xy graph both inside and outside a loop

Solved!
Go to solution

Morning all.  Semi-new LabVIEWer here (five weeks' having fun).

 

This one's got me stumped.

 

I'm taking data from up to three GPIB units, generating three sets of current-voltage data, and I'm working on a real-time xy graph.  The data is in a two-dimensional array (n rows and six columns), and I'm selecting from a couple of combo boxes what to display on the x and y axes (maybe I'd want V1 vesus I3, or I2 versus I2, or whatever.

 

That bit works fine.

 

The problem is, in order to have it updating 'live' (which, surprisingly, works nice and quickly), I need to include the graph and the code used to parse the data inside the while loop ('while' n sets of data are taken), and this means that once the loop has completed, I can't access the graph or the code.  The best I can do is use property nodes to change stuff like autoscaling.

 

Rather than post my code, which after five weeks resembles the vascular system of a diseased human kidney, I'd like to ask whether you experienced people have general strategy in this sort of case.

 

I'm 90% sure that also relates to the fact that I'm struggling to find a way of retaining and using the completed data array outside the loop, other than dumping it into a table.  As it happens, I do want a table for it, but shouldn't there be some way of storing the array?  I come from a background of text-based programming rather than object-based, in case you hadn't guessed!

 

Thanks!  Smiley Happy

0 Kudos
Message 1 of 10
(4,106 Views)

OK, responding to my own question makes me look (a) desperate for attention and (b) too lazy to have thought about the problem in the first place (and I won't deny either), but anyway....

 

I can now figure out how to use the table indicator (into which I had dumped my array) and the xy graph 'value' property node to work the graph.  I do still seem to need essentially to duplicate the control structure (data parsing based on the combo boxes) which I had inside the loop, outside it.  Presumably not the 'right' way to go about these things?

 

Just to illuminate the supplementary question - the array thing - I currently initialise my array to the right size, pass it into a case structure (true/false - running or not) which contains the loop.  The data acquisition happens in the loop, which I exit once I've got all the data or I press 'stop', thence out of the case structure, and I can use the array however I see fit.  All very nice, shift registers working well.  The problem is that the other case, 'false', has to have the array wire connected right across it, so once I exit, the 'false' case becomes active and my array gets re-initialised.  As I said, I can dump it into a table before exiting the case structure, but it would be good to dump it into a variable I can use elsewhere rather than an indicator.

 

Thanks (again)!

0 Kudos
Message 2 of 10
(4,101 Views)

Hi Andyl,

 

I believe it would be better if you post your code so that we can see what you are trying to implement.

 

Thanks,

Shalini B
Applications Engineer
National Instruments UK & Ireland
0 Kudos
Message 3 of 10
(4,079 Views)

Thanks for replying, ShalB.

 

OK.  This is NOT the code I'm working on, but illustrates what I want to do and relicates the problem.  The real VI waits for a button press, then takes a sweep/step set of data from GPIB units.

 

The data dumps nicely into the first string indicator, but on exiting the case structure, the array gets re-initialised, and dumps the resulting empty array into the second string indicator.

 

Comment 1: removing the while loop allows me to put the data in both string indicators, but that's because the VI exits on completing the case structure.  I need stuff to be continuing (e.g. prompts for data saving, graphical displays, the option to re-start etc etc etc) once the data acqisition has finished.

 

Comment 2:  I'm not using a for-next loop in the real prog, I'm using a while loop, which exits either when a certain number of iterations has occurred or when the user escapes.  This has no bearing on the operation issue.

 

I can make this do the job (by referring to a 'value' property node for the first string indicator when I need to process the data), but I can't see why I have to have a 'physical' string or table indicator on my front panel rather than (as in any other programming language I've encountered) sticking it in an array variable to be referenced at my leisure.

 

As I say, I think it's just my misunderstanding of the philosophy of LabVIEW, and that there must be a very simple procedure for doing this.  I'd love to know what it is.

 

Thanks!

 

Andy

0 Kudos
Message 4 of 10
(4,054 Views)
Solution
Accepted by topic author AndyI

@AndyI wrote:

As I say, I think it's just my misunderstanding of the philosophy of LabVIEW, and that there must be a very simple procedure for doing this.  I'd love to know what it is.



Yes, as soon as the TRUE case has finished, the FALSE case executes which feeds an empty array to the outside indicator. Use also a shift register in the outer while loop and initilize it outside with an empty array. At the end of the iteration, feed the updated array to the right shift register terminal.

Message 5 of 10
(4,052 Views)

Ooh...!!!!!

 

An analogy would be problems wiring something up to a mains outlet in the garden shed, having then tried to connect via an extension in the main house, failing and expecting the solution involves patching into the local substation only to be told I need to plug it in outside the universe.  Completely insane in my example, but completely sensible in LabVIEW, of course.  Probably a deficiency of mind-expanding drugs on my part.

 

Many thanks, altenbach, it works beautifully.

 

Andy

0 Kudos
Message 6 of 10
(4,049 Views)

I spoke too soon.

 

It seems that I have to define the array dimensions outside the main While loop, whereas I actually need to define the dimensions based on user inputs inside the loop.

 

I could make the array very large and just use a sub-set of it to store my data, but that requires me (a) to use heaps of memory, (b) put a limit on the size of data set I can acquire and (c) chop off large chunks of the array before passing it to the graph (or other applications), which apart from extra programming (which I don't mind) would slow down the operation.

 

I've tried Reshape Array (within the loop), and I've tried using Insert Into Array to crowbar a correct-sized array into a zero-sized original array.  Of course, both of these act to re-initialise everything the moment I've collected the data, leaving me in the same situation I was in before.

 

I know this is the kind of application that many of you will have created - what am I doing wrong?  Tell me I don't have to dump my data into a table and LabVIEW isn't fundamentally flawed!  Smiley Wink

 

Thanks again,

 

Andy

0 Kudos
Message 7 of 10
(4,026 Views)

For illustration, here's my example VI modified.

0 Kudos
Message 8 of 10
(4,022 Views)

Well, you need to decide what do do if the size changes and reshape accordingly.

 

Here is an example that increases the array if the array is too small for the new data but keeps the size if it is too large. Modify as needed.

 

(Of course this is a rather silly example)

Message 9 of 10
(4,008 Views)

My application works with another 'while' around everything, but adding that and the relevant shift register worked nicely.  The penny hasn't quite dropped about why I couldn't achieve that yesterday, but I'll have a thorough check and implement it in my real application (which is currently bodged by using a table hidden behind the main panel as my 'store'...).  Anyway, all is demonstrably possible now.

 

Many thanks again.

 

Andy

0 Kudos
Message 10 of 10
(3,993 Views)