diff --git a/config.default.h b/config.default.h index db5c6d1..8dcb1ac 100644 --- a/config.default.h +++ b/config.default.h @@ -440,6 +440,13 @@ PWM value for 'off' */ #define TH_COUNT 8 +/** \def FAST_PWM + Teacup offers two PWM frequencies, 76(61) Hz and 78000(62500) Hz on a 20(16) MHz electronics. The faster one is the default, as it's what most other firmwares do. It can make the heater MOSFETs pretty hot, though. + + Comment this option out if your MOSFETs overheat. Drawback is, in a quiet environment you might notice the heaters and your power supply humming, then. +*/ +#define FAST_PWM + /// this is the scaling of internally stored PID values. 1024L is a good value #define PID_SCALE 1024L diff --git a/config.gen3.h b/config.gen3.h index f9c5965..40480a1 100644 --- a/config.gen3.h +++ b/config.gen3.h @@ -447,6 +447,13 @@ DEFINE_TEMP_SENSOR(bed, TT_INTERCOM, 1, 0) */ #define TH_COUNT 8 +/** \def FAST_PWM + Teacup offers two PWM frequencies, 76(61) Hz and 78000(62500) Hz on a 20(16) MHz electronics. The faster one is the default, as it's what most other firmwares do. It can make the heater MOSFETs pretty hot, though. + + Comment this option out if your MOSFETs overheat. Drawback is, in a quiet environment you might notice the heaters and your power supply humming, then. +*/ +#define FAST_PWM + /// this is the scaling of internally stored PID values. 1024L is a good value #define PID_SCALE 1024L diff --git a/config.gen6.h b/config.gen6.h index 1963dc1..bbc2dc2 100644 --- a/config.gen6.h +++ b/config.gen6.h @@ -428,12 +428,19 @@ PWM value for 'off' */ #define STEP_INTERRUPT_INTERRUPTIBLE 1 -/* +/** temperature history count. This is how many temperature readings to keep in order to calculate derivative in PID loop higher values make PID derivative term more stable at the expense of reaction time */ #define TH_COUNT 8 +/** \def FAST_PWM + Teacup offers two PWM frequencies, 76(61) Hz and 78000(62500) Hz on a 20(16) MHz electronics. The faster one is the default, as it's what most other firmwares do. It can make the heater MOSFETs pretty hot, though. + + Comment this option out if your MOSFETs overheat. Drawback is, in a quiet environment you might notice the heaters and your power supply humming, then. +*/ +#define FAST_PWM + // this is the scaling of internally stored PID values. 1024L is a good value #define PID_SCALE 1024L diff --git a/config.gen7.h b/config.gen7.h index 9f804a7..977c01a 100644 --- a/config.gen7.h +++ b/config.gen7.h @@ -446,6 +446,13 @@ PWM value for 'off' */ #define TH_COUNT 8 +/** \def FAST_PWM + Teacup offers two PWM frequencies, 76(61) Hz and 78000(62500) Hz on a 20(16) MHz electronics. The faster one is the default, as it's what most other firmwares do. It can make the heater MOSFETs pretty hot, though. + + Comment this option out if your MOSFETs overheat. Drawback is, in a quiet environment you might notice the heaters and your power supply humming, then. +*/ +// #define FAST_PWM + /// this is the scaling of internally stored PID values. 1024L is a good value #define PID_SCALE 1024L diff --git a/config.ramps-v1.2.h b/config.ramps-v1.2.h index 1780a1b..421f620 100644 --- a/config.ramps-v1.2.h +++ b/config.ramps-v1.2.h @@ -440,6 +440,13 @@ PWM value for 'off' */ #define TH_COUNT 8 +/** \def FAST_PWM + Teacup offers two PWM frequencies, 76(61) Hz and 78000(62500) Hz on a 20(16) MHz electronics. The faster one is the default, as it's what most other firmwares do. It can make the heater MOSFETs pretty hot, though. + + Comment this option out if your MOSFETs overheat. Drawback is, in a quiet environment you might notice the heaters and your power supply humming, then. +*/ +#define FAST_PWM + /// this is the scaling of internally stored PID values. 1024L is a good value #define PID_SCALE 1024L diff --git a/config.ramps-v1.3.h b/config.ramps-v1.3.h index 1dda1d9..8d37bab 100644 --- a/config.ramps-v1.3.h +++ b/config.ramps-v1.3.h @@ -445,6 +445,13 @@ PWM value for 'off' */ #define TH_COUNT 8 +/** \def FAST_PWM + Teacup offers two PWM frequencies, 76(61) Hz and 78000(62500) Hz on a 20(16) MHz electronics. The faster one is the default, as it's what most other firmwares do. It can make the heater MOSFETs pretty hot, though. + + Comment this option out if your MOSFETs overheat. Drawback is, in a quiet environment you might notice the heaters and your power supply humming, then. +*/ +#define FAST_PWM + /// this is the scaling of internally stored PID values. 1024L is a good value #define PID_SCALE 1024L diff --git a/config.sanguinololu-v1.1.h b/config.sanguinololu-v1.1.h index 1156cd4..aae025b 100644 --- a/config.sanguinololu-v1.1.h +++ b/config.sanguinololu-v1.1.h @@ -444,6 +444,13 @@ PWM value for 'off' */ #define TH_COUNT 8 +/** \def FAST_PWM + Teacup offers two PWM frequencies, 76(61) Hz and 78000(62500) Hz on a 20(16) MHz electronics. The faster one is the default, as it's what most other firmwares do. It can make the heater MOSFETs pretty hot, though. + + Comment this option out if your MOSFETs overheat. Drawback is, in a quiet environment you might notice the heaters and your power supply humming, then. +*/ +#define FAST_PWM + /// this is the scaling of internally stored PID values. 1024L is a good value #define PID_SCALE 1024L diff --git a/config.sanguinololu-v1.2.h b/config.sanguinololu-v1.2.h index 404e08f..4676f03 100644 --- a/config.sanguinololu-v1.2.h +++ b/config.sanguinololu-v1.2.h @@ -444,6 +444,13 @@ PWM value for 'off' */ #define TH_COUNT 8 +/** \def FAST_PWM + Teacup offers two PWM frequencies, 76(61) Hz and 78000(62500) Hz on a 20(16) MHz electronics. The faster one is the default, as it's what most other firmwares do. It can make the heater MOSFETs pretty hot, though. + + Comment this option out if your MOSFETs overheat. Drawback is, in a quiet environment you might notice the heaters and your power supply humming, then. +*/ +#define FAST_PWM + /// this is the scaling of internally stored PID values. 1024L is a good value #define PID_SCALE 1024L diff --git a/mendel.c b/mendel.c index 3dfcdb6..efbfcd4 100644 --- a/mendel.c +++ b/mendel.c @@ -186,13 +186,29 @@ void io_init(void) { // setup PWM timers: fast PWM, no prescaler TCCR0A = MASK(WGM01) | MASK(WGM00); - TCCR0B = MASK(CS00); + // PWM frequencies in TCCR0B, see page 108 of the ATmega644 reference. + TCCR0B = MASK(CS00); // F_CPU / 256 (about 78(62.5) kHz on a 20(16) MHz chip) + //TCCR0B = MASK(CS01); // F_CPU / 256 / 8 (about 9.8(7.8) kHz) + //TCCR0B = MASK(CS00) | MASK(CS01); // F_CPU / 256 / 64 (about 1220(977) Hz) + //TCCR0B = MASK(CS02); // F_CPU / 256 / 256 (about 305(244) Hz) + #ifndef FAST_PWM + TCCR0B = MASK(CS00) | MASK(CS02); // F_CPU / 256 / 1024 (about 76(61) Hz) + #endif TIMSK0 = 0; OCR0A = 0; OCR0B = 0; TCCR2A = MASK(WGM21) | MASK(WGM20); - TCCR2B = MASK(CS20); + // PWM frequencies in TCCR2B, see page 156 of the ATmega644 reference. + TCCR2B = MASK(CS20); // F_CPU / 256 (about 78(62.5) kHz on a 20(16) MHz chip) + //TCCR2B = MASK(CS21); // F_CPU / 256 / 8 (about 9.8(7.8) kHz) + //TCCR2B = MASK(CS20) | MASK(CS21); // F_CPU / 256 / 32 (about 2.4(2.0) kHz) + //TCCR2B = MASK(CS22); // F_CPU / 256 / 64 (about 1220(977) Hz) + //TCCR2B = MASK(CS20) | MASK(CS22); // F_CPU / 256 / 128 (about 610(488) Hz) + //TCCR2B = MASK(CS21) | MASK(CS22); // F_CPU / 256 / 256 (about 305(244) Hz) + #ifndef FAST_PWM + TCCR2B = MASK(CS20) | MASK(CS21) | MASK(CS22); // F_CPU / 256 / 1024 + #endif TIMSK2 = 0; OCR2A = 0; OCR2B = 0;