Xuất G54…G59 và về X0Y0 đúng gốc phôi

Post mặc định thường cố định G54. Bài này cho post lấy số gốc phôi từ Fixture Offset trong NX (1 → G54, 2 → G55…), và thêm một lệnh chạy về X0Y0 của đúng gốc đó trước dao đầu tiên.

Kết quả

Trích file NC xuất thật, Fixture Offset = 1
G17G40G80G49G94G21
G91G28Z0
G0G90G54X0Y0
N1T7M6
G0G90G54X0Y0
G43H7Z50.M8

Tải về: code lệnh về X0Y0.

Phần 1 — G54…G59 theo Fixture Offset

01

Sửa biểu thức của từ G trong khối chạy nhanh

N/C Data Definitions 1 → BLOCK 2, chọn khối rapid_traverse 3 (và rapid_move nếu có). Chuột phải vào từ G thứ ba → Edit 4. Ở ô Expression 5 nhập:

Expression
$mom_fixture_offset_value + 53
Khối rapid_traverse, hộp WORD G với Expression mom_fixture_offset_value + 53
Fixture Offset 1 + 53 = G54, 2 → G55 … 6 → G59.
02

Đặt Fixture Offset trong NX

Trong NX CAM, mở MCS → mục Fixture Offset: 1 = G54, 2 = G55 … 6 = G59.

Fixture Offset = 0 sẽ ra G53

Với công thức + 53, giá trị 0 xuất G53 (toạ độ máy): G0G90G53X0Y0 chạy nhanh về gốc máy, không phải gốc phôi. Bước 03 dưới đây chặn lỗi này.

03

Chặn G53 khi quên đặt Fixture Offset

Custom Command → Create, tên fixture_offset_guard, dán code. Rồi mở PB_CMD_before_motion, thêm một dòng PB_CMD_fixture_offset_guard (giống cách gọi ở bài cảnh báo S = 0).

PB_CMD_fixture_offset_guard
global mom_fixture_offset_value mom_operation_name thanhcam_g53_warned
if { [info exists mom_fixture_offset_value] && [string is integer -strict $mom_fixture_offset_value] && $mom_fixture_offset_value >= 1 } { return }
set mom_fixture_offset_value 1
if { ![info exists thanhcam_g53_warned($mom_operation_name)] } {
   set thanhcam_g53_warned($mom_operation_name) 1
   MOM_display_message "Operation $mom_operation_name: Fixture Offset = 0 se ra G53. Da doi sang G54, kiem tra lai MCS." "Canh bao G53"
}

Lệnh chỉ sửa các dòng chạy nhanh trong nguyên công. Dòng về gốc máy cố định ở cuối chương trình vẫn giữ nguyên:

Cuối chương trình — không đổi
G91G28Z0
G28Y0
G0G90G53
M30

Phần 2 — về X0Y0 trước dao đầu tiên

01

Tạo lệnh first_tool_xy0

Custom Command → Create, tên first_tool_xy0, dán code. Lệnh chỉ chạy một lần mỗi chương trình và dùng cùng quy tắc + 53 ở trên.

PB_CMD_first_tool_xy0
global thanhcam_xy0_done mom_fixture_offset_value
if { [info exists thanhcam_xy0_done] } { return }
set thanhcam_xy0_done 1
if { [info exists mom_fixture_offset_value] && [string is integer -strict $mom_fixture_offset_value] && $mom_fixture_offset_value >= 1 } {
   MOM_output_literal "G0G90G[expr {$mom_fixture_offset_value + 53}]X0Y0"
} else {
   MOM_output_literal "G0G90G54X0Y0"
   MOM_output_to_listing_device "Work offset unknown at program start; used G54 for the first X0Y0 move"
}
02

Đặt sau G91G28Z0. trong Auto Tool Change

Kéo PB_CMD_first_tool_xy0 vào Auto Tool Change, ngay dưới khối G91G28Z0. 1: trục Z lên an toàn rồi mới chạy XY.

Khối PB_CMD_first_tool_xy0 nằm dưới G91G28Z0. trong Auto Tool Change
1 vị trí PB_CMD_first_tool_xy0.

Bài liên quan

  1. Bỏ M1 ở lần thay dao đầu tiên
  2. Thêm dao chờ sau lệnh thay dao