Post Builder Sim15 - Millturn - 9ax - Fanuc - MM
Post Builder Sim15 - Millturn - 9ax - Fanuc - MM
1. Facing
O0001
%
G40 G90 G49 G21
(FACING)
M09
G10.9 X1
(Tool Change)
G18 G54
T11
M303
S3000 M04
G94 G90 G00 G43 X-39.317 Z.9 H00
G95 G01 X-36.917 F.5 M08
X2.4
X4.8
G94 G00 Z-2.34
X-39.393
Z1.8
G95 G01 X-36.993
X2.4
X4.8
G94 G00 Z-1.44
X-39.393
Z2.7
G95 G01 X-36.993
X2.4
X4.8
G94 G00 Z-.54
X-39.393
Z3.6
G95 G01 X-36.993
X2.4
X4.8
G94 G00 Z.36
X-39.393
Z4.5
G95 G01 X-36.993
X2.4
X4.8
G10.9 X0
M10
M68
M30
%
Post builder
1. Start of program
PB_CMD_uplevel_MOM_generic cycle
# This command is used to handle G70/G71/G72 with generic cycle enhancement.
#
# <lili 2013-06-27> Initial version
# <shuai 2015-10-25> Modify for fanuc G70/G71/G72.
# <shuai 2015-12-25> Modify the code structure so as to make logical more clear.
uplevel #0 {
#=============================================================
proc MOM_generic_cycle { } {
#=============================================================
global mom_generic_cycle_status
global mom_sys_output_contour_motion
global mom_from_status
global mom_start_status
global mom_motion_type
global mom_operation_name
global dpp_return_motion_list
global dpp_return_motion_start
global dpp_first_buffer_for_return_motion
global mom_post_oper_path
##++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++
# When posting both rough and finish turning cycle operation (Scenario 2), contour
data of finish operation will be used for rough.
# So NX will use extended command MOM_post_oper_path to post the finish
operation in the rough operation to get contour data
# and mom_post_oper_path is set to 1 in subpost run by MOM_post_oper_path.
#
# Then NX will use NC codes between events MOM_generic_cycle as contour data.
# Because MOM_contour_start and MOM_contour_end don't output in
MOM_post_oper_path.
#
# In other scenarios, skip the events between MOM_generic_cycle
# and use NC codes between events MOM_contour_start and MOM_contour_end
as contour data.
##++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++
} else {
} else {
} ; #MOM_generic_cycle
} ; #uplevel 0
2. MOM_set_seq_off
3. PMB_CMD_program_header
#
# Program Header with Tape Number
#
# This procedure will output a program header with the following format:
#
# Attribute assigned to program (Name of program group)
# O0001 (NC_PROGRAM)
#
# Place this custom command in the start of program event marker. This
# custom command must be placed after any intial codes (such as #). The
# custom comand MOM_set_seq_off must precede this custom command to
# prevent sequence numbers from being output with the program number.
#
# If you are adding this custom command to a linked post, this custom
# command must be added to the main post only. It will not be output by
# any subordinate posts.
#
# If there is no attribute assigned to the program group, the string O0001
# will be used. In any case the name of the program in Program View will
# be output as a comment.
#
# To assign an attribute to the program, right click on the program. Under
# properties, select attribute. Use the string "program_number" as the
# title of the attribute. Enter the string you need for the program
# name, O0010 for example, as the value of the attribute. Use type string for the
# the attribute. Each program group can have a unique program number.
#
global mom_attr_PROGRAMVIEW_PROGRAM_NUMBER
global program_header_output
global debug
set debug 0
if [info exists program_header_output] { return }
set program_header_output 1
MOM_set_seq_off
MOM_output_literal "$mom_attr_PROGRAMVIEW_PROGRAM_NUMBER"
4. PB_CMD_fix_RAPID_SET
# This command is provided to overwrite the system RAPID_SET
# in order to correct the problem with workplane change that
# doesn't account for +/- directions along X or Y principal axes.
# It also fixes the problem that the First Move was never
# identified to force the output of the 1st point.
#
# The original command has been renamed as ugpost_RAPID_SET.
#
# - This command may be attached to the "Start of Program" event marker.
#
#
# Revisions:
#-----------
# 02-18-08 gsl - Initial version
# 02-26-09 gsl - Used mom_kin_machine_type to derive machine mode when it's
UNDEFINED.
#
#***********
uplevel #0 {
#====================
proc RAPID_SET { } {
#====================
set is_first_move 0
if { [string match "MOM_first_move" [MOM_ask_event_type]] } {
set is_first_move 1
}
WORKPLANE_SET
if { [EQ_is_lt $mom_pos($mom_cycle_spindle_axis)
$mom_last_pos($mom_cycle_spindle_axis)] } {
set going_lower 1
} else {
set going_lower 0
}
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++
# User can temporarily disable the work plane change for rapid moves along non-
principal
# spindle axis even when work plane change has been set in the Rapid Move event.
#
# Work plane change, if set, will still be in effect for moves along principal axes.
#
# - This flag has no effect if the work plane change is not set.
#
set disable_non_principal_spindle 0
switch $mom_cycle_spindle_axis {
0{
if [EQ_is_lt $mom_spindle_axis(0) 0.0] {
set going_lower [expr abs($going_lower - 1)]
}
}
1{
if [EQ_is_lt $mom_spindle_axis(1) 0.0] {
set going_lower [expr abs($going_lower - 1)]
}
}
2 { ;# Multi-spindle machine
if [EQ_is_lt $mom_spindle_axis(2) 0.0] {
set going_lower [expr abs($going_lower - 1)]
}
}
}
# Per user's choice above, disable work plane change for non-principal spindle axis
#
if { $disable_non_principal_spindle } {
global mom_user_work_plane_change
global mom_user_spindle_first
if { $mom_sys_work_plane_change } {
if { $going_lower } {
set spindle_first FALSE
} else {
set spindle_first TRUE
}
if { [EQ_is_equal $mom_pos($mom_cycle_spindle_axis)
$mom_last_pos($mom_cycle_spindle_axis)] } {
set rapid_spindle_inhibit TRUE
} else {
set rapid_spindle_inhibit FALSE
}
if { [EQ_is_equal $mom_pos($traverse_axis1) $mom_prev_pos($traverse_axis1)]
&& [EQ_is_equal $mom_pos($traverse_axis2) $mom_prev_pos($traverse_axis2)] &&
[EQ_is_equal $mom_pos(3) $mom_prev_pos(3)] && [EQ_is_equal $mom_pos(4)
$mom_prev_pos(4)] } {
} else {
set spindle_first NONE
}
} ;# RAPID_SET
} ;# uplevel
#***********
7. PB_CMD_uplevel_lock_axis
uplevel #0 {
#=============================================================
proc LOCK_AXIS_MOTION { } {
#=============================================================
# called by PB_CMD_kin_before_motion
#
# The UDE lock_axis must be specified in the tool path
# for the post to lock the requested axis. The UDE lock_axis may only
# be used for four and five axis machine tools. A four axis post may
# only lock an axis in the plane of the fourth axis. For five axis
# posts only the fifth axis may be locked. Five axis will only
# output correctly if the fifth axis is rotated so it is perpendicular
# to the spindle axis.
#
global mom_sys_lock_status
switch $mom_kin_4th_axis_plane {
XY {
set vec(2) 0.0
}
ZX {
set vec(1) 0.0
}
YZ {
set vec(0) 0.0
}
}
if { [EQ_is_zero $len] } {
set mom_sys_spindle_axis(2) 1.0
}
} else {
global mom_kin_linearization_flag
LINEARIZE_LOCK_MOTION
} else {
LINEARIZE_LOCK_OUTPUT -1
#<09-15-09 wbh> We must call ROTSET only one time for the 4th and/or 5th axis.
# Since the proc ROTSET was called in LINEARIZE_LOCK_OUTPUT,
# we should reload mom_prev_rot_ang_5th if it exists.
if { [info exists mom_kin_5th_axis_direction] } {
set mom_prev_rot_ang_5th $mom_out_angle_pos(1)
MOM_reload_variable mom_prev_rot_ang_5th
}
}
set mom_prev_rot_ang_4th $mom_out_angle_pos(0)
MOM_reload_variable mom_prev_rot_ang_4th
MOM_reload_variable -a mom_pos
}
}
}
8. PB_CMD_uplevel_CALCULATE_ANGLE
uplevel #0 {
#--------------------------------------------
proc CALCULATE_ANGLE { mode matrix ang} {
# This command is used to calculate the coordinate system rotation angles
# to support coordinate rotation function (G68/ROT/AROT G68.2/CYCLE800/PLANE
SPATIAL)
upvar $matrix rotation_matrix
# upvar $a A; upvar $b B; upvar $c C
upvar $ang rot_ang
global RAD2DEG
global coord_ang_A coord_ang_B coord_ang_C
set m0 $rotation_matrix(0)
set m1 $rotation_matrix(1)
set m2 $rotation_matrix(2)
set m3 $rotation_matrix(3)
set m4 $rotation_matrix(4)
set m5 $rotation_matrix(5)
set m6 $rotation_matrix(6)
set m7 $rotation_matrix(7)
set m8 $rotation_matrix(8)
if {$mode == "XYZ"} {
set cos_b_sq [expr $m0*$m0 + $m3*$m3]
} else {
} elseif {$mode=="ZXY"} {
set cos_a_sq [expr $m3*$m3 + $m4*$m4]
} else {
} elseif {$mode=="ZYX"} {
if {[EQ_is_equal [expr abs($m2)] 1.0]} {
set C [expr atan2([expr -1*$m3],$m4)]
} else {
set C [expr atan2($m1,$m0)]
}
if {![EQ_is_zero $cos_B]} {
set A [expr atan2($m5/$cos_B,$m8/$cos_B)]
} else {
set A 0.0
}
} else {
MOM_output_to_listing_device " The mode $mode is not available!"
set A 0
set B 0
set C 0
set rot_ang(0) $A; set rot_ang(1) $B; set rot_ang(2) $C
}
set coord_ang_A $A
set coord_ang_B $B
set coord_ang_C $C
}
}; # uplevel
9. PB_CMD_uplevel_new_tap
uplevel #0 {
#=============================================================
proc MOM_tap_deep { } {
#=============================================================
global cycle_name
global cycle_init_flag
#=============================================================
proc MOM_tap_deep_move { } {
#=============================================================
global cycle_init_flag
global mom_sys_abort_next_event
global mom_cycle_option
PB_CMD_set_cycle_plane
set mom_cycle_option "OPTION"
PB_CMD_tapping_g_code_string_determine
PB_CMD_tap_option_detect
PB_CMD_force_cycle
MOM_do_template tap_deep_break_chip_move
if { [PB_CMD__check_block_check_retract_setting] } {
MOM_force Once G_motion
MOM_do_template cycle_parameters
}
set cycle_init_flag FALSE
}
#=============================================================
proc MOM_tap_break_chip { } {
#=============================================================
global cycle_name
global cycle_init_flag
#=============================================================
proc MOM_tap_break_chip_move { } {
#=============================================================
MOM_tap_deep_move
}
} ;# uplevel
11. PB_CMD_set_default_dpp_value
# This custom command is used to set default dpp value;
# It's called in start of program and end of path
#
# 07-23-2012 ljw - Initial version
# 07-27-2012 yaoz - Add dpp_coord_transformation for polar and XZC mode
global dpp_tool_path_type
## "2AXIS" 2 axis tool path
## "3AXIS" 3 axis tool path
## "5AXIS" 5 axis tool path
global dpp_coord_rotation
## "ROTATION" G68/ROT/AROT G68.2/CYCLE800/PLANE SPATIAL
## "OFF"
global dpp_cal_coord_rot_type
## "LOCAL_CSYS" the programming coordinate system is CSYS
## "AUTO_3D" the programming coordinate system is determined by tool axis which
is not parallel to Z axis
global dpp_coord_rotation_output_type
## "WCS_ROTATION" G68/ROT/AROT
## "SWIVELING" G68.2/CYCLE800/PLANE SPATIAL
global dpp_tcp_tool_axis_output_mode
## "AXIS" output the rotation angle of axis (G43.4)
## "VECTOR" output tool axis vector(G43.5)
global dpp_output_coord_mode
## "TCP_FIX_TABLE" use a coordinate system fixed on the table as the programming
coordinate system
## "TCP_FIX_MACHINE" use workpiece coordinate system fixed on machine as the
programming coordinate system
global dpp_cycle_clearance_plane
## "TRUE" drilling operation has clearance plane or start point using AUTO_3D
## "FALSE" drilling operation has no clearance plane using AUTO_3D
global dpp_prev_coord_rotation
## an array records the coordinate rotation angles by previous swiveling function
global dpp_cycle_hole_counter
## used to record the TAP hole conter, detect whether the hole is the first hole
## to decide whether M29 is needed
global dpp_coord_transformation
## "POLAR" G112/TRANSMIT
## "XZC"
## "OFF"