Rev 2050 | Rev 2389 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2050 | Rev 2386 | ||
---|---|---|---|
Line 55... | Line 55... | ||
55 | #include "twimaster.h" |
55 | #include "twimaster.h" |
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 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 62... | Line 63... | ||
62 | #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 |
63 | 64 | ||
Line 73... | Line 74... | ||
73 | Capacity.ActualPower = 0; |
74 | Capacity.ActualPower = 0; |
74 | Capacity.MinOfMaxPWM = 0; |
75 | Capacity.MinOfMaxPWM = 0; |
75 | update_timer = SetDelay(CAPACITY_UPDATE_INTERVAL); |
76 | update_timer = SetDelay(CAPACITY_UPDATE_INTERVAL); |
76 | } |
77 | } |
Line -... | Line 78... | ||
- | 78 | ||
- | 79 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
- | 80 | // + extended Current measurement -> 200 = 20A 201 = 21A 255 = 75A (20+55) |
|
- | 81 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
- | 82 | unsigned int BL3_Current(unsigned char who) // in 0,1A |
|
- | 83 | { |
|
- | 84 | if(Motor[who].Current <= 200) return(Motor[who].Current); |
|
- | 85 | else |
|
- | 86 | { |
|
- | 87 | if(Motor[who].Version & MOTOR_STATE_BL30) return(200 + 10 * ((unsigned int)Motor[who].Current-200)); |
|
- | 88 | else return(Motor[who].Current); |
|
- | 89 | } |
|
Line 77... | Line 90... | ||
77 | 90 | } |
|
78 | 91 | ||
79 | // called in main loop at a regular interval |
92 | // called in main loop at a regular interval |
80 | void Capacity_Update(void) |
93 | void Capacity_Update(void) |
Line 96... | Line 109... | ||
96 | for(i = 0; i < MAX_MOTORS; i++) |
109 | for(i = 0; i < MAX_MOTORS; i++) |
97 | { |
110 | { |
98 | if(Motor[i].State & MOTOR_STATE_PRESENT_MASK) |
111 | if(Motor[i].State & MOTOR_STATE_PRESENT_MASK) |
99 | { |
112 | { |
100 | NumOfMotors++; |
113 | NumOfMotors++; |
- | 114 | if(Motor[i].Current > 200) |
|
- | 115 | { |
|
- | 116 | Current += BL3_Current(i); // extended Current measurement -> 200 = 20A 201 = 21A 255 = 75A (20+55) |
|
- | 117 | } |
|
101 | Current += (unsigned int)(Motor[i].Current); |
118 | else Current += (unsigned int)(Motor[i].Current); |
102 | SetSum += (unsigned int)(Motor[i].SetPoint); |
119 | SetSum += (unsigned int)(Motor[i].SetPoint); |
103 | if(Motor[i].MaxPWM < MinOfMaxPWM) MinOfMaxPWM = Motor[i].MaxPWM; |
120 | if(Motor[i].MaxPWM < MinOfMaxPWM) MinOfMaxPWM = Motor[i].MaxPWM; |
104 | } |
121 | } |
105 | } |
122 | } |
106 | Capacity.MinOfMaxPWM = MinOfMaxPWM; |
123 | Capacity.MinOfMaxPWM = MinOfMaxPWM; |