From aef613acd394d72d17cda8b431bcfcc2165c9608 Mon Sep 17 00:00:00 2001 From: Robby Candra Date: Thu, 23 Dec 2021 15:19:39 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Group=20FAST=5FPWM=5FFAN.options?= =?UTF-8?q?=20(#23331)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/Configuration.h | 3 --- Marlin/Configuration_adv.h | 29 +++++++++++++++------- Marlin/src/inc/Conditionals_post.h | 11 -------- Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h | 1 - 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index bb89bc14a3..c425746bb5 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2841,9 +2841,6 @@ // :[1,2,3,4,5,6,7,8] //#define NUM_M106_FANS 1 -// Increase the FAN PWM frequency. Removes the PWM noise but increases heating in the FET/Arduino -//#define FAST_PWM_FAN - // Use software PWM to drive the fan, as for the heaters. This uses a very low frequency // which is not as annoying as with the hardware PWM. On the other hand, if this frequency // is too low, you should also increment SOFT_PWM_SCALE. diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index e50e0cde89..3eb836ec65 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -549,18 +549,21 @@ //#define FAN_MAX_PWM 128 /** - * FAST PWM FAN Settings + * Fan Fast PWM * - * Use to change the FAST FAN PWM frequency (if enabled in Configuration.h) - * Combinations of PWM Modes, prescale values and TOP resolutions are used internally to produce a - * frequency as close as possible to the desired frequency. + * Combinations of PWM Modes, prescale values and TOP resolutions are used internally + * to produce a frequency as close as possible to the desired frequency. * - * FAST_PWM_FAN_FREQUENCY [undefined by default] + * FAST_PWM_FAN_FREQUENCY * Set this to your desired frequency. - * If left undefined this defaults to F = F_CPU/(2*255*1) - * i.e., F = 31.4kHz on 16MHz microcontrollers or F = 39.2kHz on 20MHz microcontrollers. - * These defaults are the same as with the old FAST_PWM_FAN implementation - no migration is required + * For AVR, if left undefined this defaults to F = F_CPU/(2*255*1) + * i.e., F = 31.4kHz on 16MHz microcontrollers or F = 39.2kHz on 20MHz microcontrollers. + * For non AVR, if left undefined this defaults to F = 1Khz. + * This F value is only to protect the hardware from an absence of configuration + * and not to complete it when users are not aware that the frequency must be specifically set to support the target board. + * * NOTE: Setting very low frequencies (< 10 Hz) may result in unexpected timer behavior. + * Setting very high frequencies can damage your hardware. * * USE_OCR2A_AS_TOP [undefined by default] * Boards that use TIMER2 for PWM have limitations resulting in only a few possible frequencies on TIMER2: @@ -570,9 +573,17 @@ * PWM on pin OC2A. Only use this option if you don't need PWM on 0C2A. (Check your schematic.) * USE_OCR2A_AS_TOP sacrifices duty cycle control resolution to achieve this broader range of frequencies. */ +//#define FAST_PWM_FAN // Increase the fan PWM frequency. Removes the PWM noise but increases heating in the FET/Arduino #if ENABLED(FAST_PWM_FAN) - //#define FAST_PWM_FAN_FREQUENCY 31400 + //#define FAST_PWM_FAN_FREQUENCY 31400 // Define here to override the defaults below //#define USE_OCR2A_AS_TOP + #ifndef FAST_PWM_FAN_FREQUENCY + #ifdef __AVR__ + #define FAST_PWM_FAN_FREQUENCY ((F_CPU) / (2 * 255 * 1)) + #else + #define FAST_PWM_FAN_FREQUENCY 1000U + #endif + #endif #endif /** diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 7fb8395506..95c8f7737b 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2667,17 +2667,6 @@ #error "FAN_OFF_PWM must be less than or equal to FAN_MIN_PWM." #endif -/** - * FAST PWM FAN default PWM frequency - */ -#if !defined(FAST_PWM_FAN_FREQUENCY) && ENABLED(FAST_PWM_FAN) - #ifdef __AVR__ - #define FAST_PWM_FAN_FREQUENCY ((F_CPU) / (2 * 255 * 1)) - #else - #define FAST_PWM_FAN_FREQUENCY 1000U - #endif -#endif - /** * Controller Fan Settings */ diff --git a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h index c6f1e014e0..15c6955a83 100644 --- a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h +++ b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h @@ -95,7 +95,6 @@ #define FAN_MAX_PWM 255 #else #define FAST_PWM_FAN // STM32 Variant allow TIMER2 Hardware PWM - #define FAST_PWM_FAN_FREQUENCY 31400 // This frequency allow a good range, fan starts at 3%, half noise at 50% #define FAN_MIN_PWM 5 #define FAN_MAX_PWM 255 #endif