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

Fixed Time Motion: Fix switching on or off FTM when printing #27335

Merged
merged 9 commits into from
Aug 17, 2024

Conversation

narno2202
Copy link
Contributor

Description

Changing motion system during a print is a bad idea but a long time ago, switching on or off FTM was possible. Now it's broken and the printer freezes.
As we can't switch on or off FTM via the tune menu, we need to disable M493 S0 or M493 S1 when printing .

Requirements

Benefits

Configurations

Related Issues

@thisiskeithb
Copy link
Member

Changing motion system during a print is a bad idea but a long time ago, switching on or off FTM was possible. Now it's broken and the printer freezes.

That should be fixed instead of using a workaround/disabling it.

cc: @ulendoalex

@narno2202
Copy link
Contributor Author

I agree but actually you can't switch on or off FTM when you print via the tune menu (which is a good idea). Blocking M493 S function during a print does the same. I am currently investigating this issue, but some help will be fine.

@gudvinr
Copy link

gudvinr commented Aug 8, 2024

How you define "during the print"?
In general, printer has no idea which state it's in.

From the human perspective, "print" is something that produces physical part. But:

  • there are multi object prints
  • you can concat gcode files together
  • often people stream gcode to uart (octoprint/uart displays)
  • you can do moves without extrusion/heating for testing purposes

I don't think you can clearly define concept of "print" given that it's just a stateless stream of commands. At least not without assumptions that will break in one or all of the cases I mentioned

@thisiskeithb
Copy link
Member

How you define "during the print"?
In general, printer has no idea which state it's in.

The printer may not be sentient yet, but printer_busy(), it's defined as follows:

bool printer_busy() {
return planner.movesplanned() || printingIsActive();
}

...and printingIsActive():

/**
* Printing is active when a job is underway but not paused
*/
bool printingIsActive() { return !did_pause_print && printJobOngoing(); }

So there are ways to tell if the machine is doing something.

@gudvinr
Copy link

gudvinr commented Aug 8, 2024

printingIsActive():

From what I see, printJobOngoing relies on M76/M77 when not printing from SPI-attached SD. For that slicer needs to emit said gcodes and print job needs to be enabled (but it is enabled by default from what I see).

So, it is not a very reliable method which will only work for a subset of printers AND subset of printing sources.
If FTM requires printingIsActive to be false, then it won't work for octoprint users unless they also modify their setup to support print jobs.
If it's not necessary, then checking for movesplanned will be enough and won't introduce subtle issues when you change between sources.

@narno2202
Copy link
Contributor Author

When I say during a print, it means when the effective print has begun.

  1. Freeze is related to planner.synchronize() call in M493. This call also causes little gaps when you print the ringing tower. Removing it, solves freezing and has no other incidence.

  2. The reset flag (flag.reset_ft) in M493 as also no effect with the new buffer management systetm and could be removed

  3. ftMotion_syncPosition() call is useless with the new buffer system

Applying these changes allows enabling FT_MOTION during an ongoing printing job without freezing or layer shifting. Disabling FT_MOTION is still buggy.

@narno2202
Copy link
Contributor Author

After some tests and searches, the call to stepper.ftMotion_syncPosition() must be done before the new FT_MOTION status affectation (ftMotion.cfg.active = active) in M493 function, planner.synchronize() is also called in stepper.ftMotion_syncPosition().
Now switching back and forth FT_MOTION when a print job has begun is again available.

@narno2202 narno2202 changed the title Fixed Time Motion on or off forbidden when printing Fixed Time Motion: Fix switching on or off FTM when printing Aug 8, 2024
if (flag.reset_ft) {
stepper.ftMotion_syncPosition();
ftMotion.reset();
}
Copy link
Member

Choose a reason for hiding this comment

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

Are we certain that changing any of the above parameters does/will not require ftMotion.reset() to recalculate something/anything based on the updated parameter(s)?

@@ -423,15 +416,8 @@ void GcodeSuite::M493() {

#endif // HAS_Y_AXIS

planner.synchronize();

if (flag.update) ftMotion.update_shaping_params();
Copy link
Member

Choose a reason for hiding this comment

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

Seems like a smart idea to synchronize before modifying the parameters that ftMotion uses to do its motion. Are we certain it is / will always be safe to call update_shaping_params while a move is still ongoing?

@thinkyhead thinkyhead merged commit 381aeb9 into MarlinFirmware:bugfix-2.1.x Aug 17, 2024
63 checks passed
@narno2202 narno2202 deleted the FTM_On_Off_fix branch August 19, 2024 19:11
Minims pushed a commit to Minims/Marlin that referenced this pull request Aug 20, 2024
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
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.

4 participants