### 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
# 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)