Rev 2346 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2346 | Rev 2360 | ||
---|---|---|---|
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 261... | Line 263... | ||
261 | else NickServoValue = (int16_t)Parameter_ServoNickControl * (MULTIPLYER*16); // direct poti control |
263 | else NickServoValue = (int16_t)Parameter_ServoNickControl * (MULTIPLYER*16); // direct poti control |
262 | } |
264 | } |
Line 263... | Line 265... | ||
263 | 265 | ||
264 | void CalculateServo(void) |
266 | void CalculateServo(void) |
265 | { |
267 | { |
- | 268 | //signed char cosinus, sinus; // MartinR : so war es |
|
266 | signed char cosinus, sinus; |
269 | extern signed char cosinus, sinus; // MartinR : extern für PAN-Funktion |
Line -... | Line 270... | ||
- | 270 | signed long nick, roll; |
|
- | 271 | ||
- | 272 | nick = 0; // MartinR : StartWert bei abgeschalteten Nick/ Roll ausgleich |
|
- | 273 | roll = 0; // MartinR : StartWert bei abgeschalteten Nick/ Roll ausgleich |
|
- | 274 | int tmp; // MartinR : für PAN-Funktion // Wert : 0-24 -> 0-360 -> 15° steps |
|
- | 275 | /* // MartinR: bisher |
|
- | 276 | tmp = EE_Parameter.CamOrientation + ((Parameter_Servo4 - 125) * (Parameter_UserParam8 - 125)) / 400 ; //MartinR : für PAN-Funktion |
|
- | 277 | if (tmp < 0) tmp = 24- (abs(tmp)) % 24 ; // MartinR :Modulo 24 |
|
- | 278 | else tmp = tmp % 24 ; // MartinR :Modulo 24 |
|
- | 279 | */ |
|
- | 280 | tmp = EE_Parameter.CamOrientation + ((Parameter_Servo4 - 125) * (Parameter_UserParam8 - 125)) / 200 ; //MartinR : für PAN-Funktion |
|
- | 281 | if (tmp < 0) tmp = 48- (abs(tmp)) % 48 ; // MartinR :Modulo 48 |
|
267 | signed long nick, roll; |
282 | else tmp = tmp % 48 ; // MartinR :Modulo 48 |
268 | 283 | ||
- | 284 | // cosinus = sintab[EE_Parameter.CamOrientation + 6]; // MartinR : so war es |
|
- | 285 | // sinus = sintab[EE_Parameter.CamOrientation]; // MartinR : so war es |
|
- | 286 | //cosinus = sintab[tmp + 6]; // MartinR : für PAN-Funktion |
|
Line 269... | Line 287... | ||
269 | cosinus = sintab[EE_Parameter.CamOrientation + 6]; |
287 | cosinus += (2*sintab[tmp + 12]- cosinus + 1) / 2; // MartinR : für PAN-Funktion |
270 | sinus = sintab[EE_Parameter.CamOrientation]; |
288 | sinus += (2*sintab[tmp] - sinus + 1) / 2; // MartinR : für PAN-Funktion |
- | 289 | ||
- | 290 | if(CalculateServoSignals == 1) |
|
271 | 291 | { |
|
- | 292 | if (Parameter_UserParam7 < 50) // MartinR: um per UserParameter den Nickausgleich abzuschalten |
|
272 | if(CalculateServoSignals == 1) |
293 | { |
- | 294 | //nick = (cosinus * IntegralNick) / 128L - (sinus * IntegralRoll) / 128L; // MartinR: so war es |
|
273 | { |
295 | nick = (cosinus * IntegralNick) / 512L - (sinus * IntegralRoll) / 512L; // MartinR: bessere Auflösung |
274 | nick = (cosinus * IntegralNick) / 128L - (sinus * IntegralRoll) / 128L; |
296 | nick -= POI_KameraNick * 7; |
275 | nick -= POI_KameraNick * 7; |
297 | } |
276 | nick = ((long)Parameter_ServoNickComp * nick) / 512L; |
298 | nick = ((long)Parameter_ServoNickComp * nick) / 512L; |
Line 300... | Line 322... | ||
300 | } |
322 | } |
301 | if(PlatinenVersion < 20) CalculateServoSignals = 0; else CalculateServoSignals++; |
323 | if(PlatinenVersion < 20) CalculateServoSignals = 0; else CalculateServoSignals++; |
302 | } |
324 | } |
303 | else |
325 | else |
304 | { |
326 | { |
- | 327 | if (Parameter_UserParam7 < 100) // MartinR: um per UserParameter den Nickausgleich abzuschalten |
|
- | 328 | { |
|
305 | roll = (cosinus * IntegralRoll) / 128L + (sinus * IntegralNick) / 128L; |
329 | //roll = (cosinus * IntegralRoll) / 128L + (sinus * IntegralNick) / 128L; // MartinR: so war es |
- | 330 | roll = (cosinus * IntegralRoll) / 512L + (sinus * IntegralNick) / 512L; // MartinR: bessere Auflösung |
|
- | 331 | } |
|
306 | roll = ((long)Parameter_ServoRollComp * roll) / 512L; |
332 | roll = ((long)Parameter_ServoRollComp * roll) / 512L; |
307 | ServoRollOffset += ((int16_t)Parameter_ServoRollControl * (MULTIPLYER*16) - ServoRollOffset) / EE_Parameter.ServoManualControlSpeed; |
333 | ServoRollOffset += ((int16_t)Parameter_ServoRollControl * (MULTIPLYER*16) - ServoRollOffset) / EE_Parameter.ServoManualControlSpeed; |
308 | if(EE_Parameter.ServoCompInvert & SERVO_ROLL_INV) |
334 | if(EE_Parameter.ServoCompInvert & SERVO_ROLL_INV) |
309 | { // inverting movement of servo |
335 | { // inverting movement of servo |
310 | roll = ServoRollOffset / 16 + roll; |
336 | roll = ServoRollOffset / 16 + roll; |
Line 323... | Line 349... | ||
323 | else |
349 | else |
324 | if(ServoRollValue > ((int16_t)EE_Parameter.ServoRollMax * MULTIPLYER)) |
350 | if(ServoRollValue > ((int16_t)EE_Parameter.ServoRollMax * MULTIPLYER)) |
325 | { |
351 | { |
326 | ServoRollValue = (int16_t)EE_Parameter.ServoRollMax * MULTIPLYER; |
352 | ServoRollValue = (int16_t)EE_Parameter.ServoRollMax * MULTIPLYER; |
327 | } |
353 | } |
- | 354 | ||
- | 355 | // MartinR: Filterung der Pan- Funktion |
|
- | 356 | ServoPanOffset += ((int16_t)Parameter_Servo4 * (MULTIPLYER*16) - ServoPanOffset) / EE_Parameter.ServoManualControlSpeed; |
|
- | 357 | ServoPanValue = (int16_t)ServoPanOffset/16; // offset (Range from 0 to 255 * 3 = 765) |
|
- | 358 | ||
328 | CalculateServoSignals = 0; |
359 | CalculateServoSignals = 0; |
329 | } |
360 | } |
330 | } |
361 | } |
Line 331... | Line 362... | ||
331 | 362 | ||
Line 411... | Line 442... | ||
411 | break; |
442 | break; |
412 | case 3: |
443 | case 3: |
413 | RemainingPulse += ((int16_t)Parameter_Servo3 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
444 | RemainingPulse += ((int16_t)Parameter_Servo3 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
414 | break; |
445 | break; |
415 | case 4: |
446 | case 4: |
416 | RemainingPulse += ((int16_t)Parameter_Servo4 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
447 | //RemainingPulse += ((int16_t)Parameter_Servo4 * MULTIPLYER) - (256 / 2) * MULTIPLYER; // MartinR: so war es |
- | 448 | RemainingPulse += ServoPanValue - (256 / 2) * MULTIPLYER; // MartinR: zur Filterung der Pan-Funktion |
|
417 | break; |
449 | break; |
418 | case 5: |
450 | case 5: |
419 | RemainingPulse += ((int16_t)Parameter_Servo5 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
451 | RemainingPulse += ((int16_t)Parameter_Servo5 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
420 | break; |
452 | break; |
421 | default: // other servo channels |
453 | default: // other servo channels |