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: 

Measuring the time taken between values received from tags

I am measuring the times (in seconds) of 3 production sequences; x, y and z. I can get the values of x and z from the plc via tags configured in the DSC module, however I can not measure y straight from the plc. I would like to calculate the time taken between x stopping and z starting in order to give me the time span of y.

Is there a way of programming the Tick Count (ms) function to start counting once I have stopped receiving the value of x, and to stop counting once I have started receiving the value of z?

Any example code would be greeeattly appreciated.

Many thanks,

Stuart

0 Kudos
Message 1 of 6
(2,548 Views)
Hello Stuart,

surely there's a way 🙂

Take the actual time when you stop getting x values and take again the actual time when you start the z stage. Subtract the first from the second and you get the y-time.


Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(2,549 Views)
Take the actual time when you stop getting x values and take again the actual time when you start the z stage. Subtract the first from the second and you get the y-time. Hi GerdW, thankfully I managed to work out the maths of obtaining this time (i would be worried if i didn't), however I am not sure how to 'take the actual times' using LabVIEW code, especially to specify when one tag STOPS measuring and the other tag STARTS measuring. What functions or commands do i use to achieve this?? Do you have any example code I could have a look at? Your time and input is much appreciated! Stuart
0 Kudos
Message 3 of 6
(2,544 Views)
This is a perfect case for why we need events based on DSC tag value changes without having to write code. You could use dynamic events and use the tag values to trigger them. Or just read the tags in a loop and use some code with it. Attached file is 7.0 format.
0 Kudos
Message 4 of 6
(2,539 Views)
Excellent UncleBump, thankyou. Just a quick question though.. i take it the true-false, false-true inputs determine whether the vi takes the time when the value stops recording, or when it takes the time when the value starts recording??? For this reason, does the initial 'x' element of the read tag have to go on top of the array of tag names, and the 'z' element go on the bottom?? I'm a little confused which way round this applies to my example. Many thanks for your support, Stuart
0 Kudos
Message 5 of 6
(2,534 Views)
Yes, the x tag name would go on top in the array. I assumed you were looking at boolean values.
0 Kudos
Message 6 of 6
(2,531 Views)