LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I pass data generated in a SubVI inside a Case Structure out of the Case Structure?

Hello,
 
I am using a USB 2701 to control a heater.  I have three SubVIs that are all working properly on their own.  I'd like to use an Enum to select which of the SubVIs is running at a given time.  The problem is that no data is passing out of the case structure.  How can I pass the temperatures and heater outputs acquired by the SubVIs to the main VI?  I've attached my some of my code below.  I can't attach more than 3 files, but you can see how the main VI is configured.  Like I said, the SubVIs are working individually, so you shouldn't really need to look at them.
 
Thank you,
CJones581
0 Kudos
Message 1 of 6
(3,094 Views)
Data is passing out of the case structure from the subVIs but in order to do that, I had to keep the subVI visible and stop it manually. With the while loop in the subVIs, how are you stopping them? You did not make the front panels visible when called. Are you stopping the main VI with the Abort button? That's not the correct method and that would be why you don't get anything back. Unless you want the user to click the stop button on front panel of the subVI, just get rid of the while loop. If you do want the operator to click on the stop button, change the VI Properties>Window Appearance>Customize so that the front panel is shown when called.
Message 2 of 6
(3,084 Views)
CJones,
 
You might check a couple of things.
  1. Your HeaterTCD... VI has a While loop with a stop button condition.  HeaterTCD pass out values only when it finishes running.  If it doesn't pop open the front panel (which usually doesn't happen when running a SubVI) you could run into a stuck loop because you don't have access to the Stop button.  This could appear in the form of no data being passed out (because the SubVI never stops running).  The primary VI opens the HeaterTCD VI, starts it, and waits for the VI to finish and pass final values .
    1. Secondary note: Unless you want your SubVI panel (which probably isn't open when running the main VI) to update continuously, consider moving your Temperature Graph and Temperature oC indicators outside the while loop.  Pass final values to them via a tunnel, since the main VI will only read their values after the loop finishes running, anyway.
  2. It might help to add error management to HeaterTCD like you have for RampHeater.  If you connect error lines with Error Outs to your main VI, that will help tell if there is an error somewhere that is preventing info output.
  3. RampHeater SubVI has the same issue with the stop button.  It is also probably getting stuck in the While loop waiting for a manual push of that SubVI's Stop button.

An easy way to test this would be to set up a logic circuit so that when the While loop iteration counter reaches a certain number, it registers True and sends it to the conditional.  I know this isn't what you want to do long-term, but if that lets your SubVI return outputs it means that the SubVI was just never stopping.

Hope that helps.

David C, Applications Engineering

David C
Applications Engineering
Message 3 of 6
(3,080 Views)
Hi CJones,
 
As David C suggested, you don't see any updates as you do all this data acquistion in a while loop in a subVI. If you want to see these updates in your main program, then you have to pass the data to your main VI from your subVI's loop by using one of the following methods:
1. Glabal Variables
2. Single-Process Shared Variables
3. Functional Global Variables
 
You can search both the LabVIEW Example Finder (Help»Find Examples...) and ni.com for examples on all of those methods.
 
By the way, what is the full name of the DAQ device you are using? Who is the manufacturer?
Best regards,
Kalin T.
0 Kudos
Message 4 of 6
(3,025 Views)

I vote for the Functional Global. Also have a look at this Nugget on Action Engines: http://forums.ni.com/ni/board/message?board.id=170&message.id=240328

 

0 Kudos
Message 5 of 6
(3,017 Views)
Thanks everybody.  I moved the DAQmx vi's out of the Do While loop and that fixed my problem.
0 Kudos
Message 6 of 6
(3,002 Views)