The machine control requires the D word for the cutcom register on the same line as the G41/G42 every time cutter compensation is turned on. Being modal, the D word is only being output for the first finish pass. The remaining passes get the G41 code, but no D word is included.
Solution
This will require a bit of logic to handle. If you simply make the D word non-modal, you get it on every linear move event line. The post has to know when cutcom is being turned on and off, and then output the D word accordingly. The general modality is not fine-tuned enough to do this.
We will take a basic route of comparing the previous value of cutcom with the current one and decide if the D word needs to be forced out.
To start with, we need to define our test variable and give it a default value. Add this small custom command in Start of Program, so the new variable is in place and recognized right away:
#=============================================================
proc PB_CMD_init_cutcom_status_flag { } {
#=============================================================
global prev_cutcom_status
set prev_cutcom_status UNDEFINED
}
Then inside the linear move event, we can do our testing. There are two custom commands, one at the beginning of this event and one at the end.
The first command right at the beginning of the event is what does the work. This command checks the current cutcom status against the previous one from the last linear move. If the last linear move event had cutcom OFF, and this current linear move has cutcom of either LEFT or RIGHT, it forces out the D
word:
#=============================================================
proc PB_CMD_check_cutcom_value { } {
#=============================================================
global prev_cutcom_status
global mom_cutcom_status
if { $prev_cutcom_status == "OFF" } {
if { $mom_cutcom_status == "LEFT" || $mom_cutcom_status == "RIGHT" } {
MOM_force once D
}
}
}
The last thing in the linear move event is our second custom command. This just records the current cutcom status in the prev_cutcom_status variable, as a running record of where the post is at so we can test against this in the future:
#=============================================================
proc PB_CMD_record_prev_cutcom_value { } {
#=============================================================
global mom_cutcom_status
global prev_cutcom_status
set prev_cutcom_status $mom_cutcom_status
}
The post will now put the D word out on every line where cutter compensation is being turned on:
%
N0010 G40 G17 G90 G70
N0020 G91 G28 Z0.0
N0030 T01 M06
N0040 G00 G90 X1.725 Y0.0 S0 M03
N0050 G43 Z1.5 H01
N0060 Z.9
N0070 G01 Z.8 F9.8 M08
N0080 G41 X1.225 D01 <<< here
N0090 G17 G02 I-1.225 J0.0
N0100 G40
N0110 G01 X1.725
N0120 Z.9
N0130 G00 Z1.5
N0140 X1.925
N0150 Z.7
N0160 G01 Z.6
N0170 G41 X1.425 D01 <<< here
N0180 G02 I-1.425 J0.0
N0190 G40
N0200 G01 X1.925
N0210 Z.7
N0220 G00 Z1.5
N0230 X2.
N0240 Z.5
N0250 G01 Z.4
N0260 G41 X1.5 D01 <<< here
N0270 G02 I-1.5 J0.0
N0280 G40
N0290 G01 X2.
N0300 Z.5
N0310 G00 Z1.5
N0320 Z.3
N0330 G01 Z.2
N0340 G41 X1.5 D01 <<< here
N0350 G02 I-1.5 J0.0
N0360 G40
N0370 G01 X2.
N0380 Z.3
N0390 G00 Z1.5
N0400 Z.1
N0410 G01 Z0.0
N0420 G41 X1.5 D01 <<< here
N0430 G02 I-1.5 J0.0
N0440 G40
N0450 G01 X2.
N0460 Z.1
N0470 G00 Z1.5
N0480 M02
%
Note that this is sample code. Any use of this logic in a production post should be thoroughly tested, validated, and adjusted as required to get consistent, safe output for your control.
Notes