Menu

algorithm of "adjFreq()" in ptpd2.3.1

JoHung
2015-09-03
2015-09-17
  • JoHung

    JoHung - 2015-09-03

    Hi,
    Recently i am study and implement the ptpd2.3.1 code.

    When it comes to adjFreq() i have no idae why the code doing this?
    The paprmeter in this function is nanoseconds, and why using following formula can be frequency?
    double dFreq = adj * ((1 << 16) / 1000.0);
    t.freq = (int) round(dFreq);

    Doesn't frequency be calculated by "timeOffset/periodTime"?
    What is the purpose of shift 16 bits and divide 1000 ?

    Does this adjFreq means it can tune the oscillator ?
    Cause by searching relative articles,i think this adjFreq tune the RTC clock not oscillator.

    And i also print out the relative log. The freq value seems very large?

    =============================================================
    2015-09-02T16:12:25.591Z 3060: [PTP] (J)Sync message received :

    2015-09-02T16:12:25.591Z 3061: [PTP] (J)HandleSync(1): case PTP_SLAVE

    2015-09-02T16:12:25.591Z 3062: [PTP] (J)HandleSync(4): PTP ONE_STEP

    2015-09-02T16:12:25.591Z 3063: [PTP] ==> (J) updateClock()

    2015-09-02T16:12:25.591Z 3066: [PTP] (J)==> adjFreq() t.freq= 195536

    2015-09-02T16:12:25.591Z 3067: [PTP] (J)===>adj is 2983.642906250; t freq is 195536(ppm) (float: 195536.021504000)

    ==============================================================

    Another question is that, is their has any conditions to defined
    "HAVE_STRUCT_TIMEX_TICK" & "HAVE_SYS_TIMEX_H" ?

    I have "sys/timex.h" in my embedded linux, so i defined "HAVE_SYS_TIMEX_H".
    Does these defined suitable for all systems?

    If there has anything very basic but i don't understand, plz give me a hint. I'll study it.

    Thanks

    Regards,
    Jo

     
  • Wojciech Owczarek

    Hi,

    1. Just see man adjtimex. The frequency offset is in parts per million (ppm) scaled to 2^16.
    2. The HAVE_X_X macros are defined by autotools / configure script. They are defined in config.h which the configure script generates.

    Regards,
    Wojciech

     
  • CK

    CK - 2015-09-16

    Hi,
    How to observe the information about the freq error, or master/phc offset like display message in linuxptp?
    ptp4l[114947.247]: master offset 100 s2 freq +260 path delay 2550
    or
    phc2sys[115333.442]: phc offset 58 s2 freq +98 delay 2281
    or
    phc2sys[115045.887]: rms 301 max 613 freq -12 +/- 189 delay 2249 +/- 28

    when I change the AFC about oscillator(to tune the central frequency) in my device, I can see variable by change in linuxptp, but how about ptp even there is no support of PHC?

    Thanks

     
  • Wojciech Owczarek

    Hi,

    Well there is no official PHC support, so unless you developed your own clock control, you can only see the OS clock frequency offset. Ptpd gives you this in the "Observed drift" column of the statistics file, or in the status file you can see it in the "Clock correction" line. This is however actually the PI servo accumulator - sum of errors times integral gain. The actual freq offset applied is that plus error times proportional gain - which is 0.1 by default. So for a low offset, the value you see in the logs is very close to the final freq shift.

    If you also have ntpd installed in your system, then "ntpdc -c kerninfo" will also print the frequency offset currently applied.

    Once h/w assistance support is completed, we will make the frequency visible, as it is definitely a useful property.

    Thanks,
    Wojciech

     
  • CK

    CK - 2015-09-17

    Hi,
    I see the slave init log like
    ptpd2[1538].eth0 (info) (init) Observed_drift loaded from kernel: -14687 ppb
    ...
    so the unit of 'Observed Drift' is ppb?
    2015-09-17 10:48:06.295608, slv, 000102fffe030464(unknown)/1, 0.000543978, -0.000059856, 0.000784683, 0.000352353, -8701.271202148, S, 0.000535694, 33839, 0.000548958, 383418, -17088, 4318, 0.000352353, 0.000784683

    It means that frequency offset between master and slave is -8701ppb?

    Thanks.

     

    Last edit: CK 2015-09-17

Log in to post a comment.