xShadowDanx Posted April 28, 2009 Report Share Posted April 28, 2009 Im doing this Temperature Graph using a For Loop.. It works.. The graph shows the wave signal accordingly however when i press the Stop Button on the user interface(the control).. it refuses to stop immediatly, instead, it stop after a few seconds which i think after 1 cycle. So it there a way that i can add on the block diagram to make it stop immediatly? I would gladly appreciate if someone can help me out with this. - I cant upload the .Vi since there is a technical problem on my upload. Quote Link to comment
Antoine Chalons Posted April 28, 2009 Report Share Posted April 28, 2009 Hi xShadowDanx, I think you're right, your while loop is doing an extra cycle. When a while loop executes, the first thing LabVIEW does is check the stop condition (if it can) and then executes the rest of the code inside the loop. So if you cycle has already started when you clic the stop button, it is normal that it will run one more time ; you can avoid that behaviour by forcing LabVIEW to read the stop button AFTER the rest of the code inside the loop has been executed. The 2 loops below demonstrate this. I guess your VI is like the top loop and if modify it to look like the bottom loop you'll have what you want. Hope this helps Quote Link to comment
xShadowDanx Posted April 28, 2009 Author Report Share Posted April 28, 2009 Oh.. thanks a lot. I'll modified it now.. hopefully it works. =D Quote Link to comment
PA-Paul Posted April 28, 2009 Report Share Posted April 28, 2009 Not sure I entirely agree with Antoine's solution... Although I can see where he's coming from... However, another reason that there's a delay, is that you can't interrupt the "wait ms" VI. Pressing the stop control simply instructs labview to stop the loop at the end of the current iteration. So when you press it, it still has to do the waiting for the current iteration to finish. So, basically, there will pretty much always be some delay between pressing the stop button and the code actually stopping - its just more noticable in code where you have a time delay within the while loop. Attached is one way you can have code, i.e. your temperature acquisition, occuring at set rate within a loop which runs quicker - allowing you to stop the loop "instantly" whilst still having a slow sampling rate. I seem to remember seeing somewhere that you're using 7.1, I can;t save back that far, the code posted is in 8.6.1, but you can see the block diagram in the attached screen grab: Download File:post-14639-1240840128.vi Hope that helps... Paul Quote Link to comment
Jason H Posted April 28, 2009 Report Share Posted April 28, 2009 Another solution would be to use a separate loop for the GUI. Quote Link to comment
xShadowDanx Posted April 29, 2009 Author Report Share Posted April 29, 2009 Yep.. i tried Charlon's method and theres still a bit delay b4 it stop. I don't know which area I should change but now im trying the other solutions. Thanks guys, really appreciated the replies. Quote Link to comment
Antoine Chalons Posted April 29, 2009 Report Share Posted April 29, 2009 QUOTE (xShadowDanx @ Apr 28 2009, 08:35 AM) Yep.. i tried Charlon's method and theres still a bit delay b4 it stop. I don't know which area I should change but now im trying the other solutions. Thanks guys, really appreciated the replies. Paul explained why with the solution I proposed there would still be a little delay, this is just the time you code -inside the loop- takes to execute. Can you post your code, or at least a screenshot of it so that we can provide more appropriate advice ? Quote Link to comment
xShadowDanx Posted April 29, 2009 Author Report Share Posted April 29, 2009 QUOTE (Ic3Knight @ Apr 27 2009, 09:49 PM) Not sure I entirely agree with Antoine's solution... Although I can see where he's coming from...However, another reason that there's a delay, is that you can't interrupt the "wait ms" VI. Pressing the stop control simply instructs labview to stop the loop at the end of the current iteration. So when you press it, it still has to do the waiting for the current iteration to finish. So, basically, there will pretty much always be some delay between pressing the stop button and the code actually stopping - its just more noticable in code where you have a time delay within the while loop. Attached is one way you can have code, i.e. your temperature acquisition, occuring at set rate within a loop which runs quicker - allowing you to stop the loop "instantly" whilst still having a slow sampling rate. I seem to remember seeing somewhere that you're using 7.1, I can;t save back that far, the code posted is in 8.6.1, but you can see the block diagram in the attached screen grab: Download File:post-14639-1240840128.vi Hope that helps... Paul i got try your method but i just want to ask, wat is the interval for? Is it for the whole while loop or for my temperature acquisition plus when i put in my temperature acquisition inside the case structure its in stacked squence with for loop, but when i run it, it can stop but the graph show no data in it. so what wrong? QUOTE (Antoine Châlons @ Apr 28 2009, 02:49 PM) Paul explained why with the solution I proposed there would still be a little delay, this is just the time you code -inside the loop- takes to execute. Can you post your code, or at least a screenshot of it so that we can provide more appropriate advice ? http://lavag.org/old_files/monthly_04_2009/post-15220-1240903582.jpg' target="_blank"> here the code i am currently doing..it run perfectly but when press stop it will run for a period of time then it stop. i was wondering if don't use for loop can use other method. Quote Link to comment
PA-Paul Posted April 29, 2009 Report Share Posted April 29, 2009 Ok, So my method will work if you only want a single loop application, but Jasonh's solution may be better in some regards - although actually, his code would also have the delay because the bottom loop still has to wait for the ms timer to finish. Anyway - the interval in the approach I posted is the interval at which the temperature is sampled (assuming your temperature sampling is in the "true" case of the case structure). The way I've set it up, don't use a precision higher than 1 decimal place in the interval value as then it won't work properly, if possible I'd stick to using integer values of interval (its a double to avoid coercion dots in the code). If it takes your code any length of time to acquire the temperature, then there will always be a delay (even in my example) between pressing stop and the program actually stopping. I can't say why your code doesn't work when placed into mine, as I can only see a small portion of your code in the screen shot. If you need more help, best thing to do would be post the actual code if you can. Cheers Quote Link to comment
candidus Posted April 29, 2009 Report Share Posted April 29, 2009 Hi, I stumbled upon the same problem some years ago and solved it using an Occurrence: This way you can run many parallel loops with diffent timings and they all stop at the same time. Quote Link to comment
LAVA 1.0 Content Posted April 29, 2009 Report Share Posted April 29, 2009 QUOTE (candidus @ Apr 28 2009, 12:59 PM) Hi,I stumbled upon the same problem some years ago and solved it using an Occurrence: OpenG has a generic solution based on ocurrences as well: Wait (ms) is the name of the code, here is the underlying snippet: Ton Quote Link to comment
candidus Posted April 29, 2009 Report Share Posted April 29, 2009 QUOTE (Ton @ Apr 28 2009, 01:46 PM) OpenG has a generic solution based on ocurrences as well: is the name of the code, here is the underlying snippet: Ton Thank you very much! There are treasures buried in OpenG but only a few people know about them :thumbup: Quote Link to comment
Antoine Chalons Posted April 29, 2009 Report Share Posted April 29, 2009 QUOTE (candidus @ Apr 28 2009, 03:30 PM) Thank you very much!There are treasures buried in OpenG but only a few people know about them :thumbup: you might want to take a look at the http://thinkinging.com/category/openg/i-couldnt-live-without/' rel='nofollow' target="_blank">"I couldn't live without" series by Jim Kring Quote Link to comment
candidus Posted April 29, 2009 Report Share Posted April 29, 2009 QUOTE (Antoine Châlons @ Apr 28 2009, 03:46 PM) you might want to take a look at the http://thinkinging.com/category/openg/i-couldnt-live-without/' rel='nofollow' target="_blank">"I couldn't live without" series by Jim Kring Very useful link. :thumbup: Thank you! Quote Link to comment
xShadowDanx Posted April 30, 2009 Author Report Share Posted April 30, 2009 Aight, this is the whole code. Its big so i upload it to another sharing file site. http://ifile.it/54kxwp2 Quote Link to comment
LAVA 1.0 Content Posted April 30, 2009 Report Share Posted April 30, 2009 QUOTE (xShadowDanx @ Apr 29 2009, 03:11 AM) Aight, this is the whole code. Its big so i upload it to another sharing file site.http://ifile.it/54kxwp2 Somehow I couldn't download the file, could you upload it to LAVA directly? Ton Quote Link to comment
xShadowDanx Posted April 30, 2009 Author Report Share Posted April 30, 2009 Sorry but i cant directly upload it here. Its together with other filess so i need to compile it and upload but... Lava just wont let me do so. Aight, i've uploaded the files on other file sharing site.. the download link below works. http://www.keepandshare.com/doc/view.php?id=1171468&da=y Quote Link to comment
candidus Posted April 30, 2009 Report Share Posted April 30, 2009 Here is my example using an occurrence as mentioned above: Download File:post-15449-1240991516.vi Quote Link to comment
PJM_labview Posted April 30, 2009 Report Share Posted April 30, 2009 Here is the file xShadowDanx was trying to post. Note: I did not open it up. Download File:post-121-1241023757.zip PJM Quote Link to comment
xShadowDanx Posted May 1, 2009 Author Report Share Posted May 1, 2009 ah thanks a lot for the upload Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.