Signal Processing Stack Exchange is a question and answer site for practitioners of the art and science of signal, image and video processing. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to phase shift an incoming sine wave with varying frequency but I am unsure how to go about doing so in practical terms.

A little more info regarding the requirements: I have an encoder producing a sine/cosine pair with a fixed Peak to Peak but as the speed changes so obviously does the frequency. I want to effectively advance/retard the signal by altering the phase of the incoming signal.

Where I am unsure is how to go about doing this, if I use a look up table (LUT) for fast frequencies this would be ok but at slower frequencies I am going to get a very rough (digitised) signal. I was thinking I could calculate the signal 'on the fly' but again that would require having a LUT ie output = sin (input(amplitude) + offset[amplitude])

I think I maybe going about this the wrong way and there is possibly a simple solution to this?

share|improve this question
So you want to phase shift a sine/cosine pair that has the same frequency? – Jim Clay Feb 25 '13 at 17:18
Yes, the cosine is provided to determine direction so will always be the same frequency. – LogicTom Feb 25 '13 at 17:21
I will also add that I have been looking into both 'standard' microcontrollers as well as DSP based micros - if that alters the implementation options available. – LogicTom Feb 25 '13 at 17:24
You want an NCO. See other questions here and here. – Jason R Feb 25 '13 at 18:07
up vote 0 down vote accepted

Indeed, as Jason R sais, that's how all sine oscillators are designed for synthesizers, they must change frequency without changing phase, so you have to control them only using a counter, and you vary the counter increment speed to change the sine/cosine frequency, in that way the sine is always one count onwards from it's previous value regardles of speed changes.

share|improve this answer
Can't for the life of me remember the application for the question but that's anyway! – LogicTom Apr 18 at 12:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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