190605
Dependencies: WS2812 RemoteIR PixelArray Adafruit_GFX
Revision 101:efa2315d0312, committed 2019-06-06
- Comitter:
- Jeonghoon
- Date:
- Thu Jun 06 11:16:43 2019 +0000
- Parent:
- 100:0e44e944a19f
- Child:
- 102:e846a127af54
- Commit message:
- 20190606 success
Changed in this revision
| RemoteIR.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/RemoteIR.lib Wed Jun 05 18:40:06 2019 +0000 +++ b/RemoteIR.lib Thu Jun 06 11:16:43 2019 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/teams/embedded1/code/RemoteIR/#2fafd2e7dea8 +https://os.mbed.com/teams/embedded1/code/RemoteIR/#b56a97811380
--- a/main.cpp Wed Jun 05 18:40:06 2019 +0000
+++ b/main.cpp Thu Jun 06 11:16:43 2019 +0000
@@ -12,6 +12,8 @@
I2C i2c(D14, D15); // D14, D15
Adafruit_SSD1306_I2c myOled(i2c, D9, 0x78, 64, 128); // D9, (D8: D/C - data/command change)
DigitalOut DataComm(D8);
+
+Serial blue(PA_11, PA_12, 9600);
Thread TR_thread;
Thread remote_thread;
@@ -104,8 +106,9 @@
motor.cal_stop = 0;
motor.kp = 10;
- motor.kd = 2;
- motor.max = 100;
+ motor.kd = 1;
+ motor.ki = 5000;
+ motor.max = 150;
DataComm = 0;
@@ -124,7 +127,7 @@
while(1){
myOled.clearDisplay();
//myOled.printf("%.3f, %.3f, %d\r", motor.Speed_L, motor.Speed_R, pos);
- myOled.printf("kp:%.2f, kd: %d\r", motor.kp, motor.kd);
+ myOled.printf("%.0f %.1f %d %d\r", motor.kp, motor.kd, motor.ki, motor.max);
myOled.display();
}
}
@@ -295,9 +298,9 @@
last_proportional = proportional;
- //int power_difference = proportional / 20 + integral / 10000 + derivative * 10;
+ int power_difference = proportional / motor.kp + integral / motor.ki + derivative * motor.kd;
//int power_difference = proportional / motor.kp;
- int power_difference = proportional/motor.kp + derivative * motor.kd;
+ //int power_difference = proportional/motor.kp + derivative * motor.kd;
const float std = 600.0;
if(power_difference > motor.max)
@@ -307,7 +310,7 @@
power_difference = -motor.max;
// bot position: right
- if(power_difference > 15){
+ if(power_difference > 15){ //0.1 + p_d/std
motor.speed_r((motor.max + power_difference)/std);
motor.speed_l((motor.max - power_difference)/std);
}