Macro B Reference Guide - MachMotion
Macro B Reference Guide - MachMotion
Macro B programming may not be included on your MachMotion control. If you are not able to use these macros, contact us for an
upgrade option.
1. Calling macros
Call Formats Example Notes License Required
M98 P__ Q__ L__ 1 M98 P0100 Q5 L2 M98 calls the subroutine spe‐ Any
cified by P (must be 4 digits),
and starts at the line number
specified by Q (optional). It
Run subroutine 0100 twice, will repeat it the number of ti‐
starting at line 5 (N5) mes passed to L (default is 1)
G65 P__ L__ A__ B__ …. 1 G65 P0150 L2 A5 B10 M65 calls a non-modal macro Industrial
specified by P and passes A-Z
(whichever are specified) to
the macro. M65 repeats a
Run macro 0150 twice, pas‐ number of times set by L and
sing 5 into #1 (A) and 10 into does not need to be cancel‐
#2 (B) led. Pound variables A-Z are
wiped after the macro
completes.
G66 P__ A__ B__ …. 1 G66 P1001 A12 B6 G66 is a modal macro call. It is Industrial
2 A10 B5 cancelled by G67. Any lines in
3 G67 between will call the same
macro with whichever para‐
meters you pass it.
Run macro 1001 with A = 12
and B = 6, then run it again
with A = 10 and B = 5, then
cancel the modal.
2. Passing Variables
You can pass variables to macros using letters A-Z, which correspond to pound variables. These are not places to store important
information! Once you leave a function it is unknown what will be in that pound variable. The letters G, L, N, O, and P cannot be used as
variables.
Example:
%
G65 P0100 A5 Pass a value of 5 to macro 0100.
M30
O0100 Start of macro.
#500 = #1 The value of A is stored in #1, and we will save it to #500.
M99 Return from the macro.
%
2.1 Variables
A B C D E F H I J K M Q R S T U V W X Y Z
1 2 3 7 8 9 11 4 5 6 13 17 18 19 20 21 22 23 24 25 26
3. In a macro
3.1 Storage Variables
There are two ranges of pound variables for the user to store values in.
3.2 Arithmetic
There are the basic add/subtract/multiply/divide functions available to the user, as well as some named functions for more advanced
math. When performing arithmetic, the control follows the order of [Brackets, Functions, Multiply, Divide, Add, Subtract].
Absolute Value ABS[ ] #100 = ABS[ -3 ] Sets #100 equal to the absolute va‐
lue of -3 (3)
Rounding ROUND[ ] #100 = ROUND[ 3 / 2 ] Sets #100 equal to the rounded va‐
lue of 3/2 (2)
Round Down (floor) FIX[ ] #100 = FIX[ 3 / 2 ] Sets #100 equal to the floor of 3/2
(1)
Round Up (ceiling) FUP[ ] #100 = FUP[ 3 / 2 ] Sets #100 equal to the ceiling of 3/2
(2)
Sine SIN[ ] #100 = SIN[ 45 ] Sets #100 equal to the sine of the
value (0.707). Takes degrees.
Cosine COS[ ] #100 = COS[ 45 ] Sets #100 equal to the cosine of the
value (0.707). Takes degrees.
Arc Cosine ACOS[ ] #100 = ACOS[ 0.707 ] Sets #100 equal to the arc cosine of
the value in degrees (45)
Arc Tangent ATAN[ ] #100 = ATAN[ 1 ] Sets #100 equal to the arc tangent
of the value in degrees (45)
Square Root SQRT[ ] #100 = SQRT[ 9 ] Sets #100 equal to the square root
of the value (3)
Natural Logarithm LN[ ] #100 = LN[ 2.3 ] Sets #100 equal to the natural loga‐
rithm of the value (0.83)
Operator GOTO, IF, and WHILE are used for decision making within a macro. Be careful not to create infinite loops.
GOTO GOTO 5 Skip to line 5 (line labeled N5). Can be above or below current
line.
IF IF [condition] GOTO 5 If the condition is true, it will execute the statement on that line.
#100 = 1 If it is false, it will skip it. It is combined with GOTO to create true
GOTO 6 and false sections of code.
N5 #100 = 0
N6 #500 = #100
WHILE WHILE [condition] DO 1 While the condition is true, the code will loop through the code
Statements between DO 1 and END 1. The numbers 1 correspond to each
END 1 other. It can be any number as long as it is the same at both the
start and the end.
There are additional pound variables which have functionality that may be useful to the user.
#3001 Millisecond timer. Setting it to 0 will reset (This function waits 1 second)
the timer, and its value at any point can be #3001 = 0
stored in another pound variable. WHILE [#3001 LE 1000] DO 1
END 1
#3002 Hour timer. Setting it to 0 will reset the ti‐ #100 = #3002
mer, and its value at any point can be sto‐ WHILE[condition] DO 1
red in another pound variable. Statements
END 1
#101 = #3002 - #100
(#101 now holds the difference in hours to
run the while loop)
#3000 Generates alarm. Gcode will be stop and the #3000 = 1 (Example Message)
operator must reset to continue.
#3006 Generates an alarm with an associated mes‐ #3006 = 101 (Example Message)
sage. Requires a reset before continuing.
#3004 Set this variable with a 3-digit number. Digit #3004 = 110
0 will enable/disable feed hold, digit 1 will (disable exact stop, disable feedrate over‐
enable/disable feedrate override, digit 2 will ride, and enable feed holds)
enable/disable exact stop.
#3005 Changes the units of measurement between #3005 = 1 (sets units to metric)
imperial and metric
#3011 Returns the current data in YYYYMMDD #100 = #3011 (get date)
form #100 = FIX[ #100 / 10000]
(#100 now has just the year)
#6000 Set bit b00X00000 to 1 to step into a su‐ For example, use this gcode to step into a
broutine or macro. Set it to 0 step over it. subroutine:
G10 L50
N6000 R00100000
G11
It is not recommended that you change the values of these pound variables, though they are available to the user. Changing values can
result in unexpected machine movement.
When setting modal groups, multiply the desired value by ten. For instance, to set the active motion g-code (#4001) to a feed rate
move (G01), set #4001 = 10.
Modal Groups
Buffered Values
Original Offsets
Last Outputs
Fixture Offsets
Part Positions
G92 Offsets
G31 Positions
Pound Variable Description
Cutter
Compensation
G30 P2
Coordinates
G30 P3
Coordinates
G30 P4
Coordinates
G60 Approach
Distances
G54 Fixture
Offsets
#5221 X Offset
#5222 Y Offset
#5223 Z Offset
#5224 A Offset
#5225 B Offset
#5226 C Offset
G55 Fixture
Offsets
#5241 X Offset
#5242 Y Offset
#5243 Z Offset
#5244 A Offset
#5245 B Offset
#5246 C Offset
G56 Fixture
Offsets
#5261 X Offset
#5262 Y Offset
#5263 Z Offset
#5264 A Offset
#5265 B Offset
#5266 C Offset
G57 Fixture
Offsets
#5281 X Offset
#5282 Y Offset
#5283 Z Offset
#5284 A Offset
#5285 B Offset
#5286 C Offset
G58 Fixture
Offsets
#5301 X Offset
#5302 Y Offset
#5303 Z Offset
#5304 A Offset
#5305 B Offset
#5306 C Offset
G59 Fixture
Offsets
#5321 X Offset
#5322 Y Offset
#5323 Z Offset
#5324 A Offset
#5325 B Offset
#5326 C Offset
G54.1 P1
#7001 X Offset
#7002 Y Offset
#7003 Z Offset
#7004 A Offset
#7005 B Offset
#7006 C Offset
G54.1 P2
#7021 X Offset
#7022 Y Offset
#7023 Z Offset
#7024 A Offset
#7025 B Offset
#7026 C Offset
For more information about Macro B please see the Macro B Quick Reference Guide.
Keywords: Advanced M code MCode M-Code G code GCode G-Code Macro B MacroB macros # pound variables