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.
Fork of PID by
Diff: main.cpp
- Revision:
- 5:97c1b79316c0
- Parent:
- 4:77e3082c7cf7
- Child:
- 6:cfd12ff3f3ab
--- a/main.cpp Tue Jul 24 12:11:43 2018 +0000
+++ b/main.cpp Wed Jul 25 04:04:15 2018 +0000
@@ -1,10 +1,10 @@
#include "mbed.h"
#include "EC.h"
-#define K 0.01 //評価をはじめる最小のK値
+#define K 0.2 //評価をはじめる最小のK値
#define stride 0.01 //K値を上げるときのきざみ幅
-#define duty_max 0.3 //出力duty比の上限
-#define evaluation_count 40 //定常振動しているとみなす振動回数
-#define evaluation_time 3 //評価時間
+#define duty_max 0.8 //出力duty比の上限
+#define evaluation_count 80 //定常振動しているとみなす振動回数
+#define evaluation_time 4 //評価時間
Serial pc(USBTX,USBRX);
PwmOut motorF(PA_3); //モータードライバの接続ピン
@@ -49,11 +49,11 @@
int i,j;
pc.printf("AutoTuning...\r\n");
while(1) {
- //pc.printf("Kp = %f : ",K+j*stride);
+ pc.printf("Kp = %f : ",K+j*stride);
timer.reset();
i=0;
while(i<evaluation_count && timer.read()<evaluation_time) {
- if(omega_old == 0 && Ec1.getOmega() == 0) {}
+ if(omega_old == 0 && Ec1.getOmega() == 0) {/*timer.reset();*/}
else if(omega_old * Ec1.getOmega() <= 0) i++;
omega_old = Ec1.getOmega();
out((10*(j%2) - Ec1.getCount()*(-1)*30*5/6*3.14159265359/2048) * (K + j*stride));
