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

M919 - Get or Set Trinamic Chopper Times #23333

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
489d838
add M9999
magnificu Dec 21, 2021
1bda6e5
M9999 code clean up
magnificu Dec 21, 2021
3712c61
M9999 code clean up
magnificu Dec 22, 2021
1dd1874
Merge branch 'MarlinFirmware:bugfix-2.0.x' into bugfix-2.0.x
magnificu Dec 22, 2021
9b2fdfd
extend functionality for TMC 2208, 2209, 2660
magnificu Dec 22, 2021
c3a67e2
Merge branch 'bugfix-2.0.x' of https://github.com/magnificu/Marlin in…
magnificu Dec 22, 2021
8a5c5ef
use M919 gcode instead of M9999
magnificu Dec 22, 2021
3ae201f
Merge branch 'MarlinFirmware:bugfix-2.0.x' into bugfix-2.0.x
magnificu Dec 23, 2021
4b4b400
corrections
thinkyhead Dec 23, 2021
b8f34a9
add src filter
thinkyhead Dec 23, 2021
68294d1
inline hints
thinkyhead Dec 23, 2021
f8b962b
Merge branch 'MarlinFirmware:bugfix-2.0.x' into bugfix-2.0.x
magnificu Dec 23, 2021
35519cc
fix typo
thinkyhead Dec 24, 2021
c8f7c55
Merge branch 'MarlinFirmware:bugfix-2.0.x' into bugfix-2.0.x
magnificu Dec 24, 2021
d47cfbf
V before S as in Configuration_adv.h
magnificu Dec 24, 2021
bf9a57d
Merge branch 'MarlinFirmware:bugfix-2.0.x' into bugfix-2.0.x
magnificu Dec 26, 2021
8e73d80
Merge branch 'MarlinFirmware:bugfix-2.0.x' into bugfix-2.0.x
magnificu Dec 27, 2021
52b50a9
Simplify M919
thinkyhead Dec 28, 2021
f6e76fb
simplify set_chopper_times
thinkyhead Dec 28, 2021
bb63e79
Relocate tmc functions
thinkyhead Dec 28, 2021
4312459
V => P
thinkyhead Dec 28, 2021
4058373
Alter 'I' and 'T' behavior
thinkyhead Dec 28, 2021
cef37bc
ibid.
thinkyhead Dec 28, 2021
01b4d0b
UVW => ...
thinkyhead Dec 28, 2021
874fd76
Merge 'bugfix-2.0.x' into pr/23333
thinkyhead Dec 28, 2021
3ea3d0d
sp
thinkyhead Dec 28, 2021
9e19312
alert on collision
thinkyhead Dec 28, 2021
e067096
Merge 'bugfix-2.0.x' into pr/23333
thinkyhead Dec 28, 2021
0054b38
Merge branch 'MarlinFirmware:bugfix-2.0.x' into bugfix-2.0.x
magnificu Dec 29, 2021
3ecb85b
separate default axis chopper_times
magnificu Dec 29, 2021
8578655
correct default chopper index behaviour
magnificu Dec 29, 2021
56b7991
Revert "correct default chopper index behaviour"
magnificu Dec 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 34 additions & 10 deletions Marlin/src/feature/tmc_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,17 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
inline bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); }
#endif

inline void set_chopper_times(const chopper_timing_t &ct) {
TMC::toff(ct.toff);
TMC::hysteresis_end(ct.hend);
TMC::hysteresis_start(ct.hstrt);
}

#if ENABLED(HYBRID_THRESHOLD)
uint32_t get_pwm_thrs() {
inline uint32_t get_pwm_thrs() {
thinkyhead marked this conversation as resolved.
Show resolved Hide resolved
return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
}
void set_pwm_thrs(const uint32_t thrs) {
inline void set_pwm_thrs(const uint32_t thrs) {
TMC::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID]));
TERN_(HAS_LCD_MENU, this->stored.hybrid_thrs = thrs);
}
Expand Down Expand Up @@ -166,7 +172,7 @@ class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
TMC2208Stepper(RX, TX, RS)
{}

uint16_t rms_current() { return TMC2208Stepper::rms_current(); }
inline uint16_t rms_current() { return TMC2208Stepper::rms_current(); }
inline void rms_current(const uint16_t mA) {
this->val_mA = mA;
TMC2208Stepper::rms_current(mA);
Expand All @@ -185,11 +191,17 @@ class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
inline bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); }
#endif

inline void set_chopper_times(const chopper_timing_t &ct) {
TMC2208Stepper::toff(ct.toff);
TMC2208Stepper::hysteresis_end(ct.hend);
TMC2208Stepper::hysteresis_start(ct.hstrt);
}

#if ENABLED(HYBRID_THRESHOLD)
uint32_t get_pwm_thrs() {
inline uint32_t get_pwm_thrs() {
return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
}
void set_pwm_thrs(const uint32_t thrs) {
inline void set_pwm_thrs(const uint32_t thrs) {
TMC2208Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID]));
TERN_(HAS_LCD_MENU, this->stored.hybrid_thrs = thrs);
}
Expand All @@ -213,8 +225,8 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
TMCMarlin(const uint16_t RX, const uint16_t TX, const float RS, const uint8_t addr) :
TMC2209Stepper(RX, TX, RS, addr)
{}
uint8_t get_address() { return slave_address; }
uint16_t rms_current() { return TMC2209Stepper::rms_current(); }
inline uint8_t get_address() { return slave_address; }
inline uint16_t rms_current() { return TMC2209Stepper::rms_current(); }
inline void rms_current(const uint16_t mA) {
this->val_mA = mA;
TMC2209Stepper::rms_current(mA);
Expand All @@ -233,11 +245,17 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
inline bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); }
#endif

inline void set_chopper_times(const chopper_timing_t &ct) {
TMC2209Stepper::toff(ct.toff);
TMC2209Stepper::hysteresis_end(ct.hend);
TMC2209Stepper::hysteresis_start(ct.hstrt);
}

#if ENABLED(HYBRID_THRESHOLD)
uint32_t get_pwm_thrs() {
inline uint32_t get_pwm_thrs() {
return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
}
void set_pwm_thrs(const uint32_t thrs) {
inline void set_pwm_thrs(const uint32_t thrs) {
TMC2209Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID]));
TERN_(HAS_LCD_MENU, this->stored.hybrid_thrs = thrs);
}
Expand Down Expand Up @@ -282,9 +300,15 @@ class TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC266
}
inline uint16_t get_microstep_counter() { return TMC2660Stepper::mstep(); }

inline void set_chopper_times(const chopper_timing_t &ct) {
TMC2660Stepper::toff(ct.toff);
TMC2660Stepper::hysteresis_end(ct.hend);
TMC2660Stepper::hysteresis_start(ct.hstrt);
}

#if USE_SENSORLESS
inline int16_t homing_threshold() { return TMC2660Stepper::sgt(); }
void homing_threshold(int16_t sgt_val) {
inline void homing_threshold(int16_t sgt_val) {
sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max);
TMC2660Stepper::sgt(sgt_val);
TERN_(HAS_LCD_MENU, this->stored.homing_thrs = sgt_val);
Expand Down
Loading