From 3b2d8c14c3c8c2bd76e89eb0f9fcde4d4829128e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Tue, 9 Jun 2020 23:01:04 +0200 Subject: [PATCH] Change division to multiplication in floating point operation --- stm-firmware/pid-controller.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stm-firmware/pid-controller.c b/stm-firmware/pid-controller.c index c73d591..583fdae 100644 --- a/stm-firmware/pid-controller.c +++ b/stm-firmware/pid-controller.c @@ -29,7 +29,7 @@ void pid_init(struct pid_controller *pid, float k_deriv, float k_int, float k_p, pid->k_p = k_p; pid->k_int = k_int; pid->k_deriv = k_deriv; - pid->k_int_t = pid->k_int * pid->sample_period / 2.0f; + pid->k_int_t = pid->k_int * pid->sample_period * 0.5f; pid->k_deriv_t = pid->k_deriv * 2.0f / pid->sample_period; pid->output_sat_max = output_sat_max; pid->output_sat_min = output_sat_min;