LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Counting Change of Sign of a Variable which can take values like +1,0 and-1

I am using a CCD camera and PCI 1407 to capture interference fringes.By a taking IMAQ intensity profile along a line of pixel I am getting Intensity profile and out of that by a particular algorithm I am deriving a phase sensitive output variable which crosses zero each time the fringe moves a particular distance.I am using a LabVIEW sign vi which converts any thing less than 0 or greater than 0 to -1 and +1 , now I am interested in counting number of time it crosses zero which can be done if i can register the event of change in sign from -1 to +1 or +1 to -1 , active all the time without cosidering any time .It should not count anythind if signal is stable and phase is constant as there will
be no change in sign of variable.I will be using this number of sign change incidence as an input for further processing of movement of fringe.
Ajay Shankar
0 Kudos
Message 1 of 4
(2,971 Views)
Hello Encoders,

if your sign values are in an array, you can make a copy of that array shifted by one position. Then you multiply the array with the copy: when there is a sign change, you get a -1, if there is no sign change you get a +1. Then you do a comparison "Is smaller than 0" followed by a "convert binary to 0/1" followed by "sum up array". Then you got your number of sign changes.
Simple math...
The attached vi illustrates the algorithm.
Best regards
Gerd
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(2,971 Views)
Hello sir,
Thanks for your response .My sign values are not arrays.It is a value of phase variable derived and calculated out of pixel intensity values out of sum and differences of array elements.Therefore I want to count sign change of this variable quantity which depends on change intensity distribution in original one dimension array of pixel intensities and is no more a array.
Ajay Shankar
0 Kudos
Message 3 of 4
(2,971 Views)
Two possibilities:
Count the sign changes with a Case statement inside a loop. Use a shift register to remember the last state and compare with the actual state.
Or:
Change your algorithm to get the "phase variable" also in an array. Labview can also do all the simple math with arrays. And most times its more easily to read and faster to calc.
Best regards
Gerd
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 4
(2,971 Views)