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: main.cpp
- Revision:
- 24:487c898c8d71
- Parent:
- 21:dd4bbb617415
- Child:
- 25:0ee6b164f234
--- a/main.cpp Wed Mar 15 17:16:22 2017 +0000
+++ b/main.cpp Wed Mar 15 18:14:40 2017 +0000
@@ -5,9 +5,9 @@
#include "parser.h"
#include <cmath>
-#define kp 0.08f
+#define kp 0.1f
#define ki 0.0f //0.05f
-#define kd 0.0f //0.5f
+#define kd 0.20f //0.5f
#define dt 0.002f //given in ms, used to call the PID c.
volatile uint8_t state = 0;
@@ -31,7 +31,7 @@
Ticker controlTicker;
volatile float fi0 = 0; //number of revs done
-volatile int goalRevs = 400;
+volatile int goalRevs = 200;
volatile float fi = 2*3.1415*goalRevs;
volatile float goalW = 0; //desired angular velocity
volatile float accError = 0;
@@ -39,7 +39,7 @@
float getDuty(float w){
for (int i = 0; i < 28; i++) { //iterate through the angular velocities
- if (w > angularVelocities[i] && w <= angularVelocities[i+1]) {
+ if (w >= angularVelocities[i] && w <= angularVelocities[i+1]) {
if (w-angularVelocities[i] < angularVelocities[i+1]-w ) {
return dutyCycles[i];
}
