This document is a user manual for the Macro of a CNC system, detailing various macro program instructions, including input and output commands, conditional and unconditional transfers, and cycle commands. It also covers local, global, and system variables used in the programming environment, along with their specific ranges and purposes. The manual is published by Shenzhen Guanhong Automation Co., Ltd and includes technical specifications for programming and operation of the CNC system.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
3 views
User+Manual+of+Macro(V1.0)
This document is a user manual for the Macro of a CNC system, detailing various macro program instructions, including input and output commands, conditional and unconditional transfers, and cycle commands. It also covers local, global, and system variables used in the programming environment, along with their specific ranges and purposes. The manual is published by Shenzhen Guanhong Automation Co., Ltd and includes technical specifications for programming and operation of the CNC system.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10
User Manual
Macro of CNC System
V1.0
Shenzhen Guanhong Automation CO.,LTD
Website: www.szghauto.com Add:Room 503 Anxin Building, No 536 Shenhui Road, Liuyue community, Henggang Street ,Longgang District, Shenzhen City,Guangdong Province, ChinaProvince, China Post code: 518115 Chapter 1 Macro Instruction
1.1 Macro program instruction
1.1.1 Input instruction: WAT Waiting for the input port X valid or invalid instruction Format: WAT+ (-) X Attention: "+" to means the input is effective; "-" means the input is invalid; "X" means the input port X00-X55; see the I/O diagnosis; 1.1.2 he output instruction: OUT Set the output port Y is valid or invalid instruction Format: OUT +(-)Y Attention: "+" means the output is effective; "-" means the output is invalid; "Y" means the output port Y00-Y31; see the I/O diagnosis; 1.1.3 Unconditional transfer: GOTO N Transfer to the program line with sequence number appears error when specifying beyond the 1-99999, could use expression to specify the sequence number. For example: GOTO 5, GOTO#100 1.1.4 Conditional transfer 1) IF (Conditional expression) GOTO 2) IF (Conditional expression) THEN If the conditional expression specified met, execute this segment; if the conditional expression specified does not meet, execute the next segment. For example: IF (#100 EQ 2) THEN #100=5 IF (#101 GT 2) GOTO 6 IF (#101 GT 2) GOTO 6 Operation meaning: EQ equal NE not equal GT greater than > GE greater than or equal LT less than < LE less than or equal 1.1.5 Cycle: WHILE (conditional expression) DO 1, 2, 3 Specifies a conditional expression in front of WHILE. When the specified conditions are met, execute the program between DO and END. Otherwise, turn to the program line after END. Cycle of the embed is 3 at the most. For example:WHILE (#100 LT 3)DO 1 …… WHILE (#103 EQ 5)DO 2 …… WHILE (#200 GE 20)DO 3 …… END 3 …… END 2 …… END 1 1.1.6 Non-mode to call macro program:G65 Format: G65 P- L- <A-B-C-...... Argument passing data > P is the name of macro program, L is the calling times,A B C are argument, the name of argument as follows: #0->A、#1->B、#2->C、#3->D、#4->E、#5->F、#6->H、#7->I、#8->J、#9->K、 #10->M、#11->Q、#12->R、#13->S、#14->T、#15->U、#16->V、#17->W、#18->X、 #19->Y、#20->Z. Special attention: The address G、L、N、Q、P can’t be used in argument. For example: Main program:9000 G00 X0 Z0 G65 P8000 L1 A5 B6 G0 X0 Z0 M30 Macro program:8000 N1 #2=#0+#1 N2 IF (#2 EQ 10)GOTO 4 N3 GOO X#2 N4 G00 Z#1 N5 M99 ;Return 1.1.7 Mode to call macro program:G66 G67 G67 instruction is to cancel G66 instruction.The format is the same as G65. For example: Main program:9000 G00 X0 Z0 G66 P8000 L2 A5 B6 A8 B1 A9 B10 G67 M30 Macro program:8000 N1 #2=#0+#1 N2 IF (#2 EQ 10)GOTO 4 N3 GOO X#2 N4 G00 Z#1 N5 M99 ;Return Chapter 2 Variable
2.1 Local Variable
#0--#20 : local variables only can be used to store data in macro program, such as a result of operation, when power is off, the local variables are initialized to the empty. The argument assignment to the local variable when calling the macro program.
2.2 Global Variable
#21--#600 : Their meanings are the same in different macro program. When power is off, the variable #21--#100 is initialized to zero, the variable #101--#600 data is saved not to loss even if the power is off.
2.3 System Variable
#1000-- : the system variables are used to change various data when reading the running CNC. For example, the current position and the compensation of tool. Special Attention: macro variables #100--#155 and #190--#202 have been used by the system, users can not use. 2.3.1 System Parameter Variable #1001--#1099 : Value of X-axis length compensation for T1--T99(Unit: um) #1101--#1199 : Value of D1 radius compensation for T1--T99(Unit: um) #1201--#1299 : Value of Y(C)-axis length compensation for T1--T99(Unit: um) #1301--#1399 : Value of D2 radius compensation for T1--T99(Unit: um) #1401--#1499 : Value of Z-axis length compensation for T1--T99(Unit: um) #1501--#1599 : Value of D3 radius compensation for T1--T99(Unit: um) #1601--#1699 : Value of A-axis length compensation for T1--T99(Unit: um) #1701--#1799 : Value of D4 radius compensation for T1--T99(Unit: um) 2.3.2 I/O variables #1800: X00-X07 (D0-D7) ; input resistor #1801: X08-X15 (D0-D7) ; input resistor #1802: X16-X23 (D0-D7) ; input resistor #1802: X16-X23 (D0-D7) ; input resistor #1803: X24-X31 (D0-D70 ; input resistor #1804: X32-X39 (D0-D7) ; input resistor #1805: X40-X47 (D0-D7) ; input resistor #1806: X60-X67 (D0-D7) ; input resistor #1807: X74-X81 (D0-D7) ; Alarm of driver/Spindle #1808: Y00-Y15 (D0-D15) ; output resistor #1809: Y16-Y31 (D0-D15) ; output resistor #1810: Y32-Y47 (D0-D15) ; output resistor #1811: M00-M15(D0-D15) ; auxiliary relay #1812: X101-X112(D0-D11) ; input of operational panel #1813: Y50-Y57(D0-D7) ; servo enable #1814: M16-M31(D0-D15) ; auxiliary relay #1815: M32-M47(D0-D15) ; auxiliary relay #1816: M48-M63(D0-D15) ; auxiliary relay #1817: M64-M79(D0-D15) ; auxiliary relay #1818: M100-M115(D0-D15) ; auxiliary relay #1819: M80-M95(D0-D15) ; auxiliary relay #1820: M120-M135(D0-D15) ; auxiliary relay #1850: X-axis Offset value of G54 workpeice coordinate system(unit:mm) #1851: X-axis Offset value of G55 workpeice coordinate system(unit:mm) #1852: X-axis Offset value of G56 workpeice coordinate system(unit:mm) #1853: X-axis Offset value of G57 workpeice coordinate system(unit:mm) #1854: X-axis Offset value of G58 workpeice coordinate system(unit:mm) #1855: X-axis Offset value of G59 workpeice coordinate system(unit:mm) #1856: Y-axis Offset value of G54 workpeice coordinate system(unit:mm) #1857: Y-axis Offset value of G55 workpeice coordinate system(unit:mm) #1858: Y-axis Offset value of G56 workpeice coordinate system(unit:mm) #1859: Y-axis Offset value of G57 workpeice coordinate system(unit:mm) #1860: Y-axis Offset value of G58 workpeice coordinate system(unit:mm) #1861: Y-axis Offset value of G59 workpeice coordinate system(unit:mm) #1862: Z-axis Offset value of G54 workpeice coordinate system(unit:mm) #1863: Z-axis Offset value of G55 workpeice coordinate system(unit:mm) #1864: Z-axis Offset value of G56 workpeice coordinate system(unit:mm) #1865: Z-axis Offset value of G57 workpeice coordinate system(unit:mm) #1866: Z-axis Offset value of G58 workpeice coordinate system(unit:mm) #1867: Z-axis Offset value of G59 workpeice coordinate system(unit:mm) #1868: A-axis Offset value of G54 workpeice coordinate system(unit:mm) #1869: A-axis Offset value of G55 workpeice coordinate system(unit:mm) #1870: A-axis Offset value of G56 workpeice coordinate system(unit:mm) #1871: A-axis Offset value of G57 workpeice coordinate system(unit:mm) #1872: A-axis Offset value of G58 workpeice coordinate system(unit:mm) #1873: A-axis Offset value of G59 workpeice coordinate system(unit:mm) #1874: X-axis Coordinate Value of 1st refenerce point (unit:mm) #1875: X-axis Coordinate Value of 2nd refenerce point (unit:mm) #1876: X-axis Coordinate Value of 3rd refenerce point (unit:mm) #1877: X-axis Coordinate Value of 4th refenerce point (unit:mm) #1878: Y-axis Coordinate Value of 1st refenerce point (unit:mm) #1879: Y-axis Coordinate Value of 2nd refenerce point (unit:mm) #1880: Y-axis Coordinate Value of 3rd refenerce point (unit:mm) #1881: Y-axis Coordinate Value of 4th refenerce point (unit:mm) #1882: Z-axis Coordinate Value of 1st refenerce point (unit:mm) #1883: Z-axis Coordinate Value of 2nd refenerce point (unit:mm) #1884: Z-axis Coordinate Value of 3rd refenerce point (unit:mm) #1885: Z-axis Coordinate Value of 4th refenerce point (unit:mm) #1886: A-axis Coordinate Value of 1st refenerce point (unit:mm) #1887: A-axis Coordinate Value of 2nd refenerce point (unit:mm) #1888: A-axis Coordinate Value of 3rd refenerce point (unit:mm) #1889: A-axis Coordinate Value of 4th refenerce point (unit:mm) #1890: Set of Metric/Inch in system #1891: Name of 4th axis #1892: Function Set of 4th axis #1893: Rotary mode when 4th axis is as rotary axis #1894: Display of relative coordinate when 4th axis is as rotary axis #1895: Display of workpiece coordinate when 4th axis is as rotary axis #1896: Reverse Backlash Compensatoin of X-axis (unit: um) #1897: Reverse Backlash Compensatoin of Y-axis (unit: um) #1898: Reverse Backlash Compensatoin of Z-axis (unit: um) #1899: Reverse Backlash Compensatoin of A(4th)-axis (unit: um) #1900: Feeding axis use electric gear(0: use , non-0: no) #1901: Numerator of X-axis’s electron gear (1—999999999) #1902: Denominator of X-axis’s electron gear (1—999999999) #1903: Numerator of Y-axis’s electron gear (1—999999999) #1904: Denominator of Y-axis’s electron gear (1—999999999) #1905: Numerator of Z-axis’s electron gear (1—999999999) #1906: Denominator of Z-axis’s electron gear (1—999999999) #1907: Numerator of A-axis’s electron gear (1—999999999) #1908: Denominator of A-axis’s electron gear (1—999999999) #1909: Spindle use electric gear (0: use , non-0: no) #1910: Numerator of electron gear ratio of spindle in Low grade (1—999999999) #1911: Denominator of electron gear ratio of spindle in Low grade (1—999999999) #1912: Numerator of electron gear ratio of spindle in Low grade (1—999999999) #1913: Denominator of electron gear ratio of spindle in High grade (1—999999999) #1914: Direction signal of X-axis(0: reverse , non-0: normal) #1915: Direction signal of Y-axis(0: reverse , non-0: normal) #1916: Direction signal of Z-axis(0: reverse , non-0: normal) #1917: Direction signal of A-axis(0: reverse , non-0: normal) #1918: Direction signal of Spindle servo(0: reverse , non-0: normal) #1923: Max scope of X-axis in negative direction (mm / inch) #1924: Max scope of Y-axis in negative direction (mm / inch) #1925: Max scope of Z-axis in negative direction (mm / inch) #1926: Max scope of A-axis in negative direction (mm / inch) #1927: Max scope of X-axis in positive direction (mm / inch) #1928: Max scope of Y-axis in positive direction (mm / inch) #1929: Max scope of Z-axis in positive direction (mm / inch) #1930: Max scope of A-axis in positive direction (mm / inch) #1950: G00 Speed of X-axis (mm/min) #1951: G00 Speed of Y-axis (mm/min) #1952: G00 Speed of Z-axis (mm/min) #1953: G00 Speed of A-axis (mm/min or degree/min) #1954: Default speed of G01(mm/min) #195: Simulate Speed(mm/min) #1956: Max feeding speed(mm/min) #1957: Acceleration of X-axis ((mm/min)/s) #1958: Acceleration of Y-axis ((mm/min)/s) #1959: Acceleration of Z-axis ((mm/min)/s) #1960: Acceleration of A-axis((mm/min)/s) #1961: Manual Speed of Spindle (rpm) #1962: Manual Speed of Feedinga axis (mm/min) #1963: Speed of X-axis return to reference point in positive direction (mm/min) #1964 : Speed of Y-axis return to reference point in positive direction (mm/min) #1965: Speed of Z-axis return to reference point in positive direction (mm/min) #1966: Speed of A-axis return to reference point in positive direction (mm/min) #1967: Speed of X-axis return to reference point in negative direction (mm/min) #1968: Speed of Y-axis return to reference point in negative direction (mm/min) #1969: Speed of Z-axis return to reference point in negative direction (mm/min) #1970: Speed of A-axis return to reference point in negative direction (mm/min) #1971: Max speed of spindle (rpm) #1972: Transmission Ratio of spindle in low grade(Motor_Speed/SP_Speed) #1973: Transmission Ratio of spindle in high grade(Motor_Speed/SP_Speed) #1974: Starting running speed in manual (mm/min) #1975: Allow jump speed when continuous track interpolation(mm/min) #1990: Number of processing workpieces #1991: Times of cycle auto when using M20 code #1992: Delay time when loose/tighten tool (s) #1993: Tight tool auto after loose tool(0: no , non-0: yes) #1994: Selection of Lanuage #1995: Direction of Q offset of G76 canned cycle #1996: Direction of Q offset of G87 canned cycle #1997: Width of track line in Diagram simulation (unit:pixel) #1998: Mode of length compensation of tool #1999: Type of spindle(0: servo spindle , Non-0: analog spindle) #2000: Spindle is with Low/high grade (0: no , Non-0: yes) #2001: Acceleration of spindle running normally #2002: Turn on spindle when spindle change gear (0: no , Non-0: yes) #2003: Time from stop to swing when spindle change gear (0.01s) #2004: Time from swing to change gear when spindle change gear (0.01s) #2005: Swing speed when spindle change gear (0.01 rpm) #2006: Direction of starting swing when spindle change gear (0: CW, Non-0: CCW) #2007: Time of swing CW when spindle change gear (0.01s) #2008: Time of swing CCW when spindle change gear (0.01s) #2009: Holding output singal that spindle change gear (0: no , Non-0: yes) #2010: Hint user-defined alarm (0: no , Non-0: yes) #2011: Hint alarm of feeding axis & spindle (0: no , Non-0: yes) #2012: Hint alarm of coolant overload (0: no , Non-0: yes) #2013: Hint alarm of coolant under-water (0: no , Non-0: yes) #2014: Hint alarm of lubricate overload (0: no , Non-0: yes) #2015: Hint alarm of lubricate under-oil (0: no , Non-0: yes) #2016: Close function of 5 axis linkage interpolation (0: no , Non-0: yes) #2017: Detect position feedback of spindle (0: no , Non-0: yes) #2018: Use electric gear of spindle position feedback (0: no , Non-0: yes) #2019: Control mode of spindle (G74/G84/G33 thread & spindle orientation) #2020: Managment way of tool(0: use M06, Non-0: use T code directly) #2021: Way of selecting tool(0: single direction, Non-0: both direction random) #2022: Way of feeding axes return to reference point #2023: Max length of detecting zero position when homing #2024: Max no. of tool case in fixed tool area #2025: Reference point of Z-axis return when changing tool #2026: Stoping degreen when spindle orientation during tool change #2027: Control mode when spindle homing #2028: Power condition of each axis when booting #2029: Max speed when Z-axis using handwheel (mm/min) #2030: Max speed when X/Y/A-axis using handwheel (mm/min) #2031: Detect SP_orientation & Point of changing point before change tool(Non-0: yes , 0: No) #2046: stoping degree of spindle orientation when boring canned cycle #2047: Homing Speed of spindle #2048: Speed of spindle orientation #2049: Allow Error Range of spindle orientation #2050: Way of tool radius C compensation set up #2051: Way of tool radius C compensation cancel #2052: Position direction when SP-orientation adopt pulse interpolation control way #2053: Delay time when spindle change direction suddenly (unit: 0.1s) #2054: Acceleration of spindle servo ((mm/min)/s) #2055: Active function of tool change #2056: Transmission bits when communicate with RS232 serial port #2057: Delay time between driver off of power & reboot (unit: 0.1s) #2058: Interlock between motion of Z-axis and spindle take tool(0: No , Non-0:Yes) #2059: Shifting distance after X-axis homing (unit:0.1mm) #2060: Shifting distance after Y-axis homing (unit:0.1mm) #2061: Shifting distance after Z-axis homing (unit:0.1mm) #2062: Shifting distance after A-axis homing (unit:0.1mm) #2070: Value of d quit tool in canned cycle G73 (mm) #2071: Value of d quit tool in canned cycle G83 (mm) #2100——#2199: Tool number of 0-99 tool case #2032~#2045: Spare #2063~#2069: Spare Format:#i=Expression Could read the value, for example: #200=#1003; To read the X axis offset value of the third tool into macro variables #200. Could modify the value, for example: #1003=23000; To modify the X axis offset value of the third tool to 23000 micron. #1003=#1003+50; To increase the X axis offset value of the third tool 50 micron.
4.The arithmetic and logic operation
Table: Function Format Attention Definition #i = #j Addition #i = #j + #k ; Subtraction #i = #j - #k ; Multiplication #i = #j * #k ; Division #i = #j / #k ; Sin #i = SIN(#j) ; Asin #i = ASIN(#j); Cos #i = COS(#j) ; 90.5 degrees mean 90 Acos #i = ACOS(#j); degrees 30 minutes Tan #i = TAN(#j); Atan #i = ATAN(#j); Square root #i = SQRT(#j); Absolute value #i = ABS(#j) ; Rounding off #i= ROUND(#j); Round down #i = FIX(#j); Round up #i = FUP(#j); Natural logarithm #i = LN(#j); Exponential function #i = EXP(#j); Or #i = #j OR #k ; Executing with binary Exclusive or #i = #j XOR #k ; system And #i = #j AND #k ;
Every user-defined G code is corresponding to a macro program ProgramGxxx, the M code is corresponding to a macro program of ProgramUser0 --ProgramUser9, the user cannot programme the macro program in NC system, must edit the macro code in the computer, and then copy into the system. For example, defines the G152 function: the arc model porous drilling cycle. (must copy the macro program ProgramG152 into system). Format:G152 Xx Yy Zz Rr Ii Aa Bb Hh Ff; X: The X coordinate with absolute value or incremental value of center to specify. Y: The Y coordinate with absolute value or incremental value of center to specify. Z: Hole depth R: Approaching fast to the point coordinate F: Cutting feed speed I: Radius A: The angle of the first hole B: Incremental angle specify(CW when negative) Macro program ProgramG152 as follows: #80=#0 #81=#1 #82=#2 #83=#3 #84=#4 #85=#5 #86=#6 #87=#7 #88=#8 #89=#9 #90=#10 #91=#11 #92=#12 #93=#13 #94=#14 #95=#15 #96=#16 #97=#17 #98=#18 #99=#19 #100=#20 #30=#4003 #31=#4014 G90 IF[#30 EQ 90] GOTO 1 G53 #98=#5001+#98 #99=#5002+#99 N1 WHILE[#86 GT 0] DO 1 #35=#98+#87*COS[#80] #36=#99+#87*SIN[#80] G81X#35Y#36Z#100R#92F#85 #80=#80+#81 #86=#86-1 END 1 G#30 G#31 G80 M99