07-07-2009 02:55 PM
Why can I use a local variable in a simulation loop, but not in a simulation sub-VI?
Solved! Go to Solution.
07-07-2009 03:29 PM
07-08-2009 05:50 AM
So does that mean that local variables don't function in any sub-VI? Even if they're not used outside of the sub-VI?
Also, if local variables are disabled for simulation sub-VIs is the only alternative to use a shared or global variable?
Thanks for shedding some light on this.
07-08-2009 08:51 AM
The only local variables that will work in a subVI are the ones that refer to controls or indicators that are in the subVI. If you need to pass data between different subVI's, then you have a few choices.
1. Shared variables, like you said.
2. Global variables, like you said.
3. Pass the data in or out through the connector pane of the subVI.
4. Functional Global Variables/Action engines.
5. Queues
6. References to the controls in the main VI so that they are used with property nodes in the subVI
07-08-2009 09:44 AM
A little backstory which I should have given when I asked the question.
I have a simulation of an engine and I want to enable/disable the engine clutch. Since there are conditions on changing the clutch state I was using local variables when I developed the engine simulation in a simulation loop. After I had fixed the bugs I tried to transfer the contents of the simulation loop into a simulation subVI for use in my main project. I was unable to transfer the simulator because I had local variables in the engine simulation.
I think I understand that I can't use a local variable in a simulation subVI because there's no front panel due to the way a subVI is called.
Thank you for the help in understanding this better.
06-24-2011 09:33 AM
Hi pasteless ,
Did you find alternative to replicate the variable ( use parameter value without wiring throughout the vi) in simulated sub vi ??thanks