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.
Revision 2:61ad38ea550d, committed 2018-07-09
- Comitter:
- Anaesthetix
- Date:
- Mon Jul 09 19:18:20 2018 +0000
- Parent:
- 1:53628713ede9
- Child:
- 3:a49ab9168fb2
- Commit message:
- Minor changes
Changed in this revision
| calccomp.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/calccomp.h Mon Jul 09 16:37:24 2018 +0000
+++ b/calccomp.h Mon Jul 09 19:18:20 2018 +0000
@@ -28,11 +28,7 @@
static bool armed = false;
float xcntrl = 0;
float ycntrl = 0;
-
-// float KPx, KDx, KPy, KDy;
-// static float KIx = 0;
-// static float KIy = 0;
-
+
//Scale rx channels
rud = (((float)(ctrl[0] - ruddercenter))/2.5);
ycntrl = ((float)(ctrl[3] - elevcenter))/8;
@@ -49,12 +45,12 @@
m4 = throttle;
/*
// Calc PID values and prevent integral windup on KIx
- KPx = (angles[0] + xcntrl) * 1.05f;
- KIx = KIx + ((angles[0] + xcntrl) * 0.001f);
+ KPx = (angles[0] + xcntrl) * Kp;
+ KIx = KIx + ((angles[0] + xcntrl) * Kd);
if(KIx > 30) KIx = 30;
if(KIx < -30) KIx = -30;
- KDx = (angles[3] + (angles[0] + xcntrl)*0.8f) * 0.45f;
+ KDx = (angles[3] + (angles[0] + xcntrl)) Kd;
xcomp = KPx + KIx + KDx;
xcomp2 = xcomp*-1;
@@ -71,12 +67,12 @@
m4 = m4 - xcomp2;
/*
// Calc PID values and prevent integral windup on KIx
- KPy = (angles[1] + ycntrl) * 1.05f;
- KIy = KIx + ((angles[1] + ycntrl) * 0.001f);
+ KPy = (angles[1] + ycntrl) * Kd;
+ KIy = KIx + ((angles[1] + ycntrl) * Ki);
if(KIy > 30) KIy = 30;
if(KIy < -30) KIy = -30;
- KDx = (angles[4] + (angles[1] + ycntrl)*0.8f) * 0.45f;
+ KDx = (angles[4] + (angles[1] + ycntrl)) * Kd;
ycomp = KPy + KIy + KDy;
*/
@@ -136,4 +132,3 @@
motor[2] = m3;
motor[3] = m4;
}
-