LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While loop, wait function and stop button!

Solved!
Go to solution

Hi,

 

I have a while-loop and a stop-button. Inside my While-loop I have a "Wait (x ms)" function. If I press the stop button, it won't stop the program immediately , it waits x ms and then stops the program. How do I get rid of this?

 

Thanks in advance for the help!

Message 1 of 24
(11,253 Views)

How many ms do you wait? You should not use more than 200ms or else the user will feel that the program is hanging.

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
Message 2 of 24
(11,244 Views)

Hi,

 

If you just want to wait for some seconds for performing a task you can just use an event structure as explained in the attached VI.

 

Waitseconds Event Structure.PNG

 


Regards,


Nitzz

(Give Kudos to good Answers, Mark as a solution if your problem is Solved:smileywink:

 

Message 3 of 24
(11,239 Views)

Thanks for the reply!

Well I wait a bit longer , 30 min ! :">  I control a Power Supply, and I need to change the voltage every 30 min. Do you have any other suggestion instead of using a wait ? I don't want to make the program more complicated than it needs to be.

Message 4 of 24
(11,237 Views)

Hi,

 

You make take a look at the attached vi in the previous post. It is not using any wait function. It uses an Event Structure Timeout for controlling the time. 

 

Regards,

Nitzz

(Give Kudos to good Answers, Mark as a solution if your problem is Solved:smileywink:

Message 5 of 24
(11,230 Views)

If you are going do something every 30 minutes, I would have used the time stamp function "Get Date/Time". I would have taken a timestamp when the program starts. Then I would have checked if the timestamp had gone above itself+1800 seconds, and then used that timestamp further. That's just an example. There are many ways to rome.

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
Message 6 of 24
(11,221 Views)

Thank you both Nitzz and Even! I'll try your solutions and return, so until then I'm not gonna mark this thread as solved ! Hope that's ok!

Message 7 of 24
(11,216 Views)

Ok, I tried but I can not figuered it out... So I attach my very "basic" block diagram here, maybe you can explain more for me.

 

my_prog.JPG

 

Message 8 of 24
(11,210 Views)

You are thinking the right way, since this is one way to do it. But it will make the program stalling and the user will not know in what state the program is. You could instead just check the computer time and then change the voltage. Meanwhile the program can output for example a progressbar to the user, what the current time is and how long it is to a new voltage will be aplied. And it will give the user the opertunity to abort the program easily. Instead of killing the process in windows. I will create a small program for you to illustrate this. Lets do something easy.. Say make a LED blink every minute and give the user some indications on what's going on. I'll post it as soon as it's doneSmiley Happy

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
Message 9 of 24
(11,192 Views)

It was suggested that you don't use the Wait (ms) function.  This snippet will run for 30 minutes or until the Stop button is pressed,  You can use this method for your timing, and make a State Machine that will handle your voltage changes.

 

timing.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 10 of 24
(11,190 Views)