@ -1221,20 +1221,41 @@ ISR(TIMER0_COMPB_vect)
static unsigned char temp_state = 10 ;
static unsigned char pwm_count = ( 1 < < SOFT_PWM_SCALE ) ;
static unsigned char soft_pwm_0 ;
# ifdef SLOW_PWM_HEATERS
static unsigned char slow_pwm_count = 0 ;
static unsigned char state_heater_0 = 0 ;
static unsigned char state_timer_heater_0 = 0 ;
# endif
# if (EXTRUDERS > 1) || defined(HEATERS_PARALLEL)
static unsigned char soft_pwm_1 ;
# ifdef SLOW_PWM_HEATERS
static unsigned char state_heater_1 = 0 ;
static unsigned char state_timer_heater_1 = 0 ;
# endif
# endif
# if EXTRUDERS > 2
static unsigned char soft_pwm_2 ;
# ifdef SLOW_PWM_HEATERS
static unsigned char state_heater_2 = 0 ;
static unsigned char state_timer_heater_2 = 0 ;
# endif
# endif
# if HEATER_BED_PIN > -1
static unsigned char soft_pwm_b ;
# ifdef SLOW_PWM_HEATERS
static unsigned char state_heater_b = 0 ;
static unsigned char state_timer_heater_b = 0 ;
# endif
# endif
# if defined(FILWIDTH_PIN) &&(FILWIDTH_PIN > -1)
static unsigned long raw_filwidth_value = 0 ; //added for filament width sensor
# endif
# ifndef SLOW_PWM_HEATERS
/*
* standard PWM modulation
*/
if ( pwm_count = = 0 ) {
soft_pwm_0 = soft_pwm [ 0 ] ;
if ( soft_pwm_0 > 0 ) {
@ -1283,6 +1304,228 @@ ISR(TIMER0_COMPB_vect)
pwm_count + = ( 1 < < SOFT_PWM_SCALE ) ;
pwm_count & = 0x7f ;
# else //ifndef SLOW_PWM_HEATERS
/*
* SLOW PWM HEATERS
*
* for heaters drived by relay
*/
# ifndef MIN_STATE_TIME
# define MIN_STATE_TIME 16 // MIN_STATE_TIME * 65.5 = time in milliseconds
# endif
if ( slow_pwm_count = = 0 ) {
// EXTRUDER 0
soft_pwm_0 = soft_pwm [ 0 ] ;
if ( soft_pwm_0 > 0 ) {
// turn ON heather only if the minimum time is up
if ( state_timer_heater_0 = = 0 ) {
// if change state set timer
if ( state_heater_0 = = 0 ) {
state_timer_heater_0 = MIN_STATE_TIME ;
}
state_heater_0 = 1 ;
WRITE ( HEATER_0_PIN , 1 ) ;
# ifdef HEATERS_PARALLEL
WRITE ( HEATER_1_PIN , 1 ) ;
# endif
}
} else {
// turn OFF heather only if the minimum time is up
if ( state_timer_heater_0 = = 0 ) {
// if change state set timer
if ( state_heater_0 = = 1 ) {
state_timer_heater_0 = MIN_STATE_TIME ;
}
state_heater_0 = 0 ;
WRITE ( HEATER_0_PIN , 0 ) ;
# ifdef HEATERS_PARALLEL
WRITE ( HEATER_1_PIN , 0 ) ;
# endif
}
}
# if EXTRUDERS > 1
// EXTRUDER 1
soft_pwm_1 = soft_pwm [ 1 ] ;
if ( soft_pwm_1 > 0 ) {
// turn ON heather only if the minimum time is up
if ( state_timer_heater_1 = = 0 ) {
// if change state set timer
if ( state_heater_1 = = 0 ) {
state_timer_heater_1 = MIN_STATE_TIME ;
}
state_heater_1 = 1 ;
WRITE ( HEATER_1_PIN , 1 ) ;
}
} else {
// turn OFF heather only if the minimum time is up
if ( state_timer_heater_1 = = 0 ) {
// if change state set timer
if ( state_heater_1 = = 1 ) {
state_timer_heater_1 = MIN_STATE_TIME ;
}
state_heater_1 = 0 ;
WRITE ( HEATER_1_PIN , 0 ) ;
}
}
# endif
# if EXTRUDERS > 2
// EXTRUDER 2
soft_pwm_2 = soft_pwm [ 2 ] ;
if ( soft_pwm_2 > 0 ) {
// turn ON heather only if the minimum time is up
if ( state_timer_heater_2 = = 0 ) {
// if change state set timer
if ( state_heater_2 = = 0 ) {
state_timer_heater_2 = MIN_STATE_TIME ;
}
state_heater_2 = 1 ;
WRITE ( HEATER_2_PIN , 1 ) ;
}
} else {
// turn OFF heather only if the minimum time is up
if ( state_timer_heater_2 = = 0 ) {
// if change state set timer
if ( state_heater_2 = = 1 ) {
state_timer_heater_2 = MIN_STATE_TIME ;
}
state_heater_2 = 0 ;
WRITE ( HEATER_2_PIN , 0 ) ;
}
}
# endif
# if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
// BED
soft_pwm_b = soft_pwm_bed ;
if ( soft_pwm_b > 0 ) {
// turn ON heather only if the minimum time is up
if ( state_timer_heater_b = = 0 ) {
// if change state set timer
if ( state_heater_b = = 0 ) {
state_timer_heater_b = MIN_STATE_TIME ;
}
state_heater_b = 1 ;
WRITE ( HEATER_BED_PIN , 1 ) ;
}
} else {
// turn OFF heather only if the minimum time is up
if ( state_timer_heater_b = = 0 ) {
// if change state set timer
if ( state_heater_b = = 1 ) {
state_timer_heater_b = MIN_STATE_TIME ;
}
state_heater_b = 0 ;
WRITE ( HEATER_BED_PIN , 0 ) ;
}
}
# endif
} // if (slow_pwm_count == 0)
// EXTRUDER 0
if ( soft_pwm_0 < slow_pwm_count ) {
// turn OFF heather only if the minimum time is up
if ( state_timer_heater_0 = = 0 ) {
// if change state set timer
if ( state_heater_0 = = 1 ) {
state_timer_heater_0 = MIN_STATE_TIME ;
}
state_heater_0 = 0 ;
WRITE ( HEATER_0_PIN , 0 ) ;
# ifdef HEATERS_PARALLEL
WRITE ( HEATER_1_PIN , 0 ) ;
# endif
}
}
# if EXTRUDERS > 1
// EXTRUDER 1
if ( soft_pwm_1 < slow_pwm_count ) {
// turn OFF heather only if the minimum time is up
if ( state_timer_heater_1 = = 0 ) {
// if change state set timer
if ( state_heater_1 = = 1 ) {
state_timer_heater_1 = MIN_STATE_TIME ;
}
state_heater_1 = 0 ;
WRITE ( HEATER_1_PIN , 0 ) ;
}
}
# endif
# if EXTRUDERS > 2
// EXTRUDER 2
if ( soft_pwm_2 < slow_pwm_count ) {
// turn OFF heather only if the minimum time is up
if ( state_timer_heater_2 = = 0 ) {
// if change state set timer
if ( state_heater_2 = = 1 ) {
state_timer_heater_2 = MIN_STATE_TIME ;
}
state_heater_2 = 0 ;
WRITE ( HEATER_2_PIN , 0 ) ;
}
}
# endif
# if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
// BED
if ( soft_pwm_b < slow_pwm_count ) {
// turn OFF heather only if the minimum time is up
if ( state_timer_heater_b = = 0 ) {
// if change state set timer
if ( state_heater_b = = 1 ) {
state_timer_heater_b = MIN_STATE_TIME ;
}
state_heater_b = 0 ;
WRITE ( HEATER_BED_PIN , 0 ) ;
}
}
# endif
# ifdef FAN_SOFT_PWM
if ( pwm_count = = 0 ) {
soft_pwm_fan = fanSpeedSoftPwm / 2 ;
if ( soft_pwm_fan > 0 ) WRITE ( FAN_PIN , 1 ) ; else WRITE ( FAN_PIN , 0 ) ;
}
if ( soft_pwm_fan < pwm_count ) WRITE ( FAN_PIN , 0 ) ;
# endif
pwm_count + = ( 1 < < SOFT_PWM_SCALE ) ;
pwm_count & = 0x7f ;
// increment slow_pwm_count only every 64 pwm_count circa 65.5ms
if ( ( pwm_count % 64 ) = = 0 ) {
slow_pwm_count + + ;
slow_pwm_count & = 0x7f ;
// Extruder 0
if ( state_timer_heater_0 > 0 ) {
state_timer_heater_0 - - ;
}
# if EXTRUDERS > 1
// Extruder 1
if ( state_timer_heater_1 > 0 )
state_timer_heater_1 - - ;
# endif
# if EXTRUDERS > 2
// Extruder 2
if ( state_timer_heater_2 > 0 )
state_timer_heater_2 - - ;
# endif
# if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
// Bed
if ( state_timer_heater_b > 0 )
state_timer_heater_b - - ;
# endif
} //if ((pwm_count % 64) == 0) {
# endif //ifndef SLOW_PWM_HEATERS
switch ( temp_state ) {
case 0 : // Prepare TEMP_0
# if defined(TEMP_0_PIN) && (TEMP_0_PIN > -1)