NI Home > Community > NI Discussion Forums

LabVIEW

Reply
Member
dg_lbe
Posts: 86
0 Kudos
Accepted 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.......  

Member
Herlag
Posts: 102
0 Kudos

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

Active Participant
Hornless.Rhino
Posts: 690
0 Kudos

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.

Member
dg_lbe
Posts: 86
0 Kudos

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.

Member
dg_lbe
Posts: 86
0 Kudos

Re : zero crossover detection of 2d array text file

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

Active Participant
Hornless.Rhino
Posts: 690
0 Kudos

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.