05-31-2011 05:45 AM
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!
Solved! Go to Solution.
05-31-2011 06:10 AM
How many ms do you wait? You should not use more than 200ms or else the user will feel that the program is hanging.
05-31-2011 06:17 AM - edited 05-31-2011 06:22 AM
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.
Regards,
Nitzz
(Give Kudos to good Answers, Mark as a solution if your problem is Solved)
05-31-2011 06:21 AM
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.
05-31-2011 06:25 AM
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)
05-31-2011 06:41 AM - edited 05-31-2011 06:42 AM
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.
05-31-2011 06:58 AM
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!
05-31-2011 07:23 AM
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.
05-31-2011 07:56 AM
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 done
05-31-2011 07:57 AM
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.