1
$\begingroup$

What are Method to phase shift 50 Hz digital signal using microcontroller. Appart from storage of samples to array and shift sample wise,how to shift this signal fractionally.

$\endgroup$
  • 2
    $\begingroup$ A phase shift for a periodic signal corresponds exactly to a time delay. What do you mean by "how to shift this signal fractionally?" $\endgroup$ – Jason R Oct 18 '12 at 12:29
  • $\begingroup$ @JasonR He means shifting it at a finer resolution that the sample resolution. $\endgroup$ – Jim Clay Oct 18 '12 at 15:02
3
$\begingroup$

You do it by creating a windowed sinc filter that has a wide enough pass-band to preserve the energy of whatever it is you are trying to phase shift. Instead of centering the sinc function, though, you shift it by whatever phase shift you want to introduce. You then filter the signal, which will now have that phase shift.

As Jason states in his comment, what we really want is a time delay, which means convolving with an impulse. The problem is that you can only do delays that are an integer multiple of the sample period with this technique. We get around that by creating a low-pass filter in the form of a windowed sinc. This is effectively the same as an impulse in terms of faithfully reproducing the signal-of-interest as long as the energy of the SOI is within the pass-band of the LPF. We then convolve the LPF with a fractionally delayed impulse. We do this by calculating the values of the underlying sinc function at those shifted time points.

Because convolution is a linear operation convolving your signal with the shifted sinc is equivalent to convolving the signal with a fractionally shifted impulse function and then convolving it with a LPF.

$\endgroup$
  • $\begingroup$ analog.com/static/imported-files/tech_docs/dsp_book_Ch16.pdf $\endgroup$ – Pawan Oct 19 '12 at 4:35
  • $\begingroup$ Thanks for response and showing Interest answering the question.I gone through windowed sinc filter "analog.com/static/imported-files/tech_docs/… i am Afraid that use of sine and cosine functions in code will cause 16Mhz, 16 bit microcontroller overloaded? I am running mcu at 4096 SPS from adc i.e. every ~244us i am have to collect sine wave sample. $\endgroup$ – Pawan Oct 19 '12 at 4:46
  • 1
    $\begingroup$ If the phase shift that you need doesn't change, you only have to generate the windowed sinc once and then simply reuse it. $\endgroup$ – Jim Clay Oct 19 '12 at 12:19
1
$\begingroup$

I agree with answer from Jim Clay. But if you need very fast algorithm and accuracy of results is not your main purpose, you can use a simple linear interpolation. For example, if you want to do shift by half of sample resolution you can use:

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

Yes, it is low-pass filter too, but very simple and very short. If you need more accurate results - use common answer from Jim Clay and carefully choose length of filter.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.