01-24-2017 12:57 PM
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.
01-30-2017 08:06 PM
Thank you everyone for pointing out my mistakes. This is my first time writting a program. I will try to improve on it. 😃
01-31-2017 02:22 AM
@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