LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the best way to execute code at a specific time?

You are subtracting the Timestamps to get the difference of time, that may be even in milliseconds, right... ?!

 

IMO, it wont consume more process power because you are not spinning the loop infinitely; you already have a Wait statement to tell the loop when to time out regularly. Smiley Happy

 

Even when you use Event Structure - ES, you can go down upto only milliseconds level of timeout, not microseconds. Smiley Wink  So, it should not make much difference, afaik...

- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 11 of 17
(990 Views)

You are right, but I meant something different:

I have several subvis to be performed at specific time points. The timing is not critical (+/- 20ms is ok), so I use a while loop and a stacked sequence to check if the time of each subvi has come. I run this while loop every 20ms (50 times a second).

 

If I needed the timing much more accurate (+/-1 ms) than I have to run the whileloop every ms, which is 1000 times per second.

I could imagine that this need a lot of cpu time. Do you understand what I mean?  

Greetings Johannes
Using LabVIEW 7.1 and 2009 recently
0 Kudos
Message 12 of 17
(988 Views)

Yes, I understood you very much already. Smiley Happy  Thats is why I told you can go down upto ms level, indirectly meaning down upto 1ms. Smiley Wink

 

Try this... A simple while loop with a Wait function of 0.6ms will consume only 0% of your CPU even in a single core PC. But, if you go down to 0.5ms, it ll immediately shoot upto 100% CPU consumption. Smiley Surprised  So, for a dual core or quad core, it ll be 50% or 25% respectively.

 

At a while loop spinning rate of 1ms timeout, the CPU consumption depends on the processes we do, like huge array manipulation, continuous file writing or continuous graph update on the FP which will require a total redraw (this can be reduced by deferring the FP updates till the finish) everytime its data gets changed.

- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 13 of 17
(986 Views)

parthabe wrote:

 

 

Try this... A simple while loop with a Wait function of 0.6ms will consume only 0% of your CPU even in a single core PC. But, if you go down to 0.5ms, it ll immediately shoot upto 100% CPU consumption. Smiley Surprised  So, for a dual core or quad core, it ll be 50% or 25% respectively.

 


Because Wait Function required INTEGER input, isn't? 😉

 

Andrey.

0 Kudos
Message 14 of 17
(979 Views)

johanneshoer wrote:

 

I see a problem. The timer value will wrap from (2^32)-1 to 0, so there might be a problem during comparison.

Even though it is very seldom, I can not accept that.

 

 


Not "very seldom" but exactly after 49,7 Days.

 

Unfortunately not all software engineers like you can catch such issue immediately:

 

Computer Hangs After 49.7 Days

 

Microsoft server crash nearly causes 800-plane pile-up

 

 

 Andrey.

0 Kudos
Message 15 of 17
(975 Views)

Andrey Dmitriev wrote:

 

Because Wait Function required INTEGER input, isn't? 😉


But still 0.6 is not INTEGER (I think it gets rounded off to the nearest, which is 1), right... ?! Smiley Wink

 

And 0.5 gets rounded off to 0. Smiley Happy

- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 16 of 17
(971 Views)

parthabe wrote:

 

But still 0.6 is not INTEGER (I think it gets rounded off to the nearest, which is 1), right... ?! Smiley Wink

 

And 0.5 gets rounded off to 0. Smiley Happy


Exactly!

0 Kudos
Message 17 of 17
(961 Views)