How to process/generate a phase shifted frequency varying sine wave?

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?

• 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

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.

• Can't for the life of me remember the application for the question but that's anyway! – LogicTom Apr 18 '16 at 12:07