M - Macro Development Tool Guide
M - Macro Development Tool Guide
匯出日期:2021-08-05
修改日期:2021-06-02
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
1 Preface
In order to increase the flexibility of the controller application, Syntec controller provides MACRO program editing
functions. When the processing program is declared in the MACRO format, specific mathematical functions are
applicable like other programming languages. In this way, in addition to the original movement and compensation
command functions, logical judgment and mathematical calculation functions are also included.
Preface – 2
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
2 File Format
The first line of the program should be declared as the title line with "%" and add the keyword "@MACRO".
Otherwise, the file will be regarded as a normal ISO format file, and user is not able to to use the full functionality of
the MACRO. In addition, each line of the program content must be followed by a semicolon ";", but there are
exceptions to some of the syntax, refer to the syntax description.
With or without 1. Except the special syntax, every line should end with semicolon.
semicolon at the end 2. If the line does not end with semicolon, CNC combine it together with the next line
of line is acceptable. when checking the syntax. If there is no alarm, the NC program run normally;
otherwise, there comes the alarm "COM-008," which is "line does not end with
semicolon."
Example:
While using "(...)", While using "(*...*)", the ... is regarded as comment.
the ... is regarded as
comment.
Note:
1. It is recommended that multi-path style(including $1 and $2) might not be used in NC Program which is
called as sub-program or a macro.
File Format – 3
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Should it be inevitable, the size of the program must be less than 58.6KB. Otherwise, there comes the alarm
"COR-203 Illegal NC Program format."
2. Not support the sub-program, which is in MACRO format, using the multi-path style (including $1, $2).
3. If the size of file is larger than 58.6 KB, it would not support the syntax like IF, CASE, REPEAT, FOR, WHILE,
which are longer than one line. If these syntax are used, there will be alarms.( Syntax Compiler Alarm - COM )
4. Only ASCII characters are acceptable in NC files. Using non-ASCII characters is thus unacceptable and will
trigger COM-027 Invalid character.
Note: Listed below are the special cases in which non-ASCII characters are considered acceptable:
a. Comment.
b. Arguments of MACRO functions that are of string type.
File Format – 4
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
3 Block Format
The writing format of the block (one line) is instructed as follows:
/ N G X Y Z A B C I J K F S T D M
N The block sequence No., which must be written at the head of a block, and the
MACRO command or variable designation cannot be written in the same line.
X The X axis movement command, or the expansion of the G code, must be written
after the G code.
Y The Y axis movement command, or the expansion of the G code, must be written
after the G code.
Z The Z axis movement command, or the expansion of the G code, must be written
after the G code.
A The A axis movement command, or the expansion of the G code, must be written
after the G code.
B The B axis movement command, or the expansion of the G code, must be written
after the G code.
C The C axis movement command, or the expansion of the G code, must be written
after the G code.
I The radius command in the X direction or the argument of the expansion G code,
must be written after the G code.
J The radius command in the Y direction or the argument of the expansion G code,
must be written after the G code.
K The radius command in the Z direction or the argument of the expansion G code,
must be written after the G code.
Block Format – 5
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Block Format – 6
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
4 Operator
Operator Sign Operating order
Brackets ()[] 1
Negative - 3
Complement NOT 3
Multiplication sign * 4
Divisor / 4
Plus + 5
Minus - 5
Comparison <,>,<=,>= 6
Equal = 7
Boolean “or” OR 11
Note 1:
When using the "/" component (division), be aware that if the numerator and denominator are integers, the result is
still an integer. The difference between an integer and a non-integer result is whether user adds the decimal point
or not.
example:
• The numerator is a non-integer: 1. / 2 = 0.5
• The denominator is a non-integer: 1 / 2.0 = 0.5
• The numerator and denominator are integers: 1/2 = 0
Operator – 7
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Operator – 8
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
5 Language Instructions
5.1 Variable Designation
Variable Designation
Example 1: @1 := 123;
Direct setting #1 := 456;
#10 := "12"; // The local variable #10 content is 12
@10 := "12"; // public variable @10 content is 12849
Remarks 1. The "12" in the first example is a string, indicating that the string is stored in
the variable. When the public variable is stored, the controller will translate the
string into ASCII. For the local variable, the translation will not be executed.
2. To correctly read the contents of the string stored in the public variable, use
the SCANTEXT function.
3. In the example 2, please notice that it's the "square bracket"
5.2 GOTO
GOTO
Syntax GOTO n;
Explanation The use of GOTO should be paired up with block sequence code(n). CNC would
jump to the specified N-number and execute from that line. If there are two same
N-numbers in the program, the first N-line number in the program will take
precedence than the second one.
Language Instructions – 9
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Examples %@MACRO
#1 := 1;
#2 := 10;
IF( #1 = 1 ) THEN
GOTO #2;
END_IF;
IF( #1 = 2 ) THEN
GOTO 100;
END_IF;
N10;
G01 G90 X50. Y0. F1000;
M30;
N100;
G01 G90 X0. Y50. F1000;
M30;
Remarks When using the loop function such as REPEAT/WHILE/FOR/GOTO, user should pay
attention to the problem of infinite loop. When this occurs, the human machine
interface, which is screen, may be locked or the machining program may crash.
It is recommended to add the SLEEP() function avoiding the crash resulting
from the infinite loop. With SLEEP() function, there is still chance to operate the
human-machine interface to stop the program execution.
5.3 CASE
CASE
Language Instructions – 10
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Examples %@MACRO
#1 := 1;
G01 G90 X0. Y0. F1000;
CASE #1 OF
1:
X(1.0*#1) Y(1.0*#1);
2:
X(2.0*#1) Y(2.0*#1);
3, 4, 5:
X(3.0*#1) Y(3.0*#1);
ELSE
X(4.0*#1) Y(4.0*#1);
END_CASE;
M30;
5.4 IF
IF
Language Instructions – 11
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Examples %@MACRO
#1 := 3.0;
G01 G90 X0. Y0. F1000;
IF #1 = 1 THEN
X(1.0*#1) Y(1.0*#1);
ELSEIF #1 = 2 THEN
X(2.0*#1) Y(2.0*#1);
ELSEIF #1 = 3 THEN
X(3.0*#1) Y(3.0*#1);
ELSE
X(4.0*#1) Y(4.0*#1);
END_IF;
M30;
5.5 Repeat
REPEAT
Syntax REPEAT
<statement List>
UNTIL <condition>
END_REPEAT;
Language Instructions – 12
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Examples %@MACRO
#10 := 30.;
#11 := 22.5.;
#12 := #10/2;
#13 := #11/2;
#14 := 2.0;
#15 := 1.5;
G01 G90 X#12 Y#13 F1000;
REPEAT
G00 X(#12+#14) Y(#13+#15);
G01 X(#12+#14) Y(#13-#15);
G01 X(#12-#14) Y(#13-#15);
G01 X(#12-#14) Y(#13+#15);
G01 X(#12+#14) Y(#13+#15);
#14 := #14 + 2.0;
#15 := #15 + 1.5;
UNTIL (#14 > #12) OR (#15 > #13) END_REPEAT;
M30;
Remarks When using the loop function such as REPEAT/WHILE/FOR/GOTO, user should pay
attention to the problem of infinite loop. When this occurs, the human machine
interface, which is screen, may be locked or the machining program may crash.
It is recommended to add the SLEEP() function avoiding the crash resulting
from the infinite loop. With SLEEP() function, there is still chance to operate the
human-machine interface to stop the program execution.
5.6 While
WHILE
Language Instructions – 13
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Examples %@MACRO
#10 := 30.;
#11 := 22.5.;
#12 := #10/2;
#13 := #11/2;
#14 := 2.0;
#15 := 1.5;
G01 G90 X#12 Y#13 F1000;
WHILE (#14 <= #12) AND (#15 <= #13) DO
G00 X(#12+#14) Y(#13+#15);
G01 X(#12+#14) Y(#13-#15);
G01 X(#12-#14) Y(#13-#15);
G01 X(#12-#14) Y(#13+#15);
G01 X(#12+#14) Y(#13+#15);
#14 := #14 + 2.0;
#15 := #15 + 1.5;
END_WHILE;
M30;
Remarks When using the loop function such as REPEAT/WHILE/FOR/GOTO, user should pay
attention to the problem of infinite loop. When this occurs, the human machine
interface, which is screen, may be locked or the machining program may crash.
It is recommended to add the SLEEP() function avoiding the crash resulting
from the infinite loop. With SLEEP() function, there is still chance to operate the
human-machine interface to stop the program execution.
5.7 For
FOR
Language Instructions – 14
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Syntax FOR <variable 1> := <Description 1> TO <Description 2> BY <Description 3> DO
<statement list>
END_FOR;
Variable 1: The variable that controls the number of loops
Description 1: The start number of the loop count, which can be a numerical value or
an arithmetic expression
Description 2: The terminated number of the loop count, which can be a numerical
value or an arithmetic expression.
Description 3: The added number to the current loop count after each loop, which can
be a numerical value or an arithmetic expression.
Statement list: execution in each loop
Examples %@MACRO
#10 := 30.;
#11 := 22.5.;
#12 := #10/2;
#13 := #11/2;
#14 := 2.0;
#15 := 1.5;
G01 G90 X#12 Y#13 F1000;
FOR #6 := 0 TO 3 BY 1.0 DO
G00 X(#12+#14) Y(#13+#15);
G01 X(#12+#14) Y(#13-#15);
G01 X(#12-#14) Y(#13-#15);
G01 X(#12-#14) Y(#13+#15); G01 X(#12+#14) Y(#13+#15);
#14 := #14 + 2.0;
#15 := #15 + 1.5;
END_FOR;
M30;
Language Instructions – 15
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Remarks 1. When using the loop function such as REPEAT/WHILE/FOR/GOTO, user should pay
attention to the problem of infinite loop. When this occurs, the human machine
interface, which is screen, may be locked or the machining program may crash.
2. It is recommended to add the SLEEP() function avoiding the crash resulting
from the infinite loop. With SLEEP() function, there is still chance to operate the
human-machine interface to stop the program execution.
3. Do NOT use the command whitch will jump out and in FOR loop ( e.g: Complex
Canned Cycle (G72-G78), using GOTO jump out loop and jump in again ), 、M98 H_,
it will cause the incorrect added number(<Description 3>).
example:
N12;
M00;
@1:=@1+5;
GOTO 13;
M99;
5.8 EXIT
EXIT
Syntax EXIT
Language Instructions – 16
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Examples %@MACRO
#10 := 30.;
#11 := 22.5.;
#12 := #10/2;
#13 := #11/2;
#14 := 2.0;
#15 := 1.5;
#16 := 1.0;
G01 G90 X#12 Y#13 F1000;
FOR #6 := 0 TO 3 BY 1.0 DO
IF((#14 = 4) & (#16 = 1)) THEN
EXIT;
END_IF;
G00 X(#12+#14) Y(#13+#15);
G01 X(#12+#14) Y(#13-#15);
G01 X(#12-#14) Y(#13-#15);
G01 X(#12-#14) Y(#13+#15);
G01 X(#12+#14) Y(#13+#15);
#14 := #14 + 2.0;
#15 := #15 + 1.5;
END_FOR;
M30;
Ex Program Annotation(comment)
Example 1 %@MACRO
Single line annotation G00 G90 X0. Y0.; // homing
M30;
Language Instructions – 17
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Example 2 %@MACRO
Block annotation (*
This block is the annotation area
Regardless of the content, it does not affect program execution.
*)
G00 G90 X0. Y0.;
G00 G90 X10. Y0.;
G00 G90 X10. Y10.;
G00 G90 X0. Y10.;
G00 G90 X0. Y0.;
M30;
Remark If a text that is an annotation is added to the statement list, system error may
occur due to the limitation while interpreting the code. This misuse is not under
the protection of the controller.
Syntax %
Execution Program
%
Explanation 1. While there is "%...%" in the program, the execution program between
two % will be executed by CNC. For those program prior to the first %
and after the second % will not be executed.
Language Instructions – 18
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
A #1 J #5 T #20
B #2 K #6 U #21
C #3 L #12 V #22
D #7 M #13 W #23
E #8 P #16 X #24
F #9 Q #17 Y #25
I #4 S #19 X1 GETARG(X1)
• Modal Variables ( #2001 ~ #2100, #3001 ~ #3100) will return to the VACANT state when the system is reset, so
it can be applied to the timing of data exchange between multiple MACROs to save the use of variable
resources.
• If a default initial value is required for MACRO, Customer Parameter is recommneded(#4001 ~ #4100, #5001
~#5100).
• When the MACRO sub-routine (sub-program) is executed, if the mode G code is changed (G91/G90, G40/G41/
G42, ..., etc.), please back up the current state, and restore the original mode G state before leaving the
MACRO.
• If user want to keep the current MACRO interpolation mode (#1000) after leaving MACRO, it is recommended
to designate #1000 as the MACRO number before leaving MACRO. As long as there is single block of the axial
displacement, the system will automatically call this MACRO without specifying it again.
• The interpolation mode will be automatically rewritten when G00/G01/G02/G03/G31/G33 show up or
#1000 change.
• For length or angle arguments, use the STD function to normalize the unit before operation to match the
usage habits of machine tool.
• Change to the setting of coordinate system is strictly forbidden, such as G92/G54/G52 which are relevant to
coordinate system. Otherwise, the simulation would be useless.
• When machining, the core will pre-interpret the MACRO content, so the MACRO progress is ahead of the
practical G/M code. If the variable specification or the data reading needs to synchronize with the G/M code,
please add WAIT function before the variable specification or the data reading to ensure the movement is
correct.
• The MACRO program must be added with "M99;" to return to the main program (parent program).
• Develop good habits, add more comments to the program, this will increase program readability, and help
subsequent maintenance and troubleshooting.
0 none none
-1 G00 G0000
1 G01 G0001
2 G02 G0002
3 G03 G0003
4 G53 G0053
5 G40 G0040
6 G41 G0041
7 G42 G0042
8 G43 G0043
9 G44 G0044
10 G49 G0049
• The following are the operating specifications for the G code macro
• Macro feature is treated as G code macro feature
• All G codes in the login G code macro are standard G codes.
• In old standard login G code macro, the only usable funtion is G900000, which executes G00.
• The login G code macro has the same inheritance function as the general interpolation mode (except
G53)
• Example:
G00 X100.
Y100.
Where Y100. will also execute the G00 macro, and can read the occupied Y argument
• The login G code macro is not different from the general interpolation G code in interpretation, and
can be completely replaced by it.
• If user change the interpolation mode in the login G code macro, be sure to restore the interpolation
mode before leaving the login macro.
• For example, if user login G00 as the login G code macro
In the macro G0000, if user change the interpolation state to G01, user need to change the
interpolation mode back to G00 before leaving G0000 in order to avoid the state disorder.
• The login G code macro will not work when it encounters the following instructions.
• Lathe G7.1
• Lathe G12.1
• Lathe, A
• Lathe, R
• Lathe, C
• Lathe All machining cycle instructions
• Mill All machining cycle instructions
• T code macro
• Use of G53 is the same as the rest of G code macro except the non-interpolation mode.
• Version revision
Version Revision
8 Function List
Function Explanation
ATAN Calculate the atan of a value. The calculation result is between ±90°.
Example:
#10 := 1;
#1 := ATAN(#10); // #1 = 45
#2 := ATAN(-1); // #2 = -45
Function Explanation
ATAN2(Y, X) Calculate the four-quadrant atan value of Y/X. The calculation result is between
±180°.
Example:
#10 := 1;
#20 := -1
#1 := ATAN2(#10, #20); // #1 = 135
#2 := ATAN2(#20, #10); // #2 = -45
#3 := ATAN2(1, 0); // #3 = 90
Notes:
1. Valid version: 10.118.29W, 10.118.40C, 10.118.42
2. The argument X and Y must be numbers, or the alarm COR-023【Semantic
error】will be issued.
3. The argument X and Y can not be zero at the same time, or the alarm COR-004【
Operation domain error】will be issued.
Example of wrong cases:
@1 := ATAN2( "1", 1 ); // The first argument is not a number, issue COR-023 alarm.
@2 := ATAN2( 0, 0 ); // The arguments are both zero, issue COR-004 alarm.
AXID Inquire the axis number corresponding to the axis name. If the axis name does not
exist, the return value is blank (VACANT, #0)
Example:
Suppose the sixth axis name is Y2 (Pr326=202) and the second axis name
is Y (Pr322=200).
#1 := AXID(Y); // #1 = 2
#2 := AXID(Y2); // #2 = 6
CEIL Return the smallest integer greater than or equal to a certain value
Example:
#10 := 1.4;
#1 := CEIL(#10); // #1 = 2
#2 := CEIL(1.5); // #2 = 2
CLOSE Close the file opened by the OPEN function, and the file will be automatically
closed after the program ends. The PRINT function will fail if the file is already
closed.
Example:
CLOSE(); // close the file
Function Explanation
DBLOAD Read the data of specified index from the currently loaded XML. For related
applications, please refer to the appendix.
Example:
DBOPEN("FLAT\\TAB01");
// Load FLAT\\TAB01 data file
DBLOAD( 0 );
// read the 0th cycle
DBLOAD( 1 );
// read the 1st cycle
Note: The file path to the XMLDB may be influenced by customized Action
(CUSTOMFILE_CYCLE1~5), please refer to CE人机客制应用文件.
DBSAVE Save the data of specified index from the currently loaded XML. For related
applications, please refer to the appendix.
EX:
Notes:
1. The file path for XMLDB can be changed by Customized Actions (CUSTOMFILE_C
YCLE1~5). Fore more info, refer to CE人机客制应用文件-開放使用的Action列表 。
2. Opening (DBOPEN) and loading (DBLOAD) must be done before saving
(DBSAVE). If the user uses DBSAVE without using DBPEN and DBLOAD beforehand,
the saving process will NOT be executed.
3. Versions: 10.118.39 and later.
Function Explanation
DBOPEN Load the specified XML. The XML should be in the GNCFILES specified by the user.
For related applications, please refer to the appendix.
Example:
DBOPEN("Test.cyc");
// Load GNCFILES\\Test.cyc
Example:
#1 = 51;
DBOPEN("FLAT\\\\AB#1[3]ZZ.cyc" );
// Load FLAT\\\\AB051ZZ.cyc, [3] indicates that the file name is in
three valid digits
Note1: The file path to the XMLDB may be influenced by customized action
(CUSTOMFILE_CYCLE1~5), please refer to CE人机客制应用文件.
Note2: For the requirement of reloading file, please reset system ( or run BGnd
Stop in Background Running Objects ) before re-execute DBOPEN.
DRAWHOLE Draw a circle based on the tool radius and the color defined by the SETDRAW
function at the current position (only valid in the simulation, system will not add a
circle in the actual path)
EXP Calculate the exponential value with natural number as the base
Example:
#1:=EXP(1); // e^1 = 2.71828
Valid version: 10.116.16
FLOOR Return the largest integer less than or equal to a certain value
Example:
#10 := 1.4;
#1 := FLOOR(#10); // #1 = 1
#2 := FLOOR(1.5); // #2 = 1
Function Explanation
GETTRAPARG Read the argument content in Trap Block. Trap Block is the blocks between G66/
G66.1 and G67.
Example:
Assume that the main program content of O0001 is
G66 P100 X100. Y100. // P100 means call sub-program O0100.
G01 X20. // O0100 sub-program uses GETTRAPARG to read the argument
content
#1 := GETARG(X);
// Save the X argument 100. to #1
#2 := GETTRAPARG(X);
// Save the X argument in the Trap block, 20. to #2
Please refer to G66/G67:Call Modal Macro.
Function Explanation
MSG Customize the message, please refer to the "MACRO Customized Message" for
details.
Example:
MSG(100); // message ID
MSG("bit lost"); // display message content
MSG(100, "bit lost"); // hint ID + displaye message content
Remark: There is limit of string length in a message. For Mandarin, it's 19 words;
For English, it's 39 alphabets.
Function Explanation
OPEN ("file name") or Open a text file name of which user specify, which is in the NcFiles folder ( Folder
path please refer the Pr3219 ). The PRINT function is valid only after the file is
OPEN ("file name",
opened.
"writing mode")
If the file name is "COM", it means that the port RS232 is turned on, and its setting
is determined by Pr3905.
Example:
OPEN("COM"); // Open port RS232
PRINT("\\p"); // Output '%' character
FOR #1 = 1 TO 5000 DO
#30 := #1 * 10.;
PRINT("G01 X#30"); // Output G01 X10.0
END_FOR;
PRINT("\\p"); // Output '%' character
CLOSE(); // Close port
The "writing mode" determines, when the file is opened, whether the original file
content is retained or cleared. (valid version: 10.116.36I)
(i) "a": Keep the original text and the text newly-output follows the original one.
Example:
OPEN("PROBE.NC", "a");
// Open PROBE.NC and keep the text, and be ready for text output
(ii) "w"/nothing: Clear the original text and output the new text in the file.
Example:
OPEN("PROBE.NC");
// Open PROBE.NC and clear the text, and be ready for text output
OPEN("PROBE.NC", "w");
// Open PROBE.NC and clear the text, and be ready for text output
(iii) Wrong writing mode: system issues alarm, COR-301 OPEN command format
error.
Example:
OPEN("PROBE.NC", "abc");
// Wrong writing mode, issues alarm, COR-301, so PROBE.NC is not opened
for text output.
(iv) Convert # or @ variable into a string, and the decimal digits is determined by
Pr17 (valid version: 10.118.12C)
Function Explanation
(v) Convert # or @ variable into a string with [*] in the end, and the decimal digits is
determined by this variable.
POP Taking the data in STACK from top layer to bottom layer in sequence. User must
pay attention to the total data in the stack. If there are 5 data, the maximum times
to use POP is 5.
Example:
PUSH(5); // Insert the number 5 into the stack
#1 := POP(); // Remove the topmost value in the stack (#1 = 5)
Function Explanation
PRINT This function is used to output a string, and the variable in the output string will be
replaced by the content of it.
The character "\" is an escape character, and the related special characters are
defined as follows:
"\\": indicates "\" character
"\@": indicates "@" character
"\#": indicates "#" character
"\p": indicates"%" character
Convert # or @ variable into a string, and the decimal digits is determined by Pr17
(valid version: 10.118.12C)
Convert # or @ variable into a string with [*] in the end, and the decimal digits is
determined by this variable.
Example:
Assume that Pr17=2 in metric unit
@53 = 20 ;
#3 = 23.1234 ;
PRINT("G01 X#3 Y@53 Z20.0") ;
The output is G01 X23.123 Y20 Z20.0 ; // Display to thousandths place
Example:
@53 = 20 ;
#3 = 23.1234 ;
PRINT("G01 X#3[2] Y@53 Z20.0") ; // #3[2] means display to hundredths
place
The output is G01 X23.12 Y20 Z20.0 ; // Display to hundredths place
PUSH Stuff data into the STACK, the data PUSH into the controller first will be stacked on
the bottom layer, and the last data on the top one.
Example:
PUSH(#1); // Put variable #1 into the STACK
Function Explanation
READDI The value of variable derives from the I/O point number in the parentheses
READDI/READDO.
(I point number)
Example:
READDO
@52 := READDI(31); // Read the value of I31 and put it in @52
(O point number)
#88 := READDO(11); // Read the value of O11 and put it in #88
G90 G10 L1000 P4000 R READDI(15); // Read the value of I15 and put it in
R4000
Notes:
1. Valid version: 10.116.23
2. The I/O point is read during pre-interpreting, but it is processed when READDI /
READDO is executed in order to avoid the error resulting from pre-interpreting
I/O point. Because system await until READDI / READDO is executed, machine
will decelerate to zero.
3. The range of I/O point number is 0~511. If the number is out of the range,
system issues alarm, COR-138 Read/write command format error at the I/O/A
point.
READABIT The value of variable derives from the A point number in the parentheses of
READBIT.
(A point number)
Example:
@52 := READABIT(31); // Read the value of A31 and put it in @52
#88 := READABIT(11); // Read the value of A11 and put it in #88
Notes:
1. Valid version: 10.116.44
2. The A point is read during pre-interpreting, but it is processed when READBIT
is executed in order to avoid the error resulting from pre-interpreting A point.
Because system await until READBIT is executed, machine will decelerate to
zero.
3. The range of A point number is 0~511. If the number is out of the range, system
issues alarm, COR-138 Read/write command format error at the I/O/A point.
Function Explanation
READRREGBIT The value of variable derives from the register number and specified bit in the
parenthesis of the READRREGBIT.
(Register number,
specified Bit) Example:
@52 := READRREGBIT(31,3); // Read the value of the third bit of R31 and put
it in @52
Notes:
1. Valid version: 10.116.39
2. The register is read during pre-interpreting, but it is processed when
READRREGBIT is executed in order to avoid the error resulting from pre-
interpreting Register. Because system await until READBIT is executed,
machine will decelerate to zero.
3. If register is less than 0 or greater than 65535, the system issues alarm,
COR-135 Read/write command format error for R value.
4. If register is an incorrect character, system issues alarms, COR-5 Program
loading failure and COM-8 absent statement ending character ';'.
5. If specified bit is less than 0 or greater than 31, system issues alarm,
COR-135 Read/write command format error for R value.
6. If specified bit or both of register and specified bit is incorrect characters,
system issues alarm, COR-5 Program loading failure and COM-9 wrong
assignment character ':='.
Function Explanation
SCANTEXT This function is used to read the contents of the string stored in global variable.
When the string is stored in global variable, the controller translate it into ASCII
first and save. User get wrong string if they output the value directly. To get the
correct string, please make good use of this function.
Example:
%@MACRO
@1:="12"; // 16 carry HEX=3231, 10 carry DEC=12849
#1:=SCANTEXT(1);
OPEN("NC");
PRINT("@1");
PRINT("#1");
CLOSE();
M30;
The result is @1 = 12849
#1 = 12
SETDO Determine O point number and the state (1: On, 0: Off) with 2 numbers in the
parenthesis of SETDO.
(O point number,
Example:
O point on or off)
SETDO(3, 1); // Set O3 on
SETDO(8, 0); // Set O8 off
Notes:
1. Valid version: 10.116.23
2. The writing of point O is in the interpolation stage, so it is not necessary to
decelerate to 0 during execution. However, in the MACRO processing in pre-
interpreting stage, the developer should decide whether to use WAIT, which
makes machine decelerate to 0.
3. Mixed use of PLC and SETDO should be avoided. For example, O1 is on by
SETDO in MACRO, but off in PLC. Even though the previous order is overridden
by the next one, it is common to confuse while using both, so it is
recommended that use one of them at a time.
4. The range of O point number is limited to 0~511. If the range is wrong, the
system issues alarm, COR-138 Read/write command format error at the I/O/A
point.
Function Explanation
SETABIT Determine A point number and the state (1: On, 0: Off) with 2 numbers in the
parenthesis of SETDO.
(point A, point A on or off)
Example:
SETABIT(3, 1); // Set A3 on
SETABIT(8, 0); // Set A8 off
Notes:
1. Valid version: 10.116.44
2. The writing of point A is in the interpolation stage, so it is not necessary to
decelerate to 0 during execution. However, in the MACRO processing in pre-
interpreting stage, the developer should decide whether to use WAIT, which
makes machine decelerate to 0.
3. Mixed use of PLC and SETABIT should be avoided. For example, A1 is on by
SETABIT in MACRO, but off in PLC. Even though the previous order is
overridden by the next one, it is common to confuse while using both, so it is
recommended that use one of them at a time.
4. The range of A point number is limited to 0~511. If the range is wrong, the
system issues alarm, COR-138 Read/write command format error at the I/O/A
point.
SETRREGBIT Determine Register number, Bit number, and the state (1: On, 0: Off) with the 3
digits in the parenthesis of SETRREGBIT.
(Register number, Bit
number, on or off) Example:
SETRREGBIT(50,3,1); // Set the third R50 Bit on
SETRREGBIT(50,4,0); // Set the fourth R50 Bit off
Notes:
1. Valid version: 10.116.39
2. The writing of Register is in the interpolation stage, so it is not necessary to
decelerate to 0 during execution. However, in the MACRO processing in pre-
interpreting stage, the developer should decide whether to use WAIT, which
makes machine decelerate to 0.
3. Mixed use of PLC and SETRREGBIT should be avoided. For example, first Bit of
R50 is on by SETRREGBIT in MACRO, but is off in PLC off. Even though the
previous order is overridden by the next one, it is common to confuse while
using both, so it is recommended that use one of them at a time.
4. If Register number is less than 0 or greater than 65535, the system issue alarm,
COR-135 Read/write command format error for R value.
5. If Bit number is less than 0 or greater than 31, system issues alarm,
COR-135 Read/write command format error for R value.
6. If the state is not 0 (off) or 1 (on), system issues alarm, COR-135 Read/write
command format error for R value.
7. If any argument is incorrect character, system issues alarms, COR-5 Program
loading failure and COM-3 Syntax error.
Function Explanation
0 0 8 8421504
1 8388608 9 16711680
2 32768 10 65280
3 8421376 11 16776960
4 128 12 255
5 8388736 13 16711935
6 32896 14 65535
7 12632256 15 16777215
Note:
SETDRAW sets path color and filled color at the same time. If user would like to
make path color and filled color different, remember to change the path color with
SETDRAW after DRAWHOLE is executed.
Example:
%@MACRO
#3:=SETDRAW(#1,#2,#18);
// #3 records the original path color, #2 defines the filled color, #18 defines
the circle radius
DRAWHOLE();
Function Explanation
SETDRAW(#3);
// Change the path color after drawing the circle
M99;
SIGN Return the sign of a value, the negative number is -1, the positive number is 1, and
0 is 0.
Example:
#10 := 4;
#1 := SIGN(#10); // #1 = 1
#2 := SIGN(-4); // #2 = -1
#3 := SIGN(0); // #3 = 0
SLEEP Temporarily abandon the execution right of this macro loop, generally used in
conjunction with the loop (FOR, WHILE..., etc.) to avoid entering the infinite loop,
which causes the human-machine to crash.
Example:
SLEEP();
Function Explanation
STD (argument1, According to Pr17, the value is converted into the input unit (Input Unit, IU) set by
argument 2) the system at that time.
1. The argument 1 is the value the unit of which is about to be changed.
2. The argument 2 is a standard unit. Generally, it is #1600, and value of #1600 is
from Pr17.
Metric Unit:
Example 1:
When Pr17=2, #1600 corresponds to LIU = 0.001mm
#9 := 100;
#10 := STD(#9,#1600); // #9 is 100 BLU, so #10 is 0.1mm (100*0.001)
Example 2:
When Pr17=3, #1600 corresponds to LIU = 0.0001mm
#9 := 100.;
#10 := STD(#9,#1600); // #9 is 100 BLU, so #10 is 0.01mm (100*0.0001)
Imperial:
Example 3:
When Pr17=2, #1600 corresponds to LIU = 0.0001inch
#9 := 100;
#10 := STD(#9,#1600); // #9 is 100 BLU, so #10 is 0.01inch (100*0.0001)
STDAX (argument 1, Converts the value to the standard unit of the corresponding axis.
argument 2)
The argument 1 is a variable, and the argument 2 is the name of the corresponding
axis.
Example:
#24 := STDAX(#24,X);
#3 := STDAX(#3,A);
Function Explanation
WAIT The system stops pre-interpreting until the instruction before WAIT is finished.
Example:
%@MACRO
@50 := 1; // @50 equals to 1
G90 G01 X100. F1000; // Assume to system is Reset at this time
WAIT();
@50 := 0; // @50 equals to 0
M30;
Assume that the system is reset when G01 is in execution. Since the block
before WAIT is not finished, @50 equals to 1 after Reset.
Function Explanation
CHKSN ("Serial No.") Check Serial Number. 1: consistent, 0: does not match
Example:
%@MACRO
#52 := CHKSN("M9A0001"); //The value of #52 is the checking result
IF #52=0 THEN
ALARM(502, "The serial number is invalid."); //If the serial
number does not match, system issues the alarm
END_IF;
Target version: 10.116.6A
CHKMT ("Machine Type") Check machine type. 1: consistent, 0: does not match
Example:
%@MACRO
#53 := CHKMT("MILL"); //The value of #53 is the check result
IF #53=0 THEN
ALARM(503, "The machine type is invalid."); //If machine type does
not match, system issues the alarm
END_IF ;
Target version: 10.116.6A
CHKMI ("Model") Check the controller model, 1: consistent, 0: does not match
For SUPER series, please input 'S'. For other models, please input value according
to the actual model. For example, 10B =>10B, 11A, => 11A.
Example:
%@MACRO
#54 := CHKMI("S"); //#54 is the checking result
IF #54=0 THEN
ALARM(504, "The hardware type is invalid."); //If the model does not
match, system issues the alarm
END_IF;
Target version: 10.116.6A
Function Explanation
CHKINF( category number, Check if the code corresponds to the category number. 1: consistent, 0:
"code") does not match
The range of category numbers is 1~5, each corresponding code is:
1. Machinery code
2. Serial No.
3. Machine Type
4. Model
5. Industrial machine ID
For SUPER series, please input 's'. For other models, please input value according
to the actual model. For example, 10B =>10B, 11A, => 11A.
Example:
%@MACRO
#51 := CHKINF(1, "5566"); // #51 is the checking result
IF #51=0 THEN // If the machineny code does not match, system issues an
alarm
ALARM(501, "The manufacturer code is invalid.");
END_IF;
#52 := CHKINF(2, "M9A0001"); // #52 is the checking result
IF #52=0 THEN // If the serial No. does not match, system issues the alarm
ALARM(502, "The serial number is invalid.");
END_IF;
#53 := CHKINF(3, "MILL"); // #53 is the checking[ result
IF #53=0 THEN // If the machine type does not match, system issue the
alarm
ALARM(503, "The machine type is invalid.");
END_IF;
#54 := CHKINF(4, "S"); // #54 is the checking result
IF #54=0 THEN // If the model does not match, system issues the alarm
ALARM(504, "The hardware type is invalid.");
END_IF;
#55 := CHKINF(5, "10"); // #55 is the checking result
IF #55=0 THEN // If the Industrial machine ID does not match, system issues
the alarm
ALARM(505, "The industrial machine ID is invalid.");
END_IF;
If argument is incorrect, or the category number is out of the range, system issues
the alarm, COR-353 【Invalid argument of CHKINF】
Example:
%@MACRO
#51 := CHKINF(60, "Mill"); // category number is out of range
#51 := CHKINF("2", "Mill"); // argument 1 is incorrect
#53 := CHKINF(5, 12345); // argument 2 is incorrect
Target version: 10.118.22M、10.118.28B、10.118.30
Function Explanation
Function Explanation
Function Explanation
// alarm COR-023
DRVDATA( "1003", 3425 ); // first argument must be integer
DRVDATA( 1003, "G21h" ); // if second argument is string type, must be
hexadecimal format ("xxxh", x=0~F)
DRVDATA( 1003, "3425" ); // if second argument is string type, must be
hexadecimal format ("xxxh", x=0~F)
DRVDATA( 1003, "0D61h" ); // if second argument is string type, must be
hexadecimal format ("xxxh", x=0~F)
// alarm COR-016
DRVDATA( 1003, "DFFh" ); // drive is not suupot this status No.
// return VACANT
DRVDATA( 9999, "D61h" ); // no drive corresponding to station number
DRVDATA( 9999, "DFFh" ); // if no drive corresponding to station
number, will not check the status variables No.
9 Call sub-Program
9.1 Calling Methods
Syntax Explanation Calling Local Variable Example
Type
M98 P_ H_ Call sub-program Sub- Inherit the local variables #1~#400 M98 P10 L2;
L_ program from main/parent program
P_Sub-program Explanation:
Name
Call O0010 twice
H_Starting of block
sequence No.
L_Repeated
Counts
M198 P_ H_ Call sub-program Sub- Inherit the local variables #1~#400 M198 P10 L2;
L_ program from main/parent program
P_Sub-program Explanation:
( If M198 is Name
Call O0010 twice
not logged
H_Starting of
in Pr3601~)
block sequence
No.
L_Repeated
Counts
G65 P_L_ Call Single Macro Macro Create new local variables G65 P10 Lw X10.0
#1~#400, and #1~#26 records the Y10.0
P_Subroutine
corresponding argument in the
Name Explanation:
calling block
L_Repeated Call O0010 twice, and
Counts input argument
G66 P_L_ Use movement Mode Create an independent section of G66 P10 X10.0 Y10.0;
instruction to call Macro #1~#400 each time G66 is called.
X20.
mode macro Local variables in this section will
be shared until executing G67. Y20.
P_Subroutine
After executing G67, local variables
Name Explanation:
in this section will be retrieved and
L_Repeated cleared. Moving instructions
Counts X20. and Y20. call
Note:
O0010, and input
The local variables in the section arguments X10.0,
are shared with sub-program Y10.0.
called by P argument (G66 P) only.
They are different from the local
variables in the program where
G66/G66.1 is called.
G66.1 P_ L_ Each block calls Mode The same as G66. G66.1 P10 X10.0
mode macro Macro
X20.
P_Sub-program
G04 X2.
Name
M30
L_Repeated
Counts Explanation:
Each block calls
O0010 and input
argument X10.0.
G_L_ Call expansion G Macro Create a new section of local G128 L3 X1.0
Code. variables #1~#400 each calling,
Explanation:
and restore local variables in main
L_Repeated
program when the Macro is Call G0128 three
Counts
finished. times.
Notes:
• If L argument above isn’t assigned, the default value is 1.
• The life cycle of local vaiables (#1~#400) in above form, please refer to Macro Variable Specification.
Example of Variable Life Cycle:
10 Variable Specification
For the explanation of # and @ variable, please refer to Macro Variable Specification.
11 MACRO Customized Alarm
11.1 MACRO Alarm Trigger Syntax
%@MACRO
ALARM(xxx);// xxx is the Alarm number
M30;
13 Appendix
13.1 Macro User Guide
13.1.1 Preface
• The built-in G, T, M code may not satisfy demand from all walks of life, so Syntec Corp. provides
"customizing macro" for customer.
Developer is able to, according to the machine properties, develop macros with special actions, which
greatly promotes the machine value.
• Before introduction, the methods of calling other programs in main program are as below:
• Call sub-program: execute sub-program, while reading or occupying argument is forbidden.
• Call macro: execute macro, while reading and occupying argument is allowed.
• For argument definition please refer to Argument Explanation.
• The following sections introduces related specification of macro, and the specification of calling sub-
program will be skipped.
Appendix – 53
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
G200.010
G200.100 G200100
Appendix – 54
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Appendix – 55
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Appendix – 56
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
T Effe
y ct
p
e
G Call
6 assi
6 gne
. d
1 pro
gra
m
thro
ugh
mac
ro
whe
n ev
ery
bloc
k is
finis
hed.
● Must be
the last G
code in that
row.
Appendix – 57
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
T Call T1000 Pr3215 Enable • File name can only be T0000, other file names are not T0000
Co file through T code call allowed.
de macro. mode must be • No file extension.
Ma 2.
cr
o P Type
r
3
2
1
5
0 • T
co
de
su
ppl
em
ent
ary
co
de
• do
es
not
cal
l
T0
00
0
1 • Cal
l
T0
00
0
thr
ou
gh
su
b-
pro
gra
m.
Appendix – 58
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
P Type
r
3
2
1
5
• Do
es
not
rea
d
an
d
occ
up
y
an
y
arg
um
ent
2 • Cal
l
T0
00
0
thr
ou
gh
ma
cro
.
• Re
ad
an
d
occ
up
y
an
y
arg
um
ent
Appendix – 59
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Appendix – 60
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Example_Main
1 // Main
2 G90;
3 G01 X10. F100.; // X Axis moving by G01 result X=10.
4 G200; // X Axis moving by G200 result X=20.
5 X-20.; // X Axis moving by G01 result X=-20.
6 M30;
Example_G0200
1 // G0200
2 %@MACRO
3 #101 := #1000; // Backup #1000, G00/G01/G02/G03/G33/G34/G35
4 #102 := #1004; // Backup #1004, G90/G91
5 G91 G00 X10.; // X coordinate increase in increment of 10 by
G00. result X=20.;
6 G#101; // Restore #1000, G00/G01/G02/G03/G33/G34/G35
7 G#102; // Restore #1004, G90/G91
8 M99; // Return to main program
Example_Main
1 // Example002_Main
2 G90 G00 X0. Y0.;
3 G200;
4 G201;
5 G202 X30.;
6 M30;
Appendix – 61
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Example_G0200
1 // G0200
2 %@MACRO
3 #101:=#1000;
4 #102:=#1004;
5 G91 G01 X10.;
6 G91 G01 Y10.;
7 G91 G01 X-10.;
8 G91 G01 Y-10.;
9 G#101;
10 G#102;
11 M99;
Example_G0201
1 // G0201
2 %@MACRO
3 #101:=#1000;
4 #102:=#1004;
5 G91 G01 X20.;
6 G91 G01 Y20.;
7 G91 G01 X-20.;
8 G91 G01 Y-20.;
9 G#101;
10 G#102;
11 M99;
Example_G0202
1 // G0202
2 %@MACRO
3 #101:=#1000;
4 #102:=#1004;
5 #103:=#24;
6 G91 G01 X#103;
7 G91 G01 Y#103;
8 G91 G01 X-#103;
9 G91 G01 Y-#103;
10 G#101;
11 G#102;
12 M99;
Appendix – 62
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
A #1 J #5 S #19
B #2 K #6 T #20
C #3 L #12 U #21
D #7 M #13 V #22
E #8 N W #23
F #9 O X #24
G P #16 Y #25
I #4 R #18
Instruction
Appendix – 63
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Axis XYZ As long as one of the arguments is • B code is defined by Pr3806 Second
Argume occupied by a macro, other axis auxiliary code
ABC
nt arguments are also occupied by that
Pr380 Type Explanation
IJK macro.
6
UVW
0 Axis
Argument
Appendix – 64
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Conditi FSTDE Compared to axis argument, condition • T code is defined by Pr3215 Enable T
on HPQR argument is independent from each code call mode.
Argume MB other. If one of the condition argument
Pr32 Type Explanation
nt is occupied, only that one is occupied
15
instead of all condition arguments.
Appendix – 65
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
0 Axis
Argument
Appendix – 66
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
T code macro
3 S code
4 F code
5 H code
6 D code
7 T code
8 M code
9 B code
Appendix – 67
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Condition Character Argument reading and occupation Multi same code instruction in a row
T code macro • Pr3215 Enable T code call mode. This parameter is set up as
2. After rebooting, system regard T code as T code macro.
• If T code is considered T code macro, it only executes T code
macro if T argument (#20) is not occupied.
Condition Character Argument reading and occupation Multi same code instruction in a row
Category Character
Appendix – 68
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Category Character
T code macro • T code updates different variables according to the type of T code. Following are
corresponding updating rules.
Macro O X X
Sub-program O X X
Auxiliary Code O X O
Argument X O X
• If user want to capture T code value in a T code macro, please use T code
variable (#1036).
• If user want to capture T code value in other macros, please use T argument
(#20).
• Only when T code is auxiliary code, the corresponding R value of T code will be
updated. If T code is used as macro or argument, the corresponding R value of T
code is not updated.
M code macro • M code updates different variable according to the type of M code. Following are
corresponding updating rules.
Macro O X
Auxiliary Code X O
Argument O X
• #13 is updated in M code macro or argument. Please note that this is different
from specification of T code.
• Only when M code is auxiliary code, the corresponding R value of M code will be
updated. If M code is used as macro or argument, the corresponding R value of M
code is not updated.
Condition Character Argument reading and occupation Multi same code instruction in a row
Appendix – 69
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
G code and G • While executing G code macro, argument read by G code macro is occupied.
code macro • If axis argument is read, all axis arguments are occupied simultaneously.
T code macro • While executing T code macro, system read arguments which are needed to. No
matter whether argument is occupied or not.
• After executing T code macro, all arguments read by T code macro are occupied. If
axis argument is read, all axis arguments are occupied simultaneously.
• Repeated count of T code macro is not defined by L code, and T code macro always
executes only one time.
• The L code argument (#12) is not read by system, even if there is one in T code macro.
System just puts 1 into #12.
M code macro • After executing M code macro, system occupies all arguments which are read by M
code macro.
• If M code macro doesn’t read T argument, then after finishes executing M code
macro, T argument is not occupied.
• If M code macro reads T argument, then after finishes executing M code macro,
T argument is occupied.
Condition Character Argument reading and occupation Multi same code instruction in a row
Appendix – 70
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
T • If multi T code macros are in the same row. Each T code is interpreted sequentially and each T code macro can read ar
c
o
d
e
m
a
cr
o
Appendix – 71
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
M • If multi M code macro are in the same row, only the first M code macro is interpreted.
c • Pr3810 Parallel executing multiple M code in one block is for auxiliary M code not M code macro. Hence, even if Pr3810
o
d
e
m
a
cr
o
Condition Character Argument reading and occupation Multi same code instruction in a row
Other command in macro
Appendix – 72
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Main
1 // Main
2 G200 A1 B2 C3 D7 E8 F9 H11 I4 J5 K6 L12 M13 P16 Q17 R18 S19 T20 U21
V22 W23 X24 Y25 Z26;
3 M30;
G0200
1 // G0200
2 %@MACRO
3
4 //Axis Argument
5 @101 := #1; // A
6 @102 := #2; // B
7 @103 := #3; // C
8 @104 := #4; // I
9 @105 := #5; // J
10 @106 := #6; // K
11 @121 := #21; // U
12 @122 := #22; // V
13 @123 := #23; // W
14 @124 := #24; // X
15 @125 := #25; // Y
16 @126 := #26; // Z
17
18 //Condition Argument
19 @107 := #7; // D
20 @108 := #8; // E
21 @109 := #9; // F
22 @111 := #11; // H
23 @113 := #13; // M
24 @116 := #16; // P
25 @117 := #17; // Q
26 @118 := #18; // R
27 @119 := #19; // S
28 @120 := #20; // T
29
30 //Special Argument
31 @112 := #12; // L
32
33 M00; // Switch the screen to [Diag.] →
[Display Global] and [Display Coord.]
34 WAIT();
35 M99;
Appendix – 73
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
02_Repeated argument
• Only the last repeated argument is read.
• Because same argument put value into the same # variable, the last one overrides the previous one.
Main
1 // Main
2 G01 X0.;
3 G200 X10. X-10.; // X argument has been written twice, only X-10
is read by G200
4 // #24 is input 10 by X10 first
5 // then input -10 by X-10.
6 // G01 will be executed after completing G200,
7 // because G01 can't read any argument X which
is occupied by G200
8 M30;
G0200
1 // G0200
2 %@MACRO
3 #100 := #1000; // Backup interpolation mode
4 #101 := #24; // The #24 is -10.
5 G01 X#101; // Move to X-10.
6 M00;
7 WAIT();
8 G#100; // Restore to interpolation mode
9 M99;
Appendix – 74
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Main
1 // Main
2 G01 X0. Y0. Z0.;
3 G200 X10. Y20. Z30.; // Though G200 only reads X
argument
4 // Y, Z arguments are also
occupied
5 // G01 will be executed after
completing G200
6 // because G01 can't read any
argument which is occupied by G200
7 G01 X0. Y0. Z0. F100.;
8 G201 P20. X10. Y20. Z30. F200.; // Since G201 only reads P
argument
9 // X, Y, Z, F arguments are not
occupied
10 // G01 will be executed after
completing G201 and
11 // read X10. Y20. Z30. F200.
12 // , and then execute the
corresponding actions
13 M30;
G0200
1 // G0200
2 %@MACRO
3 @1:=#24; // Only reads X argument
4 M00;
5 WAIT();
6 M99;
G0201
1 // G0201
2 %@MACRO
3 @1:=#16; // Only reads P argument
4 M00;
5 WAIT();
6 M99;
Appendix – 75
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Main
1 // Main
2 G01 X0. Y0. Z0.;
3 G200 X10. Y20. Z30. H40.; // G200 only reads H argument
4 // H argument is a condition
argument
5 // G01 will be executed after
completing G200.
6 // G01 read and occupy X10. Y20.
Z30.
7 // and then execute the
corresponding actions
8 M30;
G0200
1 // G0200
2 %@MACRO
3 #101 := #11; // Only reads H argument
4 M00;
5 WAIT();
6 M99;
Appendix – 76
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Main
1 // Main
2 G01 X0. Y0. Z0.;
3 G200 X10. Y20. Z30. H40.; // G200 only reads H argument
4 // Since Pr3809=1, the H
argument is regarded as both axis argument and condition argument
5 // However, it is occupied as a
condition argument in MACRO
6 // G01 is executed after
completing G200
7 // G01 reads and occupies X10.
Y20. Z30. H40., and
8 // system executes the
corresponding action
9 // Since the axis argument of
H40. is not occupied, it is then occupied as an axis argument by
10 // G01 again.
11 M30;
G0200
1 // G0200
2 %@MACRO
3 #101 := #11; // only reads H argument
4 M00;
5 WAIT();
6 M99;
• When reading axis arguments in MACRO, all the axis arguments will be occupied if one of them is occupied.
• As a result, the axis argument of H argument is occupied as well.
Appendix – 77
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Main
1 // Main
2 G01 X0. Y0. Z0.;
3 G200 X10. Y20. Z30. H40.; // G200 only reads X argument
4 // Since Pr3809=1, the H
argument is regarded as both axis argument and condition argument
5 // The axis argument of H
argument is also occupied
6 // G01 will be executed after
completing G200
7 // G01 can't read any argument
since the axis arguments are all occupied by G200.
8 // The axis argument of the H
argument is also included and won't be read.
9 M30;
G0200
1 // G0200
2 %@MACRO
3 #101 := #24; // Only reads X argument
4 M00;
5 WAIT();
6 M99;
Main
1 // Main
2 G01 X0. Y0. Z0.;
3 G200 X10. Y20. Z30. B40.; // G200 only reads B argument
4 // Since Pr3806=0, B argument is
regarded as an axis argument
5 // X, Y, Z arguments is occupied
by G200
6 // G01 is executed after
completing G200
7 // and G01 can't read any
argument since all arguments are occupied by G200
8 M30;
Appendix – 78
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
G0200
1 // G0200
2 %@MACRO
3 #101 := #2; // Only reads B argument
4 M00;
5 WAIT();
6 M99;
Main
1 // Main
2 G01 X0. Y0. Z0.;
3 G200 X10. Y20. Z30. B40.; // G200 only reads B argument
4 // Since Pr3806=1, B argument is
seen as a condition argument
5 // X, Y, Z arguments are not
occupied by G200
6 // G01 is executed after
completing G200
7 // G01 reads and occupies X10.
Y20. Z30., and
8 // executes the corresponding
actions
9 M30;
G0200
1 // G0200
2 %@MACRO
3 #101 := #2; // Only reads B argument
4 M00;
5 WAIT();
6 M99;
Appendix – 79
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Main
1 // Main
2 G01 X0. Y0. Z0.;
3 G200 G201 X10. P20.; // Since 2 G code macros are written in
the same line
4 // only the last G code macro is able to
read the argument
5 // Though G201 didn't read the X
argument
6 // G200 still can't read the X argument,
because X argument is axis argument
7 // G201 is executed after completing
G200, and
8 // G01 is be executed after G201 read
and occupied P argument
9 // G01 reads and occupies X10., and
10 // then executes the corresponding
actions
11 M30;
G200
1 // G0200
2 %@MACRO
3 #100 := #1000; // Backup interpolation mode
4 #101:=#24; // Read X argument which is unable to be
read
5 G01 X#101; // Since #101 has no value, this line
won't be executed
6 G01 X0.; // This line will be executed
7 M00;
8 WAIT();
9 G#100; // Restore interpolation mode
10 M99;
Appendix – 80
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
G201
1 // G0201
2 %@MACRO
3 #100 := #1000; // Backup interpolation mode
4 #101:=#16; // Read P argument which is able to be
read
5 G01 X#101; // This line will be executed
6 G01 X0.;
7 M00;
8 WAIT();
9 G#100; // Restore interpolation mode
10 M99;
Appendix – 81
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Main
1 // Main
2 G90;
3 G00 X0. Y0. Z0.; // G00, spindle moves to X0 Y0 Z0
4 G200 G01 X10. F100.; // Since 2 G codes are in the same line.
5 // only the last G code can read the
argument
6 // G200 is executed but no arguments are
read
7 // G01 X10. F100. is executed after
completing G200
8
9 G00 X0. Y0. Z0.; // G00, spindle moves to X0 Y0 Z0
10 G01 G201 X10. F100.; // Since 2 G codes are in the same line.
11 // G01 is interpreted first,
interpolation mode changes to G01.
12 // G201 is interpreted secondly.
13 // In G201, system executes G01 X10.
F100.
14 // Since G201 reads and occupies the
axis argument, all the axis arguments are occupied.
15 // Therefore, there is no moving
instruction left for G01, so no movement.
16
17 G00 X0. Y0. Z0.; // G00, spindle moves to X0 Y0 Z0
18 G01 G202 X10. F100.; // Since 2 G codes are in the same line
19 // G01 is explained first, interpolation
mode changes to G01
20 // G202 is interpreted secondely.
21 // In G202, no action is executed and no
arguments are read or occupied.
22 // Therefore, there are axis arguments
left for G01, so system executes G01 X10. F100.
23 M30;
Appendix – 82
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
G200
1 // G0200
2 %@MACRO
3 #100 := #1000; // Backup interpolation mode
4 #101 := #24; // Read X argument but it's unable to
read
5 G#100 X#101 F#9; // This line is not executed since #101
has no value. However, since #100=0, the interpolation mode changes
to G00.
6 M00;
7 WAIT();
8 M99;
G201
1 // G0201
2 %@MACRO
3 #100 := #1000; // Backup interpolation mode
4 #101 := #24; // Read X argument and read X=10.
5 G#100 X#101 F#9; // Because #100 = 1, system executes
G01.
6 M00;
7 WAIT();
8 M99;
G202
1 // G0202
2 %@MACRO
3 M00;
4 WAIT();
5 M99;
Appendix – 83
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Main
1 // Main
2 G01 X0. Y0. Z0.;
3 T01 X10. Y20. Z30.; // T argument is not occupied and Pr3215=2,
so
4 // system executes T code macro
5 // With X argument being read in T code
macro,
6 // Y, Z arguments are occupied by T code
macro because all of them are axis arguments.
7 // G01 is executed after completing T01
8 // G01 can't read any argument since the
arguments in the line are all occupied by T coda macro.
9 M30;
T0000
1 // T0000
2 %@MACRO
3 #101 := #24; // only reads X argument
4 M00; // Switch the screen to [Diag.] → [Display
Global] and [Display Coord.]
5 // Observe #20/#1036/#101
6 WAIT();
7 M99;
Appendix – 84
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Main
1 // Main
2 G01 X0. Y0. Z0.;
3 T01 G200 X10. Y20. Z30. F1000; // According to the
interpretation order, G code macro is interpreted first.
4 // There is a T argument read in
G code macro (G0200), so
5 // T argument is occupied and T
code macro is not executed.
6 // G01 is executed after
completing G code macro (G0200).
7 // G01 reads and occupies X10.
Y20. Z30. F1000, and
8 // executes the corresponding
actions
9
10 T02 G201 X10. Y20. Z30. F1000.; // According to the
interpretation order, G code macro is interpreted first.
11 // There is no T argument read
in G code macro (G0201), so
12 // T argument is not occupied,
and
13 // T code macro is executed
after G code macro (G0201) is completed
14 // Because T02 reads all
arguments, G01 can't read any argument
15 M30;
G0200
1 // G0200
2 %@MACRO
3 #101 := #20; // Only reads T argument
4 M00;
5 WAIT();
6 M99;
Appendix – 85
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
T0000_01
G0201
1 // G0201
2 %@MACRO
3 #101 := #24; // Only reads X argument
4 M00; // Switch the screen to [Diag.] → [Display
Global] and [Display Coord.]
5 WAIT();
6 M99;
Appendix – 86
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
T0000_02
1 // T0000
2 %@MACRO
3 #201 := #1000;
4 #202 := #1004;
5 #101 := #24;
6 #102 := #25;
7 #103 := #26;
8 #104 := #9;
9 M00; // Switch the screen to [Diag.] → [Display
Global] and [Display Coord.]
10 WAIT();
11 G91 G01 X#101 Y#102 Z#103 F#104; // T code macro can still read
the arguments and execute the corresponding actions
12
13 G#201;
14 G#202
15 M99;
Main
1 // Main
2 G01 X0. Y0. Z0.;
3 T01 L2; // Though T0000 reads #12,
4 // #12 is equal to "1", not "2" given by L argument
5 // Execute G01 after completed T01
6 // G01 reads and occupies L2, and
7 // executes the corresponding actions (G01 L2 is
meaningless)
8 M30;
T0000
1 // T0000
2 %@MACRO
3 #101 := #12; // Only reads L argument
4 M00; // Switch the screen to [Diag.] → [Display
Global] and [Display Coord.]
5 WAIT();
6 M99;
Appendix – 87
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Main
1 // Main
2 G01 X0. Y0. Z0.;
3 T01 T02 X10. Y20. Z30.; // This line is executed twice
4 // T01 is executed first then T02
5 // Both T code read X, Y, Z arguments
successfully
6 // If there is any other macro going to
read X, Y, Z,
7 // it reads nothing since arguments are
already occupied by T code macro.
8 // G01 is executed after completing T02
with all argument occupied.
9 M30;
T0000_T01
1 // T0000_T01
2 %@MACRO
3 #100 := #1000; // Backup interpolation mode
4 #101 := #24; // Read X argument
5 #102 := #25; // Read Y argument
6 #103 := #26; // Read Z argument
7 IF #1036 = 1 THEN // T01 → #1036=1
8 G01 X#101; // X axis moving
9 G01 X0.;
10 END_IF;
11
12 IF #1036 = 2 THEN // The section is not executed
13 G01 Y#102;
14 G01 Y0.;
15 END_IF;
16
17 M00; // Switch the screen to [Diag.] → [Display
Global] and [Display Coord.]
18 WAIT();
19 G#100; // Restore interpolation mode
20 M99;
Appendix – 88
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
T0000_T02
1 // T0000_T02
2 %@MACRO
3 #100 := #1000; // Backup interpolation mode
4 #101 := #24; // Read X argument
5 #102 := #25; // Read Y argument
6 #103 := #26; // Read Z argument
7 IF #1036 = 1 THEN // The section is not executed
8 G01 X#101;
9 G01 X0.;
10 END_IF;
11
12 IF #1036 = 2 THEN // T02 → #1036=2
13 G01 Y#102; // Y axis moving
14 G01 Y0.;
15 END_IF;
16
17 M00; // Switch the screen to [Diag.] → [Display
Global] and [Display Coord.]
18 WAIT();
19 G#100; // Restore interpolation mode
20 M99;
Appendix – 89
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Main
1 // Main
2 G01 X0. Y0. Z0. F100.;
3 M123 X10. Y20. Z30. F300.; // No M argument and no axis argument is
occupied, so
4 // M code macro M0123 is executed.
5 // While M code macro is executed, aside
from the arguments read by the M code macro,
6 // all other arguments are occupied as
well except T argument.
7 // Though the F argument is not read by
M0123, it is occupied, then the feedrate is not updated.
8 // G01, executed after completing M123,
9 // can't read any argument since the
arguments are all occupied.
10
11 G01 X0. Y0. Z0.; // The F in this line is F100, since the
argument in previous line is occupied by M code macro
12 M30;
M0123
1 // M0123
2 %@MACRO
3 #100 := #1000; // Backup interpolation mode
4 #101 := #24; // Read X argument
5 #102 := #25; // Read Y argument
6 #103 := #26; // Read Z argument
7 G00 X#101 Y#102 Z#103; // G00 moving along X, Y, Z axis
8 M00;
9 WAIT(); // Switch the screen to [Diag.] →
[Display Global] and [Display Coord.]
10 // user should found #13=123
11 // Switch the screen to [PLC Status] →
[PLC Register]
12 // User should found R1=0
13 G#100; // Restore interpolation mode
14 M99;
Appendix – 90
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Main
1 // Main
2 G01 X0. Y0. Z0.;
3 G1301 M1301 X10. Y20. Z30. P2 F1000.; // G code macro is
interpreted first.
4 // The M argument is read by
G code macro (G1301)
5 // The M argument is
regarded occupied, M code macro is executed.
6 // Since the X, Y, Z
arguments is not occupied by G code macro (G1301).
7 // G01 is executed after
completing the G code macro (G1301).
8 // G01 reads and occupies
X10. Y20. Z30. P2 F1000., and
9 // then executes the
corresponding instructions.
10
11 G1302 M1301 X10. Y20. Z30. F1000.; // G code macro is
interpreted first
12 // Only P argument is read
by G code macro (G1302)
13 // The M argument is
regarded unoccupied, and
14 // no other axis arguments
are occupied
15 // The M code macro is
executed after completing the G code macro (G1302)
16 // The M code macro (M1301)
do not read any argument,
17 // but all arguments except
T are regarded occupied after the M code macro is executed
18 // G01, executed after
completing the M code macro,
19 // can't read any argument
since the arguments are all occupied
20 M30;
G1301
1 // G1301
2 %@MACRO
3 #101 := #13; // Only reads M argument
4 M00;
5 WAIT();
6 M99;
Appendix – 91
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
M1301_01
G1302
1 // G1302
2 %@MACRO
3 #101 := #16; // Only reads P argument
4 M00;
5 WAIT();
6 M99;
M1301_02
1 // M1301
2 %@MACRO
3 M00;
4 WAIT(); // The program does not read any argument
5 // but occupies all the arguments except T
6 M99;
16_G code macro and M code macro are in the same line, and G code macro reads and
occupies axis argument.
• If Pr3601~3610 M code Macro call registry is set to 123, M0123 is registered as M code macro.
• When G code macro and M code macro are written in the same line, G code macro is interpreted before M
code macro.
• If axis arguments are occupied by G code macro, M code macro is not executed.
Appendix – 92
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Main
1 // Main
2 G01 X0. Y0. Z0.;
3 G200 M123 X10. Y20. Z30.; // G code macro is interpreted first
4 // Because X argument is read by G code
macro (G0200),
5 // all axis arguments are occupied by
G200.
6 // M code macro therefore is executed
since axis arguments are occupied.
7 // G01, executed after completing G code
macro (G0200),
8 // can't read any argument since the
arguments in the line are all occupied
9 M30;
G0200
1 // G0200
2 %@MACRO
3 #101 := #24; // Only reads X argument
4 M00;
5 WAIT();
6 M99;
M0123
Appendix – 93
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Main
1 // Main
2 G01 X0. Y0. Z0.;
3 M123 M124 X10. Y20. Z30.; // M123 is interpreted first, and only
M123 is executed.
4 // X10. Y20. Z30. are read by M code
macro (M0123)
5 // All arguments except T are occupied
after executing the M code macro.
6 // G01, executed after completing M code
macro,
7 // can't read any argument since the
arguments are all occupied.
8 M30;
M0123
1 // M0123
2 %@MACRO
3 #100 := #1000; // Backup interpolation mode
4 #101 := #24; // Read X argument
5 #102 := #25; // Read Y argument
6 #103 := #26; // Read Z argument
7 G00 X#101 Y#102 Z#103; // G00 moving along X, Y, Z axis
8 M00;
9 WAIT(); // Switch the screen to [Diag.] →
[Display Global] and [Display Coord.]
10 // User should found #13=124
11 // Since M124 is regarded as an
argument, which overwrote #13
12 G#100; // Restore interpolation mode
13 M99;
M0124
Appendix – 94
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
Main
1 // Main
2 G01 X0. Y0. Z0.;
3 T01 M1601 X10. Y20. Z30.; // According to the interpreting order,
T01 is interpreted first, then M1601.
4 // No argument is occupied by T code
macro, so M code macro (M1601) executes X=10.
5 // Although M code macro (M1601) does
not read any argument,
6 // all the arguments except T are
occupied
7 // G01, executed after completing M code
macro (M1601),
8 // can't read any argument since the
arguments are all occupied.
9
10 M1602 T02 X10. Y20. Z30.; // According to the interpreting order,
M1602 is interpreted first.
11 // M code macro (M1602) does not reading
any argument.
12 // Because M code macro (M1602) occupies
all arguments except T,
13 // T code macro (T0000_02) is able to be
executed since T argument is not occupied by M code macro.
14 // G01, executed after completing T code
macro,
15 // can't read any argument since the
arguments in the line are all occupied
16
17 M1603 T03 X10. Y20. Z30.; // According to the interpreting order,
M1603 is interpreted first.
18 // M code macro (M1603) only reads the T
argument
19 // M code macro (M1603) will occupy all
the arguments after the execution, including T argument.
20 // Then, T code macro (T0000_03) is
executed since T code here is regarded as an argument.
21 // G01 can't read any argument since the
arguments in the line are all occupied.
22 M30;
Appendix – 95
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
T0000_01
1 // T0000
2 %@MACRO
3 #100 := #1000; // Backup interpolation mode
4 #101 := #1004; // Backup absolute/increment command mode
5
6 G91 G00 X10.; // X axis moving in increment of 10.
7
8 M00; // Switch the screen to [Diag.] → [Display
Global] and [Display Coord.]
9 WAIT();
10 G#100; // Restore the interpolation mode
11 G#101; // Restore the absolute/increment command mode
12 M99;
M1601
1 // M1601
2 %@MACRO
3 #100 := #1000; // Backup interpolation mode
4 #101 := #1004; // Backup absolute/increment command mode
5
6 G91 G00 Y10.; // Y axis moving in increment of 10.
7
8 M00; // Switch the screen to [Diag.] → [Display
Global] and [Display Coord.]
9 WAIT();
10 G#100; // Restore the interpolation mode
11 G#101; // Restore the absolute/increment command mode
12 M99;
Appendix – 96
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
M1602
1 // M1602
2 %@MACRO
3 #100 := #1000; // Backup interpolation mode
4 #101 := #1004; // Backup absolute/increment command mode
5
6 G91 G00 Y10.; // Y axis moving in increment of 10.
7
8 M00; // Switch the screen to [Diag.] → [Display
Global] and [Display Coord.]
9 WAIT();
10 G#100; // Restore the interpolation mode
11 G#101; // Restore the absolute/increment command mode
12 M99;
T0000_02
1 // T0000
2 %@MACRO
3 #100 := #1000; // Backup interpolation mode
4 #101 := #1004; // Backup absolute/increment command mode
5
6 G91 G00 X10.; // X axis moving in increment of 10.
7
8 M00; // Switch the screen to [Diag.] → [Display
Global] and [Display Coord.]
9 WAIT();
10 G#100; // Restore the interpolation mode
11 G#101; // Restore the absolute/increment command mode
12 M99;
Appendix – 97
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
M1603
1 // M1603
2 %@MACRO
3 #100 := #1000; // Backup interpolation mode
4 #101 := #1004; // Backup absolute/increment command mode
5 #102 := #20; // Read data of #20, the line will occupy the T
argument
6
7 G91 G00 Y10.; // Y axis moving in increment of 10.
8
9 M00; // Switch the screen to [Diag.] → [Display
Global] and [Display Coord.]
10 WAIT();
11 G#100; // Restore the interpolation mode
12 G#101; // Restore the absolute/increment command mode
13 M99;
T0000_03
Main
1 // Main
2 G01 X0. Y0. Z0.;
3 G65 P1 X10. Y20. Z30.; // Execute O0001
4 M30;
Appendix – 98
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
O0001
1 // O0001
2 %@MACRO
3 #101 := #24;
4 #102 := #25;
5 #103 := #26;
6 M00;
7 WAIT();
8 M99;
Main
1 // Main
2 G01 X-5. Y-5. Z-5.;
3 G200 G66 P1 X10. Y20. Z30. ; // G200 in this line can't read X
argument
4 G200 X10.; // G200 in this line can read X
argument
5 // There are 2 lines of G01 movement
blocks in G200
6 // G66 P1 X10. Y20. Z30. is executed
every time G01 movement block is finished.
7 G67;
8 M30;
G0200_01
1 // G0200_01
2 %@MACRO
3 #100 := #1000; // Backup interpolation mode
4 #101 := #24; // Executing G200 for the first time, G200 can't
read X argument, so
5 G01 X#101; // this line is not executed.
6 G01 X0.;
7 M00;
8 WAIT();
9 G#100; // Restore the interpolation mode
10 M99;
Appendix – 99
机床产品/Machine Tool Products – OpenCNC_Macro Development Manual.
G0200_02
1 // G0200_02
2 %@MACRO
3 #100 := #1000; // Backup interpolation mode
4 #101 := #24; // Executing G200 for the second time, G200 is
able to read X argument, so
5 G01 X#101; // this line is executed
6 // This line is a movement block, after
finished, G66 P1 X10. Y20. Z30. is executed.
7 G01 X0.; // This line is a movement block, after
finished, G66 P1 X10. Y20. Z30. is executed.
8 M00;
9 WAIT();
10 G#100; // Restore the interpolation mode
11 M99;
O0001
1 // O0001
2 %@MACRO
3 #100 := #1000; // Backup interpolation mode
4 #101 := #24;
5 #102 := #25;
6 #103 := #26;
7 G91 G01 X#101 Y#102 Z#103;
8 M00;
9 WAIT();
10 G#100; // Restore the interpolation mode
11 M99;
Main
1 // Main
2 G01 X-5. Y-5. Z-5.;
3 G66.1 P1 X10. Y20. Z30. ;
4 G200 X10.; // G200 in this line can read the X
argument
5 // G66.1 P1 X10. Y20. Z30. is executed
every time the block in G200 is executed.
6 G67; // G66 P1 X10. Y20. Z30. is executed
after this block is executed
7 M30;
G0200
1 // G0200
2 %@MACRO
3 #100 := #1000; // Backup interpolation mode
4 #101 := #24; // Executing G200 for the second time, G200 is
able to read X argument
5 G01 X#101; // This line is executed
6 // G66 P1 X10. Y20. Z30. is executed after this
block is executed
7 G01 X0.; // G66 P1 X10. Y20. Z30. is executed after this
block is executed
8 M00; // G66 P1 X10. Y20. Z30. is executed after this
block is executed
9 WAIT(); // This line is not a block
10 G#100; // Restore the interpolation mode
11 // G66 P1 X10. Y20. Z30. is executed after this
block is executed
12 M99; // G66 P1 X10. Y20. Z30. is executed after this
block is executed
O0001
1 // O0001
2 %@MACRO
3 #100 := #1000; // Backup interpolation mode
4 #101 := #1004; // Backup absolute/increment command mode
5 #111 := #24;
6 #112 := #25;
7 #113 := #26;
8 G91 G01 X#111 Y#112 Z#113;
9 M00;
10 WAIT();
11 G#100; // Restore the interpolation mode
12 G#101; // Restore the absolute/increment command mode
13 M99;
Main
1 // Main
2 G01 X0. Y0. Z0.;
3 G65 P1 X10. Y20. Z30. G200; // Alarm COR-013 shows up owing to wrong
syntax in this line, because
4 // G65 and G200 are in the same line
5 // but G65 is not the last G code.
6 M30;
G0200
1 // G0200
2 %@MACRO
3 #101 := #24;
4 M00;
5 WAIT();
6 M99;
O0001
1 // O0001
2 %@MACRO
3 #101 := #24;
4 #102 := #25;
5 #103 := #26;
6 M00;
7 WAIT();
8 M99;
-> The customized HMI first outputs the the user-defined contents to an xml file, and save the xml file to
the GNCFILES file path of which is assigned by user (refer to Pr3219).
The syntax format is defined as below,:
<?xml version="1.0" encoding="UTF-16"?>
<CycleFile>
<Cycle Name="Cycle_HerdonProg"> ← The beginning of first data
<Field Name="Col_Y" Value="17.63"/>
<Field Name="Col_Z" Value="12.98"/>
<Field Name="Col_X" Value="0.00"/>
<Field Name="Col_A" Value="267.54"/>
</Cycle> ←The end of first data
<Cycle Name="Cycle_HerdonProg"> ←The beginning of second data
-> User have to write the configuration file of XML file by their own.
Configuration file( schema file ) defines the data to be read and the variable where data is put while
DBLOAD is used.
The syntax format is defined as below, and the configuration file should be saved in OCRes\\Common\
\Schema\\
If Dipole is enable, the schema file should be in the folder OCRes\\Common\\Schema\\ in controller.
<InputFormat>Variant</InputFormat>
<DefaultValue></DefaultValue>
</Field>
<Field>
<Name>Col_Z</Name>
<InputStorage>@1202</InputStorage> ←The variable Col_Z saves in
<InputFormat>Variant</InputFormat>
<DefaultValue></DefaultValue>
</Field>
<Field>
<Name>Col_A</Name>
<InputStorage>@1203</InputStorage> ←The variable Col_A saves in
<InputFormat>Variant</InputFormat>
<DefaultValue></DefaultValue>
</Field>
<Field>
<Name>Col_B</Name>
<InputStorage>@1204</InputStorage> ←The variable Col_B saves in
<InputFormat>Variant</InputFormat>
<DefaultValue></DefaultValue>
</Field>
<Field>
<Name>Col_C</Name>
<InputStorage>@1205</InputStorage> ←The variable Col_C saves in
<InputFormat>Variant</InputFormat>
<DefaultValue></DefaultValue>
</Field>
</Cycle>
</Schema>