The problem is you don't have a subprogram for when the barfeeder sees the end of the bar. This is what our LNS QUICK LOAD barfeed on a Nakamura TW-20 uses.
/M98 P8000
Here is how I program ours. (M191 is a subroutine.)
T #20= FACING TOOL
X #24= X-AXIS
M #13= MAX. RPM
S #19= SFM
F #9= FEEDRATE
T0101 BARSTOP
T0202 80 DEG. PROFILE TOOL CNMG-432
*
:9018 (BARSTOP)
N100M191
/M98P8000
T0101M5
X0Z.5M9
Z.2
M11
M17
G1G98Z.025F50.
G4U3.
M10
G4U1.
G0G28W0
M99
:8000 (NEW BAR)
G0G28W0M9 (BARSTOP)
T0101M5
X0
M11
M58 this is the code used by the barfeed
Z-.07
M58
G4U2.
M10
G4U1.
G0G28W0S1000M3
M1
T#20M8 (FACE)
S[3.82*#19/#24]M3
G99X#24Z.5
G50S#13
G96S#19
Z-.1
G1X.3F#9
X-.065F.004
G28G97W0S1000
M99
%
And it is called by
G65P9018X1.05F.01S900M4000T202
for 1.000 material, although I am considering adding the .05 in the subprogram, and using the stock size only in the G65 call. Problem is I'd have a ton of programs to modify.
These are my programs for the SMW SPACE SAVER 2003 on our LYNX lathes. M91 and M92 are subroutines.
T #20= FACING TOOL
X #24= X-AXIS
M #13= MAX. RPM
S #19= SFM
F #9= FEEDRATE
T0101 BARSTOP
T0202 80 DEG. PROFILE TOOL
*
:9018 (BARSTOP PROGRAM)
M91 (BARSTOP OLD BAR)
/2M98P8000
T0101M9
X0Z.03M5
M69
M51 this is the code used by the barfeed
M68
G4U.1
M92
M99
:8000 (END OF BAR)
IF[#20LT101]GOTO70
M91 (BARSTOP NEW BAR)
T0101M5
M69
M51
X0Z-.07M9
G4U4.
M51
M68
W.5S1000M3
M91
M1
M91 (FACE OFF BAR END)
T#20S[3.82*#19/#24]M63
X#24Z-.1
G50S#13
G96S#19
G1X.2F#9
X-.065F.004
G0G97W.5S1500
M91
GOTO71
N70#3000=7 (NO T-CODE)
N71M99
%
I dress the new bar in hopes of not losing the first part.
Then the new bar gets re-stopped. It is called in the same manner as for the Nakamura. I try to keep everything the same for all the lathes as much as I can.
I don't quite understand exactly how the 2 works in /2M98P8000, but it is how the manufacturer sets up the barfeed.