Rev 1652 | Rev 1657 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1652 | Rev 1654 | ||
---|---|---|---|
Line 77... | Line 77... | ||
77 | } |
77 | } |
78 | DebugOut.Analog[19] = WinkelOut.CalcState; |
78 | DebugOut.Analog[19] = WinkelOut.CalcState; |
79 | } |
79 | } |
Line 80... | Line -... | ||
80 | - | ||
81 | 80 | ||
82 | 81 | ||
- | 82 | void LipoDetection(unsigned char print) |
|
83 | void LipoDetection(unsigned char print) |
83 | { |
84 | { |
84 | #define MAX_CELL_VOLTAGE 43 // max cell volatage for LiPO |
85 | unsigned int timer; |
85 | unsigned int timer, cells; |
86 | if(print) printf("\n\rBatt:"); |
86 | if(print) printf("\n\rBatt:"); |
87 | if(EE_Parameter.UnterspannungsWarnung < 50) // automatische Zellenerkennung |
87 | if(EE_Parameter.UnterspannungsWarnung < 50) // automatische Zellenerkennung |
88 | { |
88 | { |
89 | timer = SetDelay(500); |
89 | timer = SetDelay(500); |
90 | if(print) while (!CheckDelay(timer)); |
- | |
91 | if(UBat < 130) |
90 | if(print) while (!CheckDelay(timer)); |
92 | { |
- | |
93 | BattLowVoltageWarning = 3 * EE_Parameter.UnterspannungsWarnung; |
91 | // up to 6s LiPo |
94 | if(print) |
- | |
95 | { |
92 | for(cells = 1; cells < 7; cells++) |
96 | Piep(3,200); |
93 | { |
97 | printf(" 3 Cells "); |
- | |
98 | } |
- | |
99 | } |
94 | if(UBat < cells * MAX_CELL_VOLTAGE) break; |
100 | else |
95 | } |
101 | { |
96 | |
102 | BattLowVoltageWarning = 4 * EE_Parameter.UnterspannungsWarnung; |
97 | BattLowVoltageWarning = cells * EE_Parameter.UnterspannungsWarnung; |
103 | if(print) |
98 | if(print) |
104 | { |
99 | { |
105 | Piep(4,200); |
100 | Piep(cells, 200); |
106 | printf(" 4 Cells "); |
101 | printf(" %d Cells ", cells); |
107 | } |
- | |
108 | } |
102 | } |
109 | } |
- | |
110 | else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung; |
103 | } |
111 | // if(BattLowVoltageWarning < 93) BattLowVoltageWarning = 93; |
104 | else BattLowVoltageWarning = EE_Parameter.UnterspannungsWarnung; |
Line 112... | Line 105... | ||
112 | if(print) printf(" Low warning level: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10); |
105 | if(print) printf(" Low warning level: %d.%d",BattLowVoltageWarning/10,BattLowVoltageWarning%10); |
113 | } |
106 | } |
114 | 107 | ||
Line 167... | Line 160... | ||
167 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
160 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
168 | // + Check connected BL-Ctrls |
161 | // + Check connected BL-Ctrls |
169 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
162 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
170 | // Check connected BL-Ctrls |
163 | // Check connected BL-Ctrls |
171 | BLFlags |= BLFLAG_READ_VERSION; |
164 | BLFlags |= BLFLAG_READ_VERSION; |
172 | UpdateMotor = 0; |
- | |
173 | motorread = 0; |
165 | motorread = 0; // read the first I2C-Data |
174 | SendMotorData(); |
166 | SendMotorData(); |
175 | while(!UpdateMotor); |
167 | while(!(BLFlags & BLFLAG_TX_COMPLETE)); //wait for complete transfer |
- | 168 | ||
176 | printf("\n\rFound BL-Ctrl: "); |
169 | printf("\n\rFound BL-Ctrl: "); |
177 | timer = SetDelay(4000); |
170 | timer = SetDelay(4000); |
178 | for(i=0; i < MAX_MOTORS; i++) |
171 | for(i=0; i < MAX_MOTORS; i++) |
179 | { |
172 | { |
180 | UpdateMotor = 0; |
- | |
181 | SendMotorData(); |
173 | SendMotorData(); |
182 | while(!UpdateMotor); |
174 | while(!(BLFlags & BLFLAG_TX_COMPLETE)); //wait for complete transfer |
183 | if(Mixer.Motor[i][0] > 0) // wait max 4 sec for the BL-Ctrls to wake up |
175 | if(Mixer.Motor[i][0] > 0) // wait max 4 sec for the BL-Ctrls to wake up |
184 | { |
176 | { |
185 | while(!CheckDelay(timer) && !(Motor[i].State & MOTOR_STATE_PRESENT_MASK) ) |
177 | while(!CheckDelay(timer) && !(Motor[i].State & MOTOR_STATE_PRESENT_MASK) ) |
186 | { |
178 | { |
187 | UpdateMotor = 0; |
- | |
188 | SendMotorData(); |
179 | SendMotorData(); |
189 | while(!UpdateMotor); |
180 | while(!(BLFlags & BLFLAG_TX_COMPLETE)); //wait for complete transfer |
190 | } |
181 | } |
191 | } |
182 | } |
192 | if(Motor[i].State & MOTOR_STATE_PRESENT_MASK) |
183 | if(Motor[i].State & MOTOR_STATE_PRESENT_MASK) |
193 | { |
184 | { |
194 | printf("%d",i+1); |
185 | printf("%d",i+1); |
195 | // if(Motor[i].Version & MOTOR_STATE_NEW_PROTOCOL_MASK) printf("(new) "); |
186 | // if(Motor[i].Version & MOTOR_STATE_NEW_PROTOCOL_MASK) printf("(new) "); |
196 | // else printf(" "); |
- | |
197 | } |
187 | } |
198 | } |
188 | } |
199 | for(i=0; i < MAX_MOTORS; i++) |
189 | for(i=0; i < MAX_MOTORS; i++) |
200 | { |
190 | { |
201 | if(!(Motor[i].State & MOTOR_STATE_PRESENT_MASK) && Mixer.Motor[i][0] > 0) |
191 | if(!(Motor[i].State & MOTOR_STATE_PRESENT_MASK) && Mixer.Motor[i][0] > 0) |
Line 205... | Line 195... | ||
205 | } |
195 | } |
206 | Motor[i].State &= ~MOTOR_STATE_ERROR_MASK; // clear error counter |
196 | Motor[i].State &= ~MOTOR_STATE_ERROR_MASK; // clear error counter |
207 | } |
197 | } |
208 | printf("\n\r==================================="); |
198 | printf("\n\r==================================="); |
Line 209... | Line -... | ||
209 | - | ||
210 | I2C_SendBLConfig(); |
- | |
211 | 199 | ||
212 | //if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
200 | //if(EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG) |
213 | { |
201 | { |
214 | printf("\n\rCalibrating pressure sensor.."); |
202 | printf("\n\rCalibrating pressure sensor.."); |
215 | timer = SetDelay(1000); |
203 | timer = SetDelay(1000); |