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 1:fbed80ea9cf9, committed 2018-06-19
- Comitter:
- kavhirow
- Date:
- Tue Jun 19 07:34:39 2018 +0000
- Parent:
- 0:a3c0b8cd6c61
- Commit message:
- last ver
;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Jun 19 06:27:26 2018 +0000
+++ b/main.cpp Tue Jun 19 07:34:39 2018 +0000
@@ -9,8 +9,8 @@
// Feedback gains (Arbitrary Unit)
#define KP 1.0
#define KD 0.04
-#define KX 0.003
-#define KV 0.002
+#define KX -0.001
+#define KV -0.0007
// Define LEDs
@@ -56,7 +56,7 @@
float f_velocity_prev_prev = 0;
float omega_prev = 0;
float f_omega_prev = 0;
-
+float ref = 0;
// Interrupt handler (control loop)
void int0() {
@@ -124,11 +124,11 @@
f_velocity = 0.0002414*velocity + 0.0004827*velocity_prev + 0.0002414*velocity_prev_prev + 1.9556*f_velocity_prev - 0.9565*f_velocity_prev_prev;
//update value
+ velocity_prev_prev = velocity_prev;
velocity_prev = velocity;
- velocity_prev_prev = velocity_prev;
+ f_velocity_prev_prev = f_velocity_prev;
f_velocity_prev = f_velocity;
- f_velocity_prev_prev = f_velocity_prev;
count_prev = count;
value1_prev = value1;
@@ -136,7 +136,8 @@
// output
- v_out = angle * KP + f_omega * KD + count * KX + f_velocity * KV;
+ v_out = angle * KP + f_omega * KD + (count - ref) * KX + f_velocity * KV;
+ ref += 40.0 / 2000.0;
//v_out = count * KX + f_velocity * KV;
//v_out = angle * KP + f_omega * KD ;
if (v_out > 0) {