LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read new data from main vi to sub vi on each loop of sub vi

I know this is possible (or at least I think I do), what I have is essentially two while loops, one is in hte main VI, which contains all my sub vi's, and the other is in one of my sub vis. I have a DAQ signal coming in to my main VI, and this is being sent to various sub vis and conditioning equations. One of the sub vi's is a pop up window, which allows the user to calibrate the device. It runs a while loop loging the voltage from the DAQ signal, generating a best fit line, and sending the slope and intercept data to a configuration file.

The problem is, the sub VI is taking the valueof the DAQ at the start of hte while loop, but then not updating it on each itteration. Someone told me I should look at global variables, but I could not figure out how to use them. Could someone please explain how the value can be updated in each loop of the sub VI ?
0 Kudos
Message 1 of 4
(2,625 Views)

munkifisht wrote:
Could someone please explain how the value can be updated in each loop of the sub VI ?

To make this happen, you have to pass the reference to the DAQ signal (say, it is a waveform graph) from the MainVI into the SubVI. passing the variable as such will not make it get updated in the MainVI after each run of the loop in the SubVI.

- Partha ( CLD until Oct 2027 🙂 )
Message 2 of 4
(2,606 Views)

Hello.. 🙂

 

According to me global variables will be better potion to solve your problem... You need to take values in global variables and read them in your sub VIs...

 

1. Go to block diagram - right click to get function palette - then got to all functions - structures - select global - put it in your VI - then double click on the global - then a front panel will open.

2. Take the variables you need save the file.

3. Then copy the same global variable fro the block diagram and paste it in the sub VI where you want. Left click on the global variable and you will be able to select the one of the variables you created in the global front panel.

4. Whenever you want to use these global variables just copy the variable from the VI and paste it another VI where you want to use it..

 

 

I hope this will help you.. 🙂 Best luck.. 🙂

Message 3 of 4
(2,604 Views)

Hi munkfisht,

      It would help if you were to attach your Main VI - or a screen-shot of the diagram.  At this point it's not clear whether you have one, or multiple processes in your main VI.  It sounds like there should be a couple of parallel loops (AKA "threads" ) running, and to pass data between them a Global can work, though, a Queue or Notifier is probably a "better" choice.

 

Rupali answered where to find the Global, though

 

If you find yourself puzzling over how to know when new data has arrived, or become worried about new data getting over-written by accident, these potential problems dissappear when using a Queue!

 

Cheers!

Message Edited by tbd on 09-23-2008 11:33 PM
"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
Message 4 of 4
(2,596 Views)