Jump to content

I Got A Question . . .


Recommended Posts

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.

Link to comment

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.

post-7452-1240819236.png?width=400

Hope this helps

Link to comment

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:

post-14639-1240840137.png?width=400

Download File:post-14639-1240840128.vi

Hope that helps...

Paul

Link to comment

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 ?

Link to comment

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:

post-14639-1240840137.png?width=400

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)

http://lavag.org/old_files/monthly_04_2009/post-15220-1240903582.jpg' target="_blank">post-15220-1240903582.jpg?width=400

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.

Link to comment

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

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.