LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Pause/continue a loop in Labview

I think I got it now. 

0 Kudos
Message 21 of 33
(1,887 Views)

Sorry, but I do not have energy to debug this block diagram "monster". What kind of monitor you have, 100 inches? All I can suggest is to take some tutorials, so you will learn how to design a proper state machine. Going through the Core 1 self-paced online learning videos could help a lot. In this VI I see Case structures inside the Event structure. Have a look at some single-loop state machines: the states are the cases of a Case structure inside the While loop, and the Event structure is inside one of the case of the Case structure. Your VI is somehow turned "inside-out", I guess you have some dead-lock with the Event...

 

Another option would be to use a Producer-consumer with a Queued state machine, very nice to handle it and use it. Of course, you should go through the online learning tutorials first, you will see this time investment will be very valuable...

0 Kudos
Message 22 of 33
(1,881 Views)

The thing is all that I added to timeout event case was working before... when I added that big thing to the timeoutcase it stopped working! but the two things.. the run pause stop buttons and the big part were working before.. the thing is when I put them together. I don't know why it is not working.

0 Kudos
Message 23 of 33
(1,878 Views)

I can't debug that either.  But I can point out a few problems.

 

1.  You have event structures inside of event structures.  Never a good idea and a sign of a poor architecture.

2.  You have event cases set to lock front panel until event completes.  Why is that a bad idea?  This in conjection with #1 means you could trigger an event which locks the front panel, but you don't have the event structures in the path of execution for them to be able to handle the events.  You'll lock up your front panel completely with no way of getting out unless you abort your VI.  And this is very likely to happen unless your user happens to be very careful in interacting with the front panel in just the right way to prevent this from happening.

3.  You have while loops inside event structures.  This goes along with #1 and #2 above.  You can get your code executing in a long running while loop and perhaps no way to exit it because your user has triggered other events that lock up the front panel.

 

Read Caveats and Recommendations when Using Events in LabVIEW - LabVIEW 2015 Help.

 

What do pause and run mean?  Pause and run your VI?  Or pause and run your motor?  Your pause event sets the timeout value to 10 which would allow the timeout case to execute which seems to be where all of your motor execution is.  Your run event sets the timeout value to -1 which means the timeout case will not execute, and the motor execution won't happen.  That seems backwards.

 

But you need to rethink your entire architecture.  It should probably be some form of a state machine.

0 Kudos
Message 24 of 33
(1,875 Views)

The problem is that you try to use things like Event structure without proper understanding how they work. Just put this project aside for a week, and learn LabVIEW. You should not start LabVIEW learning with Events, this comes after the basics. First you need clear understanding of functions and data flow. You could take that core 1 training in 3-4 days...I think end of core 1 or beginning of core 2 explains Events...

0 Kudos
Message 25 of 33
(1,869 Views)

Hey guys,

 

I've tried this different method to pause a while loop, but something strange is happening. My Pausar button (pause button), never becomes true (even if I activate it) and my increment counting is not showing any changes. Can someone tells me what is wrong with my VI? My problem is only with the pause button and the increment indicator. The rest of the code was working perfectly before.

0 Kudos
Message 26 of 33
(1,827 Views)

Hello guys. I am trying to pause a while loop. I've done it following an example that I saw on labview. My while loop was working properly and then I added a case with a pause button (pausar) connected to it and my Vi also have a double increment. The double increment is not working. It is stopped at value 1. And my pause button (pausar) is never True even when I press it.

 

Can anyone tell me what is wrong with my VI?

0 Kudos
Message 27 of 33
(1,852 Views)

There are a lot of routines "missing", and the code is both HUGE (i.e. it way more than fills a single Laptop screen) and the comments (and function names) are in a language I don't speak fluently.

 

That being said, the main element that is missing in my understanding is how Time should be handled in this routine.  When the code is not being paused, does it "do something" at regular clock intervals (say, every 10 milliseconds)?  If so, an easy way to implement a Pause is something like this:

Simple Pause.png

Bob Schor

0 Kudos
Message 28 of 33
(1,842 Views)

Hey bob, don't worry about the parts that are missing. I just want to know why my button pausar is never true! I could do what you suggested but it would not work either because my button never goes to TRUE even if I press it so it would not pause.

0 Kudos
Message 29 of 33
(1,822 Views)

Why would you create a new thread when you are already being helped in this thread?  (I merged the two so that everyon has the benefit of seeing the history of your VI.)

 

First.  Your counter will not advance.  (you say it is stopped at 1, but I don't see how it gets past zero.)  You have an increment value on that wire, but nothing wired to the output.  Your shift register starts at zero, and stays at zero because you just wired through and ignored your increment function.

 

Second, you still have serious flaws in your architecture because you have the Move button event structure, and it set to lock the front panel until the event completes. You can lock up your code cold if you hit the wrong buttons at the wrong time.

1.  Hit the Pause button.  Your while loop starts spinning, waiting for the Pause button to go false.

2.  Hit the Move button.  Then your event structure will execute and the code after that will complete.  But the while loop will not iterate again because your Pause loop hasn't finished.

3.  Hit the Move button again. Now your event structure queues up the event, locks the front panel, but it can't execute because the while loop hasn't gotten back around to it yet.

4.  You hit the Pause button which would allow the Pause loop to finish, which would allow the outer while loop to finish and come back around again.  EXCEPT THE FRONT PANEL IS LOCKED.  You can't hit the pause button to make it false!

 

Please take those tutorials and use highlight execution to understand how your code functions.

0 Kudos
Message 30 of 33
(1,793 Views)