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: RTOS-Threads/src/Task4.cpp
- Revision:
- 32:7a9be7761c46
- Parent:
- 31:3dde2201e54d
- Child:
- 33:f88a6ee18103
--- a/RTOS-Threads/src/Task4.cpp Mon May 12 05:12:19 2014 +0000
+++ b/RTOS-Threads/src/Task4.cpp Mon May 12 13:20:06 2014 +0000
@@ -25,15 +25,17 @@
if (calibration_mode) {
for (int i = 0; i < 4; i++)
ESC[i].pulsewidth_us(RCCommand[3]);
- } else if (RCCommand[3] > 1150) {
+ } else if (RCCommand[3] > 1100) {
if (counterESC) {
for (int i = 0; i < 3; i++)
adjust[i] /= 2.0;
- ESCpower[0] = constrainESC((RCCommand[3]) + (adjust[1]) + (adjust[2]) - adjust[0]);
- ESCpower[1] = constrainESC((RCCommand[3]) + (adjust[1]) - (adjust[2]) + adjust[0]);
- ESCpower[2] = constrainESC((RCCommand[3]) - (adjust[1]) - (adjust[2]) - adjust[0]);
- ESCpower[3] = constrainESC((RCCommand[3]) - (adjust[1]) + (adjust[2]) + adjust[0]);
+ int throttle = RCCommand[3] * 9/10;
+
+ ESCpower[0] = constrainESC(throttle + (adjust[1]) + (adjust[2]) - adjust[0]);
+ ESCpower[1] = constrainESC(throttle + (adjust[1]) - (adjust[2]) + adjust[0]);
+ ESCpower[2] = constrainESC(throttle - (adjust[1]) - (adjust[2]) - adjust[0]);
+ ESCpower[3] = constrainESC(throttle - (adjust[1]) + (adjust[2]) + adjust[0]);
for (int i = 0; i < 4; i++)
ESC[i].pulsewidth_us(ESCpower[i]);
@@ -41,7 +43,6 @@
counterESC = false;
} else {
stallESC++;
-
if (stallESC > 1) {
imu.debugSerial.printf("ESC NOT UPDATED FAST ENOUGH!\n");
stallESC = 0;
@@ -60,21 +61,20 @@
}
for (int i = 0; i < 4; i++) {
- ESCpower[i] = 980;
+ ESCpower[i] = 990;
ESC[i].pulsewidth_us(ESCpower[i]);
}
}
//if (ESC_check)
- // BT.printf("%4d %4d %4d %4d\n", ESCpower[0], ESCpower[1], ESCpower[2], ESCpower[3]);
-
+ //BT.printf("%4d %4d %4d %4d\n", ESCpower[0], ESCpower[1], ESCpower[2], ESCpower[3]);
//Timer
}
int constrainESC(float input)
{
- if (input < 1150.0)
- return 1150;
+ if (input < 1100.0)
+ return 1100;
else if (input > 2000.0)
return 2000;
else