Rev 2473 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2473 | Rev 2528 | ||
---|---|---|---|
Line 105... | Line 105... | ||
105 | // determine sum of all present BL currents and setpoints |
105 | // determine sum of all present BL currents and setpoints |
106 | Current = 0; |
106 | Current = 0; |
107 | SetSum = 0; |
107 | SetSum = 0; |
108 | NumOfMotors = 0; |
108 | NumOfMotors = 0; |
109 | MinOfMaxPWM = 255; |
109 | MinOfMaxPWM = 255; |
110 | if(Capacity.MinOfMaxPWM == 254) FC_StatusFlags3 |= FC_STATUS3_REDUNDANCE; |
110 | if(Capacity.MinOfMaxPWM == 254) FC_StatusFlags3 |= FC_STATUS3_REDUNDANCE_AKTIVE; |
111 | else if(Capacity.MinOfMaxPWM == 255) FC_StatusFlags3 &= ~FC_STATUS3_REDUNDANCE; |
111 | // else if(Capacity.MinOfMaxPWM == 255) FC_StatusFlags3 &= ~FC_STATUS3_REDUNDANCE_AKTIVE; |
Line 112... | Line 112... | ||
112 | 112 | ||
113 | for(i = 0; i < MAX_MOTORS; i++) |
113 | for(i = 0; i < MAX_MOTORS; i++) |
114 | { |
114 | { |
115 | if(Motor[i].State & MOTOR_STATE_PRESENT_MASK/* && Mixer.Motor[i][MIX_GAS]*/) |
115 | if(Motor[i].State & MOTOR_STATE_PRESENT_MASK/* && Mixer.Motor[i][MIX_GAS]*/) |
Line 119... | Line 119... | ||
119 | { |
119 | { |
120 | Current += BL3_Current(i); // extended Current measurement -> 200 = 20A 201 = 21A 255 = 75A (20+55) |
120 | Current += BL3_Current(i); // extended Current measurement -> 200 = 20A 201 = 21A 255 = 75A (20+55) |
121 | } |
121 | } |
122 | else Current += (unsigned int)(Motor[i].Current); |
122 | else Current += (unsigned int)(Motor[i].Current); |
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 FC_StatusFlags3 &= ~FC_STATUS3_REDUNDANCE; |
124 | if(Motor[i].MaxPWM <= MinOfMaxPWM) MinOfMaxPWM = Motor[i].MaxPWM; |
- | 125 | else |
|
- | 126 | if(Motor[i].MaxPWM == 255) FC_StatusFlags3 &= ~FC_STATUS3_REDUNDANCE_AKTIVE; |
|
125 | } |
127 | } |
126 | } |
128 | } |
127 | Capacity.MinOfMaxPWM = MinOfMaxPWM; |
129 | Capacity.MinOfMaxPWM = MinOfMaxPWM; |
128 | if(SetSum == 0) // if all setpoints are 0 |
130 | if(SetSum == 0) // if all setpoints are 0 |
129 | { // determine offsets of motor currents |
131 | { // determine offsets of motor currents |
Line 131... | Line 133... | ||
131 | CurrentOffset = (unsigned int)(SumCurrentOffset>>CURRENT_AVERAGE); |
133 | CurrentOffset = (unsigned int)(SumCurrentOffset>>CURRENT_AVERAGE); |
132 | SumCurrentOffset -= CurrentOffset; |
134 | SumCurrentOffset -= CurrentOffset; |
133 | SumCurrentOffset += Current; |
135 | SumCurrentOffset += Current; |
134 | // after averaging set current to static offset |
136 | // after averaging set current to static offset |
135 | Current = FC_OFFSET_CURRENT; |
137 | Current = FC_OFFSET_CURRENT; |
- | 138 | FC_StatusFlags3 &= ~FC_STATUS3_REDUNDANCE_AKTIVE; |
|
136 | } |
139 | } |
137 | else // some motors are running, includes also motor test condition, where "MotorRunning" is false |
140 | else // some motors are running, includes also motor test condition, where "MotorRunning" is false |
138 | { // subtract offset |
141 | { // subtract offset |
139 | if(Current > CurrentOffset) Current -= CurrentOffset; |
142 | if(Current > CurrentOffset) Current -= CurrentOffset; |
140 | else Current = 0; |
143 | else Current = 0; |