Menu

dirft correction in function adjFreq

Help
mhfj
2012-01-25
2012-11-23
  • mhfj

    mhfj - 2012-01-25

    Hello,

    I am trying to add hardware timestamping for a network card to ptpd. I looked at this https://sourceforge.net/projects/ptpd/forums/forum/469207/topic/1852996 and this http://home.mit.bme.hu/~khazy/ptpd/. Setting and reading the clock of the card is working, so is reading timestamps. I am currently working on correcting the drift of the clock inside the card.

    Adjusting the drift is done in the function adjFreq in dep/sys.c. I tried the solutions of the links I looked at but setting the drift in the way they do it somehow doesn't work for my cards. I believe this might be because I don't calculate the drift correction correctly.

    Does anyone know in what unit (like pps or ns/s) the parameter adj of the function adjFreq is?

    thanks for your help

     
  • Wojciech Owczarek

    The ptpClock->observedDrift (what is calculated by the servo and passed to adjFreq) is ppb (ns/s), i.e. drift 3500 = 3500 ppb = 3.5ppm = 3.5us/s frequency offset.

    This value eventually converted and passed to the adjtimex syscall (freq), is scaled ppm, with the base being 2^16, i.e. frequency offset of 65536 = 1ppm. So observedDrift is multiplied by 65536 and divided by 1000.

    You need to remember that the observedDrivft value is clamped (kept within bounds) to the kernel frequency offset limit, that is +/-512ppm.

    Hope this helps.

     

Log in to post a comment.