UG后处理三轴基础代码

2023-07-09  阅读 740 次

后处理常用系统变量名,常放置在程序头和程序尾的变量

NC文件名称:mom_output_file_basename

零件名称:mom_part_name

后处理器名称:mom_event_handler_file_name

程序组名称:mom_group_name

工序名称:mom_operation_name

加工余量:mom_stock_floor    mom_stock_part    mom_wall_stock

加工预计工时:mom_machine_time

电脑用户名:mom_logname

后处理日期:mom_date

----------------------------------------------------------

global mom_output_file_basename mom_part_name

global mom_event_handler_file_name

MOM_output_literal ";NC:$mom_output_file_basename "

MOM_output_literal ";Part:$mom_part_name  "

MOM_output_literal ";Post:$mom_event_handler_file_name "

----------------------------------------------------------

有两个操作就输出某信息只有一个操作就不输出

global mom_current_oper_is_last_oper_in_program

if {$mom_current_oper_is_last_oper_in_program == NO } {

MOM_output_literal "M60"

MOM_output_literal "NA 1"

MOM_output_literal "G30 P1"

MOM_output_literal "TLFON"

MOM_output_literal "M289 RP=2"

}

----------------------------------------------------------

操作头输出操作名

global mom_operation_name

MOM_output_literal "$mom_operation_name"

----------------------------------------------------------

操作头输出加工余量

global mom_stock_floor mom_stock_part

global mom_wall_stock mom_stock_part_use

global sidestock floorstock

if {[info exists mom_stock_part]} {

set sidestock $mom_stock_part

} elseif {[info exists mom_wall_stock]} {

set sidestock $mom_wall_stock

} else {

set sidestock 0

}

if {[info exists mom_stock_floor]} {

    if {[info exists mom_stock_part_use] && $mom_stock_part_use == 1} {

        if {[info exists mom_stock_part]} {

            set floorstock $mom_stock_part

            }

    } else {

    set floorstock $mom_stock_floor

    }

} else {

set floorstock 0

}

MOM_output_literal "(sidestock =[format "%.3f" $sidestock] \

floorstock =[format "%.3f" $floorstock])"

----------------------------------------------------------

操作头强制功能字与操作属性判断

MOM_force once X Y Z F R I J

MOM_force once G_motion G_mode G M_spindle S

global mom_current_oper_is_last_oper_in_program

if { [ info exists mom_current_oper_is_last_oper_in_program ] && $mom_current_oper_is_last_oper_in_program ==YES } {

MOM_output_literal "--------------------YES------------------"

}

global first_operation

set first_operation 1

global first_operation

if { $first_operation == 1 } {

MOM_output_literal "---------------我是第一个操作-------------------"

set first_operation 0

} else {

MOM_output_literal "-------------no--no--no-----------------"

}

----------------------------------------------------------

按程序组一次输出多个程序

每个程序组只输出一次组名

global tempgroupname

set tempgroupname 57205362

global mom_operation_name

global mom_group_name tempgroupname

if { [info exists mom_group_name] && $mom_group_name != $tempgroupname } {

MOM_output_literal " ($mom_group_name) "

set tempgroupname $mom_group_name

}

MOM_output_literal " ($mom_operation_name) "

MOM_force once S M_spindle

----------------------------------------------------------

直接输出G54及自动判断输出G54-G59

输出G54.1p1等想输出什么就输出什么

global mom_mcsname_attach_opr mom_operation_name

MOM_output_literal "$mom_mcsname_attach_opr($mom_operation_name)"

global mom_operation_name

MOM_output_literal "($mom_operation_name)"

global mom_fixture_offset_value

if {[info exists mom_fixture_offset_value]} {

if { $mom_fixture_offset_value == 0 } {

MOM_output_literal "G54.1P0"

}

if { $mom_fixture_offset_value == 1 } {

MOM_output_literal "G54.1P1"

}

if { $mom_fixture_offset_value  == 2 } {

MOM_output_literal "G54.1P2"

}

}

每次换刀输出一次坐标系不换刀不输出

global hastoolchange

set hastoolchange 1

global mom_next_oper_has_tool_change hastoolchange

if { $mom_next_oper_has_tool_change == YES } {

set hastoolchange 1

}

global mom_operation_name

MOM_output_literal "($mom_operation_name)"

global hastoolchange

if {[info exists hastoolchange] && $hastoolchange == 1} {

MOM_force once G54

set hastoolchange 0

}

$mom_fixture_offset_value + 53

换坐标系时输出一次Z轴回零不换坐标不输出

global mom_fixture_offset_value tem_mom_fixture_offset_value

set tem_mom_fixture_offset_value $mom_fixture_offset_value

global mom_fixture_offset_value tem_mom_fixture_offset_value

if {[info exists tem_mom_fixture_offset_value] } {

if { $tem_mom_fixture_offset_value != $mom_fixture_offset_value } {

MOM_output_literal "G91 G30 Z0. "

MOM_force once G_mode

}

}

----------------------------------------------------------

每个操作头输出一次行号其他行不输出行号

$mom_operation_name

每次换刀输出一次行号其他行不输出行号

要求行号单独占一行且在换刀之后的M01之前

global temseq

set temseq 1

global temseq

MOM_output_literal "N$temseq"

MOM_output_literal "M01"

incr temseq 1

----------------------------------------------------------

刀具相关设置

无刀库的机床不输出换刀指令方法

输出刀具信息防止未定义刀具类型出错-1

global mom_tool_number mom_tool_name

global mom_tool_diameter mom_tool_corner1_radius

global mom_tool_flute_length mom_tool_length

if {![info exists mom_tool_corner1_radius] } {

set mom_tool_corner1_radius 57205362

}

MOM_output_literal "(T$mom_tool_number=$mom_tool_name \

D=[format "%.2f" $mom_tool_diameter] \

R1=[format "%.2f" $mom_tool_corner1_radius] \

FL=[format "%.2f" $mom_tool_flute_length] \

L=[format "%.2f" $mom_tool_length]“

unset mom_tool_corner1_radius

输出刀具信息防止未定义刀具类型出错-2

global mom_tool_number mom_tool_name

global mom_tool_diameter mom_tool_corner1_radius

global mom_tool_flute_length mom_tool_length

global mom_tool_lower_corner_radius mom_tool_type

global mom_tool_shank_diameter

if {$mom_tool_type == "Milling Tool-T Cutter"} {

MOM_output_literal "(T$mom_tool_number=$mom_tool_name \

D=[format "%.2f" $mom_tool_diameter] \

R1=[format "%.2f" $mom_tool_lower_corner_radius] \

ND=[ format "%.2f" $mom_tool_shank_diameter] \

FL=[format "%.2f" $mom_tool_flute_length] \

L=[format "%.2f" $mom_tool_length] )  "

} elseif {$mom_tool_type == "Milling Tool-5 Parameters"} {

MOM_output_literal "(T$mom_tool_number=$mom_tool_name \

D=[format "%.2f" $mom_tool_diameter] \

R1=[format "%.2f" $mom_tool_corner1_radius] \

FL=[format "%.0f" $mom_tool_flute_length] \

L=[format "%.2f" $mom_tool_length] )  "

} else {

MOM_output_literal "(undefine tool type message)"

MOM_output_literal "(Tool_type:$mom_tool_type )“

}

换刀前M5M9换刀后M01M3M8但第一把刀不输出M5M9

每个操作都输出一次换刀不管是否有换刀且避免有换刀时重复输出

global hastoolchange mom_next_oper_has_tool_change

if {[info exists mom_next_oper_has_tool_change] \

&& $mom_next_oper_has_tool_change == "YES" } {

set hastoolchange 0

} else {

set hastoolchange 1

}

global mom_operation_name

MOM_output_literal "($mom_operation_name)"

global hastoolchange

if {[info exists hastoolchange] && $hastoolchange == 1 } {

MOM_force once T M S M_spindle G G_adjust H

PB_auto_tool_change

set hastoolchange 0

}

每个程序组都输出一次换刀信息不管是否有换刀但不是每个操作都输出

global tempgroupname

set tempgroupname 57205362

global hastoolchange mom_next_oper_has_tool_change

if {[info exists mom_next_oper_has_tool_change] \

&& $mom_next_oper_has_tool_change == "YES" } {

set hastoolchange 0

} else {

set hastoolchange 1

}

global mom_operation_name

MOM_output_literal "($mom_operation_name)"

global mom_group_name tempgroupname

if { [info exists mom_group_name] && $mom_group_name != $tempgroupname } {

MOM_output_literal " ($mom_group_name) "

set tempgroupname $mom_group_name

global hastoolchange

if {[info exists hastoolchange] && $hastoolchange == 1 } {

MOM_force once T M S M_spindle G G_adjust H

PB_auto_tool_change

set hastoolchange 0

}

}

----------------------------------------------------------

刀补相关设置

刀补G40不单独占一行

刀补G41之后必然有D01

MOM_force once D

是否输出G41的判断

global mom_cutcom_type mom_tool_cutcom_register

if { [info exists mom_cutcom_type] && $mom_cutcom_type != 0  } {

MOM_output_literal "D = $mom_tool_cutcom_register "

}


----------------------------------------------------------

主轴转速S和M03单独占一行或M3M8不在同一行

当主轴转速改变时重新输出S和M

global temp_spindle_speed mom_spindle_speed

set temp_spindle_speed $mom_spindle_speed

global mom_operation_name

MOM_output_literal "($mom_operation_name)"

global temp_spindle_speed mom_spindle_speed

if {[info exists temp_spindle_speed] && \

$temp_spindle_speed != $mom_spindle_speed} {

MOM_force once  M_spindle S

}

global mom_tool_number

MOM_output_literal "TOOL CALL \

T$mom_tool_number Z \

S$mom_spindle_speed"

MOM_output_literal "M03"


----------------------------------------------------------

运动类型相关设置

快速运动G00及线性运动G01设置

输出圆弧代码与否的区别及无法输出圆弧的原因

圆弧参数设置说明

圆弧异常最大最小圆弧设置问题

圆弧异常IJ模态问题

圆弧IJ方式输出为R方式及问题

输出螺旋代码与否的区别及无法输出螺旋代码的原因

螺旋参数设置说明及螺旋代码K报警处理

西门子铣螺纹螺距不正确问题

#加入以下的代码即可

set mom_helix_turn_number [expr ($feed_distance/$pitch)]

if { $mom_helix_turn_number > 1 } {

      set mom_helix_turn_number [expr ceil($mom_helix_turn_number-1)]

   } else {

set mom_helix_turn_number 0

}


海德汉螺旋代码不正确问题

MOM_force once X Y Z

MOM_do_template helix_pos

输出钻孔循环与否的区别及无法输出钻孔循环代码的原因

不同编程方式对应输出的循环代码及不符合要求时的修改方法

输出G98G99的选择及G99回退不正确问题

钻孔循环特殊要求及问题

global G81_first_point

set G81_first_point 1

global G81_first_point

if { $G81_first_point == 1 } {

MOM_suppress once X Y

set G81_first_point 0

}

攻丝循环G84说明及问题-1

攻丝循环G84说明及问题-2

$mom_cycle_delay

MOM_force once M29 G95 TAP_S TAP_M TAP_F TAP_Q

global mom_current_motion

if { $mom_current_motion != "tap_move" } {

MOM_suppress once G94

}

siemens840d系统CYCLE84攻丝循环设置

global mom_siemens_cycle_o_var1

global mom_siemens_cycle_o_dam

global mom_siemens_cycle_o_vrt

global mom_cycle_cam

global mom_cycle_delay

if {[info exists mom_cycle_cam] \

&& [info exists mom_cycle_delay] } {

set mom_siemens_cycle_o_var1 $mom_cycle_cam

set mom_siemens_cycle_o_dam $mom_cycle_delay

set mom_siemens_cycle_o_vrt $mom_cycle_delay

}

heidenhainI530系统CYCL209攻丝循环设置

global mom_cycle_step1

global mom_cycle_delay

global dpp_TNC_cycle_step_clearance

if {[info exists mom_cycle_delay] } {

set mom_cycle_step1 $mom_cycle_delay

set dpp_TNC_cycle_step_clearance $mom_cycle_delay

} else {

set mom_cycle_step1 0

set dpp_TNC_cycle_step_clearance 0

}

----------------------------------------------------------

进给率相关设置

MOM_force once S M_spindle X Y Z fourth_axis fifth_axis F

MOM_force once F

----------------------------------------------------------

操作结束相关设置

MOM_output_literal "G91 G28 Z0 "

MOM_output_literal “G90 "

global mom_current_oper_is_last_oper_in_program

if { [ info exists mom_current_oper_is_last_oper_in_program ] && $mom_current_oper_is_last_oper_in_program ==YES } {

MOM_output_literal "-------------YES-----------------"

}

global mom_current_oper_is_last_oper_in_program

if { [ info exists mom_current_oper_is_last_oper_in_program ] \

&& $mom_current_oper_is_last_oper_in_program ==YES } {

return 0

} else {

return 1

}


----------------------------------------------------------

程序结束相关设置

PB_CMD_check_travel_limits

global mom_sys_max_travel

global mom_sys_min_travel

MOM_output_literal "( Max Z = [format %.3f $mom_sys_max_travel(2)]   \

MIN Z = [format %.3f $mom_sys_min_travel(2)] ) "

global mom_machine_time mom_logname

MOM_output_literal "( Cutting Time = [format "%0.1f" $mom_machine_time] Min )"

global mom_logname

MOM_output_literal "( PC_name = $mom_logname )"

set chskjszx [clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S"]

MOM_output_literal "( Post Date = $chskjszx )"

----------------------------------------------------------

主轴转速S为0等安全报警设置

global mom_spindle_speed mom_operation_name

if { $mom_spindle_speed == 0 } {

MOM_abort "\n\n 雅爱提示:S=0\n \

操作名为: $mom_operation_name 的主轴转数为0\n\n"

}

global mom_tool_number mom_tool_name

if {$mom_tool_number == "0" || $mom_tool_number > "30"} {

MOM_display_message "刀具名称为:$mom_tool_name

的刀具号设置错误!" \

"雅爱提示" \

"E"

}

$mom_mcsname_attach_opr($mom_operation_name)

$ mom_next_tool_name


本文地址:https://yaaibk.com/post/378.html
版权声明:本文为原创文章,版权归 本站 所有,欢迎分享本文,转载请保留出处!

评论已关闭!