LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to add elements to an array for 60 seconds and then call the last 60 seconds to compare as time increases

Solved!
Go to solution

I know the subject is a word soup but I'll try and clarify here.

 

In 60 second increments, for an experiment total time of 1 hour,  I am trying to add a 1 or 0 to an array(comes from experiment input and not relevant) each second.

 

I want to compare the sum of 1's to a user determined fail threshold(this part is covered, its just for clarity of what I'm trying to accomplish).

 

After the first 60 seconds, I want to compare the sum to the last 60 seconds...for example at t = 63s,  I want call the sum of values from elements  2-62 to compare with the fail condition threshold.  So basically, how do I create a sum that moves with time equal to the previous 60 seconds.

 

I have tried to next a for loop inside of a while loop, but it seems to refill the array with new values instead of appending it, and I cannot for the life of me find a way to call a range of elements in an array.  Would greatly appreciate any ideas on how to achieve this!

0 Kudos
Message 1 of 4
(443 Views)
Solution
Accepted by topic author wwjacobd

Hi Jacob,

 


@wwjacobd wrote:

After the first 60 seconds, I want to compare the sum to the last 60 seconds...for example at t = 63s,  I want call the sum of values from elements  2-62 to compare with the fail condition threshold.  So basically, how do I create a sum that moves with time equal to the previous 60 seconds.


This is called "running sum": you can easily create this using a Pt-By-Pt-DataQueue function, set to hold 60 samples…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 4
(431 Views)

This exactly what I was trying to accomplish.  Thank you!

0 Kudos
Message 3 of 4
(407 Views)

This can be achieved manually with a circular buffer, something like so.

circular buffer.PNG

Message 4 of 4
(402 Views)