02-09-2010 06:37 PM
Hello all,
I currently have a program which applies and measures voltages and temperatures to a device, in sequence (stacked sequence structure of 10 stacks), contained in a while-loop. There are a set of maximum power, resistance and current values that I check each time I measure. If either the maximum power, resistance or current are surpassed, I would like to end the while-loop, and go to the safety conditions that follow. However, if a maximum value is breached in the 2nd sequence structure, the while-loop will complete (applying new voltages etc) and then exit. Because I want to have control of the ending conditions, and do not want the program to stop, I cannot use a "Stop" command.
Currently I have tried separating the while-loop into a sub-VI, and used "Stop", but that closes the main-VI as well, which I do not want.
I have also tried using an event structure wired to the value change of a button controlled by the power, resistance or current exceeding the maximum value, but my understanding is that event structures only recognize user specified changes, and not changes brought about through local variables.
Because of the amount of stacks, it would be difficult to have a set of case structures to ignore the remaining 8 or so sequences, but if that is the only way to go about doing this, please let me know.
Thank you very much for any help you may be able to give.
02-09-2010 06:53 PM
Two words you need to become very familiar with, "State Machine"
02-09-2010 07:32 PM
Hi Bobby,
In addition to Darin.K suggestion on "State Machine", do try to avoid using Stop function as well.
Below is the extracts from the context help of Stop function...
If you need to abort execution of all VIs in a hierarchy from the block diagram, you can use this function, but you must use it with caution. Before you call this function with a TRUE input, be sure to complete all final tasks for the VI first, such as closing files, setting save values for devices being controlled, and so on. If you put this function in a subVI, you should make its behavior clear to other users of the VI because this function causes their VI hierarchies to abort execution.
In general, avoid using this function when you have a built-in termination protocol in a VI. For example, I/O operations should be performed in While Loops so that the VI can terminate the loop on an I/O error. Also, consider using a front panel stop button Boolean control to terminate the loop at the request of the user rather than using this function.