LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sampling frequency effects on convolving waveforms (need feedback from a signal processing GURU)

Solved!
Go to solution

I have included my code as version 8.5 for those who have not yet upgraded to 8.6.  I have also included screenshots so that you can reproduce the results which I have obtained.  I hope that some signal processing guru can shed the light on what I discuss below.

 

This VI convolves the impulse response signal of a simulated servo motor which is essentially a damped sinusoid with the input stimulus that is a step function.  The resulting convolved signal should be IDENTICAL to that of the step response of the motor which is RED in the 1st chart display.  As you can see the resulting convolution in the 2nd chart has the same frequency structure but the magnitude is INCORRECT.  As you can see in the 2 screenshots the magnitudes differ by a factor of 2 & so does the sampling frequency of the waveform.  Why the sampling frequency impacts the magnitude is both puzzling & troubling.

 

Would appreciate any explanations & corrections so that I have confidence in convolving other input waveforms than just the step function.

Download All
0 Kudos
Message 1 of 10
(6,441 Views)

One further note is that I did not allow the sampling frequency to change the length of the arrays representing the Y values of 2 convolved waveforms so if the array lengths are sufficiently long with respect to the decay period of the impulse response I would not expect the magnitude of the convolved signals to change!!!!!!!!!

 

So I am MIFFED

0 Kudos
Message 2 of 10
(6,431 Views)

Hi tsunami,

 

In your VI, you pass dt in derivative x(t) VI.  When sampling freuquency changes, dt also changes. This will affect the result of derivative x(t).vi. 

 

So the input of Convolution VI is different with different sampling requency input.

0 Kudos
Message 3 of 10
(6,409 Views)

U R correct that dt is affected by the sampling freq but increasing the freq helps smoothing of the deriv operation which should converge the convolved waveform with the original.  Unfortunately, the increase of sampling freq diverges the magnitude from the original waveform!!!!!!!!!!!!!!!!!

 

Try it & check it out

0 Kudos
Message 4 of 10
(6,391 Views)
BTW: if U can reproduce the original waveform on Ur end then CLUE me in because I am seriously lost!!!!!!!!!!!!!
0 Kudos
Message 5 of 10
(6,389 Views)

Hi tsunami,

Derivative x(t) VI uses the discrete differentiation to compute the derivative.  Consider the simple central differentiation,

 

y[i] = (x[i+1]-x[i]) / (2*dt)

 

When you double the sampling rate from 500 Hz to 1k Hz, y[i] also doubles, since dt is only 1 ms now.  So this means the second input of Convolution VI doubles the amplitude. Thus the output of Convolution VI also doubles.

 

To eliminate the effect of the sampling rate, you can divide the convolution result by the sampling rate.

 

Also please check your VI - I think you use "offset" control for both the sine signal generation and step function. I think "offset" should be 0 in this case. And generate step function separately.  I am not sure if this is a problem. Please double check it.

 

After modifying the code, I can get the identical results.

0 Kudos
Message 6 of 10
(6,376 Views)

I am not sure your VI works either.  An offset needs to be applied to the sinusoid because there is a DC offset to a step response the the sinusoidal decay settles on that value as t-->infinity.  If you apply an offset the convolved waveform still does not have the correct magnitude even with your modification.  Moreover, the larger the offset the worse the discrepancy.

 

As for the derivative I don't quite yet understand.  I thought if the sampling freq changes so does dt as well as (x[i+1]-x[i]) such that the derivative of the waveform is not affected.  In other words, is not the derivative of sin(x) = cos(x), not n*cos(x) where n becomes a function of the sampling frequency?  I am experimenting with that now to see if what you are saying is correct.

0 Kudos
Message 7 of 10
(6,362 Views)

I tested your hypothesis of the effect of the sampling freq. on the derivative & attached the following 4 screenshots that don't seem to support your premise.  What I did was attach indicators to the output of the derivative.vi & the magnitudes do not seem to be affected as you say.

 

So we still do not have a solution!!!

0 Kudos
Message 8 of 10
(6,354 Views)
Solution
Accepted by topic author tsunami

OK, I think I have it working now.  Your premise on the effect of the sampling freq on the derivative is not the issue.  What the sampling freq. does affect is the convolution time basis.  Since the convolution is not continuous but discrete the array length needs to be accounted for & the sampling frequency needs to be consistent with that array length so that 1 second corresponds to 1 second.  If it sampling freq is 2 kHz & the array length is 1000 then to get the time basis correct a factor of 2 needs to be accounted for.  Moreover, to account for the DC offset the ZERO gain factor needs to be added to the convolved signal to get the magnitude correct.

 

Thanks for getting me think about this deeper.

0 Kudos
Message 9 of 10
(6,327 Views)
Hi. I'm having trouble with the convolution VI too. For me, it looks like just my magnitude is off. Trying to convolve square wave pulse with RC impulse response. I've made a post here :

http://forums.ni.com/t5/LabVIEW/Non-Ideal-RC-Impulse-Response-to-Square-Wave-Issue/td-p/3263215

Can you help?
0 Kudos
Message 10 of 10
(5,136 Views)