Macros For My Workflow UPDATED: 2023-10-27

Something that you should understand. What Iā€™ve done here is done for my workflow and my machine. If you attempt to use what I provide here, you must be responsible for making adjustments that work for your machine.

The best place to start is at the beginning, and I hope you donā€™t mind how verbose this story is. :smiley:

I found myself going through this repeating dance between putting in a bit, moving to the zero block, moving off-table to adjust my zero for the thickness of tape & CA glue holding my project to the wasteboard and going back to my projectā€™s XYzero to start the cutting.

DING! Thatā€™s why macros exist! (That voice in my head said, ā€œWhyā€™d it take you so long?ā€ :smiley: )

I cludged together some gcode and found something that worked ā€¦ only I was never really happy with it. So, the OP on this thread gave me the incentive to rework my macros. In addition, Iā€™ve found my workflow extending to other parts of my wasteboard using most of the other defined Workspaces - P1 - P6. I generally have fixtures for different products spaced around my machine where each one is defined within a Workspace.

Iā€™m still not happy with the results in at least one area, but more on that later. My workflow on lots of projects is similar to the way I described it above:

  • Home the machine
  • Load my Workspace coordinates
  • Move to the desired Workspaceā€™s XY
  • Prepare the part and the bit to use
  • Move to a fixed machine zero reference point
  • Perform the Z-Zero procedure
  • Move off-table (for bit clearance)
  • Go to Z-Zero
  • Jog the Z up by 0.010" (two tapes & CA glue)
  • Zero Z at this new position
  • Move the bit up for clamp clearance
  • Go to XY0 in my current Workspace
  • Start the job

And all of that has to be aware of what Workspace Iā€™m using which I keep track of (most of the time), but a macro has to have a programatic way to do the same.

I did make you aware of the verbosity in this post! :smiley:

So, this ended up being three different macros for my workflow. The first one handles loading Workspace coordinates. (This one started while I was transitioning from Carbideā€™s CM sender. It irrationally resets some coordinates as it is closing that gave me problems until someone on this forum set me straight.)

The second macro moves the bit into the area where I do Z-zero with a block. The third macro is the one that actually makes the Z adjustment for tape and glue.

Each one of the macros will save the current Workspace address, do what it does and return to the saved address. Each macro is heavily commented, but I remove all comments when I install it into gSender. Iā€™ll provide the text of each macro inline, but I will also attach the text files.

The next post explains some of the problems I encountered and discusses improvements.

After that, there are 3 posts with the gcode for a macro, and the downloadable text for that macro.

If you notice a way to improve something, that wonā€™t make me mad even a leetle bit! :smiley: Please quote something out of the post you have a response to so it will be easy to keep up with them.

2 Likes

Discussion on Problems and Improvements

Problems

modal.wcs

This line gave me fits trying to isolate what it was doing. The error messages donā€™t really help when thereā€™s this kind of problem.

%LWC=modal.wcs ( save the current workspace )

The variable and source are available in the macro editing window in gSender. Its supposed to save ā€œG54ā€ or ā€œG55ā€ or etc. when Iā€™m saving the Workspace location. It was returning null into the variable LWC.

I had to dig up some old computer programming troubleshooting skills when I was trying to pin down why I was getting an error message and not my intended result.

Have you got a clue? (Perhaps youā€™ve already looked ahead at some of my gcode? :smiley: )

Improvements

~Burning~ Workspaces

One thing that I havenā€™t figured out yet is how to specify the fixed locations without resorting to the use of a Workspace. (I chose to create the macros this way for the expediency of getting the whole development done.)

ADDED: 2023-10-27 I did find a way to use variables that make the macros independent of the Workspace that your machine is in. These new macros have these changes.

The way my workflow happens is that I have a place where I zero my project to the wasteboard (the level at the bottom of my project.) This is what is specified in my design software (Vectric Vcarve Pro) and captured when the gcode file is produced. (The Z-zero reference could easily be specified as the top of the material, but thatā€™s a different story.)

That fixed location is the most appropriate for my P1/G54 Workspace (the default.) Since my machine has been really flat for years, that location hasnā€™t been a problem for other Workspaces. However, technically, I would be better off using a Z-zero location closer to the active Workspace. I know this is possible by simply deciding on an XY offset from the XY-Zero of the current Workspace, but Iā€™ll just have to work on that gcode improvement. The change involves clamps and corner guides, but is possible. I want to maintain the macros in such a way that anyone can make adjustments for their own machine and setup.

Perhaps thatā€™s a pipedream, but Iā€™m seeing it as a goal. :smiley:


UPDATED: 2023-10-27

( MACRO INITIALIZE P1-P6 LOCATIONS )
( PURPOSE: TO SET THE LOCATION FOR EACH OF 6 WORKSPACES )
( PROCESS: SET INCH MODE )
( SAVE EACH XY POSITION FOR EACH WORKSPACE )
( ORIGINAL: CROOKEDWOODTEX 2023-08-25-1 SIENCI FORUM )
( VERSION: 2023092006185467 )
( CHANGES MADE )
( UNASSIGNED G56, G58, G59 ALL 3 DEFAULT TO P1 XY )


G20 ( INCH MODE )
G10 L2 P1 X-27.918 Y-28.617 ( G54 DEFAULT CUTTING)
G10 L2 P2 X-12.317 Y-15.002 ( G55 SMALL ORNAMENTAL FIXTURES CENTERED )
G10 L2 P3 X-27.918 Y-28.617 ( G56 UNASSIGNED )
G10 L2 P4 X-15.917 Y-26.600 ( G57 CUTTING TO RIGHT OF P1 )
G10 L2 P5 X-27.918 Y-28.617 ( G58 UNASSIGNED )
G10 L2 P6 X-27.918 Y-28.617 ( G59 UNASSIGNED )

MACRO INITIALIZE P1-P6 LOCATIONS_2023092006185467.txt (682 Bytes)

UPDATED: 2023-10-27

; MACRO MOVE TO P6 RETURN TO LWC
; PURPOSE: TO MOVE BIT TO ZERO BLOCK Z-ZERO LOCATION
; PROCESS: SAVE CURRENT WORKSPACE
; MOVE BIT FIXED WORKSPACE X0Y0
; RESTORE CURRENT WORKSPACE
; EXIT
; OPERATOR PERFORMS Z-ZERO OPERATION
; ORIGINAL: CROOKEDWOODTEX 2023-08-25-1 SIENCI FORUM
; VERSION: 2023092006200628
; CHANGES MADE
; COPIED SOME CODE FROM NEILFERRERIā€™S MACROS
; REMOVED DEPENDANCE ON WORKSPACE FOR ZERO-BLOCK LOCATION. P6 IS AVAILABLE.

;MACRO DEVELOPMENT
; ABSOLUTE MODE
; SET INCH MODE
; SET SPEED OF TRAVEL
; SAVES MODAL STATE
; SAFE RETRACT
; GOES TO X Y AT USER DEFINED COORDINATES
; RESTORES MODAL STATE
; DONE
; *** OPERATOR PERFORMS Z-ZERO OPERATION
; *** NEXT OPERATION IS EITHER X0Y0 OR MACRO TO ADJUST Z-ZERO FOR TAPE/CA GLUE THICKNESS


; SET ZEROING BLOCK LOCATION IN MACHINE COORDINATES.
; WHERE DO YOU WANT ZEROING BLOCK TO BE?
; NO COMMENTS ALLOWED ON NEXT LINES 
%ZERO_BLOCK_X = -30.584
%ZERO_BLOCK_Y = -25.141

G90 ; ABSOLUTE MODE 
G20 ; INCH MODE 
F200 ; SPEED FOR G01 
M5   ; STOP SPINDLE

; SAVE MODAL STATE
; NO COMMENTS ALLOWED ON NEXT LINES 
%LWC = modal.wcs
%PLANE = modal.plane
%UNITS = modal.units
%DISTANCE = modal.distance
%FEEDRATE = modal.feedrate
%SPINDLE = modal.spindle
%COOLANT = modal.coolant

G4 P0.5 ; SAME AS %wait

G53 G1 Z-0.8 ; SAFE RETRACT 
G4 P0.5 ; SAME AS %wait
G53 G1 X[ZERO_BLOCK_X] Y[ZERO_BLOCK_Y]
G4 P0.5 ; SAME AS %wait

; RESTORE MODAL STATE
[LWC] [PLANE] [UNITS] [DISTANCE] [FEEDRATE] [SPINDLE] [COOLANT]

MACRO MOVE TO P6 RETURN TO LWC_2023092006200628.txt (1.5 KB)

UPDATED: 2023-10-27

( MACRO ADJUST SAVED WORKSPACE Z-ZERO BY FIXED VARIABLE )
( PURPOSE: TO ADJUST CURRENT Z-ZERO BY THE THICKNESS OF 2xBLUE TAPE + CA GLUE )
( PROCESS: SAVE CURRENT WORKSPACE )
( MOVE BIT OFF TABLE TO FIXED LOCATION WORKSPACE )
( MAKE ADJUSTMENT IN Z-ZERO)
( MOVE BACK TO CURRENT WORKSPACE X0Y0 )
( ORIGINAL: CROOKEDWOODTEX 2023-08-25-1 SIENCI FORUM )
( VERSION: 2023092006192983 )
( CHANGES MADE )

(MACRO DEVELOPMENT)
( ABSOLUTE MODE )
( SET INCH MODE )
( SET SPEED OF TRAVEL )
( SET OFF_TABLE LOCATION )
( SET VARIABLE %TCA TO FIXED AMOUNT )
( SAVE CURRENT MODAL SPACE)
( SAFE RETRACT )
( GO TO X0 Y0 OFF_TABLE )
( GOTO CURRENT Z-ZERO )
( ADJUST Z-ZERO BY FIXED TAPE_GLUE THICKNESS RELATIVE MODE)
( RESET CURRENT Z-ZERO TO NEW Z-ZERO )
( ABSOLUTE MODE )
( SAFE RETRACT )
( RETURN TO CURRENT XY ZERO )
( RESTORE MODAL STATE )
( DONE. OPERATOR PERFORMS LOADED PROGRAM )


G90 ( ABSOLUTE MODE )
G20 ( INCH MODE )
F200 ( SPEED FOR G01 )

; SET OFF_TABLE LOCATION IN MACHINE COORDINATES.
; WHERE DO YOU WANT CHANGES IN Z TO HAPPEN?
; NO COMMENTS ALLOWED ON NEXT LINES 
%OFF_TABLE_X = -27.918
%OFF_TABLE_Y = -32.617

( SET VARIABLE %TCA TO FIXED AMOUNT )
( NO COMMENTS ALLOWED ON NEXT LINES )
%TCA=0.010 

; SAVE MODAL STATE
; NO COMMENTS ALLOWED ON NEXT LINES 
%LWC = modal.wcs
%PLANE = modal.plane
%UNITS = modal.units
%DISTANCE = modal.distance
%FEEDRATE = modal.feedrate
%SPINDLE = modal.spindle
%COOLANT = modal.coolant

G53 G1 Z-0.8 ( SAFE RETRACT )
G4 P0.5 ; SAME AS %wait
G53 G1 X[OFF_TABLE_X] Y[OFF_TABLE_Y] ( GO TO X0 Y0 A POINT JUST OFF TABLE FOR BIT CLEARANCE)
G4 P0.5 ; SAME AS %wait

G1 Z0 ( GOTO CURRENT Z-ZERO )
G91 G1 Z[TCA] ( RELATIVE MOVE FIXED TAPE_GLUE THICKNESS )
G10 L20 [LWC] Z0 ( RESET TO NEW Z-ZERO IN LWC)
G90 ( ABSOLUTE MODE )
G53 G1 Z-0.8 ( SAFE RETRACT )
G1 X0 Y0 ( RETURN TO CURRENT XY ZERO ) 

; RESTORE MODAL STATE
[LWC] [PLANE] [UNITS] [DISTANCE] [FEEDRATE] [SPINDLE] [COOLANT]

MACRO ADJUST LWC Z-ZERO_2023092006192983.txt (1.9 KB)

3 Likes

@CrookedWoodTex Great work, Tex. These are so far beyond me that I canā€™t provide any educated comments.

One question, just FMI, do these all pre-suppose that the machine they are running on has limit switches?

The only limit switches my machine has are the ones used for homing. If one relies on limit switches, then one doesnā€™t quite understand the limits of oneā€™s machine.

The key to doing these macros is to map out the coordinates of your Workspaces, and install those coordinates into the initialization macro. That just means to jog to the location and write down/transfer those coordinates. E.g. P1 = X Y; P2 = X Y; etc.

For more understanding, just read the comments and follow along in a gcode listing such as LinuxCNC.

I could go through these line-by-line if that would be instructive. My main reason for posting is to educate and take some of the ignorance out of the CNC. (BTW, the word ignorance is not a bad word.)

@CrookedWoodTex Tks, Tex. I, for one, am not offended by the term ignorance. I am ignorant about a lot of things. I donā€™t believe that I am stupid, though. :grinning:

I likely used the wrong term in saying ā€œlimit switchesā€. I donā€™t have switches of any kind on my LM. I asked only so that others would know if the functioning of the macros first required one to home the machine using switches.

M

So, Iā€™m ignorant of a machine that doesnā€™t have a homing cycle. GSender wonā€™t operate for me until its homed. All the homing cycle is doing is setting up the machine coordinates in Workspace G53. Well, its doing a bit more than that.

1 Like

@CrookedWoodTex Understood :grinning: My machine does not have a homing cycle as I have no switches. That was why I was posing the question - as Iā€™m sure you understand.

1 Like