01-11-2018 09:26 AM
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
01-11-2018 09:36 AM
01-11-2018 10:20 AM
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.
01-11-2018 01:39 PM
01-11-2018 04:29 PM
@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?
01-11-2018 04:56 PM - edited 01-11-2018 04:57 PM
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.
01-19-2018 09:31 AM
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.
01-19-2018 02:04 PM - edited 01-19-2018 02:04 PM
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!
01-19-2018 03:27 PM
Altenbach's solution should work for you. Have you tried it? Much more efficient than yours.
01-22-2018 11:26 AM
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.