LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Counting rising edges in array compared to another array

I have two arrays of captured data. What I would like to do is measure how many rising edges there are in on array between the rising edges of the other array. I realize using a card with a counter would make this pretty easy, but I don't have one so trying to make this work. I thought about checking the control array for a rising edge and saving the position, and then checking for the next rising edge and save that position as well. Then, go to the other array and save only the data between the start and end points, and count the number of edges in that section. I'm not sure if that is the most efficient way to do that, and was hoping to see if that is the right path to take or if someone may have an easier way to do it. Thanks

0 Kudos
Message 1 of 11
(3,730 Views)

Hi guy,

 

you could autoindex both arrays in one loop! No need for data copies…

Use the "control array" to enable the counting of rising edges in your "other array".

Stop the loop on a falling edge of the "control array"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 11
(3,723 Views)

This is my attempt at what you suggested, and it is giving me the total amount of rising edges on channel A, just not between a rising edge set on the index.

0 Kudos
Message 3 of 11
(3,711 Views)

Hi guy,

 

I told you to use just one loop:

check.png

- detect pulses on your data array

- detect both edges on your index array

- generate a GATE from your index array pulses

- use this GATE to limit pulse count of the data array

Best regards,
GerdW


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

@randomguy77 wrote:

I have two arrays of captured data. What I would like to do is measure how many rising edges there are in on array between the rising edges of the other array. I realize using a card with a counter would make this pretty easy, but I don't have one so trying to make this work. I thought about checking the control array for a rising edge and saving the position, and then checking for the next rising edge and save that position as well. 


So, this assumes that there are only two rising edges in the control array. Is this always true? How do you want to handle it if it is not true? Should each rising edge in the control array toggle between "not counting" and "counting" edges in the other array?

0 Kudos
Message 5 of 11
(3,684 Views)

Here is a simple example using booleans. You can easily convert your analog data using Gerds method, of course.

 

This counts FALSE>TRUE transitions in "data" array between the first and second FALSE>TRUE transition in the "control" array. See if it makes sense.

 

CountRising.png

 

Message 6 of 11
(3,680 Views)

Hey GerdW,

 

Sorry for not getting back sooner. I have tried what you listed, and the count total was always lower than the number that was expected. I created a text file real fast that has the data from the two channels. The count should be at 400 for total number of CH. A rising edges between each index rising edge.

0 Kudos
Message 7 of 11
(3,636 Views)

After playing around with it some today, I managed to make a solution that works. It probably isn't the most efficient way to solve the problem, but it is giving me the correct answer!

0 Kudos
Message 8 of 11
(3,621 Views)

Altenbach's solution should work for you. Have you tried it? Much more efficient than yours.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 9 of 11
(3,616 Views)

I did try it, but the output was staying at zero when I tried it. I didn't put much effort into looking into why it was staying zero though.

0 Kudos
Message 10 of 11
(3,606 Views)