# digital phase lead

**URL:** <https://forum.arduino.cc/t/digital-phase-lead/588427>\
**Category:** General Guidance\
**Created:** [April 27, 2019, 3:03am UTC](https://forum.arduino.cc/t/digital-phase-lead/588427 "2019-04-27T03:03:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gary36](https://avatars.discourse-cdn.com/v4/letter/g/46a35a/32.png) [@gary36](https://forum.arduino.cc/u/gary36)\
**Post date:** [April 27, 2019, 3:03am UTC](https://forum.arduino.cc/t/digital-phase-lead/588427/1 "2019-04-27T03:03:01Z")

</div>

Hi  
I have two sine signals A and B(50Hz) which are simultaneously sampled at 2500 Hz using external ADC interfaced with Atmega2560. I find that signal B lags A by about 5 degrees(using scope). I would like to digitally lead signal B to sync it with A. Any proven algorithm? ( I do not want to use analog methods)

---

<div class="post-metadata">

**Author:** ![Railroader](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/railroader/32/274550_2.png) [@Railroader](https://forum.arduino.cc/u/Railroader)\
**Post date:** [April 27, 2019, 4:16am UTC](https://forum.arduino.cc/t/digital-phase-lead/588427/2 "2019-04-27T04:16:57Z")

</div>

To me that looks like some 5.55 uS of delay. 1 000 000 uS / 2500 x (5/360). My guess is that the A/D conversions are triggered one first and the other shortly, 5.55 uS later.  
One fix could be to measure the delay and compensate for tht in the calculations.  
Attach Your code.

---

<div class="post-metadata">

**Author:** ![gary36](https://avatars.discourse-cdn.com/v4/letter/g/46a35a/32.png) [@gary36](https://forum.arduino.cc/u/gary36)\
**Post date:** [April 27, 2019, 4:55am UTC](https://forum.arduino.cc/t/digital-phase-lead/588427/3 "2019-04-27T04:55:23Z")

</div>

I have not written any code. I am asking suggestions. I use AD7606 which claims that sampling is simultaneous without latency between samples.

---

<div class="post-metadata">

**Author:** ![Grumpy\_Mike](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/grumpy_mike/32/213521_2.png) [@Grumpy\_Mike](https://forum.arduino.cc/u/Grumpy_Mike)\
**Post date:** [April 27, 2019, 6:36am UTC](https://forum.arduino.cc/t/digital-phase-lead/588427/4 "2019-04-27T06:36:47Z")

</div>

> I would like to digitally lead signal B to sync it with A.

Sounds like a problem for a Phased Locked Loop ( PLL )

---

<div class="post-metadata">

**Author:** ![hammy](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hammy/32/238813_2.png) [@hammy](https://forum.arduino.cc/u/hammy)\
**Post date:** [April 27, 2019, 8:40am UTC](https://forum.arduino.cc/t/digital-phase-lead/588427/5 "2019-04-27T08:40:41Z")

</div>

Should be able to fix in the maths I would have thought .  
Would sampling at a lower rate make any difference (500hz?)  
How about delaying the second sample Reading for 20mS ?

Finally .... what are you doing with the sine waves? Does the delay matter?

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 5, 2021, 6:54pm UTC](https://forum.arduino.cc/t/digital-phase-lead/588427/6 "2021-05-05T18:54:15Z")

</div>


