LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling my Subvi ? what am I doing wrong

Solved!
Go to solution

Hello People

 

I'm trying to create a simple program to read data from 3 channels ,I created a main VI for the GUI and a subvi to allow the user to choose which channels he would like to link to the front panel indicators.

 

I made something which look s like what I have attached but I have the following problems :

 

Sometimes and not all the times when I open the main VI ,i find the subvi opening automatically without pressing the calling button ,at that case I find the OK button already pressed and I cant close the subvi ,this also happens all the time if I built the vi into an exe program.

 

If the subvi was called ,if try to close it by pressing the "x" windows close button everything freeze in the main vi.

 

I tried also to add to other similar loops with two subvis for settings for other digital channels ,and the same happens with them.

 

what am I doing wrong.

 

Thanks in advance

Download All
0 Kudos
Message 1 of 11
(3,838 Views)

Since the subVI is modal, you need to close it before running the toplevel VI (if you have it open in edit mode, for example).

 

Your toplevel VI needs to be corrected. You neen events for the connect and stop buttons. The wait has no purpose since your loop has no timeout. Place the settings cluster in a shift register to maintain it between events.

0 Kudos
Message 2 of 11
(3,830 Views)

Thanks for the reply

 

what kind of events I need for the connect and stop button ? and with the wait you main the timout in the event case ? also what shall the shift register do in that case.

 

sorry I'm newly intorduced to labview so you may find me pressing myself so hard to understand generally simple things.

0 Kudos
Message 3 of 11
(3,817 Views)

Your loop only spins when the "channel setting button" is pressed, otherwise it just sits there. It cannot react to any of the other buttons, because of the event structure and the fact they don't trigger events.

 

Since "connect" and "settings" occur during different iterations of the while loop, you should place the settings cluster in a shift regsiter so they can be later used by the connect event.

 

Also note that latch action buttons only reset back to false once they are read by the code. Since you cannot stop your VI, you probably aborted it. Now the stop button is still pressed, because it hasn't been read yet, and it will be read the next time the VI is run. The VI will stop after the event has executed.

 

Here's a very quick draft of the toplevel VI how it could be done. Sorry, I don't have filedpoint, so the VI is broken for me. You don't need a wait orr timeout event, because there is nothing to do unless an event occurs.

0 Kudos
Message 4 of 11
(3,802 Views)

a lot of things are now clear for me ,I have ran your modified VI and I have found you have used shift registers to modify the values along the way.

also i found that you wired a false boolean as initiation to the loop that acquires data and wired a true in case of "channel settings" button is pressed.

 

the reason I placed a "connect" button is that I wanted the program to start normally without beginning to acquire data from the fieldpoint ,and then the user presses connect to begin acquiring the data ,so now I think you cancled the function of the connect button ?!!

 

also the subvi still freezes the program when the user presses the "x" button ,does that have a solution or shall I disable the "x" button to obligate the user to press ok ?

0 Kudos
Message 5 of 11
(3,777 Views)

Then go to the subVI and do one of the two things:

 

change the window appearance to hide the title bar

or

create a filtering event for "panel close?" and discard the event.

 

(Note that pressing the X in the upper right corner does not stop the sub VI, it just closes the panel, making it impossible to intereact with it.)

0 Kudos
Message 6 of 11
(3,772 Views)

thanks ,so far so good !!

and what about activating the function of the connect button as i mentioned in my previous comment ,what shall I do with that ?

0 Kudos
Message 7 of 11
(3,752 Views)
Which comment was that?
0 Kudos
Message 8 of 11
(3,743 Views)

I mean the message :

 

"the reason I placed a "connect" button is that I wanted the program to start normally without beginning to acquire data from the fieldpoint ,and then the user presses connect to begin acquiring the data ,so now I think you cancled the function of the connect button ?!!"

 

😄

0 Kudos
Message 9 of 11
(3,710 Views)
Solution
Accepted by topic author shadymohamed

There is an event for the connect button that executes when you press it. It will connect, but only if the boolean in the shift register is true, i.e. if you have configured the channel settings once. If you press connect right after starting the program, it will not connect.

 

If you want different behavior you can leave out the boolean entirely and initialize the shift register e.g. with the default channel settings. I don't have fieldpoint, so I cannot do that at the moment.

Message 10 of 11
(3,684 Views)