08-11-2015 01:55 PM
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> ---'
08-11-2015 01:59 PM
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
08-11-2015 02:02 PM
Thanks for all yoru help guys, and girls.
I did what you guys said, and now it works
08-11-2015 03:14 PM
I feel invested in this a bit now, so don't leave us hangin'
What was holding up the VI?
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'