45,7 → 45,9 |
unsigned int period; |
|
float temp_last=0; |
float temp_slope=0; |
|
|
void GeneralCpuInit() // inicializace |
{ |
output_high(POWER_T4); |
73,6 → 75,9 |
|
void heat_failure() // exception in case of heating fail |
{ |
top_heat_power=0; |
bottom_heat_power=0; |
|
lcd_gotoxy(1,2); |
printf(lcd_putc,"HEATING FAILURE!"); |
|
80,7 → 85,7 |
|
} |
|
unsigned int16 adc(void) |
unsigned int16 adc(void) // adc read and filtering |
{ |
unsigned int16 analog; |
unsigned int8 a; |
94,9 → 99,9 |
return (analog >> 5 ); // prumer = analog/32 |
} |
|
float teplota(void) |
float teplota(void) // temperature measuring |
{ |
return (0.674201*adc() - 294.35); |
return (0.674201*adc() - 294.35); // temperature calculaton (linear aproximation) |
} |
|
void top_heating() |
126,10 → 131,17 |
#int_TIMER1 |
void heating_control() //rizeni topnych teles pri preteceni casovace |
{ |
float temp; |
|
top_heating(); |
bottom_heating(); |
|
temp=teplota(); |
|
temp_slope=(temp - temp_last)*100.0; ///(4000000.0/65536.0); // vypocet strmosti narustu teploty ve stupnich/s |
temp_last = temp; |
|
if (period <= 200) period++; |
if (period < 200) period++; |
else period=0; |
} |
|
158,7 → 170,7 |
{ |
float slope_deviation; |
|
slope_deviation = (teplota() - temp_last) - ramp; // vypocet strmosti a odchylky od pozadovane strmosti |
slope_deviation = temp_slope - ramp; // vypocet strmosti a odchylky od pozadovane strmosti |
|
if(slope_deviation < 0) |
{ |
169,7 → 181,6 |
top_heat_power=0; |
bottom_heat_power=0; |
} |
temp_last = teplota(); |
} |
|
void level_control(float level) // P proporcionalni rizeni teploty |
204,6 → 215,7 |
struct time process_time; |
|
// preheat |
|
nullcas(&cas); |
lcd_gotoxy(1,2); |
printf(lcd_putc,"PREHEAT"); |
214,9 → 226,12 |
lcd_gotoxy(1,1); |
printf(lcd_putc,"%3.1f\21C ",teplota()); |
|
lcd_gotoxy(9,1); |
printf(lcd_putc,"%2u:%02u:%02u",cas.hod,cas.min,cas.sec); |
lcd_gotoxy(12,1); |
printf(lcd_putc,"%02u:%02u",cas.min,cas.sec); |
|
lcd_gotoxy(10,2); |
printf(lcd_putc,"%1.1f\21C/s ",temp_slope); |
|
delay_ms(1000); |
if (cas.min>3) heat_failure(); |
} |