LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FORCE STOP WHILE LOOP WITH TIME DELAY

Solved!
Go to solution

Hi Guys,

 I'm doing a project that will datalog the voltage reading from Arduino A0 pin. The arduino will read the voltage reading every "N" times (depends on time delay) and save the overall reading into excel. The problem is, I can't stop the VI anytime I want.

seems like it will wait first before the delay is finished. see the attached picture

 

0 Kudos
Message 1 of 13
(5,920 Views)

Put the time delay in the false case of an case structure. Wire the stop button to the terminal of the case structure. I have build an example

0 Kudos
Message 2 of 13
(5,911 Views)

Hi Gert-Jan,

 

you still can't stop your loop when the delay function is called!

 

@dragon:

Better try something like this:

check.png

(ElapsedTime is set to auto-reset.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 13
(5,888 Views)

 

So to abort the delay you can abort the SubVI.

 

Abort VI.png

 

Message 4 of 13
(5,879 Views)

Hi Gert-Jan,

 

usually you don't want to abort a VI somewhen in the middle of doing something important…

(What does Wiebe say about your recommendations? :D)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 13
(5,871 Views)

@GJMABerends wrote:

 

So to abort the delay you can abort the SubVI.


 

I think it is best practise to use the abort VI function only if you have absolutely no ther option.

ʍolɟɐʇɐp ʞuıɥʇ
0 Kudos
Message 6 of 13
(5,868 Views)

Hey GerdW

 

Probably he doesn't agree. I agree these suggestion that I made were not great. I should pause and look at the problem more carefully before I suggest a solution. I assumed that the question was about stopping a Time Delay without thinking about the actual question.

 

The first solution has indeed the issue that it doesn't stop an already started time delay. The second solution stops the time delay but forces the application off while not closing references properly. 

0 Kudos
Message 7 of 13
(5,855 Views)

@GerdW wrote:

Hi Gert-Jan,

 

usually you don't want to abort a VI somewhen in the middle of doing something important…

(What does Wiebe say about your recommendations? :D)


Well, "Abort" is about the only way to stop a time delay. So I think it should be the accepted answer!

 

Let's stay on topic for once! How to avoid having to stop the time delay is another (the correct) question.

 

 

 

0 Kudos
Message 8 of 13
(5,843 Views)

Place the code in an event structure in the timeout case (timeout = rate), then you can have a Stop Value change event that'll stop at any time.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 13
(5,822 Views)

I think it's suppose to run on Arduino (not sure), so no event structures.

0 Kudos
Message 10 of 13
(5,815 Views)