Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What is a local variable and what is an integer variable?
What is a local variable and what is an integer variable?

Local variables and global variables in CNC macro programs: 1. Variables. Ordinary machining programs directly specify G codes and moving distances with numerical values; for example, GO1 and X100.0. When using a user macro program, the value can be specified directly or using a variable. When using variables, the variable value can be changed programmatically or using operations on the MDI panel. #1=#2+100G01 Variables are specified using the variable symbol (#) followed by the variable number. For example: #1 expression can be used to specify a variable number. In this case, the expression must be enclosed in parentheses. For example: #[#1+#2-12] Variable type Variables can be divided into four types according to the variable number. Variable number Variable type function #0 Empty variable This variable is always empty, and no value can be assigned to the variable. #1- #33 Local variables Local variables can only be used in macro programs to store data, for example, operation results. When the power is turned off, local variables are initialized to empty. When calling a macro program, independent variables assign values ??to local variables, #100-#199 #500-#999 Public *** variables have the same meaning in different macro programs. When the power is turned off, variables #100-#199 are initialized to empty. The data of variables #500-#999 is saved. It will not be lost even if the power is off. #1000 System variables System variables are used to read and write changes in various data during CNC operation, such as the current position of the tool and the compensation value. The range of variable values ????local variables and public variables can There is a value of 0 or a value in the following range: -1047 to -10-29 or -10-2 to -1047. If the calculation result exceeds the valid range, P/S alarm NO.111 is issued. The omission of the decimal point should be defined in the program When using variable values, the decimal point can be omitted. Example: When definition #1=123; the actual value of variable #1 is 123.000. A reference to a variable is to use the variable value in the program, specifying the address followed by the variable number. When specifying a variable with an expression, enclose the expression in parentheses. For example: G01X[#1+#2]F#3; The value of the referenced variable is automatically rounded according to the minimum setting unit of the address. For example: When G00X#/; is executed in units of 1/1000mm, CNC assigns 123456 to variable #1, and the actual command value is G00X12346. To change the sign of the value of the referenced variable, put the negative sign (-) in # Front. For example: G00X-#1 When an undefined variable is referenced, the variable and address are ignored. For example: when the value of variable #1 is 0 and the value of variable #2 is empty, the execution result of G00X#1 Y#2 is G00X0. Common variables of dual tracks (dual track control) For dual track control, the system provides separate macro variables for each track. However, according to the settings of parameters N0.6036 and 6037, some public variables Variables can be used in both trajectories. Undefined variable When a variable value is undefined, such a variable becomes an empty variable. Variable #0 is always an empty variable. It cannot be written, only read. References When referencing an undefined variable, the address itself is also ignored. When #1= When #1=0G90 When #1= When #1=0 #2=#1#2=#2=#1#2=0#2=#*5#2=0#2=#*5#2=0#2 =#1+#1#2=0#2=#1+#1#2=0 (c) Conditional expressions EQ and NE are different from 0. When #1= When #1=0 #1EQ#0 holds #1EQ#0 does not hold #1 NE #0 holds #1 NE #0 does not hold #1 GE #0 holds #1 GE #0 does not hold #1 GT #0 Not true #1 GT #0 Not true The restricted program number, sequence number and optional block jump number cannot use variables. Example: Variables cannot be used in the following situations: 0#1; /#2G00X100.0;N#3Y200.0;2 Arithmetic and logical operations The operations listed in the table below can be performed in variables. The expression on the right side of the operator can contain constants and variables or variables composed of functions or operators. Variables #j and #k in expressions can be assigned constant values. The variable on the left can also be assigned with an expression. Note: The angle unit of the angle unit functions SIN, COS, ASIN, ACOS, TAN and ATAN is degrees. For example, 90°30' is expressed as 90.5 degrees.

ARCSIN # i= ASIN[#j] (1) The value range is as follows: When the NAT bit of parameter (NO.6004#0) is set to 0, 270°~90° When the NAT bit of parameter (NO.6004#0) is set When it is 1, -90°~90° (2) When #j exceeds the range of -1 to 1, P/S alarm NO.111 is issued. (3) Constant replaceable variable #jARCCOS #i=ACOS[#j ] The value range is from 180° to 0°. When #j exceeds the range of -1 to 1, P/S alarm NO.111 is issued. The constant can replace the variable #j. Three program examples for milling ellipse: trajectory: ellipse program code is as follows: N10 G54 G90 G0 S1500 M03N12 #3*SIN[#1]N30 #10=#4*COS[45]-#5*SIN[45]N32 #11=#4*SIN[45]+#5*COS[45]N34 G1 X# 10 Y#11 N36 #1=#1+1N38 IF [#1 LT 370] GOTO26N40 G40 G1 X0 Y0 N42 G0 Z100N44 M30 Milling rectangular slot: The code for milling rectangular slot is as follows: #102=0.N3#100=0.# 101=0.#103=200.#104=400.G91G28Z0.G0G90G54X0.Y0.G43H1Z20.M3S2000.N4G0X#100Y#101G01Z#102F200.#102=#102-2.IF[#102EQ-50.]GOTO1GOTO2N 2N4X# 104F500.Y#103X#100Y#101#100=#1010.#101=#101+10.#103=#103-10.#104=#104-10.IF[#100EQ100.]GOTO3GOTO4N3N1M5M9G91G28Z0.G28Y0 .M30 milling surface inclined at 3 degrees: Track: The code for milling a surface inclined at 3 degrees is as follows: O0001#[#1+1*2]=1G65P9012L1A0B0.1C4I100J3K0M30 macro program O9012 code is as follows: G54 G90 G00 X[#3] Y0 Z100S500 M3G01 Z0 F300WHILE[#1LE10]DO1#7= #1/TAN[#5]+#3G1Z-#1 X#7#8=#6/2-ROUND[#6/2]IF[#8EQ0]GOTO10G1Y0 GOTO20N10 Y#4N20#1=#1+#2#6=#6+1END1G0 Z100 milling hemisphere: Trajectory: Milling hemisphere code is as follows: G90G0G54X-10.Y0M3S4500G43Z50.H1M8#1=0.5WHILE[#1LE50.]DO1#2 =50.-#1#3=SQRT[2500.-[#2*#2]]G1Z-#1F20X-#3F500G2I#3#1=#1+0.5END1G0Z50.M5M30 milling speaker: The milling speaker code is as follows: M03 S500M06 T01#1=0#2=0G0 Z15X150 Y0N11#2=30*SIN[#1]#3=330*[1-COS[#1]]G01 Z-#2 F40G41 X#3 D01G03 I- #3G40 G01 X150 Y0#1=#1+1IF [#1 LE 90] GOTO 11G0 Z30M30