småfixes, kanske inte längre blir 0?

This commit is contained in:
Thefeli73 2021-05-12 19:18:04 +02:00
parent 487837cffa
commit b4cc590cc0

View File

@ -23,7 +23,7 @@ float motorAngularSpeed = 0;
/** PWM signal applied to the motor's driver 255 is 100% */ /** PWM signal applied to the motor's driver 255 is 100% */
int speed; int speed;
int Va; float Va;
int safe_angle; int safe_angle;
float force; float force;
int PWM; int PWM;
@ -187,7 +187,12 @@ void setSpeed(){
else { else {
force = 0; 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); Va = abs(Va);
PWM = 255*Va/12; PWM = 255*Va/12;
PWM = constrain(PWM, 0, 255); PWM = constrain(PWM, 0, 255);