ec
Fork of EC by
Diff: SpeedController.cpp
- Revision:
- 4:1b333860dd41
- Parent:
- 2:a9216df32be6
- Child:
- 5:4abba4f54406
--- a/SpeedController.cpp Wed Oct 12 05:17:56 2016 +0000 +++ b/SpeedController.cpp Wed Nov 02 02:43:15 2016 +0000 @@ -22,8 +22,8 @@ if(out_duty<-0.1)out_duty=-0.1; out+=out_duty; duty=0.0001*out+target_omega/C; - if(duty<-0.5)duty=-0.5; - else if(duty>0.5)duty=0.5; + if(duty<-0.95)duty=-0.95; + else if(duty>0.95)duty=0.95; if(duty>=0){ pwm_F_=duty; @@ -53,11 +53,21 @@ } void SpeedControl::turnF(double duty){ - pwm_F_=duty; - pwm_B_=0; + if(duty>0.95) { + pwm_F_=0.95; + pwm_B_=0; + } else { + pwm_F_=duty; + pwm_B_=0; + } } void SpeedControl::turnB(double duty){ - pwm_F_=0; - pwm_B_=duty; + if(duty>0.95) { + pwm_F_=0; + pwm_B_=0.95; + } else { + pwm_F_=0; + pwm_B_=duty; + } } \ No newline at end of file