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: 

event structure - vi execution

Hi,

I have created an event structure which opens different sub vi's depending on which button is pushed. When the vi is closed the data from that vi is held in shift registers for use in later vi's.
 The data is dependent on user input.

My problem is that the data that comes out is not what the user inputs but what was in the vi when it was last opened  (or the default values if its just been opened).

I have put 0 value constants outside the while loop containing the event structure in order to try reset the values. this just leads to 0 values being passed to the shift registers if the event structure times out.

How do i change the vi or the event structure so that when the vi opens the user can change values within the vi and these changes will then be passed on when that vi front panel is closed?

Hope that makes sense

 

I am thinking it is either something to do with how i am initiating the arrays etc which are linked to the shift registers or something that can be changed either in the event structure or vi properties but cant seem to figure it out.

 

Thanks

0 Kudos
Message 1 of 15
(2,969 Views)

hello

 

we will be able to know what you are doing and see what needs to be done, if we see what yuo have done.

 

theoretical explanation of what you did gives us only some understanding. we need to see how you are initializing the shift register, what cases you have and what controls you have on the GUI before we can give a good solution.

 

If you can post the vi, in LV 2010 or lower, i can have a look at it and try to help you.

 

 

Regards
Freelance_LV
TestAutomation Consultant
0 Kudos
Message 2 of 15
(2,965 Views)

Innn your "dialog" subVI, do you ensure that you affct thhhe output terminal only after the user entered the data?

From what you describe it could be that you just wire data_in to data_out without waiting for the user to modify data_in on the front panel.

0 Kudos
Message 3 of 15
(2,953 Views)

There are two basic ways to do this, and it sounds like you are trying one of them but doing it incorrectly:

 

  1. The VI which is called contains an uninitialized shift register.  This holds the data it last had when the VI was called last.  As long as the VI is in memory, it retains the data.  It sounds like you are trying to do this, but have initialized the shift register.  This will result in the initial data overwriting the new data each time the VI is called.
  2. Hold all data in a shift register in the calling VI and pass it to the called VI each time.  This is fairly foolproof and takes care of a lot of race condition issues.  It does require you to maintain a lot of data in your calling VI.

There are lots of more advanced ways to do this that work better in some circumstances.  Please post your code so we can look at your circumstance and make concrete suggestions.

0 Kudos
Message 4 of 15
(2,932 Views)

Sorry, I wasn't at my computer when I posted that question.

attached is a word doc with screen prints of the front panel of the main vi and then back panel followed by front panel and back panel of the first of the buttons.

0 Kudos
Message 5 of 15
(2,901 Views)

All of your tunnels in the event structure are set for Use Default if Unwired, and you have a number of those tunnels unwired.  You should wire all of those tunnels across in every case.  You are probably losing data when an event case executes that fails to pass through the data from the left hand shift register to the right hand shift register.

0 Kudos
Message 6 of 15
(2,899 Views)

I have wired those ones but only once they have been called in subsequent events.

 

SO i took away the empty constants on the left side and that has helped. However I am interested in learning the second option you mentioned DFGray. Could you give me an example please. I would really like to learn how to program more efficiently. I haven't been doing it very long and its mostly self taught so any help would be appreciated.

0 Kudos
Message 7 of 15
(2,896 Views)

@Trigirl wrote:

I have wired those ones but only once they have been called in subsequent events.



That doesn't sound very reliable.  I still highly suspect your unwired tunnels.

 

Your subVI has two path controls in it.  But you don't have paths wired into it when you call the subVI.  So what paths are being used?  They are either a default empty constant, or have something set as default.  In which case there is no point in having the controls, you've effectively set them as hardwired constants.

0 Kudos
Message 8 of 15
(2,893 Views)

With the unwired paths I though if I had them unwired then they open up the file prompt for me to select the file I want. WHich it does.

Is this not right?

I do have default values in a lot of my initial controls as I put them in so I had something to check the program with and now am going back and deleting them.

I know my programming is a bit messy.

DO I need to wire the shift registers across every event even if no data will be coming to it until later?

0 Kudos
Message 9 of 15
(2,884 Views)

If they are empty paths, then the default action for those subVI's is to open a file dialog.  If that is the behavior you want, then that is fine.  But then I'd get rid of the file path controls out of the subVI unless you do plan on using them at some point.

 

I'd recommend wiring things across even if you don't expect to use that data again.  It is just a matter of time that the VI will execute some sequence of events that you didn't anticipate (perhaps a user clicks buttons in an order you never expected) and your VI will start acting badly because data stored in the shift register reverts to default or empty data.

 

The only time I use Default if Unwired is perhaps on a boolean where most cases would be to output a default value of False, and one or a few cases would output a True to do something like end a while loop.

0 Kudos
Message 10 of 15
(2,882 Views)