Rev 2380 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2380 | Rev 2384 | ||
---|---|---|---|
Line 62... | Line 62... | ||
62 | volatile unsigned char SendSPI = 0, ServoActive = 0, CalculateServoSignals = 1; |
62 | volatile unsigned char SendSPI = 0, ServoActive = 0, CalculateServoSignals = 1; |
63 | unsigned char JustMK3MagConnected = 0; |
63 | unsigned char JustMK3MagConnected = 0; |
64 | uint16_t RemainingPulse = 0; |
64 | uint16_t RemainingPulse = 0; |
65 | volatile int16_t ServoNickOffset = (255 / 2) * MULTIPLYER * 16; // initial value near center positon |
65 | volatile int16_t ServoNickOffset = (255 / 2) * MULTIPLYER * 16; // initial value near center positon |
66 | volatile int16_t ServoRollOffset = (255 / 2) * MULTIPLYER * 16; // initial value near center positon |
66 | volatile int16_t ServoRollOffset = (255 / 2) * MULTIPLYER * 16; // initial value near center positon |
- | 67 | volatile int16_t ServoPanOffset = (255 / 2) * MULTIPLYER * 16; // MartinR: für Pan-Funktion |
|
Line 67... | Line 68... | ||
67 | 68 | ||
68 | unsigned int BeepMuster = 0xffff; |
69 | unsigned int BeepMuster = 0xffff; |
Line 69... | Line 70... | ||
69 | signed int NickServoValue = 128 * MULTIPLYER * 16; |
70 | signed int NickServoValue = 128 * MULTIPLYER * 16; |
70 | 71 | ||
- | 72 | volatile int16_t ServoNickValue = 0; |
|
Line 71... | Line 73... | ||
71 | volatile int16_t ServoNickValue = 0; |
73 | volatile int16_t ServoRollValue = 0; |
72 | volatile int16_t ServoRollValue = 0; |
74 | volatile int16_t ServoPanValue = 0; // MartinR : für PAN-Funktion |
73 | 75 | ||
Line 262... | Line 264... | ||
262 | else NickServoValue = (int16_t)Parameter_ServoNickControl * (MULTIPLYER*16); // direct poti control |
264 | else NickServoValue = (int16_t)Parameter_ServoNickControl * (MULTIPLYER*16); // direct poti control |
263 | } |
265 | } |
Line 264... | Line 266... | ||
264 | 266 | ||
265 | void CalculateServo(void) |
267 | void CalculateServo(void) |
266 | { |
268 | { |
- | 269 | //signed char cosinus, sinus; // MartinR : so war es |
|
267 | signed char cosinus, sinus; |
270 | extern signed char cosinus, sinus; // MartinR : extern für PAN-Funktion |
Line -... | Line 271... | ||
- | 271 | signed long nick, roll; |
|
- | 272 | ||
- | 273 | nick = 0; // MartinR : StartWert bei abgeschalteten Nick/ Roll ausgleich |
|
- | 274 | roll = 0; // MartinR : StartWert bei abgeschalteten Nick/ Roll ausgleich |
|
- | 275 | int tmp; // MartinR : für PAN-Funktion // Wert : 0-24 -> 0-360 -> 15° steps |
|
- | 276 | /* // MartinR: bisher |
|
- | 277 | tmp = EE_Parameter.CamOrientation + ((Parameter_Servo4 - 125) * (Parameter_UserParam8 - 125)) / 400 ; //MartinR : für PAN-Funktion |
|
- | 278 | if (tmp < 0) tmp = 24- (abs(tmp)) % 24 ; // MartinR :Modulo 24 |
|
- | 279 | else tmp = tmp % 24 ; // MartinR :Modulo 24 |
|
- | 280 | */ |
|
- | 281 | tmp = EE_Parameter.CamOrientation + ((Parameter_Servo4 - 125) * (Parameter_UserParam8 - 125)) / 200 ; //MartinR : für PAN-Funktion |
|
- | 282 | if (tmp < 0) tmp = 48- (abs(tmp)) % 48 ; // MartinR :Modulo 48 |
|
268 | signed long nick, roll; |
283 | else tmp = tmp % 48 ; // MartinR :Modulo 48 |
269 | 284 | ||
- | 285 | // cosinus = sintab[EE_Parameter.CamOrientation + 6]; // MartinR : so war es |
|
- | 286 | // sinus = sintab[EE_Parameter.CamOrientation]; // MartinR : so war es |
|
- | 287 | //cosinus = sintab[tmp + 6]; // MartinR : für PAN-Funktion |
|
Line 270... | Line 288... | ||
270 | cosinus = sintab[EE_Parameter.CamOrientation + 6]; |
288 | cosinus += (2*sintab[tmp + 12]- cosinus + 1) / 2; // MartinR : für PAN-Funktion |
271 | sinus = sintab[EE_Parameter.CamOrientation]; |
289 | sinus += (2*sintab[tmp] - sinus + 1) / 2; // MartinR : für PAN-Funktion |
272 | 290 | ||
273 | if(CalculateServoSignals == 1) |
291 | if(CalculateServoSignals == 1) |
- | 292 | { |
|
274 | { |
293 | if(EE_Parameter.GlobalConfig3 & CFG3_SERVO_NICK_COMP_OFF) nick = 0; |
275 | if(EE_Parameter.GlobalConfig3 & CFG3_SERVO_NICK_COMP_OFF) nick = 0; |
294 | //else nick = (cosinus * IntegralNick) / 128L - (sinus * IntegralRoll) / 128L; // MartinR: so war es |
276 | else nick = (cosinus * IntegralNick) / 128L - (sinus * IntegralRoll) / 128L; |
295 | else nick = (cosinus * IntegralNick) / 512L - (sinus * IntegralRoll) / 512L; // MartinR: bessere Auflösung |
277 | nick -= POI_KameraNick * 7; |
296 | nick -= POI_KameraNick * 7; |
278 | nick = ((long)Parameter_ServoNickComp * nick) / 512L; |
297 | nick = ((long)Parameter_ServoNickComp * nick) / 512L; |
Line 302... | Line 321... | ||
302 | } |
321 | } |
303 | if(PlatinenVersion < 20) CalculateServoSignals = 0; else CalculateServoSignals++; |
322 | if(PlatinenVersion < 20) CalculateServoSignals = 0; else CalculateServoSignals++; |
304 | } |
323 | } |
305 | else |
324 | else |
306 | { |
325 | { |
- | 326 | if(EE_Parameter.GlobalConfig3 & CFG3_SERVO_NICK_COMP_OFF) roll = 0; |
|
307 | roll = (cosinus * IntegralRoll) / 128L + (sinus * IntegralNick) / 128L; |
327 | //roll = (cosinus * IntegralRoll) / 128L + (sinus * IntegralNick) / 128L; // MartinR: so war es |
- | 328 | else roll = (cosinus * IntegralRoll) / 512L + (sinus * IntegralNick) / 512L; // MartinR: bessere Auflösung |
|
308 | roll = ((long)Parameter_ServoRollComp * roll) / 512L; |
329 | roll = ((long)Parameter_ServoRollComp * roll) / 512L; |
309 | ServoRollOffset += ((int16_t)Parameter_ServoRollControl * (MULTIPLYER*16) - ServoRollOffset) / EE_Parameter.ServoManualControlSpeed; |
330 | ServoRollOffset += ((int16_t)Parameter_ServoRollControl * (MULTIPLYER*16) - ServoRollOffset) / EE_Parameter.ServoManualControlSpeed; |
310 | if(EE_Parameter.ServoCompInvert & SERVO_ROLL_INV) |
331 | if(EE_Parameter.ServoCompInvert & SERVO_ROLL_INV) |
311 | { // inverting movement of servo |
332 | { // inverting movement of servo |
312 | roll = ServoRollOffset / 16 + roll; |
333 | roll = ServoRollOffset / 16 + roll; |
Line 325... | Line 346... | ||
325 | else |
346 | else |
326 | if(ServoRollValue > ((int16_t)EE_Parameter.ServoRollMax * MULTIPLYER)) |
347 | if(ServoRollValue > ((int16_t)EE_Parameter.ServoRollMax * MULTIPLYER)) |
327 | { |
348 | { |
328 | ServoRollValue = (int16_t)EE_Parameter.ServoRollMax * MULTIPLYER; |
349 | ServoRollValue = (int16_t)EE_Parameter.ServoRollMax * MULTIPLYER; |
329 | } |
350 | } |
- | 351 | ||
- | 352 | // MartinR: Filterung der Pan- Funktion |
|
- | 353 | ServoPanOffset += ((int16_t)Parameter_Servo4 * (MULTIPLYER*16) - ServoPanOffset) / EE_Parameter.ServoManualControlSpeed; |
|
- | 354 | ServoPanValue = (int16_t)ServoPanOffset/16; // offset (Range from 0 to 255 * 3 = 765) |
|
- | 355 | ||
330 | CalculateServoSignals = 0; |
356 | CalculateServoSignals = 0; |
331 | } |
357 | } |
332 | } |
358 | } |
Line 333... | Line 359... | ||
333 | 359 | ||
Line 413... | Line 439... | ||
413 | break; |
439 | break; |
414 | case 3: |
440 | case 3: |
415 | RemainingPulse += ((int16_t)Parameter_Servo3 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
441 | RemainingPulse += ((int16_t)Parameter_Servo3 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
416 | break; |
442 | break; |
417 | case 4: |
443 | case 4: |
418 | RemainingPulse += ((int16_t)Parameter_Servo4 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
444 | //RemainingPulse += ((int16_t)Parameter_Servo4 * MULTIPLYER) - (256 / 2) * MULTIPLYER; // MartinR: so war es |
- | 445 | RemainingPulse += ServoPanValue - (256 / 2) * MULTIPLYER; // MartinR: zur Filterung der Pan-Funktion |
|
419 | break; |
446 | break; |
420 | case 5: |
447 | case 5: |
421 | RemainingPulse += ((int16_t)Parameter_Servo5 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
448 | RemainingPulse += ((int16_t)Parameter_Servo5 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
422 | break; |
449 | break; |
423 | default: // other servo channels |
450 | default: // other servo channels |