Make fast PWM optional.

In some cases the heater switching MOSFETs overheat and using a lower
PWM frequency is advised. See also:
http://reprap.org/wiki/Gen7_Research#Heat_vs._PWM_Frequency
This commit is contained in:
Markus Hitter 2012-03-03 16:53:57 +01:00
parent 56258a3908
commit 86e20580f8
9 changed files with 75 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;