找回密码
 立即注册

QQ登录

只需一步,快速开始

微信扫码登录

搜索
查看: 23|回复: 0

[原创] 手把手教你制作UG四五轴宏联动后处理(十一)

[复制链接]

38

主题

133

回帖

1575

积分

六级士官

积分
1575
发表于 8 小时前 | 显示全部楼层 |阅读模式
set w4 [format "%.4f" $vz]
        if {[string index $w4 end-0] == "0"} {
          if {[string index $w4 end-1] == "0"} {
            if {[string index $w4 end-2] == "0"} {
              if {[string index $w4 end-3] == "0"} {
                set w4 [format "%d." [expr round($vz)]]
              } else {
                  set w4 [format "%.1f" $vz]
                }
            } else {
                set w4 [format "%.2f" $vz]
              }
          } else {
              set w4 [format "%.3f" $vz]
            }
        }
        if {$vz > 0.0} {
          set s4 [format "+%s" $w4]
        } elseif {$vz < 0.0} {
            set s4 [format "%s" $w4]
          } else {
              set s4 "NONE"
            }
        if {[string compare "NONE" $s1] && [string compare "NONE" $s2] && [string compare "NONE" $s3]} {
          set s [format "%s%s%s" $s1 $s2 $s3]
        } elseif {[string compare "NONE" $s1] && ![string compare "NONE" $s2] && ![string compare "NONE" $s3]} {
            set s $s1
          } elseif {![string compare "NONE" $s1] && [string compare "NONE" $s2] && ![string compare "NONE" $s3]} {
              set s $s2
            } elseif {![string compare "NONE" $s1] && ![string compare "NONE" $s2] && [string compare "NONE" $s3]} {
                set s $s3
              } elseif {[string compare "NONE" $s1] && [string compare "NONE" $s2] && ![string compare "NONE" $s3]} {
                  set s [format "%s%s" $s1 $s2]
                } elseif {[string compare "NONE" $s1] && ![string compare "NONE" $s2] && [string compare "NONE" $s3]} {
                    set s [format "%s%s" $s1 $s3]
                  } elseif {![string compare "NONE" $s1] && [string compare "NONE" $s2] && [string compare "NONE" $s3]} {
                      set s [format "%s%s" $s2 $s3]
                    } else {
                        set s "NONE"
                      }
        if {[string compare "NONE" $s] && [string compare "NONE" $s4]} {
          set sz [format "\[%s%s\]" $s $s4]
        } elseif {![string compare "NONE" $s] && [string compare "NONE" $s4]} {
            set sz $s4:
          } elseif {[string compare "NONE" $s] && ![string compare "NONE" $s4]} {
              set sz [format "\[%s\]" $s]
            } else {
                set sz "0."
              }
        return 1
      }
      return 0
      点击确定。
8.在"程序和刀轨"选项卡中,选择左侧"工序结束序列"选项,在"刀轨结束"事件下添加G91 G28 Z0.行。
9.在"程序和刀轨"选项卡中,选择左侧"程序结束序列"选项:
  (1).在"程序结束"事件下添加G91 G28 X0. Y0. M9行。
  (2).在"程序结束"事件下的G91 G28 X0. Y0. M9行下面添加G91 G28 A0. C0. M5行。
  (3).在"程序结束"事件下的G91 G28 A0. YC0. M5行下面添加M30行。
  (4).在"程序结束"事件下的M30行下面添加%行。
10.保存后处理文件。  
11.五轴双转台AC宏联动后处理制作完成。
   

===============================
(四). 制作五轴双转台BC宏联动后处理:
===============================
1.打开NX后处理构造器,新建一个后处理。
2.输入后处理名称Jia_5x_macro_full_BC,选中主后处理,后处理输出单位选择毫米,
   机床选择5轴带双转台,控制器选择一般,点击确定。
3.在"机床"选项卡中,选择左侧"第四轴"选项,将"轴限制(度)->最大值"改成20,
  "轴限制(度)->最小值"改成-110,轴限制可以根据具体机床设置。
   点击"选择轴->配置"按钮,将"第四轴转台->旋转平面"改成ZX,将"文字引导符"改成B,
   将"第五轴转台->旋转平面"改成XY,将"文字引导符"改成C。
   将"最大进给率(度/分)"改成1000,将"线性插值->旋转角度->默认公差"改成0.001,点击确定。
4.在"机床"选项卡中,选择左侧"第五轴"选项,将"轴限制(度)->最大值"改成360,
  "轴限制(度)->最小值"改成0,轴限制可以根据具体机床设置。
5.在"程序和刀轨"选项卡中,选择左侧"程序起始序列"选项,右侧出现"程序开始"事件页面:
  (1).点击定制命令PB_CMD___log_revisions,输入如下TCL代码:
      #变量dpp_path_type用来判断工序刀路类型:三轴/定轴/五轴联动
      global dpp_path_type
      global dpp_flag
      set dpp_path_type "NONE"
      set dpp_flag 0
      点击确定。
  (2).删除MOM_set_seq_on行。
  (3).将G40 G17 G90 G71条目内容改成G17 G40 G80 G69 G49 G94 G90。
  (4).在G17 G40 G80 G69 G49 G94 G90行下面添加定制命令行,
      输入名称PB_CMD_init_macro,输入以下TCL代码:
      MOM_output_literal "#101=#5261-#5241"
      MOM_output_literal "#102=#5262-#5242"
      MOM_output_literal "#103=#5263-#5243"
      点击确定。
6.在"程序和刀轨"选项卡中,选择左侧"工序起始序列"选项:
  (1).将"刀轨开始"事件下的定制命令PB_CMD_start_of_operation_force_adress
      里面的内容改成如下TCL代码:
      global dpp_flag
      MOM_force once S M_spindle X Y Z fourth_axis fifth_axis F
      if { $dpp_flag != 0 } {
         MOM_output_literal "M1"
      }
      点击确定。
  (2).在PB_CMD_start_of_operation_force_adress行下面添加操作员消息行,
      输入"工序: $mom_operation_name"(双引号无需输入),点击确定。
  (3).复制"自动换刀"事件下的PB_CND_tool_change_force_adress行到"第一个刀具"事件下面。
  (4).在"第一个刀具"事件下的PB_CND_tool_change_force_adress行下面添加MOM_set_seq_on行。
  (5).在"第一个刀具"事件下的MOM_set_seq_on行下面添加T M6行。
  (6).在"第一个刀具"事件下的T M6行下面添加MOM_set_seq_off行。   
  (7).在"第一个刀具"事件下的MOM_set_seq_off行下面添加操作员消息行,
      输入"刀具: $mom_tool_name"(双引号无需输入),点击确定。
  (8).在"第一个刀具"事件下的"刀具: $mom_tool_name"行下面添加备刀T行。
  (9).将"自动换刀"事件下的G91 G28 Z0.行内容改成G91 G28 Z0. M9。
  (10).在"自动换刀"事件下的G91 G28 Z0. M9行下面添加G91 G28 X0. Y0. M5行。
  (11).在"自动换刀"事件下的T M6行上面添加MOM_set_seq_on行。
  (12).在"自动换刀"事件下的T M6行下面添加MOM_set_seq_off行。
  (13).在"自动换刀"事件下的MOM_set_seq_off行下面添加操作员消息行,
      输入"刀具: $mom_tool_name"(双引号无需输入),点击确定。
  (14).在"自动换刀"事件下的"刀具: $mom_tool_name"行下面添加备刀T行。
  (15).在"初始移动"事件下添加定制命令行,输入名称PB_CMD_detect_tool_path_type,
       编辑TCL代码如下:
       global dpp_flag
       global mom_out_angle_pos
       global mom_tool_axis_type
       global mom_tool_path_type
       global mom_operation_type
       set dpp_flag 1
       if { ![info exists mom_tool_axis_type] } {
          set mom_tool_axis_type 0
       }
       if { ![info exists mom_tool_path_type] } {
          set mom_tool_path_type "undefined"
       }
       if { ($mom_tool_axis_type >= 2 && [string match "Variable-axis *" $mom_operation_type]) ||\
           ![string compare "Sequential Mill Main Operation" $mom_operation_type] || \
           (![string compare "variable_axis" $mom_tool_path_type] &&\
           ![string match "Variable-axis *" $mom_operation_type]) } {
         set dpp_path_type "5X"
      } else {
          set dpp_path_type "3X"
        }
      点击确定。
  (16).将PB_CMD_detect_tool_path_type行复制到"第一次移动"事件下。
  (17).在"初始移动"事件下的PB_CMD_detect_tool_path_type行下面添加定制命令,
       输入名称PB_CMD_calc_g54,编辑TCL代码如下:
       global dpp_path_type
       global mom_out_angle_pos
       global vb vc
       global sb sc
       if {![string compare "3X" $dpp_path_type]} {
         if { $mom_out_angle_pos(0) !=0 || $mom_out_angle_pos(1) != 0} {
           MOM_output_literal "(刀路: 定轴)"
           #*****获取第四轴A旋转角度***********************************
           set vb [expr round($mom_out_angle_pos(0)*10000.0)/10000.0]
           #将A轴角度转换成字符串,并且去除小数末尾多余0
           set sb [format "%.4f" $vb]
           if {[string index $sb end-0] == "0"} {
             if {[string index $sb end-1] == "0"} {
               if {[string index $sb end-2] == "0"} {
                 if {[string index $sb end-3] == "0"} {
                   set sb [format "%d." [expr round($vb)]]
                 } else {
                     set sb [format "%.1f" $vb)]
                   }
               } else {
                   set sb [format "%.2f" $vb]
                 }
             } else {
                 set sb [format "%.3f" $vb]
               }
           }
           #********获取第五轴C旋转角度***************************
           set vc [expr round($mom_out_angle_pos(1)*10000.0)/10000.0]
           #将C轴角度转换成字符串,并且去除小数末尾多余0
           set sc [format "%.4f" $vc]
           if {[string index $sc end-0] == "0"} {
             if {[string index $sc end-1] == "0"} {
               if {[string index $sc end-2] == "0"} {
                 if {[string index $sc end-3] == "0"} {
                   set sc [format "%d." [expr round($vc)]]
                 } else {
                     set sc [format "%.1f" $vc)]
                   }
               } else {
                   set sc [format "%.2f" $vc]
                 }
             } else {
                 set sc [format "%.3f" $vc]
               }
           }
未完待续。。。。


您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

咨询QQ:1359218528|发帖须知!|Archiver|手机版|小黑屋|UG爱好者论坛 ( 京ICP备10217105号-2 )

GMT+8, 2025-12-31 11:23

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表