LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get live data from a subvi while it is running ?

Hi.

I'm finishing up my little application, and one of the things I cant figure out to get to work is getting live data from a subvi and displaying it on my main vi's front panel.

In my subvi I am sending about 10 commands to the serial port, each time updating a local variable that writes value to a progress indicator. I would like to get that indicator displayed on my main vi so I can see the progress of my subvi.

Currently I have just linked the progress indicator on the sub to a terminal, and connected that to my main vi, but, that only updates when the sub finishes its mission. Is there a way to update the main while the sub is active ?

Any ideas appreciated !

/Brian
0 Kudos
Message 1 of 19
(6,133 Views)

Have the progress bar on the main VI front panel.  Pass a reference to that control to the sub-VI when it is called.  In the sub-VI, pass that reference into a property node and write to the value property.  The front panel will have a "control reference" control

Attached is a rough picture of the VI's you would use.

Message Edited by Ravens Fan on 08-10-2007 12:18 AM

Message 2 of 19
(6,131 Views)
Ok, thanks.

I'm a bit on the loose when it comes to the subvi, how do I create the things in the subvi ?

I got the things so it looks like your suggestion, but it still doesnt update.
Download All
0 Kudos
Message 3 of 19
(6,117 Views)

Without seeing all of your code, I can't tell what may be going wrong.  I would recommend in your sub VI, cleaning up the blue wire so that it comes out of the right of the local variable.  It is always helpful to make your code readable so that data flows from left to right.  Have wires flow into the left side of an object and out of the right side.  Since you are assigning the value to the referenced control by way of a local variable, perhaps you have some sort of dataflow problem that's causing the local variable not to have the desired progress data.  We would need to see the rest of the code to be sure.

I have attached example VI's in LV 8.2.1 that work for me.  The sub-VI does nothing but return the same numeric value passed into it.  And you can see the value doesn't get returned until the VI is done.  But the progress bar on the main VI gets updated while the loop in the sub-VI is executing.

Download All
0 Kudos
Message 4 of 19
(6,094 Views)
There are some problem with the reference type in Ravens example.
 
Here's the easy way to do this:
  1. Place a progress bar (change to I32 for compatibility with the iteration terminal).
  2. right-click on the terminal of the progress bar and create reference
  3. Add a FOR loop, wire N, add a wait, and add a property node, wire the property to the reference, select value, change to write, wire [i] to the property.
  4. You should get something that looks like the image below.
  5. Now select all the stuff inside the yellow frame and do edit...create subVI.
  6. save subVI under a nice name.
  7. Modify as needed.

Message Edited by altenbach on 08-10-2007 09:18 AM

Message 5 of 19
(6,080 Views)
That's a good tip.  Thanks Christian.
 
I saw that I had a coercion dot for the reference wire going into the subVI.  I was curious about that.  But the code was working so I didn't worry too much.
0 Kudos
Message 6 of 19
(6,055 Views)

"... saw that I had a coercion dot for the reference wire ... "

Rumor has it that Christian was bitten by a coercion dot when he was very young. He has not been able to resist the tempation to sqwash them ever since. Smiley Wink

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 19
(6,052 Views)
I prefer using sunlight and a magnifying glass over squashing.  But I stopped that when I burnt too many holes in my LCD screen.Smiley Happy
Message 8 of 19
(6,041 Views)
Hey Guys, thank you so much for all the help so far.

I've attached my code as is, I have not yet tried the new suggestions that you came up with, however, this might give you a better idea of what I am working on.

When you get to see the code, please bear in mind that this is the very first labview I have ever done, I havent even read or had any training yet... I know its messy but hey, all have to begin somewhere 🙂

oh, forgot the code is protected. the code is "dl90rwsc" (its no secret anyway)

/Brian

Message Edited by Synchrotron Guy on 08-13-2007 06:14 PM

0 Kudos
Message 9 of 19
(6,006 Views)
In your VI Prg_all_sub, you are actually only writing out the progress bar once to the contol reference.  Once the code to the top has executed, it will never execute again although you continue to write values to the local variable PP throughout the program.
 
The quickest fix would be to put that code at the top in a loop with a small time delay function.  That way it continues to execute every time a new value gets written to the local variable.  You would have to use a local variable stop button to stop hat loop wonce your string of VISA reads and writes executes.  Also make sure to reset that stop boolean to false once the loop ends so that the loop will execute properly the next time this sub VI is called.
 
Other recommendations for cleaning up the programming is to use arrays or bundle values into clusters that you pass into and out of subVI's.  Prg_all_sub and MPS setup loader have numerous wires going into and out of the sub-VI's.  Bundling these together would simplify the wiring quite a bit.
 
Note also that in a lot of places you send in a wire to an indicator and branch it off to a local variable of the same indicator.  That is redundant.  Sending the wire to the local variable does the same thing as sending the wire to the indicator.  Try to use wires instead of local variables as much as possible.  For instance, near the top you send the output of the VISA resource name control back into a local variable of itself, (not necessary) then use a local variable numerous times in the case structure below.  Just wire the name into the case structure border, and maintain the value through all of the loops using a shift register.  This will eliminate dozens of copies of the VISA resource name variable.
 
In several places you concatenate a carriage return character to a string constant.  Just put a "\r" at the end of the string constant when it is shown in \ display.  Then you can eliminate the concatenation.
 
I hope this helps you get your progress bar working and help simplify the code for you.

Message Edited by Ravens Fan on 08-13-2007 09:34 AM

Message 10 of 19
(5,984 Views)