LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing measurement file in While loop, multiple-second "sleep"

Solved!
Go to solution

Hi,

 

I'm doing app in LabView 2011 (v11).

Its reading from FP-RTD-122, attached to FP-1001 via RS485.

Attached app does job quite well, but (Never good enough for me... :-)) when delay between logging is long

(i dont want to log every 100ms, rather every 30 minutes (1800 seconds, 1800000ms) - and it could also get resource-abusing to use COM each 100ms),

app doesn't do multitasking, and waits for sleep to finish, so it could listen to actions again.

 

For example,

i have 30s "sleep", and after 5 seconds i interrupt app (i stop while loop with button), but i need to wait the rest 25 seconds.

How would I make this app multitasking ("multithreaded"), so i would have GUI thread (graphical interface) in frontground, and logging in background,

and even if it started new sleep cycle, i would be able to stop it without waiting?

I attach .vi.

 

Thanks for further support.

 

(PS: strictly windows application, includes creation of folder C:\LOG and usage of Notepad.exe. I appologise if i forgot to translate anything.)

0 Kudos
Message 1 of 5
(2,430 Views)

DON'T UPLOAD A VI THAT IS SET TO RUN WHEN OPENED!

 

You should look at using the Elapsed Time express VI.  When the alotted time as elapsed, it will output a true and you can use that to drive a case structure such as logging to a file.  When the time has not elapsed, it outputs a false.  Don't log to to a file, just do the other stuff you need to do inside the loop.

0 Kudos
Message 2 of 5
(2,428 Views)

I knew i've forgotten something. humm..

 

so, i think i don't really understand time lapsed thingy... At least it doesn't work as i've wanted... 

Labview1.JPG

0 Kudos
Message 3 of 5
(2,411 Views)
Solution
Accepted by topic author wattss

One while loop, not two.  You are trapping yourelf into the inner while loop until the time has elapsed.  Use the output of the time elapsed to trigger a case structure.  Do the stuff you want to do periodically in the true case of the case structure.

 

Wire your time to wait into the Time Target, not the Set start time.

0 Kudos
Message 4 of 5
(2,407 Views)

Enlightened! This seems to work! 🙂Labview2.JPG

0 Kudos
Message 5 of 5
(2,405 Views)