There are two ways to stop a LabVIEW vi. A clean one and a dirty one.
The dirty wayIn a parallel loop the vi can open a reference to itself and use the abort vi method (see attachment). This will abort the vi just like clicking on the abort button.
There are some drawbacks for using this method:
- As the motion board is working independently from the LabVIEW vi ongoing moves won't be stopped when the vi is aborted. If you want to stop an ongoing move you would have to make sure that another vi that is started dynamically calls stop motion after every other vi is stopped or aborted.
- When the abort method is called at a time when LV calls a hardware driver there is a chance that the complete application hangs.
The clean wayThis involves some more programming but it's definitely the recommended way. There is also not only one way to do that. The general idea is to provide in every loop in every subvi a way to leave it when a global stop command occurrs. You also need to make sure that everything is stopped correctly before the application is stopped. Please have a look at the example in my next reply. It works with a global variable but you also could work with control references, notifications, occurrences and so on.
It might look like that the clean way is a bit annoying but in fact there is no good alternative and please note that this issue is immanent in every programming language. The code Motion Assistant generates is just a prototype that you need to adjust for your specific requirements.
Jochen