Quad X Type Multicopter

Dependencies:   IAP

Files at this revision

API Documentation at this revision

Comitter:
komaida424
Date:
Tue Apr 28 01:48:21 2015 +0000
Parent:
6:a50e6d3924f1
Child:
8:1db19b529b22
Commit message:
rev.3.11 bug fix

Changed in this revision

I2cPeripherals/I2cPeripherals.cpp Show annotated file Show diff for this revision Revisions of this file
config.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/I2cPeripherals/I2cPeripherals.cpp	Tue Feb 24 09:28:29 2015 +0000
+++ b/I2cPeripherals/I2cPeripherals.cpp	Tue Apr 28 01:48:21 2015 +0000
@@ -37,7 +37,7 @@
         _i2c.write(LCD_addr,tx,2);
         tx[1] = 0x5C | ((contrast >> 4) & 0x03);
         _i2c.write(LCD_addr,tx,2);
-        tx[1] = 0x6A;
+        tx[1] = 0x6C;
         _i2c.write(LCD_addr,tx,2);
         wait(0.3);
         tx[1] = 0x0C;
--- a/config.h	Tue Feb 24 09:28:29 2015 +0000
+++ b/config.h	Tue Apr 28 01:48:21 2015 +0000
@@ -3,7 +3,7 @@
 
 //#define SERIAL_LCD
 //#define SOFT_PWM
-//#define LPCXpresso
+#define LPCXpresso
 //#define LocalFileOut
 
 #define TX_TYPE 0               // 0:FM 1:IR
@@ -33,6 +33,7 @@
 #define _L3GD20   0x01
 #define TICK_TIME 0.05
 #define GYRO_ADJUST 2
+#define THR_MIDRANGE 80
 
 enum PlaneType{Quad_X=0,Quad_VP,Quad_3D,Delta,Delta_TW,AirPlane};
 enum JR{_THR=0,_AIL,_ELE,_RUD,_GYRO,_AUX1,_AUX2,_AUX3,_AUX4};       //JR 信号の順番
@@ -77,7 +78,7 @@
     float Thro_Limit_Rate;
 public:
     config() {
-        Revision = 3.10;
+        Revision = 3.11;
         Struct_Size = sizeof(config);
         Stick_Ref[0] = 1500;
         Stick_Ref[1] = 1500;
--- a/main.cpp	Tue Feb 24 09:28:29 2015 +0000
+++ b/main.cpp	Tue Apr 28 01:48:21 2015 +0000
@@ -533,7 +533,7 @@
 void PWM_Out(bool mode)
 {
     int reg[3];
-    int i;
+    int i,j,k;
     float gain;
 //    float cur_height;
     
@@ -563,9 +563,17 @@
             M5 = THR + conf.Throttl_Trim;
             break;
         case Quad_3D:
-            i = (int)throLimit.calc((float)THR);
-            if ( abs(i-conf.Reverse_Point) > 100 ) i = THR;
-            M1 = M2 = M3 = M4 = i + conf.Throttl_Trim;
+            j = THR + conf.Throttl_Trim;
+            if ( Stick[GAIN] < 0 )  {
+                k = THR - conf.Reverse_Point;
+                if ( abs(k) < THR_MIDRANGE )   { 
+                    if ( k > 0 ) j = conf.Reverse_Point + THR_MIDRANGE;
+                    else j = conf.Reverse_Point - THR_MIDRANGE;
+                }
+            }
+//           i = (int)throLimit.calc((float)THR);
+ //           if ( abs(i-conf.Reverse_Point) > 100 ) i = THR;
+            M1 = M2 = M3 = M4 = j;
             break;
         case Delta:
         case Delta_TW:
@@ -655,32 +663,28 @@
         M4 -= reg[YAW];
         break;
     }
-    int h = conf.Model_Type;
-    for ( int i=0; i<6; i++ ) {
+    j = conf.Model_Type;
+    for ( i=0; i<6; i++ ) {
         if ( M[i] > Pulse_Max )   M[i] = Pulse_Max; 
         if ( M[i] < Pulse_Min )   M[i] = Pulse_Min;
-        if ( Servo_idx[h][i] == 1 )
+        if ( Servo_idx[j][i] == 1 )
         {
             M[i] = conf.Stick_Ref[i] + ( ( M[i] - conf.Stick_Ref[i] ) * conf.Servo_Dir[i] );
         }
         else    {
-            if ( h == Quad_3D ) {
+            if ( j == Quad_3D ) {
                 if ( Stick[GAIN] > 0 )  {
                     if ( THR < conf.Reverse_Point ) 
                         M[i] = conf.Reverse_Point;
                 }
-                else    {
-                    if ( abs(THR - conf.Reverse_Point ) < 10 )
-                        M[i] = conf.Reverse_Point;
-                }            
             }
             else    {
- //               if ( Stick[COL] < Thro_Zero ) M[i] = conf.Stick_Ref[COL];
+                if ( Stick[COL] < Thro_Zero ) M[i] = conf.Stick_Ref[COL];
             }
         }
     }
     if ( mode ) {
-        h = conf.Stick_Ref[THR];
+//        h = conf.Stick_Ref[THR];
         for ( i=0;i<6;i++ ) {
 //           while ( !pwmpin[i] );
             if ( conf.PWM_Mode == 1 )