LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble passing iteration values between two separate VI's

Hello,
 
I'm having a bit of trouble passing a while loop iteration value from one vi to another.
I have tried creating a sub-vi of the "B VI" and dropping the icon into the main vi (in picture called "A VI") and just pull the itereation value out this way. So far no luck as an error occurs which causes Labview to crash.
I've spent a lot of time trying to use invoke nodes, globals and VI server references but I haven't gotten them to work either. 
 
In the pictures below "A VI" is the main acquisition application. "B VI" is the motor control application. Each VI will run at the same time but with their own front panel. Anyway, I would like to pass the while loop iteration value (Called "Steps") from the "B VI" to the "A VI" (essentially use this itereation value to keep track of the number of motor rotations.)
 
So far no luck so any help would be appreciated.
 
thanks in advance
SS
 
 
Download All
0 Kudos
Message 1 of 10
(3,567 Views)
Have you tried using shared variables?

Another would be to drop the diagram from the B. vi into the A. vi as a parallel loop and combine front panels.  Then, you could access the steps value using a property node or pull it from some type of queue.





Message Edited by vt92 on 02-05-2008 01:32 PM
>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
0 Kudos
Message 2 of 10
(3,559 Views)
Or.. using a global.vi that holds the value for both loops.


>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
Download All
0 Kudos
Message 3 of 10
(3,549 Views)

I've tried dropping B into A as a sub-vi but it's been crashing.

I've also tried to plop B's block diagram into A's but I ran into them not running parrallel....I'm trying to have both vi's runnig concurrently with the ability to start and stop each at will so to speak. When I tried, for instance, stopping A I wasn't able to restart A until B was also stopped.  Maybe I should try putting them together again and working it out that way.

Haven't tried shared variables...I'll take a look.

 

thanks

SS

0 Kudos
Message 4 of 10
(3,516 Views)
What determines how either VI stops?  How are you stopping them when they run individually?  You have a false constant wired to your outermost while loop, so those VI's will run forever unless you crash them by hitting the Abort button on the toolbar.  I hope you are not doing that.
 
The steps that are in the B VI that you want to get into the A VI.  Where do you want them to go?  It's not clear as to what you want to do with that value.
 
Another alternative is to use a functional global variable (search the forums for that, LV2 style globabl, or action engine).  You could pass the data between VI's that way.
 
You should be able to merge them into a single VI, but you may need to rethink your architecture.  An endless while loop isn't generally good programming style.Smiley Wink
0 Kudos
Message 5 of 10
(3,505 Views)

Hi,

sorry for the confusion. I attached less confusing block diagrams...hope that helps .

The only thing that is in B that i'd like to import into A is the "STEPS" iteration value. (its circled in green).

I'm looking to have this iteration value (from B) updated as A's loop runs.

I use the outside while loop instead of hitting the run continuously button....habit i guess

Right now I'm getting stuck on using Vi references....I've modeled examples fromt the forums and i just can't get it to work....its driving me nuts.

thanks again

Download All
0 Kudos
Message 6 of 10
(3,499 Views)
Best bet would be to write a 3rd VI that is an action engine.   See attached.  This is LV 8.5.
 
This is a non reentrant VI.  It runs once each time it is called.  It stores the value of steps in the uninitialized shift register.
 
In the one VI, set the enum to Set and wire the steps into it.
 
In the other VI, set the enum to Get (or leave blank), the value of steps will be passed out of the connector pane.
0 Kudos
Message 7 of 10
(3,493 Views)

Hey Raven,

Thanks for the quick help....I'm running LV 8.0 and couldn't open the 8.5 VI....could you post a screen shot?

thanks again for the help and I'll let you know how it turns out

 

best

SS

 

 

 

0 Kudos
Message 8 of 10
(3,485 Views)
Looking back at your latest screen shots, it looks like you were on track.  Sorry I missed that.
 
Here it is in LV 8.0.  Just drop a copy of this as a sub-VI into each of your two VI's and wire it up accordingly.
0 Kudos
Message 9 of 10
(3,483 Views)

Nice, very nice.....works like a charm....I would've never have gotten that....

thanks, saved me another few days of buggin out

best

SS

 

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