From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Elapsed Time Express VI: why sometimes Elapsed Time is not the same as Time Target (s)

Solved!
Go to solution

Hello, 

 

I am trying to make a program to take voltage data in a specific period, then calculate the average value of the data. I also want to change time target several times before saving data (no. of test-counter, time target, avg volt).

 

I am suffering because sometimes Elapsed Time and Time Target are different. Did I do anything wrong? 

 

Thank you for all your comments and help.

 

Best regards,

Plu

0 Kudos
Message 1 of 5
(867 Views)
Solution
Accepted by PuriK.

There are a couple of things I would change about this VI but the main problem you're getting is that you have some execution cases where the express VI isn't run. Once the express VI runs once, it ALWAYS keeps track of time. Including time when the task is being stopped and recreated, and before start is hit on the second iteration of the top loop. You need to be manually handing the reset logic for the timer but even better IMO is to implement your own timing logic with code setup like this.

 

~ The wizard formerly known as DerrickB ~
Gradatim Ferociter
Message 2 of 5
(856 Views)
Solution
Accepted by PuriK.

Short answer is that elapsed time VI runs only when it is called (~ every 100 ms in your case) - the clock of this VI is not exactly aligned with the clock of Tick Count (ms) you use for timing + the code takes some time to execute, so you don't get exactly Time Target value in Elapsed Time indicator.

 

I also noticed that you have Timer autoreset turned on. In that case, once you get over Time Target value, the Timer is reset. When you click Start after 3 seconds, you already see 3s in elapsed time, but I guess you would expect 0 right? You need to wire the reset input somehow and turn the autoreset off.

 

The problem in your code is somewhere else though. I don't think you need to code it this way. Does this code fulfill your needs? I mean, measure 100 values, then based on START button value, you repeatedly wait for the Time Target? You certainly don't want to have the concatenating output from the while loop. And the Mean VI should be one level deeper, just after finishing the while loop, right?

 

I would recommend removing the timer from this loop completely, maybe start anew with Continuous DAQmx Example, and place the added code in another loop. You should consider using queue to send data from the DAQmx loop to the other queue. The DAQmx loop should be timed by the DAQmx Read VI only, where you specify the timeout correctly. This is a must for continuous reading, but since what you've shown looks more like on demand reading, you might be able to stuff it all in only one loop.

Message 3 of 5
(842 Views)

Thank you so much for explaining the cause of this problem. It helps me a lot. 

0 Kudos
Message 4 of 5
(821 Views)

Thank you so much. I can improve this vi a lot according to your suggestion.

0 Kudos
Message 5 of 5
(819 Views)