Rev 1242 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1242 | Rev 1265 | ||
---|---|---|---|
1 | #include "main.h" |
1 | #include "main.h" |
2 | 2 | ||
3 | volatile unsigned int CountMilliseconds = 0; |
3 | volatile unsigned int CountMilliseconds = 0; |
4 | volatile static unsigned int tim_main; |
4 | volatile static unsigned int tim_main; |
5 | volatile unsigned char UpdateMotor = 0; |
5 | volatile unsigned char UpdateMotor = 0; |
6 | volatile unsigned int cntKompass = 0; |
6 | volatile unsigned int cntKompass = 0; |
7 | volatile unsigned int beeptime = 0; |
7 | volatile unsigned int beeptime = 0; |
8 | volatile unsigned char SendSPI = 0, ServoActive = 0; |
8 | volatile unsigned char SendSPI = 0, ServoActive = 0; |
9 | 9 | ||
10 | unsigned int BeepMuster = 0xffff; |
10 | unsigned int BeepMuster = 0xffff; |
11 | int ServoValue = 0; |
11 | int ServoValue = 0; |
12 | 12 | ||
13 | volatile int16_t ServoNickValue = 0; |
13 | volatile int16_t ServoNickValue = 0; |
14 | volatile int16_t ServoRollValue = 0; |
14 | volatile int16_t ServoRollValue = 0; |
15 | 15 | ||
16 | // Arthur P: Added two variables for control of the shutter servo cycle. |
16 | // Arthur P: Added two variables for control of the shutter servo cycle. |
17 | 17 | ||
18 | volatile static unsigned int CameraShutterCycleCounter = 0; |
18 | volatile static unsigned int CameraShutterCycleCounter = 0; |
19 | volatile static unsigned int CameraShutterCycle = 0; |
19 | volatile static unsigned int CameraShutterCycle = 0; |
20 | 20 | ||
21 | 21 | ||
22 | enum { |
22 | enum { |
23 | STOP = 0, |
23 | STOP = 0, |
24 | CK = 1, |
24 | CK = 1, |
25 | CK8 = 2, |
25 | CK8 = 2, |
26 | CK64 = 3, |
26 | CK64 = 3, |
27 | CK256 = 4, |
27 | CK256 = 4, |
28 | CK1024 = 5, |
28 | CK1024 = 5, |
29 | T0_FALLING_EDGE = 6, |
29 | T0_FALLING_EDGE = 6, |
30 | T0_RISING_EDGE = 7 |
30 | T0_RISING_EDGE = 7 |
31 | }; |
31 | }; |
32 | 32 | ||
33 | 33 | ||
34 | SIGNAL (SIG_OVERFLOW0) // 8kHz |
34 | SIGNAL (SIG_OVERFLOW0) // 8kHz |
35 | { |
35 | { |
36 | static unsigned char cnt_1ms = 1,cnt = 0; |
36 | static unsigned char cnt_1ms = 1,cnt = 0; |
37 | unsigned char pieper_ein = 0; |
37 | unsigned char pieper_ein = 0; |
38 | // TCNT0 -= 250;//TIMER_RELOAD_VALUE; |
38 | // TCNT0 -= 250;//TIMER_RELOAD_VALUE; |
39 | if(SendSPI) SendSPI--; |
39 | if(SendSPI) SendSPI--; |
40 | if(!cnt--) |
40 | if(!cnt--) |
41 | { |
41 | { |
42 | cnt = 9; |
42 | cnt = 9; |
43 | cnt_1ms++; |
43 | cnt_1ms++; |
44 | cnt_1ms %= 2; |
44 | cnt_1ms %= 2; |
45 | if(!cnt_1ms) UpdateMotor = 1; |
45 | if(!cnt_1ms) UpdateMotor = 1; |
46 | CountMilliseconds++; |
46 | CountMilliseconds++; |
47 | } |
47 | } |
48 | 48 | ||
49 | if(beeptime > 1) |
49 | if(beeptime > 1) |
50 | { |
50 | { |
51 | beeptime--; |
51 | beeptime--; |
52 | if(beeptime & BeepMuster) |
52 | if(beeptime & BeepMuster) |
53 | { |
53 | { |
54 | pieper_ein = 1; |
54 | pieper_ein = 1; |
55 | } |
55 | } |
56 | else pieper_ein = 0; |
56 | else pieper_ein = 0; |
57 | } |
57 | } |
58 | else |
58 | else |
59 | { |
59 | { |
60 | pieper_ein = 0; |
60 | pieper_ein = 0; |
61 | BeepMuster = 0xffff; |
61 | BeepMuster = 0xffff; |
62 | } |
62 | } |
63 | 63 | ||
64 | 64 | ||
65 | if(pieper_ein) |
65 | if(pieper_ein) |
66 | { |
66 | { |
67 | if(PlatinenVersion == 10) PORTD |= (1<<2); // Speaker an PORTD.2 |
67 | if(PlatinenVersion == 10) PORTD |= (1<<2); // Speaker an PORTD.2 |
68 | else PORTC |= (1<<7); // Speaker an PORTC.7 |
68 | else PORTC |= (1<<7); // Speaker an PORTC.7 |
69 | } |
69 | } |
70 | else |
70 | else |
71 | { |
71 | { |
72 | if(PlatinenVersion == 10) PORTD &= ~(1<<2); |
72 | if(PlatinenVersion == 10) PORTD &= ~(1<<2); |
73 | else PORTC &= ~(1<<7); |
73 | else PORTC &= ~(1<<7); |
74 | } |
74 | } |
75 | 75 | ||
76 | if(EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV) |
76 | if(EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV) |
77 | { |
77 | { |
78 | if(PINC & 0x10) |
78 | if(PINC & 0x10) |
79 | { |
79 | { |
80 | cntKompass++; |
80 | cntKompass++; |
81 | } |
81 | } |
82 | else |
82 | else |
83 | { |
83 | { |
84 | if((cntKompass) && (cntKompass < 362)) |
84 | if((cntKompass) && (cntKompass < 362)) |
85 | { |
85 | { |
86 | cntKompass += cntKompass / 41; |
86 | cntKompass += cntKompass / 41; |
87 | if(cntKompass > 10) KompassValue = cntKompass - 10; else KompassValue = 0; |
87 | if(cntKompass > 10) KompassValue = cntKompass - 10; else KompassValue = 0; |
88 | } |
88 | } |
89 | // if(cntKompass < 10) cntKompass = 10; |
89 | // if(cntKompass < 10) cntKompass = 10; |
90 | // KompassValue = (unsigned long)((unsigned long)(cntKompass-10)*720L + 1L) / 703L; |
90 | // KompassValue = (unsigned long)((unsigned long)(cntKompass-10)*720L + 1L) / 703L; |
91 | KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180; |
91 | KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180; |
92 | cntKompass = 0; |
92 | cntKompass = 0; |
93 | } |
93 | } |
94 | } |
94 | } |
95 | } |
95 | } |
96 | 96 | ||
97 | 97 | ||
98 | // ----------------------------------------------------------------------- |
98 | // ----------------------------------------------------------------------- |
99 | 99 | ||
100 | unsigned int SetDelay (unsigned int t) |
100 | unsigned int SetDelay (unsigned int t) |
101 | { |
101 | { |
102 | // TIMSK0 &= ~_BV(TOIE0); |
102 | // TIMSK0 &= ~_BV(TOIE0); |
103 | return(CountMilliseconds + t + 1); |
103 | return(CountMilliseconds + t + 1); |
104 | // TIMSK0 |= _BV(TOIE0); |
104 | // TIMSK0 |= _BV(TOIE0); |
105 | } |
105 | } |
106 | 106 | ||
107 | // ----------------------------------------------------------------------- |
107 | // ----------------------------------------------------------------------- |
108 | char CheckDelay(unsigned int t) |
108 | char CheckDelay(unsigned int t) |
109 | { |
109 | { |
110 | // TIMSK0 &= ~_BV(TOIE0); |
110 | // TIMSK0 &= ~_BV(TOIE0); |
111 | return(((t - CountMilliseconds) & 0x8000) >> 9); |
111 | return(((t - CountMilliseconds) & 0x8000) >> 9); |
112 | // TIMSK0 |= _BV(TOIE0); |
112 | // TIMSK0 |= _BV(TOIE0); |
113 | } |
113 | } |
114 | 114 | ||
115 | // ----------------------------------------------------------------------- |
115 | // ----------------------------------------------------------------------- |
116 | void Delay_ms(unsigned int w) |
116 | void Delay_ms(unsigned int w) |
117 | { |
117 | { |
118 | unsigned int akt; |
118 | unsigned int akt; |
119 | akt = SetDelay(w); |
119 | akt = SetDelay(w); |
120 | while (!CheckDelay(akt)); |
120 | while (!CheckDelay(akt)); |
121 | } |
121 | } |
122 | 122 | ||
123 | void Delay_ms_Mess(unsigned int w) |
123 | void Delay_ms_Mess(unsigned int w) |
124 | { |
124 | { |
125 | unsigned int akt; |
125 | unsigned int akt; |
126 | akt = SetDelay(w); |
126 | akt = SetDelay(w); |
127 | while (!CheckDelay(akt)) if(AdReady) {AdReady = 0; ANALOG_ON;} |
127 | while (!CheckDelay(akt)) if(AdReady) {AdReady = 0; ANALOG_ON;} |
128 | } |
128 | } |
129 | 129 | ||
130 | /*****************************************************/ |
130 | /*****************************************************/ |
131 | /* Initialize Timer 2 */ |
131 | /* Initialize Timer 2 */ |
132 | /*****************************************************/ |
132 | /*****************************************************/ |
133 | // The timer 2 is used to generate the PWM at PD7 (J7) |
133 | // The timer 2 is used to generate the PWM at PD7 (J7) |
134 | // to control a camera servo for nick compensation. |
134 | // to control a camera servo for nick compensation. |
135 | void TIMER2_Init(void) |
135 | void TIMER2_Init(void) |
136 | { |
136 | { |
137 | 137 | ||
138 | uint8_t sreg = SREG; |
138 | uint8_t sreg = SREG; |
139 | 139 | ||
140 | // disable all interrupts before reconfiguration |
140 | // disable all interrupts before reconfiguration |
141 | cli(); |
141 | cli(); |
142 | 142 | ||
143 | // set PD7 as output of the PWM for nick servo |
143 | // set PD7 as output of the PWM for nick servo |
144 | DDRD |= (1<<DDD7); |
144 | DDRD |= (1<<DDD7); |
145 | PORTD &= ~(1<<PORTD7); // set PD7 to low |
145 | PORTD &= ~(1<<PORTD7); // set PD7 to low |
146 | 146 | ||
147 | DDRC |= (1<<DDC6); // set PC6 as output (Reset for HEF4017) |
147 | DDRC |= (1<<DDC6); // set PC6 as output (Reset for HEF4017) |
148 | HEF4017R_ON; |
148 | HEF4017R_ON; |
149 | // Timer/Counter 2 Control Register A |
149 | // Timer/Counter 2 Control Register A |
150 | 150 | ||
151 | // Timer Mode is FastPWM with timer reload at OCR2A (Bits: WGM22 = 1, WGM21 = 1, WGM20 = 1) |
151 | // Timer Mode is FastPWM with timer reload at OCR2A (Bits: WGM22 = 1, WGM21 = 1, WGM20 = 1) |
152 | // PD7: Normal port operation, OC2A disconnected, (Bits: COM2A1 = 0, COM2A0 = 0) |
152 | // PD7: Normal port operation, OC2A disconnected, (Bits: COM2A1 = 0, COM2A0 = 0) |
153 | // PD6: Normal port operation, OC2B disconnected, (Bits: COM2B1 = 0, COM2B0 = 0) |
153 | // PD6: Normal port operation, OC2B disconnected, (Bits: COM2B1 = 0, COM2B0 = 0) |
154 | TCCR2A &= ~((1<<COM2A1)|(1<<COM2A0)|(1<<COM2B1)|(1<<COM2B0)); |
154 | TCCR2A &= ~((1<<COM2A1)|(1<<COM2A0)|(1<<COM2B1)|(1<<COM2B0)); |
155 | TCCR2A |= (1<<WGM21)|(1<<WGM20); |
155 | TCCR2A |= (1<<WGM21)|(1<<WGM20); |
156 | 156 | ||
157 | // Timer/Counter 2 Control Register B |
157 | // Timer/Counter 2 Control Register B |
158 | 158 | ||
159 | // Set clock divider for timer 2 to SYSKLOCK/32 = 20MHz / 32 = 625 kHz |
159 | // Set clock divider for timer 2 to SYSKLOCK/32 = 20MHz / 32 = 625 kHz |
160 | // The timer increments from 0x00 to 0xFF with an update rate of 625 kHz or 1.6 us |
160 | // The timer increments from 0x00 to 0xFF with an update rate of 625 kHz or 1.6 us |
161 | // hence the timer overflow interrupt frequency is 625 kHz / 256 = 2.44 kHz or 0.4096 ms |
161 | // hence the timer overflow interrupt frequency is 625 kHz / 256 = 2.44 kHz or 0.4096 ms |
162 | 162 | ||
163 | // divider 32 (Bits: CS022 = 0, CS21 = 1, CS20 = 1) |
163 | // divider 32 (Bits: CS022 = 0, CS21 = 1, CS20 = 1) |
164 | TCCR2B &= ~((1<<FOC2A)|(1<<FOC2B)|(1<<CS22)); |
164 | TCCR2B &= ~((1<<FOC2A)|(1<<FOC2B)|(1<<CS22)); |
165 | TCCR2B |= (1<<CS21)|(1<<CS20)|(1<<WGM22); |
165 | TCCR2B |= (1<<CS21)|(1<<CS20)|(1<<WGM22); |
166 | 166 | ||
167 | // Initialize the Timer/Counter 2 Register |
167 | // Initialize the Timer/Counter 2 Register |
168 | TCNT2 = 0; |
168 | TCNT2 = 0; |
169 | 169 | ||
170 | // Initialize the Output Compare Register A used for PWM generation on port PD7. |
170 | // Initialize the Output Compare Register A used for PWM generation on port PD7. |
171 | OCR2A = 255; |
171 | OCR2A = 255; |
172 | TCCR2A |= (1<<COM2A1); // set or clear at compare match depends on value of COM2A0 |
172 | TCCR2A |= (1<<COM2A1); // set or clear at compare match depends on value of COM2A0 |
173 | 173 | ||
174 | // Timer/Counter 2 Interrupt Mask Register |
174 | // Timer/Counter 2 Interrupt Mask Register |
175 | // Enable timer output compare match A Interrupt only |
175 | // Enable timer output compare match A Interrupt only |
176 | TIMSK2 &= ~((1<<OCIE2B)|(1<<TOIE2)); |
176 | TIMSK2 &= ~((1<<OCIE2B)|(1<<TOIE2)); |
177 | TIMSK2 |= (1<<OCIE2A); |
177 | TIMSK2 |= (1<<OCIE2A); |
178 | 178 | ||
179 | SREG = sreg; |
179 | SREG = sreg; |
180 | } |
180 | } |
181 | 181 | ||
182 | //---------------------------- |
182 | //---------------------------- |
183 | void Timer_Init(void) |
183 | void Timer_Init(void) |
184 | { |
184 | { |
185 | 185 | ||
186 | tim_main = SetDelay(10); |
186 | tim_main = SetDelay(10); |
187 | TCCR0B = CK8; |
187 | TCCR0B = CK8; |
188 | TCCR0A = (1<<COM0A1)|(1<<COM0B1)|3;//fast PWM |
188 | TCCR0A = (1<<COM0A1)|(1<<COM0B1)|3;//fast PWM |
189 | OCR0A = 0; |
189 | OCR0A = 0; |
190 | OCR0B = 120; |
190 | OCR0B = 120; |
191 | TCNT0 = (unsigned char)-TIMER_RELOAD_VALUE; // reload |
191 | TCNT0 = (unsigned char)-TIMER_RELOAD_VALUE; // reload |
192 | //OCR1 = 0x00; |
192 | //OCR1 = 0x00; |
193 | 193 | ||
194 | TIMSK0 |= _BV(TOIE0); |
194 | TIMSK0 |= _BV(TOIE0); |
195 | } |
195 | } |
196 | 196 | ||
197 | 197 | ||
198 | /*****************************************************/ |
198 | /*****************************************************/ |
199 | /* Control Servo Position */ |
199 | /* Control Servo Position */ |
200 | /*****************************************************/ |
200 | /*****************************************************/ |
201 | 201 | ||
202 | ISR(TIMER2_COMPA_vect) |
202 | ISR(TIMER2_COMPA_vect) |
203 | { |
203 | { |
204 | 204 | ||
205 | // frame len 22.5 ms = 14063 * 1.6 us |
205 | // frame len 22.5 ms = 14063 * 1.6 us |
206 | // stop pulse: 0.3 ms = 188 * 1.6 us |
206 | // stop pulse: 0.3 ms = 188 * 1.6 us |
207 | // min servo pulse: 0.6 ms = 375 * 1.6 us |
207 | // min servo pulse: 0.6 ms = 375 * 1.6 us |
208 | // max servo pulse: 2.4 ms = 1500 * 1.6 us |
208 | // max servo pulse: 2.4 ms = 1500 * 1.6 us |
209 | // resolution: 1500 - 375 = 1125 steps |
209 | // resolution: 1500 - 375 = 1125 steps |
210 | 210 | ||
211 | #define IRS_RUNTIME 127 |
211 | #define IRS_RUNTIME 127 |
212 | #define PPM_STOPPULSE 188 |
212 | #define PPM_STOPPULSE 188 |
213 | // #define PPM_FRAMELEN (14063 |
213 | // #define PPM_FRAMELEN (14063 |
214 | #define PPM_FRAMELEN (1757 * EE_Parameter.ServoNickRefresh) |
214 | #define PPM_FRAMELEN (1757 * EE_Parameter.ServoNickRefresh) |
215 | #define MINSERVOPULSE 375 |
215 | #define MINSERVOPULSE 375 |
216 | #define MAXSERVOPULSE 1500 |
216 | #define MAXSERVOPULSE 1500 |
217 | #define SERVORANGE (MAXSERVOPULSE - MINSERVOPULSE) |
217 | #define SERVORANGE (MAXSERVOPULSE - MINSERVOPULSE) |
218 | 218 | ||
219 | static uint8_t PulseOutput = 0; |
219 | static uint8_t PulseOutput = 0; |
220 | static uint16_t RemainingPulse = 0; |
220 | static uint16_t RemainingPulse = 0; |
221 | static uint16_t ServoFrameTime = 0; |
221 | static uint16_t ServoFrameTime = 0; |
222 | static uint8_t ServoIndex = 0; |
222 | static uint8_t ServoIndex = 0; |
223 | 223 | ||
224 | #define MULTIPLYER 4 |
224 | #define MULTIPLYER 4 |
225 | static int16_t ServoNickOffset = (255 / 2) * MULTIPLYER; // initial value near center positon |
225 | static int16_t ServoNickOffset = (255 / 2) * MULTIPLYER; // initial value near center positon |
226 | static int16_t ServoRollOffset = (255 / 2) * MULTIPLYER; // initial value near center positon |
226 | static int16_t ServoRollOffset = (255 / 2) * MULTIPLYER; // initial value near center positon |
227 | 227 | ||
228 | // Arthur P: Added initialization of the CameraShutterCycle value here as this routine is only |
228 | // Arthur P: Added initialization of the CameraShutterCycle value here as this routine is only |
229 | // called once. This retains all code changes in timer0.c. If parameter 6 > 0 then the user |
229 | // called once. This retains all code changes in timer0.c. If parameter 6 > 0 then the user |
230 | // has set a value for the cycle. CameraShuytterCycle == 5x Para6 to get approx 0.1sec increments. |
230 | // has set a value for the cycle. CameraShuytterCycle == 5x Para6 to get approx 0.1sec increments. |
231 | - | ||
- | 231 | // 090807: Arthur P.: Removed the shutter cycle parts as they may be impacting timing loops. |
|
232 | // CameraShutterCycle = 5 * Parameter_UserParam6; |
232 | // CameraShutterCycle = 5 * Parameter_UserParam6; |
233 | CameraShutterCycle = Parameter_UserParam6; |
233 | // CameraShutterCycle = Parameter_UserParam6; |
234 | 234 | ||
235 | // Arthur P: Modified the code to scheck the value of parameter 8. If 128 or higher then a HEF4017 is |
235 | // Arthur P: Modified the code to scheck the value of parameter 8. If 128 or higher then a HEF4017 is |
236 | // expected and will be used. Else J7 and J9 are seen as separate normal outputs. |
236 | // expected and will be used. Else J7 and J9 are seen as separate normal outputs. |
237 | // if((PlatinenVersion < 20) |
237 | // if((PlatinenVersion < 20) |
238 | 238 | ||
239 | if((PlatinenVersion < 20) && (Parameter_UserParam8 < 128 )) |
239 | if((PlatinenVersion < 20) && (Parameter_UserParam8 < 128 )) |
240 | { |
240 | { |
241 | //--------------------------- |
241 | //--------------------------- |
242 | // Nick servo state machine |
242 | // Nick servo state machine |
243 | //--------------------------- |
243 | //--------------------------- |
244 | if(!PulseOutput) // pulse output complete |
244 | if(!PulseOutput) // pulse output complete |
245 | { |
245 | { |
246 | if(TCCR2A & (1<<COM2A0)) // we had a low pulse |
246 | if(TCCR2A & (1<<COM2A0)) // we had a low pulse |
247 | { |
247 | { |
248 | TCCR2A &= ~(1<<COM2A0);// make a high pulse |
248 | TCCR2A &= ~(1<<COM2A0);// make a high pulse |
249 | RemainingPulse = MINSERVOPULSE + SERVORANGE/2; // center position ~ 1.5ms |
249 | RemainingPulse = MINSERVOPULSE + SERVORANGE/2; // center position ~ 1.5ms |
250 | 250 | ||
251 | ServoNickOffset = (ServoNickOffset * 3 + (int16_t)Parameter_ServoNickControl * MULTIPLYER) / 4; // lowpass offset |
251 | ServoNickOffset = (ServoNickOffset * 3 + (int16_t)Parameter_ServoNickControl * MULTIPLYER) / 4; // lowpass offset |
252 | ServoNickValue = ServoNickOffset; // offset (Range from 0 to 255 * 3 = 765) |
252 | ServoNickValue = ServoNickOffset; // offset (Range from 0 to 255 * 3 = 765) |
253 | if(EE_Parameter.ServoNickCompInvert & 0x01) |
253 | if(EE_Parameter.ServoNickCompInvert & 0x01) |
254 | { // inverting movement of servo |
254 | { // inverting movement of servo |
255 | ServoNickValue += (int16_t)( ( (int32_t)EE_Parameter.ServoNickComp * MULTIPLYER * (IntegralNick / 128L ) ) / (256L) ); |
255 | ServoNickValue += (int16_t)( ( (int32_t)EE_Parameter.ServoNickComp * MULTIPLYER * (IntegralNick / 128L ) ) / (256L) ); |
256 | } |
256 | } |
257 | else |
257 | else |
258 | { // non inverting movement of servo |
258 | { // non inverting movement of servo |
259 | ServoNickValue -= (int16_t)( ( (int32_t)EE_Parameter.ServoNickComp * MULTIPLYER * (IntegralNick / 128L ) ) / (256L) ); |
259 | ServoNickValue -= (int16_t)( ( (int32_t)EE_Parameter.ServoNickComp * MULTIPLYER * (IntegralNick / 128L ) ) / (256L) ); |
260 | } |
260 | } |
261 | // limit servo value to its parameter range definition |
261 | // limit servo value to its parameter range definition |
262 | if(ServoNickValue < ((int16_t)EE_Parameter.ServoNickMin * MULTIPLYER) ) |
262 | if(ServoNickValue < ((int16_t)EE_Parameter.ServoNickMin * MULTIPLYER) ) |
263 | { |
263 | { |
264 | ServoNickValue = (int16_t)EE_Parameter.ServoNickMin * MULTIPLYER; |
264 | ServoNickValue = (int16_t)EE_Parameter.ServoNickMin * MULTIPLYER; |
265 | } |
265 | } |
266 | else |
266 | else |
267 | if(ServoNickValue > ((int16_t)EE_Parameter.ServoNickMax * MULTIPLYER) ) |
267 | if(ServoNickValue > ((int16_t)EE_Parameter.ServoNickMax * MULTIPLYER) ) |
268 | { |
268 | { |
269 | ServoNickValue = (int16_t)EE_Parameter.ServoNickMax * MULTIPLYER; |
269 | ServoNickValue = (int16_t)EE_Parameter.ServoNickMax * MULTIPLYER; |
270 | } |
270 | } |
271 | 271 | ||
272 | RemainingPulse += ServoNickValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
272 | RemainingPulse += ServoNickValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
273 | 273 | ||
274 | ServoNickValue /= MULTIPLYER; |
274 | ServoNickValue /= MULTIPLYER; |
275 | DebugOut.Analog[20] = ServoNickValue; |
275 | DebugOut.Analog[20] = ServoNickValue; |
276 | 276 | ||
277 | // range servo pulse width |
277 | // range servo pulse width |
278 | if(RemainingPulse > MAXSERVOPULSE ) RemainingPulse = MAXSERVOPULSE; // upper servo pulse limit |
278 | if(RemainingPulse > MAXSERVOPULSE ) RemainingPulse = MAXSERVOPULSE; // upper servo pulse limit |
279 | else if(RemainingPulse < MINSERVOPULSE ) RemainingPulse = MINSERVOPULSE; // lower servo pulse limit |
279 | else if(RemainingPulse < MINSERVOPULSE ) RemainingPulse = MINSERVOPULSE; // lower servo pulse limit |
280 | // accumulate time for correct update rate |
280 | // accumulate time for correct update rate |
281 | ServoFrameTime = RemainingPulse; |
281 | ServoFrameTime = RemainingPulse; |
282 | } |
282 | } |
283 | else // we had a high pulse |
283 | else // we had a high pulse |
284 | { |
284 | { |
285 | TCCR2A |= (1<<COM2A0); // make a low pulse |
285 | TCCR2A |= (1<<COM2A0); // make a low pulse |
286 | RemainingPulse = PPM_FRAMELEN - ServoFrameTime; |
286 | RemainingPulse = PPM_FRAMELEN - ServoFrameTime; |
287 | } |
287 | } |
288 | // set pulse output active |
288 | // set pulse output active |
289 | PulseOutput = 1; |
289 | PulseOutput = 1; |
290 | } |
290 | } |
291 | } // EOF Nick servo state machine |
291 | } // EOF Nick servo state machine |
292 | else |
292 | else |
293 | { |
293 | { |
294 | //----------------------------------------------------- |
294 | //----------------------------------------------------- |
295 | // PPM state machine, onboard demultiplexed by HEF4017 |
295 | // PPM state machine, onboard demultiplexed by HEF4017 |
296 | //----------------------------------------------------- |
296 | //----------------------------------------------------- |
297 | if(!PulseOutput) // pulse output complete |
297 | if(!PulseOutput) // pulse output complete |
298 | { |
298 | { |
299 | if(TCCR2A & (1<<COM2A0)) // we had a low pulse |
299 | if(TCCR2A & (1<<COM2A0)) // we had a low pulse |
300 | { |
300 | { |
301 | TCCR2A &= ~(1<<COM2A0);// make a high pulse |
301 | TCCR2A &= ~(1<<COM2A0);// make a high pulse |
302 | 302 | ||
303 | if(ServoIndex == 0) // if we are at the sync gap |
303 | if(ServoIndex == 0) // if we are at the sync gap |
304 | { |
304 | { |
305 | RemainingPulse = PPM_FRAMELEN - ServoFrameTime; // generate sync gap by filling time to full frame time |
305 | RemainingPulse = PPM_FRAMELEN - ServoFrameTime; // generate sync gap by filling time to full frame time |
306 | ServoFrameTime = 0; // reset servo frame time |
306 | ServoFrameTime = 0; // reset servo frame time |
307 | HEF4017R_ON; // enable HEF4017 reset |
307 | HEF4017R_ON; // enable HEF4017 reset |
308 | } |
308 | } |
309 | else // servo channels |
309 | else // servo channels |
310 | { |
310 | { |
311 | RemainingPulse = MINSERVOPULSE + SERVORANGE/2; // center position ~ 1.5ms |
311 | RemainingPulse = MINSERVOPULSE + SERVORANGE/2; // center position ~ 1.5ms |
312 | switch(ServoIndex) // map servo channels |
312 | switch(ServoIndex) // map servo channels |
313 | { |
313 | { |
314 | case 1: // Nick Compensation Servo |
314 | case 1: // Nick Compensation Servo |
315 | ServoNickOffset = (ServoNickOffset * 3 + (int16_t)Parameter_ServoNickControl * MULTIPLYER) / 4; // lowpass offset |
315 | ServoNickOffset = (ServoNickOffset * 3 + (int16_t)Parameter_ServoNickControl * MULTIPLYER) / 4; // lowpass offset |
316 | ServoNickValue = ServoNickOffset; // offset (Range from 0 to 255 * 3 = 765) |
316 | ServoNickValue = ServoNickOffset; // offset (Range from 0 to 255 * 3 = 765) |
317 | if(EE_Parameter.ServoNickCompInvert & 0x01) |
317 | if(EE_Parameter.ServoNickCompInvert & 0x01) |
318 | { // inverting movement of servo |
318 | { // inverting movement of servo |
319 | ServoNickValue += (int16_t)( ( (int32_t)EE_Parameter.ServoNickComp * MULTIPLYER * (IntegralNick / 128L ) ) / (256L) ); |
319 | ServoNickValue += (int16_t)( ( (int32_t)EE_Parameter.ServoNickComp * MULTIPLYER * (IntegralNick / 128L ) ) / (256L) ); |
320 | } |
320 | } |
321 | else |
321 | else |
322 | { // non inverting movement of servo |
322 | { // non inverting movement of servo |
323 | ServoNickValue -= (int16_t)( ( (int32_t)EE_Parameter.ServoNickComp * MULTIPLYER * (IntegralNick / 128L ) ) / (256L) ); |
323 | ServoNickValue -= (int16_t)( ( (int32_t)EE_Parameter.ServoNickComp * MULTIPLYER * (IntegralNick / 128L ) ) / (256L) ); |
324 | } |
324 | } |
325 | // limit servo value to its parameter range definition |
325 | // limit servo value to its parameter range definition |
326 | if(ServoNickValue < ((int16_t)EE_Parameter.ServoNickMin * MULTIPLYER) ) |
326 | if(ServoNickValue < ((int16_t)EE_Parameter.ServoNickMin * MULTIPLYER) ) |
327 | { |
327 | { |
328 | ServoNickValue = (int16_t)EE_Parameter.ServoNickMin * MULTIPLYER; |
328 | ServoNickValue = (int16_t)EE_Parameter.ServoNickMin * MULTIPLYER; |
329 | } |
329 | } |
330 | else |
330 | else |
331 | if(ServoNickValue > ((int16_t)EE_Parameter.ServoNickMax * MULTIPLYER) ) |
331 | if(ServoNickValue > ((int16_t)EE_Parameter.ServoNickMax * MULTIPLYER) ) |
332 | { |
332 | { |
333 | ServoNickValue = (int16_t)EE_Parameter.ServoNickMax * MULTIPLYER; |
333 | ServoNickValue = (int16_t)EE_Parameter.ServoNickMax * MULTIPLYER; |
334 | } |
334 | } |
335 | RemainingPulse += ServoNickValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
335 | RemainingPulse += ServoNickValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
336 | ServoNickValue /= MULTIPLYER; |
336 | ServoNickValue /= MULTIPLYER; |
337 | DebugOut.Analog[20] = ServoNickValue; |
337 | DebugOut.Analog[20] = ServoNickValue; |
338 | break; |
338 | break; |
339 | case 2: // Roll Compensation Servo |
339 | case 2: // Roll Compensation Servo |
340 | // Arthur P: Modified the code here to allow the user to either continue with the default |
340 | // Arthur P: Modified the code here to allow the user to either continue with the default |
341 | // offset value of 80, or set a different offset using parameter 7. I.e. if |
341 | // offset value of 80, or set a different offset using parameter 7. I.e. if |
342 | // parameter 7 == 0 then the default is used, but if a value > 0 is entered then |
342 | // parameter 7 == 0 then the default is used, but if a value > 0 is entered then |
343 | // that value is used. |
343 | // that value is used. |
344 | if(Parameter_UserParam7==0) |
344 | if(Parameter_UserParam7==0) |
345 | { |
345 | { |
346 | ServoRollOffset = (ServoRollOffset * 3 + (int16_t) 80 * MULTIPLYER) / 4; // lowpass offset |
346 | ServoRollOffset = (ServoRollOffset * 3 + (int16_t) 80 * MULTIPLYER) / 4; // lowpass offset |
347 | } |
347 | } |
348 | else |
348 | else |
349 | { |
349 | { |
350 | ServoRollOffset = (ServoRollOffset * 3 + (int16_t) Parameter_UserParam7 * MULTIPLYER) / 4; |
350 | ServoRollOffset = (ServoRollOffset * 3 + (int16_t) Parameter_UserParam7 * MULTIPLYER) / 4; |
351 | } |
351 | } |
352 | ServoRollValue = ServoRollOffset; // offset (Range from 0 to 255 * 3 = 765) |
352 | ServoRollValue = ServoRollOffset; // offset (Range from 0 to 255 * 3 = 765) |
353 | //if(EE_Parameter.ServoRollCompInvert & 0x01) |
353 | //if(EE_Parameter.ServoRollCompInvert & 0x01) |
354 | if(Parameter_UserParam8 & 0x40) |
354 | if(Parameter_UserParam8 & 0x40) |
355 | { // Arthur P: Inverting movement of servo if 64 has been added to User Parameter8 |
355 | { // Arthur P: Inverting movement of servo if 64 has been added to User Parameter8 |
356 | ServoRollValue += (int16_t)( ( (int32_t) 50 * MULTIPLYER * (IntegralRoll / 128L ) ) / (256L) ); |
356 | ServoRollValue += (int16_t)( ( (int32_t) 50 * MULTIPLYER * (IntegralRoll / 128L ) ) / (256L) ); |
357 | } |
357 | } |
358 | /**/ else |
358 | /**/ else |
359 | { // non inverting movement of servo |
359 | { // non inverting movement of servo |
360 | ServoRollValue -= (int16_t)( ( (int32_t) 40 * MULTIPLYER * (IntegralRoll / 128L ) ) / (256L) ); |
360 | ServoRollValue -= (int16_t)( ( (int32_t) 40 * MULTIPLYER * (IntegralRoll / 128L ) ) / (256L) ); |
361 | } |
361 | } |
362 | /**/ // limit servo value to its parameter range definition |
362 | /**/ // limit servo value to its parameter range definition |
363 | if(ServoRollValue < ((int16_t)EE_Parameter.ServoNickMin * MULTIPLYER) ) |
363 | if(ServoRollValue < ((int16_t)EE_Parameter.ServoNickMin * MULTIPLYER) ) |
364 | { |
364 | { |
365 | ServoRollValue = (int16_t)EE_Parameter.ServoNickMin * MULTIPLYER; |
365 | ServoRollValue = (int16_t)EE_Parameter.ServoNickMin * MULTIPLYER; |
366 | } |
366 | } |
367 | else |
367 | else |
368 | if(ServoRollValue > ((int16_t)EE_Parameter.ServoNickMax * MULTIPLYER) ) |
368 | if(ServoRollValue > ((int16_t)EE_Parameter.ServoNickMax * MULTIPLYER) ) |
369 | { |
369 | { |
370 | ServoRollValue = (int16_t)EE_Parameter.ServoNickMax * MULTIPLYER; |
370 | ServoRollValue = (int16_t)EE_Parameter.ServoNickMax * MULTIPLYER; |
371 | } |
371 | } |
372 | RemainingPulse += ServoRollValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
372 | RemainingPulse += ServoRollValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
373 | ServoRollValue /= MULTIPLYER; |
373 | ServoRollValue /= MULTIPLYER; |
374 | //DebugOut.Analog[20] = ServoRollValue; |
374 | //DebugOut.Analog[20] = ServoRollValue; |
375 | 375 | ||
376 | /* ServoRollOffset = (ServoRollOffset * 3 + (int16_t)Parameter_ServoRollControl * MULTIPLYER) / 4; // lowpass offset |
376 | /* ServoRollOffset = (ServoRollOffset * 3 + (int16_t)Parameter_ServoRollControl * MULTIPLYER) / 4; // lowpass offset |
377 | ServoRollValue = ServoRollOffset; // offset (Range from 0 to 255 * 3 = 765) |
377 | ServoRollValue = ServoRollOffset; // offset (Range from 0 to 255 * 3 = 765) |
378 | if(EE_Parameter.ServoRollCompInvert & 0x01) |
378 | if(EE_Parameter.ServoRollCompInvert & 0x01) |
379 | { // inverting movement of servo |
379 | { // inverting movement of servo |
380 | ServoRollValue += (int16_t)( ( (int32_t)EE_Parameter.ServoNickComp * MULTIPLYER * (IntegralNick / 128L ) ) / (256L) ); |
380 | ServoRollValue += (int16_t)( ( (int32_t)EE_Parameter.ServoNickComp * MULTIPLYER * (IntegralNick / 128L ) ) / (256L) ); |
381 | } |
381 | } |
382 | else |
382 | else |
383 | { // non inverting movement of servo |
383 | { // non inverting movement of servo |
384 | ServoRollValue -= (int16_t)( ( (int32_t)EE_Parameter.ServoNickComp * MULTIPLYER * (IntegralNick / 128L ) ) / (256L) ); |
384 | ServoRollValue -= (int16_t)( ( (int32_t)EE_Parameter.ServoNickComp * MULTIPLYER * (IntegralNick / 128L ) ) / (256L) ); |
385 | } |
385 | } |
386 | // limit servo value to its parameter range definition |
386 | // limit servo value to its parameter range definition |
387 | if(ServoRollValue < ((int16_t)EE_Parameter.ServoRollMin * MULTIPLYER) ) |
387 | if(ServoRollValue < ((int16_t)EE_Parameter.ServoRollMin * MULTIPLYER) ) |
388 | { |
388 | { |
389 | ServoRollValue = (int16_t)EE_Parameter.ServoRollMin * MULTIPLYER; |
389 | ServoRollValue = (int16_t)EE_Parameter.ServoRollMin * MULTIPLYER; |
390 | } |
390 | } |
391 | else |
391 | else |
392 | if(ServoRollValue > ((int16_t)EE_Parameter.ServoRollMax * MULTIPLYER) ) |
392 | if(ServoRollValue > ((int16_t)EE_Parameter.ServoRollMax * MULTIPLYER) ) |
393 | { |
393 | { |
394 | ServoRollValue = (int16_t)EE_Parameter.ServoRollMax * MULTIPLYER; |
394 | ServoRollValue = (int16_t)EE_Parameter.ServoRollMax * MULTIPLYER; |
395 | } |
395 | } |
396 | RemainingPulse += ServoRollValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
396 | RemainingPulse += ServoRollValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
397 | ServoRollValue /= MULTIPLYER; |
397 | ServoRollValue /= MULTIPLYER; |
398 | //DebugOut.Analog[20] = ServoRollValue; |
398 | //DebugOut.Analog[20] = ServoRollValue; |
399 | */ break; |
399 | */ break; |
400 | case 3: // Arthur P: Shutter Servo including interval control over parameter 5 and 6. |
400 | case 3: // Arthur P: Shutter Servo including interval control over parameter 5 and 6. |
401 | 401 | ||
402 | 402 | ||
403 | if(PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] < -32) |
403 | if(PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] < -32) |
404 | { |
404 | { |
405 | // Set servo to null position, turning camera off. |
405 | // Set servo to null position, turning camera off. |
406 | RemainingPulse = MINSERVOPULSE; |
406 | RemainingPulse = MINSERVOPULSE; |
407 | } |
407 | } |
408 | else |
408 | else |
409 | { |
409 | { |
- | 410 | // 090807: Arthur P.: Removed the shutter cycle parts as they may be impacting timing loops. |
|
410 | if(PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] > 32) |
411 | // if(PPM_in[EE_Parameter.Kanalbelegung[K_POTI3]] > 32) |
411 | // Middle position on a 3 position switch which runs from -127 to +127 |
412 | // Middle position on a 3 position switch which runs from -127 to +127 |
412 | { |
413 | // { |
413 | 414 | ||
414 | RemainingPulse = MINSERVOPULSE + SERVORANGE/2; |
415 | RemainingPulse = MINSERVOPULSE + SERVORANGE/2; |
415 | } |
416 | // } |
416 | else |
417 | // else |
417 | { |
418 | // { |
418 | // Cycle shutter servo between on and off depending upon CameraShutterCycleCounter |
419 | // Cycle shutter servo between on and off depending upon CameraShutterCycleCounter |
419 | // If CameraShutterCylce < 50 then default to continuous shoot. |
420 | // If CameraShutterCylce < 50 then default to continuous shoot. |
420 | if(CameraShutterCycle < 50 ) |
421 | //if(CameraShutterCycle < 50 ) |
421 | { |
422 | // { |
422 | RemainingPulse = MINSERVOPULSE + SERVORANGE/2; |
423 | RemainingPulse = MINSERVOPULSE + SERVORANGE/2; |
423 | } |
424 | // } |
424 | else |
425 | // else |
425 | { |
426 | // { |
426 | if(CameraShutterCycleCounter == CameraShutterCycle) |
427 | // if(CameraShutterCycleCounter == CameraShutterCycle) |
427 | { |
428 | // { |
428 | // Shutter on |
429 | // Shutter on |
429 | CameraShutterCycleCounter = 0; |
430 | // CameraShutterCycleCounter = 0; |
430 | RemainingPulse = MINSERVOPULSE + SERVORANGE/2; |
431 | // RemainingPulse = MINSERVOPULSE + SERVORANGE/2; |
431 | } |
432 | // } |
432 | else |
433 | // else |
433 | { |
434 | // { |
434 | // Leave on for at least 24 cycles or 0.25 seconds to allow |
435 | // Leave on for at least 24 cycles or 0.25 seconds to allow |
435 | // the camera to properly trigger, turn off if past 0.25 sec. |
436 | // the camera to properly trigger, turn off if past 0.25 sec. |
436 | // For now this is actually set via para5 to allow for a long enough |
437 | // For now this is actually set via para5 to allow for a long enough |
437 | // shutter pulse for different cameras. Once it is clear what value |
438 | // shutter pulse for different cameras. Once it is clear what value |
438 | // works, this can be changed to a hardcoded value. |
439 | // works, this can be changed to a hardcoded value. |
439 | if(CameraShutterCycleCounter>Parameter_UserParam5) |
440 | // if(CameraShutterCycleCounter>Parameter_UserParam5) |
440 | { |
441 | // { |
441 | 442 | ||
442 | RemainingPulse = MINSERVOPULSE; |
443 | // RemainingPulse = MINSERVOPULSE; |
443 | } |
444 | // } |
444 | CameraShutterCycleCounter++; |
445 | // CameraShutterCycleCounter++; |
445 | } |
446 | // } |
446 | } |
447 | // } |
447 | } |
448 | // } |
448 | } |
449 | } |
449 | break; |
- | |
- | 450 | break; |
|
- | 451 | // 090807 Arthur P: Removed the output of the remaining channels as this just eats time and probably |
|
450 | 452 | // does not have much of a function. Better to add specific outputs as needed. |
|
451 | default: // other servo channels |
453 | // default: // other servo channels |
452 | RemainingPulse += 2 * PPM_in[ServoIndex]; // add channel value, factor of 2 because timer 1 increments 3.2µs |
454 | // RemainingPulse += 2 * PPM_in[ServoIndex]; // add channel value, factor of 2 because timer 1 increments 3.2µs |
453 | break; |
455 | // break; |
454 | } |
456 | } |
455 | // range servo pulse width |
457 | // range servo pulse width |
456 | if(RemainingPulse > MAXSERVOPULSE ) RemainingPulse = MAXSERVOPULSE; // upper servo pulse limit |
458 | if(RemainingPulse > MAXSERVOPULSE ) RemainingPulse = MAXSERVOPULSE; // upper servo pulse limit |
457 | else if(RemainingPulse < MINSERVOPULSE ) RemainingPulse = MINSERVOPULSE; // lower servo pulse limit |
459 | else if(RemainingPulse < MINSERVOPULSE ) RemainingPulse = MINSERVOPULSE; // lower servo pulse limit |
458 | // substract stop pulse width |
460 | // substract stop pulse width |
459 | // Arthur P: I think the following line, correcting for the PPM sTOPPULSE does not apply for the |
461 | // Arthur P: I think the following line, correcting for the PPM sTOPPULSE does not apply for the |
460 | // calculated pulses, or maybe not at all. Therefore I-m commenting it out to see what happens.... |
462 | // calculated pulses, or maybe not at all. Therefore I-m commenting it out to see what happens.... |
461 | // 090624 reactivated as rollservo correction can now be done over para7. |
463 | // 090624 reactivated as rollservo correction can now be done over para7. |
462 | RemainingPulse -= PPM_STOPPULSE; |
464 | RemainingPulse -= PPM_STOPPULSE; |
463 | // accumulate time for correct sync gap |
465 | // accumulate time for correct sync gap |
464 | ServoFrameTime += RemainingPulse; |
466 | ServoFrameTime += RemainingPulse; |
465 | } |
467 | } |
466 | } |
468 | } |
467 | else // we had a high pulse |
469 | else // we had a high pulse |
468 | { |
470 | { |
469 | TCCR2A |= (1<<COM2A0); // make a low pulse |
471 | TCCR2A |= (1<<COM2A0); // make a low pulse |
470 | // set pulsewidth to stop pulse width |
472 | // set pulsewidth to stop pulse width |
471 | RemainingPulse = PPM_STOPPULSE; |
473 | RemainingPulse = PPM_STOPPULSE; |
472 | // accumulate time for correct sync gap |
474 | // accumulate time for correct sync gap |
473 | ServoFrameTime += RemainingPulse; |
475 | ServoFrameTime += RemainingPulse; |
474 | if(ServoActive && SenderOkay > 180) HEF4017R_OFF; // disable HEF4017 reset |
476 | if(ServoActive && SenderOkay > 180) HEF4017R_OFF; // disable HEF4017 reset |
475 | ServoIndex++; // change to next servo channel |
477 | ServoIndex++; // change to next servo channel |
476 | if(ServoIndex > EE_Parameter.ServoNickRefresh) ServoIndex = 0; // reset to the sync gap |
478 | if(ServoIndex > EE_Parameter.ServoNickRefresh) ServoIndex = 0; // reset to the sync gap |
477 | } |
479 | } |
478 | // set pulse output active |
480 | // set pulse output active |
479 | PulseOutput = 1; |
481 | PulseOutput = 1; |
480 | } |
482 | } |
481 | } // EOF PPM state machine |
483 | } // EOF PPM state machine |
482 | 484 | ||
483 | // General pulse output generator |
485 | // General pulse output generator |
484 | if(RemainingPulse > (255 + IRS_RUNTIME)) |
486 | if(RemainingPulse > (255 + IRS_RUNTIME)) |
485 | { |
487 | { |
486 | OCR2A = 255; |
488 | OCR2A = 255; |
487 | RemainingPulse -= 255; |
489 | RemainingPulse -= 255; |
488 | } |
490 | } |
489 | else |
491 | else |
490 | { |
492 | { |
491 | if(RemainingPulse > 255) // this is the 2nd last part |
493 | if(RemainingPulse > 255) // this is the 2nd last part |
492 | { |
494 | { |
493 | if((RemainingPulse - 255) < IRS_RUNTIME) |
495 | if((RemainingPulse - 255) < IRS_RUNTIME) |
494 | { |
496 | { |
495 | OCR2A = 255 - IRS_RUNTIME; |
497 | OCR2A = 255 - IRS_RUNTIME; |
496 | RemainingPulse -= 255 - IRS_RUNTIME; |
498 | RemainingPulse -= 255 - IRS_RUNTIME; |
497 | 499 | ||
498 | } |
500 | } |
499 | else // last part > ISR_RUNTIME |
501 | else // last part > ISR_RUNTIME |
500 | { |
502 | { |
501 | OCR2A = 255; |
503 | OCR2A = 255; |
502 | RemainingPulse -= 255; |
504 | RemainingPulse -= 255; |
503 | } |
505 | } |
504 | } |
506 | } |
505 | else // this is the last part |
507 | else // this is the last part |
506 | { |
508 | { |
507 | OCR2A = RemainingPulse; |
509 | OCR2A = RemainingPulse; |
508 | RemainingPulse = 0; |
510 | RemainingPulse = 0; |
509 | PulseOutput = 0; // trigger to stop pulse |
511 | PulseOutput = 0; // trigger to stop pulse |
510 | } |
512 | } |
511 | } // EOF general pulse output generator |
513 | } // EOF general pulse output generator |
512 | } |
514 | } |
513 | 515 |