ec
Fork of EC by
Diff: SpeedController.cpp
- Revision:
- 17:e0b465d9b579
- Parent:
- 16:14d05ae8d566
- Child:
- 18:31058ca8fc8a
diff -r 14d05ae8d566 -r e0b465d9b579 SpeedController.cpp --- a/SpeedController.cpp Mon Apr 10 10:14:38 2017 +0000 +++ b/SpeedController.cpp Tue Apr 11 07:51:08 2017 +0000 @@ -21,7 +21,7 @@ diff_old=diff; if(out_duty>0.1)out_duty=0.1; if(out_duty<-0.1)out_duty=-0.1; - out+=out_duty; + if((duty>0)&&(duty<0.95)) out+=out_duty; duty=0.0001*out+target_omega/C; if(duty<-0.95)duty=-0.95; else if(duty>0.95)duty=0.95; @@ -113,7 +113,7 @@ diff_old=diff; if(out_duty>0.01)out_duty=0.01; if(out_duty<-0.01)out_duty=-0.01; - out+=out_duty; + if((duty>0)&&(duty<0.95)) out+=out_duty; duty=0.0001*out/*+target_RPM/C*/; turnF(duty); } @@ -128,7 +128,7 @@ diff_old=diff; if(out_duty>0.001)out_duty=0.001; if(out_duty<-0.001)out_duty=-0.001; - out+=out_duty; + if((duty>0)&&(duty<0.95)) out+=out_duty; duty=0.001*out; turnF(duty); }