pidctrl Actually use the variables that we assign to as seatbelts to prevent divide
by zero Reviewed by: jeffr
This commit is contained in:
parent
c0874c3468
commit
ae6be8e6f7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=333823
@ -103,9 +103,9 @@ pidctrl_classic(struct pidctrl *pc, int input)
|
||||
pc->pc_derivative = error - pc->pc_olderror;
|
||||
|
||||
/* Divide by inverse gain values to produce output. */
|
||||
output = ((pc->pc_error / pc->pc_Kpd) +
|
||||
(pc->pc_integral / pc->pc_Kid)) +
|
||||
(pc->pc_derivative / pc->pc_Kdd);
|
||||
output = ((pc->pc_error / Kpd) +
|
||||
(pc->pc_integral / Kid)) +
|
||||
(pc->pc_derivative / Kdd);
|
||||
/* Save for sysctl. */
|
||||
pc->pc_output = output;
|
||||
pc->pc_input = input;
|
||||
@ -146,9 +146,9 @@ pidctrl_daemon(struct pidctrl *pc, int input)
|
||||
pc->pc_derivative = error - pc->pc_olderror;
|
||||
|
||||
/* Divide by inverse gain values to produce output. */
|
||||
output = ((error / pc->pc_Kpd) +
|
||||
(pc->pc_integral / pc->pc_Kid)) +
|
||||
(pc->pc_derivative / pc->pc_Kdd);
|
||||
output = ((error / Kpd) +
|
||||
(pc->pc_integral / Kid)) +
|
||||
(pc->pc_derivative / Kdd);
|
||||
output = MAX(output - pc->pc_output, 0);
|
||||
pc->pc_output += output;
|
||||
pc->pc_input = input;
|
||||
|
Loading…
Reference in New Issue
Block a user