@DECLARE
//#INT #prognum
#INT #preselect
//#DEC #chpBrk
#DEC #rindex
#DEC #fakec
#STR #toolname
#DEC #checka//****************JOE  inserted for G68 redundant check
#DEC #checkc//****************JOE  inserted for G68 redundant check
#INT #mcode
// along with the M26 code.  It only outputs the M25 once per cycle.
#STR #pecker
@START
%
#EVAL(#U10=0)
#EVAL(#U1=0)
#IF(#U10=1)<  ***** This is the Start of the Program Section  *****  >
#EVAL(#toolname=JOS(st_desc))
O0000       (  JOB# 99-21022  DATE: #DATE  )
G00 G53 G49 G20 G64 G40 G80 G90 G94 G17 Z0
T#TOOL 
#IF(#NTOOL=2)<#EVAL(#preselect=2)>
#IF(#NTOOL=3)<#EVAL(#preselect=3)>
#IF(#NTOOL=4)<#EVAL(#preselect=4)>
#IF(#NTOOL=5)<#EVAL(#preselect=5)>
#IF(#NTOOL=6)<#EVAL(#preselect=6)>
#IF(#NTOOL=7)<#EVAL(#preselect=7)>
#IF(#NTOOL=8)<#EVAL(#preselect=8)>
#IF(#NTOOL=9)<#EVAL(#preselect=9)>
M00
M06
#IF(#TOOL=2)<( T#TOOL )
( #toolname )>
#IF(#TOOL=3)<( T#TOOL )
( #toolname )>
#IF(#TOOL>3,AND #TOOL<=10)<( T#TOOL )
( #toolname )>
#IF(#TOOL=11)<( T64 )
( #toolname )>
#IF(#TOOL>11,AND #TOOL<=35)<( T#TOOL )
( #toolname )>
T#preselect//NTOOL
G00 C90 B0
G43.1 Z10.
S#SPEED
#SPNDL
G54 X#XPOS Y#YPOS
#EVAL(#rindex=-(#INDXA))
#EVAL(#fakec=(#INDXB+90))
G90 G00 B#INDXA  C#fakec
#IF(#INDXA<0)<Y-4.0>
#IF(#INDXA>0)<Y12.0>
G68 X#XFO Y#YFO Z#ZFO I1 J0 K0 R#FMT(#rindex,D3.4)//(REFERENC FROM WORLD ORIGIN)
Z4.0
#EVAL(#checka=1)//****************JOE  inserted for G68 redundant check
#EVAL(#checkc=1)//****************JOE  inserted for G68 redundant check
#RESET(#XPOS)
#RESET(#YPOS)
#IF(#WKSCHG=1)<#EVAL(#INO=1)>
#IF(#WKSCHG=1)<#CALL(WKSYS)>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@WKSYS
#IF(#U10=1)<  ***** This is the Work plane Change Section  *****  >
#IF(#checka=1,#AND#checkc=1)<#EXIT>
#IF(#WKPLN)<#EVAL(#U1=#WKPLN)>#ELSE<#EVAL(#U1=1)>
///***************************************************************************
( PULL UP AND ADJUST THE HEAD TIP AND RESET THE G68 )
G80 M09
G00 Z10.
G53 Z0
G90 G53 G49 Z0
G69
G90 G00 C90 B0
G00 G53 G49 G20 G64 G40 G80 G90 G94 G17 Z0
G54 X#XPOS Y#YPOS
G43.1 Z10.
G53 Z0
#RESET(#FXD)
#EVAL(#rindex=-(#INDXA))
#EVAL(#fakec=(#INDXB+90))
G90 G00 B#INDXA  C#fakec
#IF(#INDXA<0)<Y-4.0>
#IF(#INDXA>0)<Y12.0>
G68 X#XFO Y#YFO Z#ZFO I1 J0 K0 R#FMT(#rindex,D3.4)
Z4.0
#EVAL(#checka=0)//****************JOE  inserted for G68 redundant check
#EVAL(#checkc=0)//****************JOE  inserted for G68 redundant check
#EVAL(#U9=0)
#EVAL(#mcode=1)
#RESET(#pecker)
#RESET(#XPOS)
#RESET(#YPOS)
#RESET(#INDXA)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// coolant table accessed by #COOLNT
@COOLNT
0,M09
1,M08
2,M7
3,M07
@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@TOOLCHG
#IF(#U10=1)<  ***** This is the Tool Change Section  *****  >
#EVAL(#U1=0)
#EVAL(#toolname=JOS(st_desc))
#EVAL(#mcode=1)
#EVAL(#S19=1)
//  *********#toolname****************
<#FXD >M09

G00 Z4.
G53 Z0
G90 G53 G49 Z0
G69
G90 G00 C90 B0
G00 G53 G49 G20 G64 G40 G80 G90 G94 G17 Z0
M06
#IF(#TOOL=2)<( T#TOOL )
( #toolname )>
#IF(#TOOL=3)<( T#TOOL )
( #toolname )>
#IF(#TOOL>3,AND #TOOL<=10)<( T#TOOL )
( #toolname )>
#IF(#TOOL=11)<( T64 )
( #toolname )>
#IF(#TOOL>11,AND #TOOL<=35)<( T#TOOL )
( #toolname )>
#IF(#TOOL=35)<( T15 )
( #toolname )>
T#preselect//NTOOL
G43.1 Z10.
S#SPEED
#SPNDL
G53 Z0
//X80.
#EVAL(#rindex=-(#INDXA))
#EVAL(#fakec=(#INDXB+90))
G90 G00 B#INDXA  C#fakec
#IF(#INDXA<0)<Y-4.0>
#IF(#INDXA>0)<Y12.0>
G68 X#XFO Y#YFO Z#ZFO I1 J0 K0 R#FMT(#rindex,D3.4)//(REFERENC FROM WORLD ORIGIN)
Z4.0
#EVAL(#checka=1)//****************JOE  inserted for G68 redundant check
#EVAL(#checkc=1)//****************JOE  inserted for G68 redundant check
#RESET(#XPOS)
#RESET(#YPOS)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// coolant table accessed by #COOLNT
@COOLNT
0,M09
1,M08
2,M7
3,M07
@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#RESET(#pecker)
#RESET(#XPOS)
#RESET(#YPOS)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@END
#IF(#U10=1)<  ***** This is the End Section  *****  >
<#FXD >M09
G00 Z4.
G53 Z0
G90 G53 G49 Z0
G69
G90 G00 C90 B0
M06
(#CYTIME)
M30
%
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@STPROF
#IF(#U10=1)<  ***** This is the Start Profile Section  *****  >
<#ABSI ><#FXD ><#MOV ><X#XPOS ><Y#YPOS >
#EVAL(#mcode=1)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ENDPROF
#IF(#U10=1)<  ***** This is the End Profile Section  *****  >
<#MOV><  Z#ZPOS >
<#DCOMP >
#EVAL(#mcode=1)
#RESET(#pecker)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@RAP
#IF(#U10=1)<  ***** This is the Rapid Traverse Section  *****  >
<#ABSI ><#FXD ><#MOV ><Z#ZPOS >
<#ABSI ><#FXD ><#MOV ><X#XPOS ><Y#YPOS >
#EVAL(#mcode=1)
#RESET(#pecker)
#RESET(#FXD)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@LINE
#IF(#U10=1)< COMPENSATED LINE SECTION>
#IF(#U10=1)<                                                 M00 ( SET CUTTER COMP. D#DOFF TO HALF THE DIA. OF THE CUTTER )>
#IF(#DCOMP=0)<#CALL(NOCOMP)>
#IF(#DCOMP=0)<#EXIT>
<#MOV><#DCOMP D#DOFF ><X#XPOS ><Y#YPOS ><Z#ZPOS ><F#FEED>
#EVAL(#S19=0)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@NOCOMP
#IF(#U10=1)< NON-COMPENSATED LINE SECTION>
<#MOV><#DCOMP ><X#XPOS ><Y#YPOS ><Z#ZPOS ><F#FEED>
#EVAL(#S19=0)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ARC
#IF(#U10=1)<  ***** This is the ARC Section  *****  >
<#PLANE ><#MOV ><X#XPOS ><Y#YPOS >I#XCTR J#YCTR <F#FEED >
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@XZARC// You could probably delete this whole section
#IF(#U10=1)<  ***** This is the XZARC Section  *****  >
<#PLANE ><#MOV ><X#XPOS ><Z#ZPOS >I#XCTR K#ZCTR <F#FEED >
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@YZARC// You could probably delete this whole section
#IF(#U10=1)<  ***** This is the YZARC Section  *****  >
<#PLANE ><#MOV ><Y#YPOS ><Z#ZPOS >J#YCTR K#ZCTR <F#FEED >
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@HELIX
#IF(#U10=1)<  ***** This is the HELIX Section  *****  >
<#PLANE >#MOV <X#XPOS ><Y#YPOS >Z#ZPOS I#XCTR J#YCTR <F#FEED >
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@XZHELIX// You could probably delete this whole section
#IF(#U10=1)<  ***** This is the XZHELIX Section  *****  >
<#PLANE >#MOV <X#XPOS >Y#YPOS <Z#ZPOS >I#XCTR K#ZCTR <F#FEED >
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@YZHELIX// You could probably delete this whole section
#IF(#U10=1)<  ***** This is theYZHELIX Section  *****  >
<#PLANE >#MOV X#XPOS <Y#YPOS ><Z#ZPOS >J#YCTR K#ZCTR <F#FEED >
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// I ADDED THIS TO COOLANT ON AT THE START OF THE TOOL
@ZCHKMV
#IF(#U10=1)<  ***** This is the Z Check Move Section  *****  >
#IF(#U1=1)<#CALL(COOL)>
#IF(#U1=1)<#EXIT>
<#FXD ><<#MOV >Z#ZPOS M08>
#EVAL(#U1=1)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@COOL
#IF(#U10=1)<  ***** This is the Cool Section  *****  >
<#FXD ><<#MOV >Z#ZPOS >
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ZDPTHMV
#IF(#U10=1)<  ***** This is the Z Depth Move Section  *****  >
<<#MOV >Z#ZPOS <F#FEED >>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@OP_DRL
#IF(#U10=1)<  ***** This is the new DRILL Section  *****  >
#EVAL(#checka=0)//****************JOE  inserted for G68 redundant check
#EVAL(#checkc=0)//****************JOE  inserted for G68 redundant check
#IF(#CYCLE=0)<
<#ABSI ><#RTNLVL ><#CYCLE ><X#XPOS ><Y#YPOS ><Z#ZDPTH R#ZCHK ><F#FEED #COOLNT >>
#IF(#CYCLE=1)<
<#ABSI ><#RTNLVL ><#CYCLE ><X#XPOS ><Y#YPOS ><Z#ZDPTH R#ZCHK ><F#FEED #COOLNT >>
#IF(#CYCLE=2)<
<#ABSI ><#RTNLVL ><#CYCLE ><X#XPOS ><Y#YPOS ><Z#ZDPTH R#ZCHK ><F#FEED #COOLNT >>
#IF(#CYCLE=3)<
//#IF(#mcode=1)<M25>
#IF(#mcode=1)
#IF(#mcode=1)
<#ABSI ><#RTNLVL ><#CYCLE ><X#XPOS ><Y#YPOS ><Z#ZDPTH R#ZCHK ><F#FEED #COOLNT >
#EVAL(#mcode=0)>
#RESET(#FXD)
@@CYCLE
0,G83
1,G73
2,G82
3,G81
@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@FXD1
// This section is no longer being processed.  OP_DRL overrides it.
#IF(#U10=1)<  ***** This is the FXD1 Section  *****  >
#EVAL(#checka=0)//****************JOE  inserted for G68 redundant check
#EVAL(#checkc=0)//****************JOE  inserted for G68 redundant check
#IF(#U1=1)<#CALL(DRILL1)>
#IF(#U1=1)<#EXIT>
//*****TOOL #TOOL*****
#IF(#TOOL=3,#OR#TOOL=4,#OR#TOOL=5,#OR#TOOL=8,#OR#TOOL=10,#OR#TOOL=22,#OR#TOOL=24,#OR#TOOL=42,#OR#TOOL=43,#OR#TOOL=45,#OR#TOOL=46,#OR#TOOL=47,#OR#TOOL=50,#OR#TOOL=51,#OR#TOOL=52,#OR#TOOL=53,#OR#TOOL=54)
#IF(#TOOL=3,#OR#TOOL=4,#OR#TOOL=5,#OR#TOOL=8,#OR#TOOL=10,#OR#TOOL=22,#OR#TOOL=24,#OR#TOOL=42,#OR#TOOL=43,#OR#TOOL=45,#OR#TOOL=46,#OR#TOOL=47,#OR#TOOL=50,#OR#TOOL=51,#OR#TOOL=52,#OR#TOOL=53,#OR#TOOL=54)
<<#ABSI ><#RTNLVL ><#FXD >X#XPOS Y#YPOS< Z#ZDPTH R#ZCHK>< F#FEED >>
<<#ABSI ><#RTNLVL ><#FXD >X#XPOS Y#YPOS< Z#ZDPTH R#ZCHK>< F#FEED M07 >>
#IF(#TOOL<>3,#AND#TOOL<>4,#AND#TOOL<>5,#AND#TOOL<>8,#AND#TOOL<>10,#AND#TOOL<>22,#AND#TOOL<>24,#AND#TOOL<>42,#AND#TOOL<>43,#AND#TOOL<>45,#AND#TOOL<>46,#AND#TOOL<>47,#AND#TOOL<>50,#AND#TOOL<>51,#AND#TOOL<>52,#AND#TOOL<>53,#AND#TOOL<>54)
<<#ABSI ><#RTNLVL ><#FXD >X#XPOS Y#YPOS< Z#ZDPTH R#ZCHK>< F#FEED M08 >>
#EVAL(#U1=1)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@DRILL1
#IF(#U10=1)<  ***** This is the Drill1 Section  *****  >
#EVAL(#checka=0)//****************JOE  inserted for G68 redundant check
#EVAL(#checkc=0)//****************JOE  inserted for G68 redundant check
<#ABSI ><#RTNLVL ><#FXD ><X#XPOS ><Y#YPOS >< Z#ZDPTH R#ZCHK>< F#FEED >
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@FXD2
#IF(#U10=1)<  ***** This is the FXD2 Section  *****  >
#IF(#U1=1)<#CALL(DRILL2)>
#IF(#U1=1)<#EXIT>
#EVAL(#checka=0)//****************JOE  inserted for G68 redundant check
#EVAL(#checkc=0)//****************JOE  inserted for G68 redundant check
<#ABSI ><#RTNLVL ><#FXD >X#XPOS Y#YPOS< Z#ZDPTH R#ZCHK P#DWELL>< F#FEED M08 >
#EVAL(#U1=1)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@DRILL2
#IF(#U10=1)<  ***** This is the Drill2 Section  *****  >
#EVAL(#checka=0)//****************JOE  inserted for G68 redundant check
#EVAL(#checkc=0)//****************JOE  inserted for G68 redundant check
<#ABSI ><#RTNLVL ><#FXD ><X#XPOS ><Y#YPOS >< Z#ZDPTH R#ZCHK P#DWELL>< F#FEED >
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@FXD3
#IF(#U10=1)<  ***** This is the FXD3 Section  *****  >
#IF(#U1=1)<#CALL(DRILL3)>
#IF(#U1=1)<#EXIT>
#EVAL(#checka=0)//****************JOE  inserted for G68 redundant check
#EVAL(#checkc=0)//****************JOE  inserted for G68 redundant check
#EVAL (#ZCHK=#ZCHK+.1)
<#ABSI ><#RTNLVL ><#FXD >X#XPOS Y#YPOS< Z#ZDPTH R#ZCHK>< F#FEED M08 >
#EVAL(#U1=1)
#EVAL(#checka=0)//****************JOE  inserted for G68 redundant check
#EVAL(#checkc=0)//****************JOE  inserted for G68 redundant check
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@DRILL3
#IF(#U10=1)<  ***** This is the Drill3 Section  *****  >
#EVAL(#checka=0)//****************JOE  inserted for G68 redundant check
#EVAL(#checkc=0)//****************JOE  inserted for G68 redundant check
#EVAL (#ZCHK=#ZCHK+.1)
<#ABSI ><#RTNLVL ><#FXD ><X#XPOS ><Y#YPOS >< Z#ZDPTH R#ZCHK>< F#FEED M08 >
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@FXD4
#IF(#U10=1)<  ***** This is the FXD4 Section  *****  >
#IF(#U1=1)<#CALL(DRILL4)>
#IF(#U1=1)<#EXIT>
<#ABSI ><#RTNLVL ><#FXD >X#XPOS Y#YPOS< Z#ZDPTH R#ZCHK>< F#FEED >
#EVAL(#U1=1)
#EVAL(#checka=0)//****************JOE  inserted for G68 redundant check
#EVAL(#checkc=0)//****************JOE  inserted for G68 redundant check
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@DRILL4
#IF(#U10=1)<  ***** This is the Drill4 Section  *****  >
#EVAL(#checka=0)//****************JOE  inserted for G68 redundant check
#EVAL(#checkc=0)//****************JOE  inserted for G68 redundant check
<#ABSI ><#RTNLVL ><#FXD ><X#XPOS ><Y#YPOS >< Z#ZDPTH R#ZCHK>< F#FEED M08>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  Brock... if the code is output just the opposite of what you want,
//  change the greater than/less than signs in the logic below
@OP_PDRL
#IF(#U10=1)<  ***** This is the  new Peck Drilling Section  *****  >
#IF(#TOOL=7)<#EVAL(#pecker=G73)>
#IF(#TOOL=7)<<#ABSI ><#RTNLVL ><#pecker>< X#XPOS>< Y#YPOS>< Z#ZDPTH R#ZCHK Q#PECK>< F#FEED M08 >>
// This was added to add a G80 for dp.
#RESET(#FXD)
#IF(#TOOL=7)<#EXIT>
#IF(#ZDPTH>=-1.875)<#EVAL(#pecker=G73)>
#IF(#ZDPTH<=-1.8751)<#EVAL(#pecker=G83)>
<#ABSI ><#RTNLVL ><#pecker ><X#XPOS ><Y#YPOS ><Z#ZDPTH R#ZCHK Q#PECK >< F#FEED #COOLNT>
#RESET(#FXD)
#EVAL(#checka=0)//****************JOE  inserted for G68 redundant check
#EVAL(#checkc=0)//****************JOE  inserted for G68 redundant check
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ADD TO EXCLUDE DRILLS THAT DRILL JB SO THEY ALWAYS G73 A HOLE
//  This section is no longer being processed by the system.  OP_PDRL overrides it.
@FXD5
#IF(#U10=1)<  ***** This is the FXD5 Section  *****  >
#IF(#U1=1)<#CALL(DRILL5)>
#IF(#U1=1)<#EXIT>
#EVAL(#checka=0)//****************JOE  inserted for G68 redundant check
#EVAL(#checkc=0)//****************JOE  inserted for G68 redundant check
#EVAL(#U1=1)
#UPDATE(#FXD)// 
#EVAL(#S1=G73)
#IF(#TOOL=7)<<#ABSI ><#RTNLVL >#S1 X#XPOS Y#YPOS< Z#ZDPTH R#ZCHK Q#PECK>< F#FEED M08 >>
#IF(#TOOL<>7,#AND#ZDPTH>=-1.875)<<#ABSI ><#RTNLVL >#S1 X#XPOS Y#YPOS< Z#ZDPTH R#ZCHK Q#PECK>< F#FEED M08 >>
#IF(#ZDPTH>=-1.875,#OR#TOOL=7)<#EXIT>
#EVAL(#S1=G83)
#IF(#ZDPTH<-1.875)<<#ABSI ><#RTNLVL >#S1 X#XPOS Y#YPOS< Z#ZDPTH R#ZCHK Q#PECK>< F#FEED M08 >>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@DRILL5
#IF(#U10=1)<  ***** This is the Drill5 Section  *****  >
#EVAL(#checka=0)//****************JOE  inserted for G68 redundant check
#EVAL(#checkc=0)//****************JOE  inserted for G68 redundant check
#EVAL(#S1=G73)
#IF(#ZDPTH>=-1.875)<<#ABSI ><#RTNLVL ><#S1 ><X#XPOS ><Y#YPOS >< Z#ZDPTH R#ZCHK Q#PECK>< F#FEED>>
#EVAL(#S1=G73)
#IF(#TOOL=7)<<#ABSI ><#RTNLVL ><#S1 ><X#XPOS ><Y#YPOS >< Z#ZDPTH R#ZCHK Q#PECK>< F#FEED>>
#EVAL(#S1=G83)
#IF(#TOOL<>7,#AND#ZDPTH<-1.875)<<#ABSI ><#RTNLVL ><#S1 ><X#XPOS ><Y#YPOS >< Z#ZDPTH R#ZCHK Q#PECK>< F#FEED>>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@DWELL
#IF(#U10=1)<  ***** This is the Dwell Section  *****  >
G04 P#DWELL#EVAL(#TIME=#DWELL/60)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@SUBDEF
#IF(#U10=1)<  ***** This is the Subroutine Define Section  *****  >
%
O#SNAME
( SUB ,  NOTE USED BY  MAIN PROGRAM  #FILE )
<#ABSI >
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ENDDEF
#IF(#U10=1)<  ***** This is the Subroutine end Section  *****  >
//G9#U1 G00 Z0.1
G90 G00 Z0.1
M99
%
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@GOSUB
#IF(#U10=1)<  ***** This is the Gosub Section  *****  >
M98 P#SNAME#IF(#SREPT<>0)< L#SREPT>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@FXDDEF
#IF(#U10=1)<  ***** This is the FXD define Section  *****  >
<X#XPOS ><Y#YPOS >
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@
