From b4cc590cc0bbae83b82c30427b0c869ee04eed53 Mon Sep 17 00:00:00 2001 From: Thefeli73 Date: Wed, 12 May 2021 19:18:04 +0200 Subject: [PATCH] =?UTF-8?q?sm=C3=A5fixes,=20kanske=20inte=20l=C3=A4ngre=20?= =?UTF-8?q?blir=200=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EENX15_LQR/EENX15_LQR.ino | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/EENX15_LQR/EENX15_LQR.ino b/EENX15_LQR/EENX15_LQR.ino index b76c5cc..e1eb571 100644 --- a/EENX15_LQR/EENX15_LQR.ino +++ b/EENX15_LQR/EENX15_LQR.ino @@ -23,7 +23,7 @@ float motorAngularSpeed = 0; /** PWM signal applied to the motor's driver 255 is 100% */ int speed; -int Va; +float Va; int safe_angle; float force; int PWM; @@ -187,7 +187,12 @@ void setSpeed(){ else { force = 0; } - if(force!=0){Va = calc_speed(force, angle_speed_rs); } + if(force!=0){ + Va = calc_speed(force, angle_speed_rs); + } + else { + Va = 0; + } Va = abs(Va); PWM = 255*Va/12; PWM = constrain(PWM, 0, 255);