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 M166 Gradient Mix on delta printers #19285

Merged
merged 3 commits into from
Sep 7, 2020

Conversation

Kadah
Copy link
Contributor

@Kadah Kadah commented Sep 7, 2020

Description

The updates for M166 gradient mix on delta printers use the z tower stepper position instead of the toolhead cartesian z position. This leads to current gradient mix being constantly changing during a single layer as seen here and results in the gradient being rotated and offset.

Example:

2020-09-06 12 34 46

I am not sure if the fix I have made is the correct way to do it. I have been running with this patch and it does fix the issue. This likely creates additional cycles with having to call for a forward kinematics update more often, though a delta+mixing setup should already preclude 8-bit controllers.

Benefits

Allows M166 to work as intended on delta printers.

Configurations

RGB_Delta.zip

Related Issues

#18917

@thinkyhead thinkyhead merged commit bb01703 into MarlinFirmware:bugfix-2.0.x Sep 7, 2020
@thinkyhead
Copy link
Member

That looks much better, thanks!

@AnHardt
Copy link
Member

AnHardt commented Sep 7, 2020

There is always a way to speed things up.

There the problem is the expensive back calculation of the Cartesian Z.

Currently the mix for a block is set and calculated at the end of _populate_block(). The catch could be to only copy in the mix there, but calculating it as long the Cartesian Z is still available. It's just a matter of finding the right place for that calculation. I'd search near the kinematic conversion.


SERIAL_ECHOPGM(" ; Current Z");
#if ENABLED(DELTA)
get_cartesian_from_steppers();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't this duplicative since mixer.update_mix_from_gradient() calls it?

@AnHardt
Copy link
Member

AnHardt commented Sep 7, 2020

Isn't this the critical path? (from 2.0.x)

TERN_(HAS_POSITION_FLOAT, position_float = target_float);
TERN_(GRADIENT_MIX, mixer.gradient_control(target_float.z));
TERN_(POWER_LOSS_RECOVERY, block->sdpos = recovery.command_sdpos());
return true; // Movement was accepted
} // _populate_block()

static inline void gradient_control(const float z) {
if (gradient.enabled) {
if (z >= gradient.end_z)
T(gradient.end_vtool);
else
update_gradient_for_z(z);
}
}

void Mixer::update_gradient_for_z(const float z) {
if (z == prev_z) return;
prev_z = z;
const float slice = gradient.end_z - gradient.start_z;
float pct = (z - gradient.start_z) / slice;
NOLESS(pct, 0.0f); NOMORE(pct, 1.0f);
MIXER_STEPPER_LOOP(i) {
const mixer_perc_t sm = gradient.start_mix[i];
mix[i] = sm + (gradient.end_mix[i] - sm) * pct;
}
copy_mix_to_color(gradient.color);
}

davidveg added a commit to davidveg/Marlin that referenced this pull request Sep 9, 2020
* commit 'bc7720c0cd3917f44200c0b78e1b635e4c7b6797': (483 commits)
  Minor HAL cleanup
  [cron] Bump distribution date (2020-09-09)
  Update HAL/STM32 platform to 8.0 (MarlinFirmware#18496)
  Make M600 heat up the nozzle. Reset runout on fail. (MarlinFirmware#19298)
  [cron] Bump distribution date (2020-09-08)
  TFT is neither "graphical" nor "character" (MarlinFirmware#19297)
  Sanity-check BABYSTEP_DISPLAY_TOTAL with ColorUI (MarlinFirmware#19284)
  Fix M166 Gradient Mix for DELTA (MarlinFirmware#19285)
  Separate Neopixel followup (MarlinFirmware#19287)
  Clean up LCD conditionals, DWIN
  Whitespace cleanup
  Adjust GTR PeripheralPins to avoid timer conflicts (MarlinFirmware#19183)
  STM32F1 EP with USB_COMPOSITE (MarlinFirmware#19281)
  Menu items for Separate NeoPixel (MarlinFirmware#19280)
  [cron] Bump distribution date (2020-09-07)
  Clarify disabling StallGuard for axes (MarlinFirmware#19263)
  Touch UI long filenames fixes (MarlinFirmware#19262)
  Fix Ender 3 V2 (DWIN) buffer overrun (MarlinFirmware#19268)
  Fix STM32F1 SPI device init, MKS_LCD12864 (MarlinFirmware#19271)
  Emergency Parser for STM32F1 (MarlinFirmware#19279)
  ...

# Conflicts:
#	.github/issue_template.md
#	Marlin/Configuration.h
#	Marlin/Configuration_adv.h
#	README.md
davidveg added a commit to davidveg/Marlin that referenced this pull request Sep 9, 2020
* commit 'bc7720c0cd3917f44200c0b78e1b635e4c7b6797': (483 commits)
  Minor HAL cleanup
  [cron] Bump distribution date (2020-09-09)
  Update HAL/STM32 platform to 8.0 (MarlinFirmware#18496)
  Make M600 heat up the nozzle. Reset runout on fail. (MarlinFirmware#19298)
  [cron] Bump distribution date (2020-09-08)
  TFT is neither "graphical" nor "character" (MarlinFirmware#19297)
  Sanity-check BABYSTEP_DISPLAY_TOTAL with ColorUI (MarlinFirmware#19284)
  Fix M166 Gradient Mix for DELTA (MarlinFirmware#19285)
  Separate Neopixel followup (MarlinFirmware#19287)
  Clean up LCD conditionals, DWIN
  Whitespace cleanup
  Adjust GTR PeripheralPins to avoid timer conflicts (MarlinFirmware#19183)
  STM32F1 EP with USB_COMPOSITE (MarlinFirmware#19281)
  Menu items for Separate NeoPixel (MarlinFirmware#19280)
  [cron] Bump distribution date (2020-09-07)
  Clarify disabling StallGuard for axes (MarlinFirmware#19263)
  Touch UI long filenames fixes (MarlinFirmware#19262)
  Fix Ender 3 V2 (DWIN) buffer overrun (MarlinFirmware#19268)
  Fix STM32F1 SPI device init, MKS_LCD12864 (MarlinFirmware#19271)
  Emergency Parser for STM32F1 (MarlinFirmware#19279)
  ...

# Conflicts:
#	.github/issue_template.md
#	README.md
davidveg added a commit to davidveg/Marlin that referenced this pull request Sep 9, 2020
* 2.0.x: (483 commits)
  Minor HAL cleanup
  [cron] Bump distribution date (2020-09-09)
  Update HAL/STM32 platform to 8.0 (MarlinFirmware#18496)
  Make M600 heat up the nozzle. Reset runout on fail. (MarlinFirmware#19298)
  [cron] Bump distribution date (2020-09-08)
  TFT is neither "graphical" nor "character" (MarlinFirmware#19297)
  Sanity-check BABYSTEP_DISPLAY_TOTAL with ColorUI (MarlinFirmware#19284)
  Fix M166 Gradient Mix for DELTA (MarlinFirmware#19285)
  Separate Neopixel followup (MarlinFirmware#19287)
  Clean up LCD conditionals, DWIN
  Whitespace cleanup
  Adjust GTR PeripheralPins to avoid timer conflicts (MarlinFirmware#19183)
  STM32F1 EP with USB_COMPOSITE (MarlinFirmware#19281)
  Menu items for Separate NeoPixel (MarlinFirmware#19280)
  [cron] Bump distribution date (2020-09-07)
  Clarify disabling StallGuard for axes (MarlinFirmware#19263)
  Touch UI long filenames fixes (MarlinFirmware#19262)
  Fix Ender 3 V2 (DWIN) buffer overrun (MarlinFirmware#19268)
  Fix STM32F1 SPI device init, MKS_LCD12864 (MarlinFirmware#19271)
  Emergency Parser for STM32F1 (MarlinFirmware#19279)
  ...

# Conflicts:
#	Marlin/Configuration.h
#	platformio.ini
vgadreau pushed a commit to vgadreau/Marlin that referenced this pull request Dec 9, 2020
kageurufu pushed a commit to CR30-Users/Marlin-CR30 that referenced this pull request Apr 30, 2021
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.

3 participants