Rev 1708 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1708 | Rev 1734 | ||
---|---|---|---|
Line -... | Line 1... | ||
- | 1 | // Arthur P. Modified to use several parameters for servo control: |
|
- | 2 | // User_Parameter4: |
|
- | 3 | // User_Parameter5: |
|
- | 4 | // User_Parameter6: |
|
- | 5 | // User_Parameter7: |
|
- | 6 | // User_Parameter8: Use external HEF4017 if bit 8 is set (>127). The remaining 7 bits are used |
|
- | 7 | // for the shutter cycle counter: the value is multiplied by 5 programmatically, |
|
- | 8 | // resulting in steps of approx. 0.1sec. Minimum value to start using the |
|
- | 9 | // interval timer is 10 (approx. 1 sec, or countervalue of 50). Note that this |
|
- | 10 | // was originally done through user para 6. |
|
- | 11 | ||
- | 12 | ||
1 | #include "main.h" |
13 | #include "main.h" |
Line 2... | Line 14... | ||
2 | 14 | ||
3 | 15 | ||
Line 11... | Line 23... | ||
11 | unsigned int BeepMuster = 0xffff; |
23 | unsigned int BeepMuster = 0xffff; |
Line 12... | Line 24... | ||
12 | 24 | ||
13 | volatile int16_t ServoNickValue = 0; |
25 | volatile int16_t ServoNickValue = 0; |
Line -... | Line 26... | ||
- | 26 | volatile int16_t ServoRollValue = 0; |
|
- | 27 | ||
- | 28 | // Arthur P: Added two variables for control of the shutter servo cycle. |
|
- | 29 | // 091114 Inserted same changes into v.0.76g code. |
|
- | 30 | // 091114 Inactivated the following two lines as the shutter interval funtion is not |
|
- | 31 | // used at the moment. |
|
- | 32 | // 20100804 Reactivated to be able to choose slower shutter rate than normal for |
|
- | 33 | // Panasonic FX150 in continuous mode. |
|
- | 34 | volatile static unsigned int CameraShutterCycleCounter = 0; |
|
- | 35 | volatile static unsigned int CameraShutterCycle = 0; |
|
Line 14... | Line 36... | ||
14 | volatile int16_t ServoRollValue = 0; |
36 | volatile static unsigned int CameraShutterCycleOnCount = 25; // Leave the shutter on for at least |
15 | 37 | // 25 cycles or approx. 0.25 seconds. |
|
16 | 38 | ||
17 | enum { |
39 | enum { |
Line 125... | Line 147... | ||
125 | // to control a camera servo for nick compensation. |
147 | // to control a camera servo for nick compensation. |
126 | void TIMER2_Init(void) |
148 | void TIMER2_Init(void) |
127 | { |
149 | { |
128 | uint8_t sreg = SREG; |
150 | uint8_t sreg = SREG; |
Line -... | Line 151... | ||
- | 151 | ||
- | 152 | ||
- | 153 | // Arthur P: Added initialization of the CameraShutterCycle value here as this routine is only |
|
- | 154 | // called once. This retains all code changes in timer0.c. If parameter 6 > 0 then the user |
|
- | 155 | // has set a value for the cycle. CameraShuytterCycle == 5x Para6 to get approx 0.1sec increments. |
|
- | 156 | // 090807: Arthur P.: Removed the shutter cycle parts as they may be impacting timing loops. |
|
- | 157 | // 20100804 Arthur P.: Reactivate shutter cycle counters. Modified to use the lower 7 bits of |
|
- | 158 | // user parameter 7 (bit 8 is used for enabling the external HEF4017). |
|
- | 159 | // CameraShutterCycle = Parameter_UserParam6; |
|
- | 160 | CameraShutterCycle = 5 * (Parameter_UserParam8 & 127); |
|
129 | 161 | ||
130 | // disable all interrupts before reconfiguration |
162 | // disable all interrupts before reconfiguration |
Line 131... | Line 163... | ||
131 | cli(); |
163 | cli(); |
Line 208... | Line 240... | ||
208 | 240 | ||
209 | #define MULTIPLYER 4 |
241 | #define MULTIPLYER 4 |
210 | static int16_t ServoNickOffset = (255 / 2) * MULTIPLYER; // initial value near center positon |
242 | static int16_t ServoNickOffset = (255 / 2) * MULTIPLYER; // initial value near center positon |
Line -... | Line 243... | ||
- | 243 | static int16_t ServoRollOffset = (255 / 2) * MULTIPLYER; // initial value near center positon |
|
- | 244 | ||
- | 245 | ||
211 | static int16_t ServoRollOffset = (255 / 2) * MULTIPLYER; // initial value near center positon |
246 | // Arthur P: Modified the code to scheck the value of parameter 8. If 128 or higher then a HEF4017 is |
- | 247 | // expected and will be used. Else J7 and J9 are seen as separate normal outputs. |
|
- | 248 | // if((PlatinenVersion < 20) |
|
- | 249 | // 091114. Inserted same changes into v.0.76g code. |
|
- | 250 | // 20100802 Inserted same changes into v.0.80d code. |
|
212 | 251 | ||
213 | if(PlatinenVersion < 20) |
252 | if((PlatinenVersion < 20) && (Parameter_UserParam8 < 128 )) |
214 | { |
253 | { |
215 | //--------------------------- |
254 | //--------------------------- |
216 | // Nick servo state machine |
255 | // Nick servo state machine |
Line 331... | Line 370... | ||
331 | } |
370 | } |
332 | RemainingPulse += ServoRollValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
371 | RemainingPulse += ServoRollValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
333 | ServoRollValue /= MULTIPLYER; |
372 | ServoRollValue /= MULTIPLYER; |
334 | //DebugOut.Analog[20] = ServoRollValue; |
373 | //DebugOut.Analog[20] = ServoRollValue; |
335 | break; |
374 | break; |
- | 375 | ||
- | 376 | case 3: // Arthur P: Shutter Servo including interval control over parameter 5 and 6. |
|
- | 377 | // 091114 Inserted same modification into v.0.76g code, removing previously REM-ed out modified parts. |
|
- | 378 | // 20100802 Inserted same modification into v.0.76g code, removing previously REM-ed out modified parts. |
|
- | 379 | // Modified to use lower 7 bits of user parameter 7. |
|
- | 380 | // RemainingPulse += ((int16_t)Parameter_Servo3 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
|
- | 381 | // break; |
|
- | 382 | ||
- | 383 | ||
- | 384 | if(PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] < -32) |
|
- | 385 | { |
|
- | 386 | // Set servo to null position, turning camera off. |
|
- | 387 | RemainingPulse = MINSERVOPULSE; |
|
- | 388 | } |
|
- | 389 | else |
|
- | 390 | { |
|
- | 391 | // 090807: Arthur P.: Removed the shutter cycle parts as they may be impacting timing loops. |
|
- | 392 | // 20100804 Reactived shutter interval timer capability. |
|
- | 393 | if(PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] > 32) |
|
- | 394 | // Middle position on a 3 position switch which runs from -127 to +127 |
|
- | 395 | { |
|
- | 396 | ||
- | 397 | RemainingPulse = MINSERVOPULSE + SERVORANGE/2; |
|
- | 398 | } |
|
- | 399 | else |
|
- | 400 | { |
|
- | 401 | // Cycle shutter servo between on and off depending upon CameraShutterCycleCounter |
|
- | 402 | // If CameraShutterCylce < 50 then default to continuous shoot. |
|
- | 403 | if(CameraShutterCycle < 50 ) |
|
- | 404 | { |
|
- | 405 | RemainingPulse = MINSERVOPULSE + SERVORANGE/2; |
|
- | 406 | } |
|
336 | case 3: |
407 | else |
- | 408 | { |
|
- | 409 | if(CameraShutterCycleCounter == CameraShutterCycle) |
|
- | 410 | { |
|
- | 411 | // Shutter on |
|
- | 412 | CameraShutterCycleCounter = 0; |
|
337 | RemainingPulse += ((int16_t)Parameter_Servo3 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
413 | RemainingPulse = MINSERVOPULSE + SERVORANGE/2; |
- | 414 | } |
|
- | 415 | else |
|
- | 416 | { |
|
- | 417 | // Leave on for at least 25 cycles or 0.25 seconds to allow |
|
- | 418 | // the camera to properly trigger, turn off if past 0.25 sec. |
|
- | 419 | // For now this is actually set via para5 to allow for a long enough |
|
- | 420 | // shutter pulse for different cameras. Once it is clear what value |
|
- | 421 | // works, this can be changed to a hardcoded value. |
|
- | 422 | CameraShutterCycleCounter++; |
|
- | 423 | if(CameraShutterCycleCounter == CameraShutterCycleOnCount) |
|
- | 424 | { |
|
- | 425 | // Shutter off |
|
- | 426 | RemainingPulse = MINSERVOPULSE; |
|
- | 427 | } |
|
- | 428 | } |
|
- | 429 | } |
|
- | 430 | } |
|
- | 431 | } |
|
338 | break; |
432 | break; |
339 | case 4: |
433 | case 4: |
340 | RemainingPulse += ((int16_t)Parameter_Servo4 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
434 | RemainingPulse += ((int16_t)Parameter_Servo4 * MULTIPLYER) - (256 / 2) * MULTIPLYER; |
341 | break; |
435 | break; |
342 | case 5: |
436 | case 5: |