LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Control value to sub-vi via connector input

Hello
Question is fairly generic. I have developed a sub-vi which is a simple
state machine design. It has a while loop with 3 states. The default state
is essentially checking a push-button(latch when pressed). When pressed it
executes one of other states once and returns to default. Pressed the next
time, it executes the other state and returns to default. Essentially it
toggles between two states(that send out a GPIB command). It works fine and
does exactly what I want to do.

Problem I have is, when I use this sub-vi(to build say a control panel), I
create the controls that are eg wired to the inputs at this level. When I
execute this vi, press the push button for example, no data passes into the
sub-vi to write to
the same control within it.

Is there a way to make this happen? That is, pressing the push button at the
top level, data 'writes' to the sub-vi control via the input within it's
While loop and execute approp, case? It does not do so. It only sees the
first state of the 'image'(for lack of being able to call it something else)
control and any subsequent presses of the button(T/F) does not pass into the
sub-vi.

It seems wiring the control to that within the sub-vi(in a While loop) via
the connector input, to which the latter control is connected does not see
any subsequent states, as long as the while loop is running?

I know a While loop when running won't accept new values from outside it,
but it does from any control within it. But why won't it do so if a control
is created on the input, which is connected to the sub-vi control within the
loop at the main vi-level?

Hope I have not overdescribed it in so many words to cloud up my situation.

TIA
Khan
0 Kudos
Message 1 of 3
(2,461 Views)
If i got your problem, the solution is simple. Just remove the inside while loop, as long as i think you already have a main loop. This way, you will repeat the main loop once and again, and the state machine inside the subVI, now a case structure, will select the state depending on the button input from outside. Hope this helps
0 Kudos
Message 2 of 3
(2,461 Views)
If you trace through the program, you will find that data flows from the top level VI down to the subVI, then the while loop in the subVI will run and the program execution will stay there. Execution will not come back out of the subVI until it has finished running. Because of this, the front panel controls (in the top level VI) are not even being checked.

The trick here is to not put a while loop in the subVI, or (if you really want the while loop in the subVI) use references to check the controls in the top level VI.

Rob
0 Kudos
Message 3 of 3
(2,461 Views)