Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unstable temperature on HC32 #27085

Merged

Conversation

shadow578
Copy link
Contributor

Description

When using MPCTEMP on HC32-based boards and setting the hotend temperature high (240C), strong oscillations of the hotend temperature occur.

While i'm not quite sure what causes this, i've found that reducing the ADC's operating frequency (PCLK2) to 25MHz eliminates the issue.

Other findings:

  • enabling hardware averaging of the ADC channels dampens the oscillations slightly
  • increasing or decreasing the sampling times does not affect oscillations
  • using HAL_ADC_RESOLUTION of 12 bit while PCLK2=50MHz makes the oscillations stronger than 10 bit, but with PCLK2=25MHz 12 bit yields slightly more stable temperatures
  • with 8-bit adc, marlin fails to boot

All testing was done over ~5 Minutes at 240C, followed by ~5 Minutes at 220C, with a fresh MPC autotune before each test.

See Fig. A and Fig. B for before and after.

Requirements

HC32-based mainboard with MPCTEMP enabled.

Benefits

Makes hotend temperature much more stable.

Configurations

N/A

Related Issues

N/A

Screenshots

temp-no-fix_annotated temp-with-fix_annotated
Fig. A: Hotend temperature oscillations at 240C, on current bugfix-2.1.x branch Fig. B: Stable hotend temperatures on this PR's branch

@thinkyhead thinkyhead added PR: Bug Fix T: HAL & APIs Topic related to the HAL and internal APIs. labels May 15, 2024
@thinkyhead thinkyhead merged commit 6eedeae into MarlinFirmware:bugfix-2.1.x May 15, 2024
62 checks passed
@shadow578 shadow578 deleted the fix/unstable-temperature branch May 16, 2024 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Bug Fix T: HAL & APIs Topic related to the HAL and internal APIs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants