X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/37bc30fd8a2e3e3ee3a1dadcfad6fecc9345a53c..b605b5b5c80a9daf90e92ed4be43501ff5951e8d:/unitproc/bktemp-updateLoopPI?ds=sidebyside diff --git a/unitproc/bktemp-updateLoopPI b/unitproc/bktemp-updateLoopPI index 2c345ab..9054b90 100644 --- a/unitproc/bktemp-updateLoopPI +++ b/unitproc/bktemp-updateLoopPI @@ -9,7 +9,7 @@ update_pi() { # process variable (PV). Uses proportional integral (PI) # control. # Usage: update_pi arg1 arg2 arg3 arg4 arg5 arg6 - # Version: 0.1.1 + # Version: 0.1.3 # Input: arg1: path_loop_name (control loop name path) # arg2: var_pv (process variable) # arg3: var_sp (set point) @@ -28,7 +28,7 @@ update_pi() { local var_sp var_pv var_cv; local tune_p tune_i; local term_p term_i; - local error sum; + local error sum sum_cand; local path_sum path_var_sp path_var_pv path_tune_p path_tune_i; path_loop_name="$1"; @@ -59,6 +59,7 @@ update_pi() { path_var_cv="$path_loop_name".cv + path_var_cv_bias="$path_loop_name".cv_bias var_cv_bias="$6"; path_sum="$path_loop_name".sum @@ -72,13 +73,19 @@ update_pi() { #yell "DEBUG:var_pv:$var_pv"; #yell "DEBUG:var_sp:$var_sp"; #yell "DEBUG:var_cv:$var_cv"; + #yell "DEBUG:var_cv_bias:$var_cv_bias"; #yell "DEBUG:tune_p:$tune_p"; #yell "DEBUG:tune_i:$tune_i"; error="$(try echo "$var_sp - $var_pv" | bc -l)"; #yell "DEBUG:error:$error"; - sum="$(try echo "$sum + $error" | bc -l)"; + sum_cand="$(try echo "$sum + $error" | bc -l)"; #yell "DEBUG:sum:$sum"; + if [[ "$(try echo "$sum_cand > 2 * $sum " | bc -l)" -eq 1 ]]; then + sum="$(try echo "$sum + l($error + 1)" | bc -l)"; # dampen integral sum spikes + else + sum="$sum_cand"; + fi; term_p="$(try echo "$tune_p * $error" | bc -l)"; #yell "DEBUG:term_p:$term_p"; term_i="$(try echo "$tune_i * $sum" | bc -l)"; @@ -93,6 +100,7 @@ update_pi() { echo "$tune_p" > "$path_tune_p"; echo "$tune_i" > "$path_tune_i"; echo "$var_cv" > "$path_var_cv"; + echo "$var_cv_bias" > "$path_var_cv_bias"; # Output control variable to stdout echo "$var_cv";