08-09-2009 02:25 PM
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.
Solved! Go to Solution.
08-09-2009 04:26 PM
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
08-09-2009 11:40 PM
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.
08-10-2009 02:44 AM
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
08-10-2009 02:53 AM
08-10-2009 03:54 AM
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.
08-10-2009 02:38 PM
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.
08-10-2009 03:10 PM
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!!!
08-10-2009 05:45 PM
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.
03-05-2016 07:33 PM