From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State vs SubVI, which one is faster/better?

Hi,

 

im working on a project which using a state machine to build an application for windows CE. I'm wondering which one is faster/better. I'm continuing the project, so basically I'm not the one who created the project from zero.

 

The task is simply to switch ON/OFF different valves at certain time. We have a subVI "command_DO" in the project which is used to send T/F to switch the valves (input is port number and a boolean).

 

In a certain situation, I need to turn ON/OFF some valves at once, let say 5 valves at once. For this case, I think I can call 5 subVI's in one state, which I think it would save time rather than calling 5 states with 1 subVI in each state. I thought, calling 5 states would cost 5x time of 1 state call.

 

But on the other side, this means I would have much subVIs in the state. Just imagine, if it becomes more complex, I think the  '1 state with 1 subVI'-form could help me with just simply calling states instead of calling subVIs directly.

 

I couldnt find much information about this (state vs subVI), and I hope someone can help me with this.

 

regards,

Yan.

0 Kudos
Message 1 of 2
(1,939 Views)

I'd use a FOR loop.  But the subVI inside of the FOR loop and use Autoindexing to set your values.  That makes it very extendable if you need to add or remove commands.


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
0 Kudos
Message 2 of 2
(1,928 Views)