LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

calculating on times of XY Data

I have two arrays - one of timestamps and one of binary samples of data which represent an event log that I want to compute the time the data is at the value of 1 on.  This signal data represents the time the system is on or off and I want to calculate the time that the system is on.  What is an easy way to do this?

0 Kudos
Message 1 of 4
(2,237 Views)

It depends on how clean the arrays are. Do they only contain entries about the run state, and is it guaranteed that you will never get two identical states after eachother? If this is the case the following code could do the trick:

 

timeOn.png

 

If the arrays do not fulfill those requirements you will either have to write the code so that it will handle the possible variations - or you can write a filter that will clean and sort the data first, and then run the resulting arrays through the code suggested above. If the arrays are rather large you might want to handle them a bit more memory-efficient though.

0 Kudos
Message 2 of 4
(2,223 Views)

The arrays are sorted in terms of timestamps but there is no guarantee that you wont get the same binary value for 2 events in a row.

0 Kudos
Message 3 of 4
(2,216 Views)

Ok, then you can do it as in the attached VI...(Search for the first ON, then search for the following OFF - add the difference to your total and continue this alternating search until the last TRUE has been reached.)

 

The attached VI then lets you decide whether to add the time from the last ON until the time you run the VI ("Extrapolate?"), or not.

0 Kudos
Message 4 of 4
(2,201 Views)