mastrcam 5轴后处理

# Post Name : MPGEN5X
# Product : MILL
# Machine Name : GENERIC FANUC
# Control Name : GENERIC FANUC
# Description : GENERIC FANUC 5 AXIS MILL POST
# Associated Post : NONE
# Mill/Turn : NO
# 4-axis/Axis subs. : YES
# 5-axis : YES
# Subprograms : NO
# Executable : MP V9.00
#
# WARNING: THIS POST IS GENERIC AND IS INTENDED FOR MODIFICATION TO
# THE MACHINE TOOL REQUIREMENTS AND PERSONAL PREFERENCE.
#
# --------------------------------------------------------------------------
# Revision log:
# --------------------------------------------------------------------------
# Programmers Note:
# CNC 12/20/01 - Initial post setup
#
# --------------------------------------------------------------------------
# Features:
# --------------------------------------------------------------------------
# This post supports Generic 5 axis milling.
# It is designed to support the features of Mastercam Mill V9.0
#
# Following Misc. Integers are used:
#
# mi2 - Absolute or Incremental positioning at top level
# 0 = absolute
# 1 = incremental
#
# mi3 - Select G28 or G30 reference point return.
# 0 = G28, 1 = G30
#
# mi4 - Start initial primary rotary axis bias
# +/-999 represents start as close to limit as possible
# Integer represents number of 180 degree shifts for non-nutating
# machine or 360 degree shifts for nutating machine
# -999 = Low, 0 = Default, 999 = Hi
#
# mi5 - Start initial secondary rotary axis bias
# +/-999 represents start as close to limit as possible
# Integer represents number of 360 degree shifts
# -999 = Low, 0 = Default, 999 = Hi
#
# mi6 - Add work shift position for rotation center programming
# 0 = Output relative to work origin (toolplane)
# 1 = Output relative to WCS origin (axis shifts)
#
# mi7 - Enable retract to and from linear limits. Disable for
# internal work to prevent part collisions.
# 0 = Disable, 1 = Enable
#
# mi8 - Safe retract/approach at toolchange.
# The tool retracts/approachs to limits from last path to current
# path or after/before a toolchange
# (limits must be enabled, see 'use_stck_typ')
# 0 = Disable all toolchange retract/approach
# 1 = Enable null toolchange retract/approach only
# 2 = Enable toolchange retract/approach only
# 3 = Enable both toolchange retract/approach
#
# mi9 - Nutating bias calculation.
# 0 = Calculate angle bias to original vector
# 1 = Bias to positive
# 2 = Bias to negative
#
# mr1 - Retract/approach clearance distance at tool reposition
#
# mr2 - Right angle head toolpath conversion (not with nutating machine type).
# Right angle rotates secondary axis by degrees
# The head may only be rotated perpendicular to the secondary axis
# 0 = Off, Ente

r angle for amount of head rotation (RA = +/- 90)
#
# mr3 - Mill Plus G74 toolchange X axis home position
#
# mr4 - Mill Plus G74 toolchange Y axis home position
#
# mr5 - Mill Plus G74 toolchange Z axis home position
#
#Canned text:
# Entering cantext on a contour point from within Mastercam allows the
# following functions to enable/disable.
# Cantext value:
# 1 = Stop = output the "M00" stop code
# 2 = Ostop = output the "M01" optional stop code
# 3 = Bld on = turn on block delete codes in NC lines
# 4 = bLd off = turn off block delete codes in NC lines
#
#Layout:
# The term "Reference View" refers to the coordinate system associated
# with the Top view (Alt-F9, the upper gnomon of the three displayed).
#
#3 Axis Rotary (Polar)
# Polar positioning is offered in Mastercam 3 axis toolpaths through the
# rotary axis options dialog.
#
#Axis Substitution:
# Use the Rotary axis substitution by drawing the geometry flattened
# from the cylinder.
#
#Canned Cycle Drilling with Mill Plus:
# The drilling cycle for the Mill Plus requires that a position is defined
# where the part surface is expected. This information must be passed to
# the post by creating drill cycles in the following manner:
# The difference of the top of stock location and the reference hieght is
# taken from the drill cycle definition (Gcode 81) and applied to repeat
# drill positions.
#
#Toolchange retracts:
# Mi8 is used to control retracts at tool changes and null toolchanges.
# Mi8 for tool changes applies to the approach to the part to the retract
# from the part at the next toolchange (unless changed in a null tool
# change). Null toolchange control at a null toolchange uses the current
# setting and previous setting of mi8. Through a null toolchange, the
# setting of mi8 at the retract applies to the approach.
#
#Additional Notes:
# 1) G54 calls are generated where the work offset entry (workofs) are
# 0 = G54, 1 = G55, etc. This post only uses work offsets.
# 2) Metric is applied from the NCI met_tool variable.
# 3) Incremental mode calculates motion from home position at toolchanges.
# The home position is used to define the last position of the tool
# for all toolchanges.
# 4) The variable 'absinc' is pre-defined, set mi2 (Misc. Integer) for
# the absolute/incremental program output.
# 5) Always avoid machining to the center of rotation with rotary axis!
# 6) Set the NCI precision to 7 places precision minimum in Mastercam. Set the
# 'Tool vecter length' in 5 axis tool paths as 1 unit minimum, longer is better
# to avoid rounding problems (output precision deviations).
# 7) The tool length is taken from the overall length entered with the tool
# definition in Mastercam.
#
#Axis Offsetting:
# This post is designed to support axis offset and zero shifts to handle
# cases where 1) the primary and secondary axis do not intersect and
# 2) where the program zero poi

nt is not set at the primary and secondary
# axis intersection. Always select the WCS origin to be the zero point
# relative to the machine model when creating toolpaths in Mastercam.
# The zero point should be selected as the primary and secondary
# axis intersections whenever possible.
# When mi6 is off, the assumption is made that the zero position is
# set in the control at a datum. This is disabled in all cases for
# 5 axis toolpaths (including polar and axis substitution).
# The offsets are set relative to the machine base matrix (matb1-matb9).
# The machine zero point must be on the primary or secondary axis and
# the shift (saxisx, saxisy, saxisz) describes where the rotation is
# relative to the zero point.
#Table/Table configuration:
# All 3 axis offsets are supported.
#
#Table/Head configuration (only primary table/secondary head):
# Axis offsets are supported on primary axis.
#
#Head/Head configuration:
# All 3 axis offsets are supported for non-nutating machines.
# Only the primary to secondary axis offset is supported for nutating machines.
#
#Subprograms:
# Note: Subprograms are not enabled.
#
# --------------------------------------------------------------------------
#Constants
# --------------------------------------------------------------------------
m_one : -1 #Define constant
zero : 0 #Define constant
one : 1 #Define constant
two : 2 #Define constant
three : 3 #Define constant
four : 4 #Define constant
five : 5 #Define constant
six : 6 #Define constant
arc45 : 45 #Define constant
arc90 : 90 #Define constant
arc180 : 180 #Define constant
arc360 : 360 #Define constant
c9d : 999 #Define constant
c9k : 9999 #Define constant

# --------------------------------------------------------------------------
# Debugging and Factory Set Program Switches
# --------------------------------------------------------------------------
fastmode : 1 #Posting speed optimizition
bug1 : 2 #0=No display, 1=Generic list box, 2=Editor
bug2 : 30 #Append postline labels, non-zero is column position?
bug3 : 0 #Append whatline no. to each NC line?
bug4 : 1 #Append NCI line no. to each NC line?
whatno : yes #Do not perform whatline branches? (leave as yes)

#MP executable process controls
get_1004 : 1 #Find gcode 1004 with getnextop?
rpd_typ_v7 : 0 #Use Version 7 style contour flags/processing?
strtool_v7 : 2 #Use Version 7+ toolname?
tlchng_aft : 2 #Delay call to toolchange until move line
cant_tlchng : 1 #Ignore cantext entry on move with tlchng_aft
newglobal : 1 #Error checking for global variables
getnextop : 1 #Build the next variable table
nobrk : yes #Omit breakup of x, y & z rapid moves
no_updprv : yes #Post exclusively maintains previ

ous

#Tolerances
ltol : .002 #Length tolerance for arccheck = 1
vtol : .0001 #System tolerance
ltol_m : .05 #Length tolerance for arccheck = 1, metric
vtol_m : .0025 #System tolerance, metric

#Arc output settings
breakarcs : 0 #Break arcs, 0 = no, 1 = quadrants, 2 = 180 arcs

arcoutput : 0 #0 = IJK, 1 = R no sign, 2 = R signed neg. over 180
arctype : 2 #Arc center 1=abs, 2=St-Ctr, 3=Ctr-St, 4=unsigned inc.
do_full_arc : 1 #Allow full circle output? 0=no, 1=yes
helix_arc : 1 #Support helix arc output, 0=no, 1=all planes, 2=XY plane only
arccheck : 1 #Check for small arcs, convert to linear
atol : .01 #Angularity tolerance for arccheck = 2

#Program control
stagetool : 0 #0 = Do not pre-stage tools, 1 = Stage tools
progname : 1 #Use uppercase for program name
sub_level : -2 #Enable automatic subprogram support (do not enable)
sub_seq_typ : 1 #Enable subprogram sequence number reset at sub call

#Work offsets
workofs : -1 #Initialize work offset
force_wcs : yes #Force WCS output at every toolchange?
use_frst_wcs: yes #Use only the first WCS read and ignore all others in NCI

#Spindle control settings
use_gear : 0 #Output gear selection code, 0=no, 1=yes
max_speed : 10000 #Maximum spindle speed
min_speed : 50 #Minimum spindle speed

#Feed control settings
#Mill Plus uses A40, B40, C40 instead of inverse
convert_rpd : 0 #Convert rapid to rapid feed
use_fr : 2 #Output feedrate
#0 - programmed feedrate
#1 - inverse feedrate
#2 - inverse feedrate on 5 axis continuous
#3 - inverse feedrate on motion with rotary
inv_fd_typ : 0 #Calculate feed location options
#0 - inverse feed at tip
#1 - min-max on flute length
#2 - tip to pivot on tool length
#3 - min-max on flute length to pivot on tool length
rot_feed : 0 #Rapid rotary motion only feed options
#0 - convert to G0 rapid
#1 - apply rapid feedrate
maxfeedpm : 500 #Limit for feed in inch/min
maxfeedpm_m : 10000 #Limit for feed in mm/min
maxfrinv : 999.99#Limit for feed inverse time
fix_fr : 1 #If feedrate is zero, apply these values
deffeedpm : 1.0 #Default for zero feed in inch/min
deffeedpm_m : 25.0 #Default for zero feed in mm/min
deffrinv : 500.0 #Default for zero feed inverse time

#Enable canned drill cycle switches, prv_ is used to restore original
peckacel : 0 #Fractional percent to reduce peck2 when usecan... : no
usecandrill : yes #Use canned cycle for drill
usecanpeck : yes #Use canned cycle for Peck
usecanchip : yes #Use canned cycle for Chip Break
usecantap : yes #Use canned cycle for Tap
usecanbore1 : yes #Use canned cycle for Bore1
usecanb

ore2 : yes #Use canned cycle for Bore2
usecanmisc1 : yes #Use canned cycle for Misc1
usecanmisc2 : yes #Use canned cycle for Misc2

#Sequence numbers
omitseq : yes #Omit sequence no.
seqmax : 9999 #Max. sequence no.

#Output formatting
mill_plus : 0 #Output for the nutating machine mill plus G codes
spaces : 1 #No. of spaces to add between fields
pang_output : 0 #Angle output options, primary
sang_output : 0 #Angle output options, secondary
#0 = Normal angle output
#1 = Signed absolute output, 0 - 360
#2 = Implied shortest direction absolute output, 0 - 360

# --------------------------------------------------------------------------
# 5 Axis Rotary Settings
# --------------------------------------------------------------------------
#Assign axis address
str_pri_axis "C"
str_sec_axis "B"
str_dum_axis "A"
#Mill Plus, Assign feedrate axis address
str_pri_f40 "C40="
str_sec_f40 "B40="

#Mill Plus, toolplane angle position strings
str_n_a_axis "A5="
str_n_b_axis "B5="
str_n_c_axis "C5="

#Machine rotary routine settings
mtype : 0 #Machine type (Define base and rotation plane below)
#0 = Table/Table
#1 = Tilt Head/Table
#2 = Head/Head
#3 = Nutator Table/Table
#4 = Nutator Tilt Head/Table
#5 = Nutator Head/Head

head_is_sec : 1 #Set with mtype 1 and 4 to indicate head is on secondary

#Preferred setup is pri. zero matches sec. zero/direction
#Zero machine and determine the planes perp. to axis rotations
#These plane combinations are valid:
#Primary plane XY XZ YZ
#Secondary or XZ XY XY
#Secondary YZ YZ XZ

#Primary axis angle description (in machine base terms)
#With nutating (mtype 3-5) the nutating axis must be the XY plane
rotaxis1 = vecy #Zero
rotdir1 = vecx #Direction

#Secondary axis angle description (in machine base terms)
#With nutating (mtype 3-5) the nutating axis and this plane normal
#are aligned to calculate the secondary angle
rotaxis2 = vecz #Zero
rotdir2 = vecx #Direction

#NOTE: mill_plus and mtype > 2 (nutating), the dealer must match the
# above settings below. These must match initial settings!!!
p_nut_restore #Postblock, restores original axis settings
result = updgbl(rotaxis1, vecy) #Zero
result = updgbl(rotdir1, vecx) #Direction
result = updgbl(rotaxis2, vecz) #Zero
result = updgbl(rotdir2, vecx) #Direction

#Nutating machine (mtype 3-5) describe the plane that the nutated axis
#lays in, this is the plane perpendicular to the primary axis and
#secondary axis
nut_ang_pri : -45 #Nutating head secondary axis angle from machine Z positive

#Tool length, typically for head/head machine, both set to zero disables
#Applied to the tool le

ngth, RA applies this along the tool
use_tlength : 0 #Use tool length, read from tool overall length
toollength : 0 #Tool length if not read from overall length
shift_z_pvt : 0 #Shift Z by tool length, head/head program to pivot (Z axis only)
add_tl_to_lim : 0 #Add tool length after intersecting limit, always
#on if limit from stock
use_g45 : 0 #Use G45 offset with right angle head (RA)
g45_of_add : 30 #Add this number to tool length no. for G45 offset number

#Axis shift
#Part programmed where machine zero location is WCS origin-
#Applied to spindle direction, independent of RA
#Table/Table -
#Offset of tables to secondary axis relative to machine base.
#Tilt Head/Table - Head/Head -
#Part programmed at machine zero location-
#Offset in head based on secondary axis relative to machine base.
#Normally use the tool length for the offset in the tool direction
saxisx : 0 #The axis offset direction?
saxisy : 0 #The axis offset direction?
saxisz : 0 #The axis offset direction?

r_intersect : 1 #Rotary axis intersect on their center of ratations
#Determines if the zero point shifts relative to zero
#or rotation with axis offset.

#Force rotary axis reset at toolchange and other options
frc_cinit : 1
typ3_brk_evn : 0 #Windup limit, use even revolution break position
#Primary and/or secondary
brk_mv_head : 0 #Break the head 5 axis moves to remove gouge

g7_tilt : 3 #With mill_plus and nutating, select toolplane output
#0 = Post selects G7 rotation axis
#1 to 4, user selected G7 rotation axis
#1 = Primary C : X zero, Secondary B
#2 = Primary C : Y zero, Secondary A
#3 = Primary C : -X zero, Secondary B
#4 = Primary C : -Y zero, Secondary A

#Secondary shift (determines position and angle calculation)
#plane correction 90 degree shift case (plus or minus)
#used when secondary plane is defined perp to primary zero
#EX. P - vecx, vecy S - vecz, vecy
shift_90_s : 1 #Shift pos.=1, neg.=-1

#Rotary axis limits
adj2sec : 1 #Attempt to adjust the primary axis from secondary?
#Allows primary axis to flip 180 to satisfy secondary
#0 = Off
#1 = Use method when secondary is out of limit
#Use with pri_limtyp = one to keep secondary as controlling
#limit when limit tripped

#When the tool repositions, an intersection is made to the limits and the
#tool is driven around the limits to the reposition point as required.
#Z upper limit is used as the safe transition boundary
#Linear limits relative to machine base coordinates / part origin
use_stck_typ : 2 #0=Off, 1=Stock def., 2=Limits
up_x_lin_lim :

20.0 #X axis limit in positive direction
up_y_lin_lim : 20.0 #Y axis limit in positive direction
up_z_lin_lim : 20.0 #Z axis limit in positive direction
lw_x_lin_lim : -20.0 #X axis limit in negative direction
lw_y_lin_lim : -20.0 #Y axis limit in negative direction
lw_z_lin_lim : -5.0 #Z axis limit in negative direction

clear_stck : 0.0 #Add inc. offset to stock definition for transition boundary
clear_vec : 0 #5 axis motion, add inc. retract/approach clearance to cut
#Set with mr1

#Set pri_limtyp and sec_limtyp on following conditions
#0 = Less than 180 degrees
#1 = Equal or greater than 180 degrees and less than 360 degrees
#2 = Soft limit at 0-360 degrees with hard limits slightly beyond
#Set limhi-limlo to hard limits, inthi-intlo to 360 degrees total
#limhi-limlo are expected equal amount from inthi-intlo
#3 = Greater than 360 degrees
auto_set_lim : 1 #Set the type from the angle limit settings (ignore these)
pri_limtyp : 0
sec_limtyp : 0

#Set the absolute angles for axis travel on primary
pri_limlo : -9999
pri_limhi : 9999
#Set intermediate angle, in limits, for post to reposition machine
pri_intlo : -9999
pri_inthi : 9999

#Set the absolute angles for axis travel on secondary
sec_limlo : -9999
sec_limhi : 9999
#Set intermediate angle, in limits, for post to reposition machine
sec_intlo : -9999
sec_inthi : 9999

use_clamp : 0 #Use the automatic clamp Mcode

#Machine base matrix (Base matrix to map positions into)
matb1 : 1
matb2 : 0
matb3 : 0
matb4 : 0
matb5 : 1
matb6 : 0
matb7 : 0
matb8 : 0
matb9 : 1

#Tolerance settings for wind up and soft limit head reposition
p_tol_ang : 210 #Primary angle move to exceed for direction change
s_tol_ang : 210 #Secondary angle move to exceed for direction change
d_tol_ang : 210 #Dummy angle move to exceed for direction change

#pri_limtyp = 1, tolerance to validate tripping limit
#pri_limtyp = 2, angle move >= to trigger reposition on primary and
# reset the p_frc_adj_sec flag when back to normal range
# angle move >= with rev5 or 180 reposition to validate tripping limit
p_rsoft_tol : 45

#sec_limtyp = 2, Angle move >= for reposition
s_soft_tol : 270

adj_lim_trp : 90 #Angle move in p_pri_rot180 to trip reposition
#pri_limtyp = 2 and sec_limtyp = 2 control values
p_soft_tol : 270 #Angle move >= for reposition, primary
#pri_limtyp = 3 and sec_limtyp = 3 control values
p_rsoft_tol3 : 90 #Angle move >= with rev5 or 180 reposition

# --------------------------------------------------------------------------
# Format statements - n=nonmodal, l=leading, t=trailing, i=inc, d=delta
# ------------------------------------------------------------------

--------
#Default english/metric position format statements
fs2 1 0.8 0.7 #Decimal, absolute, 7 place, default for initialize (:)
fs2 2 0.4 0.3 #Decimal, absolute, 4/3 place
fs2 3 0.4 0.3d #Decimal, delta, 4/3 place
#Common format statements
fs2 4 1 0 1 0 #Integer, not leading
fs2 5 2 0 2 0l #Integer, force two leading
fs2 6 3 0 3 0l #Integer, force three leading
fs2 7 4 0 4 0l #Integer, force four leading
fs2 9 0.1 0.1 #Decimal, absolute, 1 place
fs2 10 0.2 0.2 #Decimal, absolute, 2 place
fs2 11 0.3 0.3 #Decimal, absolute, 3 place
fs2 12 0.4 0.4 #Decimal, absolute, 4 place
fs2 13 0.5 0.5 #Decimal, absolute, 5 place
fs2 14 0.3 0.3d #Decimal, delta, 3 place
fs2 15 0.2 0.1 #Decimal, absolute, 2/1 place
fs2 16 1 0 1 0n #Integer, forced output

# --------------------------------------------------------------------------
#String and string selector definitions for NC output
# --------------------------------------------------------------------------
#Address string definitions
stri "I"
strj "J"
strk "K"
strm "M"
strn "N"
stro "O"
strp "P"
strx "X"
stry "Y"
strz "Z"
srad "R"
srminus "R-"
sblank
sneg "-"
str_pri_axis_n
str_sec_axis_n

#Cantext string definitions (spaces must be padded here)
sm00 "M00"
sm01 "M01"
strtextno
strctxt

#String to capture rapid feedrate
sq38

#Mill Plus strings
sg07 "G7" #Tilt operating plane
str_l1 "L1=1" #Tilt operating plane parameter
#Re-assignment
str_mpls_prog "%PM"
str_mpls_g28 "G74"
str_mpls_m99
str_mpls_g82 "G81"
str_mpls_g73 "G83"
str_mpls_g84 "G84"
str_mpls_g85 "G85"
str_mpls_gxx "G??"

# --------------------------------------------------------------------------
# General G and M Code String select tables
# --------------------------------------------------------------------------
# Motion G code selection
sg00 G0 #Rapid
sg01 G1 #Linear feed
sg02 G2 #Circular interpolation CW
sg03 G3 #Circular interpolation CCW
sg04 G4 #Dwell
sgcode #Target for string

fstrsel sg00 gcode sgcode
# --------------------------------------------------------------------------
# Select work plane G code
sg17 G17 #XY plane code
sg19 G19 #YZ plane code
sg18 G18 #XZ plane code
sgplane #Target string

fstrsel sg17 plane_2 sgplane
# --------------------------------------------------------------------------
#Mill Plus Gcodes
sg70 G70 #Inch code
sg71 G71 #Metric code
# --------------------------------------------------------------------------
#Select english/metric code
sg20 G20 #Inch code
sg21 G21 #Metric code
smetric #Target string

fstrsel sg20 met_tool smetric
# --------------------

------------------------------------------------------
#Select reference return code
sg28 G28 #First reference point return
sg30 G30 #Second reference point return
sg28ref #Target string

fstrsel sg28 mi3 sg28ref
# --------------------------------------------------------------------------
# Cutter compensation G code selection
scc0 G40 #Cancel cutter compensation
scc1 G41 #Cutter compensation left
scc2 G42 #Cutter compensation right
sccomp #Target for string

fstrsel scc0 cc_pos sccomp
# --------------------------------------------------------------------------
# Canned drill cycle string select
sg81 G81 #drill - no dwell
sg81d G82 #drill - with dwell
sg83 G83 #peck drill - no dwell
sg83d G83 #peck drill - with dwell
sg73 G73 #chip break - no dwell
sg73d G73 #chip break - with dwell
sg84 G84 #tap - right hand
sg84d G74 #tap - left hand
sg85 G85 #bore #1 - no dwell
sg85d G89 #bore #1 - with dwell
sg86 G86 #bore #2 - no dwell
sg86d G86 #bore #2 - with dwell
sgm1 G88 #misc #1 - no dwell
sgm1d G88 #misc #1 - with dwell
sgm2 G89 #misc #2 - no dwell
sgm2d G89 #misc #2 - with dwell
sgdrill #Target for string

fstrsel sg81 drlgsel sgdrill
# --------------------------------------------------------------------------
# Select incremental or absolute G code
sg90 G90 #Absolute code
sg91 G91 #Incremental code
sgabsinc #Target string

fstrsel sg90 absinc sgabsinc
# --------------------------------------------------------------------------
# Feed mode G code selection
sg94 G94 #UPM
sg93 G93 #Inverse
sgfeed #Target for string

fstrsel sg94 ipr_type sgfeed
# --------------------------------------------------------------------------
#Canned drill cycle reference height
sg98 G98 #Reference at initht
sg99 G99 #Reference at refht
sgdrlref #Target for string

fstrsel sg98 drillref sgdrlref # Drill cycle G string select
# --------------------------------------------------------------------------
# Generate string for spindle
sm04 M4 #Spindle reverse
sm05 M5 #Spindle off
sm03 M3 #Spindle forward
spindle #Target for string

fstrsel sm04 spdir2 spindle
# --------------------------------------------------------------------------
# Coolant M code selection
sm09 M9 #Coolant Off
sm08 M8 #Coolant Flood
sm08_1 M7 #Coolant Mist
sm08_2 M7 #Coolant Tool
scoolant #Target for string

fstrsel sm09 coolant scoolant
# --------------------------------------------------------------------------
#Mill Plus Gcodes
sm11 M11 # Unlock Rotary Table
sm10 M10 # Lock Rotary Table
#

--------------------------------------------------------------------------
# Primary axis lock/unlock
spunlock M43 # Unlock Rotary Table
splock M44 # Lock Rotary Table
s_plock #Target for string

fstrsel spunlock p_lock s_plock
# --------------------------------------------------------------------------
#Mill Plus Gcodes
sm23 M23 # Unlock Rotary Table
sm22 M22 # Lock Rotary Table
# --------------------------------------------------------------------------
# Secondary axis lock/unlock
ssunlock M46 # Unlock Rotary Table
sslock M47 # Lock Rotary Table
s_slock #Target for string

fstrsel ssunlock s_lock s_slock
# --------------------------------------------------------------------------
# Define the gear selection code
flktbl 1 3 #Lookup table definition - table no. - no. entries
40 0 #Low gear range
41 400 #Med gear range
42 2250 #Hi gear range

# --------------------------------------------------------------------------
# Toolchange / NC output Variable Formats
# --------------------------------------------------------------------------
fmt T 4 t #Tool No
fmt T 4 first_tool #First Tool Used
fmt T 4 next_tool #Next Tool Used
fmt D 4 tloffno #Diameter Offset No
fmt D 4 tloffno2 #G45 Diameter Offset No
fmt H 4 tlngno #Length Offset No
fmt G 4 g_wcs #WCS G address
fmt P 4 p_wcs #WCS P address
fmt P 4 p_ofs #G10 P address
fmt S 4 speed #Spindle Speed
fmt M 4 gear #Gear range
# --------------------------------------------------------------------------
fmt N 4 n #Sequence number
fmt X 2 xout #X position output
fmt Y 2 yout #Y position output
fmt Z 2 zout #Z position output
fmt X 2 g74xabs #G74 X position output
fmt Y 2 g74yabs #G74 Y position output
fmt Z 2 g74zabs #G74 Z position output
fmt I 3 i #Arc center description in X
fmt J 3 j #Arc center description in Y
fmt K 3 k #Arc center description in Z
fmt I 3 iout #Arc center description in X
fmt J 3 jout #Arc center description in Y
fmt K 3 kout #Arc center description in Z
fmt R 2 arcrad #Arc Radius
fmt K 2 m_arc_ptch #Arc Pitch for Mill Plus helix
fmt "B5=" 2 m_sweep #Sweep for Mill Plus helix
fmt X 2 drlx #X position output
fmt Y 2 drly #Y position output
fmt Z 2 drlz #Z position output
fmt R 2 refhtoutx #Reference height
fmt R 2 refhtouty #Reference height
fmt R 2 refhtoutz #Reference height
fmt Q 2 peck1 #First peck increment (positive)
fmt 2 peck2 #Second or last peck (positive)
fmt 2 retr #Retract distance (positive)
fmt Q 2 shftdrl #Fine bore tool shi

ft
fmt F 15 feed #Feedrate
fmt "C40=" 2 pri_feed #Feedrate with 5 axis on Mill Plus
fmt "B40=" 2 sec_feed #Feedrate with 5 axis on Mill Plus
fmt P 11 dwell #Dwell
fmt M 5 cantext #Canned text
fmt Y 2 refhtout #Reference height (Mill Plus)
fmt B 2 inithtout #Initial height
fmt Z 2 depthout #Depth (drillcycle)

# --------------------------------------------------------------------------
fmt A 11 p_out #Primary output axis position
fmt B 11 s_out #Secondary output axis position
fmt C 11 d_out #Dummy output axis position
fmt X 2 tox_g #X origin position output (machine base)
fmt Y 2 toy_g #Y origin position output
fmt Z 2 toz_g #Z origin position output

# --------------------------------------------------------------------------
#Move comment (pound) to ignore program number prefix not used
#fmt O 7 progno #Program number
fmt ":" 7 progno #Program number

# --------------------------------------------------------------------------
fmt "TOOL - " 4 tnote # Note format
fmt " DIA. OFF. - " 4 toffnote # Note format
fmt " LEN. - " 4 tlngnote # Note format
fmt " DIA. - " 1 tldia # Note format

# --------------------------------------------------------------------------
# User Prompts
# --------------------------------------------------------------------------
fq 1 prv_p_wnd_ang Vertical tool detected! Enter initial primary axis angle:

# --------------------------------------------------------------------------
# Tool Comment / Manual Entry Section
# --------------------------------------------------------------------------

##### Custom changes allowed below #####

ptoolcomment #Comment for tool
tnote = t
toffnote = tloffno
tlngnote = tlngno
"(", pstrtool, *tnote, *toffnote, *tlngnote, *tldia, ")", e

pstrtool #Comment for tool
if strtool <> sblank,
[
strtool = ucase(strtool)
*strtool, " "
]

pcomment #Comment from manual entry (must call pcomment2 if booleans)
pcomment2

pcomment2 #Comment from manual entry
scomm = ucase (scomm)
if gcode = 1006 | gcode = 1026, scomm
else, "(", scomm, ")"
if gcode <> 1007 & gcode <> 1026, e


##### Stop custom changes #####

# --------------------------------------------------------------------------
# Start of File and Toolchange Setup
# --------------------------------------------------------------------------
p_goto_strt_tl #Make the tool start up at toolchange
pfd_shft_inc
psign_ang_out

##### Custom changes allowed below #####

if mill_plus,
[
if stagetool <= one, pbld, n, *t, "M6", e
pbld, n, *speed, *spindle, pgear, e
if stagetool = one, pbld, n, *next

_tool, e

if n_tpln_mch > m_one, #Toolplane mode
[
if lng3(tox_g), pbld, n, "G93", *tox_g, *toy_g, *toz_g, e
pbld, n, sg07, *s_out, pf_d_ang, *p_out, str_l1, e
pcan1, pbld, n, *sgcode, *sgabsinc, *xout, *yout, strctxt, e
]
else, #5 axis mode
[
plane_2 = zero
pbld, n, sgplane, e
pbld, n, sg07, str_l1, e
pcan1, pbld, n, *sgcode, *sgabsinc, *xout, *yout, *p_out, *s_out, strctxt, e
]
pbld, n, *zout, e
pbld, n, scoolant, e

!n_tpln_mch
]
else,
[
if stagetool <= one, pbld, n, *t, "M6", e
if cut_ra_head & use_g45, #Swap xout and yout based on offset axis
[
tloffno2 = tlngno + g45_of_add
pcan1, pbld, n, *sgcode, pwcs, *sgabsinc, *yout, *p_out, *s_out,
*speed, *spindle, pgear, strctxt, e
pbld, n, "G45", *tloffno2, *xout, e
]
else,
[
pcan1, pbld, n, *sgcode, pwcs, *sgabsinc, *xout, *yout, *p_out, *s_out,
*speed, *spindle, pgear, strctxt, e
]
if stagetool = one, pbld, n, *next_tool, e
pbld, n, "G43", *tlngno, *zout, scoolant, e
]

##### Stop custom changes #####

psign_ang_res
pcom_movea
#locally set delta for feed calculation
p_dlt_ang = zero
s_dlt_ang = zero
toolchng = zero

p_goto_strt_ntl #Make the tool start up at null toolchange
if workofs <> prv_workofs
| (mill_plus & (prv_n_tpln_mch <> n_tpln_mch
| prv_p_abs <> p_abs | prv_s_abs <> s_abs)),
[
pfd_shft_inc
sav_absinc = absinc
absinc = zero
p_absinc_chng
psign_ang_out

##### Custom changes allowed below #####

if mill_plus,
[
if n_tpln_mch > m_one,
[
pcan1, pbld, n, pwcs, e
if lng3(tox_g), pbld, n, "G93", *tox_g, *toy_g, *toz_g, e
pbld, n, sg07, *s_out, pf_d_ang, *p_out, str_l1, e
pcan1, pbld, n, *sgcode, *sgabsinc, *xout, *yout, strctxt, e
]
else,
[
pbld, n, pwcs, e
if prv_n_tpln_mch > zero,
[
plane_2 = zero
pbld, n, sgplane, e
pbld, n, sg07, str_l1, e
]
pcan1, pbld, n, *sgcode, *sgabsinc, *xout, *yout, *p_out, *s_out, strctxt, e
]
pbld, n, *zout, e
]
else, pbld, n, pwcs, sgabsinc, *xout, *yout, *zout, *p_out, *s_out, e

!n_tpln_mch

##### Stop custom changes #####

psign_ang_res
pe_inc_calc
absinc = sav_absinc
ps_inc_calc #calls p_absinc_chng
pcom_movea
]
else, p_goto_pos

#locally set delta for feed calculation
p_dlt_ang = zero
s_dlt_ang = zero

psof0 #Start of file for tool zero
psof

psof #Start of file for non-zero tool number

##### Custom changes allowed below #####

if ntools = one,
[
#skip single tool outputs, stagetool must be on
stagetool = m_one
!next_tool
]
if progno = zero, progno = one

*progno, "(", "PROGRAM - ", progname, ")", e
pbld, n, "(", "DATE - ", date, " TIME - ", time, ")", e
if not(mill_plus),
[
pbld, n, *smetric, e
pbld, n, "G0", *sgplane, "G40", "G80", "G90", *sgfeed, "G98", e
]

sav_absinc = absinc
absinc = one
prefreturn #xout, p_out not output here
absinc = zero
p_absinc_chng
ptoolcomment
comment
pcan

##### Stop custom changes #####

if mill_plus,
[
pbld, n, *smetric, e
pbld, n, pwcs, e
pbld, n, sg28, *g74zabs, "L1", e
pbld, n, sg07, str_l1, e
]
psof_tlchg_blck #Start position block
#Save the current brk_ in prv_brk_ for next loop
pupd_brk

##### Custom changes allowed below #####

pbld, n, s_plock, e
pbld, n, s_slock, e

##### Stop custom changes #####

absinc = sav_absinc
p_absinc_chng
pcom_movea
pe_inc_calc

ptlchg0 #Call from NCI null tool change (tool number repeats)

##### Custom changes allowed below #####

comment
pcan
pbld, n, sgplane, e
pspindchng
pbld, n, scoolant, e

##### Stop custom changes #####

psof_tlchg_blck #Start position block
#Save the current brk_ in prv_brk_ for next loop
pupd_brk
toolchng = zero

##### Custom changes allowed below #####

pbld, n, s_plock, e
pbld, n, s_slock, e

##### Stop custom changes #####

ptlchg #Tool change

##### Custom changes allowed below #####

pbld, n, "M01", e
if not(mill_plus),
pbld, n, "G0", sgplane, "G40", "G80", "G90", *sgfeed, "G98", e

sav_absinc = absinc
absinc = one
prefreturn #xout, p_out not output here
absinc = sav_absinc
ptoolcomment
comment
pcan
sav_absinc = absinc
absinc = zero
p_absinc_chng
##### Stop custom changes #####

psof_tlchg_blck #Tool change position block
#Save the current brk_ in prv_brk_ for next loop
pupd_brk

##### Custom changes allowed below #####

pbld,

n, s_plock, e
pbld, n, s_slock, e
absinc = sav_absinc
p_absinc_chng

##### Stop custom changes #####

pcom_movea
pe_inc_calc

pretract #End of tool path, toolchange
pretract_mov
sav_absinc = absinc
coolant = zero
cc_pos = zero
gcode = zero
spdir2 = one
p_lock = one
s_lock = one

##### Custom changes allowed below #####

pbld, n, scoolant, e
pbld, n, sccomp, spindle, e
pbld, n, s_plock, e
pbld, n, s_slock, e
absinc = one
prefreturn #xout, p_out not output here
absinc = sav_absinc
if mill_plus,
[
pbld, n, sg28, *g74zabs, "L1", e
#EOF on prv_gcode = 1003
if prv_gcode = 1003, pbld, n, sg28, *g74xabs, *g74yabs, e
pbld, n, sg07, str_l1, e
if lng3(tox_g), pbld, n, "G93", "X0.", "Y0.", "Z0.", e
if prv_gcode = 1003, frc_cinit = one
protretinc
if prv_gcode = 1003,
[
pbld, n, "T0", "M6", e
pbld, n, sg07, s_out, pf_d_ang, p_out, str_l1, e
]
]
else, pbld, n, *sg28, protretinc, e

prefreturn #Refernce return
if not(mill_plus),
[
pbld, n, *sgcode, *sg28, *sgabsinc, "Z0.", e
if toolchng = one, pbld, n, *sgcode, *sg28ref, "X0.", "Y0.", e
]

##### Stop custom changes #####

protretinc #Reset the C axis revolution counter
if frc_cinit,
[
p_abs = zero
p_inc = zero
s_abs = zero
s_inc = zero
pset_dlt_to_abs
if not(mill_plus), p_out, s_out
p_wnd_ang = zero
s_wnd_ang = zero
!p_wnd_ang, !s_wnd_ang
]

peof0 #End of file for tool zero
peof

peof #End of file for non-zero tool
toolchng = one
!gcode #to see that this is the EOF in pretract
pretract

##### Custom changes allowed below #####

comment
n, "M30", e

##### Stop custom changes #####

pwcs #G54+ coordinate setting at toolchange
if workofs <> prv_workofs | (force_wcs & toolchng > zero),
[
if workofs < 6,
[
g_wcs = workofs + 54
*g_wcs
]
else,
[
p_wcs = workofs - five
"G54.1", *p_wcs
if mill_plus, result = mprint(swcserror)
]
]
!workofs

pgear #Find spindle gear from lookup table
if use_gear = one,
[
gear = frange (one, speed)
*gear
]

#Toolchange setup
pspindchng #Spindle speed change
if prv_spdir2 <> spdir2 & prv_speed <> zero, pbld, n, *sm05, e
if prv_speed <> speed | prv_spdir2

<> spdir2,
[
if speed, pbld, n, *speed, *spindle, pgear, e
]
!speed, !spdir2

pspindle #Spindle speed calculations for RPM
speed = abs(ss)
if maxss = zero | maxss > max_speed, maxss = max_speed
#zero indicates spindle off (not a mistake)
if speed,
[
if speed > max_speed, speed = maxss
if speed < min_speed, speed = min_speed
]
spdir2 = fsg3(spdir)

ptoolend #End of tool path, before reading new tool data
if end_gcode = 1000,
[
#Null toolchange
toolchng = m_one
pretract_mov
]
else,
[
#Actual toolchange
toolchng = two
pretract
]
!speed, !spdir2, !tlch_ret_app, !g_lim_trip

# --------------------------------------------------------------------------
# Motion NC output
# --------------------------------------------------------------------------

##### Custom changes allowed below #####

prapidout #Output to NC of linear movement - rapid
pcan1, pbld, n, `sgcode, sgplane, sgabsinc, pccdia,
xout, yout, zout, p_out, s_out, strctxt, scoolant, e

plinout #Output to NC of linear movement - feed
pcan1, pbld, n, `sgcode, sgplane, sgabsinc, sgfeed, pccdia,
xout, yout, zout, p_out, s_out, p_mpls_feed, `feed, strctxt, scoolant, e
if nc_lout <> m_one & feed = zero, psfeederror

pcirout #Output to NC of circular interpolation
sav_gcode = gcode
parc_setup
pcan1, pbld, n, `sgcode, sgplane, sgabsinc, sgfeed, pccdia,
xout, yout, zout, p_out, s_out, parcijk, `feed, strctxt, scoolant, e
gcode = sav_gcode
if nc_lout <> m_one & feed = zero, psfeederror

pncoutput #Movement output
comment
pcan
if feed = zero & fix_fr,
[
if ipr_type, feed = deffrinv
else, feed = deffeedpm
]
psign_ang_out
if cuttype = zero, ppos_cax_lin #Toolplane rotary positioning
if mill_plus, pbld, n, pccdia_mlps, e
if gcode = zero, prapidout
if gcode = one, plinout
if gcode > one & gcode < four, pcirout
psign_ang_res
pcom_movea

ppos_cax_lin #Position the rotary axis before move - rapid
if p_inc | s_inc,
[
sav_gcode = gcode
gcode = zero
pbld, n, sgcode, p_out, s_out, e
ps_cinc_calc
gcode = sav_gcode
]

pcom_movea #Common motion preparation routines, after
pcan2
pe_inc_calc

pdwl_spd #Call from NCI gcode 4
pspindle
comment
pspindchng
pcan
if fmtrnd(dwell), pcan1, pbld, n, *sgcode, *dwell, strctxt, e
else, pcan1, pbld, n, strctxt, e
pcan2

# --------------

------------------------------------------------------------
# Motion output components
# --------------------------------------------------------------------------
pbld #Canned text - block delete
if bld, '/'

pccdia #Cutter Compensation
#Force Dxx#
if not(mill_plus),
[
if prv_cc_pos <> cc_pos & cc_pos, result = force(tloffno,tloffno)
sav_cc_pos = cc_pos
if cc_pos & pln_2_rev, cc_pos = abs(cc_pos - three)
sccomp, tloffno
cc_pos = sav_cc_pos
]

pccdia_mlps #Cutter Compensation, D register
sav_cc_pos = cc_pos
if cc_pos & pln_2_rev, cc_pos = abs(cc_pos - three)
sccomp
cc_pos = sav_cc_pos

psign_ang_out #Signed angle output modification
if pang_output,
[
sv_p_abs = p_abs
ppsign_ang
if p_inc, result = force(p_out,p_out)
else, !p_out
]
if sang_output,
[
sv_s_abs = s_abs
pssign_ang
if s_inc, result = force(s_out,s_out)
else, !s_out
]

psign_ang_res #Restore p_abs with signed angle output
if pang_output, p_abs = sv_p_abs
if sang_output, s_abs = sv_s_abs

pf_d_ang #Force tertiary axis output with mill_plus
d_abs = zero
d_inc = zero
*d_out

parc_setup #Force the arc position output
if pln_2_rev, gcode = abs(gcode - five)
if mill_plus, #Mill Plus helix, force positions and add arc_pitch
[
result = force(gcode, gcode)
if plane_2 = zero,
[
result = force(xout,yout) #XY
result = force(iout,jout) #IJ
if arc_pitch, result = nwadrs(strk, m_arc_ptch)
]
else,
[
if plane_2 = one,
[
result = force(yout,zout) #YZ
result = force(jout,kout) #JK
if arc_pitch, result = nwadrs(stri, m_arc_ptch)
]
if plane_2 = two, #XZ
[
result = force(xout,xout)
result = force(zout,zout)
result = force(iout,iout)
result = force(kout,kout)
if arc_pitch, result = nwadrs(strj, m_arc_ptch)
]
]
]

parcijk #Select the arc output
if arcoutput = zero | full_arc_flg | (mill_plus & arc_pitch),
[
#Arc output for IJK
iout, jout, kout
if mill_plus & arc_pitch,
[
m_arc_ptch = -arc_pitch
*m_arc_ptch
]
!i, !j, !k
]
else,
[
#Arc output for R
if abs(sweep)<=arc180 | arcoutput=one, result = nwadrs(srad, arcrad)
else, result = nwadrs(srminus, arcrad)
*arcrad
]

p_mpls_feed #Feed output with Mill Plus and 5 axis, add A40, B40, C40
if mill_plus & cuttype

<> zero & drilltype = zero, pri_feed, sec_feed

# --------------------------------------------------------------------------
# Drilling
# --------------------------------------------------------------------------
pdrlcommonb #Canned Drill Cycle common call, before
if mill_plus,
[
if prv_gnci = 81,
[
#Mill plus can only set ref on a real drill cycle def.
prv_drl_txa = vequ(aaxisy) #aaxisy is tapping 0,0,0
if plane_2 = zero, #XY
[
prv_drl_tza = drl_rza - drl_tza #Saved for gcode 100 calcs
refhtout = abs(prv_drl_tza)
]
else,
[
if plane_2 = one, #YZ
[
prv_drl_txa = drl_rxa - drl_txa
refhtout = abs(prv_drl_txa)
]
else, #XZ
[
prv_drl_tya = drl_rya - drl_tya
refhtout = abs(prv_drl_tya)
]
]
]
#init and depth can change
if plane_2 = zero, #XY
[
inithtout = abs(zabs - drl_rza)
depthout = drl_dza - drl_rza + prv_drl_tza
]
else,
[
if plane_2 = one, #YZ
[
inithtout = abs(xabs - drl_rxa)
depthout = drl_dxa - drl_rxa + prv_drl_tza
]
else, #XZ
[
inithtout = abs(yabs - drl_rya)
depthout = drl_dya - drl_rya + prv_drl_tza
]
]
#refhtoutx is used to output G79 point (at surface)
refhtoutx = vsub(drl_rxa, prv_drl_txa)
if not(drillref), result = force(inithtout, inithtout)
else, !inithtout
if gcode = 81,
[
sav_absinc = absinc
absinc = zero #only absolute for definition
p_absinc_chng
]
else,
[
sav_absinc = absinc
p_absinc_chng
]
]
pbld, n, sgplane, sgfeed, e
feed = fr_pos
prv_dwell = zero
@dwell
comment
pcan

prdrlout #Output drill position
if mill_plus,
[
if plane_2 = zero, *xout, *yout, p_out, s_out, *refhtoutz #XY
else,
[
if plane_2 = one, *yout, *zout, p_out, s_out, *refhtoutx #YZ
else, *xout, *zout, p_out, s_out, *refhtouty #XZ
]
]
else,
[
if plane_2 = zero, #XY
[
if gcode = 81,
[
result = force(drlz, drlz)
result = force(refhtoutz, refhtoutz)
]
xout, yout, drlz, p_out, s_out, refhtoutz
]
else,
[
if plane_2 = one, #YZ
[
if gcode = 81,
[
result = force(drlx, drlx)
result = force(refhtoutx, refhtoutx)
]

drlx, yout, zout, p_out, s_out, refhtoutx
]
else, #XZ
[
if gcode = 81,
[
result = force(drly, drly)
result = force(refhtouty, refhtouty)
]
xout, drly, zout, p_out, s_out, refhtouty
]
]
]
!refhtoutx, !refhtouty, !refhtoutz, !drlx, !drly, !drlz

pdrill #Canned Drill Cycle
pdrlcommonb
if mill_plus,
[
pcan1, pbld, n, *sgdrill, dwell, *refhtout, *depthout,
inithtout, *feed, strctxt, e
pbld, n, "G79", prdrlout, e
]
else, pcan1, pbld, n, *sgdrill, sgabsinc, *sgdrlref, prdrlout,
dwell, *feed, strctxt, e
pcom_movea

ppeck #Canned Peck Drill Cycle
pdrlcommonb
if mill_plus,
[
pcan1, pbld, n, *sgdrill, dwell, *refhtout, *depthout,
inithtout, *peck2, *peck1, *feed, strctxt, e
pbld, n, "G79", prdrlout, e
]
else, pcan1, pbld, n, *sgdrill, sgabsinc, *sgdrlref, prdrlout,
*peck1, *feed, strctxt, e
pcom_movea

pchpbrk #Canned Chip Break Cycle
pdrlcommonb
if mill_plus,
[
pcan1, pbld, n, *sgdrill, dwell, *refhtout, *depthout,
inithtout, *peck2, *peck1, *retr, *feed, strctxt, e
pbld, n, "G79", prdrlout, e
]
else, pcan1, pbld, n, *sgdrill, sgabsinc, *sgdrlref, prdrlout,
*peck1, *feed, strctxt, e
pcom_movea

ptap #Canned Tap Cycle
pdrlcommonb
if mill_plus,
[
pcan1, pbld, n, *sgdrill, dwell, *refhtout, *depthout,
inithtout, *feed, *speed, *feed, strctxt, e
pbld, n, "G79", prdrlout, e
]
else, pcan1, pbld, n, *sgdrill, sgabsinc, *sgdrlref, prdrlout,
*feed, strctxt, e
pcom_movea

pbore1 #Canned Bore #1 Cycle (Ream with Mill Plus)
pdrlcommonb
if mill_plus,
[
pcan1, pbld, n, *sgdrill, dwell, *refhtout, *depthout,
inithtout, *feed, strctxt, e
pbld, n, "G79", prdrlout, e
]
else, pcan1, pbld, n, *sgdrill, sgabsinc, *sgdrlref, prdrlout,
dwell, *feed, strctxt, e
pcom_movea

pbore2 #Canned Bore #2 Cycle
pdrlcommonb
if mill_plus,
[
pcan1, pbld, n, *sgdrill, dwell, *refhtout, *depthout,
inithtout, *feed, strctxt, e
pbld, n, "G79", prdrlout, e
]
else, pcan1, pbld, n, *sgdrill, sgabsinc, *sgdrlref, prdrlout,
*feed, strctxt, e
pcom_movea

pmisc1 #Canned Misc #1 Cycle (Finish Bore)
pdrlcommonb
if mill_plus,
[
pcan1, pbld, n, *sgdrill, dwell, *refhtout, *depthout,
inithtout, *feed, strctxt, e
pbld, n, "G79", prdrlout, e
]
else, pcan1, pbld, n, *s

gdrill, sgabsinc, *sgdrlref, prdrlout,
shftdrl, dwell, *feed, strctxt, e
pcom_movea

pmisc2 #Canned Misc #2 Cycle (Floating Tap)
pdrlcommonb
if mill_plus,
[
pcan1, pbld, n, *sgdrill, dwell, *refhtout, *depthout,
inithtout, *feed, strctxt, e
pbld, n, "G79", prdrlout, e
]
else, pcan1, pbld, n, *sgdrill, sgabsinc, *sgdrlref, prdrlout,
shftdrl, dwell, *feed, strctxt, e
pcom_movea

pdrill_2_cmn #Canned Drill Cycle, additional points
pdrlcommonb
if mill_plus,
[
pcan1, pbld, n, "G79", prdrlout, strctxt, e
]
else, pcan1, pbld, n, sgplane, prdrlout, dwell, feed, strctxt, e
pcom_movea

pdrill_2 #Canned Drill Cycle, additional points
if gcode = 81, pdrill
else, pdrill_2_cmn

ppeck_2 #Canned Peck Drill Cycle
if gcode = 81, ppeck
else, pdrill_2_cmn

pchpbrk_2 #Canned Chip Break Cycle
if gcode = 81, pchpbrk
else, pdrill_2_cmn

ptap_2 #Canned Tap Cycle
if gcode = 81, ptap
else, pdrill_2_cmn

pbore1_2 #Canned Bore #1 Cycle
if gcode = 81, pbore1
else, pdrill_2_cmn

pbore2_2 #Canned Bore #2 Cycle
if gcode = 81, pbore2
else, pdrill_2_cmn

pmisc1_2 #Canned Misc #1 Cycle
if gcode = 81, pmisc1
else, pdrill_2_cmn

pmisc2_2 #Canned Misc #2 Cycle
if gcode = 81, pmisc2
else, pdrill_2_cmn

pdrlcst #Custom drill cycles 8 - 19 (user option)
#Use this postblock to customize drilling cycles 8 - 19
pdrlcommonb
"CUSTOMIZABLE DRILL CYCLE ", prdrlout, e
pcom_movea

pdrlcst_2 #Custom drill cycles 8 - 19, additional points (user option)
#Use this postblock to customize drilling cycles 8 - 19
pdrlcommonb
"CUSTOMIZABLE DRILL CYCLE ", prdrlout, e
pcom_movea

pcanceldc #Cancel canned drill cycle
prv_gcode = zero
if not(mill_plus), pbld, n, "G80", e

# --------------------------------------------------------------------------
#For subprogram postblocks
# --------------------------------------------------------------------------
pmiscint #Set the misc. integer values
absinc = mi2
add_wrk_sht = mi6
enable_lim = mi7
tlch_ret_app = mi8
nut_bias = mi9

pmiscreal #Set the misc. real values
clear_vec = mr1
cut_ra_head = mr2
g74xabs = vequ(mr3)

# --------------------------------------------------------------------------
# Canned Text
# --------------------------------------------------------------------------
pcan #Canned text - before output call
strctxt = sblank
if cant_no > zero,
[
if cant_pos1 = zero, pcant_1
if cant_pos2 = zero, pcant_2
if cant_pos3 = zero, pcant

_3
if cant_pos4 = zero, pcant_4
if cant_pos5 = zero, pcant_5
if cant_pos6 = zero, pcant_6
if cant_pos7 = zero, pcant_7
if cant_pos8 = zero, pcant_8
if cant_pos9 = zero, pcant_9
if cant_pos10 = zero, pcant_10
pbld, n, strctxt, e
strctxt = sblank
]

pcan1 #Canned text - with move
strctxt = sblank
if cant_no > zero,
[
if cant_pos1 = one, pcant_1
if cant_pos2 = one, pcant_2
if cant_pos3 = one, pcant_3
if cant_pos4 = one, pcant_4
if cant_pos5 = one, pcant_5
if cant_pos6 = one, pcant_6
if cant_pos7 = one, pcant_7
if cant_pos8 = one, pcant_8
if cant_pos9 = one, pcant_9
if cant_pos10 = one, pcant_10
]
if cstop, strctxt = strctxt + sm00
if cgstop, strctxt = strctxt + sm01
#Output of strctxt occurs at the end of the output line

pcan2 #Canned text - after output call
strctxt = sblank
if cant_no > zero,
[
if cant_pos1 = two, pcant_1
if cant_pos2 = two, pcant_2
if cant_pos3 = two, pcant_3
if cant_pos4 = two, pcant_4
if cant_pos5 = two, pcant_5
if cant_pos6 = two, pcant_6
if cant_pos7 = two, pcant_7
if cant_pos8 = two, pcant_8
if cant_pos9 = two, pcant_9
if cant_pos10 = two, pcant_10
pbld, n, strctxt, e
strctxt = sblank
]

pcant_1 #Canned text - output call
cantext = cant_val1
pcant_out

pcant_2 #Canned text - output call
cantext = cant_val2
pcant_out

pcant_3 #Canned text - output call
cantext = cant_val3
pcant_out

pcant_4 #Canned text - output call
cantext = cant_val4
pcant_out

pcant_5 #Canned text - output call
cantext = cant_val5
pcant_out

pcant_6 #Canned text - output call
cantext = cant_val6
pcant_out

pcant_7 #Canned text - output call
cantext = cant_val7
pcant_out

pcant_8 #Canned text - output call
cantext = cant_val8
pcant_out

pcant_9 #Canned text - output call
cantext = cant_val9
pcant_out

pcant_10 #Canned text - output call
cantext = cant_val10
pcant_out

pcant_out #Canned text - build the string for output
#Assign string select type outputs
if cantext = three, bld = one
if cantext = four, bld = zero
#Build the cantext string
if cantext = one, strctxt = strctxt + sm00
if cantext = two, strctxt = strctxt + sm01
if cantext > four,
[
strtextno = no2str(cantext)
strctxt = strctxt + strm + strtextno
]

##### Stop custom changes #####

# -------------------------------------------------------------------------

相关主题
相关文档
最新文档