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

[FR] GCODE to send CHOPPER_TIMING {off_time, hysteresis_end, hysteresis_start} #23252

Closed
magnificu opened this issue Dec 2, 2021 · 7 comments
Labels

Comments

@magnificu
Copy link

magnificu commented Dec 2, 2021

Is your feature request related to a problem? Please describe.

I have noise/vibration with the stepper motors and it would be great to send the CHOPPER_TIMING via GCODE so that I can check on the oscilloscope the distortions of the sin wave.

Are you looking for hardware support?

No response

Describe the feature you want

In order to optimize quickly the CHOPPER_TIMING for different stepper drivers and motors it would be great to be able to send the CHOPPER_TIMING {blank time TBL, off_time, hysteresis_end, hysteresis_start} via GCODE

Is there any easy way to implement it? Where should I look/start?

Hardware:
SKR2, TMC5160

Additional context

No response

@oliver-eifler
Copy link
Contributor

oliver-eifler commented Dec 3, 2021

you have to use tmc driver class functions to set/changes these values on the fly
blank_time(config.blank_time);
toff(config.off_time);
etc.
have a look at tmcstepper lib examples
https://github.com/teemuatlut/TMCStepper/tree/master/examples/Calibrate_spreadCycle

and class TMCMarlin in marlin source
https://github.com/MarlinFirmware/Marlin/blob/bugfix-2.0.x/Marlin/src/feature/tmc_util.h
I would follow and clone/adapt the rms_current() and rms_current(const uint16_t mA, const float mult) functions of class TMCMarlin to get/set other values

@magnificu
Copy link
Author

magnificu commented Dec 3, 2021

Thank you for your feedback.
I will give it a try, even if this seems to be complex.

@oliver-eifler
Copy link
Contributor

analyze void GcodeSuite::M906() function in Marlin\src\gcode\feature\trinamic\M906.cpp
it calls rms_current(...) setter from TMCMarlin for every Axis according to parameters of m-code M906

you have to extend the TMCMarlin class with functions to get/set the chopper values

As this part marlin uses C++ classes and C++ Templates you'll need some knowledge how C++ works - no complicated things like STL (standard template library) but the basics

@magnificu
Copy link
Author

magnificu commented Dec 10, 2021

I have a first working draft of the code and I am doing some cleanups. (I test it only for TMC5160)
Can someone instruct me how can I prepare and send a commit with the code?
Which gcode number I can use for this? At the moment I am using M9999.
Is there any rule on setting the gcode parameters?

The new gcode works like this e.g.:
M9999
read all chopper times for all axis

e.g. set chopper times for X axis
M9999 X O3 N6 S8
time_off=3
hysteresis_end=6
hysteresis_start=8

e.g. set Z2 chopper times
M9999 I1 Z O3 N6 S8

e.g. set E0 chopper times
M9999 I0 E O3 N6 S8

It is possible to set the same chopper times for multiple axis e.g. M9999 X Y Z O3 N6 S8

For tuning the chopper times now a gcode can be created to move the axis at different speeds and test with different chopper times.

@XDA-Bam
Copy link
Contributor

XDA-Bam commented Dec 18, 2021

I have a first working draft of the code and I am doing some cleanups. (I test it only for TMC5160) Can someone instruct me how can I prepare and send a commit with the code?

You have to fork MarlinFirmware/Marlin. Then you create a new branch based on the most recent bugfix-2.0.x. In that branch, you apply all you changes / commits and push them. Then, you login to github.com and navigate to your forked Marlin repository - on the top the main repository page, there should be a message in the form of "You pushed XYZ to magnificu/Marlin. Do you want to create a pull request?". Click on the corresponding button to create that pull request. Make sure you select "bugfix-2.0.x" as remote branch in the next step and submit.

@magnificu
Copy link
Author

@github-actions
Copy link

github-actions bot commented Mar 6, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants