欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

探究UG后处理中的进给速度R模式输出

最编程 2024-08-10 19:02:08
...

进给速度F之R模式输出

前言:

问题描述:

在机床加工过程中,通过UG CAM生成的数控程序段中可能存在多个进给速度,比如切削进给速度,逼近速度,进刀速度,第一刀切削速度,步进速度,退刀速度等等,如果利用常用的数值模式输出,在实际加工过程中容易出现两个问题:
① 在数控程序较大时候,如果需要对其中一个速度进行修改,可能出现搜索困难等问题
② 在数控程序中,同一个速度类型可能在多个代码段中使用,如果用数值模式输出,往往需要一一进行修改,造成工作量增大等问题

解决:

针对这个问题,不同的数控系统厂商都提供了自家关于进给速度变量控制方式,需要用户自行通过后置处理程序进行配置,那么以变量控制的好处是什么呢?
首先,如果以变量形式控制进给速度,可以在程序头统一体现,便于统一观察、管理及调用变量值,
其次,在修改进给参数时候,可以通过修改变量对应的数值来修改整个类型的进给速度,也可以通过对过程中的具体某个数值进行修改,操作方式更为灵活。

后处理编程过程:

虽然不同数控厂商的变量设置形式不同,当后处理程序段逻辑思路类似,以下我们以西门子840D系统为例,进行编程验证:

TCL程序段

#=============================================================
proc PB_CMD_wjc_value_msg_ini { } {
#=============================================================
uplevel #0 {
#  # 常规进给速度输出格式:
#  # "0" 或其它非 "1" "2"字符, 输出数字
#  # "1", 输出 R 参数格式进给速度, R 值为进给速度值
 set wjc_feed_output_format                "1"
#
#  # 当常规进给速度只有一个或一种速度时输出格式:
#  # "0" 或其它非 "1" 字符, 输出数字
#  # "1", 只有一个或一种速度时跟随输出 R 参数格式进给速度
 set wjc_feed_single_output_format            "0"
};#enduplevel
}
#=============================================================
proc PB_CMD_wjc_value_set_ini { } {
#=============================================================
#初始用户变量设定,在系统初始变量中设定
uplevel #0 {
  set mom_feed_rapid_value                                        "0"
  set mom_feed_approach_value                                     "0"
  set mom_feed_engage_value                                       "0"
  set mom_feed_first_cut_value                                    "0"
  set mom_feed_stepover_value                                     "0"
  set mom_feed_cut_value                                          "0"
  set mom_feed_traversal_value                                    "0"
  set mom_feed_retract_value                                      "0"
  set mom_feed_return_value                                       "0"
  set mom_feed_departure_value                                    "0"

  set custom_feed_rapid_text                                       ""
  set custom_feed_approach_text                                    ""
  set custom_feed_engage_text                                      ""
  set custom_feed_first_cut_text                                   ""
  set custom_feed_stepover_text                                    ""
  set custom_feed_cut_text                                         ""
  set custom_feed_traversal_text                                   ""
  set custom_feed_retract_text                                     ""
  set custom_feed_return_text                                      ""
  set custom_feed_departure_text                                   ""
  set custom_feed_rate_text                                        ""
  set custom_feed_base_value_text                                  ""

  set custom_sys_leader_F                                          "F"
  set custom_sys_trailer_F                                          ""
   }; # end_uplevel
}

#=============================================================
proc PB_CMD_wjc_feed_check { } {
#=============================================================
#检测当前Feed设置形式,用于mom_before_motion中PB_CMD_wjc_feed_R_mode_replace前判定
#用于判定UG进给速度设置形式,是否是同一速度或不同速度等
  global  mom_feed_rapid_value #参数变量需要自行在mom变量中确认
  global  mom_feed_approach_value
  global  mom_feed_engage_value
  global  mom_feed_first_cut_value
  global  mom_feed_stepover_value
  global  mom_feed_cut_value
  global  mom_feed_traversal_value
  global  mom_feed_retract_value
  global  mom_feed_return_value
  global  mom_feed_departure_value
  global  custom_flag_feed_type_count
if {[EQ_is_zero $mom_feed_rapid_value]   &&  [EQ_is_zero $mom_feed_approach_value]        && \
  [EQ_is_zero $mom_feed_engage_value]  && [EQ_is_zero $mom_feed_first_cut_value]    && \
  [EQ_is_zero $mom_feed_stepover_value]  && [EQ_is_zero $mom_feed_traversal_value]    && \
  [EQ_is_zero $mom_feed_retract_value]  &&  [EQ_is_zero $mom_feed_departure_value] }  {
set custom_flag_feed_type_count 1
  } elseif {
 ([EQ_is_zero $mom_feed_rapid_value] || [EQ_is_equal $mom_feed_cut_value $mom_feed_rapid_value])  && \
 ([EQ_is_zero $mom_feed_approach_value]    || [EQ_is_equal $mom_feed_cut_value $mom_feed_approach_value])  && \
([EQ_is_zero $mom_feed_engage_value]  || [EQ_is_equal $mom_feed_cut_value $mom_feed_engage_value])        && \
([EQ_is_zero $mom_feed_first_cut_value]    || [EQ_is_equal $mom_feed_cut_value $mom_feed_first_cut_value])    && \
 ([EQ_is_zero $mom_feed_stepover_value]    || [EQ_is_equal $mom_feed_cut_value $mom_feed_stepover_value])    && \
 ([EQ_is_zero $mom_feed_traversal_value]    || [EQ_is_equal $mom_feed_cut_value $mom_feed_traversal_value])    && \
 ([EQ_is_zero $mom_feed_retract_value]        || [EQ_is_equal $mom_feed_cut_value $mom_feed_retract_value])     && \
  ([EQ_is_zero $mom_feed_departure_value]    || [EQ_is_equal $mom_feed_cut_value $mom_feed_departure_value])   }  {
  set custom_flag_feed_type_count 2
  } else {
  set custom_flag_feed_type_count 0
  }
}

#=============================================================
proc PB_CMD_wjc_feed_R_mode_output { } {
#=============================================================
#输出R模式格式,该程序段用于生成R模式的参数值及程序段头显示
#custom_flag_feed_type_count 均为0设置为1  均为0或者与切削速度相同为2  其他情况为0
  global  feed
  global  custom_feed
  global  mom_template_type

  global  custom_sys_leader_F
  global  custom_sys_trailer_F
  global  custom_sys_leader_F_output
  global  custom_sys_trailer_F_output

  global  mom_feed_rapid_value
  global  mom_feed_approach_value
  global  mom_feed_engage_value
  global  mom_feed_first_cut_value
  global  mom_feed_stepover_value
  global  mom_feed_cut_value
  global  mom_feed_traversal_value
  global  mom_feed_retract_value
  global  mom_feed_return_value
  global  mom_feed_departure_value

  global  custom_feed_rapid_value
  global  custom_feed_approach_value
  global  custom_feed_engage_value
  global  custom_feed_first_cut_value
  global  custom_feed_stepover_value
  global  custom_feed_cut_value
  global  custom_feed_traversal_value
  global  custom_feed_retract_value
  global  custom_feed_return_value
  global  custom_feed_departure_value

  global  custom_feed_rapid_text
  global  custom_feed_approach_text
  global  custom_feed_engage_text
  global  custom_feed_first_cut_text
  global  custom_feed_stepover_text
  global  custom_feed_cut_text
  global  custom_feed_traversal_text
  global  custom_feed_retract_text
  global  custom_feed_return_text
  global  custom_feed_departure_text
  global  custom_feed_rate_text
  global  custom_feed_base_value_text

  global  custom_flag_feed_type_count

  global  mom_seqnum
  global  custom_seqnum_length_old
  global  custom_seqnum_length_new

  global  custom_R_number
  global  custom_blanks_length_max
  global  custom_blanks_length_min
  global  custom_blanks_temp
  global  custom_blanks
  global  custom_blanks_1
  global  custom_blanks_2

  # for NX8
  global  mom_feed_rapid_unit
  global  mom_feed_approach_unit
  global  mom_feed_engage_unit
  global  mom_feed_first_cut_unit
  global  mom_feed_stepover_unit
  global  mom_feed_cut_unit
  global  mom_feed_traversal_unit
  global  mom_feed_retract_unit
  global  mom_feed_return_unit
  global  mom_feed_departure_unit

  global  mom_feed_rapid_nominal_unit
  global  mom_feed_approach_nominal_unit
  global  mom_feed_engage_nominal_unit
  global  mom_feed_first_cut_nominal_unit
  global  mom_feed_stepover_nominal_unit
  global  mom_feed_cut_nominal_unit
  global  mom_feed_traversal_nominal_unit
  global  mom_feed_retract_nominal_unit
  global  mom_feed_return_nominal_unit
  global  mom_feed_departure_nominal_unit

  global  mom_feed_rapid_nominal_value
  global  mom_feed_approach_nominal_value
  global  mom_feed_engage_nominal_value
  global  mom_feed_first_cut_nominal_value
  global  mom_feed_stepover_nominal_value
  global  mom_feed_cut_nominal_value
  global  mom_feed_traversal_nominal_value
  global  mom_feed_retract_nominal_value
  global  mom_feed_return_nominal_value
  global  mom_feed_departure_nominal_value
  global  mom_ug_version
 #MOM_output_literal "mom_ug_version = $mom_ug_version "
 #MOM_output_literal "mom_feed_first_cut_nominal_value = $mom_feed_first_cut_nominal_value "

 if  {$mom_ug_version >= "8.0"} {
# -01-
      if {[info exists mom_feed_cut_nominal_unit]} {
      switch $mom_feed_cut_nominal_unit {
                "None"            { }
                "mmpm"            { }
                "mmpr"            { }
                default            { }
      }
      }

      # -02-
      if {[info exists mom_feed_rapid_nominal_unit]} {
  switch $mom_feed_rapid_nominal_unit {
                "None"            {    }
                "mmpm"            { }
                "mmpr"            { }
                "Rapid"            { }
   "%Cut"    { set mom_feed_rapid_value     [expr $mom_feed_rapid_nominal_value / 100.0 * $mom_feed_cut_value] }
                default            { }
      }
      }

        # -03-
        if {[info exists mom_feed_approach_nominal_unit]} {
        switch $mom_feed_approach_nominal_unit {
                "None"            {    }
                "mmpm"            { }
                "mmpr"            { }
                "Rapid"            { }
    "%Cut" { set mom_feed_approach_value  [expr $mom_feed_approach_nominal_value / 100.0 * $mom_feed_cut_value] }
                default            { }
      }
      }

      # -04-
      if {[info exists mom_feed_engage_nominal_unit]} {
      switch $mom_feed_engage_nominal_unit {
                "None"            {    }
                "mmpm"            { }
                "mmpr"            { }
                "Rapid"            { }
 "%Cut"   { set mom_feed_engage_value    [expr $mom_feed_engage_nominal_value / 100.0 * $mom_feed_cut_value] }
                default            { }
      }
      }

      # -05-
      if {[info exists mom_feed_first_cut_nominal_unit]} {
      switch $mom_feed_first_cut_nominal_unit {
                "None"            {    }
                "mmpm"            { }
                "mmpr"            { }
                "Rapid"            { }
   "%Cut"   { set mom_feed_first_cut_value  [expr $mom_feed_first_cut_nominal_value / 100.0 * $mom_feed_cut_value] }
                default            { }
      }
      }

      # -06-
      if {[info exists mom_feed_stepover_nominal_unit]} {
      switch $mom_feed_stepover_nominal_unit {
                "None"            {    }
                "mmpm"            { }
                "mmpr"            { }
                "Rapid"            { }
     "%Cut"  { set mom_feed_stepover_value  [expr $mom_feed_stepover_nominal_value / 100.0 * $mom_feed_cut_value] }
                default            { }
      }
      }

      # -07-
      if {[info exists mom_feed_traversal_nominal_unit]} {
      switch $mom_feed_traversal_nominal_unit {
                "None"            {    }
                "mmpm"            { }
                "mmpr"            { }
                "Rapid"            { }
"%Cut"  { set mom_feed_traversal_value   [expr $mom_feed_traversal_nominal_value / 100.0 * $mom_feed_cut_value] }
                default            { }
      }
      }

      # -08-
      if {[info exists mom_feed_retract_nominal_unit]} {
      switch $mom_feed_retract_nominal_unit {
                "None"            {    }
                "mmpm"            { }
                "mmpr"            { }
                "Rapid"            { }
   "%Cut"    { set mom_feed_retract_value  [expr $mom_feed_retract_nominal_value / 100.0 * $mom_feed_cut_value] }
                default            { }
      }
      }

      # -09-
   if {[info exists mom_feed_return_nominal_unit]} {
   switch $mom_feed_return_nominal_unit {
                "None"            {    }
              "mmpm"            { }
                "mmpr"            { }
                "Rapid"            { }
"%Cut"    { set mom_feed_return_value   [expr $mom_feed_return_nominal_value / 100.0 * $mom_feed_cut_value] }
            default            { }
      }
    }

      # -10-
      if {[info exists mom_feed_departure_nominal_unit]} {
      switch $mom_feed_departure_nominal_unit {
                "None"            {    }
                "mmpm"            { }
                "mmpr"            { }
                "Rapid"            { }
     "%Cut" { set mom_feed_departure_value[expr $mom_feed_departure_nominal_value / 100.0 * $mom_feed_cut_value] }
                default            { }
      }
      }
}
 #MOM_output_literal "mom_feed_first_cut_value = $mom_feed_first_cut_value"
#-----------------------
#设置F输出格式flag,如无pui文件,则在def中修改格式
  set custom_sys_leader_F_output                      $custom_sys_leader_F
  set custom_sys_trailer_F_output                     $custom_sys_trailer_F
  set custom_template_type                           [string toupper $mom_template_type]

 if {[EQ_is_zero $mom_feed_rapid_value]  &&  [EQ_is_zero $mom_feed_approach_value]     && \
   [EQ_is_zero $mom_feed_engage_value]   &&  [EQ_is_zero $mom_feed_first_cut_value]    && \
   [EQ_is_zero $mom_feed_stepover_value]  && [EQ_is_zero $mom_feed_traversal_value]    && \
   [EQ_is_zero $mom_feed_retract_value]  &&  [EQ_is_zero $mom_feed_departure_value]    } {
  set custom_flag_feed_type_count 1
  } elseif {
([EQ_is_zero $mom_feed_rapid_value]  || [EQ_is_equal $mom_feed_cut_value $mom_feed_rapid_value])   && \ ([EQ_is_zero $mom_feed_approach_value]   || [EQ_is_equal $mom_feed_cut_value $mom_feed_approach_value])    && \
([EQ_is_zero $mom_feed_engage_value]  || [EQ_is_equal $mom_feed_cut_value $mom_feed_engage_value])        && \ ([EQ_is_zero $mom_feed_first_cut_value]    || [EQ_is_equal $mom_feed_cut_value $mom_feed_first_cut_value])    && \
 ([EQ_is_zero $mom_feed_stepover_value]    || [EQ_is_equal $mom_feed_cut_value $mom_feed_stepover_value])    && \
 ([EQ_is_zero $mom_feed_traversal_value]    || [EQ_is_equal $mom_feed_cut_value $mom_feed_traversal_value])    && \
([EQ_is_zero $mom_feed_retract_value]  || [EQ_is_equal $mom_feed_cut_value $mom_feed_retract_value])        && \
([EQ_is_zero $mom_feed_departure_value] || [EQ_is_equal $mom_feed_cut_value $mom_feed_departure_value])  } {
  set custom_flag_feed_type_count 2
  } else {
  set custom_flag_feed_type_count 0
  }
  #测试用
  global  wjc_feed_output_format  wjc_feed_single_output_format

  if {$wjc_feed_output_format != 1 } {return}
  if {$wjc_feed_single_output_format != 1} {
  if {$custom_flag_feed_type_count == 1 || $custom_flag_feed_type_count == 2} {
  return
  }
   }

  set custom_R_number    0

  set custom_blanks                 ""
  set custom_blanks_1               "    "
  set custom_blanks_2               "; "
   #-----------------------------------
  set custom_feed_rapid_value           [string trimright [string trimright [format %.3f $mom_feed_rapid_value] 0] .]
  set custom_feed_approach_value        [string trimright [string trimright [format %.3f $mom_feed_approach_value] 0] .]
  set custom_feed_engage_value          [string trimright [string trimright [format %.3f $mom_feed_engage_value] 0] .]
  set custom_feed_first_cut_value       [string trimright [string trimright [format %.3f $mom_feed_first_cut_value] 0] .]
  set custom_feed_stepover_value        [string trimright [string trimright [format %.3f $mom_feed_stepover_value] 0] .]
  set custom_feed_cut_value             [string trimright [string trimright [format %.3f $mom_feed_cut_value] 0] .]
  set custom_feed_traversal_value       [string trimright [string trimright [format %.3f $mom_feed_traversal_value] 0] .]
  set custom_feed_retract_value         [string trimright [string trimright [format %.3f $mom_feed_retract_value] 0] .]
  set custom_feed_return_value          [string trimright [string trimright [format %.3f $mom_feed_return_value] 0] .]
  set custom_feed_departure_value       [string trimright [string trimright [format %.3f $mom_feed_departure_value] 0] .]
  #-----------------------------------
  set custom_blanks_length_max            [string length $custom_feed_rapid_value]

  set custom_seqnum_length_old            [expr [string length $mom_seqnum]-18]
  set custom_blanks_length_max                 [expr $custom_seqnum_length_old+6+$custom_blanks_length_max]
#测试用
#    MOM_output_literal "mom_seqnum:$mom_seqnum"
#   MOM_output_literal "custom_seqnum_length_old:$custom_seqnum_length_old"
#  MOM_output_literal "custom_blanks_length_max:$custom_blanks_length_max"
 #-----------------------------------
 #输出R模式程序头
 #1
 if {![EQ_is_zero $mom_feed_rapid_value] && ($mom_feed_cut_value != $mom_feed_rapid_value)} {
  incr custom_R_number
  set custom_blanks_length_min            [string length $custom_feed_rapid_value]
 #PB_CMD_wjc_blank_comment $custom_blanks_length_max    $custom_blanks_length_min
  MOM_output_literal "R\[$custom_R_number\]=${custom_feed_rapid_value}${custom_blanks}${custom_blanks_2}FEED_RAPID"
  set custom_feed_rapid_text                "=R\[$custom_R_number\]"
  } else {
  set custom_feed_rapid_text                ""
  }
 #2
 if {![EQ_is_zero $mom_feed_approach_value] && ($mom_feed_cut_value != $mom_feed_approach_value)} {
  incr custom_R_number
  set custom_blanks_length_min            [string length $custom_feed_approach_value]
 #PB_CMD_wjc_blank_comment $custom_blanks_length_max    $custom_blanks_length_min
  MOM_output_literal "R\[$custom_R_number\]=${custom_feed_approach_value}${custom_blanks}${custom_blanks_2}FEED_APPROACH"
  set custom_feed_approach_text            "=R\[$custom_R_number\]"
  } else {
  set custom_feed_approach_text            ""
  }
  #3
  if {![EQ_is_zero $mom_feed_engage_value] && ($mom_feed_cut_value != $mom_feed_engage_value)} {
  incr custom_R_number
  set custom_blanks_length_min            [string length $custom_feed_engage_value]
  #PB_CMD_wjc_blank_comment $custom_blanks_length_max    $custom_blanks_length_min 
  MOM_output_literal "R\[$custom_R_number\]=${custom_feed_engage_value}${custom_blanks}${custom_blanks_2}FEED_ENGAGE"
  set custom_feed_engage_text                "=R\[$custom_R_number\]"
  } else {
  set custom_feed_engage_text                ""
  }
  #4
  if {![EQ_is_zero $mom_feed_first_cut_value] && ($mom_feed_cut_value != $mom_feed_first_cut_value)} {
  incr custom_R_number
  set custom_blanks_length_min            [string length $custom_feed_first_cut_value]
  #PB_CMD_wjc_blank_comment $custom_blanks_length_max    $custom_blanks_length_min
  MOM_output_literal "R\[$custom_R_number\]=${custom_feed_first_cut_value}${custom_blanks}${custom_blanks_2}FEED_FIRST_CUT"
  set custom_feed_first_cut_text        "=R\[$custom_R_number\]"
  } else {
  set custom_feed_first_cut_text        ""
  }
  #5
  if {![EQ_is_zero $mom_feed_stepover_value] && ($mom_feed_cut_value != $mom_feed_stepover_value)} {
  incr custom_R_number
  set custom_blanks_length_min            [string length $custom_feed_stepover_value]
  #PB_CMD_wjc_blank_comment $custom_blanks_length_max    $custom_blanks_length_min
  MOM_output_literal "R\[$custom_R_number\]=${custom_feed_stepover_value}${custom_blanks}${custom_blanks_2}FEED_STEPOVER"
  set custom_feed_stepover_text            "=R\[$custom_R_number\]"
  } else {
  set custom_feed_stepover_text            ""
  }
  #6
  if {![EQ_is_zero $mom_feed_cut_value]} {
  incr custom_R_number
  set custom_blanks_length_min            [string length $custom_feed_cut_value]
  #PB_CMD_wjc_blank_comment $custom_blanks_length_max    $custom_blanks_length_min
  MOM_output_literal "R\[$custom_R_number\]=${custom_feed_cut_value}${custom_blanks}${custom_blanks_2}FEED_CUT"
  set custom_feed_cut_text                    "=R\[$custom_R_number\]"
  } else {
  set custom_feed_cut_text                    "250."
  }
  #7
  if {![EQ_is_zero $mom_feed_traversal_value] && ($mom_feed_cut_value != $mom_feed_traversal_value)} {
  incr custom_R_number
  set custom_blanks_length_min            [string length $custom_feed_traversal_value]
  #PB_CMD_wjc_blank_comment $custom_blanks_length_max    $custom_blanks_length_min
  MOM_output_literal "R\[$custom_R_number\]=${custom_feed_traversal_value}${custom_blanks}${custom_blanks_2}FEED_TRAVERSAL"
  set custom_feed_traversal_text        "=R\[$custom_R_number\]"
  } else {
  set custom_feed_traversal_text        ""
  }
  #8
  if {![EQ_is_zero $mom_feed_retract_value] && ($mom_feed_cut_value != $mom_feed_retract_value)} {
  incr custom_R_number
  set custom_blanks_length_min            [string length $custom_feed_retract_value]
  #PB_CMD_wjc_blank_comment $custom_blanks_length_max    $custom_blanks_length_min
  MOM_output_literal "R\[$custom_R_number\]=${custom_feed_retract_value}${custom_blanks}${custom_blanks_2}FEED_RETRACT"
  set custom_feed_retract_text            "=R\[$custom_R_number\]"
  } else {
  set custom_feed_retract_text            ""
  }
  #9
  if {![EQ_is_zero $mom_feed_return_value]					

推荐阅读