diff options
author | Ben V. Brown <[email protected]> | 2024-06-08 17:34:20 +1000 |
---|---|---|
committer | GitHub <[email protected]> | 2024-06-08 17:34:20 +1000 |
commit | e925037988ebbe94051f00ae85a9890e798a573c (patch) | |
tree | fe7750fbbeb8b6526cd66638596433a872833a79 /source/Core | |
parent | 14b92cde08359d4efec6e426b08c7ac7b9bee61d (diff) | |
download | IronOS-e925037988ebbe94051f00ae85a9890e798a573c.tar.gz IronOS-e925037988ebbe94051f00ae85a9890e798a573c.zip |
Sequre Faster PWM (#1926)
* 4x faster PWM
* Add light filter to displayed temp
Diffstat (limited to 'source/Core')
-rw-r--r-- | source/Core/BSP/Sequre_S60/BSP.cpp | 2 | ||||
-rw-r--r-- | source/Core/BSP/Sequre_S60/Setup.cpp | 15 | ||||
-rw-r--r-- | source/Core/BSP/Sequre_S60/configuration.h | 6 |
3 files changed, 11 insertions, 12 deletions
diff --git a/source/Core/BSP/Sequre_S60/BSP.cpp b/source/Core/BSP/Sequre_S60/BSP.cpp index b32f239e..ebf46e7f 100644 --- a/source/Core/BSP/Sequre_S60/BSP.cpp +++ b/source/Core/BSP/Sequre_S60/BSP.cpp @@ -105,7 +105,7 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) { if (PWMSafetyTimer == 0) {
htim4.Instance->CCR3 = 0;
} else {
- htim4.Instance->CCR3 = pendingPWM;
+ htim4.Instance->CCR3 = pendingPWM / 4;
}
} else if (htim->Instance == TIM1) {
// STM uses this for internal functions as a counter for timeouts
diff --git a/source/Core/BSP/Sequre_S60/Setup.cpp b/source/Core/BSP/Sequre_S60/Setup.cpp index 87a383f1..a5d5845e 100644 --- a/source/Core/BSP/Sequre_S60/Setup.cpp +++ b/source/Core/BSP/Sequre_S60/Setup.cpp @@ -57,7 +57,7 @@ void Setup_HAL() { GPIO_InitStruct.Pin = MOVEMENT_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_PULLDOWN; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; // We would like sharp rising edges + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(MOVEMENT_GPIO_Port, &GPIO_InitStruct); } } @@ -254,23 +254,20 @@ static void MX_IWDG_Init(void) { static void MX_TIM4_Init(void) { /* - * We use the channel 1 to trigger the ADC at end of PWM period - * And we use the channel 4 as the PWM modulation source using Interrupts + * On Sequre devies we run the output PWM as fast as possible due to the low tip resistance + no inductor for filtering. + * So we run it as fast as we can and hope that the caps filter out the current spikes. * */ TIM_ClockConfigTypeDef sClockSourceConfig; TIM_MasterConfigTypeDef sMasterConfig; TIM_OC_InitTypeDef sConfigOC; memset(&sConfigOC, 0, sizeof(sConfigOC)); - // Timer 2 is fairly slow as its being used to run the PWM and trigger the ADC - // in the PWM off time. + htim4.Instance = TIM4; // dummy value, will be reconfigured by BSPInit() - htim4.Init.Prescaler = 10; // 2 MHz timer clock/1000 = 2 kHz tick rate + htim4.Init.Prescaler = 10; // 2 MHz timer clock/10 = 200 kHz tick rate - // pwm out is 10k from tim3, we want to run our PWM at around 10hz or slower on the output stage - // These values give a rate of around 3.5 Hz for "fast" mode and 1.84 Hz for "slow" htim4.Init.CounterMode = TIM_COUNTERMODE_UP; - htim4.Init.Period = 255; + htim4.Init.Period = 64; htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; // 8 MHz (x2 APB1) before divide htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; diff --git a/source/Core/BSP/Sequre_S60/configuration.h b/source/Core/BSP/Sequre_S60/configuration.h index 008ce6b5..73568fda 100644 --- a/source/Core/BSP/Sequre_S60/configuration.h +++ b/source/Core/BSP/Sequre_S60/configuration.h @@ -148,7 +148,7 @@ #define HARDWARE_MAX_WATTAGE_X10 600 -#define TIP_THERMAL_MASS 8 // X10 watts to raise 1 deg C in 1 second +#define TIP_THERMAL_MASS 10 // X10 watts to raise 1 deg C in 1 second #define TIP_THERMAL_INERTIA 128 // We use a large inertia value to smooth out the drive to the tip since its stupidly sensitive #define TIP_RESISTANCE 20 //(actually 2.5 ish but we need to be more conservative on pwm'ing watt limit) x10 ohms @@ -162,6 +162,7 @@ #define TEMP_NTC #define I2C_SOFT_BUS_2 // For now we are doing software I2C to get around hardware chip issues #define OLED_I2CBB2 +#define FILTER_DISPLAYED_TIP_TEMP 4 // Filtering for GUI display #define MODEL_HAS_DCDC // We dont have DC/DC but have reallly fast PWM that gets us roughly the same place #endif /* S60 */ @@ -179,7 +180,7 @@ #define HARDWARE_MAX_WATTAGE_X10 600 -#define TIP_THERMAL_MASS 8 // X10 watts to raise 1 deg C in 1 second +#define TIP_THERMAL_MASS 10 // X10 watts to raise 1 deg C in 1 second #define TIP_THERMAL_INERTIA 128 // We use a large inertia value to smooth out the drive to the tip since its stupidly sensitive #define TIP_RESISTANCE 20 //(actually 2.5 ish but we need to be more conservative on pwm'ing watt limit) x10 ohms @@ -193,6 +194,7 @@ #define TEMP_NTC #define I2C_SOFT_BUS_2 // For now we are doing software I2C to get around hardware chip issues #define OLED_I2CBB2 +#define FILTER_DISPLAYED_TIP_TEMP 4 // Filtering for GUI display #define MODEL_HAS_DCDC // We dont have DC/DC but have reallly fast PWM that gets us roughly the same place #endif /* S60P */ |