Rev 1963 Rev 2007
Line 43... Line 43...
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;
46   46  
47 float temp_last=0; 47 float temp_last=0;
-   48 float temp_slope=0;
-   49  
48   50  
49 void GeneralCpuInit() // inicializace 51 void GeneralCpuInit() // inicializace
50 { 52 {
51 output_high(POWER_T4); 53 output_high(POWER_T4);
52 output_high(POWER_T5); 54 output_high(POWER_T5);
Line 71... Line 73...
71 SET_ADC_CHANNEL(0); //AN0, PIN_A0 73 SET_ADC_CHANNEL(0); //AN0, PIN_A0
72 } 74 }
73   75  
74 void heat_failure() // exception in case of heating fail 76 void heat_failure() // exception in case of heating fail
75 { 77 {
-   78 top_heat_power=0;
-   79 bottom_heat_power=0;
-   80  
76 lcd_gotoxy(1,2); 81 lcd_gotoxy(1,2);
77 printf(lcd_putc,"HEATING FAILURE!"); 82 printf(lcd_putc,"HEATING FAILURE!");
78 83
79 while(true); 84 while(true);
80   85  
81 } 86 }
82   87  
83 unsigned int16 adc(void) 88 unsigned int16 adc(void) // adc read and filtering
84 { 89 {
85 unsigned int16 analog; 90 unsigned int16 analog;
86 unsigned int8 a; 91 unsigned int8 a;
87   92  
88 analog = 0; 93 analog = 0;
Line 92... Line 97...
92 delay_us(50); 97 delay_us(50);
93 } 98 }
94 return (analog >> 5 ); // prumer = analog/32 99 return (analog >> 5 ); // prumer = analog/32
95 } 100 }
96   101  
97 float teplota(void) 102 float teplota(void) // temperature measuring
98 { 103 {
99 return (0.674201*adc() - 294.35); 104 return (0.674201*adc() - 294.35); // temperature calculaton (linear aproximation)
100 } 105 }
101   106  
102 void top_heating() 107 void top_heating()
103 { 108 {
104 if (period < top_heat_power){ 109 if (period < top_heat_power){
Line 124... Line 129...
124 } 129 }
125   130  
126 #int_TIMER1 131 #int_TIMER1
127 void heating_control() //rizeni topnych teles pri preteceni casovace 132 void heating_control() //rizeni topnych teles pri preteceni casovace
128 { 133 {
-   134 float temp;
-   135  
129 top_heating(); 136 top_heating();
130 bottom_heating(); 137 bottom_heating();
-   138
-   139 temp=teplota();
-   140
-   141 temp_slope=(temp - temp_last)*100.0; ///(4000000.0/65536.0); // vypocet strmosti narustu teploty ve stupnich/s
-   142 temp_last = temp;
131   143  
132 if (period <= 200) period++; 144 if (period < 200) period++;
133 else period=0; 145 else period=0;
134 } 146 }
135   147  
136 #int_TIMER2 148 #int_TIMER2
137 void Rtc(void) //40ms 149 void Rtc(void) //40ms
Line 156... Line 168...
156   168  
157 void slope_control(float ramp, unsigned int balance) // P proporcionalni rizeni narustu teploty predpoklada periodicke volani 1x/s 169 void slope_control(float ramp, unsigned int balance) // P proporcionalni rizeni narustu teploty predpoklada periodicke volani 1x/s
158 { 170 {
159 float slope_deviation; 171 float slope_deviation;
160   172  
161 slope_deviation = (teplota() - temp_last) - ramp; // vypocet strmosti a odchylky od pozadovane strmosti 173 slope_deviation = temp_slope - ramp; // vypocet strmosti a odchylky od pozadovane strmosti
162   174  
163 if(slope_deviation < 0) 175 if(slope_deviation < 0)
164 { 176 {
165 top_heat_power= 80 + balance; 177 top_heat_power= 80 + balance;
166 bottom_heat_power= 90; 178 bottom_heat_power= 90;
167 } 179 }
168 else{ 180 else{
169 top_heat_power=0; 181 top_heat_power=0;
170 bottom_heat_power=0; 182 bottom_heat_power=0;
171 } 183 }
172 temp_last = teplota(); -  
173 } 184 }
174   185  
175 void level_control(float level) // P proporcionalni rizeni teploty 186 void level_control(float level) // P proporcionalni rizeni teploty
176 { 187 {
177 if (teplota() > level) 188 if (teplota() > level)
Line 202... Line 213...
202 { 213 {
203   214  
204 struct time process_time; 215 struct time process_time;
205   216  
206 // preheat 217 // preheat
-   218  
207 nullcas(&cas); 219 nullcas(&cas);
208 lcd_gotoxy(1,2); 220 lcd_gotoxy(1,2);
209 printf(lcd_putc,"PREHEAT"); 221 printf(lcd_putc,"PREHEAT");
210   222  
211 do { 223 do {
212 slope_control(PREHEAT_SLOPE, 0); // hlida strmost predehrevu 224 slope_control(PREHEAT_SLOPE, 0); // hlida strmost predehrevu
213   225  
214 lcd_gotoxy(1,1); 226 lcd_gotoxy(1,1);
215 printf(lcd_putc,"%3.1f\21C ",teplota()); 227 printf(lcd_putc,"%3.1f\21C ",teplota());
216   228  
217 lcd_gotoxy(9,1); 229 lcd_gotoxy(12,1);
218 printf(lcd_putc,"%2u:%02u:%02u",cas.hod,cas.min,cas.sec); 230 printf(lcd_putc,"%02u:%02u",cas.min,cas.sec);
-   231  
-   232 lcd_gotoxy(10,2);
-   233 printf(lcd_putc,"%1.1f\21C/s ",temp_slope);
219   234  
220 delay_ms(1000); 235 delay_ms(1000);
221 if (cas.min>3) heat_failure(); 236 if (cas.min>3) heat_failure();
222 } 237 }
223 while (teplota() < SOAK_TEMP); 238 while (teplota() < SOAK_TEMP);