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 crossing detector in software

Hi,

 

I have an analog input read from a PLC which is copied into a variable. whenever it crosses a particular value x, I want to set a variable. Something similar to a zero crossing detector in hardware. Is this possible in Labview?

 

Thanks!

0 Kudos
Message 1 of 6
(3,573 Views)

What exactly do you mean by "crosses particular value"? Do you want to trigger a signal whenever your analog input reaches or goes high than that particular value?
You might want to use "equal to" function in comparison palette. 


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

the problem with using 'equal to' is , the signal has to be polled in a while loop and the while loop requires a delay and if during the delay time the signal crossing happens the program will miss to detect it.  

 

I am looking for something similar to a microcontroller interrupt. when an event happens, a signal is triggered, we dont have to poll for it continuously.

0 Kudos
Message 3 of 6
(3,549 Views)

Use event structure to trigger another event whenever an input changes it's value. If it is boolean ( High or Low ) then use " Boolean Crossing ptbypt". 

 


0 Kudos
Message 4 of 6
(3,542 Views)

What is the sampling rate of your acquisition? Use "Timed Loop" to acquire every sample without missing one. And then inside that loop use event structure to monitor for signal change and then trigger an event based on that change. 


0 Kudos
Message 5 of 6
(3,534 Views)

Use a >? comparison with the analog input wired to the top terminal and the value of x wired to the lower terminal. The output (boolean) goes to a shift register. Compare the previous result (left terminal of shift register) to current value (output of comparison). If they are different, you have an "x-crossing." If you only want crossings in one direction, the logic is slightly different.

 

Lynn

Message 6 of 6
(3,505 Views)