LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to stop a while loop with long delay

Hi everyone,

 

I am building a simple program for turning on and off a single Bit.  The task is to turn ON the Bit for a period length T1, and OFF the Bit for a period length T2. T1 is normally different from T2, and can be controlled  by users

 

Since T1 and T2 can be variable, they sometimes can be very long.

 

If I use a Wait function inside a While loop, it needs long delay to be able to Stop the Main program.

 
The same situation happens when I use Timed loop.

 

Can anyone suggest me how to do this task?

 

Thanks a lot. 

Message Edited by tatuan on 04-12-2010 12:56 AM
0 Kudos
Message 1 of 6
(4,193 Views)

It's a well known problem that long delays causes sluggish response.

One easy solution is to split the delays into smaller parts, e.g. X*100ms + rest. Then either check time elapsed each loop, or calculate/make a "wait time array" and feed the wait loop.

The array is easily done through a Quotient/Remainder calculation with 100(ms) as divider -> Initialize array with 100 ms * Quotient -> Build array with Remainder.

 

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 6
(4,177 Views)
I like using the Elapsed Time Express VI for this.  I used the OpenG Boolean Trigger VI to detect the transition between T1 and T2.

Example_VI.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 3 of 6
(4,122 Views)
I would not put a wait step. I would keep up witht he time as we go in this situation. See the example below.
Tim
GHSP
0 Kudos
Message 4 of 6
(4,119 Views)

Here's another possibility using OpenG Wait ms:

 

Example_VI_BD.png

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 5 of 6
(4,094 Views)
0 Kudos
Message 6 of 6
(4,041 Views)