# LabVIEW

cancel
Showing results for
Did you mean:

## Re: Taking 1st maxmin 2nd maxmin & 3rd maxmin from 1d array.

Thank you man for your time.

I will be looking forward to your suggestions as my VI is full of flaws.

Message 21 of 31
(346 Views)

## Re: Taking 1st maxmin 2nd maxmin & 3rd maxmin from 1d array.

It would be trivial to find the points of the signal where they cross ~50% of the amplitude (~.34, but since the signal is so steep it does not matter!), then take the inner ~1/3 of each interval and average thos, depending if it is a top or bottom interval.

You can also just threshold into the data, the do a low order fit (least absolute residual, second order in the picture) as in the attached simple example. Do piecewise averaging over a handful of peaks each time to record longtime trends.

Message 22 of 31
(335 Views)

## Re: Taking 1st maxmin 2nd maxmin & 3rd maxmin from 1d array.

The solution works perfect but I have one more question.

The white signal is out of phase from the square wave (chopper), it lags behind the square wave. how can i move the white wave in such a wave that the phase diference between these waves become zero ?

Message 23 of 31
(316 Views)

## Re: Taking 1st maxmin 2nd maxmin & 3rd maxmin from 1d array.

Hi Yum,

@Pukhtun_Yum wrote:

The white signal is out of phase from the square wave (chopper), it lags behind the square wave. how can i move the white wave in such a wave that the phase diference between these waves become zero ?

Best regards,
GerdW

using LV2016/2019/2020 on Win8.1/10+cRIO
Message 24 of 31
(313 Views)

## Re: Taking 1st maxmin 2nd maxmin & 3rd maxmin from 1d array.

Hello, yes I did but i did not come up with the solution of it yet

Message 25 of 31
(311 Views)

## Re: Taking 1st maxmin 2nd maxmin & 3rd maxmin from 1d array.

Hi Yum,

when you can determine the phase shift then you can shift one of the signals to align them.

You already know how to determine state changes in the choper signal. You can implement a similar algorithm to determine the related state changes in the thermopile signal.

Once you know both positions (aka sample indexes) you can use Rotate1DArray to shift one signal…

So what have you tried and where are you stuck?

Best regards,
GerdW

using LV2016/2019/2020 on Win8.1/10+cRIO
Message 26 of 31
(308 Views)

## Re: Taking 1st maxmin 2nd maxmin & 3rd maxmin from 1d array.

The phase shift fluctuates and how to use phase shift in rotating the 1d array

Message 27 of 31
(304 Views)

## Re: Taking 1st maxmin 2nd maxmin & 3rd maxmin from 1d array.

Your VI makes absolutely no sense.

You can only "phase shift" by rotating an array if it contains an integer number of periods for all frequencies. This is not the case with your data. Just find the location if the first transition halfway between the low and high points, then shift one of the data and discard whatever does not contain data from both.

Of course if the delay is an exactly known and invariant instrumental quality, you can just delay one trace by the correct number of points.

Message 28 of 31
(262 Views)

## Re: Taking 1st maxmin 2nd maxmin & 3rd maxmin from 1d array.

This is how i did, can you please take a look

Message 29 of 31
(254 Views)

## Re: Taking 1st maxmin 2nd maxmin & 3rd maxmin from 1d array.

@Pukhtun_Yum wrote:

This is how i did, can you please take a look

This will not work for the general case because half the amplitude is only at the midpoint if the lower parts are close to zero. (e.g. if you data would go from -5 to 0, the amplitude is 5 but the data never reaches 2.5). Your code also fails the the data e.g. starts at a valley. You need to test for all possible inputs (one starts at low, one at high, both at high, both at low, etc.). Add some code where you can arbitrarily rotate each trace before sending it to your alignment!

Here's my quick attempt. Modify as needed depending on which part you want to shift. Also note that the shift might not be integer, so a better solution would remap the data using interpolation. (not shown)

Message 30 of 31
(231 Views)