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