I have two sine signals A and B which are simultaneously sampled at 2500 Hz using ADC. Through oscilloscope, I find that signal B lags A by about 5 degrees. I would like to digitally lead signal B to sync it with A. How to do that in MCU?


Do they lag 5 degrees for all frequencies? Or only for a specific signal frequency?

If you want to shift a signal by 5 degrees for all frequencies you need some kind of all-pass filter similar to a Hilbert filter. However the Hilbert Filter whether FIR or IIR shifts a signal by 90 degrees not 5.

However, if you want to add or subtract 5 degrees at a specific frequency, you need to this

delay = phase/( 2*pi * f).

If your delay is an integer number of samples, you simply need to delay your leading signal by this number of samples. However, if the delay is fractionnal you need to delay the leading signal with a fractional-delay filter.


| improve this answer | |
  • $\begingroup$ Signal frequency is 50 Hz fixed. How many samples do I have to delay for achieving 5 degree lead? $\endgroup$ – gari Apr 27 '19 at 4:16
  • 1
    $\begingroup$ gari: I think you can calculate that yourself. How long in samples is 360°? $\endgroup$ – Marcus Müller Apr 27 '19 at 7:34
  • $\begingroup$ Sampling for 2500Hz means I have 50 samples for a period, each samples displaced by 400us. Each sample delay contributes ( 360/2500) degrees. Is it the right way? $\endgroup$ – gari Apr 27 '19 at 8:00
  • $\begingroup$ Not quite phase = 5 * pi/180 = pi/36 Delay = pi/36* 1/(2*50*pi) = 1/(3600) = 277.77777 µs Less than 1 sample, you need a fractional delay filter $\endgroup$ – Ben Apr 27 '19 at 12:42

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.