Rev 1812 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1812 | Rev 1813 | ||
---|---|---|---|
Line -... | Line 1... | ||
- | 1 | /****************************************************************************************************************** |
|
- | 2 | V0.82b-Arthur-P 2010-12-18 |
|
- | 3 | ------------------------------------------------------------------------------------------------------------------ |
|
- | 4 | Version includes only support for external HEF4017 for FC1.x hardware, NOT for Twi2Ppm converters for ESCs. |
|
- | 5 | ||
- | 6 | 2010-12-18 Transferred changes to v.0.82b-Arthur-P |
|
- | 7 | 20100917: Transferred changes to v0.80g-Arthur-P. |
|
- | 8 | Arthur P. Modified to use several parameters for servo control: |
|
- | 9 | User_Parameter4: |
|
- | 10 | User_Parameter5: |
|
- | 11 | User_Parameter6: |
|
- | 12 | User_Parameter7: |
|
- | 13 | User_Parameter8: Use external HEF4017 if bit 8 is set (>127). The remaining 7 bits are used |
|
- | 14 | for the shutter cycle counter: the value is multiplied by 5 programmatically, |
|
- | 15 | resulting in steps of approx. 0.1sec. Minimum value to start using the |
|
- | 16 | interval timer is 10 (approx. 1 sec, or countervalue of 50). Note that this |
|
- | 17 | was originally done through user para 6. |
|
- | 18 | ******************************************************************************************************************/ |
|
1 | #include "main.h" |
19 | #include "main.h" |
2 | #define MULTIPLYER 4 |
20 | #define MULTIPLYER 4 |
Line 3... | Line 21... | ||
3 | 21 | ||
4 | volatile unsigned int CountMilliseconds = 0; |
22 | volatile unsigned int CountMilliseconds = 0; |
Line 14... | Line 32... | ||
14 | unsigned int BeepMuster = 0xffff; |
32 | unsigned int BeepMuster = 0xffff; |
Line 15... | Line 33... | ||
15 | 33 | ||
16 | volatile int16_t ServoNickValue = 0; |
34 | volatile int16_t ServoNickValue = 0; |
Line -... | Line 35... | ||
- | 35 | volatile int16_t ServoRollValue = 0; |
|
- | 36 | ||
- | 37 | /****************************************************************************************************************** |
|
- | 38 | Arthur P: Added two variables for control of the shutter servo cycle. |
|
- | 39 | 091114 Inserted same changes into v.0.76g code. |
|
- | 40 | 091114 Inactivated the following two lines as the shutter interval funtion is not |
|
- | 41 | used at the moment. |
|
- | 42 | 20100804 Reactivated to be able to choose slower shutter rate than normal for |
|
- | 43 | Panasonic FX150 in continuous mode. |
|
- | 44 | ******************************************************************************************************************/ |
|
- | 45 | ||
- | 46 | volatile static unsigned int CameraShutterCycleCounter = 0; |
|
- | 47 | volatile static unsigned int CameraShutterCycle = 0; |
|
- | 48 | volatile static unsigned int CameraShutterCycleOnCount = 20; // Leave the shutter on for at least |
|
- | 49 | // 20 cycles or approx. 0.2 seconds. |
|
- | 50 | /****************************************************************************************************************** |
|
- | 51 | Arthur P: End of changes to variables section of timer0.c. |
|
Line 17... | Line 52... | ||
17 | volatile int16_t ServoRollValue = 0; |
52 | ******************************************************************************************************************/ |
18 | 53 | ||
19 | 54 | ||
20 | enum { |
55 | enum { |
Line 128... | Line 163... | ||
128 | // to control a camera servo for nick compensation. |
163 | // to control a camera servo for nick compensation. |
129 | void TIMER2_Init(void) |
164 | void TIMER2_Init(void) |
130 | { |
165 | { |
131 | uint8_t sreg = SREG; |
166 | uint8_t sreg = SREG; |
Line -... | Line 167... | ||
- | 167 | ||
- | 168 | /****************************************************************************************************************** |
|
- | 169 | Arthur P: Added initialization of the CameraShutterCycle value here as this routine is only |
|
- | 170 | called once. This retains all code changes in timer0.c. If (parameter 8 & 127) > 0 then the user |
|
- | 171 | has set a value for the cycle. CameraShuytterCycle == 5x (Para8 & 127) to get approx 0.1sec increments. |
|
- | 172 | 090807: Arthur P.: Removed the shutter cycle parts as they may be impacting timing loops. |
|
- | 173 | 20100804 Arthur P.: Reactivate shutter cycle counters. Modified to use the lower 7 bits of |
|
- | 174 | user parameter 8 (bit 8 is used for enabling the external HEF4017). |
|
- | 175 | CameraShutterCycle = Parameter_UserParam6; |
|
- | 176 | ******************************************************************************************************************/ |
|
- | 177 | ||
- | 178 | CameraShutterCycle = 5 * (Parameter_UserParam8 & 127); |
|
- | 179 | ||
- | 180 | /****************************************************************************************************************** |
|
- | 181 | Arthur P: End of changes to Timer2 function. |
|
- | 182 | ******************************************************************************************************************/ |
|
- | 183 | ||
132 | 184 | ||
133 | // disable all interrupts before reconfiguration |
185 | // disable all interrupts before reconfiguration |
Line 134... | Line 186... | ||
134 | cli(); |
186 | cli(); |
Line 269... | Line 321... | ||
269 | static uint8_t PulseOutput = 0; |
321 | static uint8_t PulseOutput = 0; |
270 | static uint16_t ServoFrameTime = 0; |
322 | static uint16_t ServoFrameTime = 0; |
271 | static uint8_t ServoIndex = 0; |
323 | static uint8_t ServoIndex = 0; |
Line -... | Line 324... | ||
- | 324 | ||
- | 325 | ||
- | 326 | /****************************************************************************************************************** |
|
- | 327 | Arthur P: Modified the code to check the value of parameter 8. If 128 or higher then a HEF4017 is |
|
- | 328 | expected and will be used. Else J7 and J9 are seen as separate normal outputs. |
|
- | 329 | if((PlatinenVersion < 20) |
|
- | 330 | 091114. Inserted same changes into v.0.76g code. |
|
- | 331 | 20100802 Inserted same changes into v.0.80d code. |
|
272 | 332 | ******************************************************************************************************************/ |
|
- | 333 | ||
- | 334 | // if(PlatinenVersion < 20) |
|
- | 335 | ||
- | 336 | if((PlatinenVersion < 20) && (Parameter_UserParam8 < 128 )) |
|
- | 337 | /****************************************************************************************************************** |
|
- | 338 | Arthur P: End of modification ot if statement. |
|
273 | 339 | ******************************************************************************************************************/ |
|
274 | if(PlatinenVersion < 20) |
340 | |
275 | { |
341 | { |
276 | //--------------------------- |
342 | //--------------------------- |
277 | // Nick servo state machine |
343 | // Nick servo state machine |
Line 325... | Line 391... | ||
325 | RemainingPulse += ServoNickValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
391 | RemainingPulse += ServoNickValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
326 | break; |
392 | break; |
327 | case 2: // Roll Compensation Servo |
393 | case 2: // Roll Compensation Servo |
328 | RemainingPulse += ServoRollValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
394 | RemainingPulse += ServoRollValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
329 | break; |
395 | break; |
- | 396 | /****************************************************************************************************************** |
|
- | 397 | Arthur P: Shutter Servo including interval control over parameter 5 and 6. |
|
- | 398 | 091114 Inserted same modification into v.0.76g code, removing previously REM-ed out modified parts. |
|
- | 399 | 20100802 Inserted same modification into v.0.76g code, removing previously REM-ed out modified parts. |
|
- | 400 | Modified to use lower 7 bits of user parameter 7. |
|
- | 401 | ******************************************************************************************************************/ |
|
330 | case 3: |
402 | case 3: |
331 | RemainingPulse += ((int16_t)Parameter_Servo3 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
403 | // RemainingPulse += ((int16_t)Parameter_Servo3 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
- | 404 | // break; |
|
- | 405 | ||
- | 406 | ||
- | 407 | if(PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] < -32) |
|
- | 408 | { |
|
- | 409 | // Set servo to null position, turning camera off. |
|
- | 410 | RemainingPulse = MINSERVOPULSE; |
|
- | 411 | } |
|
- | 412 | else |
|
- | 413 | { |
|
- | 414 | // 090807: Arthur P.: Removed the shutter cycle parts as they may be impacting timing loops. |
|
- | 415 | // 20100804 Reactived shutter interval timer capability. |
|
- | 416 | if(PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] > 32) |
|
- | 417 | // Top position on a 3 position switch which runs from -127 to +127 |
|
- | 418 | { |
|
- | 419 | ||
- | 420 | RemainingPulse = MINSERVOPULSE + SERVORANGE; |
|
- | 421 | } |
|
- | 422 | else |
|
- | 423 | { |
|
- | 424 | // Cycle shutter servo between 50% on and off depending upon CameraShutterCycleCounter |
|
- | 425 | // If CameraShutterCylce < 50 then default to continuous shoot. |
|
- | 426 | if(CameraShutterCycle < 50 ) // == 5x the minimum value of userpara8 lower 7 bits |
|
- | 427 | { |
|
- | 428 | RemainingPulse = MINSERVOPULSE + SERVORANGE/2; |
|
- | 429 | } |
|
- | 430 | else |
|
- | 431 | { |
|
- | 432 | if(CameraShutterCycleCounter == CameraShutterCycle) |
|
- | 433 | { |
|
- | 434 | // Shutter on |
|
- | 435 | CameraShutterCycleCounter = 0; |
|
- | 436 | RemainingPulse = MINSERVOPULSE + SERVORANGE/2; |
|
- | 437 | } |
|
- | 438 | else |
|
- | 439 | { |
|
- | 440 | // Leave on for at least 20 cycles or 0.2 seconds to allow |
|
- | 441 | // the camera to properly trigger, turn off if past 0.2 sec. |
|
- | 442 | // For now this is actually set via para5 to allow for a long enough |
|
- | 443 | // shutter pulse for different cameras. Once it is clear what value |
|
- | 444 | // works, this can be changed to a hardcoded value. |
|
- | 445 | CameraShutterCycleCounter++; |
|
- | 446 | if(CameraShutterCycleCounter == CameraShutterCycleOnCount) |
|
- | 447 | { |
|
- | 448 | // Shutter off |
|
- | 449 | RemainingPulse = MINSERVOPULSE; |
|
- | 450 | } |
|
- | 451 | } |
|
- | 452 | } |
|
- | 453 | } |
|
- | 454 | } |
|
332 | break; |
455 | break; |
- | 456 | /****************************************************************************************************************** |
|
- | 457 | Arthur P: End of modified shutter servo control (via HEF4017) and of modifications to timer0.c. |
|
- | 458 | ******************************************************************************************************************/ |
|
- | 459 | ||
333 | case 4: |
460 | case 4: |
334 | RemainingPulse += ((int16_t)Parameter_Servo4 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
461 | RemainingPulse += ((int16_t)Parameter_Servo4 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
335 | break; |
462 | break; |
336 | case 5: |
463 | case 5: |
337 | RemainingPulse += ((int16_t)Parameter_Servo5 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
464 | RemainingPulse += ((int16_t)Parameter_Servo5 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |