Greg Abdo / Mbed 2 deprecated quadCommand

Dependencies:   mbed PID MMA8451Q

Files at this revision

API Documentation at this revision

Comitter:
oprospero
Date:
Sat Jul 20 02:28:04 2013 +0000
Parent:
58:9dfd9169a5e7
Commit message:
Increase motor control resolution

Changed in this revision

quadCommand/motor/motor.cpp Show annotated file Show diff for this revision Revisions of this file
quadCommand/quadCommand.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/quadCommand/motor/motor.cpp	Wed Jul 03 04:45:03 2013 +0000
+++ b/quadCommand/motor/motor.cpp	Sat Jul 20 02:28:04 2013 +0000
@@ -18,7 +18,7 @@
 {
     pwmPin = new PwmOut( pin );
     pwmPin->period( 0.020 );    // Set the period to 20ms.
-    setPulseMin( 0.001150 );    // Set default min pulse.
+    setPulseMin( 0.001000 );    // Set default min pulse.
     setPulseMax( 0.002 );       // Set default max pulse.
     setSpeed( 0 );              // Set motor to stopped.
 }
@@ -35,15 +35,15 @@
         currentSpeed = 0;
     
     // Is the value to large?
-    else if( value > 100 )      // Yup, just set to 100.
-        currentSpeed = 100;
+    else if( value > 500 )      // Yup, just set to 100. Changed to 500 to increase
+        currentSpeed = 500;     // motor control resolution
     
     // Value must be in the correct range.    
     else    
         currentSpeed = value;   // Set the new value.
 
     // Calculate the value based on pulseMin, pulseMax and currentSpeed.
-    pulse = ((pulseMax - pulseMin) / 100 * currentSpeed) + pulseMin;
+    pulse = ((pulseMax - pulseMin) / 500 * currentSpeed) + pulseMin;
     pwmPin->pulsewidth( pulse );   // Write the pulse to the pin.
 }
 
--- a/quadCommand/quadCommand.cpp	Wed Jul 03 04:45:03 2013 +0000
+++ b/quadCommand/quadCommand.cpp	Sat Jul 20 02:28:04 2013 +0000
@@ -102,7 +102,7 @@
     updateCurrent();
     float throttle, pitch, roll, yaw;   
         
-    throttle = targetThrottle;
+    throttle = targetThrottle * 5;  // Increased throttle Range to match higher resolution
     pitch = pidPitch->correct(currentPitch, targetPitch, MOTOR_UPDATE);
     roll = pidRoll->correct(currentRoll, targetRoll, MOTOR_UPDATE);
     yaw = pidYaw->correct(currentYaw, targetYaw, MOTOR_UPDATE);