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.
Dependencies: EMG1 PIDController1 compute mbed InBetweenController PinDetect QEI
Diff: main.cpp
- Revision:
- 10:3cee5adfbd72
- Parent:
- 9:70cab4bf38a5
- Child:
- 11:46a859e526ca
diff -r 70cab4bf38a5 -r 3cee5adfbd72 main.cpp
--- a/main.cpp Mon Oct 26 12:14:22 2015 +0000
+++ b/main.cpp Tue Oct 27 11:43:55 2015 +0000
@@ -16,6 +16,7 @@
bool go_motor = true;
bool go_tick = false;
bool go_sample = false;
+double motorSpeed = 0.05;
double emg_out0, emg_out1, emg_out2;
@@ -36,6 +37,14 @@
// Calculate the new position using the EMG output and the current position
newPos(emg_out0, emg_out1, 0, a, b, x, y);
pc2.printf("O0: %f | O1: %f | O2: %f\r\n",emg_out0, emg_out1, emg_out2);
+
+ Angles2Point(x,y,a,b);
+
+ if(a < -20 || a > 20)
+ motorSpeed = 0.03;
+ else
+ motorSpeed = 0.05;
+
// Rotate the motors
rotate(x,y);
}
@@ -64,7 +73,7 @@
void calibrate()
{
sample_timer.attach(&goSample, 0.002);
- calc_timer.attach(&goTick, 0.5);
+ calc_timer.attach(&goTick, 0.15);
}
/* Initialize the buttons */
@@ -108,7 +117,7 @@
// The motor timer
if(go_motor) {
go_motor = false;
- moveTick();
+ moveTick(motorSpeed);
}
// The sample timer
if(go_sample) {