LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble getting a subvi to update a graph in real-time on the front panel

Hi All,

First post here, so play nice =). I am trying to update a graph on the front panel from within one of my subvis, however it does not update it in real-time. It will only show the completed graph after the subvi finishes running. I have tried to use references/property nodes and I have also tried using my chart as a global variable, but neither of those methods have worked (I am probably doing it wrong). Can anyone provide a detailed walk-through of how to do this using either one of those methods? Or perhaps even a different method?

0 Kudos
Message 1 of 36
(4,066 Views)
You drop a lot of fancy words, but without telling us how you use these things, all bets are off, Obviously you are doing something wrong. If you show us some code we can point it out. 🙂
Message 2 of 36
(4,053 Views)

Unfortunately, and I know this makes things far more difficult, I cannot provide any code. I can outline it for you, but I can't upload the code itself here. To start off, I will outline what I did with the global variable method:

 

1. I created a global variable and placed the graph I wanted on it.

2. Then I right-clicked on the global variable and did Select Item -> Graph. 

3. I replaced the graph indicator in my subvi's block diagram with the global variable I had just created. 

4. I placed the global variable on my main vi's block diagram, and right-clicked it to create an indicator. 

 

If I have the global variable front panel open, I can see the graph being updated just fine. However, it does not update itself on my front panel. There is probably something minor that I am doing wrong. 

 

If at all possible, I would prefer using global variables to accomplish this task, as it makes the diagram simpler. I don't think I would have to worry about race conditions, because only one portion of code can write to the graph at any given time anyways. At this point, however, I will pretty much do anything so long as it works. 

0 Kudos
Message 3 of 36
(4,044 Views)
You probably need some independent loop that polls the global and feeds the graph. A better solutin is a reference to the graph, then inside the subVI you write to a value property. All these things re a bit convoluted and not performance oriented. Maybe you should consider a more natural approach, e.g. using an action engine.
0 Kudos
Message 4 of 36
(4,038 Views)

Since you are creating an indicator of the global variable, why wouldn't it just automatically update whenever the state of the graph on the global variables front panel changes? Ah well..

 

What is an action engine and how would I use it? 

0 Kudos
Message 5 of 36
(4,035 Views)
... sorry for the typos. I am answering using my phone and cannot edit 🙂
0 Kudos
Message 6 of 36
(4,032 Views)

Also, I had tried the reference method, but it did not work. This is how you do it, right?:

 

1. Create a refnum control in the subvi that links to the graph in the main vi.

2. I created a property node and wired the refnum control to it, selecting value in the property node. 

3. I created an input terminal on the subvi's connector pane (to wire the reference in). 

4. I created a reference and wired it to the newly created terminal on the subvi. 

0 Kudos
Message 7 of 36
(4,030 Views)

 


@ModusPwnens wrote:

This is how you do it, right?:


 

Try this for a quick demo of the reference method:

 

 

  1. Create a VI as shown in the image.
  2. Select only the while loop and do "edit...create subVI" (as shown). (you will get a subVI that contains the needed connectors and is alread wired to the reference)
  3. Run the main VI, and the chart will update every 200ms.
Note that this is only a draft and many things are missing. (For example, the subVI cannot be stopped at the moment. Also, you want a graph, and not a chart.)
.
.

 

0 Kudos
Message 8 of 36
(4,019 Views)

I just tried the equivalent of that in my project, and it did not work. However, I did not create a subVI out of it like in that example. I tried, and I actually just ended up with a giant clump of references and wires for some reason. In any case though, I did the equivalent. I wired a reference to the graph into the subVI, I linked that to a refnum control, and then I wrote the values to a property node. That should do the trick right? I mean, if it helps, I suppose I could provide a screenshot of the section of code in question...

 

EDIT: It turns out that for some reason the graph does not get updated at all anymore, even when the subVI finishes running. Maybe there is something else going on..

0 Kudos
Message 9 of 36
(4,005 Views)

 


@ModusPwnens wrote:

I tried, and I actually just ended up with a giant clump of references and wires for some reason. 


 

What else was in the selection (direct property nodes, local variables, etc)?

 

 


@ModusPwnens wrote:

 

EDIT: It turns out that for some reason the graph does not get updated at all anymore, even when the subVI finishes running. Maybe there is something else going on..


 

If you update it from within the subVI, and the subVI stops running, I would expect it to no longer update. 😉

 

 


@ModusPwnens wrote:

 I mean, if it helps, I suppose I could provide a screenshot of the section of code in question...


Yes, please do.

 

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