Multithreaded-software/external/soem/test/win32/ebox/ebox.c
void ec_sync(int64 reftime, int64 cycletime , int64 *offsettime)
{
   int64 delta;
   /* set linux sync point 50us later than DC sync, just as example */
   delta = (reftime - 50000) % cycletime;
   if(delta> (cycletime /2)) { delta= delta - cycletime; }
   if(delta>0){ integral++; }
   if(delta<0){ integral--; }
   *offsettime = -(delta / 100) - (integral /20);
}
/* PI calculation to get linux time synced to DC time */
PI calculation to get linux time synced to DC time
PI calculation to get linux time synced to DC time
void ec_sync(int64 reftime, int64 cycletime , int64 *offsettime)
{
   int64 delta;
   delta = (reftime - 50000) % cycletime;
   if(delta> (cycletime /2)) { delta= delta - cycletime; }
   if(delta>0){ integral++; }
   if(delta<0){ integral--; }
   *offsettime = -(delta / 100) - (integral /20);
}
void ec_sync ( int64 reftime , int64 cycletime , int64 * offsettime ) { int64 delta ; delta = ( reftime - 50000 ) % cycletime ; if ( delta > ( cycletime / 2 ) ) { delta = delta - cycletime ; } if ( delta > 0 ) { integral ++ ; } if ( delta < 0 ) { integral -- ; } * offsettime = - ( delta / 100 ) - ( integral / 20 ) ; }
PI calculation to get linux time synced to DC time
PI calculation to get linux time synced to DC time
/* set linux sync point 50us later than DC sync, just as example */