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

[BUG] [marlin-bugfix-2.0] G54 + G92 X0 Y0 inadvertently resets origin in G53 machine coordinate system as well. #14743

Open
telleropnul opened this issue Jul 27, 2019 · 4 comments

Comments

@telleropnul
Copy link

commented Jul 27, 2019

Thank you for all your hard work developing and maintaining the Marlin codebase!

You can run this on any Marlin gcode parser to replicate:

[CNC_Coordinate_Systems] needs to be enabled in [configuration_adv.h] to enable G53-G59 coordinate systems:

/**
* CNC Coordinate Systems
*
* Enables G53 and G54-G59.3 commands to select coordinate systems
* and G92.1 to reset the workspace to native machine space.
*
#define CNC_COORDINATE_SYSTEMS

Enter the following Gcode commands:

<power cycle device>
G21 ; millimeters
G90 ; absolute coords
G53 ; machine coordinate system
M114 ; get position
    X:0.00 Y:0.00 Z:0.00 E:0.00 Count X:0 Y:0 Z:0
G54 ; switch to (1st) work coordinate system
G0 X10 Y10 ; move
    X:10.00 Y:10.00 Z:0.00 E:0.00 Count X:2000 Y:2000 Z:0
G92 X0 Y0 ; set current position as new origin (similar to G10 L20 P1 X0 Y0)
M114 ; get position
    X:0.00 Y:0.00 Z:0.00 E:0.00 Count X:2000 Y:2000 Z:0
G53 ; switch back to machine coordinates
M114 ; get position
    X:0.00 Y:0.00 Z:0.00 E:0.00 Count X:2000 Y:2000 Z:0

Setting an origin in G54 inadvertently also sets it as origin in G53. G53 should not be affected and should display absolute machine coordinates at all times i.e. X:10.00 Y:10.00 at this point.

If we repeat this using G55 we get the following:

<power cycle device>
G21 ; millimeters
G90 ; absolute coords
G53 ; machine coordinate system
M114 ; get position
    X:0.00 Y:0.00 Z:0.00 E:0.00 Count X:0 Y:0 Z:0
G55 ; switch to (2nd) work coordinate system
G0 X10 Y10 ; move
    X:10.00 Y:10.00 Z:0.00 E:0.00 Count X:2000 Y:2000 Z:0
G92 X0 Y0 ; set current position as new origin (similar to G10 L20 P2 X0 Y0)
M114 ; get position
    X:0.00 Y:0.00 Z:0.00 E:0.00 Count X:2000 Y:2000 Z:0
G53 ; switch back to machine coordinates
M114 ; get position
    X:10.00 Y:10.00 Z:0.00 E:0.00 Count X:2000 Y:2000 Z:0

Note how Machine Coordinates are not affected by zeroing X and Y in G55 using G92 X0 Y0 and continue to display the true absolute machine coordinates at all times.

@boelle boelle changed the title [BUG] G54 + G92 X0 Y0 inadvertently resets origin in G53 machine coordinate system as well. [BUG] [marlin-bugfix-2.0] G54 + G92 X0 Y0 inadvertently resets origin in G53 machine coordinate system as well. Jul 28, 2019

@shitcreek

This comment has been minimized.

Copy link

commented Aug 8, 2019

I believe there is a bit of confusion here. G53 is not a workspace itself, it is a modifier. It tells the printer to move in accordance to the selected workspace ie G54 - 59.3 : http://marlinfw.org/docs/gcode/G054-059.html

G21
G90
M114 ; X:4 Y:2 Z:0
G0 X10 Y10
G55 ; Select workspace 1 | X:10 Y10
G92 X0 Y0 ; X:0 Y:0
G28 XY ; X:4 Y2
G53 G0 X10 Y10 ;  X10 Y10 - but is actually X20 Y20
G54 ; Select workspace 0
M114 ; X20 Y20

G53 can be used like so:
G53
G0 X# Y#
--- or ----
G53 G0 X# Y#

@telleropnul

This comment has been minimized.

Copy link
Author

commented Aug 9, 2019

http://marlinfw.org/docs/gcode/G053.html
"G53 - Move in Machine Coordinates"

Yes, G53 is a modifier i.e. G53 G0 X100 Y100.

"Marlin also accepts G53 on a line by itself as the command to return to the native workspace."

i.e.

Use native space
G53

My use of G53 is exactly this: to return to the native space i.e. machine coordinate system. I simply use a G53 command to be absolutely certain of my current position in machine coordinates before I switch to G54 or G55 in the two examples provided.

The point is that in the two examples provided, setting an origin in G55 using G92 X0 Y0 does not affect G53 machine coordinates (correct behavior) whereas setting an origin in G54 using G92 X0 Y0 does affect G53 machine coordinates (incorrect behavior).

As a result, it is impossible to use work position coordinates (G54) in CNC.js or other CNC Marlin interfaces:

G53_G54

If you try to zero X and Y (G92 X0 Y0) in work position coordinates (G54), the machine coordinates DRO will instantly change to "0.00" and "0.00" as well (!)

The two Gcode examples provided show exactly where it goes wrong. You can easily reproduce the error by running the commands provided.

Executing G92 X0 Y0 in a work coordinate system (G54-G59) should NEVER affect native space / machine coordinates / G93.

@shitcreek

This comment has been minimized.

Copy link

commented Aug 13, 2019

I stand corrected. G53 as a modifier should move relative to native space and when called by itself should switch back to native space.
This is what I've put together to get it to work. I've also made G28 set current position to the selected workspace.
G53 - G59 - G28.zip
If you wouldn't mind trying it out and let me know if functions as it should for you.

@telleropnul

This comment has been minimized.

Copy link
Author

commented Aug 13, 2019

Thank you for your time and effort - most appreciated!

I will have to reflash my CNC machine using the modified source code files provided.
I will report back my findings shortly...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.