Rev 2007 Rev 2008
Line 33... Line 33...
33 #define PowerOff() output_high(POWER_T4);output_high(POWER_T5) 33 #define PowerOff() output_high(POWER_T4);output_high(POWER_T5)
34   34  
35 // globalni promenne 35 // globalni promenne
36 struct time 36 struct time
37 { 37 {
38 volatile unsigned int8 hod; 38 volatile signed int8 hod;
39 volatile unsigned int8 min; 39 volatile signed int8 min;
40 volatile unsigned int8 sec; 40 volatile signed int8 sec;
41 }cas; 41 }cas;
42   42  
43 unsigned int top_heat_power=0; // range 0-200% nad 100% je ale teleso jiz pretizene 43 unsigned int top_heat_power=0; // range 0-200% nad 100% je ale teleso jiz pretizene
44 unsigned int bottom_heat_power=0; // contains heating power range 0-100% 44 unsigned int bottom_heat_power=0; // contains heating power range 0-100%
45 unsigned int period; 45 unsigned int period;
Line 55... Line 55...
55 port_b_pullups(true); 55 port_b_pullups(true);
56 56
57 setup_psp(PSP_DISABLED); 57 setup_psp(PSP_DISABLED);
58 setup_spi(SPI_SS_DISABLED); 58 setup_spi(SPI_SS_DISABLED);
59 59
60 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); //nepouzit 60 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_64); //nepouzit
61 setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); // rizeni 61 setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); // rizeni
62 setup_timer_2(T2_DIV_BY_16,249,10); //rtc 40ms 62 setup_timer_2(T2_DIV_BY_16,249,10); //rtc 40ms
63 63
64 setup_comparator(NC_NC_NC_NC); 64 setup_comparator(NC_NC_NC_NC);
65 setup_vref(FALSE); 65 setup_vref(FALSE);
66 66
67 enable_interrupts(GLOBAL); 67 enable_interrupts(GLOBAL);
68 enable_interrupts(INT_TIMER2); 68 enable_interrupts(INT_TIMER2);
69 enable_interrupts(INT_TIMER1); 69 enable_interrupts(INT_TIMER0);
70 70
71 setup_adc_ports(AN0_AN1_VSS_VREF); //A0 vstup cidla, A1 nepozit, A3 - ref. 2.5V 71 setup_adc_ports(AN0_AN1_VSS_VREF); //A0 vstup cidla, A1 nepozit, A3 - ref. 2.5V
72 setup_adc(ADC_CLOCK_DIV_8); 72 setup_adc(ADC_CLOCK_DIV_8);
73 SET_ADC_CHANNEL(0); //AN0, PIN_A0 73 SET_ADC_CHANNEL(0); //AN0, PIN_A0
74 } 74 }
Line 123... Line 123...
123 output_low(POWER_T3); 123 output_low(POWER_T3);
124 } 124 }
125 else{ 125 else{
126 output_high(POWER_T3); 126 output_high(POWER_T3);
127 } 127 }
128   -  
129 } 128 }
130   129  
131 #int_TIMER1 130 #int_TIMER0
132 void heating_control() //rizeni topnych teles pri preteceni casovace 131 void heating_control() //rizeni topnych teles pri preteceni casovace
133 { 132 {
134 float temp; 133 float temp;
135   134  
136 top_heating(); 135 top_heating();
137 bottom_heating(); 136 bottom_heating();
138 137
139 temp=teplota(); -  
140 138
-   139 if (period == 200)
-   140 {
-   141 temp=teplota();
141 temp_slope=(temp - temp_last)*100.0; ///(4000000.0/65536.0); // vypocet strmosti narustu teploty ve stupnich/s 142 temp_slope=(temp - temp_last) /(2*100.0*256.0/62500.0); // vypocet strmosti narustu teploty ve stupnich/s
142 temp_last = temp; 143 temp_last = temp;
-   144 }
143   145
144 if (period < 200) period++; 146 if (period < 200) period++;
145 else period=0; 147 else period=0;
146 } 148 }
147   149  
148 #int_TIMER2 150 #int_TIMER2
Line 172... Line 174...
172   174  
173 slope_deviation = temp_slope - ramp; // vypocet strmosti a odchylky od pozadovane strmosti 175 slope_deviation = temp_slope - ramp; // vypocet strmosti a odchylky od pozadovane strmosti
174   176  
175 if(slope_deviation < 0) 177 if(slope_deviation < 0)
176 { 178 {
177 top_heat_power= 80 + balance; 179 top_heat_power= 67 + balance;
178 bottom_heat_power= 90; 180 bottom_heat_power= 100;
179 } 181 }
180 else{ 182 else{
181 top_heat_power=0; 183 top_heat_power=0;
182 bottom_heat_power=0; 184 bottom_heat_power=0;
183 } 185 }
Line 212... Line 214...
212 void reflow_solder() 214 void reflow_solder()
213 { 215 {
214   216  
215 struct time process_time; 217 struct time process_time;
216   218  
217 // preheat 219 // ------------------- PREHEAT ---------------------
218   220  
219 nullcas(&cas); 221 nullcas(&cas);
220 lcd_gotoxy(1,2); 222 lcd_gotoxy(1,2);
221 printf(lcd_putc,"PREHEAT"); 223 printf(lcd_putc,"PREHEAT");
222   224  
Line 230... Line 232...
230 printf(lcd_putc,"%02u:%02u",cas.min,cas.sec); 232 printf(lcd_putc,"%02u:%02u",cas.min,cas.sec);
231   233  
232 lcd_gotoxy(10,2); 234 lcd_gotoxy(10,2);
233 printf(lcd_putc,"%1.1f\21C/s ",temp_slope); 235 printf(lcd_putc,"%1.1f\21C/s ",temp_slope);
234   236  
235 delay_ms(1000); 237 delay_ms(200);
236 if (cas.min>3) heat_failure(); 238 if (cas.min>3) heat_failure();
237 } 239 }
238 while (teplota() < SOAK_TEMP); 240 while (teplota() < SOAK_TEMP);
239   241  
240 // soak 242 // ----------- SOAK ---------------
241 nullcas(&cas); 243 nullcas(&cas);
242 process_time.min = SOAK_TIME/60; 244 process_time.min = SOAK_TIME/60;
243 process_time.sec = SOAK_TIME - process_time.min*60; 245 process_time.sec = SOAK_TIME - process_time.min*60;
-   246  
244 247 lcd_clr();
245 lcd_gotoxy(1,2); 248 lcd_gotoxy(1,2);
246 printf(lcd_putc,"SOAK "); 249 printf(lcd_putc,"SOAK ");
247   250  
248 while (process_time.sec!=0 || process_time.min!=0) 251 while (process_time.sec!=0 || process_time.min!=0)
249 { 252 {
Line 256... Line 259...
256   259  
257 process_time.min = (SOAK_TIME - cas.min*60 - cas.sec)/60; 260 process_time.min = (SOAK_TIME - cas.min*60 - cas.sec)/60;
258 process_time.sec = (SOAK_TIME - cas.min*60 - cas.sec) - process_time.min*60; 261 process_time.sec = (SOAK_TIME - cas.min*60 - cas.sec) - process_time.min*60;
259   262  
260 lcd_gotoxy(9,1); 263 lcd_gotoxy(9,1);
261 printf(lcd_putc,"%2u:%02u:%02u",cas.hod, process_time.min, process_time.sec); 264 printf(lcd_putc,"%02u:%02u", process_time.min, process_time.sec);
262 delay_ms(1000); 265 delay_ms(200);
-   266
263 } 267 }
264 268
-   269 //----------------- solder ----------------------------
-   270  
-   271 nullcas(&cas);
-   272 lcd_clr();
-   273 lcd_gotoxy(1,2);
-   274 printf(lcd_putc,"SOLDER");
-   275  
265 // solder 276 do {
-   277 slope_control(SOLDER_SLOPE, 10); // hlida strmost predehrevu
-   278  
-   279 lcd_gotoxy(1,1);
-   280 printf(lcd_putc,"%3.1f\21C ",teplota());
-   281  
-   282 lcd_gotoxy(12,1);
-   283 printf(lcd_putc,"%02u:%02u",cas.min,cas.sec);
-   284  
-   285 lcd_gotoxy(10,2);
-   286 printf(lcd_putc,"%1.1f\21C/s ",temp_slope);
-   287  
-   288 delay_ms(200);
-   289 if (cas.min>3) heat_failure();
-   290 }
-   291 while (teplota() < SOLDER_TEMP);
-   292  
-   293 // ---------------- TAO ------------------------
-   294  
-   295  
-   296 while (process_time.sec!=0 || process_time.min!=0)
-   297 {
-   298 level_control(SOLDER_TEMP);
-   299  
-   300 lcd_gotoxy(1,1);
-   301 printf(lcd_putc,"%3.1f\21C ",teplota());
-   302  
-   303 if ((process_time.sec = process_time.sec - cas.sec)<0) process_time.sec=59;
-   304  
-   305 process_time.min = (SOLDER_TIME - cas.min*60 - cas.sec)/60;
-   306 process_time.sec = (SOLDER_TIME - cas.min*60 - cas.sec) - process_time.min*60;
-   307  
-   308 lcd_gotoxy(9,1);
-   309 printf(lcd_putc,"%02u:%02u", process_time.min, process_time.sec);
-   310 delay_ms(200);
-   311
-   312 }
-   313  
-   314 // ---------------- COOLING ------------------------
-   315  
-   316 top_heat_power=0;
-   317 bottom_heat_power=0;
-   318  
-   319 lcd_clr();
-   320  
-   321 lcd_gotoxy(1,2);
-   322 printf(lcd_putc,"REFLOW COMPLETE");
266 323
-   324 while(true)
-   325 {
-   326 lcd_gotoxy(1,1);
-   327 printf(lcd_putc,"%3.1f\21C ",teplota());
267 } 328  
-   329 lcd_gotoxy(10,1);
-   330 printf(lcd_putc,"%1.1f\21C/s ",temp_slope);
268   331  
-   332 }
-   333 }
269   334  
270 void main() // main loop 335 void main() // main loop
271 { 336 {
272 GeneralCpuInit(); 337 GeneralCpuInit();
273 PowerOff(); 338 PowerOff();