LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

subVI inside event structure wont run a second time.

Solved!
Go to solution
Solution
Accepted by fghfghgfhfhg

By "end itself", I mean the subVI has to end programmatically. There is no way for your main VI to tell it to end. So it looks like it does end itself because it ends after a certain number of iterations. This means that it's probably not this subVI that causing your main Vi not to end. Do like I said above and use the debugging tools to figure out what's holding up your code.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 21 of 24
(1,014 Views)

I looked at your main VI.  This program is defintely a candidate for a Producer/Consumer architecture.

 

1. Anything which takes more than a few milliseconds to run (magnet calibration? Hall measurement?) should be moved outside the event structure, probably into a parallel loop.

2. Shift regsiters are your friend. Get rid of the local variables. Wire directly to the control/indicator terminals.

3. Get rid of the STOP function. This has no place in most code and definitely not in your program.

4. It appears that you call Initialize Intrument.vi several times in your attempts to shut down. Some instruments take long times (100s of ms to seconds) to intialize. If this gets called several times during shutdown attempts, it just prolongs the agony.

5. Use a consistent mechanical action on the buttons.  Latch when Released is most often used.

 

Rather than trying to make piecemeal fixes, which are not working an may be making things worse, STOP. Spend some time with pencil and paper defining exactly what should happen and when.  Focus on the front panel buttons at first. Make a list of the buttons. in the next column write a brief description of what the program should do when that putton is pressed. Also list the data needed by (or produced by) that function.  You can use that list to define the events needed in the event structure and the parameters which need to be available or passed for that process to run.

 

Then proceed to design a state machine for the main control process. Each state should perform one task such as initializing the instruments, reading one data set, writing to file, setting instruments to a safe condition before shutting down, and so on.  The design of a the state machine should be done on paper before starting to code. This will allow you to define the states ahead of time and to verify that thigns like the shutdown process works as you want it to.

 

Lynn

 

Message 22 of 24
(1,009 Views)

Thanks for all yoru help guys, and girls.

 

I did what you guys said, and now it works

0 Kudos
Message 23 of 24
(1,000 Views)

I feel invested in this a bit now, so don't leave us hangin' Smiley Happy

What was holding up the VI?

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 24 of 24
(973 Views)