LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems pausing or stopping a sequence

I'm having an issue getting a sequence to pause or stop on command. The key is that the response to either pause or stop button be immediate and that I output a false logic to the valves shown in the attached VI. I've tried all sorts of case structures and sequences to no avail and was hoping someone on here with more skill and intelligence could at least point me in the right direction.
Thanks in advance for the help.
0 Kudos
Message 1 of 8
(3,557 Views)
First of all, you should use an event structure to capture the run event.  Then use a case structure for pausing.  When true, do nothing in a loop until the pause is false or stop is true.  When pause is false, run your code.  Here is a partial solution written in LV 7.1.1.  You should be able to add your additional code.  The flat sequence structure was unnecessary.
- tbob

Inventor of the WORM Global
Message 2 of 8
(3,555 Views)
Thanks for the help, but I'm running on lowly 7.0. I think I get what you're saying, but could I trouble you to post an image or 7.0 code?
Thanks again.

Message Edited by JohnnyF on 02-20-2007 08:27 PM

0 Kudos
Message 3 of 8
(3,550 Views)
Okay, I was able to download that VI on another computer with a demo version of LabbView. Unfortunately, it didn't quite do what I needed in that ti didn't stop or pause immediately while writing a valve to the solenoids I am trying to control. I'm attaching a new version of what I'm trying to do. It works except that it will not automatically restart after pausing-I need it to either go back to the main cycles or go to the jump cycles based on the number of cycles (granted, my counters are messed up at the moment). If anyone can shed some light on a better way to do things or knock some sense into me, I'd be much obliged.
Thanks in advance for the help.
0 Kudos
Message 4 of 8
(3,514 Views)
I agree with tbob. An event structure can help you manage the button presses. Put in some additional cases in the state machine. One would be an Idle state. Pressing the pause button takes you to this state. If the waits are handled in a Wait state, it can be implemented in such a way that Pause or Stop occurs immediately rather than after the wait. As the state machine grows in complexity you may find that using a typedef enum as the state selector will offer some advantages over the simple numerics. One big advantage is the self documentation. The enum strings appear in the selection box at the top of the case structure providing self documentation of the states.

Pressing Stop or Pause does the same thing in all cases except the Stop case. I have not sorted out all your logic to see why it does not resume. I usually have a Resume button and a state which restores everything which was suspended during Pause.

I think the nested loops are probably not necessary and the local variables can certainly be eliminated.

Lynn
Message 5 of 8
(3,497 Views)
Lynn,
Thank you for taking the time to look at my disaster of a program. I now actually have something that is 100% functional, though I am less than pleased with the level of complexity and haven't been able to eliminate the locals. I understood some of what you suggested regarding the event structure, but I'm a bit of a hack at this and not sure how I would work with the wait and pause functions as you mentioned.
I'll post the updated version of what I have, though the logic is not any more clear. Basically, what needs to happen is that it needs to execute the main cycles for x cycles and then go to the jump cycles for y cycles and back to main. The key thing is being able to pause or stop immediately while closing the valves. If you have the time and inclination to point me towards the proper way of implementing the event structure, I'd greatly appreciate it. As I said, it currently works, but I'm certain it is inefficient and unnecessarily complex.
Thanks again for the help.
0 Kudos
Message 6 of 8
(3,492 Views)
Try rewriting your code using the event structure as shown in my example.  Sorry, right now I am swamped with work and don't have the time to write another example.  How are you closing your valves?  Are you using the DAQ write functions to do so?  Once the DAQ function starts its execution, and your press the pause or stop while it is executing, your vi will not stop or pause until the DAQ function is finished its execution.  To change this, you would have to rewrite the DAQ function or create your own.  This is pretty advanced stuff.  Look for another way to do this.  You would have to pass a reference to the stop and pause buttons to the function that closes the valves, and inside that code, you would have to periodically check the value of the referenced buttons to stop the action.  Sorry i don't have time to continue right now.
- tbob

Inventor of the WORM Global
Message 7 of 8
(3,479 Views)
No worries, thanks for all the help. I am using the DAQ write to close the valves on pause or stop so that seems to be part of my problem.
I'm working on getting it all back into the event structure to work with what you and johnisold have suggested.

Message Edited by JohnnyF on 02-22-2007 10:47 AM

0 Kudos
Message 8 of 8
(3,471 Views)