LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Pause button

Solved!
Go to solution

Probably my question is really stupid, but I tried to solve it in different ways with no success....

 

In the attachment you can see the piece of my program with the problem (I can show more, if necessary).

I want to be able to pause the acquisition of measurements concerning what is inside of the For Loop from frame number 2. The semaphore is working fine, I can pause and continue the measurements as I wanted.

 

But in the third frame I would like to ask the user to enter new data and the frame would restart, doing the same acquisition, but now with a different voltage.

 

My problem is that after passing for the first time in frame number 2 the program stops working and do not go to the frame number 3. I know that the problem is with the "Event Structure" to able/disable the semaphore....

 

But I have no idea on how to solve this...

 

I don't want the program to stop in this loop, actually there are other steps after this acquisition.

 

Can, please, someone help me? 

0 Kudos
Message 1 of 10
(4,361 Views)

Well,

 

looking into your code... it's quite a mess. The code doesn't reflect anything what you like to do. It lacks of a proper architecture.

 

So please step back a little and re-think: "What do i want to achive with the code? How would this look like if i should create a dataflow-diagram out of my approach?"

From your description, i would think that a standard statemachine will serve quite well for you, so you easily can remove all the disturbing sequence structures as well as variables.

 

Correcting your code is nothing i want to do since you would stumble from one issue to the next......

 

hope this helps,

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 10
(4,337 Views)

Hello,

 

Yes, my code is a mess. But I have no time to solve this now. 

Another person was working with this and now I need to fix a lot of things in less than one week, so my supervisor can use this program. The day of measurement is booked for more than two months and using a state machine now will take a lot of time.

 

So, if is possible, I would like to solve the semaphore problem now, to have a functional program (everythings is working well, instead of this semaphore) and later I'll, for sure, take care of the code. 

 

thanks

0 Kudos
Message 3 of 10
(4,331 Views)

Well, well,

 

ok, i try to give you some hints on what you ARE doing.

In the For-Loop, you acquire the semaphore and release it right afterwords. This is not synchronized with any other content of this loop. So if you acquire the semaphore in the while-loop, the content of the for-loop will be executed one additional time until the "acquire semaphore" blocks the further execution of the for-loop.

The for-loop can continue to execute if you release the semaphore in the while-loop then.

 

So in fact you never leave the for-loop while pausing. So you never get to frame 3 of your stacked sequence structure. So the user will never be prompted for a new parameter.

 

In order to solve this, you HAVE to rework the architecture because the current state of the code does not give you any possibility to solve your issue!

You have to get away from the stacked sequence because it does not provide the functionality you have to use here.

 

hope this helps,

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 10
(4,325 Views)

The first time you press pause, the event loop stops and no further events are handled. This means that the event no longer works when you try to unpause and the semaphore can never be released ever again. You need to keep the event loop running until the FOR loop is finished.

 

Your approach is overly complicated. You could use a wait loop inside the FOR loop, for example.

Message 5 of 10
(4,318 Views)

Actually the pause is working... I could pause-continue several times and the filed saved contained the right data...

 

What I don't understand is why it doesn't go to the next frame.... 

 

I'm trying to work with this code because I have no time to build a new one. But for sure this needs to be better structure and it will be in the future.

 

thanks

 

0 Kudos
Message 6 of 10
(4,315 Views)

Altenbach

 

When you say to use a while loop inside the for loop you mean to remove the event structure? 

 

 

0 Kudos
Message 7 of 10
(4,313 Views)

altenbach wrote:

The first time you press pause, the event loop stops and no further events are handled. [..]


Good point, Altenbach, overlooked that one....

Nevertheless, i understand it that pressing the pause button to unpause the measurement, it should first give the user the possibility to change parameters. And that will definetly not occur in the current state of the programm...

 

Norbert 

 

[EDIT]: Ah, and never ever use the STOP-function in VIs. To quote Darren: "Stopping a VI using the Abort Button is like stopping your car with a tree. It works, but it may have consequences...." (STOP-function is like pressing Abort) 

Message Edited by Norbert B on 10-08-2008 03:51 AM
Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 8 of 10
(4,302 Views)
Solution
Accepted by radiofysik

By now my problem is solved.

 

Pause-continue working and frame sequence being obeyed.

 

Thanks for inputs.

 

 

0 Kudos
Message 9 of 10
(4,294 Views)

Beware,

 

while pausing, you are creating 100% CPU load. Insert a timing in your pause-loop!

 

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 10 of 10
(4,272 Views)