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

Resuming after Pause breaks relative E mode #1083

Closed
VanessaE opened this issue Jul 28, 2020 · 6 comments · Fixed by #1114
Closed

Resuming after Pause breaks relative E mode #1083

VanessaE opened this issue Jul 28, 2020 · 6 comments · Fixed by #1114

Comments

@VanessaE
Copy link
Contributor

VanessaE commented Jul 28, 2020

If the printer is in relative E mode as commanded by M83 or G91 in the g-code, and you "Pause" and then immediately "Resume" the print without doing anything else, Pronterface forces the printer back into absolute E mode. I assume this actually applies to all axes and not just E.

This leads to unpredictable results, but is guaranteed to fail.

As far as I'm aware, there's no way to query the printer for its default axis modes, or for which axes are in which mode at the moment, so I suggest the following:

  • When the print starts, before reading/sending any g-code, set a flag in the program to indicate XYZ are in absolute mode (they're always in the same mode, whatever it is), and set a flag indicating E is in absolute mode.

  • During the print, watch for G90, G91, M82, and M83 commands:

    • if you see a G90, set both the XYZ and E flags to indicate that they're absolute mode.
    • if you see a G91, set both flags to indicate everything's in relative mode.
    • if you see an M82, set the E flag to indicate absolute mode.
    • if you see an M83, set the E flag to indicate relative mode.
  • On pause: immediately issue M114 to get the current coordinates.

  • On resume, we just need to read those flags and reset the mode(s):

    • send G90
    • send a G1 ... command to restore the nozzle position that M114 reported earlier
    • if the XYZ flag indicates relative mode, send G92 X0 Y0 Z0
    • if the E flag indicates relative mode, send G92 E0 (if there's more than one extruder, you'll probably want to send pairs of tool change commands and G92 E0, to reset all extruders to 0).
    • send either G90 or G91, according to the state of the XYZ flag
    • send either M82 or M83 according to the state of the E flag (you can omit this if the flags match)

This way Pronterface can do its usual stuff like jogging or homing in absolute mode, but should put the printer back into whatever state the g-code had it in on resume.

@volconst
Copy link
Collaborator

Some of the specified logic is already implemented. I think only the relative e is not restored on resume. Ideally first could be created gcode test files with the expected result for different combinations.

@VanessaE
Copy link
Contributor Author

Ideally first could be created gcode test files with the expected result for different combinations

In the meantime, here's some g-code as exported from Prusaslicer: bed spacer-standoff.gcode.zip

volconst added a commit to volconst/Printrun that referenced this issue Jul 31, 2020
The test fails due to thread join unrelated to kliment#1083
This is fixed with next commit, then fails for missing M83 command,
which is fixed with another commit
volconst added a commit to volconst/Printrun that referenced this issue Jul 31, 2020
@volconst
Copy link
Collaborator

@VanessaE , you can checkout this branch https://github.com/volconst/Printrun/commits/resume-rel-extr if it fixes the problem
I have created a test gcode ./testfiles/pause-restore-rel-e.gcode . It has to be loaded in Pronterface, connect, print. The gcode pauses by itself and switches verbose logging so you can verify the commands emitted on resume. Test needs the user to press Resume button to continue.
To compare behavior of test before and after fix do:
$ git clone ... or ... git remote && git fetch remote
$ git checkout 5cffab7
$ ./pronterface
$ git checkout resume-rel-extr
$ ./pronterface
After you confirm fix, I will create pull request.

@VanessaE
Copy link
Contributor Author

Sorry I took so long to get back to this one.

I tested with an XYZ cube, and it seems to work as it should. I also used your test gcode file:

Loading file: /home/vanessa/RepRap/Printrun-volconst/testfiles/pause-restore-rel-e.gcode
Loaded /home/vanessa/RepRap/Printrun-volconst/testfiles/pause-restore-rel-e.gcode, 10 lines
0.00mm of filament used in this print
The print goes:
- from 0.00 mm to 0.00 mm in X and is 0.00 mm wide
- from 0.00 mm to 0.00 mm in Y and is 0.00 mm deep
- from 0.00 mm to 0.00 mm in Z and is 0.00 mm high
Estimated duration: 0 layers, 0:00:00
Print started at: 16:42:38
Locking interface.
G-Code calling host command "!print('Please press Resume and check for M 83')"
Please press Resume and check for M 83
G-Code calling host command "!self.p.loud = True"
Print paused at: 16:42:49
SENT: M105
RECV: ok T:239.37 /240.00 B:82.82 /85.00 @:127 B@:127
SENT: M105
RECV: ok T:239.06 /240.00 B:82.60 /85.00 @:0 B@:127
SENT: M105
RECV: ok T:239.06 /240.00 B:82.53 /85.00 @:0 B@:127
SENT: M105
RECV: ok T:238.75 /240.00 B:82.45 /85.00 @:127 B@:127
SENT: M105
RECV: ok T:239.37 /240.00 B:82.41 /85.00 @:0 B@:127
Unlocking interface.
SENT: M105
RECV: ok T:239.37 /240.00 B:82.30 /85.00 @:32 B@:127
Resuming.
SENT: G90
RECV: ok
Print resumed at: 16:43:05
SENT: G1 X0.0 Y0.0 F3000
RECV: ok
SENT: G1 Z0.0 F12000
RECV: ok
SENT: G92 E147.42697999999962
Locking interface.
RECV: X:0.00 Y:0.00 Z:0.00 E:147.43 Count A:36320 B:-4320 Z:8000
RECV: ok
SENT: M83
RECV: ok
SENT: G1 F12000.0
RECV: ok
G-Code calling host command "!self.p.loud = False"
G-Code calling host command "!threading.Timer(2, lambda logbox: print('PASSED. Seen M 83' if 'M' + '83' in logbox.Value else 'FAILED: M 83 not seen'), (self.logbox,)).start()"
Print ended at: 16:43:05 and took 0:00:10
PASSED. Seen M 83
Unlocking interface.

I guess that's a success 😃

I am not sure what you meant with that last bit about comparing behavior; what I did above suggests no unexpected changes.

@volconst
Copy link
Collaborator

Thank you @VanessaE
Comparing behavior is about proving that this specific commit fixes the problem.
I see you use [X] Lock checkbox. What's the idea behind it?

@VanessaE
Copy link
Contributor Author

Oh you can ignore that, I was testing with the "factory" configuration rather than one of my usual config files and didn't bother to disable that option 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants