20,9 → 20,9 |
#define TL3 PIN_B1 // tlacitko S3 |
#define TL4 PIN_B0 // tlacitko S4 |
|
#define POWER_T3 PIN_A3 // ovladani optotriaku T3 |
#define POWER_T4 PIN_A5 // ovladani optotriaku T4 |
#define POWER_T5 PIN_A4 // ovladani optotriaku T5 |
#define POWER_T3 PIN_C4 // ovladani optotriaku T3 |
#define POWER_T4 PIN_C5 // ovladani optotriaku T4 |
#define POWER_T5 PIN_C6 // ovladani optotriaku T5 |
|
#define ADC_PIN PIN_A0 //info, nelze menit - pin pouzit jako input analog |
#define ADC_PIN_NC PIN_A1 //info, nelze menit - pin pouzit jako input analog |
64,6 → 64,7 |
|
enable_interrupts(GLOBAL); |
enable_interrupts(INT_TIMER2); |
enable_interrupts(INT_TIMER1); |
|
setup_adc_ports(AN0_AN1_VSS_VREF); //A0 vstup cidla, A1 nepozit, A3 - ref. 2.5V |
setup_adc(ADC_CLOCK_DIV_8); |
70,6 → 71,15 |
SET_ADC_CHANNEL(0); //AN0, PIN_A0 |
} |
|
void heat_failure() // exception in case of heating fail |
{ |
lcd_gotoxy(1,2); |
printf(lcd_putc,"HEATING FAILURE!"); |
|
while(true); |
|
} |
|
unsigned int16 adc(void) |
{ |
unsigned int16 analog; |
91,7 → 101,7 |
|
void top_heating() |
{ |
if (period <= top_heat_power){ |
if (period < top_heat_power){ |
output_low(POWER_T4); |
output_low(POWER_T5); |
} |
104,7 → 114,7 |
void bottom_heating() |
{ |
|
if (period <= 2*bottom_heat_power){ |
if (period < 2*bottom_heat_power){ |
output_low(POWER_T3); |
} |
else{ |
116,15 → 126,13 |
#int_TIMER1 |
void heating_control() //rizeni topnych teles pri preteceni casovace |
{ |
top_heating(); |
bottom_heating(); |
|
top_heating(); |
bottom_heating(); |
|
if (period <= 200) period++; |
else period=0; |
if (period <= 200) period++; |
else period=0; |
} |
|
|
#int_TIMER2 |
void Rtc(void) //40ms |
{ |
150,26 → 158,32 |
{ |
float slope_deviation; |
|
slope_deviation = (teplota() - temp_last) - ramp; // vypocet strmosti a odchylky od pozadovane strmosti |
slope_deviation = (teplota() - temp_last) - ramp; // vypocet strmosti a odchylky od pozadovane strmosti |
|
if(slope_deviation < 0) |
{ |
top_heat_power= slope_deviation*(-10) + balance; |
bottom_heat_power= slope_deviation*(-10); |
if(slope_deviation < 0) |
{ |
top_heat_power= 80 + balance; |
bottom_heat_power= 90; |
} |
else{ |
top_heat_power=0; |
bottom_heat_power=0; |
} |
temp_last = teplota(); |
} |
else{ |
top_heat_power=0; |
bottom_heat_power=0; |
} |
|
temp_last = teplota(); |
} |
|
void level_control(float level) // P proporcionalni rizeni teploty |
{ |
|
teplota(); |
|
if (teplota() > level) |
{ |
top_heat_power=0; |
bottom_heat_power=0; |
} |
else |
{ |
top_heat_power=70; |
bottom_heat_power=80; |
} |
} |
|
|
187,8 → 201,12 |
void reflow_solder() |
{ |
|
struct time process_time; |
|
// preheat |
nullcas(&cas); |
lcd_gotoxy(1,2); |
printf(lcd_putc,"PREHEAT"); |
|
do { |
slope_control(PREHEAT_SLOPE, 0); // hlida strmost predehrevu |
200,12 → 218,19 |
printf(lcd_putc,"%2u:%02u:%02u",cas.hod,cas.min,cas.sec); |
|
delay_ms(1000); |
if (cas.min>3) heat_failure(); |
} |
while (teplota() < SOAK_TEMP); |
|
// soak |
nullcas(&cas); |
while (cas.min*60+cas.sec <= SOAK_TIME) |
process_time.min = SOAK_TIME/60; |
process_time.sec = SOAK_TIME - process_time.min*60; |
|
lcd_gotoxy(1,2); |
printf(lcd_putc,"SOAK "); |
|
while (process_time.sec!=0 || process_time.min!=0) |
{ |
level_control(SOAK_TEMP); |
|
212,8 → 237,13 |
lcd_gotoxy(1,1); |
printf(lcd_putc,"%3.1f\21C ",teplota()); |
|
if ((process_time.sec = process_time.sec - cas.sec)<0) process_time.sec=59; |
|
process_time.min = (SOAK_TIME - cas.min*60 - cas.sec)/60; |
process_time.sec = (SOAK_TIME - cas.min*60 - cas.sec) - process_time.min*60; |
|
lcd_gotoxy(9,1); |
printf(lcd_putc,"%2u:%02u:%02u",cas.hod, SOAK_TIME/60 - cas.min, SOAK_TIME - cas.min*60 - cas.sec); |
printf(lcd_putc,"%2u:%02u:%02u",cas.hod, process_time.min, process_time.sec); |
delay_ms(1000); |
} |
|
234,9 → 264,7 |
|
while(true) |
{ |
delay_ms(300); |
|
|
delay_ms(300); |
reflow_solder(); |
|
} |