-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
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
M919 - Get or Set Trinamic Chopper Times #23333
Conversation
I had a quick look at the code. If I didn't overlook anything, it checks if set values are in range, but does not handle Looking at Marlin and RepRap G-codes, M919 seems to be unused and close to other TMC-related G-codes like M911, M914 and M915. Maybe it would be a suitable G-code identifier. |
The variables are uint8_t and int8_t, if there is a parameter that is not given the actual value is 0 not null. |
I did a test as you suggested and it does not crash. Here you can find some images. Is actually writing the default CHOPPER_TIMING from Configuration_adv.h, in my case is static constexpr chopper_timing_t chopper_timing = CHOPPER_TIMING;
time_off = chopper_timing.toff;
hysteresis_end = chopper_timing.hend;
hysteresis_start = chopper_timing.hstrt; |
Conceptually this should be just fine and a good addition but I think the code quality can be improved. |
Changed parameter |
I think the 4 should be 6. Can you please check? #if LINEAR_AXES >= 4
case K_AXIS:
#if AXIS_IS_TMC(K)
TMC_SET_CHOPPER_TIME(K);
#endif
break;
#endif |
Without changing the code, I just fetched the latest changes to my fork and now for some reason the automatic checks are failing... |
Network issue
|
@teemuatlut |
@thinkyhead great work I noticed that you changed the axis letters I, J, K to U, V, W
This description of the parameters does not match with the following code in M919. #if LINEAR_AXES >= 4
case I_AXIS:
#if AXIS_IS_TMC(I)
TMC_SET_CHOPPER_TIME(I);
#endif
break;
#endif
#if LINEAR_AXES >= 5
case J_AXIS:
#if AXIS_IS_TMC(J)
TMC_SET_CHOPPER_TIME(J);
#endif
break;
#endif
#if LINEAR_AXES >= 6
case K_AXIS:
#if AXIS_IS_TMC(K)
TMC_SET_CHOPPER_TIME(K);
#endif
break;
#endif |
I've tweaked the parameter behavior a bit, so that if you leave out the "I" parameter then all stepper drivers for the flagged axes will be updated. And, if you leave out the "T" parameter when there is an "E" parameter, then all E stepper drivers will be updated. The previous behavior was kind of inconsistent, and not very well documented. |
Internally, the extra axes are referred to as I, J, K. However, the default G-code parameters for these axes are #if HAS_CLASSIC_JERK && (AXIS4_NAME == 'J' || AXIS5_NAME == 'J' || AXIS6_NAME == 'J')
#error "Can't set_max_jerk for 'J' axis because 'J' is used for Junction Deviation."
#endif |
I noticed that in Configuration_adv.h CHOPPER_TIMING can be overwritten for each axis by: I think would be more correct to use those values for the ct initialization depending on the i (axis) values |
Yeah, I was gonna say…. |
I tried to "collect" all default chopper times in an array int ct_array[] = {CHOPPER_TIMING, CHOPPER_TIMING_X, CHOPPER_TIMING_X2, etc}, but they are not all necessarily defined in Configuration_adv.h |
@thinkyhead M919 was thought to temporarily fine tune the chopper times for each axis independent. M906 with the altered behavior can cause hardware damage in case the user have different drivers & motors for the Z, Z2 and Z3 axis. |
It was intended that |
This PR is somehow corrupted and can't be edited, so it has been recreated at the PR linked above. |
This pull request adds the possibility to temporarily overwrites the TMC chopper times using a gcode command:
e.g.
M919 X Y O3 V4 S1
This means update chopper times for X and Y axis
O3 - set time_off = 3
V4 - set hysteresis_end = 4
S1 - set hysteresis_start = 1
in case there is no parameter e.g. M9999 it reports the current chopper times for all axis
Requirements
TMC drive.
I test it only with TMC5160
Benefits
With this option the user can tune the chopper times using gcode commands and when he is happy with the results he can write the tuned values for time_off, hysteresis_end and hysteresis_start into the firmware Configuration_adv.h
In the future this functionality can be improved e.g. by saving/changing these values in EEPROM.
Configurations
I test it with TMC5160, SPI
config_magni3D.zip
Related Issues
#23252