LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW wait function in a while loop delay time not accurate

Solved!
Go to solution

Need Your Help,Thanks!
I put a wait(ms) function in a while loop, and the value is set to 10 ms. I put tick counts(ms) before and after the wait function to calculate the delay time.
I found that sometimes the delay time is larger than 10 ms, sometimes can be about 150 ms. how could that be possible!
The snapshot of the VI is attached, thanks!.

0 Kudos
Message 1 of 12
(4,391 Views)

1. Nothing was attached.

2. Timing on Windows is horribly inaccurate.  You should expect some jitter in the tens of ms.  Extra 140ms sounds a bit much.  Need to see what all is happening in your loop in order to help any more.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 12
(4,386 Views)

@ritayuan wrote:

The snapshot of the VI is attached, thanks!.


Not sure what you mean by "snapshot" -- we need something that we can actually run, like a VI or a VI Snippet.  Please do not waste our time by posting an un-executable image of your code.

 

Bob Schor

0 Kudos
Message 3 of 12
(4,381 Views)

Sorry, I forget. TestLoopTime.vi is Attached and also the screenshot of a test.

0 Kudos
Message 4 of 12
(4,333 Views)

I don't know why the .bmp file can not be attached. So no screenshot.

0 Kudos
Message 5 of 12
(4,332 Views)

Sorry, I am new here. Thank you for your replay, attached is my test vi.

0 Kudos
Message 6 of 12
(4,322 Views)

Hi ritayuan,

 

your test VI runs on my laptop for a minute without showing anything else then zero in the delaytime indicator…

Edit: after running for some minutes now I get values of 12 and 15 - but that's ok for a non-deterministic Windows system…

 

- You cannot attach BMP files to this forum because of their (usual big) filesize! Use PNG or JPG instead! (And please convert those files correctly - renaming a file is completely different to converting an image!)

- Please don't delete labels from controls or indicators. You may hide the label in the frontpanel, but never in the block diagram! (I'm talking about your stop button.)

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 12
(4,307 Views)

Thanks for your advice! Attached is one screenshot of my test with the delay time of 183 ms. I am thinking if that is related to the windows system. When the windows system is busy or in other situations, all the processes are blocked?? For example, when my monitor awake from OFF state, there sometimes will have a delay time larger than 100 ms.

0 Kudos
Message 8 of 12
(4,302 Views)
Solution
Accepted by topic author ritayuan

Hi ritayuan,

 

I am thinking if that is related to the windows system.

Yes, Windows is a non-deterministic (aka "Realtime") operating system.

 

When the windows system is busy or in other situations, all the processes are blocked??

Yes, this might happen.

 

- When you need real (or: more) deterministic behaviour you need to use a realtime OS as is used with the RIO devices from NI.

- When you just want to read data from a DAQ device it might help to use the hardware timing of this DAQ device instead of relying on software timing!

 

Edit:

DID YOU READ MY COMMENT ON CONVERTING IMAGES TO REAL PNG/JPG?

BMPs are banned because of their filesize as can be seen from my converted PNG and JPG version of your image!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Download All
Message 9 of 12
(4,295 Views)

Hi GerdW,

Yes, I have read your comment on converting images but get no tools of converting, so sorry for that. 

In my project, I use the PXI-7813r Device to acquirer signals, with the sampling rate of 50us, and the timing is from PXI-7813R device. And I use the DMA FIFO technology to transfer data every 10 ms to master controller PXIe-8840 with the windows system. 

 

- When you need real (or: more) deterministic behaviour you need to use a realtime OS as is used with the RIO devices from NI.

Yes, I think I get the solution.

Thank you very much for your help, GerdW.

 

Best regards,

Rita

0 Kudos
Message 10 of 12
(4,282 Views)