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?

  • $\begingroup$ So you want to phase shift a sine/cosine pair that has the same frequency? $\endgroup$
    – Jim Clay
    Feb 25, 2013 at 17:18
  • $\begingroup$ Yes, the cosine is provided to determine direction so will always be the same frequency. $\endgroup$
    – LogicTom
    Feb 25, 2013 at 17:21
  • $\begingroup$ 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. $\endgroup$
    – LogicTom
    Feb 25, 2013 at 17:24
  • 1
    $\begingroup$ You want an NCO. See other questions here and here. $\endgroup$
    – Jason R
    Feb 25, 2013 at 18:07

1 Answer 1


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.

  • $\begingroup$ Can't for the life of me remember the application for the question but that's anyway! $\endgroup$
    – LogicTom
    Apr 18, 2016 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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