X-Git-Url: https://zdv2.bktei.com/gitweb/EVA-2020-02.git/blobdiff_plain/8b52ffcaab047d950f2c0818680f3347d55dce70..c8ebb71cde973439d2a2161cc72f170bfed3a25b:/exec/bkgpslog?ds=sidebyside diff --git a/exec/bkgpslog b/exec/bkgpslog index 0dd7f5d..b69b8be 100755 --- a/exec/bkgpslog +++ b/exec/bkgpslog @@ -950,8 +950,8 @@ magicBufferSleepPID() { ### PID Control factors K_P=1; # Gain for compensating buffer round lag - T_I="$((4*BUFFER_TTL_NS))"; # Consider this number of past nanoseconds to eliminate error - T_D="$((1*BUFFER_TTL_NS))"; # Predict value this number of nanoseconds into the future + T_I="$(((4)*BUFFER_TTL_NS/(1)))"; # Consider this number of past nanoseconds to eliminate error + T_D="$(((1)*BUFFER_TTL_NS/(1)))"; # Predict value this number of nanoseconds into the future # Calculate Error, errNS, in nanoseconds ## Get current time @@ -976,12 +976,18 @@ magicBufferSleepPID() { # for value in "${errorHistory[@]}"; do # errReset=$(( errReset + ( value*BUFFER_TTL_NS ) )); # done; - errReset="$(( (errReset + (errNS*BUFFER_TTL_NS)) ))" && vbm "errReset:$errReset"; + vbm "errReset(orig):$errReset" + errReset="$(( (errReset + (errNS*BUFFER_TTL_NS)) ))" && vbm "errReset(post):$errReset"; # errResetx10e3="$(( ( errResetx10e3 + ( errNSx10e3 * BUFFER_TTL_NS ) )*10**3 ))" && vbm "errResetx10e3:$errResetx10e3"; # Calculate errRate in nanoseconds per nanosecond errRate="$(( errNS / BUFFER_TTL_NS ))" && vbm "errRate:$errRate"; # errRatex10e3="$(( ( errNSx10e3 ) / BUFFER_TTL_NS ))" && vbm "errRatex10e3:$errRatex10e3"; + + # Debug + vbm "errNS :$errNS"; + vbm "errResetTerm:$((errReset/T_I))"; + vbm "errRateTerm :$((errRate*T_D))"; # Calculate PID control signal ## ADJ = K_P * (errNS + errReset/T_I + errRate*T_D)