0% found this document useful (0 votes)
225 views18 pages

Post Builder Sim15 - Millturn - 9ax - Fanuc - MM

This document contains a post processor for a Fanuc 9-axis millturn machine. It includes routines for: 1. Facing operations using multiple depth cuts. 2. Initialization of rough and finish turning cycle output handling. 3. Setting the program header with the tape number attribute if available. 4. Overwriting the system RAPID_SET procedure to correctly handle workplane changes and identify the first move of the program.

Uploaded by

Disiplioner 5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
225 views18 pages

Post Builder Sim15 - Millturn - 9ax - Fanuc - MM

This document contains a post processor for a Fanuc 9-axis millturn machine. It includes routines for: 1. Facing operations using multiple depth cuts. 2. Initialization of rough and finish turning cycle output handling. 3. Setting the program header with the tape number attribute if available. 4. Overwriting the system RAPID_SET procedure to correctly handle workplane changes and identify the first move of the program.

Uploaded by

Disiplioner 5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Post processor from library NX12 millturn 9 axis fanuc

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

if {[info exists mom_generic_cycle_status] && ($mom_generic_cycle_status == 1)} {

# Initialize G71/G72 output at generic cycle start


PB_CMD_init_rough_turn_cycle_output

# <shuai 2016-Nov-25> - If a finish operation uses the previous corresponding contour


of a rough turning operation,
# it will also need to skip to the next generic event.
if {([info exists mom_sys_output_contour_motion] &&
($mom_sys_output_contour_motion == 1 || $mom_sys_output_contour_motion == 2)) || \
([info exists ::dpp_fanuc_turning_cycle_type] &&
($::dpp_fanuc_turning_cycle_type == "Rough Finish"))} {

# <shuai 2016-Nov-25> - Remove the checking condition for G70\G71\G72 that


whether a from point has been set or not.
# Check whether a start point has been set
if {([info exists mom_start_status] && $mom_start_status == 1) || \
([info exists mom_motion_type] && $mom_motion_type == "APPROACH")} {

##++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++
# 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.
##++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++

if {[info exists mom_post_oper_path] && ($mom_post_oper_path == 1)} {

# Set start mark of finish contour data in output file


PB_CMD_finish_turn_cycle_contour_start

} else {

# Skip to next generic which should be cycle off


MOM_skip_handler_to_event generic_cycle
}

} else {

MOM_display_message "$mom_operation_name: None of start point or approach


path is defined before turning cycle in this operation.\
\nPlease recheck the parameters. Post processing will be aborted."
"Postprocessor Error Message" "E"
MOM_abort_program
}
}
}

if {[info exists mom_generic_cycle_status] && ($mom_generic_cycle_status == 0)} {

if {[info exists mom_sys_output_contour_motion] && \


($mom_sys_output_contour_motion == 1 || $mom_sys_output_contour_motion ==
2)} {

if {[info exists mom_post_oper_path] && ($mom_post_oper_path == 1)} {

# Set end mark of finish contour data in output file


PB_CMD_finish_turn_cycle_contour_end
}

# Flag to indicate return motion begin


set dpp_return_motion_start 1
# Flag to indicate the first buffer for return motion
set dpp_first_buffer_for_return_motion 1

# Create a list to store the return motion NC codes


set dpp_return_motion_list [list]
}
}

} ; #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

if { ![info exists mom_attr_PROGRAMVIEW_PROGRAM_NUMBER] } {


set mom_attr_PROGRAMVIEW_PROGRAM_NUMBER "O0001"
}

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.
#

# Only redefine RAPID_SET once, since ugpost_base is only loaded once.


#
if { [llength [info commands ugpost_RAPID_SET]] == 0 } {
if { [llength [info commands RAPID_SET]] } {
rename RAPID_SET ugpost_RAPID_SET
}
} else {
return
}

#***********
uplevel #0 {

#====================
proc RAPID_SET { } {
#====================

if { [llength [info commands PB_CMD_set_principal_axis]] > 0 } {


PB_CMD_set_principal_axis
}

global mom_cycle_spindle_axis mom_sys_work_plane_change


global traverse_axis1 traverse_axis2 mom_motion_event mom_machine_mode
global mom_pos mom_prev_pos mom_from_pos mom_last_pos mom_sys_home_pos
global mom_sys_tool_change_pos
global spindle_first rapid_spindle_inhibit rapid_traverse_inhibit

if { ![info exists mom_from_pos($mom_cycle_spindle_axis)] && [info exists


mom_sys_home_pos($mom_cycle_spindle_axis)] } {

set mom_from_pos(0) $mom_sys_home_pos(0)


set mom_from_pos(1) $mom_sys_home_pos(1)
set mom_from_pos(2) $mom_sys_home_pos(2)

} elseif { ![info exists mom_sys_home_pos($mom_cycle_spindle_axis)] && [info


exists mom_from_pos($mom_cycle_spindle_axis)] } {

set mom_sys_home_pos(0) $mom_from_pos(0)


set mom_sys_home_pos(1) $mom_from_pos(1)
set mom_sys_home_pos(2) $mom_from_pos(2)

} elseif { ![info exists mom_sys_home_pos($mom_cycle_spindle_axis)] && ![info


exists mom_from_pos($mom_cycle_spindle_axis)] } {

set mom_from_pos(0) 0.0 ; set mom_sys_home_pos(0) 0.0


set mom_from_pos(1) 0.0 ; set mom_sys_home_pos(1) 0.0
set mom_from_pos(2) 0.0 ; set mom_sys_home_pos(2) 0.0
}

if { ![info exists mom_sys_tool_change_pos($mom_cycle_spindle_axis)] } {


set mom_sys_tool_change_pos($mom_cycle_spindle_axis) 100000.0
}

set is_first_move 0
if { [string match "MOM_first_move" [MOM_ask_event_type]] } {
set is_first_move 1
}

if { ![info exists mom_motion_event] } { set mom_motion_event "" }

if { [string match "initial_move" $mom_motion_event] || $is_first_move } {


set mom_last_pos($mom_cycle_spindle_axis)
$mom_sys_tool_change_pos($mom_cycle_spindle_axis)
} else {
if { [info exists mom_last_pos($mom_cycle_spindle_axis)] == 0 } {
set mom_last_pos($mom_cycle_spindle_axis)
$mom_sys_home_pos($mom_cycle_spindle_axis)
}
}

if { $mom_machine_mode != "MILL" && $mom_machine_mode != "DRILL" } {


# When machine mode is UNDEFINED, ask machine type
if { ![string match "MILL" [PB_CMD_ask_machine_type]] } {
return
}
}

WORKPLANE_SET

set rapid_spindle_inhibit FALSE


set rapid_traverse_inhibit FALSE

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
}

if { ![info exists mom_sys_work_plane_change] } {


set mom_sys_work_plane_change 1
}

# Reverse workplane change direction per spindle axis


global mom_spindle_axis

if { [info exists mom_spindle_axis] } {

#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++
# 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 } {

if { ![EQ_is_equal $mom_spindle_axis(0) 1] && ![EQ_is_equal


$mom_spindle_axis(1) 1] && ![EQ_is_equal $mom_spindle_axis(0) 1] } {

global mom_user_work_plane_change
global mom_user_spindle_first

set mom_user_work_plane_change $mom_sys_work_plane_change


set mom_sys_work_plane_change 0

if [info exists spindle_first] {


set mom_user_spindle_first $spindle_first
} else {
set mom_user_spindle_first NONE
}
}
}
}

if { $mom_sys_work_plane_change } {

if { $going_lower } {
set spindle_first FALSE
} else {
set spindle_first TRUE
}

# Force output in Initial Move and First Move.


if { ![string match "*initial_move*" $mom_motion_event] && !$is_first_move } {

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)] } {

set rapid_traverse_inhibit TRUE


} else {
set rapid_traverse_inhibit FALSE
}
}

} else {
set spindle_first NONE
}

} ;# RAPID_SET

} ;# uplevel
#***********

5. block name G53 = % (rewind_step_code)


6. PB_CMD_uplevel_VECTOR_ROTATE
uplevel #0 {
#=============================================================
proc VECTOR_ROTATE { axis angle input_vector output_vector } {
#=============================================================
# This proc is used to rotating a vector about arbitrary axis
#
upvar $axis r; upvar $input_vector input ; upvar $output_vector output
#set up matrix to rotate about an arbitrary axis
set m(0) [expr $r(0)*$r(0)*(1-cos($angle))+cos($angle)]
set m(1) [expr $r(0)*$r(1)*(1-cos($angle))-$r(2)*sin($angle)]
set m(2) [expr $r(0)*$r(2)*(1-cos($angle))+$r(1)*sin($angle)]
set m(3) [expr $r(0)*$r(1)*(1-cos($angle))+$r(2)*sin($angle)]
set m(4) [expr $r(1)*$r(1)*(1-cos($angle))+cos($angle)]
set m(5) [expr $r(1)*$r(2)*(1-cos($angle))-$r(0)*sin($angle)]
set m(6) [expr $r(0)*$r(2)*(1-cos($angle))-$r(1)*sin($angle)]
set m(7) [expr $r(1)*$r(2)*(1-cos($angle))+$r(0)*sin($angle)]
set m(8) [expr $r(2)*$r(2)*(1-cos($angle))+cos($angle)]
MTX3_vec_multiply input m output
}
}

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

if { [string match "ON" $mom_sys_lock_status] } {

global mom_pos mom_out_angle_pos


global mom_current_motion
global mom_motion_type
global mom_cycle_feed_to_pos
global mom_cycle_feed_to mom_tool_axis
global mom_motion_event
global mom_cycle_rapid_to_pos
global mom_cycle_retract_to_pos
global mom_cycle_rapid_to
global mom_cycle_retract_to
global mom_prev_pos
global mom_kin_4th_axis_type
global mom_kin_spindle_axis
global mom_kin_5th_axis_type
global mom_kin_4th_axis_plane
global mom_sys_cycle_after_initial
global mom_kin_4th_axis_min_limit
global mom_kin_4th_axis_max_limit
global mom_kin_5th_axis_min_limit
global mom_kin_5th_axis_max_limit
global mom_prev_rot_ang_4th
global mom_prev_rot_ang_5th
global mom_kin_4th_axis_direction
global mom_kin_5th_axis_direction
global mom_kin_4th_axis_leader
global mom_kin_5th_axis_leader

if { [string match "circular_move" $mom_current_motion] } {


return
}

if { ![info exists mom_sys_cycle_after_initial] } {


set mom_sys_cycle_after_initial "FALSE"
}

if { [string match "FALSE" $mom_sys_cycle_after_initial] } {


LOCK_AXIS mom_pos mom_pos mom_out_angle_pos
}

if { [string match "CYCLE" $mom_motion_type] } {

if { [string match "initial_move" $mom_motion_event] } {


set mom_sys_cycle_after_initial "TRUE"
#return
}

if { [string match "TRUE" $mom_sys_cycle_after_initial] } {


# set mom_pos(0) [expr $mom_pos(0) - $mom_cycle_rapid_to *
$mom_tool_axis(0)]
# set mom_pos(1) [expr $mom_pos(1) - $mom_cycle_rapid_to *
$mom_tool_axis(1)]
# set mom_pos(2) [expr $mom_pos(2) - $mom_cycle_rapid_to *
$mom_tool_axis(2)]
}

set mom_sys_cycle_after_initial "FALSE"

if { [string match "Table" $mom_kin_4th_axis_type] } {

VMOV 3 mom_kin_spindle_axis mom_sys_spindle_axis

} elseif { [string match "Table" $mom_kin_5th_axis_type] } {

VMOV 3 mom_tool_axis vec

switch $mom_kin_4th_axis_plane {
XY {
set vec(2) 0.0
}
ZX {
set vec(1) 0.0
}
YZ {
set vec(0) 0.0
}
}

set len [VEC3_unitize vec mom_sys_spindle_axis]

if { [EQ_is_zero $len] } {
set mom_sys_spindle_axis(2) 1.0
}
} else {

VMOV 3 mom_tool_axis mom_sys_spindle_axis


}

set mom_cycle_feed_to_pos(0) [expr $mom_pos(0) + $mom_cycle_feed_to *


$mom_sys_spindle_axis(0)]
set mom_cycle_feed_to_pos(1) [expr $mom_pos(1) + $mom_cycle_feed_to *
$mom_sys_spindle_axis(1)]
set mom_cycle_feed_to_pos(2) [expr $mom_pos(2) + $mom_cycle_feed_to *
$mom_sys_spindle_axis(2)]

set mom_cycle_rapid_to_pos(0) [expr $mom_pos(0) + $mom_cycle_rapid_to *


$mom_sys_spindle_axis(0)]
set mom_cycle_rapid_to_pos(1) [expr $mom_pos(1) + $mom_cycle_rapid_to *
$mom_sys_spindle_axis(1)]
set mom_cycle_rapid_to_pos(2) [expr $mom_pos(2) + $mom_cycle_rapid_to *
$mom_sys_spindle_axis(2)]

set mom_cycle_retract_to_pos(0) [expr $mom_pos(0) + $mom_cycle_retract_to *


$mom_sys_spindle_axis(0)]
set mom_cycle_retract_to_pos(1) [expr $mom_pos(1) + $mom_cycle_retract_to *
$mom_sys_spindle_axis(1)]
set mom_cycle_retract_to_pos(2) [expr $mom_pos(2) + $mom_cycle_retract_to *
$mom_sys_spindle_axis(2)]

global mom_kin_linearization_flag

if { ![string compare "TRUE" $mom_kin_linearization_flag] &&\


[string compare "RAPID" $mom_motion_type] &&\
[string compare "RETRACT" $mom_motion_type] } {

LINEARIZE_LOCK_MOTION

} else {

if { ![info exists mom_prev_rot_ang_4th] } { set mom_prev_rot_ang_4th 0.0 }


if { ![info exists mom_prev_rot_ang_5th] } { set mom_prev_rot_ang_5th 0.0 }

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]

if { [EQ_is_equal $cos_b_sq 0.0] } {

set cos_b 0.0


#set cos_c 1.0
#set cos_a $m4
#set sin_c 0.0
#set sin_a [expr -1*$m5]
set cos_a 1.0
set sin_a 0.0
set cos_c $m4
set sin_c [expr -1*$m1]

if { $m6 < 0.0 } {


set sin_b 1.0
} else {
set sin_b -1.0
}

} else {

set cos_b [expr sqrt($cos_b_sq)]


set sin_b [expr -$m6]

set cos_a [expr $m8/$cos_b]


set sin_a [expr $m7/$cos_b]

set cos_c [expr $m0/$cos_b]


set sin_c [expr $m3/$cos_b]

set A [expr -atan2($sin_a,$cos_a)*$RAD2DEG]


set B [expr -atan2($sin_b,$cos_b)*$RAD2DEG]
set C [expr -atan2($sin_c,$cos_c)*$RAD2DEG]

set rot_ang(0) $A; set rot_ang(1) $B; set rot_ang(2) $C

} elseif {$mode=="ZXY"} {
set cos_a_sq [expr $m3*$m3 + $m4*$m4]

if { [EQ_is_equal $cos_a_sq 0.0] } {

set cos_a 0.0


set cos_c 1.0
set sin_c 0.0
set sin_b $m6
set cos_b $m0

if { $m5 < 0.0 } {


set sin_a -1.0
} else {
set sin_a 1.0
}

} else {

set cos_a [expr sqrt($cos_a_sq)]


set sin_a [expr $m5]

set cos_b [expr $m8/$cos_a]


set sin_b [expr -$m2/$cos_a]

set cos_c [expr $m4/$cos_a]


set sin_c [expr -$m3/$cos_a]
}

set A [expr atan2($sin_a,$cos_a)*$RAD2DEG]


set B [expr atan2($sin_b,$cos_b)*$RAD2DEG]
set C [expr atan2($sin_c,$cos_c)*$RAD2DEG]
set rot_ang(0) $C; set rot_ang(1) $A; set rot_ang(2) $B

} 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)]
}

set length [expr sqrt($m0*$m0 + $m1*$m1)]


set B [expr -1*atan2($m2,$length)]
set cos_B [expr cos($B)]

if {![EQ_is_zero $cos_B]} {
set A [expr atan2($m5/$cos_B,$m8/$cos_B)]
} else {
set A 0.0
}

set A [expr $A*$RAD2DEG]


set B [expr $B*$RAD2DEG]
set C [expr $C*$RAD2DEG]
set rot_ang(0) $C; set rot_ang(1) $B; set rot_ang(2) $A
} elseif {$mode=="ZXZ"} {
set sin_b_sq [expr $m2*$m2 + $m5*$m5]

if { [EQ_is_equal $sin_b_sq 0.0] } {


set cos_b 1.0
set sin_b 0.0
set sin_c 0.0
set cos_c 1.0
set sin_a $m1
# set cos_a $m0
if {$m8>0} {
set cos_b 1.0
set cos_a $m0
} else {
set cos_b -1.0
set cos_a -$m4
}
} else {
set sin_b [expr sqrt($sin_b_sq)]
set cos_b [expr $m8]

set cos_a [expr -$m7/$sin_b]


set sin_a [expr $m6/$sin_b]

set cos_c [expr $m5/$sin_b]


set sin_c [expr $m2/$sin_b]
}

set A [expr atan2($sin_a,$cos_a)*$RAD2DEG]


set B [expr atan2($sin_b,$cos_b)*$RAD2DEG]
set C [expr atan2($sin_c,$cos_c)*$RAD2DEG]

set rot_ang(0) $A; set rot_ang(1) $B; set rot_ang(2) $C

} 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

set cycle_init_flag TRUE


set cycle_name TAP_DEEP
CYCLE_SET
}

#=============================================================
proc MOM_tap_deep_move { } {
#=============================================================
global cycle_init_flag
global mom_sys_abort_next_event
global mom_cycle_option

if { [info exists mom_sys_abort_next_event] } {


if { [llength [info commands PB_CMD_kin_abort_event]] } {
PB_CMD_kin_abort_event
}
}

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

set cycle_init_flag TRUE


set cycle_name TAP_BREAK_CHIP
CYCLE_SET
}

#=============================================================
proc MOM_tap_break_chip_move { } {
#=============================================================
MOM_tap_deep_move
}

} ;# uplevel

10. absolute mode G53


G40 G90 G49 G 21

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"

## set default value


set dpp_tool_path_type "3AXIS"
set dpp_coord_rotation "OFF"
set dpp_cal_coord_rot_type "AUTO_3D"
set dpp_coord_rotation_output_type "SWIVELING"
set dpp_tcp_tool_axis_output_mode "VECTOR"
set dpp_output_coord_mode "TCP_FIX_TABLE"
set dpp_cycle_clearance_plane "TRUE"
set dpp_prev_coord_rotation(0) 0
set dpp_prev_coord_rotation(1) 0
set dpp_prev_coord_rotation(2) 0
set dpp_cycle_hole_counter 0
set dpp_coord_transformation "OFF"

You might also like