|
|
|
|
@ -23,18 +23,18 @@ uint8_t setting_timeout = 0;
|
|
|
|
|
|
|
|
|
|
uint8_t adc_pos = 0;
|
|
|
|
|
uint16_t adc_sum = 0;
|
|
|
|
|
uint16_t target = 0;
|
|
|
|
|
|
|
|
|
|
uint16_t temperature = 0;
|
|
|
|
|
uint16_t target = 0;
|
|
|
|
|
uint16_t temperature = 0; // all temperatures are in tenth of degrees celsius
|
|
|
|
|
|
|
|
|
|
uint8_t heat_output = 0;
|
|
|
|
|
|
|
|
|
|
uint8_t heat_pwm = 0;
|
|
|
|
|
uint8_t heat_on[2] = {0, 128};
|
|
|
|
|
uint8_t heat_off[2] = {128, 0};
|
|
|
|
|
uint8_t heat_pwm = 0; // softpwm counter
|
|
|
|
|
uint8_t heat_power = 0; // requested heating power; 0..255
|
|
|
|
|
//uint8_t heat_on[2] = {0, 128};
|
|
|
|
|
//uint8_t heat_off[2] = {128, 0};
|
|
|
|
|
|
|
|
|
|
uint8_t input_state = 0;
|
|
|
|
|
uint8_t dev_state = 0;
|
|
|
|
|
uint8_t dev_state = 0; // whether the device is on or off
|
|
|
|
|
|
|
|
|
|
#define TEN_SECONDS 256
|
|
|
|
|
uint16_t startup = TEN_SECONDS;
|
|
|
|
|
@ -62,10 +62,24 @@ ISR(TIM1_OVF_vect)
|
|
|
|
|
|
|
|
|
|
/* incremtening softpwm, toggling output if needed */
|
|
|
|
|
heat_pwm++;
|
|
|
|
|
if(heat_pwm == heat_on[0]) {PORTB |= (1 << FET0_PIN);}
|
|
|
|
|
if(heat_pwm <= heat_power)
|
|
|
|
|
{
|
|
|
|
|
PORTB |= (1 << FET0_PIN);
|
|
|
|
|
} else {
|
|
|
|
|
PORTB &= ~(1 << FET0_PIN);
|
|
|
|
|
}
|
|
|
|
|
if( ((heat_pwm + 128)&0xff) <= heat_power )
|
|
|
|
|
{
|
|
|
|
|
PORTB |= (1 << FET1_PIN);
|
|
|
|
|
} else {
|
|
|
|
|
PORTB &= ~(1 << FET1_PIN);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* if(heat_pwm == heat_on[0]) {PORTB |= (1 << FET0_PIN);}
|
|
|
|
|
if(heat_pwm == heat_off[0]) {PORTB &= ~(1 << FET0_PIN);}
|
|
|
|
|
if(heat_pwm == heat_on[1]) {PORTB |= (1 << FET1_PIN);}
|
|
|
|
|
if(heat_pwm == heat_off[1]) {PORTB &= ~(1 << FET1_PIN);}
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ISR(PCINT0_vect)
|
|
|
|
|
@ -249,16 +263,12 @@ int main(void)
|
|
|
|
|
adc_pos = 0;
|
|
|
|
|
if(1)//dev_state)
|
|
|
|
|
{
|
|
|
|
|
heat_output = control_output();
|
|
|
|
|
if(startup && heat_output > 96) {heat_output = 96;}
|
|
|
|
|
heat_on[0] = 0;
|
|
|
|
|
heat_on[1] = 128;
|
|
|
|
|
heat_off[0] = heat_output;
|
|
|
|
|
heat_off[1] = heat_output + 128;
|
|
|
|
|
heat_power = control_output();
|
|
|
|
|
if(startup && heat_power > 96) {heat_power = 96;}
|
|
|
|
|
}
|
|
|
|
|
/*else
|
|
|
|
|
{
|
|
|
|
|
heat_on[0] = heat_on[1] = heat_off[0] = heat_off[1] = 0;
|
|
|
|
|
heat_power = 0;
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|