Skip to content

Add spindle acceleration #27759

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

Merged

Conversation

DerAndere1
Copy link
Contributor

Description

Instantaneous changes to the spindle PWM duty cycle during M3/M4 commands can cause voltage fluctuations and reconfiguration of stepper drivers. This PR adds the setting DEFAULT_ACCELERATION_SPINDLE. When this option is enabled together with SPINDLE_LASER_USE_PWM, the spindle is accelerated slowly.

Changes that would allow setting spindle acceleration at runtime via M201 T0 are not part of this PR because that would require merging of PR #27614

Requirements

SPINDLE_FEATURE, SPINDLE_LASER_USE_PWM

Benefits

linear spindle acceleration instead of instantaneous PWM duty cycle changes.
fixes #27727

Configurations

This PR contains a seperate commit that updates the config. Default behaviour remainsunchanged (instantaneous PWM change). For testing the new behaviour, enable and set DEFAULT_ACCELERATION_SPINDLE. Also enable SPINDLE_FEATURE, SPINDLE_LASER_USE_PWM

Related Issues

#27727

@DerAndere1 DerAndere1 marked this pull request as draft March 25, 2025 21:32
@DerAndere1 DerAndere1 force-pushed the spindle_acceleration branch 2 times, most recently from 80aa324 to e2b3412 Compare March 25, 2025 23:22
@DerAndere1 DerAndere1 force-pushed the spindle_acceleration branch from e2b3412 to 3391e9d Compare March 25, 2025 23:36
buergi
buergi previously requested changes Mar 27, 2025
Copy link

@buergi buergi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your implementation. Unfortunately it does not work like that, the most problematic part is the while loop inside _set_ocr() which blocks the whole firmware. Maybe something like the planner is needed to perform periodic update of the spindle speed.

@thinkyhead thinkyhead force-pushed the bugfix-2.1.x branch 2 times, most recently from 4354891 to efa1758 Compare March 28, 2025 01:57
@thinkyhead thinkyhead force-pushed the spindle_acceleration branch from 5c444b8 to 51af38a Compare March 28, 2025 05:28
@DerAndere1 DerAndere1 force-pushed the spindle_acceleration branch from 740236e to 6429897 Compare March 28, 2025 08:42
@DerAndere1 DerAndere1 force-pushed the spindle_acceleration branch from be7d395 to a6baca6 Compare March 28, 2025 09:31
@DerAndere1
Copy link
Contributor Author

Thanks for the help with this one, guys. I will keep this in draft mode until it was tested on hardware.

@thinkyhead thinkyhead force-pushed the spindle_acceleration branch from 034ed5d to 23eb1c8 Compare April 14, 2025 21:09
thinkyhead added a commit to MarlinFirmware/Configurations that referenced this pull request Apr 14, 2025
@thinkyhead thinkyhead marked this pull request as ready for review April 14, 2025 21:49
@thinkyhead thinkyhead merged commit b5d7b4a into MarlinFirmware:bugfix-2.1.x Apr 14, 2025
66 checks passed
EvilGremlin pushed a commit to EvilGremlin/Marlin that referenced this pull request May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Starting spindle causes stepper driver to reset
3 participants