Skip to content

Commit

Permalink
Merge pull request #1802 from XPila/MK3
Browse files Browse the repository at this point in the history
Variable bed PWM resolution/frequency (adjusted to 5bits/32Hz)
  • Loading branch information
mkbel authored May 7, 2019
2 parents 744e482 + 85806a0 commit 8692565
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Firmware/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,9 @@ your extruder heater takes 2 minutes to hit the target on heating.
#define FAN_SOFT_PWM
#define FAN_SOFT_PWM_BITS 4 //PWM bit resolution = 4bits, freq = 62.5Hz

// Bed soft pwm
#define HEATER_BED_SOFT_PWM_BITS 5 //PWM bit resolution = 5bits, freq = 31.25Hz

// Incrementing this by 1 will double the software PWM frequency,
// affecting heaters, and the fan if FAN_SOFT_PWM is enabled.
// However, control resolution will be halved for each increment;
Expand Down
9 changes: 6 additions & 3 deletions Firmware/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1693,13 +1693,16 @@ ISR(TIMER0_COMPB_vect)
soft_pwm_2 = soft_pwm[2];
if(soft_pwm_2 > 0) WRITE(HEATER_2_PIN,1); else WRITE(HEATER_2_PIN,0);
#endif
}
#if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
soft_pwm_b = soft_pwm_bed;
if ((pwm_count & ((1 << HEATER_BED_SOFT_PWM_BITS) - 1)) == 0)
{
soft_pwm_b = soft_pwm_bed >> (7 - HEATER_BED_SOFT_PWM_BITS);
#ifndef SYSTEM_TIMER_2
if(soft_pwm_b > 0) WRITE(HEATER_BED_PIN,1); else WRITE(HEATER_BED_PIN,0);
#endif //SYSTEM_TIMER_2
#endif
}
#endif
#ifdef FAN_SOFT_PWM
if ((pwm_count & ((1 << FAN_SOFT_PWM_BITS) - 1)) == 0)
{
Expand All @@ -1722,7 +1725,7 @@ ISR(TIMER0_COMPB_vect)
if(soft_pwm_2 < pwm_count) WRITE(HEATER_2_PIN,0);
#endif
#if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
if(soft_pwm_b < pwm_count) WRITE(HEATER_BED_PIN,0);
if (soft_pwm_b < (pwm_count & ((1 << HEATER_BED_SOFT_PWM_BITS) - 1))) WRITE(HEATER_BED_PIN,0);
#endif
#ifdef FAN_SOFT_PWM
if (soft_pwm_fan < (pwm_count & ((1 << FAN_SOFT_PWM_BITS) - 1))) WRITE(FAN_PIN,0);
Expand Down

1 comment on commit 8692565

@3boysdad
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm curious about this - not a EE, but I am a HAM Radio operator - wouldn't introducing a ceramic filter in the positive power line reduce or eliminate the noise as well without this software correction? I use these periodically to remove RF noise and the building of baluns.

Please sign in to comment.