Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: PID_SC.cpp
- Revision:
- 37:c631d9b2206f
- Parent:
- 36:ce11c30e303c
- Child:
- 38:1e70e21c6ce4
--- a/PID_SC.cpp Fri Jun 14 09:56:32 2019 +0000
+++ b/PID_SC.cpp Wed Jun 26 03:42:35 2019 +0000
@@ -18,11 +18,11 @@
void SpeedControl::Sc(double target_omega){ //スカンジウムじゃないよ
if(duty==0&&target_omega!=0){
duty=target_omega/C;
- }
+ }else{
now_omega=omega;
now_time_=timer.read();
- diff= (target_omega-now_omega)/C;
- out_duty=Kv_p*diff+Kv_d*(diff-diff_old)/(now_time_-old_time_);
+ diff= (target_omega-now_omega)/20;
+ out_duty=Kv_p*diff-Kv_d*(diff-diff_old)/(now_time_-old_time_);
diff_old=diff;
if(out_duty>0.1)out_duty=0.1;
if(out_duty<-0.1)out_duty=-0.1;
@@ -31,7 +31,7 @@
if(duty<-0.95)duty=-0.95;
else if(duty>0.95)duty=0.95;
old_time_=now_time_;
-
+ }
if(duty*target_omega<0){
duty=0;
out_duty=0;