From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

zero crossover detection of 2d array text file

Solved!
Go to solution

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.......  

0 Kudos
Message 1 of 6
(2,850 Views)

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

0 Kudos
Message 2 of 6
(2,843 Views)
Solution
Accepted by topic author dg_lbe

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.

0 Kudos
Message 3 of 6
(2,835 Views)

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.

0 Kudos
Message 4 of 6
(2,807 Views)

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

0 Kudos
Message 5 of 6
(2,804 Views)

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.

0 Kudos
Message 6 of 6
(2,778 Views)