Lines Matching +full:range +full:- +full:double
1 // SPDX-License-Identifier: GPL-2.0-or-later
29 * PID (Proportional-Integral-Derivative) controller is commonly used in
39 * y[k] = y[k-1] - kp*(x[k] - x[k-1]) + Ki*Ts*e[k] - Kd*(x[k]
40 * - 2*x[k-1]+x[k-2])/Ts
46 static double xk_1, xk_2; /* input temperature x[k-#] */
51 * 2. calculate PID based on Ziegler-Nichols rule
73 syslog(LOG_DEBUG, "TC inactive, relax p-state\n"); in controller_reset()
81 * y[k] = y[k-1] - kp*(x[k] - x[k-1]) + Ki*Ts*e[k] - Kd*(x[k]
82 * - 2*x[k-1]+x[k-2])/Ts
86 void controller_handler(const double xk, double *yk) in controller_handler()
88 double ek; in controller_handler()
89 double p_term, i_term, d_term; in controller_handler()
91 ek = p_param.t_target - xk; /* error */ in controller_handler()
100 p_term = -p_param.kp * (xk - xk_1); in controller_handler()
102 d_term = -p_param.kp * p_param.kd * (xk - 2 * xk_1 + xk_2) / p_param.ts; in controller_handler()
109 /* clamp output adjustment range */ in controller_handler()
110 if (*yk < -LIMIT_HIGH) in controller_handler()
111 *yk = -LIMIT_HIGH; in controller_handler()
112 else if (*yk > -LIMIT_LOW) in controller_handler()
113 *yk = -LIMIT_LOW; in controller_handler()