Need help with ugs macro

Using ugsplatform and I am having trouble getting a macro to work correctly. Thought I would reach out to the forum to figure out what I’m doing wrong.

The main issue I am having is ugs seems to be processing the macro commands before it is able to complete them. I originally had all the commands on one line but ugs seems to be doing the command before it is ready to. Now I have the commands split into 2 macros. What’s worse is the macro seems to be overwriting my g56 with my g55 setting. After using the second part of the macro g55 is now set to g56 coordinates.

Work flow is as follows
Home machine
1st macro
G56;G0 X0 Y0; G20 G91 G38.2 Z-3 F10;G91 G21 g0 z5
Second macro
G90 Z19.05;G10 P2 L20 Z0;G91 g0 z5;G55;G0 X0 Y0

I want it to home, go to probe, set zero from table surface then move to g55 z5 to be ready to cut. I also plan on using the macro for tool changes as well.

Anyone see something obvious I’m missing or maybe suggest a better way to do this macro? Is there a limit to how many commands ugs can handle in one macro maybe?

This is what you are telling your machine to do. Is this what you wanted?

Home Machine - grbl defaults to G54 and G90 if you haven’t changed it

Active: G54 G90

1st Macro
G56 - change to G56 co-ordinate system (since you haven’t set it, it defaults to whatever the setting was the last time it was set - value is retained across power off/on)

Active: G56
G0 X0 Y0 - go to Work zero (x and y) in G56 co-ordinate system

G20 change to inch mode
G91 change to relative positioning
G38.2 Z-3 F10 probe
G91 change to relative positioning
G21 change to millimeter mode
G0 Z5 move Z 5 mm from current position in G56 co-ordinate system

Active G56 G21 G91

2nd Macro

Active: unknown state unless used immediately after Macro 1 (G56 G21 G91)

G90 change to absolute positioning
Z19.05 move Z to absolute 19.05 in unknown co-ordinate system (G56)
G10 P2 L20 Z0 change G55 co-ordinate system Work Zero Z = 0 (x and y unchanged)
G91 change to relative positioning in unknown co-ordinate system (G56)
G0 Z5 move Z 5 unknown unit positions (5 mm G56)
G55 change to G55 co-ordinate system
G0 X0 Y0 move relative position to X0, Y0 (basically no movement as you are in G91)

G56 is already programmed in as my work cutting x/y zero. I am used to doing everything in mm but am trying to switch to inches due to software changes. Need to clean it up and convert everything to inches.

Are G55 X and Y setup before you run your macros?

Is this OK?

As you said g55 will default to the previously used coordinats if it is not changed. I have been using the same g55 for couple weeks until I programmed in g56.

Converted to inches and combined into one macro again
G91 G20 G56;G0 X0 Y0; G38.2 Z-3 F10;G0 z.27;G10 P2 L20 Z0;G0 Z.2;G55;G0 X0 Y0

Go to probe location, probe, retract to .75 height(probe is .48 inch), set z0 at new height(.75 inch), retract .2 inch set g55 go x0y0.

Purpose of the macro is to probe and move bit to x0y0z.2 inch, then be able to rerun macro after a tool change. But I still don’t understand why get g55 x/y are being changed using this macro.

Edit: after adding new macro I homed the machine, started macro and the machine started probing at the home location without moving to g56 first. Starting to hate macros. This is what grbl console said

$H

ok

G91 G20 G56

ok

G0 X0 Y0

G38.2 Z-3 F10

G0 z.27

G10 P2 L20 Z0

ok

**** Canceling file transfer. ****

I tried your macro on my machine (Windows 7, UGCS 1.0.9, grbl 1.0c). Here is the log.

**** Connected to COM3 @ 115200 baud ****

Grbl 1.0c [‘$’ for help]
modified by Larry Mayberry
[‘$H’|‘$X’ to unlock]

$H
ok
$G
[G0 G54 G17 G21 G90 G94 M0 M5 M9 T0 F0. S0.]
ok
$#
[G54:1.000,1.000,1.000]
[G55:2.000,2.000,2.000]
[G56:3.000,3.000,3.000]
[G57:0.000,0.000,0.000]
[G58:0.000,0.000,0.000]
[G59:0.000,0.000,0.000]
[G28:0.000,0.000,0.000]
[G30:0.000,0.000,0.000]
[G92:0.000,0.000,0.000]
[TLO:0.000]
[PRB:0.000,0.000,0.000:0]
ok
G91 G20 G56
G0 X0 Y0
ok
G38.2 Z-3 F10
G0 z.27
G10 P2 L20 Z0
G0 Z.2
G55
ok
G0 X0 Y0
[PRB:0.000,0.000,-3.959:1]
ok
ok
ok
ok
ok
ok
$G
[G0 G55 G17 G20 G91 G94 M0 M5 M9 T0 F254. S0.]
ok
$#
[G54:1.000,1.000,1.000]
[G55:2.000,2.000,2.629]
[G56:3.000,3.000,3.000]
[G57:0.000,0.000,0.000]
[G58:0.000,0.000,0.000]
[G59:0.000,0.000,0.000]
[G28:0.000,0.000,0.000]
[G30:0.000,0.000,0.000]
[G92:0.000,0.000,0.000]
[TLO:0.000]
[PRB:0.000,0.000,-3.959:1]
ok
**** Connection closed ****

Tried recreating what you did Larry. $h, $g, and $#. Then ran macro. You can see I have g55 and g56 set up. As soon as I hit the macro machine starts probing at g54 and I have to cancel. Also included $$ in case a setting is messing me up. Some of the $$ settings are because I have a jtech laser.

$H

ok

$G

[GC:G0 G54 G17 G21 G90 G94 M5 M9 M56 T0 F0 S0]

ok

$#

[G54:0.000,0.000,-45.092]

[G55:-329.200,-323.900,-45.067]

[G56:-341.900,-336.600,-64.117]

[G57:0.000,0.000,0.000]

[G58:0.000,0.000,0.000]

[G59:-254.800,-305.600,0.000]

[G28:0.000,0.000,0.000]

[G30:0.000,0.000,0.000]

[G92:0.000,0.000,0.000]

[TLO:0.000]

[PRB:0.000,0.000,0.000:0]

ok

G91 G20

G56

ok

ok

G0 X0 Y0

G38.2 Z-3 F10

G0 z.27

G10 P2 L20 Z0

ok

**** Canceling file transfer. ****

**** Pausing file transfer. ****

ok

Grbl 1.1f [‘$’ for help]

$$

$0 = 10 (Step pulse time, microseconds)

$1 = 255 (Step idle delay, milliseconds)

$2 = 0 (Step pulse invert, mask)

$3 = 4 (Step direction invert, mask)

$4 = 0 (Invert step enable pin, boolean)

$5 = 0 (Invert limit pins, boolean)

$6 = 0 (Invert probe pin, boolean)

$10 = 255 (Status report options, mask)

$11 = 0.020 (Junction deviation, millimeters)

$12 = 0.010 (Arc tolerance, millimeters)

$13 = 0 (Report in inches, boolean)

$20 = 0 (Soft limits enable, boolean)

$21 = 0 (Hard limits enable, boolean)

$22 = 1 (Homing cycle enable, boolean)

$23 = 0 (Homing direction invert, mask)

$24 = 100.000 (Homing locate feed rate, mm/min)

$25 = 2000.000 (Homing search seek rate, mm/min)

$26 = 25 (Homing switch debounce delay, milliseconds)

$27 = 1.000 (Homing switch pull-off distance, millimeters)

$30 = 255 (Maximum spindle speed, RPM)

$31 = 0 (Minimum spindle speed, RPM)

$32 = 1 (Laser-mode enable, boolean)

$100 = 40.000 (X-axis travel resolution, step/mm)

$101 = 40.000 (Y-axis travel resolution, step/mm)

$102 = 40.000 (Z-axis travel resolution, step/mm)

$110 = 5000.000 (X-axis maximum rate, mm/min)

$111 = 5000.000 (Y-axis maximum rate, mm/min)

$112 = 5000.000 (Z-axis maximum rate, mm/min)

$120 = 400.000 (X-axis acceleration, mm/sec^2)

$121 = 400.000 (Y-axis acceleration, mm/sec^2)

$122 = 400.000 (Z-axis acceleration, mm/sec^2)

$130 = 845.000 (X-axis maximum travel, millimeters)

$131 = 850.000 (Y-axis maximum travel, millimeters)

$132 = 80.000 (Z-axis maximum travel, millimeters)

Your $10 setting is not really right for 1.1f.

Valid settings for $10 in grbl version 1.1f are:
1 Enable MPos, Disable WPos
2 Enable WPos, Disable MPos, Enable Bufffer (planner and serial available buffer)

$10=1 is the default

The following is a problem:

Since you are in relative addressing mode the G0 X0 Y0 is a NOP (No Operation) as far as GRBL is concerned.
G91 G20
G56
G0 X0 Y0

This is what this G-code snippet tells grbl

G91 enter relative positioning mode
G20 enter inch mode
G56 use the G56 co-ordinate system
G0 X0 Y0 do nothing (since you are in relative positioning mode, you are requesting that grbl move to a new position by adding 0 to the current X value and Y value which is no move at all so grbl does nothing with it)
G38.2 etc begin probe operation

Try this (uses absolute positioning)

G90 G20
G56
G0 X0 Y0 (with absolute positioning now you are telling grbl to go to Work 0,0 in the G56 co-ordinate system)
G38.2 etc.

1 Like

That was the issue right there. Changed it to g90 g20, ran the rest of the macro and it did exactly as it was supposed to. Now I have a working macro, thank you so much Larry.

1 Like