Products Catalogue Home     |     About Us    |     Retrofit     |     Download     |     News     |     Tech Support     |     Contact Us     |     
ppr fittings-NF-4011-Newsun Industry Co., Ltd
Home > Tech Support >

Variables for macro programming of Fanuc CNC

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 with a variable. When using variables, the variable value can be changed by the program or by the operation on the MDI panel
 
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 with a variable. When using variables, the variable value can be changed by the program or by the operation on the MDI panel.
  #1=#2+100
  G01 X#1 F300
  Description:
   Variable representation
   The computer allows the use of variable names, but not user macro programs. Variables are designated by the variable symbol (#) and the following variable number.
   Example: #1
   expression can be used to specify the variable number. At this time, the expression must be enclosed in parentheses.
   For example: #[#1+#2-12]
   Type of variable
   Variables can be divided into four types according to the variable number
  1. Variable number: #0
   Variable type: empty variable
   Function: The variable is always empty, and no value can be assigned to the variable.
  2. Variable number: #1-#33
   Variable type: local variable
   Function: Local variables can only be used to store data in macro programs, for example, calculation results. When power is off, local variables are initialized to empty. When macro programs are called, independent variables are assigned to local variables.
  3. Variable number: #100-#199, #500-#999
   Variable type: public variable
   Function: Common variables have the same meaning in different macro programs. When the power is off, the variables #100-#199 are initialized to be empty. The data of variables #500-#999 are saved, even if the power is off.
4. Variable number: #1000 Variable type: System variable Function: System variable is used to read and write various data changes during CNC operation, for example, the current position and compensation value of the tool. Variable value range Local variables and public variables can have a value of 0 or a value in the following range: -1047 to -10-29 or -10-2 to -1047
 
  4. Variable number: #1000
   Variable type: system variable
   Function: System variables are used to read and write various data changes during CNC operation, for example, the current position and compensation value of the tool.
   Variable value range
   Local variables and public variables can have a value of 0 or values ​​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 will be issued.
   omission of decimal point
   When the variable value is defined in the program, the decimal point can be omitted.
   Example: When definition #1=123; the actual value of variable #1 is 123.000.
   variable reference
   is to use the variable value in the program, and specify the address followed by the variable number. When using an expression to specify a variable, put 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.
  E.g:
   When G00X#/; is executed in the unit 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 minus sign (-) in front of #.
   For example: G00X-#1
   When referring to undefined variables, the variables and addresses 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 double track (dual track control)
   For dual-track control, the system provides a separate macro variable for each track. However, according to the settings of parameters No. 6036 and 6037, some common variables can be used for two tracks at the same time.
Undefined variables When the value of a variable is undefined, such a variable becomes an empty variable. Variable #0 is always an empty variable. It cannot write, only read. (a) Quoting When quoting an undefined variable, the address itself is also ignored. When #1=empty G90 X100 Y#1 G90 X100 When #1=0 G90 X100 Y#1 G90
 
   undefined variable
   When the variable value is not defined, such a variable becomes an empty variable. Variable #0 is always an empty variable. It cannot write, only read.
  (A) quote
   When referencing an undefined variable, the address itself is also ignored.
  当#1=<empty>
  G90 X100 Y#1
  G90 X100
  当#1=0
  G90 X100 Y#1
  G90 X100 Y0
  (B) calculation
   Except for assignment with <empty>, <empty> is the same as 0 in other cases.
   When #1=<empty>
  #2=#1
  #2=<empty>
  #2=#*5
  #2=0
  #2=#1+#1
  #2=0
   When #1=0
  #2=#1
  #2=0
  #2=#*5
  #2=0
  #2=#1+#1
  #2=0
  (C) Conditional expression
   The <empty> in EQ and NE is different from 0.
   When #1=<empty>
  #1EQ#0 established
  #1 NE #0 established
  #1 GE #0 established
  #1 GT #0 does not hold
   When #1=0
  #1EQ#0 does not hold
  #1 NE #0 does not hold
  #1 GE #0 does not hold
  #1 GT #0 does not hold
   limit
   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;

—[Close]— —[ Back]— —[ Print]—