LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

looking for zero crossing point

Hello,
I have Amplitude vs. time data (wave).    
I need to find the zero crossing time. Now I am using "For loop"  to search the Amplitude array for the index of the neighbor to zero through point by point, and then by linear inerpolating to get the zero crossing time.  When the point number is large, say 60kpts, it gets slow because the for loop "point by point" searching method, I think.
I am wondering if there is any quick way to do that.
 
Thanks,
 
Wei Tong
0 Kudos
Message 1 of 35
(18,102 Views)
One way of finding zero crossings is to multiply successive values together. If the product is negative, the two points are on opposite sides of zero. This can be implemented rapidly with a for loop and a shift register. A simple test shows that it can test an array of 1 million elements in about 45 milliseconds.

Lynn
Message 2 of 35
(18,095 Views)
I love the simplicity of that. Smiley Happy I've used the zero crossing PtByPT but I don't think it performed (or was it as easy to use) as your solution.
PaulG.

LabVIEW versions 5.0 - 2023

“All programmers are optimists”
― Frederick P. Brooks Jr.
0 Kudos
Message 3 of 35
(18,092 Views)

I don't know how realized it by shift register with a For Loop. Could you please show an example? I have an array of data.

When finding the zero crossing point for Amplitude Array,  I need to get the zero crossing time .

 

Thanks,

 

Wei Tong

LabView7.1

0 Kudos
Message 4 of 35
(18,058 Views)

This is the basic idea.

If you calculate the zero crossing , each time you acquire new data, you will have no speed problems.

Although this is NOT completely right. It will not work if one data is equal to zero.

You should add aditional code for this....



Message Edited by Pnt on 04-13-2008 09:36 AM
0 Kudos
Message 5 of 35
(18,043 Views)

Your problem description is really not very well defined to make a definite suggestion.

  • Do you have a single zero crossing or multiple.
  • If there is more than one, do you want to find the first one, or all of them.
  • Is the data monotonically increasing or decreasing?

Depending on how much you know about the data, you might be able to use "threshold array" (which gives you the linearly interpolated x value of the first zero crossing from negative to positive) Check the online help for details.. If the function is monotonic, you could use a binary seach, which is much faster.

0 Kudos
Message 6 of 35
(18,037 Views)

Sorry for unclear descrition.

There are a lot of zero crossings  because the data is kind of sine wave(mixture). I need to find all of them (zero crossing time). Also I need to identify the "increasing" zero crossing and "decreasing" zero crossing.

 

Wei Tong

LV 7.1

 

 

0 Kudos
Message 7 of 35
(18,019 Views)
Try something like this, maybe? See if it makes sense.
 
(It currently fails if a value is exactly zero and the function does not switch sign afterward. It just needs a bit more code to fix that. 🙂 Modify as needed.)
 


Message Edited by altenbach on 04-13-2008 12:52 PM
Download All
Message 8 of 35
(18,011 Views)
Thanks.
0 Kudos
Message 9 of 35
(18,006 Views)

 

Thank you!

 

 

I'll try your example maybe it will fit my Zero-Crossing FM demodulation project/
0 Kudos
Message 10 of 35
(17,677 Views)