LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SubVI and Global Variable

Solved!
Go to solution

1. Learn to use Shift Registers  and the terminals instead of the local variables.

2. You use the connector pane to pass data into your subVI.  I recommend having an input control and an output indicator instead of the local variables as this will allow for proper data flow and make your program easier to read and more efficient.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 11 of 13
(965 Views)

Thank you everyone for pointing out my mistakes. This is my first time writting a program. I will try to improve on it. 😃

0 Kudos
Message 12 of 13
(934 Views)

@S.Neo wrote:

"I have a VI full of local variables and I was planning to clear up the block diagram with SubVIs. "

Good.

 

"But I read that in SubVis there should not be any local variables and it must be changed to global variables. "

A misunderstanding. You should try to avoid local variables as they typically introduces race conditions and data copies. Remember that the wire is the variable. 'The wire is the variable'. Sub vi's should use their connector pane for data in/out, like the "Add" has 2 ins and 1 out. 🙂 Globals has their uses, but connectors are usually the answer.

 

"Just want to know if there is any other method to clean up my block diagram. I have attached an example of my block diagram. I would say  50% of the code consist of local variables."

It looks like your "compare something to Smoke detector" et al could be exchanged for a Case structure and thus removing ~70% of the control update code.

Building arrays and clusters should also help loads.

/Y


 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 13 of 13
(923 Views)