Basic Principle
In numerical control (NC) machining, once the program begins executing, the tool specified in the code is typically called first. After that, the machining block is carried out based on the currently valid tool radius parameter. To ensure proper tool compensation and prevent errors, a judgment module should be inserted between the two program statements prior to executing the machining block. This module evaluates whether the currently valid tool radius falls within the appropriate range. If the condition is met, the program proceeds to the next steps; otherwise, it jumps to the alarm block and halts execution (as shown in Figure 1).
2. Main Programming Instructions and System Parameters
To implement the tool offset error prevention feature outlined in the error prevention principle, the execution program needs to incorporate three key elements: retrieving the currently valid tool radius value, performing logical operations and conditional judgments, and implementing program jumps with alarm notifications. Below is a detailed explanation of the programming commands and system parameters required for programming in the Siemens SINUMERIK system.
(1) Retrieving the Currently Valid Tool Radius Value: The current valid tool radius value is accessed through a system variable. In the SINUMERIK system, "$TC_DP6[t,d]" represents the geometry radius value of a given tool, where 't' is the tool number and 'd' is the tool offset address number. A commonly used readable call format is "$TC_DP6[$P_TOOLNO, $P_TOOL]", where "$P_TOOLNO" represents the system variable for the currently active tool number, and "$P_TOOL" is the currently valid tool offset address. Thus, "$TC_DP6[$P_TOOLNO, $P_TOOL]" denotes the tool geometry radius value of the currently valid tool number.
Another system variable, "$P_TOOLP", exists for the tool number, representing the programmable tool number, which corresponds to the 'T' command in the NC program. For instance, if 'T21' is specified during programming, the system assigns 21 to "$P_TOOLP". While the tool management function in the SINUMERIK system maps the 'T' command number to the corresponding tool management list number, this might not always align with the actual tool position number. Using "$P_TOOLP" as the calling variable could lead to assignment errors, so it is advisable to avoid it.
(2) Conditional Judgment: The SINUMERIK system uses the "IF" instruction for conditional judgment, with the complete syntax being IF-ELSE-ENDIF. The standard programming syntax is:
IF
Block 1
ELSE
Block 2
ENDIF
If the logical return value of the expression is true, meaning the qualification condition is met, the program executes the subsequent program segment 1; if false, it executes the ELSE-directed program segment 2. In practice, auxiliary commands like ELSE and ENDIF can sometimes be omitted.
(3) Logical Operations: Logical operations (or Boolean operations) can be applied in conditional judgment expressions as needed. The primary logical operators include AND, OR, NOT, and XOR. Often, there are multiple conditions for the tool compensation value. To ensure stricter and safer limits, both the maximum and minimum values are typically set. Therefore, the OR operator is commonly used to connect the truth expressions of the conditional judgment.
(4) Program Line Jumps: In the SINUMERIK system, program line jump instructions that alter the program flow include GOTO, GOTOB, and GOTOF. GOTO searches forward according to the given target and then backward if not found; GOTOB targets backward jumps; GOTOF targets forward jumps. For machining programs, the forward direction is toward the end of the program, while the reverse is toward the beginning. Based on the preset program structure, the jump target is in the forward position, making the GOTOB command unavailable. Instead, GOTO or GOTOF commands can be used.
The standard programming syntax is:
GOTO
GOTOF
Jump targets can be labels, program line numbers, strings, etc., but they must consist of at least two letters or numbers, with the first two symbols being letters or underscores.
There must be a colon after the jump target block marker; otherwise, it won't be found. For example, "LAB LE:" indicates that when GOTO LAB is executed, the program will search for and jump to the block marked with "LAB:".
(5) Displaying Alarm Information: In the SINUMERIK system, the command to display programmable information on the machine operation monitor is "MSG()". The programming syntax is:
MSG("Content") is generally used in conjunction with the G4 F... command when using the "MSG()" instruction. Here, F specifies the duration of the pause in seconds.
This instruction's main purpose is to pause the program for the corresponding time, allowing the content displayed by "MSG()" to remain on the monitor long enough for the operator to read it.
3. Programming Examples and Instructions
(1) Machining Content: A blind hole with a diameter of 25 mm is machined on the end face of a rectangular prism. The position dimensions are shown in Figure 2.
Machining Equipment: Horizontal machining center; CNC System: SINUMERIK 840D; Cutting Tool: φ10mm solid carbide end mill; Programming Method: Contour programming.
(2) Programming and Analysis:
N010 T21 M6 D1 (Tool change)
N020 G54 (Establishing the workpiece coordinate system)
N030 G0 G90 G40 X0 Y0 Z100 (Program origin)
N040 S900 M3 (Spindle forward rotation)
N050 IF $TC_DP6[$P_TOOLNO, $P_TOOLND] < 5 OR $TC_DP6[$P_TOOLNO, $P_TOOLND] > 9 GOTO LABLE (Conditional judgment: If the tool radius value is less than 5mm or greater than 9mm, the program jumps to the LABLE line)
N060 ELSE (If the tool radius value is between 5 to 9mm, the downstream program is executed)
N070 TRANS X100 Y50 (Coordinate system zero offset)
N080 Z47 (Safe distance)
N090 G1 Z35 F100 M8 (Feed to the bottom of the hole, coolant on)
N100 G41 Y12.5 (Feed to the upper wall of the blind hole)
N110 G3 Y12.5 CR=12.5 (Milling circumference)
N120 G1 G40 Y0 (Retract to hole center)
N130 G0 Z100 M9 (Retract, coolant off)
N140 ENDIF (End judgment)
N150 M5 (Spindle stop)
N160 M30 (Program stop)
N170 LABLE: MSG("WARNING: THE TOOL RADIUS IS INCORRECT! PLEASE CHECK IT!") (Display alarm information)
N180 G4 F5 (Pause for 5 seconds)
N190 M5 (Spindle stop)
N200 M30 (Program stop)
When the program starts running and reaches line N050, it judges whether the currently valid tool radius value meets the criteria: if it’s between 5~9mm, the program continues executing the next lines until the N140 line; if it’s less than 5mm or greater than 9mm, the program jumps to line N150 to prompt an error message, pausing for 5 seconds before stopping.
4. Conclusion
In this article, we have achieved the basic form of NC program tool compensation and error prevention using relevant instructions from the SINUMERIK system. This approach is simple and universal, effectively controlling the accuracy of manual tool compensation settings.
Sliding Bar Set,Wall Mounted Sliding Bar Set,Sliding Bar With Shower Bracket,Adjustable Sliding Rail Set,shower rod set
Kaiping Rainparty Sanitary Ware Technology Co.,Ltd. , https://www.rpshower.com