1,4 → 1,5 |
#include "reflow.h" |
#include "process.h" |
#include <math.h> |
|
// nastaveni teplot a casu |
19,7 → 20,7 |
#define TL3 PIN_B1 // tlacitko S3 |
#define TL4 PIN_B0 // tlacitko S4 |
|
#define POWER_T3 PIN_A6 // ovladani optotriaku T3 |
#define POWER_T3 PIN_A3 // ovladani optotriaku T3 |
#define POWER_T4 PIN_A5 // ovladani optotriaku T4 |
#define POWER_T5 PIN_A4 // ovladani optotriaku T5 |
|
39,8 → 40,13 |
volatile unsigned int8 sec; |
}cas; |
|
// funkce |
void GeneralCpuInit() |
unsigned int top_heat_power=0; // range 0-200% nad 100% je ale teleso jiz pretizene |
unsigned int bottom_heat_power=0; // contains heating power range 0-100% |
unsigned int period; |
|
float temp_last=0; |
|
void GeneralCpuInit() // inicializace |
{ |
output_high(POWER_T4); |
output_high(POWER_T5); |
50,7 → 56,7 |
setup_spi(SPI_SS_DISABLED); |
|
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); //nepouzit |
setup_timer_1(T1_DISABLED); //nepouzit |
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); // rizeni |
setup_timer_2(T2_DIV_BY_16,249,10); //rtc 40ms |
|
setup_comparator(NC_NC_NC_NC); |
83,7 → 89,42 |
return (0.674201*adc() - 294.35); |
} |
|
void top_heating() |
{ |
if (period <= top_heat_power){ |
output_low(POWER_T4); |
output_low(POWER_T5); |
} |
else{ |
output_high(POWER_T4); |
output_high(POWER_T5); |
} |
} |
|
void bottom_heating() |
{ |
|
if (period <= 2*bottom_heat_power){ |
output_low(POWER_T3); |
} |
else{ |
output_high(POWER_T3); |
} |
|
} |
|
#int_TIMER1 |
void heating_control() //rizeni topnych teles pri preteceni casovace |
{ |
|
top_heating(); |
bottom_heating(); |
|
if (period <= 200) period++; |
else period=0; |
} |
|
|
#int_TIMER2 |
void Rtc(void) //40ms |
{ |
105,6 → 146,33 |
} |
} |
|
void slope_control(float ramp, unsigned int balance) // P proporcionalni rizeni narustu teploty predpoklada periodicke volani 1x/s |
{ |
float slope_deviation; |
|
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); |
} |
else{ |
top_heat_power=0; |
bottom_heat_power=0; |
} |
|
temp_last = teplota(); |
} |
|
void level_control(float level) // P proporcionalni rizeni teploty |
{ |
|
teplota(); |
|
} |
|
|
void nullcas(struct time* time) |
{ |
disable_interrupts(INT_TIMER2); |
116,10 → 184,46 |
enable_interrupts(INT_TIMER2); |
} |
|
// start |
void main() |
void reflow_solder() |
{ |
int8 tmp; |
|
// preheat |
nullcas(&cas); |
|
do { |
slope_control(PREHEAT_SLOPE, 0); // hlida strmost predehrevu |
|
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); |
|
delay_ms(1000); |
} |
while (teplota() < SOAK_TEMP); |
|
// soak |
nullcas(&cas); |
while (cas.min*60+cas.sec <= SOAK_TIME) |
{ |
level_control(SOAK_TEMP); |
|
lcd_gotoxy(1,1); |
printf(lcd_putc,"%3.1f\21C ",teplota()); |
|
lcd_gotoxy(9,1); |
printf(lcd_putc,"%2u:%02u:%02u",cas.hod, SOAK_TIME/60 - cas.min, SOAK_TIME - cas.min*60 - cas.sec); |
delay_ms(1000); |
} |
|
// solder |
|
} |
|
|
void main() // main loop |
{ |
GeneralCpuInit(); |
PowerOff(); |
|
131,14 → 235,9 |
while(true) |
{ |
delay_ms(300); |
|
if (cas.sec != tmp){ |
tmp=cas.sec; |
lcd_gotoxy(9,1); |
printf(lcd_putc,"%2u:%02u:%02u",cas.hod,cas.min,cas.sec); |
} |
|
lcd_gotoxy(1,2); |
printf(lcd_putc,"teplota: %3.1f\21C ",teplota()); |
|
reflow_solder(); |
|
} |
} |