# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## zero crossover detection of 2d array text file

Drawing a blank on this.  I have a text file that represents a 2d array of distance in column 1 and voltage out in column 2.  Need to search file and extract the zero crossover value and the corresponding distance value.  Once completed need to subtract the 2 consecutive values to determine the distance between the 2 crossover points.  Have to do this for all zero crossovers.

So if my crossovers were at 11,21,32,41,51,61........ So 21 - 11 = 10, 32-21 = 11, 41-32=9, 51-41 = 10, 61-51=10......

Thanks so much for your help.

Happy Thanksgiving.......

Message 1 of 6
(403 Views)

## Re : zero crossover detection of 2d array text file

Various solutions seem quite easy to imagine !

What did you try ? Could you post some code from your own to clarify your problem, if any ?

Best regards,

HL

Message 2 of 6
(396 Views)
Solution
Accepted by topic author dg_lbe
08-27-2015 04:09 PM

## Re : zero crossover detection of 2d array text file

First get the data into LabVIEW (perhaps "spreadsheet to array" or similar).

Well you'll have a crossover when you have a -ve to +ve (or +ve to -ve) transition. [by this I mean going from <0 to >0 or >0 to <0, I'm ignoring positive and negative 0s]

So just move through until you find these transitions.

note: you'll also have to check for values=0 as they'll be a crossover but not a sign related transition (as defined above).

If you have a value=0 then the cross over is right there

if not, just use interpolation to find it.

You can then build up an array with the crossovers as you go through.

You can then move through that finding the differences.

Message 3 of 6
(388 Views)

## Re : zero crossover detection of 2d array text file

Thanks for the help in the right direction....  I generated the code but seem to have a brain freeze with getting all the values into an array.  I've attached the file I'm working with.

Message 4 of 6
(360 Views)

## Re : zero crossover detection of 2d array text file

Figured out the build array issue.  Now just working on the differences of each reference.

Message 5 of 6
(357 Views)

## Re : zero crossover detection of 2d array text file

I can't open your VI (I use an old version of LabVIEW) but I'd use a loop (the type is up to you).

Some pseudo code.

make an array_of_differences

i=number of elements in array.

for(k=0;k<i;k++){

current_diff=array(k+1)-array(k);

append_current_diff_to_array_off_differences

}

essentially iterate through all elements of the array except the last one, and find the difference between the current element and the next element (use index array to pull out the values), and then finding the difference is trivial. Then just put them into the array of differences how ever you see fit.

There are a few ways to do this;

1) just use build array in a loop, and add a new element onto the old array

2) pre initialise the difference array using the initialise array block and the number of entries based on the number of differences there will be (number of crosses - 1).

Not sure about the efficiencies or if there's anything in either method you need to be careful of, but hope that helps if you haven't got it sorted already.

Message 6 of 6
(331 Views)