Subversion Repositories FlightCtrl

Rev

Rev 2418 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2418 Rev 2443
Line 56... Line 56...
56
#include "main.h"
56
#include "main.h"
57
#include "timer0.h"
57
#include "timer0.h"
58
#include "analog.h"
58
#include "analog.h"
Line 59... Line 59...
59
 
59
 
60
//#define CAPACITY_UPDATE_INTERVAL 10 // 10 ms
60
//#define CAPACITY_UPDATE_INTERVAL 10 // 10 ms
61
#define CAPACITY_UPDATE_INTERVAL 50 // 50 ms
61
#define CAPACITY_UPDATE_INTERVAL 50 // 50 ms  = 20Hz
62
#define FC_OFFSET_CURRENT 5  // calculate with a current of 0.5A
62
#define FC_OFFSET_CURRENT 5  // calculate with a current of 0.5A
Line 63... Line 63...
63
#define BL_OFFSET_CURRENT 2  // calculate with a current of 0.2A
63
#define BL_OFFSET_CURRENT 2  // calculate with a current of 0.2A
64
 
64
 
Line 123... Line 123...
123
                                SetSum +=  (unsigned int)(Motor[i].SetPoint);
123
                                SetSum +=  (unsigned int)(Motor[i].SetPoint);
124
                                if(Motor[i].MaxPWM <= MinOfMaxPWM) MinOfMaxPWM = Motor[i].MaxPWM; else RedundanceBlOperation = 0;
124
                                if(Motor[i].MaxPWM <= MinOfMaxPWM) MinOfMaxPWM = Motor[i].MaxPWM; else RedundanceBlOperation = 0;
125
                        }
125
                        }
126
                }
126
                }
127
                Capacity.MinOfMaxPWM = MinOfMaxPWM;
127
                Capacity.MinOfMaxPWM = MinOfMaxPWM;
128
 
-
 
129
                if(SetSum == 0) // if all setpoints are 0
128
                if(SetSum == 0) // if all setpoints are 0
130
                { // determine offsets of motor currents
129
                { // determine offsets of motor currents
131
                        #define CURRENT_AVERAGE 8  // 8bit = 256 * 10 ms = 2.56s average time
130
                        #define CURRENT_AVERAGE 8  // 8bit = 256 * 10 ms = 2.56s average time
132
                        CurrentOffset = (unsigned int)(SumCurrentOffset>>CURRENT_AVERAGE);
131
                        CurrentOffset = (unsigned int)(SumCurrentOffset>>CURRENT_AVERAGE);
133
                        SumCurrentOffset -= CurrentOffset;
132
                        SumCurrentOffset -= CurrentOffset;