Advertisement
Guest User

Untitled

a guest
Apr 9th, 2025
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 229.02 KB | Source Code | 0 0
  1. [POST_VERSION] #DO NOT MOVE OR ALTER THIS LINE# V25.00 P4 E1 W25.00 T1673541375 M25.00 I0 O0
  2. # Post Name           : HYUNDAIKIA_SKT_FANUC
  3. # Product             : LATHE
  4. # Machine Name        : Hyundai Kia SKT
  5. # Control Name        : FANUC
  6. # Description         : Hyundai Kia SKT with Fanuc control
  7. # Mill/Turn           : YES
  8. # 4-axis/Axis subs.   : YES
  9. # 5-axis              : NO
  10. # Subprograms         : YES
  11. # Canned Cycles       : YES
  12. # Executable          : MP 14.0
  13. # Encrypted to SIM    : END USER
  14. # Timed Until         : PERM
  15. #
  16. # WARNING: THIS POST IS GENERIC AND IS INTENDED FOR MODIFICATION TO
  17. # THE MACHINE TOOL REQUIREMENTS AND PERSONAL PREFERENCE.
  18. #
  19. # Associated File List$
  20. #
  21. # Associated File List$
  22. #
  23. # --------------------------------------------------------------------------
  24. # Revision log:
  25. # --------------------------------------------------------------------------
  26. # Programmers Note:
  27. # CNC 07/7/05  -  Initial post update for Mastercam X
  28. # IHS 02/01/06 -  Initial setup from "Generic Fanuc 4X MT_Lathe.pst",
  29. #                 G112, G107, mill drilling, home_type, wbt
  30. # IHS 02/08/06 -  Canned threading, C-axis clamp/brake, wbt
  31. # IHS 02/10/06 -  breakarcs, canned thread, lathe_stop, wbt
  32. # IHS 04/10/06 -  ipr_actv$ not updated yet in ltlchg, wbt
  33. # IHS 05/15/06 -  split up gear and spindle M codes, wbt
  34. # IHS 07/07/06 -  G112, type 1 and 2 G71 roughing, tool table, drill cycles, wbt
  35. # IHS 07/10/06 -  c_axistype, ctable, rot_dir, from machine def, wbt
  36. # IHS 07/28/06 -  index mode for drilling, feed/rev for milling, wbt
  37. # IHS 08/29/06 -  force R output for G07.1 arcs, wbt
  38. # IHS 01/02/07 -  feed G code output in ltlchg and use_pitch, wbt
  39. # IHS 02/05/07 -  css_end_rpm added, wbt
  40. # IHS 02/12/07 -  support for arcs on face about X0 Y0 (breakarcs set automatically), wbt
  41. # IHS 02/14/07 -  plane output before G07.1 even if no Y-axis on machine, wbt
  42. # IHS 07/11/07 -  g54g55, `sgcode, mi10$ canned rough and finish (search #CRF), wbt
  43. # IHS 10/24/07 -  Force arc output for particular planes (parc), wbt
  44. # IHS 11/02/07 -  Uncommented pcc_capture in pl_ncoutput to fix G73 pattern repeat (U and W values) and motion after canned rough, also see pcc_capture, wbt
  45. # IHS 11/27/07 -  added c_resolution, wbt
  46. # IHS 12/10/07 -  Metvals variable, rjj
  47. # IHS 02/12/08 -  axis subs cross drilling plane to output G19, wbt
  48. # IHS 03/01/08 -  plinout fix issue with longhand drilling output, cam/wbt
  49. # IHS 03/01/08 -  cwind, checkyflg, wbt/cam/rjj
  50. # IHS 04/01/08 -  changed gcode$ to gnci in pcom_moveb to issue with gcode being set twice by pcom_moveb, rjj/sxc
  51. # IHS 04/02/08 -  Eliminated prv_spindle_no from logic due to errors, rjj
  52. # IHS 08/11/08 -  Updated to version X3, rjj
  53. # IHS 10/20/08 -  tldianote added, aeh
  54. # IHS 03/10/09 -  5 Axis Multisurface coordinates mapping corrected, jff
  55. # IHS 06/09/09 -  Updated to version X4, rjj
  56. # IHS 10/12/09 -  Added cc_seqno switch to fix lathe canned cycle sequence numbers, rjj
  57. # IHS 06/03/10 -  Updated to version X5, jff
  58. # IHS 01/10/12 -  Updated to X6, ijm
  59. # IHS 11/16/12 -  Modified one_rev calculations, sfc
  60. # IHS 12/06/13 -  Written for Sinters (CAP), kwws
  61. # IHS 01/31/14 -  Untimed post, cml
  62. # IHS 03/06/14 -  Added nethasp, cml
  63. # IHS 09/09/14 -  Various formatting mods, arjd
  64. # IHS 03/18/15 -  Synced onsite IHSQ mods, cml
  65. # IHS 09/21/17 -  Updated post to M2018, aks
  66. # IHS 09/21/17 -  Synced customer changes (possibly reverted the onsite mods), aks
  67. # IHS 11/16/17 -  Synced customer mods, Changed speed at sof, Moved tool comments,
  68. #                 Moved spindle speed and M code for tapping cycle, only home X-axis (switch)
  69. #                 Replaced M29 with M129, M-Codes for lathe tapping, C-axis disable M-Code, kee
  70. # IHS 11/22/17 -  Enable C-axis at start and disable at end of every mill op., kee
  71. # IHS 12/15/18 -  SYNCED CHANGES: tool_info = 1, thread_address = 0, Modified min/max speeds, Modified tool comments,
  72. #                                 Modified header, kma
  73. # IHS 12/15/18 -  SYNCED CHANGES: Ltlchg approach in Z followed by X, Ctrl text language and miscs, kee
  74. # IHS 03/20/18 -  Changed maxfeedpm 500 to 200, approach move to Z then XY, coolant position, kl
  75. # IHS 02/28/19 -  Overide RPM to 800 when css rpm start, modified comment positions, unforced feed units, modified home moves, jr & rw
  76. # IHS 03/28/19 -  Corrected feed type output, added Z4.0 home move for milling, header mods, dvb
  77. # IHS 01/12/23 -  00070978 - Updated to Mastecam2023 & added sim number, cml
  78. #
  79. # --------------------------------------------------------------------------
  80. # Features:
  81. # --------------------------------------------------------------------------
  82. #######          MILL/TURN FUNCTIONS SUPPORTED BY THIS POST          #######
  83. #
  84. # This post supports Generic Fanuc code output for mill/turn lathes.
  85. # It is designed to support the features of Mastercam X.
  86. #
  87. ## NEW FEATURES FOR X
  88. # - Machine definition, control definition and toolpath group parameter read sections added.
  89. # - Variable initialization with CD_VAR are read directly from CD.  Changing these initial values
  90. #     in the post will not effect output.  These values are only processed during the update post routine.
  91. # - Variable initialization with SET_BY_MD or SET_BY_CD are overwritten in this post by parameter or
  92. #     variable settings from MD or CD.
  93. # - Enhanced tool information - Added switch for tool comments (see tool_info)
  94. # - Supports X comments including machine name, group name and group comment output (see pcomment2)
  95. # - Additional date, time and data path output options (see pheader)
  96. # - Support for 10 additional canned text options for X
  97. # - Decimal support for sequence number output (set "Increment sequence number" in CD to a decimal value
  98. #     for output.  I.E. "Increment sequence number" = .5, "Start sequence number" = 10 : N10, N10.5, N11, N11.5, etc...)
  99. # - Switch for output of M00 or M01 at tool change (3 position switch, off, M00, M01 - see prog_stop)
  100. # - Support for seperate XY, XZ and YZ plane/arc variables (see Arc page in CD)
  101. # - Support for X style coolant.  Allows up to 10 different coolants to be turned on/off before, with, or after like
  102. #     canned text.  Coolant output is handled by "coolant" variable and string selector for V9 style coolant,
  103. #     "coolantx" variable and string selector for X style coolant.
  104. #
  105. # Following Misc. Integers are used:
  106. #
  107. # mi2 - Absolute or Incremental positioning at top level
  108. #       0 = absolute
  109. #       1 = incremental
  110. #
  111. # mi3 - Select G28 or G30 reference point return:
  112. #       0 = G28, 1 = G30
  113. #
  114. # mi4 - Canned conversion cycle type selection:   (mill only)
  115. #       Mill-
  116. #       Activates milling axis conversation canned cycles (G107 or G112).
  117. #       1 activates the cycle.  Post will change rapid moves to high feed linear moves.
  118. #
  119. # mi5 - Spindle Synch
  120. #       0 = Off
  121. #       1 = On
  122. #
  123. # mi6 - Feed/Rev Output   (mill)
  124. #       0 = Off
  125. #       1 = On
  126. #
  127. # mi7 - Clamp Code Override     (mill only)
  128. #       0 = Default post decision
  129. #       1 = Force Full Clamp
  130. #       2 = Force Brake / Mid-Clamp
  131. #       3 = Off
  132. #
  133. # mi10 - CRF X value    #Set this integer in the canned finish path
  134. #       0=orig
  135. #       1=post
  136. #   Used to change the initial X value before the canned cycle call to the OD (original)
  137. #       X value of the canned rough.  this is a safetly precaution to avoid a rapid approach
  138. #       through the part to your lathe canned finish ops.
  139. #
  140. #Canned text:
  141. #  Entering cantext within Mastercam allows the following functions to
  142. #  enable/disable.
  143. #  cantext value:
  144. #  1 = Program Stop =  output the "M00" stop code
  145. #  2 = Optional Stop = output the "M01" optional stop code
  146. #  3 = Block Delete on = turn on block delete codes in NC lines
  147. #  4 = Block Delete off = turn off block delete codes in NC lines
  148. #  5 = Return Tailstock =  output the code to retract the tail stock
  149. #  6 = Advance Tailstock =  output the code to advance the tail stock
  150. #  7 = Return Chute =  output the code to retract the chute
  151. #  8 = Advance Chute =  output the code to advance the chute
  152. #  9 = Exact Stop on = turn on the exact stop code in the NC line
  153. #  10 = Exact Stop off = turn off the exact stop code in the NC line
  154. #  11 to 99 output the value selected
  155. #
  156. #TURN TOOLPATHS:
  157. #Lathe canned cycles:
  158. # Supports lathe canned turning cycles through Mastercam.  This post
  159. # is configured to process them.
  160. #
  161. #MILL TOOLPATHS:
  162. #Mill Layout:
  163. # The term "Reference View" refers to the coordinate system associated
  164. # with the Mill Top view (Alt-F9, the upper gnomon of the three displayed).
  165. # Create the part drawing with the the axis of rotation along the X axis
  166. # of the "Mill Reference View" with the face of the part toward the side
  167. # view (Mill Reference View X plus direction).  The Y plus axis of the
  168. # Mill Reference View indicates the position on the part of C zero
  169. # (View number 3).  The right or left side view are the only legal views
  170. # for face milling.  The view number 3 rotated about the X axis as a
  171. # "single axis rotation" are the only legal views for cross milling
  172. # except for axis substitution where the top view is required.
  173. # Rotation around the part is positive in the CCW direction when viewed
  174. # from the side view.
  175. # (The Chook 'CVIEW' should be used for creating milling tool plane and
  176. # construction plane selections, C axis toolpaths in lathe perform
  177. # this function automatically).
  178. #NOTICE: View number 3 always indicates the location for C zero.  Milling
  179. #        with a turret below the centerline indicates C at 180 degrees.
  180. #
  181. #Mill canned cycles:
  182. #Cylindrical interpolation, G107 canned cycle:
  183. # Cylindrical interpolation is created with axis substitution only.
  184. # Use the Caxis/C_axis Contour toolpath.  Create the geometry from
  185. # view number 4 if the rotation of C axis is CCW.  This prevents producing
  186. # a mirror image.  Wrapped and unwrapped geometry are broken and arcs are
  187. # lost so it is better to create flattened geometry.  Set the parameters
  188. # in Rotary Axis not to 'unroll' and set the correct diameter.
  189. # Use View number 3 as the C0 location.  Set mi4 to activate!
  190. #
  191. #Polar interpolation, G112 canned cycle:
  192. # Polar interpolation is active only for face cutting (Right or Left).
  193. # Use the Caxis/Face Contour toolpath.  Create geometry for the lead in
  194. # and lead out with the start and end position on the View number 3 tool
  195. # axis.  All paths must start and end at the 'C0'location for output to
  196. # be correct.  Chain the entire geometry without using Mastercam leads.
  197. # Set mi4 to activate!
  198. #
  199. #Axis substitution:
  200. # View number 3 is the C zero location on the part and corresponds to the
  201. # Y zero position of the "Mill Reference View".  Positions are wrapped
  202. # from and to the diameter of the part as CCW for the Y positive direction.
  203. # If geometry is drawn from View number 4 (Bottom), it is correct for the
  204. # wrap/unwrap on the diameter.  The radius of the specified diameter is
  205. # added to the Z position in the post.  The Y axis is the only axis to
  206. # be converted with mill/turn.
  207. #
  208. #Simultaneous 4 Axis (11 gcode):
  209. # Full 4 axis toolpaths can be generated from various toolpaths under the
  210. # 'multi-axis' selection (i.e. Rotary 4 axis). All 5 axis paths are
  211. # converted to 4 axis paths where only the angle about the rotation axis
  212. # is resolved. Use View number 3 for the toolplane with all 'multi-axis'.
  213. # 4 and 5 axis toolpaths are converted assuming cross machining only!
  214. #
  215. #Y axis output and machining over part center:
  216. # Output Y axis motion by setting 'Rotary axis/Y axis' in the NC
  217. # parameter page.  This requires a valid Axis Combination in your machine defintion.
  218. # y_axis_mch is set from the axis combination.
  219. # Set 'Rotary axis/Y axis' in a machine with no Y axis (y_axis_mch = 0)
  220. # to force linear/circular position moves in the XZ plane (g18).
  221. # This allows machining over the part center.
  222. #Caution: The machining must stay in the XZ plane at a Y fixed value
  223. # when y_axis_mch = zero because no C (other than the Tplane) or
  224. # Y positions are output!!!  This occurs when selecting C_axis/Cross
  225. # Contour without 'y_axis_mch'.  Use Mill toolpaths for cross profiling.
  226. #
  227. #NOTICE: Milling through the part center with a linear move requires the
  228. #        geometry be broken at the centerline.  Milling through the part
  229. #        center with an arc move in the G18 plane, no Y axis and on the
  230. #        negative side of X, reverses only the arc direction and I sign.
  231. #
  232. #Additional Notes:
  233. # 1) G54 calls are generated where the work offset entry of 0 = G54,
  234. #    1 = G55, etc.
  235. # 2) Metric is applied from the NCI met_tool variable.
  236. # 3) The Tplane angle is added to polar conversion and rotary paths.
  237. # 4) The variable 'absinc' is now pre-defined, set mi2 (Misc. Integer) for
  238. #    the 'top level' absolute/incremental program output.  Subprograms are
  239. #    updated through the Mastercam dialog settings for sub-programs.
  240. # 5) Lathe disables coordinate mirror and rotate subprograms.
  241. # 6) When creating tools the diameter/radius should end as even numbers
  242. #    relative to the machine precision. EX. Enter 1.0002 dia. and not
  243. #    1.0001 dia. with a machine accuracy of .0001.
  244. # 7) Transform subprograms are intended for use with G54... workshifts.
  245. # 8) Incremental motion at a toolchange is calculated from the values
  246. #    entered for home position.
  247. #
  248. # END_HEADER$
  249. #
  250. # --------------------------------------------------------------------------
  251. # Debugging and program switches
  252. # --------------------------------------------------------------------------
  253. m_one       :  -1   #Define constant
  254. zero        : 0     #Define constant
  255. one         : 1     #Define constant
  256. two         : 2     #Define constant
  257. three       : 3     #Define constant
  258. four        : 4     #Define constant
  259. five        : 5     #Define constant
  260. oneeighty   : 180   #Define constant
  261. c9k         : 9999  #Define constant
  262.  
  263. fastmode$    : yes$  #CD_VAR Enable Quick Post Processing, (set to no for debug)
  264. bug1$        : 2     #0=No display, 1=Generic list box, 2=Editor
  265. bug2$        : 30    #Append postline labels, non-zero is column position?
  266. #bug3$       : 0     #Append whatline no. to each NC line?
  267. bug4$        : 1     #Append NCI line no. to each NC line?
  268. whatno$      : yes$  #Do not perform whatline branches? (leave as yes)
  269. linktolvar$  : 0     #Associate X tolerance variables to V9- variable?
  270. linkplnvar$  : 0     #Associate X plane specific variables to V9- variable?
  271. linklvar$    : 0     #Associate X lathe specific variables to V9- variable?
  272.  
  273. skp_lead_flgs$ : 1   #Do NOT use v9 style contour flags
  274. get_1004$    : 0     #Find gcode 1004 with getnextop?
  275. rpd_typ_v7$  : 0     #Use Version 7 style contour flags/processing?
  276. strtool_v7$  : 2     #Use Version 7+ toolname?
  277. tlchng_aft$  : 2     #Delay call to toolchange until move line
  278. cant_tlchng$ : 1     #Ignore cantext entry on move with tlchng_aft
  279. newglobal$   : 1     #Error checking for global variables
  280. getnextop$   : 1     #Build the next variable table
  281. cc_1013$     : 1     #Read cc_pos on the 1013 line, lathe
  282.  
  283. # --------------------------------------------------------------------------
  284. # General Output Settings
  285. # --------------------------------------------------------------------------
  286. force_wcs    : yes$  #Force WCS output at every toolchange?
  287. progname$    : 1     #Use uppercase for program name
  288. css_start_rpm : yes$   #Do direct RPM spindle start prior to CSS?
  289. css_end_rpm  : yes$   #Do direct RPM spindle prior to Retract?
  290. prog_stop    : 1     #Program stop at toolchange: 0=None, 1=M01, 2 = M00
  291. tool_info    : 3     #Output tool information?
  292.                      #0 = Off - Do not output any tool comments or tool table
  293.                      #1 = Tool comments only
  294.                      #2 = Tool table only
  295.                      #3 = Tool comments and tool table
  296. use_pitch    : 0     #0 = Use feed for tapping (force Feed/Min), 1 = Use pitch for tapping (force Feed/Rev)
  297. rigid_tap    : 1     #0 = Floating tap output
  298.                      #1 = Rigid tap output (Set parameter 5200 bit 0 to 1 for rigid)
  299.                      #(Set M code for rigid tap in parameter 5210)
  300. tap_feed     : 1     #0 = 2/1 (in/mm) decimal places, 1 = 4/3 (in/mm) decimal places
  301. thread_address : 0   #Thread pitch address for lathe threading, 0 = Use F, 1 = Use E
  302. use_clamp    : 0     #0 = No, 1 = Clamp
  303. use_brake    : 0     #0 = No, 1 = Brake
  304. lathe_stop   : 1     #Stop lathe spindle on lathe tool change? 0 = no, 1 = yes
  305. drop_offset  : 0     #Drop offset at end of tool? 0 = no, 1 = yes
  306. tseqno       : 1     #Output sequence number at toolchanges when omitseq = yes
  307.                      #0=off, 1=seq numbers match toolchange number, 2=seq numbers match tool number
  308. g54g55       : 0     #0 = Use Mcam Work Offset Logic, 1 = Force G54 for main spindle and G55 for sub spindle
  309. c_resolution : 0.001 #Set your C-axis resolution.  This is used for deg/min feed calcs
  310.                      #Post must only enter pfclc_deg_inv if C motion >= to the resolution of the axis output occurs
  311. checkyflg    : yes$  #Check Y movement only once for error
  312. #cwind        : 0     #0 = No, always start the calc from 0, 1 = Yes, allow C-axis winding for axis subsitution (start at closest rev) #MU00007
  313. cc_seqno     : 0     #If using full sequence numbers engage this switch to correct all lathe sequence numbers including canned cycles.
  314. home_z       : 0     #G28 ref. return axes: 0 = Output X only, 1 = Output X and Z
  315. speedoverride: 600   #RPM override for RPM start
  316.  
  317. #Interpolation Output Settings
  318. g107crad      : 0    #0 = radius, 1 = diameter
  319. g112address   : 1    #0 = Y, 1 = C
  320.  
  321. home_type    : 2     #Work coordinate system: (home_type)
  322. #       -1 = Reference return / Tool offset positioning.
  323. #       0 = G50 with the X and Z home positions.
  324. #       1 = X and Z home positions.
  325. #       2 = WCS of G54, G55.... based on Mastercam settings.
  326.  
  327. # --------------------------------------------------------------------------
  328. # Machine Specific Settings
  329. # --------------------------------------------------------------------------
  330. #Machine axis switches, initial
  331. y_axis_mch  : no$   #SET_BY_MD - Machine has a Y axis, 0=no, 1=yes - Set based on Axis Combination in MD
  332. old_new_sw  : 1     #Switch old (6T), new (0T+) cycle formats, 0=old, 1=new
  333. wcs_origin  : 0     #Always use the WCS origin for coordinates
  334. dia_mult    : 2     #Multiplier for output on X axis (Neg. switches sign of X)
  335. y_mult      : 1     #Multiplier for output on Y axis (Neg. switches sign of Y)
  336. z_mult      : 1     #Multiplier for output on Z axis (Neg. switches sign of Z)
  337. dia_shift   : 0     #Shift for output on X axis, radial entry
  338. y_shift     : 0     #Shift for output on Y axis
  339. z_shift     : 0     #Shift for output on Z axis
  340. map_home    : yes$   #Use home positions as entered or map to machine axis
  341.  
  342. #C axis and Index switches
  343. str_cax_abs : "C"     #String address for absolute rotary axis
  344. str_cax_inc : "H"     #String address for incremental rotary axis
  345. str_index   : "B"     #String address for indexer
  346. frc_cinit   : 1     #Force C axis reset at toolchange
  347. c_shift     : 0     #Shift for output on bottom turrets with C axis
  348. ctol        : 270   #Tolerance in deg. of inc. move before 'rev' flag changes
  349. ctable      : 1     #Degrees for each index step with indexing spindle
  350. ixtol       : 0.01  #Tolerance in deg. for index error
  351. maxfrdeg    : 2000  #Limit for feed in deg/min
  352. frdegstp    : 10    #Step limit for rotary feed in deg/min
  353.  
  354. #Spindle switches and values
  355. use_gear    : 0      #Output gear selection code, 0=no, 1=yes
  356. cool_w_spd  : 0      #Output coolant with spindle code, 0=no, 1=yes - only available with V9 coolant option in MD
  357. max_speedl0 : 3000   #Maximum spindle speed (lathe), Bottom turret/Left spindle
  358. min_speedl0 : 20     #Minimum spindle speed
  359. max_speedm0 : 5000   #Maximum spindle speed (mill)
  360. min_speedm0 : 50     #Minimum spindle speed
  361. max_speedl1 : 3000   #Maximum spindle speed (lathe), Top turret/Left spindle
  362. min_speedl1 : 20     #Minimum spindle speed
  363. max_speedm1 : 5000   #Maximum spindle speed (mill)
  364. min_speedm1 : 50     #Minimum spindle speed
  365. max_speedl2 : 3000   #Maximum spindle speed (lathe), Bottom turret/Right spindle
  366. min_speedl2 : 20     #Minimum spindle speed
  367. max_speedm2 : 5000   #Maximum spindle speed (mill)
  368. min_speedm2 : 50     #Minimum spindle speed
  369. max_speedl3 : 3000   #Maximum spindle speed (lathe), Top turret/Right spindle
  370. min_speedl3 : 20     #Minimum spindle speed
  371. max_speedm3 : 5000   #Maximum spindle speed (mill)
  372. min_speedm3 : 50     #Minimum spindle speed
  373.  
  374. #Machining position turret/spindle settings
  375. # Switch strings based on turret position top/bottom-left/right and cut type.
  376. # Turret position is based on the Mastercam settings (see lathtype).
  377. # Strings are re-assigned for output in the routine psw_str_mult.
  378. # The string variable sw_string holds the place position value to determine
  379. # how to assign the strings.  Planes are relative to the view from Mastercam.
  380. # Assign the 17 digit string following the alpha columns below:
  381. # A - C axis, 1 = axis winds, 2 = axis signed, 3 = indexer
  382. # B - Spindle direction, 0 = normal, 1 = reverse
  383. # C - Plane 0 arc/comp, 0 = normal, 1 = switch
  384. # D - Plane 1 arc/comp, 0 = normal, 1 = switch
  385. # E - Plane 2 arc/comp, 0 = normal, 1 = switch
  386. # F - Plane 0, 0 = G17, 1 = G19, 2 = G18
  387. # G - Plane 1, 0 = G17, 1 = G19, 2 = G18
  388. # H - Plane 2, 0 = G17, 1 = G19, 2 = G18
  389. # Decimal (required)
  390. # I - Plane 0, X axis, 0 = normal, 1 = switch sign from basic
  391. # J - Plane 0, Y axis, 0 = normal, 1 = switch sign from basic
  392. # K - Plane 0, Z axis, 0 = normal, 1 = switch sign from basic
  393. # L - Plane 1, X axis, 0 = normal, 1 = switch sign from basic
  394. # M - Plane 1, Y axis, 0 = normal, 1 = switch sign from basic
  395. # N - Plane 1, Z axis, 0 = normal, 1 = switch sign from basic
  396. # O - Plane 2, X axis, 0 = normal, 1 = switch sign from basic
  397. # P - Plane 2, Y axis, 0 = normal, 1 = switch sign from basic
  398. # Q - Plane 2, Z axis, 0 = normal, 1 = switch sign from basic
  399. use_only_tl : 0     #Use only Top turret/Left spindle settings (below) for
  400.                     #all Mastercam turret/spindle selections
  401.                     #When configuring for multi-spindle/turret set to 0
  402.  
  403. #Columns-       ABCDEFGH.IJKLMNOPQ #Turret/Spindle            #Path Type
  404. scase_tl_c1  : "10000222.000000000"  #Top turret/Left spindle, Turning cut
  405. scase_tl_c2  : "10000012.000000000"  #Top turret/Left spindle, Right Face cut
  406. scase_tl_c_2 : "10110012.000000000"  #Top turret/Left spindle, Left Face cut
  407. scase_tl_c3  : "10010102.000000000"  #Top turret/Left spindle, Cross cut (cuttype = 3)
  408. scase_tl_c3r : "10001102.000000000"  #Top turret/Left spindle, Reverse Cross cut (cuttype = -3)
  409. scase_tl_c4c : "10000222.000000000"  #Top turret/Left spindle, Y axis subs. Cycle
  410. scase_tl_c4  : "10000122.000000000"  #Top turret/Left spindle, Y axis subs.
  411. scase_tl_c5  : "10000222.000000000"  #Top turret/Left spindle, Multisurf Rotary
  412.  
  413. #Columns-    ABCDEFGH.IJKLMNOPQ
  414. scase_bl_c1  : "10000222.000000000"  #Bottom turret/Left spindle, Turning cut
  415. scase_bl_c2  : "10000222.000000000"  #Bottom turret/Left spindle, Right Face cut
  416. scase_bl_c_2 : "10110222.000000000"  #Bottom turret/Left spindle, Left Face cut
  417. scase_bl_c3  : "10010222.000000000"  #Bottom turret/Left spindle, Cross cut (cuttype = 3)
  418. scase_bl_c3r : "10010222.000000000"  #Bottom turret/Left spindle, Reverse Cross cut (cuttype = -3)
  419. scase_bl_c4c : "10000222.000000000"  #Bottom turret/Left spindle, Y axis subs. Cycle
  420. scase_bl_c4  : "10000222.000000000"  #Bottom turret/Left spindle, Y axis subs.
  421. scase_bl_c5  : "10000222.000000000"  #Bottom turret/Left spindle, Multisurf Rotary
  422.  
  423. #Columns-    ABCDEFGH.IJKLMNOPQ
  424. scase_tr_c1  : "10000222.000000000"  #Top turret/Right spindle, Turning cut
  425. scase_tr_c2  : "10000012.000000000"  #Top turret/Right spindle, Right Face cut
  426. scase_tr_c_2 : "10110012.000000000"  #Top turret/Right spindle, Left Face cut
  427. scase_tr_c3  : "10010102.000000000"  #Top turret/Right spindle, Cross cut (cuttype = 3)
  428. scase_tr_c3r : "10001102.000000000"  #Top turret/Right spindle, Reverse Cross cut (cuttype = -3)
  429. scase_tr_c4c : "10000222.000000000"  #Top turret/Right spindle, Y axis subs. Cycle
  430. scase_tr_c4  : "10000222.000000000"  #Top turret/Right spindle, Y axis subs.
  431. scase_tr_c5  : "10000222.000000000"  #Top turret/Right spindle, Multisurf Rotary
  432.  
  433. #Columns-    ABCDEFGH.IJKLMNOPQ
  434. scase_br_c1  : "10000222.000000000"  #Bottom turret/Right spindle, Turning cut
  435. scase_br_c2  : "10000222.000000000"  #Bottom turret/Right spindle, Right Face cut
  436. scase_br_c_2 : "10110222.000000000"  #Bottom turret/Right spindle, Left Face cut
  437. scase_br_c3  : "10010222.000000000"  #Bottom turret/Right spindle, Cross cut (cuttype = 3)
  438. scase_br_c3r : "10010222.000000000"  #Bottom turret/Right spindle, Reverse Cross cut (cuttype = -3)
  439. scase_br_c4c : "10000222.000000000"  #Bottom turret/Right spindle, Y axis subs. Cycle
  440. scase_br_c4  : "10000222.000000000"  #Bottom turret/Right spindle, Y axis subs.
  441. scase_br_c5  : "10000222.000000000"  #Bottom turret/Right spindle, Multisurf Rotary
  442.  
  443. # --------------------------------------------------------------------------
  444. # Common User-defined Variable Initializations (not switches!)
  445. # --------------------------------------------------------------------------
  446. #Post Setup Variable Initializations (Generally these are not modified)
  447. sub_level$   : 1     #CD_VAR Enable automatic subprogram support
  448. breakarcs$   : 1     #CD_VAR Break arcs, 0 = no, 1 = quadrants, 2 = 180deg. max arcs
  449. arctype$     : 2     #CD_VAR arctype$, arctpeyz$, arctypxz$
  450.                      #Arc center 1=abs, 2=St-Ctr, 3=Ctr-St, 4=unsigned inc.,
  451.                      #5 = R no sign, 6 = R signed neg. over 180
  452. do_full_arc$ : 0     #CD_VAR Allow full circle output? 0=no, 1=yes
  453. helix_arc$   : 0     #CD_VAR Support helix arc output, 0=no, 1=all planes, 2=XY plane only
  454. arccheck$    : 1     #CD_VAR Convert small arcs to linear
  455. atol$        : 0.01  #CD_VAR Angularity tolerance for arccheck
  456. ltol$        : 0.002 #CD_VAR Length tolerance for arccheck
  457. vtol$        : 0.0001#System tolerance
  458. maxfeedpm    : 500   #Limit for feed in inch/min
  459. lcc_move     : 0.05  #Enter the move in X, Z for lathe canned cycle comp.
  460. vtol_m       : 0.0025#System tolerance, metric
  461. maxfeedpm_m  : 10000 #Limit for feed in mm/min
  462. lcc_move_m   : 1.25  #Enter the move in X, Z for lathe canned cycle comp.,mm
  463. spaces$      : 1     #CD_VAR Number of spaces to add between fields
  464. seqmax$      : 9999  #CD_VAR Max. sequence number
  465. nobrk$       : no$   #CD_VAR Omit breakup of x, y & z rapid moves
  466. rotaxtyp$    : 3     #Rotary axis type for toolplane
  467. tooltable$   : 3     #Read for tool table and pwrtt (3 recalls pwrtt at sof)
  468. ref_ret     : 0      #G29 / G30 return variable from Mi3
  469.  
  470. cuttype     : 0     #Flag for cut type
  471.                     #1 = Lathe
  472.                     #2 = Right face cut
  473.                     #-2 = Left face cut
  474.                     #3 = Cross cut
  475.                     #-3 = Reverse Cross cut
  476.                     #4 = Y axis substitution
  477.                     #5 = Multisurf Rotary 4 axis or 11 gcode
  478. lathtype    : 0     #Lathe turret and spindle selection
  479.                     #0 = Bottom turret/Left spindle
  480.                     #1 = Top turret/Left spindle
  481.                     #2 = Bottom turret/Right spindle
  482.                     #3 = Top turret/Right spindle
  483. lathecc     : 0     #Flag for canned turning cycle type
  484.                     #1 = G71/G72 rough cycle
  485.                     #2 = G73 pattern repeating cycle
  486.                     #3 = G74/G75 groove cycle
  487.                     #4 = Finish pass for types 1 and 2
  488.                     #Neg.=rough and finish, Pos.=rough only
  489. millcc      : 0     #Flag for mill conversion cycle type
  490. comp_type   : 0     #Cutter compensation type
  491.                     #0 = Computer
  492.                     #1 = Control
  493.                     #2 = Wear
  494.                     #3 = Reverse wear
  495.                     #4 = Off
  496. metvals     : 0     #Use inch/metric values switch in tool parameters
  497.                     #0 = inch values, 1 = metric values. Affects pitch in tapping
  498.  
  499. #Cantext activated flags
  500. bld         : 0     #Block delete active
  501. exact       : 0     #Exact stop active
  502. chute       : 0     #Toggle for part catcher operation
  503. tlstk       : 0     #Toggle for tailstock operation
  504.  
  505. #General user variables
  506. xia         : 0     #Formated absolute value for X
  507. yia         : 0     #Formated absolute value for Y
  508. zia         : 0     #Formated absolute value for Z
  509. cia         : 0     #Formated absolute value for C
  510. copy_x      : 0     #X value copy, prevent compound operations
  511. copy_y      : 0     #Y value copy, prevent compound operations
  512. copy_z      : 0     #Z value copy, prevent compound operations
  513. xa          : 0     #Absolute coordinate mapped value for X
  514. ya          : 0     #Absolute coordinate mapped value for Y
  515. za          : 0     #Absolute coordinate mapped value for Z
  516. cfeed_x     : 0     #Absolute mapped/rotated unshifted value for X
  517. cfeed_y     : 0     #Absolute mapped/rotated unshifted value for Y
  518. cfeed_z     : 0     #Absolute mapped/rotated unshifted value for Z
  519. xca         : 0     #Absolute unshifted value for XC
  520. yca         : 0     #Absolute unshifted value for YC
  521. zca         : 0     #Absolute unshifted value for ZC
  522. sav_xa      : 0     #X saved value
  523. sav_ya      : 0     #Z saved value
  524. sav_za      : 0     #Z saved value
  525. sav_xh      : 0     #X saved value
  526. sav_yh      : 0     #Z saved value
  527. sav_zh      : 0     #Z saved value
  528. start_xh    : 0
  529. start_yh    : 0
  530. start_zh    : 0
  531. sav_cc_1013 : 1     #Capture value of cc_1013 flag  # 1/17/03
  532. clamp_code  : -1    #String select variable
  533. conversion  : 12    #Unit conversion value, do not change
  534. result      : 0     #Return value for functions
  535. compok      : 1     #Flag to output cutter compensation
  536. toolchng    : 2     #On a toolchange flag
  537. toolchng0   : 2     #On a null toolchange flag
  538. plane$      :  -1   #Initialize plane
  539. ipr_actv$   :  -1   #Initialize active feed type
  540. mach_plane  : 0     #Plane mapped to machine
  541. sav_arcout  : arcoutput$ #Arc output type saved
  542. breakarcss  : 0     #saved breakarcs$ value
  543. g71type     : 0     #lathe plunge for G71 type 1 or type 2 cycle
  544. counter     : 0     #Counter
  545. nstrlen     : 0     #Length of string
  546.  
  547. #User Variables
  548. blockno:0
  549. stpgrpname : "" #20018 - Toolpath Group Name (name of operations Parent TP Group)
  550. s_grp_comm : ""
  551. s_grp_name : ""
  552. my_prog_num : 0
  553. sTL_Name : ""
  554. sTL_String : ""
  555. sTL_HolderName : ""
  556.  
  557. #User Variables for tooltable
  558. NumTool_1 : 0
  559. NumToolMin : 0
  560. NumToolMax : 999
  561. Idx_Start : 0
  562. Idx_End : 0
  563. sTool : ""
  564. stinsert : "INSERT "
  565. stinsert2 : ""
  566. stholder : "HOLDER "
  567. stholder2 : ""
  568. snocomm : "DEFINE TOOL NAME"
  569. stcustom2 : 0
  570. stcode2 : ""
  571. stplane1 : ""
  572. #storient : 0
  573.  
  574. #User Variables for custom drilling cycle
  575. drill_dist : 0 #calulate drilling distance
  576. pck_amt : 0 #peck amount
  577. pck_no : 0 #calculate no. OF PECKS
  578. drl_depth : 0 #calculate Z drill depth
  579. z_return : 0 #rapid Z dpeth
  580. rtr_hgt : 0
  581. z_calc : 0 #calulated Z depth
  582. prv_zdrill : 0 #capture previous drilled depth
  583. z_clear : 0 #Z clearance return value
  584. z_clear_val : 0 #clearance distance to previous peck
  585. z_start_pos : 0
  586. pass : -9999 #Calculate number of pecks remaining
  587. entryfeed : 0
  588. exitfeed : 0
  589. drillfeed : 0
  590. retractFeed : 0
  591.  
  592. sav_absinc  : 0     #Saved absolute/Incremental
  593. spd_rev     : 0     #Flag to reverse spindle direction
  594. sav_gcode   : 0     #Gcode saved
  595. sav_feed    : 0     #Feed saved
  596. sav_ipr     : 0     #IPR saved
  597. sav_feedcc  : 0     #Feed saved, canned cycle
  598. sav_iprcc   : 0     #IPR saved, canned cycle
  599. sav_spdir   : 0     #Spindle direction saved
  600. sav_omitsq  : 0     #Omitseq saved
  601. sav_subout  : 0     #Saved subout
  602. sav_frc_wcs : 0     #Force work offset flag saved
  603. sav_bug2    : bug2$  #Saved setting for bug2
  604. sav_cutpos2 : 0     #Patch to handle cutpos2 flag through null toolchnages
  605. sav_eob     : 0     #eob saved
  606. cir_at_zero : 0     #Arc center at centerline in XY plane, -1 if not plane 0
  607. pnt_at_zero : 0     #Position at centerline with milling
  608. c_ax_flp    : 0     #G18 plane with C axis arcs in neg. range
  609. rslt_plc    : 0     #Return value from plcval
  610. rslt_upd    : 0     #Return value from updstr
  611.  
  612. #Drilling variables
  613. drlgsel     :  -1   #Drill Select Initialize
  614. drillref    :  -1   #Select drill reference
  615. peckacel$   : 0     #Fractional percent to reduce peck2 when usecan.. : no
  616. mdrl_dir    : 0     #Mill drill direction for boolean, 0 = face, 1 = cross
  617. zdrl_x      : 0     #Drill point, mapped X
  618. zdrl_y      : 0     #Drill point, mapped Y
  619. zdrl_z      : 0     #Drill point, mapped Z
  620.  
  621. #Threading variables
  622. nstart_cnt  : 0     #Counter for multiple threads
  623. thd_vlen    : 0     #Incremental X move for G76 mult starts
  624. xmaj_thd    : 0     #X major dia. from parameters
  625. zstrt_thd   : 0     #Z start from parameters
  626. zend_thd    : 0     #Z end from parameters
  627. face_thd    : 0     #Face thread from parameters
  628.  
  629. #Spindle variables
  630. max_speed   : 0     #Maximum spindle speed (set by turret definition)
  631. min_speed   : 0     #Minimum spindle speed (set by turret definition)
  632. speedrpm    : 0     #Spindle calculation RPM
  633. g_speed     : 0     #Generic positive spindle speed (rpm or css)
  634. g_spdir     : 999   #Generic spindle direction
  635. speedx      : 0     #Test spindle calculation X position
  636. gear_spd    : 0     #Absolute value of gear speed
  637.  
  638. # Lathe canned cycle variables
  639. gcodecc     : 0     #Canned turning cycle gcode
  640. y_axis      : 0     #Flag for Y axis machining (implies over center)
  641. directcc    : 0     #Direction from parameters
  642. dopeckcc    : 0     #Do peck from groove parameters
  643. foundcc     : 0     #Return found from G70 read
  644. cc_stop_fcc : 0     #Stop output with rough only
  645. lcc_cc_pos  : 0     #Position for lathe canned cycle cutter comp. enable
  646. lccdirx     : 0     #Canned cycle X vector direction
  647. lccdirz     : 0     #Canned cycle Z vector direction
  648. lcc_xcst    : 0     #Lathe canned cycle contour start position
  649. lcc_ycst    : 0     #Lathe canned cycle contour start position
  650. lcc_zcst    : 0     #Lathe canned cycle contour start position
  651. lcc_xcend   : 0     #Lathe canned cycle contour end position
  652. lcc_ycend   : 0     #Lathe canned cycle contour end position
  653. lcc_zcend   : 0     #Lathe canned cycle contour end position
  654.  
  655. #_last variables to keep track of previous values (see plast)
  656. last_millcc  : 0     #Previous value of millcc
  657. last_op_id   : 0     #Previous value of op_id$
  658. last_cuttype : 0     #Previous value of cuttype
  659. last_spindle_no : 0  #Previous value of spindle_no$
  660.  
  661. #_flg variables
  662. interp_flg   : 0     #Interpolation output currently on
  663. clamp_flg    : 0     #Clamp curently on or off
  664. synch_flg    : 0     #Flag for synched spindle work
  665. force_flg    : 0     #Flag to indicate forced output in mtlchg0,ltlchg0
  666. rigid_tap_flg : 0    #Flag for rigid tapping
  667.  
  668. #Vector Variables for Mapping and Rotary Calculations
  669. #Lathe - Uses top matrix - initialize here
  670. m1$          : 1
  671. m5$          : 1
  672. m9$          : 1
  673.  
  674. vtoolx_rot  : 0
  675. vtooly_rot  : 0
  676. vtoolz_rot  : 0
  677.  
  678. #A rotation vector
  679. aaxisx      : 1
  680. aaxisy      : 0
  681. aaxisz      : 0
  682.  
  683. #B rotation vector
  684. baxisx      : 0
  685. baxisy      : 1
  686. baxisz      : 0
  687.  
  688. #C rotation vector
  689. caxisx      : 0
  690. caxisy      : 0
  691. caxisz      : 1
  692.  
  693.  
  694. #Mapping matrix
  695. #Home position mapping matrix
  696. hmtx1       : 1
  697. hmtx2       : 0
  698. hmtx3       : 0
  699. hmtx4       : 0
  700. hmtx5       : 1
  701. hmtx6       : 0
  702. hmtx7       : 0
  703. hmtx8       : 0
  704. hmtx9       : 1
  705.  
  706. #Cut type mapping matrix
  707. mmtx1       : 1
  708. mmtx2       : 0
  709. mmtx3       : 0
  710. mmtx4       : 0
  711. mmtx5       : 1
  712. mmtx6       : 0
  713. mmtx7       : 0
  714. mmtx8       : 0
  715. mmtx9       : 1
  716.  
  717. #Side matrix
  718. smtx1       : 0
  719. smtx2       : 1
  720. smtx3       : 0
  721. smtx4       : 0
  722. smtx5       : 0
  723. smtx6       : 1
  724. smtx7       : 1
  725. smtx8       : 0
  726. smtx9       : 0
  727.  
  728. #Cross matrix
  729. cmtx1       :  -1
  730. cmtx2       : 0
  731. cmtx3       : 0
  732. cmtx4       : 0
  733. cmtx5       : 0
  734. cmtx6       : 1
  735. cmtx7       : 0
  736. cmtx8       : 1
  737. cmtx9       : 0
  738.  
  739. #Reversed cross matrix
  740. crmtx1      : 1
  741. crmtx2      : 0
  742. crmtx3      : 0
  743. crmtx4      : 0
  744. crmtx5      : 0
  745. crmtx6      : -1
  746. crmtx7      : 0
  747. crmtx8      : 1
  748. crmtx9      : 0
  749.  
  750. #Back matrix
  751. bmtx1       : 0
  752. bmtx2       :  -1
  753. bmtx3       : 0
  754. bmtx4       : 0
  755. bmtx5       : 0
  756. bmtx6       : 1
  757. bmtx7       :  -1
  758. bmtx8       : 0
  759. bmtx9       : 0
  760.  
  761. #Axis Subs matrix
  762. amtx1       : 1
  763. amtx2       : 0
  764. amtx3       : 0
  765. amtx4       : 0
  766. amtx5       : 0
  767. amtx6       : 1
  768. amtx7       : 0
  769. amtx8       : 1
  770. amtx9       : 0
  771.  
  772. #C-axis variables for calculations
  773. one_rev     : 0     #0 = Absolute positioning with wind up, 1 = Start between 0 to 360 closest direction #MU00004
  774. c_axistype  : 0     #1 = C axis winds-up, 2 = C axis signed absolute
  775.                     #3 = index positioning (do not set here, use string)
  776. ipr_type    : 0     #Feedrate for Rotary, 0 = UPM, 1 = DPM
  777. csav        : 0     #Initial c axis result from pxyzcout call
  778. last_csav   : 0     #Initial c axis result from pxyzcout call
  779. czero_csav  : 0     #Save csav when circle at zero detected
  780. c_wnd       : 0     #Calculation for c axis position tracking (abs-wind)
  781. prvc_wnd    : 0     #Saved cout calculation from deg., this is cabs in mpfan
  782. rev         : 0     #C axis wind-up multiplier
  783. prvfrdeg    : 0     #Feedrate deg/min actual
  784. circum      : 0     #Circumference
  785. ldelta      : 0     #Linear distance for deg/min, linear
  786. cdelta      : 0     #Total linear and angular motion for deg/min
  787. cldelta     : 0     #Calculation for deg/min, linear and rotary
  788. sav_rev     : 0     #Saved revolution counter
  789. indx_out    : c9k   #Rotation direction calculation
  790. fmt     17  frdeg   #Feedrate deg/min actual
  791. fmt     20  indx_mc #Rotation direction calculation
  792.  
  793. #Coolant variables for X style coolant
  794. cant_pos     : 0    #Read from current canned text (cant_pos1 - cant_pos20)
  795. coolant_bin  : 0    #Binary value for current coolant command
  796. coolant_on   : 0    #Binary value holding the sum of all coolants currently on
  797. coolantx     : 0    #Selector variable for coolant string selector
  798. local_int    : 0    #Local variable for output of coolant off commands
  799. result2      : 0    #Return value for functions
  800. suppress     : 0    #Flag used to suppress redundant coolant on commands
  801. all_cool_off : 0    #SET_BY_MD - First coolant off command shuts off ALL coolant options
  802. v9_coolant   : 0    #SET_BY_MD - Use V9 coolant options - read from General Machine Parameters
  803.  
  804. #SET BY MD - Variables to capture parameter values - use to set post switches in pset_mach
  805. rot_axis     : 0     #Axis of rotation - 1=X, 2=Y, 3=Z
  806. rot_type     : 0     #Rotary type - 0=signed continuous, 1=signed absolute, 2=shortest direction
  807. rot_dir      : 0     #Rotary direction - CW is positive, 0 = false, 1 = true
  808. rot_index    : 0     #Index or continuous - 0 = continuous, 1 = index
  809. rot_angle    : 0     #Degrees for each index step with indexing spindle
  810. component_type : 0   #Component type: (See documentation for complete list - )
  811.                        #0 = MACHINE
  812.                        #1 = STOCK_COMPONENT
  813.                        #2 = MISC_COMPONENT
  814.                        #3 = MACHINE_BASE_COMPONENT
  815.                        #4 = LINEAR_AXIS_COMPONENT
  816.                        #5 = ROTARY_AXIS_COMPONENT
  817.                        #6 = RECT_TABLE_COMPONENT
  818.                        #12 = CHUCK_COMPONENT
  819.                        #24 = TOOL_SPINDLE_COMPONENT
  820.                        #23 = ATC_COMPONENT
  821. xpos_dir        : 0    #x Axis direction flag
  822. ypos_dir        : 0    #y Axis direction flag
  823. zpos_dir        : 0    #Z Axis direction flag
  824. axis_label   : 0     #Axis label - 1=X,2=Y,3=Z
  825. write_ops    : 0     #Write NC operation information (True/False)
  826. sof          : 1     #indicated start of file
  827.  
  828. #Plane/axis sign modifier (always 1 or -1)
  829. pl_ax_m0x   : 1
  830. pl_ax_m0y   : 1
  831. pl_ax_m0z   : 1
  832. pl_ax_m1x   : 1
  833. pl_ax_m1y   : 1
  834. pl_ax_m1z   : 1
  835. pl_ax_m2x   : 1
  836. pl_ax_m2y   : 1
  837. pl_ax_m2z   : 1
  838.  
  839. # --------------------------------------------------------------------------
  840. # Buffer definitions
  841. # --------------------------------------------------------------------------
  842. #Buffer 1, toolchange information
  843. wc1           : 1       #Initial count for write buffer 1
  844. rc1           : 1       #Initial count for read buffer 1
  845. nc1           : 2       #Initial count for read buffer 1 into next record
  846. size1         : 0       #Buffer 1 size
  847.  
  848. # Current tool information
  849. c1_gcode      : 0       #Buffer 1
  850. c1_xh         : 0       #Buffer 1
  851. c1_yh         : 0       #Buffer 1
  852. c1_zh         : 0       #Buffer 1
  853. c1_tox        : 0       #Buffer 1
  854. c1_toy        : 0       #Buffer 1
  855. c1_toz        : 0       #Buffer 1
  856. c1_cc_pos     : 0       #Buffer 1
  857. c1_tool       : 0       #Buffer 1
  858. c1_tloffno    : 0       #Buffer 1
  859. c1_maxss      : 0       #Buffer 1
  860. c1_ss         : 0       #Buffer 1
  861. c1_spdir      : 0       #Buffer 1
  862. c1_css_actv   : 0       #Buffer 1
  863. c1_fr_pos     : 0       #Buffer 1
  864. c1_ipr_actv   : 0       #Buffer 1
  865. c1_coolant    : 0       #Buffer 1
  866. c1_nextdc     : 0       #Buffer 1
  867. c1_posttype   : 0       #Buffer 1
  868. c1_cuttype    : 0       #Buffer 1
  869. c1_lathtype   : 0       #Buffer 1
  870. c1_gcodecc    : 0       #Buffer 1
  871. c1_lathecc    : 0       #Buffer 1
  872. c1_millcc     : 0       #Buffer 1
  873. c1_y_axis     : 0       #Buffer 1
  874. c1_x_min      : 0       #Buffer 1
  875. c1_x_max      : 0       #Buffer 1
  876. c1_spindle_no : 0       #Buffer 1
  877.  
  878. # Next tool information
  879. n1_gcode      : 0       #Buffer 1
  880. n1_xh         : 0       #Buffer 1
  881. n1_yh         : 0       #Buffer 1
  882. n1_zh         : 0       #Buffer 1
  883. n1_tox        : 0       #Buffer 1
  884. n1_toy        : 0       #Buffer 1
  885. n1_toz        : 0       #Buffer 1
  886. n1_cc_pos     : 0       #Buffer 1
  887. n1_tool       : 0       #Buffer 1
  888. n1_tloffno    : 0       #Buffer 1
  889. n1_maxss      : 0       #Buffer 1
  890. n1_ss         : 0       #Buffer 1
  891. n1_spdir      : 0       #Buffer 1
  892. n1_css_actv   : 0       #Buffer 1
  893. n1_fr_pos     : 0       #Buffer 1
  894. n1_ipr_actv   : 0       #Buffer 1
  895. n1_coolant    : 0       #Buffer 1
  896. n1_nextdc     : 0       #Buffer 1
  897. n1_posttype   : 0       #Buffer 1
  898. n1_cuttype    : 0       #Buffer 1
  899. n1_lathtype   : 0       #Buffer 1
  900. n1_gcodecc    : 0       #Buffer 1
  901. n1_lathecc    : 0       #Buffer 1
  902. n1_millcc     : 0       #Buffer 1
  903. n1_y_axis     : 0       #Buffer 1
  904. n1_x_min      : 0       #Buffer 1
  905. n1_x_max      : 0       #Buffer 1
  906. n1_spindle_no : 0       #Buffer 1
  907.  
  908. fbuf 1 0 28 0 0         #Buffer 1
  909. sbufname1$ = "C:\Apps\buffer1_file.txt"
  910. # --------------------------------------------------------------------------
  911. #Buffer 2, recall lathe canned turning cycle line numbers
  912. wc2           : 1       #Initial count for write buffer 2
  913. rc2           : 1       #Initial count for read buffer 2
  914. size2         : 0       #Buffer 2 size
  915.  
  916. fcc_subid     : 0       #Buffer 2
  917. fcc_ng70s     : 0       #Buffer 2
  918. fcc_ng70e     : 0       #Buffer 2
  919.  
  920. fbuf 2 0 3 0 0          #Buffer 2
  921. # --------------------------------------------------------------------------
  922. #Buffer 3, output strings for lathe canned turning cycles
  923. wc3           : 1       #Initial count for write buffer 3
  924. rc3           : 1       #Initial count for read buffer 3
  925. size3         : 0       #Buffer 3 size
  926.  
  927. string3 : ""                 #Buffer 3
  928.  
  929. fbuf 3 0 80 1 1         #Buffer 3
  930. # --------------------------------------------------------------------------
  931. #Buffer 4, used to sav X and Z initial values for lathe canned rough and finish #CRF
  932. wc4           : 1       #Initial count for write buffer 4
  933. rc4           : 1       #Initial count for read buffer 4
  934. size4         : 0       #Buffer 4 size
  935.  
  936. crf_line      : 0     #Canned cycle line number
  937. crf_xsav1     : 0     #Saved X value before lathe canned rough for use with lathe canned finish
  938. crf_zsav1     : 0     #Saved Z value before lathe canned rough for use with lathe canned finish
  939. crf_xsav2     : 0     #Saved X value before lathe canned rough for use with lathe canned finish
  940. crf_zsav2     : 0     #Saved Z value before lathe canned rough for use with lathe canned finish
  941.  
  942. fbuf 4 0 2 0 0         #Buffer 4
  943. # --------------------------------------------------------------------------
  944. size5 : 0
  945. rc5 : 1
  946. wc5 : 1
  947. fbuf 5 0 256 0 1 #Buffer 5 (string)
  948. sbufname5$ = "C:\Apps\buffer5_file.txt"
  949. # --------------------------------------------------------------------------
  950. size6 : 0
  951. rc6 : 1
  952. wc6 : 1
  953. fbuf 6 0 1 0 0 #Buffer 6 (number)
  954. sbufname6$ = "C:\Apps\buffer6_file.txt"
  955. # --------------------------------------------------------------------------
  956. #String and string selector definitions for NC output
  957. # --------------------------------------------------------------------------
  958. #Address string definitions
  959. stra        : "A"     #String for address A
  960. strc        : "C"     #String for address C
  961. strd        : "D"     #String for address D
  962. stre        : "E"     #String for address E
  963. strf        : "F"     #String for address F
  964. strh        : "H"     #String for address H
  965. stri        : "I"     #String for address I
  966. strk        : "K"     #String for address K
  967. strm        : "M"     #String for address M
  968. stro        : "O"     #String for address O
  969. strp        : "P"     #String for address P
  970. strq        : "Q"     #String for address Q
  971. stru        : "U"     #String for address U
  972. strw        : "W"     #String for address W
  973. strr        : "R"     #String for address R (radius)
  974. srminus     : "R-"    #String for address R- (minus radius)
  975. strs        : "S"     #String for address S
  976. stry        : "Y"     #String for address Y
  977. sc_minus    : "-"     #Manipulated string for signed rotary minus
  978.  
  979. #Misc Strings
  980. scomm_str   : "("
  981. scomm_end   : ")"
  982. snull       : ""      # Null character string
  983.  
  984. #String definitions
  985. sg50        : "G50"   #String for spindle clamp and work coordinate
  986.  
  987. #Cantext string definitions (spaces must be padded here)
  988. sm00        : "M0"   #String for stop
  989. sm01        : "M1"   #String for optional stop
  990. strtextno : ""           #String for cantext
  991. strcantext : ""          #String for cantext
  992.  
  993. sblank : ""              #Empty string
  994. sw_string : ""           #String for lathe turret type settings
  995. # --------------------------------------------------------------------------
  996. # Error message strings
  997. # --------------------------------------------------------------------------
  998. saxiserror  : "ERROR-WRONG AXIS OF ROTATION, ROTATE ON X AXIS OF WCS"
  999. sindxerror  : "WARNING-INDEX ANGLE DOES NOT MATCH MACHINE DEF SETTING ('INDEX ANGLE')"
  1000. ssignerror  : "WARNING-SIGNED AXIS POSITIONING MOVE OVER 360 DEGREES"
  1001. swrkserror  : "WARNING-WORK OFFSET IS CHANGED IN A SUBPROGRAM"
  1002. stoperror   : "ERROR-AXIS SUBSTITUTION MUST USE THE TOP TOOLPLANE"
  1003. scutterror  : "ERROR-A VALID CUT TYPE WAS NOT FOUND, CHECK ROTARY SETTINGS"
  1004. sfccerror   : "ERROR-MATCHING G70 FINISH PROFILE WAS NOT FOUND"
  1005. s5drlerror  : "ERROR-5 AXIS DRILLING REQUIRES LONG CYCLE ('usecan..')"
  1006. slthrmerror : "ERROR-ROTATE/MIRROR SUBPROGRAM NOT ALLOWED WITH LATHE PATH"
  1007. smilrmerror : "ERROR-ROTATE/MIRROR PROGRAM ROUTINE NOT ALLOWED"
  1008. smny50error : "ERROR-G50 AND HOME ('mi1') DOES NOT SUPPORT MULTIPLE TOOL SUBPROGRAM"
  1009. shomeserror : "ERROR-HOME ('mi1') DOES NOT SUPPORT TRANSFORM SUBPROGRAM"
  1010. symoterror  : "WARNING-Y AXIS MOTION ENCOUNTERED.  NO Y AXIS DEFINED IN MACHINE - CHECK AXIS COMBINATION"
  1011. swriteopserror : "ERROR - WRITE NC OPERATION INFORMATION MUST BE ENABLED IN CONTROL DEFINITION - SET AND REPOST"
  1012.  
  1013. # --------------------------------------------------------------------------
  1014. # General G and M Code String select tables
  1015. # --------------------------------------------------------------------------
  1016. # Strings for switch based on planes, see psw_str_mult
  1017. sxg02   : "G2"       #Circular interpolation CW
  1018. sxg03   : "G3"       #Circular interpolation CCW
  1019. # --------------------------------------------------------------------------
  1020. # Motion G code selection
  1021. sg00    : "G0"       #Rapid
  1022. sg01    : "G1"       #Linear feed
  1023. sg02    : "G2"       #Circular interpolation CW
  1024. sg03    : "G3"       #Circular interpolation CCW
  1025. sg04    : "G4"       #Dwell
  1026. sgcode : ""          #Target for string
  1027.  
  1028. fstrsel sg00 gcode$ sgcode 5 -1
  1029. # --------------------------------------------------------------------------
  1030. # Motion G code selection, plane 1
  1031. sg00_1  : "G0"       #Rapid
  1032. sg01_1  : "G1"       #Linear feed
  1033. sg02_1  : "G2"       #Circular interpolation CW
  1034. sg03_1  : "G3"       #Circular interpolation CCW
  1035. sg04_1  : "G4"       #Dwell
  1036. sgcode1 : ""         #Target for string
  1037.  
  1038. fstrsel sg00_1 gcode$ sgcode1 5 -1
  1039. # --------------------------------------------------------------------------
  1040. # Motion G code selection, plane 2
  1041. sg00_2  : "G0"       #Rapid
  1042. sg01_2  : "G1"       #Linear feed
  1043. sg02_2  : "G2"       #Circular interpolation CW
  1044. sg03_2  : "G3"       #Circular interpolation CCW
  1045. sg04_2  : "G4"       #Dwell
  1046. sgcode2 : ""         #Target for string
  1047.  
  1048. fstrsel sg00_2 gcode$ sgcode2 5 -1
  1049. # --------------------------------------------------------------------------
  1050. # Strings for switch based on planes, see psw_str_mult
  1051. sxg17   : "G17"      #XY plane code
  1052. sxg19   : "G19"      #YZ plane code
  1053. sxg18   : "G18"      #XZ plane code
  1054. swstr : ""              #Target for string
  1055.  
  1056. fstrsel sxg17 rslt_plc swstr 3 -1
  1057. # --------------------------------------------------------------------------
  1058. # Select work plane G code
  1059. sg17    : "G17"      #XY plane code
  1060. sg19    : "G19"      #YZ plane code
  1061. sg18    : "G18"      #XZ plane code
  1062. sgplane : ""            #Target string
  1063.  
  1064. fstrsel sg17 plane$ sgplane 3 -1
  1065. # --------------------------------------------------------------------------
  1066. #Select english/metric code
  1067. sg20    : "G20"      #Inch code
  1068. sg21    : "G21"      #Metric code
  1069. smetric : ""         #Target string
  1070.  
  1071. fstrsel sg20 met_tool$ smetric 2 -1
  1072. # --------------------------------------------------------------------------
  1073. #Select reference return code
  1074. sg28    : "G28"      #First reference point return
  1075. sg30    : "G30"      #Second reference point return
  1076. sg28ref : ""         #Target string
  1077.  
  1078. fstrsel sg28 ref_ret sg28ref 2 -1
  1079. # --------------------------------------------------------------------------
  1080. sg53    : "G53"      #Machine coordinate reference return
  1081. # --------------------------------------------------------------------------
  1082. # Strings for switch based on planes, see psw_str_mult
  1083. sxg41   : "G41"      #Cutter compensation left
  1084. sxg42   : "G42"      #Cutter compensation right
  1085. # --------------------------------------------------------------------------
  1086. # Cutter compensation G code selection, plane 0
  1087. sg40    : "G40"      #Cancel cutter compensation
  1088. sg41    : "G41"      #Cutter compensation left
  1089. sg42    : "G42"      #Cutter compensation right
  1090. sccomp : ""          #Target for string
  1091.  
  1092. fstrsel sg40 cc_pos$ sccomp 3 -1
  1093. # --------------------------------------------------------------------------
  1094. # Cutter compensation G code selection, plane 1
  1095. sg40_1  : "G40"      #Cancel cutter compensation
  1096. sg41_1  : "G41"      #Cutter compensation left
  1097. sg42_1  : "G42"      #Cutter compensation right
  1098. sccomp1 : ""         #Target for string
  1099.  
  1100. fstrsel sg40_1 cc_pos$ sccomp1 3 -1
  1101. # --------------------------------------------------------------------------
  1102. # Cutter compensation G code selection, plane 2
  1103. sg40_2  : "G40"      #Cancel cutter compensation
  1104. sg41_2  : "G41"      #Cutter compensation left
  1105. sg42_2  : "G42"      #Cutter compensation right
  1106. sccomp2 : ""         #Target for string
  1107.  
  1108. fstrsel sg40_2 cc_pos$ sccomp2 3 -1
  1109. # --------------------------------------------------------------------------
  1110. # Select canned cycle type, profile is direction of finish profile vector
  1111. sthdg32 : "G32"      #Cycle type G32
  1112. sthdg76 : "G76"      #Cycle type G76
  1113. sthdg92 : "G92"      #Cycle type G92
  1114. sthdg33 : "G32"      #Cycle type G32 with alternating position
  1115. sthdgcode : ""       #Target for string
  1116.  
  1117. fstrsel sthdg32 thdtype$ sthdgcode 4 -1
  1118. # --------------------------------------------------------------------------
  1119. # Select canned cycle type
  1120. sg70    : "G70"      #Cycle type G70
  1121. sg71    : "G71"      #Cycle type G71
  1122. sg72    : "G72"      #Cycle type G72
  1123. sg73    : "G73"      #Cycle type G73
  1124. sg74    : "G74"      #Cycle type G74
  1125. sg75    : "G75"      #Cycle type G75
  1126. scclgcode : ""       #Target for string
  1127.  
  1128. fstrsel sg70 gcodecc scclgcode 6 -1
  1129. # --------------------------------------------------------------------------
  1130. # Canned drill cycle string select
  1131. sg80_f  : "G83"      #drill face
  1132. sg80_fd : "G83"      #drill face w/dwell
  1133. sg81_f  : "G83"      #peck face
  1134. sg81_fd : "G83"      #peck face w/dwell
  1135. sg82_f  : "G83"      #chpbrk face
  1136. sg82_fd : "G83"      #chpbrk face w/dwell
  1137. sg83_f  : "G84"      #tap right face
  1138. sg83_fd : "G84"      #tap left face
  1139. sg84_f  : "G85"      #bore1 face
  1140. sg84_fd : "G85"      #bore1 face w/dwell
  1141. sg85_f  : "G86"      #bore2 face
  1142. sg85_fd : "G88"      #bore2 face w/dwell
  1143. sg86_f  : "G87"      #misc1 face
  1144. sg86_fd : "G87"      #misc1 face w/dwell
  1145. sg87_f  : "G8?"      #misc2 face
  1146. sg87_fd : "G8?"      #misc2 face w/dwell
  1147. sgdrillf : ""        #Target for string
  1148.  
  1149. fstrsel sg80_f drlgsel sgdrillf 16 -1
  1150. # --------------------------------------------------------------------------
  1151. sg80_c  : "G87"      #drill cross
  1152. sg80_cd : "G87"      #drill cross w/dwell
  1153. sg81_c  : "G87"      #peck cross
  1154. sg81_cd : "G87"      #peck cross w/dwell
  1155. sg82_c  : "G87"      #chpbrk cross
  1156. sg82_cd : "G87"      #chpbrk cross w/dwell
  1157. sg83_c  : "G88"      #tap right cross
  1158. sg83_cd : "G88"      #tap left cross
  1159. sg84_c  : "G89"      #bore1 cross
  1160. sg84_cd : "G89"      #bore1 cross w/dwell
  1161. sg85_c  : "G86"      #bore2 cross
  1162. sg85_cd : "G88"      #bore2 cross w/dwell
  1163. sg86_c  : "G87"      #misc1 cross
  1164. sg86_cd : "G87"      #misc1 cross w/dwell
  1165. sg87_c  : "G8?"      #misc2 cross
  1166. sg87_cd : "G8?"      #misc2 cross w/dwell
  1167. sgdrillc : ""        #Target for string
  1168.  
  1169. fstrsel sg80_c drlgsel sgdrillc 16 -1
  1170. # --------------------------------------------------------------------------
  1171. #Tapping Strings
  1172. sm129   : "M129"      #Rigid Tapping
  1173. sm128   : "M128"      #Cancel Rigid Tapping
  1174. sm122   : "M122"      #Main spindle Center rigid tap mode ON
  1175. sm123   : "M123"      #Main spindle Center rigid tap mode OFF
  1176. sm126   : "M126"      #Live Tool Rigid Tap ON
  1177. sm127   : "M127"      #Live Tool Rigid Tap OFF
  1178. # --------------------------------------------------------------------------
  1179. # Select incremental or absolute G code
  1180. sg90 : ""    #G90     #Absolute code
  1181. sg91 : ""    #G91     #Incremental code
  1182. sgabsinc : ""        #Target string
  1183.  
  1184. fstrsel sg90 absinc$ sgabsinc 2 -1
  1185. # --------------------------------------------------------------------------
  1186. # RPM/CSS code selection
  1187. sg97    : "G97"      #RPM
  1188. sg96    : "G96"      #CSS
  1189. sg9697 : ""          #Target for string
  1190.  
  1191. fstrsel sg97 css_actv$ sg9697 2 -1
  1192. # --------------------------------------------------------------------------
  1193. # Feed mode G code selection
  1194. sg98    : "G98"      #UPM
  1195. sg99    : "G99"      #UPR
  1196. sgfeed : ""          #Target for string
  1197.  
  1198. fstrsel sg98 ipr_actv$ sgfeed 2 -1
  1199. # --------------------------------------------------------------------------
  1200. # C axis cycles
  1201. sg107   : "G07.1"     #C axis cylindrical interpolation enable
  1202. sg108   : "G07.1"     #C axis cylindrical interpolation disable
  1203. sg112   : "G12.1"     #C axis face polar interpolation enable
  1204. sg113   : "G13.1"     #C axis face polar interpolation disable
  1205. # --------------------------------------------------------------------------
  1206. #Canned drill cycle reference height
  1207. sg198 : ""   #G198   #Reference at initht
  1208. sg199 : ""   #G199   #Reference at refht
  1209. sgdrlref : ""        #Target for string
  1210.  
  1211. fstrsel sg198 drillref sgdrlref 2 -1
  1212. # --------------------------------------------------------------------------
  1213. # Generate string for spindle, lathe main
  1214. sm04    : "M4"      # Spindle reverse - no coolant
  1215. sm05    : "M5"      # Spindle off     - no coolant
  1216. sm03    : "M3"      # Spindle forward - no coolant
  1217. sm14    : "M4"      # Spindle reverse - coolant
  1218. sm05c   : "M5"      # Spindle off     - coolant
  1219. sm13    : "M3"      # Spindle forward - coolant
  1220. spindle_l : ""       #Target for string
  1221.  
  1222. fstrsel sm04 g_spdir spindle_l 6 -1
  1223. # --------------------------------------------------------------------------
  1224. # Generate string for spindle, lathe sub
  1225. sm04a    : "M4"      # Spindle reverse - no coolant
  1226. sm05a    : "M5"      # Spindle off     - no coolant
  1227. sm03a    : "M3"      # Spindle forward - no coolant
  1228. sm14a    : "M4"      # Spindle reverse - coolant
  1229. sm05ca   : "M5"      # Spindle off     - coolant
  1230. sm13a    : "M3"      # Spindle forward - coolant
  1231. spindle_ls : ""       #Target for string
  1232.  
  1233. fstrsel sm04a g_spdir spindle_ls 6 -1
  1234. # --------------------------------------------------------------------------
  1235. # Generate string for spindle, lathe main and sub synch
  1236. sm04b    : "M4"      # Spindle reverse - no coolant
  1237. sm05b    : "M5"      # Spindle off     - no coolant
  1238. sm03b    : "M3"      # Spindle forward - no coolant
  1239. sm14b    : "M4"      # Spindle reverse - coolant
  1240. sm05cb   : "M5"      # Spindle off     - coolant
  1241. sm13b    : "M3"      # Spindle forward - coolant
  1242. spindle_l_synch : ""       #Target for string
  1243.  
  1244. fstrsel sm04b g_spdir spindle_l_synch 6 -1
  1245. # --------------------------------------------------------------------------
  1246. # Coolant M code selection for V9 style coolant
  1247. # Note: To enable V9 style coolant, click on the General Machine Parameters icon
  1248. #   in the Machine Definition Manager, Coolant tab, enable first check box
  1249. #   Output of V9 style coolant commands in this post is controlled by scoolant
  1250. sm09    : "M9"       #Coolant Off
  1251. sm08    : "M8"       #Coolant Flood
  1252. sm08_1  : "M8"       #Coolant Mist
  1253. sm08_2  : "M8"       #Coolant Tool
  1254. scoolant : ""        #Target for string
  1255.  
  1256. fstrsel sm09 coolant$ scoolant 4 -1
  1257. # --------------------------------------------------------------------------
  1258. # Coolant output code selection for X style coolant
  1259. # Note: To enable X style coolant, click on the General Machine Parameters icon
  1260. #   in the Machine Definition Manager, Coolant tab, disable first check box
  1261. #   Output of X style coolant commands in this post is controlled by pcan, pcan1, & pcan2
  1262. scool50    : "M8"                 #Coolant 1 on value
  1263. scool51    : "M9"                 #Coolant 1 off value
  1264. scool52    : "M7"                 #Coolant 2 on value
  1265. scool53    : "M9"                 #Coolant 2 off value
  1266. scool54    : "M88"                #Coolant 3 on value
  1267. scool55    : "M89"                #Coolant 3 off value
  1268. scool56    : "M8(Coolant4=ON)"    #Coolant 4 on value
  1269. scool57    : "M9(Coolant4=OFF)"   #Coolant 4 off value
  1270. scool58    : "M8(Coolant5=ON)"    #Coolant 5 on value
  1271. scool59    : "M9(Coolant5=OFF)"   #Coolant 5 off value
  1272. scool60    : "M8(Coolant6=ON)"    #Coolant 6 on value
  1273. scool61    : "M9(Coolant6=OFF)"   #Coolant 6 off value
  1274. scool62    : "M8(Coolant7=ON)"    #Coolant 7 on value
  1275. scool63    : "M9(Coolant7=OFF)"   #Coolant 7 off value
  1276. scool64    : "M8(Coolant8=ON)"    #Coolant 8 on value
  1277. scool65    : "M9(Coolant8=OFF)"   #Coolant 8 off value
  1278. scool66    : "M8(Coolant9=ON)"    #Coolant 9 on value
  1279. scool67    : "M9(Coolant9=OFF)"   #Coolant 9 off value
  1280. scool68    : "M8(Coolant10=ON)"   #Coolant 10 on value
  1281. scool69    : "M9(Coolant10=OFF)"  #Coolant 10 off value
  1282. scoolantx : ""                    #Target for string
  1283.  
  1284. fstrsel scool50 coolantx scoolantx 20 -1
  1285.  
  1286. #X coolant has the option - First coolant off command shuts off ALL coolant options
  1287. sall_cool_off  : "M09" #Coolant off command output with all_cool_off
  1288.  
  1289. # --------------------------------------------------------------------------
  1290. # Table rotation direction, index
  1291. sindx_cw   : "M22"    #Rotate CW code
  1292. sindx_ccw  : "M21"    #Rotate CCW code
  1293. sindx_mc : ""        #Target for string
  1294.  
  1295. fstrsel sindx_cw indx_mc sindx_mc 2 -1
  1296. # --------------------------------------------------------------------------
  1297. # C axis mode
  1298. sm23    : "M43"          #Main C axis enable
  1299. sm24    : "G99 M40"      #C axis disable
  1300. sm223   : "" #"M223"     #Sub C axis enable
  1301. sm224   : "" #"M224"     #Sub C axis disable
  1302. # --------------------------------------------------------------------------
  1303. # Tailstock M code selection
  1304. sm26    : "M28"      #Tailstock retracted
  1305. sm25    : "M25"      #Tailstock engaged
  1306. stlstk : ""          #Target for string
  1307.  
  1308. fstrsel sm26 tlstk stlstk 2 -1
  1309. # --------------------------------------------------------------------------
  1310. # Generate string for spindle, mill
  1311. sm52    : "M14"      # Spindle reverse - no coolant
  1312. sm55    : "M15"      # Spindle off     - no coolant
  1313. sm51    : "M13"      # Spindle forward - no coolant
  1314. sm54    : "M14"      # Spindle reverse - coolant
  1315. sm55c   : "M15"      # Spindle off     - coolant
  1316. sm53    : "M13"      # Spindle forward - coolant
  1317. spindle_m : ""       #Target for string
  1318.  
  1319. fstrsel sm52 g_spdir spindle_m 6 -1
  1320. # --------------------------------------------------------------------------
  1321. # Chute M code selection
  1322. sm73    : "M73"      #Chute retracted
  1323. sm74    : "M74"      #Chute engaged
  1324. schute : ""          #Target for string
  1325.  
  1326. fstrsel sm73 chute schute 2 -1
  1327. # --------------------------------------------------------------------------
  1328. #Spindle Clamping M-Codes   Main
  1329. sm89   : "M89"      #Clamp On
  1330. sm88   : "M88"      #Brake/Mid-Clamp On
  1331. sm90   : "M90"      #Clamp Off
  1332. smspdl_clmp : ""    #Target String
  1333.  
  1334. fstrsel sm89 clamp_code smspdl_clmp 3 -1
  1335. # --------------------------------------------------------------------------
  1336. #Spindle Clamping M-Codes   Sub
  1337. sm189   : "M189"      #Clamp On
  1338. sm188   : "M188"      #Brake/Mid-Clamp On
  1339. sm190   : "M190"      #Clamp Off
  1340. smspdl_clmps : ""    #Target String
  1341.  
  1342. fstrsel sm189 clamp_code smspdl_clmps 3 -1
  1343. # --------------------------------------------------------------------------
  1344. #Spindle Clamping M-Codes   main and sub synch
  1345. sm89a   : "M89 M189"     #Clamp On
  1346. sm88a   : "M88 M188"     #Brake/Mid-Clamp On
  1347. sm90a   : "M90 M190"     #Clamp Off
  1348. smspdl_clmp_synch : ""    #Target String
  1349.  
  1350. fstrsel sm89a clamp_code smspdl_clmp_synch 3 -1
  1351. # --------------------------------------------------------------------------
  1352. # Cutter Compensation Type
  1353. scomp   : "COMPUTER"
  1354. scomp1  : "CONTROL COMP"
  1355. scomp2  : "WEAR COMP"
  1356. scomp3  : "REVERSE WEAR COMP"
  1357. scomp4  : "OFF"
  1358. scomp_type : ""
  1359.  
  1360. fstrsel scomp comp_type scomp_type 5 -1
  1361. # --------------------------------------------------------------------------
  1362. # Month selector
  1363. smon0   : ""
  1364. smon1   : "JAN."
  1365. smon2   : "FEV."
  1366. smon3   : "MAR."
  1367. smon4   : "AVR."
  1368. smon5   : "MAI."
  1369. smon6   : "JUN."
  1370. smon7   : "JUL."
  1371. smon8   : "AOU."
  1372. smon9   : "SEP."
  1373. smon10  : "OCT."
  1374. smon11  : "NOV."
  1375. smon12  : "DEC."
  1376. smonth : ""
  1377.  
  1378. fstrsel smon0 month$ smonth 13 -1
  1379.  
  1380. # --------------------------------------------------------------------------
  1381. # Lathe tool orientation
  1382. stoolpos1 : "T-3" #Orient 1, Tool position 3
  1383. stoolpos2 : "T-4" #Orient 2, Tool position 4
  1384. stoolpos3 : "T-1" #Orient 3, Tool position 1
  1385. stoolpos4 : "T-2" #Orient 4, Tool position 1
  1386. stoolpos5 : "" #Orient 1, Tool position 3
  1387. stoolpos6 : "" #Orient 2, Tool position 4
  1388. stoolpos7 : "" #Orient 3, Tool position 1
  1389. stoolpos8 : "" #Orient 4, Tool position 1
  1390. sorient : ""
  1391.  
  1392. fstrsel stoolpos1 orient$ sorient 8 -1
  1393.  
  1394. # --------------------------------------------------------------------------
  1395. # Define the gear selection code
  1396. flktbl  1       3       #Lookup table definition - table no. - no. entries
  1397.         40      0       #Low gear range
  1398.         41      400     #Med gear range
  1399.         42      2250    #Hi gear range
  1400.  
  1401. # --------------------------------------------------------------------------
  1402. # Define coolant binary value for X style coolant
  1403. flktbl  2       20      #Lookup table definition - table no. - no. entries
  1404.         1       50      #Coolant 1 on value
  1405.         2       51      #Coolant 1 off value
  1406.         4       52      #Coolant 2 on value
  1407.         8       53      #Coolant 2 off value
  1408.         16      54      #Coolant 3 on value
  1409.         32      55      #Coolant 3 off value
  1410.         64      56      #Coolant 4 on value
  1411.         128     57      #Coolant 4 off value
  1412.         256     58      #Coolant 5 on value
  1413.         512     59      #Coolant 5 off value
  1414.         1024    60      #Coolant 6 on value
  1415.         2048    61      #Coolant 6 off value
  1416.         4096    62      #Coolant 7 on value
  1417.         8192    63      #Coolant 7 off value
  1418.         16384   64      #Coolant 8 on value
  1419.         32768   65      #Coolant 8 off value
  1420.         65536   66      #Coolant 9 on value
  1421.         131072  67      #Coolant 9 off value
  1422.         262144  68      #Coolant 10 on value
  1423.         524288  69      #Coolant 10 off value
  1424.  
  1425. # --------------------------------------------------------------------------
  1426. # Format statements - n=nonmodal, l=leading, t=trailing, i=inc, d=delta
  1427. # --------------------------------------------------------------------------
  1428. #Default english/metric position format statements
  1429. fs2 1   0.7 0.6     #Decimal, absolute, 7 place, default for initialize (:)
  1430. fs2 2   0.4 0.3     #Decimal, absolute, 4/3 place
  1431. fs2 3   0.4 0.3d    #Decimal, delta, 4/3 place
  1432. #Common format statements
  1433. fs2 4   1 0 1 0     #Integer, not leading
  1434. fs2 5   2 0 2 0l    #Integer, force two leading
  1435. fs2 6   3 0 3 0l    #Integer, force three leading
  1436. fs2 7   4 0 4 0l    #Integer, force four leading
  1437. fs2 9   0.1 0.1     #Decimal, absolute, 1 place
  1438. fs2 10  0.2 0.2     #Decimal, absolute, 2 place
  1439. fs2 11  0.3 0.3     #Decimal, absolute, 3 place
  1440. fs2 12  0.4 0.4     #Decimal, absolute, 4 place
  1441. fs2 13  0.5 0.5     #Decimal, absolute, 5 place
  1442. fs2 14  0.3 0.3d    #Decimal, delta, 3 place
  1443. fs2 15  0.2 0.1     #Decimal, absolute, 2/1 place
  1444. fs2 16  0 4 0 3t    #No decimal, absolute, 4 trailing
  1445. #Default english/metric feed format statements
  1446. fs2 17  0.2 0.1     #Decimal, absolute, 2/1 place
  1447. fs2 18  0.4 0.3     #Decimal, absolute, 4/3 place
  1448. fs2 19  0.5 0.4     #Decimal, absolute, 5/4 place
  1449. fs2 20  1 0 1 0n    #Integer, forced output
  1450. fs2 28  3 09 3 09   #Output for rounding peck values
  1451. fs2 25  1.4 1.3lt   #Decimal, absolute, 4/3 trailing
  1452. fs2 26  0 4 0 4lt   #Integer, absolute, 0/4 leading/trailing
  1453. fs2 27  0 4 0 3lt   #No decimal, absolute, 4 trailing
  1454.  
  1455. # These formats used for 'Date' & 'Time'
  1456. fs2 21  2.2 2.2lt    #Decimal, force two leading & two trailing (time2)
  1457. fs2 22  2 0 2 0t     #Integer, force trailing                   (hour)
  1458. fs2 23  0 2 0 2lt    #Integer, force leading & trailing         (min)
  1459.  
  1460. # This format statement is used for sequence number output
  1461. # Number of places output is determined by value for "Increment Sequence Number" in CD
  1462. # Max depth to the right of the decimal point is set in the fs statement below
  1463. fs2 24  0^7 0^7      #Decimal, 7 place, omit decimal if integer value
  1464.  
  1465. # --------------------------------------------------------------------------
  1466. # Toolchange / NC output Variable Formats
  1467. # --------------------------------------------------------------------------
  1468. fmt 4 my_prog_num #tool group program number format
  1469. fmt  "OP" 4 blockno
  1470. fmt  "T" 7  toolno      #Tool number
  1471. fmt  "G" 4  g_wcs       #WCS G address
  1472. fmt  "P" 4  p_wcs       #WCS P address
  1473. fmt  "S" 4  speed       #Spindle Speed
  1474. fmt  "M" 4  gear        #Gear range
  1475. fmt  "S" 4  maxss$       #RPM spindle speed
  1476. # --------------------------------------------------------------------------
  1477. fmt  "N" 24  n$           #Sequence number
  1478. fmt  "X" 2  xabs        #X position output
  1479. fmt  "Y" 2  yabs        #Y position output
  1480. fmt  "Z" 2  zabs        #Z position output
  1481. fmt  "U" 3  xinc        #X position output
  1482. fmt  "V" 3  yinc        #Y position output
  1483. fmt  "W" 3  zinc        #Z position output
  1484. fmt  "C" 11 cabs        #C axis position
  1485. fmt  "H" 14 cinc        #C axis position
  1486. fmt  "C" 11 cout_a      #C axis position
  1487. fmt  "H" 14 cout_i      #C axis position
  1488. fmt  "B" 4  indx_out    #Index position
  1489. fmt  "I" 3  iout        #Arc center description in X
  1490. fmt  "J" 3  jout        #Arc center description in Y
  1491. fmt  "K" 3  kout        #Arc center description in Z
  1492. fmt  "R" 2  arcrad$      #Arc Radius
  1493. fmt  "F" 18 feed        #Feedrate
  1494. fmt  "P" 16 dwell$       #Dwell
  1495. fmt  "M" 5  cantext$     #Default cantext
  1496. fmt  "C" 2  crad        #C axis start radius, G107
  1497. fmt      2  xa          #Absolute coordinate mapped value for X
  1498. fmt      2  ya          #Absolute coordinate mapped value for Y
  1499. fmt      2  za          #Absolute coordinate mapped value for Z
  1500. # --------------------------------------------------------------------------
  1501. #Move comment (pound) to output colon with program numbers
  1502. fmt  "O" 7  progno$      #Program number
  1503. #fmt ":" 7   progno$      #Program number
  1504. fmt  "O" 7  main_prg_no$ #Program number
  1505. #fmt ":" 7   main_prg_no$ #Program number
  1506. fmt  "O" 7  sub_prg_no$  #Program number
  1507. #fmt ":" 7   sub_prg_no$  #Program number
  1508. fmt  "U" 2  sub_trnsx$   #Rotation point
  1509. fmt  "V" 2  sub_trnsy$   #Rotation point
  1510. fmt  "W" 2  sub_trnsz$   #Rotation point
  1511. # --------------------------------------------------------------------------
  1512. # Drill output
  1513. # --------------------------------------------------------------------------
  1514. fmt  "R" 2  refht_a     #Reference height
  1515. fmt  "R" 2  refht_i     #Reference height
  1516. fmt  "X" 2  initht_x    #Initial height, mapped X
  1517. fmt     2   initht_y    #Initial height, mapped Y
  1518. fmt  "Z" 2  initht_z    #Initial height, mapped Z
  1519. fmt  "X" 2  refht_x     #Reference height, mapped X
  1520. fmt     2   refht_y     #Reference height, mapped Y
  1521. fmt  "Z" 2  refht_z     #Reference height, mapped Z
  1522. fmt  "X" 2  depth_x     #Depth, mapped X
  1523. fmt     2   depth_y     #Depth, mapped Y
  1524. fmt  "Z" 2  depth_z     #Depth, mapped Z
  1525. fmt  "Q" 16  peck1$     #First peck increment (positive)
  1526. fmt     2   peck2$      #Second or last peck (positive)
  1527. fmt  "R" 2  peckclr$    #Safety distance
  1528. fmt     2   retr$       #Retract height
  1529. fmt  "Q" 16 shftdrl$    #Fine bore tool shift
  1530. fmt  "F" 2  pitch       #Tap pitch (inches per thread)
  1531. # --------------------------------------------------------------------------
  1532. # Thread output
  1533. # --------------------------------------------------------------------------
  1534. fmt  "P" 26  thddepth$    #Thread height absolute
  1535. fmt  "Q" 27  thdfirst$    #First depth cut in thread
  1536. fmt  "Q" 27  thdlast$     #Last depth cut in thread
  1537. fmt  "R" 2  thdfinish$   #G76 thread finish allowance
  1538. fmt  "R" 3  thdrdlt     #Thread R delta G92 and G76
  1539. fmt  "U" 3  thd_dirx    #Incremental X move for G76 mult starts
  1540. fmt  "W" 3  thd_dirz    #Incremental Z move for G76 mult starts
  1541. fmt  "P" 5  nspring$     #Number of spring cuts
  1542. fmt     5   thdpull     #G76 thread pull off
  1543. fmt     5   thdang      #G76 threading angle
  1544. # --------------------------------------------------------------------------
  1545. # Canned cycle output format (do not change order, used by buffer 2)
  1546. # --------------------------------------------------------------------------
  1547. fmt  "U" 2  depthcc
  1548. fmt  "R" 2  clearcc
  1549. fmt  "U" 2  xstckcc
  1550. fmt  "W" 2  zstckcc
  1551. fmt  "R" 4  ncutscc
  1552. fmt     2   stepcc
  1553. fmt  "P" 4  ng70s       #P line number in canned cycle
  1554. fmt  "Q" 4  ng70e       #Q line number in canned cycle
  1555. fmt  "U" 2  g73x        #Stored offset of canned cycle rough cut G73
  1556. fmt  "V" 2  g73y        #Stored offset of canned cycle rough cut G73
  1557. fmt  "W" 2  g73z        #Stored offset of canned cycle rough cut G73
  1558. fmt  "P" 2  grvspcc
  1559. fmt  "Q" 2  grvdpcc
  1560. # --------------------------------------------------------------------------
  1561. fmt "T" 4 tnote
  1562. fmt "OFFSET, "    4   toffnote    # Note format "OFFSET: "
  1563. fmt "DIA, "      1   tldianote   # Note format
  1564. fmt  "D" 25 tldia$                # Note format
  1565. fmt  "R" 25 tcr$                  # Note format
  1566. # --------------------------------------------------------------------------
  1567. fmt     4   year2       #Calculated year value
  1568. fmt     21  time2       #Capture 24-hour time value into 'time2' variable
  1569. fmt     22  hour        #Hour
  1570. fmt     23  min         #Minutes
  1571. year2 = year$ + 2000
  1572. # --------------------------------------------------------------------------
  1573. #User added formating
  1574. fmt "F" 2 retractFeed
  1575. fmt "F" 2 entryfeed
  1576. fmt "F" 2 exitfeed
  1577. fmt "F" 2 drillfeed
  1578.  
  1579. fmt 2 drill_dist
  1580. fmt 2 pck_amt
  1581. fmt 28 pck_no
  1582. fmt Z 2 drl_depth
  1583. fmt Z 2 z_return
  1584. fmt Z 2 rtr_hgt
  1585. fmt 2 z_calc
  1586. fmt 2 prv_zdrill
  1587. fmt Z 2 z_clear
  1588. fmt 2 z_clear_val
  1589. fmt Z 2 z_start_pos
  1590.  
  1591. # --------------------------------------------------------------------------
  1592. # Parameter information lookup tables, see pparameter
  1593. # --------------------------------------------------------------------------
  1594. fprmtbl 1 5 #Rough cut parameters
  1595.         13343 depthcc
  1596.         10407 clearcc
  1597.         10202 xstckcc
  1598.         10203 zstckcc
  1599.         10214 directcc
  1600.  
  1601. fprmtbl 2 4 #Finish cut parameters
  1602.         13341 ncutscc
  1603.         10101 depthcc
  1604.         10102 xstckcc
  1605.         10103 zstckcc
  1606.  
  1607. fprmtbl 3 5 #Groove cut parameters
  1608.         13358 stepcc
  1609.         13138 directcc
  1610.         13352 dopeckcc
  1611.         10316 depthcc
  1612.         13364 clearcc
  1613.  
  1614. fprmtbl 104 4 #Thread cut parameters
  1615.         10811 xmaj_thd
  1616.         10813 zstrt_thd
  1617.         10814 zend_thd
  1618.         10819 face_thd
  1619.  
  1620. fprmtbl 17000   7   #Table Number, Size - Machine Definition parameter table
  1621.         17391   axis_label   #Axis label - 1=X,2=Y,3=Z
  1622.         17402   rot_dir      #Rotary direction
  1623.         17408   rot_index    #Index or continuous
  1624.         17409   rot_angle    #Index step
  1625.         17410   rot_type     #Rotary type
  1626.         17101   all_cool_off #First coolant off command shuts off ALL coolant options
  1627.         17102   v9_coolant   #Use V9 coolant option
  1628.  
  1629. # Control Definition Parameters
  1630. fprmtbl 18000   1    #Table Number, Size
  1631. #       Param   Variable to load value into
  1632.         18171   write_ops    #Enable write NC operation information
  1633.  
  1634. pparameter$      #Information from parameters
  1635.       #"pwrttparam", ~prmcode$, ~sparameter$, e$
  1636.       if prmcode$ = 15145, metvals   = rpar(sparameter$,1)
  1637.       if prmcode$ = 15346, comp_type = rpar(sparameter$,1)
  1638.       if prmcode$ = 20103, stinsert2 = sparameter$
  1639.       if prmcode$ = 20110, stholder2 = sparameter$
  1640.       if prmcode$ = 10124, g71type = rpar(sparameter$,1)
  1641.       if prmcode$ = 10042, my_prog_num = rpar(sparameter$, 1)
  1642.       #if prmcode$ = 20018, stpgrpname = ucase(sparameter$)
  1643.       result = fprm (abs(lathecc))
  1644.  
  1645. # --------------------------------------------------------------------------
  1646. pset_mach       #Set post switches by reading machine def parameters
  1647.       #Reset variables prior to MD read
  1648.       y_axis_mch = no$    #Reset to zero - Set from Axis Combination
  1649.  
  1650.       rd_mch_ent_no$ = syncaxis$  #Retrieve machine parameters based on current axis combination - read from .nci G950 line
  1651.       rd_md$       #Read machine definition parameters - calls pmachineinfo$
  1652.  
  1653.       #We only need these set at toolchange (and start of file).  No need to set them each time a user may call rd_md
  1654.       if rot_angle = zero, ctable = one #ctable zero will produce a divide by zero error, so force to one if zero in MD
  1655.         else, ctable = rot_angle
  1656.  
  1657. pfn #mcam operation numbers
  1658.       blockno = opinfo(15240,0)
  1659.       if op_id$ <> prv_op_id$ & blockno <> -99999,
  1660.         [
  1661.         *blockno
  1662.         ]
  1663.  
  1664. # --------------------------------------------------------------------------
  1665. # Tool Comment / Manual Entry Section
  1666. # --------------------------------------------------------------------------
  1667. ptoolcomment    #Comment for tool
  1668.       if tool_info = 1 | tool_info = 3,
  1669.         [
  1670.         tnote = abs(t$)
  1671.         toffnote = tloffno$
  1672.         strtool$ = ucase(strtool$)
  1673.         stinsert2 = ucase(stinsert2)
  1674.         !spaces$
  1675.         spaces$ = zero
  1676.         if posttype$ = two, # Lathe toolpath operation
  1677.           [
  1678.           if tool_op$ = 64, # Drill operation
  1679.           scomm_str, *strtool$, scomm_end, e$
  1680.           else,
  1681.             if stinsert2 = snull,
  1682.             scomm_str, *strtool$, scomm_end, e$
  1683.             else,
  1684.           #scomm_str, *strtool$, " ", *stinsert, *stinsert2, scomm_end, e$
  1685.           #keeping it super simple
  1686.           scomm_str, *strtool$, scomm_end, e$
  1687.          ]
  1688.         else, scomm_str, *strtool$, scomm_end, e$    # Mill toolpath operation
  1689.         #scomm_str, *tnote, " ", *toffnote, scomm_end, e$
  1690.         spaces$ = prv_spaces$
  1691.         ]
  1692.  
  1693. pcomment$       #Comment from manual entry (must call pcomment2)
  1694.       pcomment2
  1695.  
  1696. pcomment2       #Output Comment from manual entry
  1697.       scomm$ = ucase (scomm$)
  1698.       !spaces$
  1699.       spaces$ = zero
  1700.      
  1701.       if gcode$ = 1005, #Manual entry - as comment
  1702.         [
  1703.         if scomm$ = "SPACE", " ", e$
  1704.         else, scomm_str, scomm$, scomm_end, e$
  1705.         spaces$ = prv_spaces$
  1706.         ]
  1707.  
  1708.       if gcode$ = 1006, #Manual entry - as code
  1709.         [
  1710.         if scomm$ = "SPACE", " ", e$
  1711.         else,
  1712.         scomm$, e$
  1713.         ]
  1714.  
  1715.       if gcode$ = 1007, scomm_str, scomm$, scomm_end      #Manual entry - as comment with move NO e$
  1716.       if gcode$ = 1026, scomm$                            #Manual entry - as code with move NO e$
  1717.      
  1718.       if gcode$ = 1008, #Operation comment
  1719.         #*n$, scomm_str, *pfn, ",", scomm$, scomm_end, e$
  1720.         *n$, scomm_str, scomm$, scomm_end, e$
  1721.        
  1722.       if gcode$ = 1054, scomm_str, scomm$, scomm_end, e$  #File Descriptor
  1723. #      if toolchng,
  1724. #        [
  1725. #        if gcode$ = 1051, scomm_str, scomm$, scomm_end, e$  #Machine name
  1726. #        if gcode$ = 1052, scomm_str, scomm$, scomm_end, e$  #Group comment
  1727. #        if gcode$ = 1053, scomm_str, scomm$, scomm_end, e$  #Group name
  1728. #        ]
  1729.       spaces$ = prv_spaces$
  1730.      
  1731. pGroupComment
  1732.         spaces$ = zero
  1733.         sTL_Name = groupinfo(19111)
  1734.         sTL_String = sTL_Name
  1735.         while zero <> strstr(";", sTL_Name) | zero <> strstr(no2asc(13), sTL_Name),
  1736.         [
  1737.             if zero <> strstr(";", sTL_Name), sTL_HolderName = brksps((strstr(";", sTL_Name)), sTL_Name)
  1738.             else, sTL_HolderName = brksps((strstr(no2asc(13), sTL_Name)), sTL_Name)
  1739.             sTL_String = sTL_Name
  1740.             sTL_Name = sTL_HolderName
  1741.            
  1742.             #Remove semicolon
  1743.             if strstr(";", sTL_Name) = one,
  1744.             [
  1745.                 sTL_Name = brksps(two, sTL_HolderName)
  1746.                 sTL_HolderName = sTL_Name
  1747.             ]
  1748.            
  1749.             #Remove EOB
  1750.             if strstr(no2asc(13), sTL_Name) = one,
  1751.             [
  1752.                 sTL_Name = brksps(three, sTL_HolderName)
  1753.                 sTL_HolderName = sTL_Name
  1754.             ]
  1755.            
  1756.             #Output current line from Group comment
  1757.             scomm_str, sTL_String, scomm_end, e$
  1758.         ]
  1759.         #Output last line
  1760.         if strlen(sTL_Name) <> zero, scomm_str, sTL_Name, scomm_end, e$
  1761.         spaces$ = prv_spaces$
  1762.  
  1763. # --------------------------------------------------------------------------
  1764. # Start of File and Toolchange Setup
  1765. # --------------------------------------------------------------------------
  1766. ptime           #Convert 24-hour time format into 12-hour AM/PM format
  1767.       if time$ >= 13, time2 = (time$ - 12)
  1768.       else, time2 = time$
  1769.       hour = int(time2), min = frac(time2)
  1770.       *hour, ":", *min,
  1771.       if time$ > 12, " PM"
  1772.       else, " AM"
  1773.  
  1774. pheader_custom         #Start of file
  1775.       "%", e$
  1776.       !spaces$
  1777.       spaces$ = zero
  1778.       *progno$, " ", scomm_str, sprogname$, scomm_end, e$
  1779.       s_grp_name = groupinfo(19248) #machine group name
  1780.       scomm_str, "P/N, ", s_grp_name, scomm_end, e$
  1781.       if my_prog_num <> 0, pbld, scomm_str, "OP, ", my_prog_num, scomm_end, e$
  1782.       #if stpgrpname <> snull, pbld, n$, scomm_str, "OP, ", stpgrpname, scomm_end, e$
  1783.       pGroupComment
  1784.       " ", e$
  1785.       spaces$ = 0
  1786.       scomm_str, "MACHOIRES, ", scomm_end, e$
  1787.       scomm_str, "PRESSION, ", scomm_end, e$
  1788.       #*progno$, " ", scomm_str, *smcname$, scomm_end, e$
  1789.       #scomm_str, "PROGRAM NAME - ", sprogname$, scomm_end, e$
  1790.       #scomm_str, "DATE=DD-MM-YY - ", date$, " TIME=HH:MM - ", time$, scomm_end, e$ #Date and time output Ex. 12-02-05 15:52
  1791.       #scomm_str, "DATE - ", month$, "-", day$, "-", year$, scomm_end, e$  #Date output as month,day,year - Ex. 02-12-05
  1792.       #scomm_str, "DATE - ", *smonth, " ", day$, " ", *year2, scomm_end, e$ #Date output as month,day,year - Ex. Feb. 12 2005
  1793.       #scomm_str, "TIME - ", time$, scomm_end, e$  #24 hour time output - Ex. 15:52
  1794.       #scomm_str, "TIME - ", ptime, scomm_end, e$  #12 hour time output 3:52 PM
  1795.       #spathnc$ = ucase(spathnc$)
  1796.       #smcname$ = ucase(smcname$)
  1797.       #stck_matl$ = ucase(stck_matl$)
  1798.       #snamenc$ = ucase(snamenc$)
  1799.       #scomm_str, "PROGRAMMER PAR ,,, DERNIERE UTILISATION LE,,,, PAR ,,,", scomm_end, e$
  1800.       #scomm_str, "MCX FILE - ", *smcpath$, *smcname$, *smcext$, scomm_end, e$
  1801.       #scomm_str, "NC FILE - ", *spathnc$, *snamenc$, *sextnc$, scomm_end, e$
  1802.       #scomm_str, "MATERIEL:", *stck_matl$, scomm_end, e$
  1803.       #scomm_str, "POST DEV - ", *slicense, scomm_end, e$
  1804.       " ", e$
  1805.       spaces$ = prv_spaces$
  1806.       !sub_seq_typ$
  1807.  
  1808. lsof0$           #Start of file for tool zero, lathe
  1809.       lsof$
  1810.  
  1811. lsof$            #Start of file for non-zero tool number, lathe
  1812.       last_op_id = 0
  1813.       speed = max_speedl1
  1814.       sav_cc_1013 = cc_1013$                                   # 1/17/03
  1815.       pRead_buf
  1816.       " ", e$
  1817.       pbld, n$, "G0 G54 G20 G40 G80 G99" e$
  1818.       pbld, n$, sg50, speed, e$
  1819.       pbld, n$, *sg28ref, "U0.", e$
  1820.       pbld, n$, *sg28ref, "W0.", e$
  1821.       pbld, n$, sm01 e$
  1822.       " ", *e$
  1823.       ltlchg$
  1824.  
  1825. msof0$           #Start of file for tool zero, mill
  1826.       msof$
  1827.  
  1828. msof$            #Start of file for non-zero tool number, mill
  1829.       last_op_id = 0
  1830.       speed = max_speedl1
  1831.       pRead_buf
  1832.       " ", e$
  1833.       pbld, n$, "G0 G54 G20 G40 G80 G99" e$
  1834.       pbld, n$, sg50, speed, e$
  1835.       pbld, n$, *sg28ref, "U0.", e$
  1836.       pbld, n$, *sg28ref, "W0.", e$
  1837.       pbld, n$, sm01 e$
  1838.       " ", *e$
  1839.       mtlchg$
  1840.  
  1841. ltlchg$          #Toolchange, lathe
  1842.       toolchng = one
  1843.       gcode$ = zero
  1844.       copy_x = vequ(x$)
  1845.       pcc_capture   #Capture LCC ends, stop output RLCC
  1846.       c_rcc_setup$   #Save original in sav_xa and shift copy_x for LCC comp.
  1847.       pcom_moveb    #Get machine position, set inc. from c1_xh
  1848.       c_mmlt$        #Position multi-tool sub, sets inc. current if G54...
  1849.       comment$
  1850.       toolno = t$ * 100 + tloffno$
  1851.       if not(synch_flg & tool_op$ = 67),     #Suppress tool output if cutoff during part xfer
  1852.         [
  1853.         if omitseq$ = 1 & tseqno > 0,
  1854.           [
  1855.           if tseqno = 2, n$ = t$
  1856.           pbld, [if home_type = -1, *sgcode], *toolno
  1857.           #pbld, *n$, [if home_type = -1, *sgcode], *toolno
  1858.           ]
  1859.         else, pbld, [if home_type = -1, *sgcode], *toolno
  1860.         #else, pbld, n$, [if home_type = -1, *sgcode], *toolno
  1861.         ptoolcomment
  1862.         ]
  1863.       if home_type < two, #Toolchange G50/home/reference position
  1864.         [
  1865.         sav_xh = vequ(copy_x)
  1866.         sav_absinc = absinc$
  1867.         absinc$ = zero
  1868.         start_xh = vequ(xh$)
  1869.         pmap_home   #Get home position, xabs
  1870.         ps_inc_calc #Set start position, not incremental
  1871.         #Toolchange home position
  1872.         if home_type = one,
  1873.           pbld, n$, *sgcode, pwcs, pfxout, pfyout, pfzout, e$
  1874.         else,
  1875.           [
  1876.           #Toolchange g50 position
  1877.           pbld, n$, *sg28ref, "U0.", [if y_axis_mch, "V0."], e$
  1878.           if home_z, pbld, n$, *sg28ref, "W0.", e$
  1879.           if home_type = zero, pbld, n$, *sg50, pfxout, pfyout, pfzout, e$
  1880.           ]
  1881.         pe_inc_calc #Update previous
  1882.         absinc$ = sav_absinc
  1883.         copy_x = vequ(sav_xh)
  1884.         ]
  1885.       else,
  1886.         [
  1887.         pbld, n$, pwcs
  1888.         ]
  1889.       ipr_actv$ = c1_ipr_actv
  1890.       pfsgplane, pfsgfeed, e$
  1891.       #pbld, n$, pfsgplane, [if sof = 0, pfsgfeed], e$
  1892.       sof = 0
  1893.       #pcaxis_off_l  #Postblock for lathe transition
  1894.       pcom_moveb    #Reset machine position, set inc. from last position
  1895.       pcan
  1896.       pspindle
  1897.       #Added for 'css_start_rpm' logic (09/05/01)
  1898.       if css_actv$,
  1899.         [
  1900.         if css_start_rpm,
  1901.           prpm # Direct RPM startup for programmed CSS
  1902.         else,
  1903.           pcssg50, pcss # NO RPM start - just output the CSS
  1904.         ]
  1905.       else, # Direct RPM was programmed
  1906.         [
  1907.         prpm # Output programmed RPM
  1908.         ]
  1909.       sav_absinc = absinc$
  1910.       if home_type > one, absinc$ = zero
  1911.       if tool_op$ <> 216,
  1912.       [
  1913.       pcan1, pbld, n$, *sgcode, pfzout, e$
  1914.       pbld, n$, *sgcode, pfxout, pyout, pscool, strcantext, e$
  1915.       ]
  1916.       if lcc_cc_pos, plcc_cc_pos  #Use sav_xa to position with comp. LCC
  1917.       pcom_movea    #Update previous, pcan2
  1918.       ps_inc_calc   #Reset current
  1919.       absinc$ = sav_absinc
  1920.       #Added for 'css_start_rpm' logic (09/05/01)
  1921.       if css_start_rpm, pcssg50, pcss #CSS output AFTER a G97S???? RPM spindle startup
  1922.       c_msng$        #Position single-tool sub, sets inc. current if G54...
  1923.       toolchng = zero
  1924.       plast
  1925.  
  1926. mtlchg$          #Toolchange, mill
  1927.       toolchng = one
  1928.       gcode$ = zero
  1929.       copy_x = vequ(x$)
  1930.       pcom_moveb    #Get machine position, set inc. from c1_xh
  1931.       c_mmlt$        #Position multi-tool sub, sets inc. current if G54...
  1932.       comment$
  1933.       #ptoolcomment
  1934.      
  1935.       if opcode$ = 3 | opcode$ = 16, toolno = t$ * 100 + tlngno$
  1936.       else, toolno = t$ * 100 + tloffno$
  1937.       if omitseq$ = 1 & tseqno > 0,
  1938.         [
  1939.         if tseqno = 2, n$ = t$
  1940.         pbld, [if home_type = -1, *sgcode], *toolno, ptoolcomment
  1941.         ]
  1942.       else, n$, [if home_type = -1, *sgcode], *toolno, ptoolcomment
  1943.      
  1944.     if home_type < two, #Toolchange G50/home/reference position
  1945.         [
  1946.         sav_xh = vequ(copy_x)
  1947.         sav_absinc = absinc$
  1948.         absinc$ = zero
  1949.         start_xh = vequ(xh$)
  1950.         pmap_home   #Get home position, xabs
  1951.         ps_inc_calc #Set start position, not incremental
  1952.        
  1953.         #Toolchange home position
  1954.         if home_type = one,
  1955.           pbld, n$, *sgcode, pwcs, pfxout, pfyout, pfzout, e$
  1956.         else,
  1957.           [
  1958.           #Toolchange g50 position/reference
  1959.           pbld, n$, *sg28ref, "U0.", [if y_axis_mch, "V0."], e$
  1960.           if home_z, pbld, n$, *sg28ref, "W0.", e$
  1961.           if home_type = zero, pbld, n$, *sg50, pfxout, pfyout, pfzout, e$
  1962.           ]
  1963.         pe_inc_calc #Update previous
  1964.         absinc$ = sav_absinc
  1965.         copy_x = vequ(sav_xh)
  1966.         ]
  1967.       else,
  1968.         [
  1969.         pbld, n$, pwcs
  1970.         ]
  1971.  
  1972.       pfsgplane, pfsgfeed, e$
  1973.       pcom_moveb    #Reset machine position, set inc. from last position
  1974.       pcaxis_on_m   #Postblock for mill transition
  1975.       pspindle
  1976.       prpm
  1977.       pcan
  1978.       sav_absinc = absinc$
  1979.       if home_type > one, absinc$ = zero
  1980.       pbld, n$, pclampoff, e$        # Unclamp
  1981.       if millcc,
  1982.         [
  1983.         cabs = 0
  1984.         pbld, n$, *sgcode, pfcout, [if y_axis_mch, "Y0."], e$
  1985.         ]
  1986.       else,
  1987.         [
  1988.         prv_gcode$ = c9k                  #change modality for forced output
  1989.         pbld, n$, `sgcode, pfcout, e$     #` used in case indexing mode
  1990.         ]
  1991.       pindex
  1992.       pbld, n$, pclampbrake, e$  # Clamp
  1993.       pcan1, pbld, n$, *sgcode, pfzout, e$
  1994.       pbld, n$, pfxout, pfyout, pscool, strcantext, e$
  1995.       pcom_movea    #Update previous, pcan2
  1996.       ps_inc_calc   #Reset current
  1997.       absinc$ = sav_absinc
  1998.       c_msng$        #Position single-tool sub, sets inc. current if G54...
  1999.       toolchng = zero
  2000.       if millcc, pmillccb #Set mill conversion
  2001.       plast
  2002.  
  2003. ltlchg0$         #Call from NCI null tool change, lathe
  2004.       toolchng0 = one
  2005.       copy_x = vequ(x$)
  2006.       start_xh = vequ(xh$)
  2007.       c_rcc_setup$   #Save original in sav_xa and shift copy_x for LCC comp.
  2008.       pcom_moveb    #Get machine position, set inc. from last position
  2009.       c_mmlt$        #Position multi-tool sub, sets inc. current if G54...
  2010.       comment$
  2011.       pcan
  2012.       toolno = t$ * 100 + tloffno$
  2013.       if home_type = -1,
  2014.         [
  2015.         prv_gcode$ = c9k
  2016.         pbld, n$, `sgcode, toolno, e$
  2017.         ]
  2018.       else, pbld, n$, toolno, e$
  2019.       pbld, n$, psgplane, e$
  2020.       #pcaxis_off_l  #Postblock for lathe transition
  2021.       pspindle
  2022.       pnullspindle
  2023.       pbld, n$, pscool,e$
  2024.       force_flg = 0
  2025.       if not(g54g55) & home_type > one & workofs$ <> prv_workofs$, force_flg = 1
  2026.       if spindle_no$ <> last_spindle_no, force_flg = 1
  2027.       if force_flg,
  2028.         [
  2029.         sav_absinc = absinc$
  2030.         absinc$ = zero
  2031.         pbld, n$, pwcs, e$
  2032.         pbld, n$, psgcode, pfzout, e$
  2033.         pbld, n$, psgcode, pfxout, pfyout, e$
  2034.         pe_inc_calc #Update previous
  2035.         ps_inc_calc #Set current inc.
  2036.         absinc$ = sav_absinc
  2037.         ]
  2038.       #Output cutter comp before each finish pass of           # 1/17/03
  2039.       #finishing groove canned cyle                            # 1/17/03
  2040.       if gcode$ = one, plinout                                 # 1/17/03
  2041.       else,                                                    # 1/17/03
  2042.         [                                                      # 1/17/03
  2043.         if lathecc = 3, pbld, n$, sccomp, e$                   # 1/17/03
  2044.         if tool_op$ = 201, !cc_pos$                            # 5/28/04
  2045.         prapidout                                              # 1/17/03
  2046.         ]                                                      # 1/17/03
  2047.       if lcc_cc_pos, plcc_cc_pos  #Use sav_xa to position with comp. LCC
  2048.       pcom_movea
  2049.       c_msng$ #Single tool subprogram call
  2050.       toolchng0 = zero
  2051.       plast
  2052.  
  2053. mtlchg0$         #Call from NCI null tool change, mill
  2054.       toolchng0 = one
  2055.       if last_millcc & op_id$ <> last_op_id & (not(millcc) | cuttype <> last_cuttype), pmillcca #End mill conversion
  2056.       copy_x = vequ(x$)
  2057.       start_xh = vequ(xh$)
  2058.       pcom_moveb    #Get machine position, set inc. from last position
  2059.       c_mmlt$        #Position multi-tool sub, sets inc. current if G54...
  2060.       comment$
  2061.       pcan
  2062.       if opcode$ = 3 | opcode$ = 16, toolno = t$ * 100 + tlngno$
  2063.       else, toolno = t$ * 100 + tloffno$
  2064.       if home_type = -1,
  2065.         [
  2066.         prv_gcode$ = c9k                     #change modality for forced output
  2067.         pbld, n$, `sgcode, toolno, e$
  2068.         ]
  2069.       else, pbld, n$, toolno, e$
  2070.       pbld, n$, psgplane, e$
  2071.       #pcaxis_on_m   #Postblock for mill transition
  2072.       pspindle
  2073.       #pnullspindle
  2074.       pbld, n$, pscool,e$
  2075.       force_flg = 0
  2076.       if not(g54g55) & home_type > one & workofs$ <> prv_workofs$, force_flg = 1
  2077.       if spindle_no$ <> last_spindle_no, force_flg = 1
  2078.       if force_flg,
  2079.         [
  2080.         sav_absinc = absinc$
  2081.         absinc$ = zero
  2082.         pbld, n$, pwcs, e$
  2083.         pbld, n$, pclampoff, e$  # Clamp Off
  2084.         if millcc & not(last_millcc), pbld, n$, *sgcode, "C0.", [if y_axis_mch, "Y0."], e$
  2085.         else,
  2086.           [
  2087.           prv_gcode$ = c9k                     #change modality for forced output
  2088.           pbld, n$, `sgcode, pfcout, e$        #` used in case indexing mode
  2089.           ]
  2090.         pindex
  2091.         pbld, n$, pclampbrake, e$  # Clamp
  2092.         pbld, n$, psgcode, pfzout, e$
  2093.         pbld, n$, psgcode, pfxout, pfyout, e$
  2094.         pe_inc_calc #Update previous
  2095.         ps_inc_calc #Set current inc.
  2096.         absinc$ = sav_absinc
  2097.         ]
  2098.       else,
  2099.         [
  2100.         if op_id$ <> last_op_id & millcc & not(last_millcc),
  2101.           [
  2102.           pbld, n$, pclampoff, e$  # Clamp Off
  2103.           cabs = 0
  2104.           pbld, n$, *sgcode, pfcout, [if y_axis_mch, "Y0."], e$
  2105.           pbld, n$, pclampbrake, e$  # Clamp
  2106.           ]
  2107.         ]
  2108.       pbld, n$, pclampbrake0, e$
  2109.       pindex
  2110.       ppos_cax_lin  #Position C axis, toolplane or CL
  2111.       if millcc,
  2112.         [
  2113.         pmillccb #Set mill conversion
  2114.         pcom_moveb
  2115.         ]
  2116.       if gcode$ = one, plinout
  2117.       else, prapidout
  2118.       pbld, n$, pclampbrake, e$
  2119.       pcom_movea    #Update previous, pcan2
  2120.       c_msng$ #Single tool subprogram call
  2121.       toolchng0 = zero
  2122.       plast
  2123.  
  2124. plast       #Keep track of previous values
  2125.       last_millcc = millcc
  2126.       last_op_id =  op_id$
  2127.       last_cuttype  = cuttype
  2128.       last_spindle_no = spindle_no$
  2129.  
  2130. ptoolend$        #Read from buffer 1 for prv_, current and next tool info
  2131.                  #end tool here, current and next valid
  2132.       if toolend_flg,
  2133.         [
  2134.         sav_rev = rev #Axis Sub does not update to rev
  2135.         pcan
  2136.         if n1_gcode <> 1000,
  2137.           [
  2138.           if millcc, pmillcca #End mill conversion
  2139.           toolno = t$ * 100 + zero
  2140.           sav_gcode = gcode$
  2141.           gcode$ = zero
  2142.           if v9_coolant, [coolant$ = zero, pbld, n$, pscool, e$]
  2143.           if all_cool_off,
  2144.             [
  2145.             #all coolant off with a single off code here
  2146.             if coolant_on, pbld, n$, *sall_cool_off, e$
  2147.             coolant_on = zero
  2148.             ]
  2149.           else,
  2150.             [
  2151.             local_int = zero
  2152.             coolantx = zero
  2153.             while local_int < 20,
  2154.               [
  2155.               coolantx = and(2^local_int, coolant_on)
  2156.               local_int = local_int + one
  2157.               if coolantx > zero,
  2158.                 [
  2159.                 coolantx = local_int
  2160.                 pbld, n$, scoolantx, e$
  2161.                 ]
  2162.               coolantx = zero
  2163.               ]
  2164.             coolant_on = zero
  2165.             ]
  2166.           #pbld, n$, *sm05, e$
  2167.           if posttype$ = two, pl_retract
  2168.           else, pm_retract
  2169.           if n1_gcode <> 1003,
  2170.             [
  2171.            if prog_stop = 1, pbld, n$, *sm01, e$, " ", *e$
  2172.            if prog_stop = 2, pbld, n$, *sm00, e$, " ", *e$
  2173.             ]
  2174.           gcode$ = sav_gcode
  2175.           ]
  2176.         else, #Null toolchange
  2177.           [
  2178.           if n1_posttype <> posttype$, pcan1, pbld, n$, pnullstop, strcantext, e$
  2179.           ]
  2180.         pcan2
  2181.         #Update current variables to prv_ needed in comparisons
  2182.         !posttype$
  2183.         if rc1 < size1, preadcur_nxt
  2184.         ]
  2185.  
  2186.       # 1/17/03
  2187.       # When canned grooving, set cc_1013 to zero so that the cutter comp
  2188.       # value called out on the NCI 1013 line will be ignored.  cc_1013
  2189.       # should be restored to it's previous value in 'prcc_call_end'.
  2190.       if tool_op$ = 208 | tool_op$ = 62,                         # 1/17/03
  2191.         [                                                        # 1/17/03
  2192.         sav_cc_1013 = cc_1013$                                   # 1/17/03
  2193.         cc_1013$ = zero                                          # 1/17/03
  2194.         ]                                                        # 1/17/03
  2195.  
  2196. pl_retract      #Retract tool based on next tool gcode, lathe (see ptoolend)
  2197.       cc_pos$ = zero
  2198.       if home_type = one,
  2199.         [
  2200.         xh$ = vequ(start_xh)
  2201.         pmap_home   #Get home position, xabs
  2202.         ps_inc_calc #Set inc.
  2203.         pbld, n$, psccomp, e$
  2204.         if css_actv$ & css_end_rpm & not(lathe_stop | synch_flg | n1_gcode = 1003 | n1_posttype <> posttype$ | n1_spindle_no <> spindle_no$),
  2205.           [
  2206.           pspindle
  2207.           prpm
  2208.           ]
  2209.         pcan1, pbld, n$, *sgcode, pfxout, pfyout, pfzout, [if drop_offset, *toolno], strcantext, e$
  2210.         if lathe_stop | synch_flg | n1_gcode = 1003 | n1_posttype <> posttype$ | n1_spindle_no <> spindle_no$,
  2211.           [
  2212.           pbld, n$, pnullstop, e$
  2213.           ]
  2214.         ]
  2215.       else,
  2216.         [
  2217.         #Retract to reference return
  2218.         pbld, n$, `sgcode, psccomp, e$
  2219.         if home_type = m_one & drop_offset, pbld, n$, *toolno, e$
  2220.         if css_actv$ & css_end_rpm & not(lathe_stop | synch_flg | n1_gcode = 1003 | n1_posttype <> posttype$ | n1_spindle_no <> spindle_no$),
  2221.           [
  2222.           pspindle
  2223.           prpm
  2224.           ]
  2225.         if lathe_stop | synch_flg | n1_gcode = 1003 | n1_posttype <> posttype$ | n1_spindle_no <> spindle_no$,
  2226.           [
  2227.           pbld, n$, pnullstop, e$
  2228.           ]
  2229.         #if c1_tool <> n1_tool, #temp fix, need adding if force tool change = false ?
  2230.           #[
  2231.           pcan1, pbld, n$, *sg28ref, "U0.", [if y_axis_mch, "V0."], [if home_z, "W0."], strcantext, e$
  2232.           if home_z, pbld, n$, *sg28ref, "W0.", e$
  2233.           else, pbld, n$, "G0", "Z4.", e$
  2234.           #]
  2235.         if home_type > m_one & drop_offset, pbld, n$, *toolno, e$
  2236.         ]
  2237.  
  2238. pm_retract      #Retract tool based on next tool gcode, mill (see ptoolend)
  2239.       if home_type = one,
  2240.         [
  2241.         xh$ = vequ(start_xh)
  2242.         pmap_home   #Get home position, xabs
  2243.         if frc_cinit, cabs = zero
  2244.         ps_inc_calc #Set inc.
  2245.         pbld, n$, psccomp, e$
  2246.         if frc_cinit, pbld, n$, pclampoff, e$
  2247.         pcan1, pbld, n$, *sgcode, pfxout, pfyout, pfzout, protretinc, [if drop_offset, *toolno], strcantext, e$
  2248.         pbld, n$, pnullstop, e$
  2249.         ]
  2250.       else,
  2251.         [
  2252.         #Retract to reference return
  2253.         pbld, n$, `sgcode, psccomp, e$
  2254.         if home_type = m_one & drop_offset, pbld, n$, *toolno, e$
  2255.         if frc_cinit, pbld, n$, pclampoff, e$
  2256.         pcan1, pbld, n$, *sg28ref, "U0.", [if y_axis_mch, "V0."], pnullstop, strcantext, e$
  2257.         if home_z, pbld, n$, *sg28ref, "W0.", e$
  2258.         else, pbld, n$, *sgcode, "Z4.", e$
  2259.         if home_type > m_one & drop_offset, pbld, n$, *toolno, e$
  2260.         pcaxis_off_l
  2261.         ]
  2262.  
  2263. protretinc      #Reset the C axis revolution counter
  2264.       if frc_cinit,
  2265.         [
  2266.         rev = zero
  2267.         sav_rev = zero
  2268.         cabs = zero
  2269.         csav = zero
  2270.         c_wnd = zero
  2271.         prvc_wnd = zero
  2272.         indx_out = zero
  2273.         if c_axistype = one,
  2274.           [
  2275.           if home_type = one, pfcout
  2276.           else,
  2277.             [
  2278.             cinc = zero
  2279.             *cinc
  2280.             ]
  2281.           ]
  2282.         else,
  2283.           [
  2284.           pindxcalc
  2285.           if c_axistype = three,
  2286.             [
  2287.             indx_out = cabs
  2288.             e$, pbld, n$, pindex
  2289.             ]
  2290.           else, pfcout
  2291.           ]
  2292.         !csav, !cabs, !c_wnd
  2293.         ]
  2294.  
  2295. peof0$           #End of file for tool zero
  2296.       peof$
  2297.  
  2298. peof$            #End of file for non-zero tool
  2299.       ptoolend$
  2300.       comment$
  2301.       "M30", e$
  2302.       mergesub$
  2303.       clearsub$
  2304.       mergeaux$
  2305.       clearaux$
  2306.       "%", e$
  2307.  
  2308. pwcs            #G54+ coordinate setting at toolchange
  2309.       if home_type >= one,
  2310.         [
  2311.         sav_frc_wcs = force_wcs
  2312.         if sub_level$ > 0, force_wcs = zero
  2313.         if not(g54g55) & (workofs$ <> prv_workofs$ | (force_wcs & toolchng)),       #Mcam Work Offset Logic
  2314.           [
  2315.           if sub_level$, result = mprint(swrkserror)
  2316.           if workofs$ < 6,
  2317.             [
  2318.             g_wcs = workofs$ + 54
  2319.             *g_wcs
  2320.             ]
  2321.           else,
  2322.             [
  2323.             p_wcs = workofs$ - five
  2324.             "G54.1", *p_wcs
  2325.             ]
  2326.           ]
  2327.         if g54g55 & (spindle_no$ <> last_spindle_no | (force_wcs & toolchng)),        #G54/G55
  2328.           [
  2329.           if sub_level$, result = mprint(swrkserror)
  2330.           if spindle_no$ = 0, "G54"
  2331.           else, "G55"
  2332.           ]
  2333.         force_wcs = sav_frc_wcs
  2334.         !workofs$
  2335.         ]
  2336.  
  2337. #Rc1 is used to flag the SOF, rc1 = two at SOF
  2338. pcaxis_off_l    #Toolchange C axis disable, lathe, check prv_ to current
  2339.         if synch_flg, pbld, n$, *sm24, *sm224, e$
  2340.         else,
  2341.           [
  2342.           if spindle_no$ = 0, pbld, n$, *sm24, e$
  2343.           else, pbld, n$, *sm224, e$
  2344.           ]
  2345.  
  2346. pcaxis_on_m     #Toolchange C axis enable, mill, check prv_ to current
  2347.       if (rc1 = two | prv_posttype$ = two | spindle_no$ <> last_spindle_no | posttype$ = 1),
  2348.         [
  2349.         if synch_flg, pbld, n$, *sm23, *sm223, e$
  2350.         else,
  2351.           [
  2352.           if spindle_no$ = 0, pbld, n$, *sm23, e$
  2353.           else, pbld, n$,  *sm223, e$
  2354.           ]
  2355.         #if nextdc$ = three, pbld, n$, "M49", e$  #Disable tap
  2356.         ]
  2357.  
  2358. plcc_cc_pos     #Position for lathe canned cycle cutter comp. enable
  2359.                 #Position saved in prcc_setup
  2360.       pe_inc_calc   #Update previous
  2361.       copy_x = vequ(sav_xa)
  2362.       pcom_moveb    #Get machine position, set inc. from previous
  2363.       #Force comp from the finish profile
  2364.       compok = one
  2365.       cc_pos$ = n1_cc_pos
  2366.       if gcode$ = zero, prapidout
  2367.       else, plinout
  2368.       lcc_cc_pos = zero
  2369.  
  2370. pgear           #Use spindle gear range, find gear from RPM at X min.
  2371.       if use_gear = one,
  2372.         [
  2373.         if lathtype = zero | lathtype = two, x_min$ = c1_x_max
  2374.         else, x_min$ = c1_x_min
  2375.         x_min$ = x_min$ + c1_tox  #Correction for workshift
  2376.         if x_min$ = zero, x_min$ = 0.001
  2377.         if css_actv$ = zero, gear_spd = speedrpm
  2378.         else, gear_spd = (conversion * g_speed) / (pi$ * abs(x_min$) * two)
  2379.         gear = frange(one, gear_spd)
  2380.         *gear
  2381.         ]
  2382.  
  2383. prpm            #Output for start spindle
  2384.       speed = speedrpm
  2385.       if posttype$ = two,  #Lathe mode spindle
  2386.         [
  2387.         if speed = zero,
  2388.           pbld, n$, pfspindle_l, e$  #RPM = '0', output just an 'M05'
  2389.         else,
  2390.           [
  2391.           # if (opcode$ = 3 | opcode$ = 16 | opcode$ = 105) & nextdc$ = 3 & rigid_tap = 1,
  2392.             # [
  2393.             # pbld, n$, pgear, e$
  2394.             # pbld, n$, *sg97, e$
  2395.             # ]
  2396.           # else,
  2397.             # [
  2398.             # pbld, n$, pgear, e$
  2399.             # pbld, n$, *sg97, *speed, [if toolchng, pfspindle_l], e$
  2400.             # ]
  2401.           if css_actv$, speed = speedoverride
  2402.           pbld, n$, pgear, e$
  2403.           pbld, n$, *sg97, *speed, [if toolchng, pfspindle_l], e$
  2404.           ]
  2405.         ]
  2406.       else,    #Milling mode spindle
  2407.         [
  2408.         #result = nwadrs(strp, speed) #Different letter than 'S' for mill spindle?
  2409.         #if (opcode$ = 3 | opcode$ = 16 | opcode$ = 105) & nextdc$ = 3 & rigid_tap = 1, pbld, n$, *sg97, e$
  2410.         #else, pbld, n$, *sg97, *speed, *spindle_m, e$
  2411.         pbld, n$, *sg97, *speed, *spindle_m, e$
  2412.         result = nwadrs(strs, speed) #Reset to 'S' for next single speeed output
  2413.         ]
  2414.       !css_actv$ #Added (8/27/2002)
  2415.  
  2416. prpmnull       #Output for RPM at NULL tlchg (don't force spindle 'M' code)
  2417.       speed = speedrpm
  2418.       if posttype$ = two,
  2419.         [
  2420.         if (opcode$ = 3 | opcode$ = 16 | opcode$ = 105) & nextdc$ = 3 & rigid_tap = 1,
  2421.           [
  2422.           pbld, n$, pgear, e$
  2423.           pbld, n$, *sg97, e$
  2424.           ]
  2425.         else,
  2426.           [
  2427.           pbld, n$, pgear, e$
  2428.           pbld, n$, *sg97, *speed, pfspindle_l, e$
  2429.           ]
  2430.         ]
  2431.       else,
  2432.         [  #Milling mode spindle
  2433.         #result = nwadrs(strp, speed) #Different letter than 'S' for mill spindle?
  2434.         if (opcode$ = 3 | opcode$ = 16 | opcode$ = 105) & nextdc$ = 3 & rigid_tap = 1, pbld, n$, *sg97, e$
  2435.         else, pbld, n$, *sg97, *speed, *spindle_m, e$
  2436.         result = nwadrs(strs, speed) #Reset to 'S' for next single speeed output
  2437.         ]
  2438.       !css_actv$ #Added (8/27/2002)
  2439.  
  2440.  
  2441. pcssg50         #Output Constant surface speed clamp
  2442.       if css_actv$, pbld, n$, *sg50, *maxss$, e$
  2443.  
  2444. pcss            #Output Constant surface speed
  2445.       speed = g_speed
  2446.       if css_actv$,
  2447.         [
  2448.         if css_start_rpm, pbld, n$, *sg9697, *speed, pspindle_l, !css_actv$, e$
  2449.         else, pbld, n$, *sg9697, *speed, pfspindle_l, !css_actv$, e$                 #Force if not called after G97
  2450.         ]
  2451.       !speed
  2452.  
  2453. pspindle_l
  2454.       if not(synch_flg),
  2455.         [
  2456.         if spindle_no$ = 0, spindle_l
  2457.         else, spindle_ls
  2458.         ]
  2459.       else, spindle_l_synch
  2460.  
  2461. pfspindle_l
  2462.       if not(synch_flg),
  2463.         [
  2464.         if spindle_no$ = 0, *spindle_l
  2465.         else, *spindle_ls
  2466.         ]
  2467.       else, *spindle_l_synch
  2468.  
  2469. #Toolchange setup, spindle output, pspindle must be called first
  2470. pnullspindle  #Null toolchange and dwell spindle change, g_speed is input
  2471.       if prv_css_actv$<>css_actv$ | prv_g_spdir<>g_spdir | prv_speed<>g_speed,
  2472.         [
  2473.         #(1/10/2003) - test for coolant OFF (with 'cool_w_spd' mode enabled)
  2474.         if posttype$ = two & cool_w_spd <> zero
  2475.           & coolant$ = zero & prv_coolant$ > zero, pbld, n$, pscool, e$
  2476.  
  2477.         #Switch G97/G96 or direction at null or dwell
  2478.         #Stop the spindle if direction changes
  2479.         if (prv_g_spdir <> g_spdir) & abs(prv_g_spdir - g_spdir) <> three,
  2480.             pbld, n$, pnullstop, e$
  2481.         if css_actv$,
  2482.           [
  2483.           speed = g_speed
  2484.           pnullg50
  2485.           if prv_speed <> speed | prv_g_spdir<>g_spdir | prv_css_actv$<>css_actv$, pcss #(09/05/01)
  2486.           ]
  2487.         else,
  2488.           [
  2489.           if (prv_speed<>g_speed | prv_g_spdir<>g_spdir | prv_css_actv$<>css_actv$)
  2490.              & g_speed, prpmnull #(09/05/01)
  2491.           ]
  2492.         ]
  2493.       else, pnullg50
  2494.  
  2495. pnullg50      #Change G50 clamp speed at null or dwell
  2496.       if prv_maxss$ <> maxss$ & css_actv$, pcssg50
  2497.  
  2498. pnullstop     #Stop spindle at null, dwell or tool end
  2499.       sav_spdir = g_spdir
  2500.       if cool_w_spd = zero, g_spdir = one
  2501.       else, g_spdir = one + (fsg2(coolant$) * three)
  2502.       if posttype$ = two, pspindle_l
  2503.       else, spindle_m
  2504.       g_spdir = sav_spdir
  2505.  
  2506. pspindle        #Spindle speed calculations for RPM
  2507.       if maxss$ = zero | maxss$ > max_speed, maxss$ = max_speed
  2508.       if css_actv$,
  2509.         [
  2510.         #Spindle speed calculations for strt_spd w/CSS
  2511.         speedx = abs(xa)
  2512.         if opcode$ = 104, speedx = abs(c1_x_min)
  2513.         if opcode$ = 105, speedx = abs(tcr$)
  2514.         if speedx < 0.001,speedx = 0.001
  2515.         speedrpm = (conversion * g_speed) / (pi$ * speedx * two)
  2516.         ]
  2517.       else, speedrpm = g_speed
  2518.       #zero indicates spindle off (not a mistake)
  2519.       if speedrpm,
  2520.         [
  2521.         if speedrpm > maxss$, speedrpm = maxss$
  2522.         if speedrpm < min_speed, speedrpm = min_speed
  2523.         ]
  2524.       #Spindle speed for RPM with lathe drill, thread
  2525.       if opcode$ = 104 | opcode$ = 105, css_actv$ = zero
  2526.       if css_actv$ = zero, g_speed = speedrpm
  2527.  
  2528. pset_g_speed    #Set the spindle control variables from the read variables
  2529.       g_speed = abs(ss$)
  2530.       if cool_w_spd, g_spdir = fsg3(spdir$) + (fsg2(coolant$) * 3)
  2531.       else, g_spdir = fsg3(spdir$)
  2532.       if g_speed = zero, g_spdir = one # if RPM = '0', output 'M05'
  2533.       if spd_rev, pswtchspin
  2534.  
  2535. pswtchspin      #Reverse spindle direction
  2536.       if g_spdir > two, g_spdir = abs (g_spdir - five) + three
  2537.       else, g_spdir = abs (g_spdir - two)
  2538.  
  2539. pclampbrake   #by operation     # clamp_code 0=clamp, 1=brake, 2=off
  2540.                                 # clamp_flg  0=clamp, 1=brake, 2=off
  2541.                                 # mi7 - Clamp Code Override
  2542.                                 #       0 = Default post decision
  2543.                                 #       1 = Force Full Clamp
  2544.                                 #       2 = Force Brake / Mid-Clamp
  2545.                                 #       3 = Off
  2546.  
  2547.  
  2548.       #if cuttype = one, pxyzcout0                   #Turning                     off
  2549.       #if abs(cuttype) = two                         #Right/Left Face cut         brake unless rotary type is off (0) or Y (3)
  2550.       #| abs(cuttype) = three, pxyzcout2             #Cross cut                   brake/clamp
  2551.       #if cuttype = four, pxyzcout4                  #Y axis substitution         brake
  2552.       #if cuttype = five, pxyzcout5                  #Multisurf Rotary            brake
  2553.  
  2554.      if use_clamp | use_brake,
  2555.        [
  2556.        clamp_code = 2
  2557.        if cuttype = 1 | abs(cuttype) = 3 | (abs(cuttype) = 2 & (rotary_type$ = 0 | rotary_type$ = 3) & not(millcc)), clamp_code = 0       #clamp
  2558.        if abs(cuttype) = 2 | abs(cuttype) = 3 | cuttype = 4 | cuttype = 5 | millcc,
  2559.          [
  2560.          if clamp_code <> 0, clamp_code = 1      #brake
  2561.          ]
  2562.        if opcode$ = 3 | opcode$ = 16, clamp_code = 2
  2563.        if use_clamp = 0 & clamp_code = 0, clamp_code = 2
  2564.        if use_brake = 0 & clamp_code = 1, clamp_code = 2
  2565.        if mi7$, clamp_code = mi7$ - 1
  2566.        if synch_flg, smspdl_clmp_synch
  2567.        else,
  2568.          [
  2569.          if spindle_no$ = 0, smspdl_clmp
  2570.          if spindle_no$ = 1, smspdl_clmps
  2571.          ]
  2572.        clamp_flg = clamp_code
  2573.        ]
  2574.  
  2575. pclampbrake0                     # clamp_code 0=clamp, 1=brake, 2=off
  2576.      if (use_clamp | use_brake) & clamp_flg = 0,
  2577.         [
  2578.         if fmtrnd(cabs) <> prv_cabs, clamp_code = 2
  2579.         if mi7$, clamp_code = mi7$ - 1
  2580.         if synch_flg, smspdl_clmp_synch
  2581.         else,
  2582.           [
  2583.           if spindle_no$ = 0, smspdl_clmp
  2584.           if spindle_no$ = 1, smspdl_clmps
  2585.           ]
  2586.         clamp_flg = clamp_code
  2587.         ]
  2588.  
  2589. pfclampon      #Force clamp on
  2590.      if use_clamp | use_brake,
  2591.        [
  2592.        clamp_code = 0
  2593.        if mi7$, clamp_code = mi7$ - 1
  2594.        if synch_flg, *smspdl_clmp_synch
  2595.        else,
  2596.          [
  2597.          if spindle_no$ = 0, *smspdl_clmp
  2598.          if spindle_no$ = 1, *smspdl_clmps
  2599.          ]
  2600.        clamp_flg = clamp_code
  2601.        ]
  2602.  
  2603. pfclampoff      #Force clamp off
  2604.      if use_clamp | use_brake,
  2605.        [
  2606.        clamp_code = 2
  2607.        if synch_flg, *smspdl_clmp_synch
  2608.        else,
  2609.          [
  2610.          if spindle_no$ = 0, *smspdl_clmp
  2611.          if spindle_no$ = 1, *smspdl_clmps
  2612.          ]
  2613.        clamp_flg = clamp_code
  2614.        ]
  2615.  
  2616. pclampoff       #Clamp off
  2617.      if spindle_no$ <> last_spindle_no, pfclampoff
  2618.      if use_clamp | use_brake,
  2619.        [
  2620.        clamp_code = 2
  2621.        if synch_flg, smspdl_clmp_synch
  2622.        else,
  2623.          [
  2624.          if spindle_no$ = 0, smspdl_clmp
  2625.          if spindle_no$ = 1, smspdl_clmps
  2626.          ]
  2627.        clamp_flg = clamp_code
  2628.        ]
  2629.  
  2630. preadcur_nxt    #Read current and next tool record
  2631.       c1_gcode = rbuf (one, rc1)     #Current tool record
  2632.       #Place buffered variables in post global variables
  2633.       cuttype = c1_cuttype
  2634.       lathtype = c1_lathtype
  2635.       lathecc = c1_lathecc
  2636.       gcodecc = c1_gcodecc
  2637.       y_axis = c1_y_axis
  2638.       millcc = c1_millcc
  2639.       n1_gcode = rbuf (one, nc1)     #Next tool record
  2640.       if cuttype = one, cc_1013$ = one
  2641.       else, cc_1013$ = zero
  2642.       if lathecc<>zero & lathecc<>4, compok = zero
  2643.       else, compok = one
  2644.  
  2645. ptlchg1002$      #Call at actual toolchange with tlchng_aft
  2646.       whatline$ = four #Required for vector toolpaths
  2647.       pset_mach   #Set rotary switches by reading machine def parameters
  2648.       pmatrix_su
  2649.       pmap_plane
  2650.       pset_turret
  2651.       pset_g_speed
  2652.       toolend_flg = one
  2653.       if rcc_flg$ = zero, sub_seq_typ$ = prv_sub_seq_typ$
  2654.       if gcode$ = 1000,
  2655.         [
  2656.         #Null toolchange
  2657.         #if millcc & prv_mi4$ = mi4$, cutpos2$ = sav_cutpos2
  2658.         if cc_stop_fcc & rcc_flg$ = 6, no_nc_out$ = one
  2659.         ]
  2660.       else,
  2661.         [
  2662.         #Toolchange and Start of file
  2663.         if gcode$ = 1002,
  2664.           [
  2665.           #Actual toolchange
  2666.           preset_mod
  2667.           ]
  2668.         prv_xia = vequ (c1_xh)
  2669.         prv_feed = c9k
  2670.         pnt_at_zero = zero
  2671.         ]
  2672.       #Mill canned cycle initialze at toolchange
  2673.       arcoutput$ = sav_arcout
  2674.       if millcc,
  2675.         [
  2676.         #R arc output
  2677.         arcoutput$ = one
  2678.         if cuttype = four,
  2679.           [
  2680.           if g107crad = 0, crad = rotdia$/two
  2681.           else, crad = rotdia$
  2682.           ]
  2683.         else,
  2684.           [
  2685.           breakarcs$ = zero
  2686.           ]
  2687.         ]
  2688.       iout = zero
  2689.       kout = zero
  2690.       !mi4$
  2691.  
  2692. preset_mod    #Reset the mode flags and map during motion blocks
  2693.       breakarcs$ = breakarcss
  2694.       cir_at_zero = zero
  2695.       linarc$ = zero
  2696.       brklinestype$ = zero
  2697.  
  2698. # --------------------------------------------------------------------------
  2699. # Motion NC output
  2700. # --------------------------------------------------------------------------
  2701. prapidout       #Output to NC, linear movement - rapid
  2702.       if interp_flg & (abs(cuttype) = 4 | abs(cuttype) = 2) & cutpos2$ = 0,
  2703.         [
  2704.         if abs(cuttype) = 4,   #position C then XZ for approach to interpolation on the OD
  2705.           [
  2706.           pcan1, pbld, n$, psgplane, pexct, psgcode, pcout, pscool, strcantext, e$
  2707.           pbld, n$, pexct, pxout, pyout, pzout, e$
  2708.           ]
  2709.         else,                 #position C and X then Z for approach to interpolation on the face
  2710.           [
  2711.           pcan1, pbld, n$, psgplane, pexct, psgcode, pxout, pcout, pyout, pscool, strcantext, e$
  2712.           pbld, n$, pzout, e$
  2713.           ]
  2714.         ]
  2715.       else,
  2716.         [
  2717.         if tool_op$ <> 216,
  2718.         [
  2719.         pcan1, pbld, n$, psgplane, pexct, psgcode, [if tool_op$ > 200 & tool_op$ < 208, psccomp],
  2720.           pxout, pyout, pzout, pcout, pscool, strcantext, e$
  2721.         ]  
  2722.         ]
  2723.  
  2724. plinout         #Output to NC, linear movement - feed
  2725.       #Output the Z after XY so the tool can move to position before plunging
  2726.       #helps for toolpaths not starting near the 3o'clock position
  2727.       if interp_flg & abs(cuttype) = 2 & cutpos2$ = 0,
  2728.         [
  2729.         pcan1, pbld, n$, psgplane, psgfeed, pexct, psgcode, psccomp, pxout,
  2730.           pyout, pcout, pfr, pscool, strcantext, e$
  2731.         pbld, n$, psgfeed, psgcode, pzout, pfr, e$
  2732.         ]
  2733.       else,
  2734.         [
  2735.         if opcode$ = 3, pbld, n$, pcout, e$  #Fixes issue with longhand drilling output, cam/wbt
  2736.         pcan1, pbld, n$, psgplane, psgfeed, pexct, psgcode, psccomp, pxout,
  2737.           pyout, pzout, pcout, pfr, pscool, strcantext, e$
  2738.         ]
  2739.  
  2740. pcirout   #Output to NC, circular interpolation
  2741.       pcan1, pbld, n$, psgplane, psgfeed, pexct, psgcode, psccomp, pxout,
  2742.         pyout, pzout, pcout, parc, pfr, pscool, strcantext, e$
  2743.  
  2744. pl_ncoutput     #Movement output
  2745.       pcc_capture   #Capture LCC ends, stop output RLCC          # 05/28/04   #This was previously commented out but I have removed that as it affects G73 pattern repeat.  I'm not sure what else this affects at this point. WBT
  2746.       pcom_moveb    #Get machine position, set inc. from last position
  2747.       pcan
  2748.       c_rcc_setup$   #Save original in sav_xa and shift copy_x for LCC comp.
  2749.       if gcode$ = zero, prapidout
  2750.       if gcode$ = one, plinout
  2751.       if gcode$ > one & gcode$ < four, pcirout
  2752.       if lcc_cc_pos, plcc_cc_pos  #Use sav_xa to position with comp. LCC
  2753.       pcom_movea    #Update previous, pcan2
  2754.  
  2755. pm_ncoutput     #Movement output
  2756.       if millcc, pmillccb #Set mill conversion   #set here so coordinate calc is consitent with state of G112
  2757.       pcom_moveb    #Get machine position, set inc. from last position
  2758.       pcan
  2759.       pindex
  2760.       ppos_cax_lin  #Position C axis, toolplane or CL
  2761.       if gcode$ = zero, prapidout
  2762.       if gcode$ = one, plinout
  2763.       if gcode$ > one & gcode$ < four, pcirout
  2764.       pcom_movea    #Update previous, pcan2
  2765.       ppos_pnt_zero #Update to detect point at zero
  2766.  
  2767. pdwl_spd$        #Output to NC, spindle, dwell changes
  2768.       pset_g_speed
  2769.       pspindle
  2770.       comment$
  2771.       pnullspindle
  2772.       pcan
  2773.       if fmtrnd(dwell$), pdwell1
  2774.       else, pcan1, pbld, n$, strcantext, e$
  2775.       pcan2
  2776.  
  2777. mrapid$          #Output to NC of linear movement - rapid, mill
  2778.       copy_x = vequ(x$)
  2779.       pm_ncoutput
  2780.  
  2781. pzrapid$         #Linear movement in Z axis only - rapid, mill
  2782.       copy_x = vequ(x$)
  2783.       pm_ncoutput
  2784.  
  2785. pz$              #Linear movement in Z axis only - at feedrate, mill
  2786.       copy_x = vequ(x$)
  2787.       pm_ncoutput
  2788.  
  2789. mlin$            #Output to NC of linear movement - feed, mill
  2790.       copy_x = vequ(x$)
  2791.       pm_ncoutput
  2792.  
  2793. mcir$            #Output to NC of circular interpolation, mill
  2794.       pshft_map_ijk
  2795.       copy_x = vequ(x$)
  2796.       pm_ncoutput
  2797.  
  2798. lrapid$          #Rapid linear movement, lathe
  2799.       copy_x = vequ(x$)
  2800.       if lathecc = 3, pbld, n$, sccomp, e$        # 1/17/03
  2801.       pl_ncoutput
  2802.  
  2803. llin$            #Linear line movement - at feedrate, lathe
  2804.       copy_x = vequ(x$)
  2805.       pl_ncoutput
  2806.  
  2807. lcir$            #Circular interpolation, lathe
  2808.       pshft_map_ijk
  2809.       copy_x = vequ(x$)
  2810.       pl_ncoutput
  2811.  
  2812. pmx$             #Output to NC of Multisurf Rotary, mill
  2813.       copy_x = vequ(x$)
  2814.       pm_ncoutput
  2815.  
  2816. #Pre-process rotary motion control flags, mill
  2817. pmx0$            #5 ax Drill
  2818.       if cuttype = five,
  2819.         [
  2820.         if drill5$ = one, z$ = initht$ * z_mult
  2821.         else,
  2822.           [
  2823.           if fr$ =  -2,gcode$ = zero
  2824.           else, gcode$ = one
  2825.           ]
  2826.         ]
  2827. plin0$           #Pre-linear movement postblock
  2828.       if posttype$ <> two,
  2829.         [
  2830.         preset_mod
  2831.         if y_axis = zero & millcc = zero & c_axistype <> three,
  2832.           [
  2833.           #Set brklinestype
  2834.           if abs(cuttype) = two & (cutpos2$ >= 2 & cutpos2$ <= 4), brklinestype$ = 6  #Break XY (machine coord sys) motion on during face cut
  2835.           if abs(cuttype) = three & (cutpos2$ >= 2 & cutpos2$ <= 4), brklinestype$ = 4  #Break XY (machine coord sys) motion on during cross cut
  2836.           #if abs(cuttype) = two, brklinestype$ = 6
  2837.           #if cuttype = three, brklinestype$ = four
  2838.           ]
  2839.         ]
  2840.  
  2841. pcir0$           #Pre-circular interpolation postblock
  2842.       pmap_plane
  2843.       if posttype$ <> two,
  2844.         [
  2845.         preset_mod
  2846.         pshft_map_xc
  2847.         if y_axis = zero & millcc = zero,
  2848.           [
  2849.           #Set linarc, breakarcs and cir_at_zero
  2850.           if fmtrnd(xca) = zero & fmtrnd(yca) = zero,
  2851.             [
  2852.             #Set breakarcs and cir_at_zero
  2853.             #if rot_type = 2 & abs(cuttype) = 2, breakarcs$ = 1
  2854.             #we want all arcs about X0Y0 to be broken regardless of rot_type
  2855.             #This helps with side plane, rotary axis one, full arcs when arcs get converted to rotary motion
  2856.             if abs(cuttype) = 2, breakarcs$ = 2      #this can be changed between 1 (quadrants) and 2 (180 deg)
  2857.             else, breakarcs$ = zero
  2858.             #C axis move
  2859.             if mach_plane = zero,
  2860.               [
  2861.               cir_at_zero = one
  2862.               czero_csav = csav
  2863.               ]
  2864.             #Arc output
  2865.             if mach_plane = two, cir_at_zero = m_one
  2866.             ]
  2867.           if cir_at_zero = zero, linarc$ = one
  2868.           ]
  2869.         if millcc & plane$ <> 0, linarc$ = one
  2870.         ]
  2871.       !ynci$
  2872.  
  2873. # --------------------------------------------------------------------------
  2874. # Motion output components
  2875. # --------------------------------------------------------------------------
  2876. pdwell1         #Dwell output
  2877.       gcode$ = four  #for implied dwells
  2878.       pcan1, pbld, n$, *sgcode, *dwell$, strcantext, e$
  2879.  
  2880. pbld            #Canned text - block delete
  2881.       if bld, '/'
  2882.  
  2883. pfbld           #Force block delete
  2884.       "/"
  2885.  
  2886. psgplane        #Machining plane
  2887.       if (gcode$ = 2 | gcode$ = 3) & plane$ <> prv_plane$, result = force(gcode$,gcode$)
  2888.       if y_axis_mch & not(millcc) & posttype$ <> 2, sgplane   #plane changes between 0 and 2 for turning, only allow output at toolchange, never allow plane output during G07.1 or G12.1
  2889.       !plane$
  2890.  
  2891. pfsgplane       #Force machining plane
  2892.       if (gcode$ = 2 | gcode$ = 3) & plane$ <> prv_plane$, result = force(gcode$,gcode$)
  2893.       if y_axis_mch | (millcc & cuttype = 4), *sgplane    #force plane output before G07 whether Y-axis or not, never allow plane output during G07.1 or G12.1
  2894.       !plane$
  2895.  
  2896. psgfeed
  2897.       if posttype$ = 1 & mi6$ = 1, ipr_actv$ = 1
  2898.       if (opcode$ = 3 | opcode$ = 16 | opcode$ = 105) & nextdc$ = 3 & posttype$ = 1,
  2899.         [
  2900.         if use_pitch = 1, ipr_actv$ = 1
  2901.         else, ipr_actv$ = 0
  2902.         ]
  2903.       sgfeed
  2904.  
  2905. pfsgfeed
  2906.       if posttype$ = 1 & mi6$ = 1, ipr_actv$ = 1
  2907.       if (opcode$ = 3 | opcode$ = 16 | opcode$ = 105) & nextdc$ = 3 & posttype$ = 1,
  2908.         [
  2909.         if use_pitch = 1, ipr_actv$ = 1
  2910.         else, ipr_actv$ = 0
  2911.         ]
  2912.       *sgfeed
  2913.  
  2914. pexct           #Canned text - exact stop
  2915.       if exact, 'G9'
  2916.  
  2917. psgcode         #Output the Gcode based on the current plane
  2918.       if c_ax_flp,
  2919.         [
  2920.         #Reverse arc direction for c_axis flip
  2921.         if gcode$ = two | gcode$ = three,
  2922.           [
  2923.           sav_gcode = gcode$
  2924.           gcode$ = (5 - gcode$)  #G02->G03 or G03->G02    # 1/17/03
  2925.           ]
  2926.         ]
  2927.       if plane$ = zero, `sgcode
  2928.       if plane$ = one, `sgcode1
  2929.       if plane$ = two, `sgcode2
  2930.       if c_ax_flp, gcode$ = sav_gcode
  2931.  
  2932. psccomp         #Output the cutter compensation based on the current plane
  2933.       if compok,
  2934.         [
  2935.         if plane$ = zero, sccomp
  2936.         if plane$ = one, sccomp1
  2937.         if plane$ = two, sccomp2
  2938.         ]
  2939.  
  2940. pfxout          #Force X axis output
  2941.       if absinc$ = zero, *xabs, !xinc
  2942.       else, *xinc, !xabs
  2943.  
  2944. pxout           #X output
  2945.       if absinc$ = zero, xabs, !xinc
  2946.       else, xinc, !xabs
  2947.  
  2948. pfyout          #Force Y axis output
  2949.       if y_axis_mch,                    #Allow Y in the force out so it can come out before and after G112
  2950.         [
  2951.         if absinc$ = zero, *yabs
  2952.         else, *yinc
  2953.         ]
  2954.       if not(y_axis_mch), pchecky
  2955.       !yabs, !yinc
  2956.  
  2957. pyout           #Y output
  2958.       if y_axis_mch & not(millcc),
  2959.         [
  2960.         if absinc$ = zero, yabs
  2961.         else, yinc
  2962.         ]
  2963.       if not(y_axis_mch), pchecky
  2964.       !yabs, !yinc
  2965.  
  2966. pchecky         #Y output should not happen on a c-axis lathe
  2967.       if not(toolchng) & yinc & checkyflg,
  2968.         [
  2969.         result = mprint(symoterror, 2)
  2970.         checkyflg = no$
  2971.         ]
  2972. pfzout          #Force Z axis output
  2973.       if absinc$ = zero, *zabs, !zinc
  2974.       else, *zinc, !zabs
  2975.  
  2976. pzout           #Z output
  2977.       if absinc$ = zero, zabs, !zinc
  2978.       else, zinc, !zabs
  2979.  
  2980. pfcout          #Force C axis output
  2981.       if spindle_no$ = 0,                       #main
  2982.         [
  2983.         result = nwadrs(strc,cout_a)
  2984.         result = nwadrs(strh,cout_i)
  2985.         if millcc & g112address = 0, result = nwadrs(stry, cabs)
  2986.         if millcc & g112address = 1, result = nwadrs(strc, cabs)
  2987.         ]
  2988.        else,                                   #sub
  2989.         [
  2990.         result = nwadrs(stra,cout_a)
  2991.         if millcc & g112address = 0, result = nwadrs(stry, cabs)
  2992.         if millcc & g112address = 1, result = nwadrs(stra, cabs)
  2993.         ]
  2994.  
  2995.       cout_a = cabs
  2996.       cout_i = csav - prv_csav
  2997.  
  2998.       if rot_type = 2,
  2999.         [
  3000.         while cout_a >= 360, cout_a = cout_a - 360
  3001.         while cout_a < 0, cout_a = cout_a + 360
  3002.         ]
  3003.  
  3004.       if posttype$ <> two & c_axistype < three,
  3005.         [
  3006.         if c_axistype = one | millcc,
  3007.           [
  3008.           if (abs(cuttype) = 3 | cuttype = 4) & rot_type = 2,
  3009.             [
  3010.             if absinc$ = one | (abs(fmtrnd(csav - prv_csav)) >= 180. & gcode$ <> 0), *cout_i, !cinc, !cabs, !cout_a
  3011.             else, *cout_a, !cabs, !cinc, !cout_i
  3012.             ]
  3013.           else,
  3014.             [
  3015.             if millcc,
  3016.               [
  3017.               if absinc$ = zero, !cout_a, *cabs, !cinc, !cout_i
  3018.               else, !cout_i, *cinc, !cabs, !cout_a
  3019.               ]
  3020.             else,
  3021.               [
  3022.               if absinc$ = zero, *cout_a, !cabs, !cinc, !cout_i
  3023.               else, *cout_i, !cinc, !cabs, !cout_a
  3024.               ]
  3025.             ]
  3026.           ]
  3027.         else, #Signed direction, modality on c_wnd, no incremental
  3028.           [
  3029.           if fmtrnd(prv_c_wnd) <> fmtrnd(c_wnd),
  3030.             [
  3031.             if indx_mc = zero, result = nwadrs(sc_minus, cout_a)
  3032.             else, result = nwadrs(str_cax_abs, cout_a)
  3033.             *cout_a
  3034.             ]
  3035.           !c_wnd, !cabs, !cinc
  3036.           ]
  3037.         ]
  3038.       !csav
  3039.  
  3040. pcout           #C axis output
  3041.       if spindle_no$ = 0,                       #main
  3042.         [
  3043.         result = nwadrs(strc,cout_a)
  3044.         result = nwadrs(strh,cout_i)
  3045.         if millcc & g112address = 0, result = nwadrs(stry, cabs)
  3046.         if millcc & g112address = 1, result = nwadrs(strc, cabs)
  3047.         ]
  3048.        else,                                   #sub
  3049.         [
  3050.         result = nwadrs(stra,cout_a)
  3051.         if millcc & g112address = 0, result = nwadrs(stry, cabs)
  3052.         if millcc & g112address = 1, result = nwadrs(stra, cabs)
  3053.         ]
  3054.  
  3055.       cout_a = cabs
  3056.       cout_i = csav - prv_csav
  3057.  
  3058.       if rot_type = 2,
  3059.         [
  3060.         while cout_a >= 360, cout_a = cout_a - 360
  3061.         while cout_a < 0, cout_a = cout_a + 360
  3062.         ]
  3063.  
  3064.       if posttype$ <> two & c_axistype < three,
  3065.         [
  3066.         if c_axistype = one | millcc,
  3067.           [
  3068.           if (abs(cuttype) = 3 | cuttype = 4) & rot_type = 2,
  3069.             [
  3070.             if absinc$ = one | (abs(fmtrnd(csav - prv_csav)) >= 180. & gcode$ <> 0), *cout_i, !cinc, !cabs, !cout_a
  3071.             else, cout_a, !cabs, !cinc, !cout_i
  3072.             ]
  3073.           else,
  3074.             [
  3075.             if millcc,
  3076.               [
  3077.               if absinc$ = zero, !cout_a, cabs, !cinc, !cout_i
  3078.               else, !cout_i, cinc, !cabs, !cout_a
  3079.               ]
  3080.             else,
  3081.               [
  3082.               if absinc$ = zero, cout_a, !cabs, !cinc, !cout_i
  3083.               else, cout_i, !cinc, !cabs, !cout_a
  3084.               ]
  3085.             ]
  3086.           ]
  3087.         else, #Signed direction, modality on c_wnd, no incremental
  3088.           [
  3089.           if fmtrnd(prv_c_wnd) <> fmtrnd(c_wnd),
  3090.             [
  3091.             if indx_mc = zero, result = nwadrs(sc_minus, cout_a)
  3092.             else, result = nwadrs(str_cax_abs, cout_a)
  3093.             *cout_a
  3094.             ]
  3095.           !c_wnd, !cabs, !cinc
  3096.           ]
  3097.         ]
  3098.       !csav
  3099.  
  3100. pindex          #Index output
  3101.       if c_axistype = three,
  3102.         [
  3103.         pbld, n$, `sindx_mc, indx_out, e$
  3104.         !cabs, !cinc
  3105.         ]
  3106.  
  3107. pindexdrl          #Index output
  3108.       if c_axistype = three,
  3109.         [
  3110.         pbld, n$, `sindx_mc, indx_out
  3111.         !cabs, !cinc
  3112.         ]
  3113.  
  3114. parc            #Select the arc output
  3115.       #Setup for arctype setting
  3116.       if (posttype$ = 2 & (larctypexz$ = one | larctypexz$ = four)) |
  3117.         (posttype$ = 1 &(plane$ = zero & (arctype$ = one | arctype$ = four)) |   #XY Plane
  3118.         (plane$ = one & (arctypeyz$ = one | arctypeyz$ = four)) | #YZ Plane
  3119.         (plane$ = two & (arctypexz$ = one | arctypexz$ = four))),  #XZ Plane
  3120.         [
  3121.         result = newfs(two, i$)
  3122.         result = newfs(two, j$)
  3123.         result = newfs(two, k$)
  3124.         result = newfs(two, iout)
  3125.         result = newfs(two, jout)
  3126.         result = newfs(two, kout)
  3127.         ]
  3128.       else,
  3129.         [
  3130.         result = newfs(three, i$)
  3131.         result = newfs(three, j$)
  3132.         result = newfs(three, k$)
  3133.         result = newfs(three, iout)
  3134.         result = newfs(three, jout)
  3135.         result = newfs(three, kout)
  3136.         ]
  3137.  
  3138.       if ((posttype$ = 2 & (plane$ = 2 & larctypexz$ < five)) |
  3139.         (posttype$ = 1 & ((plane$ = 0 & arctype$ < five) |
  3140.         (plane$ = 1 & arctypeyz$ < five) |
  3141.         (plane$ = 2 & arctypexz$ < five)))) & not(cuttype = 4 & millcc),
  3142.         [
  3143.         #Arc output for IJK
  3144.         if (posttype$ = 2 & (plane$ = 2 & larctypexz$ = one)) |   #XZ plane - Lathe
  3145.           (posttype$ = 1 & ((plane$ = zero & arctype$ = one) |    #XY Plane - Mill
  3146.           (plane$ = one & arctypeyz$ = one) |                     #YZ Plane - Mill
  3147.           (plane$ = two & arctypexz$ = one))),                    #XZ Plane - Mill
  3148.           [
  3149.           #Arc output for IJK, absolute
  3150.           iout = (iout + dia_shift) * dia_mult
  3151.           jout = (jout + y_shift) * y_mult
  3152.           kout = (kout + z_shift) * z_mult
  3153.           if c_ax_flp, iout = -iout
  3154.           ]
  3155.         else,
  3156.           [
  3157.           #Arc output for IJK, start/center
  3158.           iout = iout * (dia_mult/abs(dia_mult))
  3159.           jout = jout * y_mult
  3160.           kout = kout * z_mult
  3161.           if c_ax_flp, iout = -iout
  3162.           ]
  3163.         #If you do NOT want to force out the I,J,K values,
  3164.         #remove the "*" asterisks on the *i, *j, *k 's below...
  3165.         if plane$ = zero, *iout, *jout, kout #XY plane code - G17
  3166.         if plane$ = one, iout, *jout, *kout  #YZ plane code - G19
  3167.         if plane$ = two, *iout, jout, *kout  #XZ plane code - G18
  3168.         #Original method does not force out IJK values of 0 for delta start to centre arcs
  3169.         #iout, kout, jout
  3170.         !i$, !j$, !k$
  3171.         ]
  3172.       else,
  3173.         [
  3174.         #Arc output for R
  3175.         if abs(sweep$)<=180 | cuttype = 4 & millcc |
  3176.           (posttype$ = 2 & (plane$ = 2 & larctypexz$ = five)) |               #XZ Plane - Lathe
  3177.           (posttype$ = 1 & ((plane$ = 0 & arctype$ = five) |                  #XY Plane - Mill
  3178.           (plane$ = 1 & arctypeyz$ = five) |                                  #YZ Plane - Mill
  3179.           (plane$ = 2 & arctypexz$ = five))), result = nwadrs(strr, arcrad$)  #XZ Plane - Mill
  3180.         else, result = nwadrs(srminus, arcrad$)
  3181.         *arcrad$
  3182.         ]
  3183.  
  3184. pffr            #Output feedrate, force
  3185.       if posttype$ = 1 & mi6$ = 1, ipr_actv$ = 1
  3186.       if ipr_actv$ = zero, pfr_m
  3187.       else, pfr_l
  3188.       if tap_feed = one & drillcyc$ = three, result = newfs (18, feed)  #Tap feeds with 4/3 decimal places
  3189.       *feed
  3190.  
  3191. pfr             #Output feedrate
  3192.       if posttype$ = 1 & mi6$ = 1, ipr_actv$ = 1
  3193.       if ipr_actv$ = zero, pfr_m
  3194.       else, pfr_l
  3195.       if tap_feed = one & drillcyc$ = three, result = newfs (18, feed)  #Tap feeds with 4/3 decimal places
  3196.       `feed
  3197.  
  3198. pfr_m           #Format feedrate for mill
  3199.       result = nwadrs(strf, feed)
  3200.       result = newfs (17, feed)
  3201.  
  3202. pfr_l           #Format feedrate for lathe
  3203.       if opcode$ = 104,
  3204.         [
  3205.         #Format feedrate for lathe thread
  3206.         if thread_address,
  3207.           [
  3208.           result = nwadrs(stre,feed)
  3209.           ]
  3210.         else,
  3211.           [
  3212.           result = nwadrs(strf,feed)             #Default as per Fanuc programming manual
  3213.           ]
  3214.         result = newfs (19, feed)
  3215.         ]
  3216.       else,
  3217.         [
  3218.         result = nwadrs(strf, feed)
  3219.         result = newfs (18, feed)
  3220.         if mi6$, result = newfs (12, feed)
  3221.         ]
  3222.  
  3223. pscool          #Coolant is separate code
  3224.       if v9_coolant,
  3225.         [
  3226.         if cool_w_spd = zero, scoolant
  3227.         else,
  3228.           [ # 'cool_w_spd' mode is active - (1/10/2003)
  3229.           if coolant$ = zero, scoolant  #Turn coolant OFF
  3230.           ]
  3231.         !coolant$
  3232.         ]
  3233.  
  3234. pfscool         #Coolant is separate code, force
  3235.       if v9_coolant,
  3236.         [
  3237.         if cool_w_spd = zero, *scoolant
  3238.         !coolant$
  3239.         ]
  3240.  
  3241. pcc_capture     #Capture ends of canned turning path, stop output w/rough
  3242.       #Stop output in rough only lathe canned cycles
  3243.       #between rough and finish paths
  3244.       #if cc_stop_fcc & rcc_flg$ = 6, no_nc_out$ = one          # 05/28/04
  3245.       if cc_stop_fcc & rcc_flg$ = 6 & lathecc <> 2, no_nc_out$ = one          #wbt - do not want to stop output before/after pattern repeat
  3246.       #Capture vector for G73 cycle
  3247.       if rpd_typ$ = 6 & abs(lathecc) = two,
  3248.         [
  3249.         if rcc_flg$ = one, lcc_xcst = vequ (copy_x)
  3250.         if rcc_flg$ = three, lcc_xcend = vequ (copy_x)
  3251.         ]
  3252.  
  3253. pcom_moveb      #Common motion preparation routines, before
  3254.       pshft_map_xa
  3255.       pxyzcout
  3256.       if interp_flg = 1 & millcc,
  3257.         [
  3258.         #Change rapid to highest possible feedrate
  3259.         if gnci$ = zero,
  3260.           [
  3261.           gcode$ = one
  3262.           feed = maxfeedpm
  3263.           result = force(feed,feed)
  3264.           ]
  3265.         ]
  3266.       ps_inc_calc
  3267.  
  3268. ppos_cax_lin    #Position C if from CL
  3269.       if (prv_pnt_at_zero) & c_axistype < three,
  3270.         [
  3271.         #Output to NC, C axis movement only - rapid deg/min
  3272.         sav_gcode = gcode$
  3273.         sav_feed = feed
  3274.         gcode$ = one
  3275.         if millcc = zero,
  3276.           [
  3277.           feed = maxfrdeg
  3278.           pbld, n$, psgcode, pfcout, pffr, e$
  3279.           ]
  3280.         else, pbld, n$, psgcode, pfcout, pfr, e$
  3281.         gcode$ = sav_gcode
  3282.         feed = sav_feed
  3283.         ]
  3284.  
  3285. pcom_movea      #Common motion preparation routines, after
  3286.       pcan2
  3287.       pe_inc_calc
  3288.  
  3289. ppos_pnt_zero   #Position C if from CL
  3290.       !pnt_at_zero
  3291.       pnt_at_zero = zero
  3292.  
  3293. #Mill canned cycle output
  3294. pmillccb        #Cross/Face canned cycle code, before
  3295.       if interp_flg = 0,
  3296.         [
  3297.         interp_flg = 1
  3298.         result = newfs(two, cabs)
  3299.         result = newfs(two, cinc)
  3300.         #Cross/Face canned cycle start code
  3301.         if abs(cuttype) = two,
  3302.           [
  3303.           #Face canned cycle start code, G112 (break ramp)
  3304.           #Fanuc style uses X diameter, C radius
  3305.           pbld, n$, *sg112, e$
  3306.           prv_xabs = c9k
  3307.           prv_xinc = c9k
  3308.           prv_cabs = c9k
  3309.           prv_cinc = c9k
  3310.           compok = one
  3311.           ]
  3312.         else,
  3313.           [
  3314.           #Cross canned cycle start code
  3315.           #Fanuc Style, G107 is new style, G07.1 is older style
  3316.           #Here X is in radius ccords and the toolpath is executed in C (Y coord) and Z
  3317.           pbld, n$, pfsgplane, "H0.", "W0.", e$
  3318.           pbld, n$, *sg107, *crad, e$
  3319.           ]
  3320.         ]
  3321.  
  3322. pmillcca        #Cross/Face canned cycle code, after
  3323.       #cancel at end of op only regardless of whether or not the next op
  3324.       if interp_flg,
  3325.         [
  3326.         interp_flg = 0
  3327.         #Cross/Face canned cycle end code
  3328.         result = newfs(12, cabs)
  3329.         result = newfs(14, cinc)
  3330.         !cabs
  3331.         cabs = 0
  3332.         if abs(last_cuttype) = two,   #Face
  3333.           [
  3334.           #Fanuc Style
  3335.           pbld, n$, *sg113, e$
  3336.           ]
  3337.         else,                         #Cross
  3338.           [
  3339.           #Fanuc Style
  3340.           pbld, n$, *sg108, pfcout, e$
  3341.           ]
  3342.         cabs = prv_cabs
  3343.         ]
  3344.  
  3345. # --------------------------------------------------------------------------
  3346. # Drilling
  3347. # --------------------------------------------------------------------------
  3348. pdrill0$         #Pre-drill postblock call
  3349.       if cuttype = five, #Don't allow 5 axis, rests at toolchange
  3350.         [
  3351.         usecandrill$ = zero
  3352.         usecanpeck$ = zero
  3353.         usecanchip$ = zero
  3354.         usecantap$ = zero
  3355.         usecanbore1$ = zero
  3356.         usecanbore2$ = zero
  3357.         usecanmisc1$ = zero
  3358.         usecanmisc2$ = zero
  3359.         ]
  3360.       else,
  3361.         [
  3362.         if abs(cuttype) < three, mdrl_dir = zero
  3363.         else, mdrl_dir = one
  3364.         x$ = xnci$
  3365.         y$ = ynci$
  3366.         z$ = refht$
  3367.         copy_x = vequ(x$)
  3368.         pshft_map_xa
  3369.         pxyzcout
  3370.         refht_x = vequ(xabs)
  3371.         z$ = depth$
  3372.         copy_x = vequ(x$)
  3373.         pshft_map_xa
  3374.         pxyzcout
  3375.         depth_x = vequ(xabs)
  3376.         z$ = zdrl$
  3377.         copy_x = vequ(x$)
  3378.         pshft_map_xa
  3379.         pxyzcout
  3380.         zdrl_x = vequ(xabs)
  3381.         z$ = initht$  #Initial is last
  3382.         copy_x = vequ(x$)
  3383.         pshft_map_xa
  3384.         pxyzcout
  3385.         initht_x = vequ(xabs)
  3386.         znci$ = initht$
  3387.         ps_inc_calc
  3388.         ]
  3389.  
  3390. pdrlcommonb     #Canned Drill Cycle common call, before
  3391.       if gcode$ = 81,
  3392.         [
  3393.         if drillcyc$ = three, drlgsel = fsg1 (-g_speed) + drillcyc$ * two #Tap
  3394.         else, drlgsel = fsg2 (dwell$) + drillcyc$ * two
  3395.         if initht$ <> refht$, drillref = zero
  3396.         else, drillref = one
  3397.         prv_refht_a = c9k
  3398.         prv_refht_i = c9k
  3399.         prv_dwell$ = zero
  3400.         ]
  3401.       if mdrl_dir = zero, #Set Z to depth
  3402.         [
  3403.         zia = fmtrnd(depth_z)
  3404.         zinc = zia - prv_zia
  3405.         ]
  3406.       else,               #Set X to depth
  3407.         [
  3408.         xia = fmtrnd(depth_x)
  3409.         xinc = xia - prv_xia
  3410.         ]
  3411.       xabs = vequ (depth_x)
  3412.       comment$
  3413.       pcan
  3414.  
  3415. pgdrlout        #Drill Gcode output
  3416.       if mdrl_dir = zero, *sgdrillf
  3417.       else, *sgdrillc
  3418.  
  3419. prdrlout        #R drill position
  3420.       if mdrl_dir = zero,
  3421.         [
  3422.         refht_a = refht_z
  3423.         refht_i = refht_a - initht_z
  3424.         ]
  3425.       else,
  3426.         [
  3427.         refht_a = refht_x
  3428.         refht_i = (refht_a - initht_x) / dia_mult
  3429.         ]
  3430.       #if absinc$ = zero, refht_a, !refht_i
  3431.       #else, refht_i, !refht_a
  3432.       refht_i, !refht_a            #Fanuc is always incremental from initial height
  3433.  
  3434. ldrill$          #Canned drill cycle, lathe
  3435.       pdrlcommonb
  3436.       pcan1, pbld, n$, *sgdrlref, pgdrlout, pxout, pyout, pzout,
  3437.         prdrlout, dwell$, pffr, strcantext, e$
  3438.       pcom_movea
  3439.       pcanceldcl
  3440.  
  3441. lpeck$           #Canned peck drill cycle, lathe
  3442.       pdrlcommonb
  3443.       pcan1, pbld, n$, *sgdrlref, pgdrlout, pxout, pyout, pzout,
  3444.         prdrlout, *peck1$, dwell$, pffr, strcantext, e$
  3445.       pcom_movea
  3446.       pcanceldcl
  3447.  
  3448. lchpbrk$         #Canned chip break cycle, lathe
  3449.       pdrlcommonb
  3450.       pcan1, pbld, n$, *sgdrlref, pgdrlout, pxout, pyout, pzout,
  3451.         prdrlout, *peck1$, dwell$, pffr, strcantext, e$
  3452.       pcom_movea
  3453.       pcanceldcl
  3454.  
  3455. ltap$            #Canned tap cycle, lathe
  3456.       pdrlcommonb
  3457.       if rigid_tap,
  3458.         [
  3459.         pbld, n$, sm122, e$
  3460.         rigid_tap_flg = 1
  3461.         ]
  3462.       if use_pitch = 0, #Feed/Min mode, feed divided by spindle speed is equal to thread lead
  3463.         [
  3464.         if rigid_tap, pbld, n$, *sm129, *speed, e$           #Rigid Tapping    Can use G84/G88 with M29 or just G84.2
  3465.         pcan1, pbld, n$, *sgdrlref, pgdrlout, pxout, pyout, pzout,
  3466.           prdrlout, dwell$, pffr, strcantext, e$
  3467.         ]
  3468.       else, #Feed/Rev mode, feed is equal to thread lead
  3469.         [
  3470.         if rigid_tap, pbld, n$, *sm129, *speed, e$           #Rigid Tapping    Can use G84/G88 with M29 or just G84.2
  3471.         if met_tool$, pitch = n_tap_thds$  # Tap pitch (mm  per thread)
  3472.         else, pitch = 1/n_tap_thds$       # Tap pitch (inches per thread)
  3473.         pcan1, pbld, n$, *sgdrlref, pgdrlout, pxout, pyout, pzout,
  3474.           prdrlout, dwell$, *pitch, !feed, strcantext, e$
  3475.         ]
  3476.       pcom_movea
  3477.       pcanceldcl
  3478.  
  3479. lbore1$          #Canned bore #1 cycle, lathe
  3480.       ldrill$
  3481.  
  3482. lbore2$          #Canned bore #2 cycle, lathe
  3483.       ldrill$
  3484.  
  3485. lmisc1$          #Canned misc #1 cycle, lathe (Reamer)
  3486.      
  3487.       pdrlcommonb
  3488.       pbld, n$, sg01, pxout, pyout, pzout, pffr, e$
  3489.       if dwell$, sg04, dwell$, e$
  3490.       if drl_prm1$,
  3491.             [
  3492.             retractFeed = drl_prm1$
  3493.             pbld, n$, sg01, refht_z, *retractFeed, e$
  3494.             ]
  3495.        else,
  3496.             [
  3497.             #retractFeed = pffr * 4
  3498.             pbld, n$, sg01, refht_z, pffr, e$
  3499.             ]
  3500.       pcom_movea
  3501.       #pe_inc_calc
  3502.  
  3503. lmisc2$          #Canned misc #2 cycle, lathe
  3504.       ldrill$
  3505.  
  3506. mdrill$          #Canned drill cycle, mill
  3507.       pdrlcommonb
  3508.       pcan1, pbld, n$, *sgdrlref, pgdrlout, pxout, pyout, pzout,
  3509.         pcout, pindexdrl, prdrlout, dwell$, pffr, pfclampon, strcantext, e$
  3510.       pcom_movea
  3511.  
  3512. mpeck$         #Longhand drilling, mill
  3513.       pdrlcommonb
  3514.       pcan1, pbld, n$, *sgdrlref, pgdrlout, pxout, pyout, pzout,
  3515.         pcout, pindexdrl, prdrlout, *peck1$, dwell$, pffr, pfclampon, strcantext, e$
  3516.       pcom_movea
  3517.  
  3518. mchpbrk$       #Canned chip break cycle, mill
  3519.       pdrlcommonb
  3520.       pcan1, pbld, n$, *sgdrlref, pgdrlout, pxout, pyout, pzout,
  3521.         pcout, pindexdrl, prdrlout, *peck1$, dwell$, pffr, pfclampon, strcantext, e$
  3522.       pcom_movea
  3523.  
  3524. mtap$          #Canned tap cycle, mill
  3525.       pdrlcommonb
  3526.       if rigid_tap,
  3527.         [
  3528.         pbld, n$, sm126, e$
  3529.         rigid_tap_flg = 1
  3530.         ]
  3531.       if use_pitch = 0, #Feed/Min mode, feed divided by spindle speed is equal to thread lead
  3532.         [
  3533.         if rigid_tap, pbld, n$, *sm129, *speed, e$           #Rigid Tapping    Can use G84/G88 with M29 or just G84.2
  3534.         pcan1, pbld, n$, *sgdrlref, pgdrlout, pxout, pyout, pzout, pcout,
  3535.           pindexdrl, prdrlout, dwell$, pffr, pfclampon, strcantext, e$
  3536.           #pindexdrl, prdrlout, dwell$, pffr, [if rigid_tap, "P500"], pfclampon, strcantext, e$
  3537.         ]
  3538.       else, #Feed/Rev mode, feed is equal to thread lead
  3539.         [
  3540.         if rigid_tap, pbld, n$, *sm129, *speed, e$           #Rigid Tapping    Can use G84/G88 with M29 or just G84.2
  3541.         if metvals, pitch = n_tap_thds$  # Tap pitch (mm  per thread)
  3542.         else, pitch = 1/n_tap_thds$       # Tap pitch (inches per thread)
  3543.         pcan1, pbld, n$, *sgdrlref, pgdrlout, pxout, pyout, pzout, pcout,
  3544.           pindexdrl, prdrlout, dwell$, *pitch, !feed, pfclampon, strcantext, e$
  3545.           #pindexdrl, prdrlout, dwell$, *pitch, !feed, [if rigid_tap, "P500"], pfclampon, strcantext, e$
  3546.         ]
  3547.       pcom_movea
  3548.  
  3549. mbore1$        #Canned bore #1 cycle, mill
  3550.       pdrlcommonb
  3551.       pcan1, pbld, n$, *sgdrlref, pgdrlout, pxout, pyout, pzout,
  3552.         pcout, pindexdrl, prdrlout, *shftdrl$, dwell$, pffr, pfclampon, strcantext, e$
  3553.       pcom_movea
  3554.  
  3555. mbore2$        #Canned bore #2 cycle, mill
  3556.       mbore1$
  3557.  
  3558. mmisc1$        #Canned misc #1 cycle, mill (Reamer)
  3559.       pdrlcommonb
  3560.       pbld, n$, sg01, pxout, pyout, pzout, pffr, e$
  3561.       if dwell$, sg04, dwell$, e$
  3562.      
  3563.       if mdrl_dir = one,
  3564.       [
  3565.         if drl_prm1$,
  3566.         [
  3567.         retractFeed = drl_prm1$
  3568.         pbld, n$, sg01, refht_x, *retractFeed, e$
  3569.         ]
  3570.         else, pbld, n$, sg01, refht_x, pffr, e$
  3571.       ]
  3572.       if mdrl_dir = zero,
  3573.       [
  3574.         if drl_prm1$,
  3575.         [
  3576.         retractFeed = drl_prm1$
  3577.         pbld, n$, sg01, refht_z, *retractFeed, e$
  3578.         ]
  3579.         else, pbld, n$, sg01, refht_z, pffr, e$
  3580.       ]
  3581.       pcom_movea
  3582.  
  3583. mmisc2$        #Canned misc #2 cycle, mill
  3584.       mdrill$
  3585.  
  3586. mdrill_2$      #Canned drill cycle repeat, mill
  3587.       pdrlcommonb
  3588.       pcan1, pbld, n$, pxout, pyout, pzout, pcout, pindexdrl, prdrlout,
  3589.       dwell$, pfr, strcantext, e$
  3590.       pcom_movea
  3591.  
  3592. mpeck_2$       #Canned peck drill cycle repeat, mill
  3593.       mdrill_2$
  3594.  
  3595. mchpbrk_2$     #Canned chip break cycle repeat, mill
  3596.       pdrlcommonb
  3597.       pcan1, pbld, n$, pxout, pyout, pzout, pcout, pindexdrl, prdrlout,
  3598.       [if peck1$, *peck1$], dwell$, pfr, strcantext, e$
  3599.       pcom_movea
  3600.  
  3601. mtap_2$        #Canned tap cycle repeat, mill
  3602.       pdrlcommonb
  3603.       pcan1, pbld, n$, pxout, pyout, pzout, pcout, pindexdrl, prdrlout,
  3604.       dwell$, strcantext, e$
  3605.       pcom_movea
  3606.  
  3607. mbore1_2$      #Canned bore #1 cycle repeat, mill
  3608.       mdrill_2$
  3609.  
  3610. mbore2_2$      #Canned bore #2 cycle repeat, mill
  3611.       mdrill_2$
  3612.  
  3613. mmisc1_2$      #Canned misc #1 cycle repeat, mill
  3614.       mdrill_2$
  3615.  
  3616. mmisc2_2$      #Canned misc #2 cycle repeat, mill
  3617.       mdrill_2$
  3618.  
  3619. pdrill_entryfeed
  3620.       pdrlcommonb
  3621.       pck_amt = peck1$
  3622.       drill_dist = (-depth$ + tosz$)
  3623.       pck_no = (drill_dist/ pck_amt)
  3624.       pck_no = fmtrnd(pck_no)
  3625.       pass = pck_no
  3626.       rtr_hgt = (tosz$ + .1)
  3627.       z_calc = 0
  3628.       z_clear_val = peckclr$
  3629.       z_clear = (tosz$ + z_clear_val)
  3630.       z_start_pos = initht$
  3631.       entryfeed = drl_prm1$
  3632.       exitfeed = drl_prm2$
  3633.       drillfeed = frplunge$
  3634.      
  3635.       pbld, n$, pxout, pyout, pcout, e$
  3636.       if drl_prm1$ <> 0, pbld, n$, sg01, *rtr_hgt, *entryfeed, e$
  3637.       else, pbld, n$, sg00, *rtr_hgt, e$
  3638.  
  3639.       while pass > 0,
  3640.        [
  3641.        drl_depth = ((tosz$-(pck_amt)) + (-z_calc))
  3642.        pbld, n$, *sg01, *drl_depth, *drillfeed, e$
  3643.        pbld, n$, sg00, *rtr_hgt, e$
  3644.        prv_zdrill = drl_depth
  3645.        z_calc = z_calc + pck_amt
  3646.        z_clear = (prv_zdrill + z_clear_val)
  3647.        pbld, n$, sg00, z_clear, e$
  3648.        pass = pass - 1
  3649.        ]
  3650.  
  3651.       z_clear = (prv_zdrill + z_clear_val)
  3652.       pbld, n$, sg01, pfzout, feed, e$
  3653.       pbld, n$, sg00, *rtr_hgt, e$
  3654.       if drl_prm2$ <> 0, pbld, n$, sg01, *z_start_pos, *exitfeed, e$
  3655.       else, pbld, n$, sg00, *z_start_pos, e$
  3656.       pcom_movea
  3657.  
  3658. pdrlcst$         #Custom drill cycles 8 - 19 (user option)
  3659.       if drillcyc$ = 8, pdrill_entryfeed
  3660.  
  3661. pdrlcst_2$       #Custom drill cycles 8 - 19 (user option)
  3662.       pdrlcst$
  3663.      
  3664. pcanceldc$     #Cancel mill drill cycle
  3665.       xabs = vequ (initht_x) #Position to return
  3666.       ps_inc_calc
  3667.       pe_inc_calc #Update to current location
  3668.       gcode$ = zero
  3669.       pcan
  3670.       if drillcyc$ < 8, pcan1, pbld, n$, sgcode, "G80", strcantext, e$
  3671.       if rigid_tap_flg,
  3672.         [
  3673.         pbld, n$, sm128, e$
  3674.         pbld, n$, sm127, e$
  3675.         rigid_tap_flg = 0
  3676.         ]
  3677.       pcan2
  3678.  
  3679. pcanceldcl     #Cancel lathe drill cycle
  3680.       xabs = vequ (initht_x) #Position to return
  3681.       ps_inc_calc
  3682.       pe_inc_calc #Update to current location
  3683.       gcode$ = zero
  3684.       pcan
  3685.       pcan1, pbld, n$, sgcode, "G80", strcantext, e$
  3686.       if rigid_tap_flg,
  3687.         [
  3688.         pbld, n$, sm128, e$
  3689.         pbld, n$, sm123, e$
  3690.         rigid_tap_flg = 0
  3691.         ]
  3692.       pcan2
  3693.  
  3694. # --------------------------------------------------------------------------
  3695. # Version 9+ MiscOps Section
  3696. # --------------------------------------------------------------------------
  3697. #Miscellaneous Variables Common to all Miscops operations
  3698. #Format as needed
  3699.  
  3700. #Integers
  3701. #miscops_mi1, miscops_mi2, miscops_mi3,
  3702. #miscops_mi4,  miscops_mi5, miscops_mi6,
  3703. #miscops_mi7, miscops_mi8, miscops_mi9,
  3704. #miscops_mi10
  3705.  
  3706. #Reals
  3707. #miscops_mr1, miscops_mr2, miscops_mr3,
  3708. #miscops_mr4, miscops_mr5, miscops_mr6,
  3709. #miscops_mr7, miscops_mr8, miscops_mr9,
  3710. #miscops_mr10
  3711. #
  3712. # --------------------------------------------------------------------------
  3713. #Format Assignments and Initializations
  3714. # --------------------------------------------------------------------------
  3715. fmt "Z" 2 stck_init_z$           #Initial Z position of the stock (900-902,904,905)
  3716. fmt "Z" 2 stck_final_z$          #Final Z position of the stock (900-902,904,905)
  3717. fmt "Z" 2 stck_chuk_st_z$        #Initial Z axis Chuck Position (900-903)
  3718. fmt "X" 2 stck_chuk_st_x$        #Initial X axis Chuck Position (900-903)
  3719. fmt "Z" 2 stck_chuk_end_z$       #Final Z axis Chuck Position (900-903)
  3720. fmt "X" 2 stck_chuk_end_x$       #Final X axis Chuck Position (900-903)
  3721. fmt "B" 3 stck_chuk_st_dz$       #Destination chuck Z axis reference position before transfer (900)
  3722. fmt "U" 3 stck_chuk_st_dx$       #Destination chuck X axis reference position before transfer (900)
  3723. fmt "B" 3 stck_chuk_end_dz$      #Destination chuck Z axis reference position after transfer (900)
  3724. fmt "U" 3 stck_chuk_end_dx$      #Destination chuck X axis reference position after transfer (900)
  3725. fmt "Z" 2 stck_clear$            #Stock clearance value for stock pull operation (902)
  3726. fmt "X" 2 stck_tool_x$           #Tool X axis position for bar stop / puller (902)
  3727. fmt "Z" 2 stck_grip$             #Grip length value for stock pull operation(902)
  3728.  
  3729. fmt "F" 18 stck_adv_fr$          #Used with Lathe Stock Advance (Bar-Feed/Pull) function (NCI 902)
  3730. fmt "F" 18 stck_appr_fr$         #Used with Lathe Stock Advance (Bar-Feed/Pull) function (NCI 902)
  3731.  
  3732. #Flags
  3733. stck_op$         : 0             #Stock advance operation method (902)
  3734.                                 #(0=Push stock,1=Push stock with Use Tool Stop option,2=Pull stock)
  3735. stck_spindle$    : 0             #Active spindle with stock to transfer (900-902)
  3736.                                 #0=Left Spindle,1=Right Spindle
  3737. clmp_op$         : 0             #The selected Operation mode: 0=Clamp,1=Un-clamp,2=Re-position (903)
  3738. clmp_spindle$    : 0             #Active spindle for clamp/unclamp 0=Left Spindle,1=Right Spindle (903)
  3739. tlstck_on$       : 0             #Retract or engage the tailstock (0=Retract,1=Engage) (904)
  3740.  
  3741. toolend_flg     : 1             #Flag to execute ptoolend sequence or not
  3742. transfer        : 0
  3743.  
  3744. fmt "T" 4 miscops_mi1$      #Tool call
  3745. fmt "B" 2 miscops_mr1$      #sub rapid point
  3746. fmt "B" 2 miscops_mr2$      #sub feed point
  3747. fmt "Z" 2 miscops_mr3$      #tool move point
  3748.  
  3749.  
  3750. fmt "B" 2 subreturn         #Initial Z axis Chuck Position (900-903)
  3751. # --------------------------------------------------------------------------
  3752. #Postblock Section -comments only!
  3753. # --------------------------------------------------------------------------
  3754. pstck_trans$     #NCI code = 900 available variables:
  3755.                 #stck_spindle, stck_init_z, stck_final_z,
  3756.                 #stck_chuk_st_z, stck_chuk_st_x,
  3757.                 #stck_chuk_end_z, stck_chuk_end_x,
  3758.                 #stck_chuk_st_dz, stck_chuk_st_dx,
  3759.                 #stck_chuk_end_dz, stck_chuk_end_dx
  3760.                 if toolchng <> two, ptoolend$
  3761.                 toolend_flg = zero  #Do not execute ptoolend again after xfer
  3762.                 [
  3763. #                 !spaces$
  3764. #                 spaces$ = zero
  3765. #                 pbld, n$, "M00",e$
  3766. #                 if prv_spaces$ > 0, " ",e$
  3767. #                 if stck_spindle$ = 0, "(Xfer Part from Left Spindle)", e$
  3768. #                 if stck_spindle$ = 1, "(Xfer Part from Right Spindle)", e$
  3769. #                 spaces$ = prv_spaces$
  3770.                 ]
  3771.  
  3772.       !spaces$
  3773.       spaces$ = zero
  3774.  
  3775.       *e$
  3776.       if stck_chuk_st_dz$ = stck_chuk_end_dz$,
  3777.        [
  3778.        pbld, n$, "(CHUCK RETRACT ONLY)", e$
  3779.        transfer = 2
  3780.        ]
  3781.       else,
  3782.        [
  3783.        pbld, n$, "(TRANSFER)", e$                #Transfer program
  3784.        transfer = 1
  3785.        ]
  3786.  
  3787.       if transfer = 1,
  3788.         [
  3789.         toolchng = 1
  3790.         pbld, n$, pwcs, e$
  3791.         toolchng = 0
  3792.  
  3793.         if miscops_mi1$,    #No output of tool or motion if no tool selected
  3794.           [
  3795.           toolno = miscops_mi1$
  3796.           if omitseq$ = 1 & tseqno > 0,
  3797.             [
  3798.             if tseqno = 2, n$ = int(miscops_mi1$ / 100)
  3799.             pbld, *n$, *toolno, "(CUTOFF TOOL, MISC INT 1)", e$
  3800.             ]
  3801.           else, pbld, n$, *toolno, "(CUTOFF TOOL, MISC INT 1)", e$
  3802.           pbld, n$, "G0", *miscops_mr3$, "(TOOL RAPID POSITION, MISC REAL 3)", e$  #MOVE TO POSITION
  3803.           ]
  3804.  
  3805.  
  3806.         pbld, n$, "(OPEN SUB HERE)", e$
  3807.  
  3808.         pbld, n$, "G0", *miscops_mr1$, "(SUB RAPID POSITION, MISC REAL 1)", e$           #sub rapid to position
  3809.  
  3810.         if miscops_mi2$,
  3811.           [
  3812.           pbld, n$, "G1G98", *miscops_mr2$, "(SUB FEED POSITION, MISC REAL 2)", "F50.", e$     #sub feed to position
  3813.           pbld, n$, "(TORQUE SKIP MODE ON HERE)", e$    #torque skip
  3814.           pbld, n$, "(TORQUE SKIP CODE HERE)G98", *stck_chuk_end_dz$, "F30.", "(SUB PICK-OFF POSITION)", e$     #sub feed to position
  3815.           #Usually there's a macro here to check if it's within tolerance of the theoretical position
  3816.           ]
  3817.         else, pbld, n$, "G1G98", *stck_chuk_end_dz$, "F50.", "(SUB PICK-OFF POSITION)", e$
  3818.  
  3819.  
  3820.         pbld, n$, "G4", "U500", e$           #dwell
  3821.         pbld, n$, "(CLOSE SUB HERE)", e$              #close sub
  3822.         pbld, n$, "G4", "U500", e$            #dwell
  3823.  
  3824.         if stck_init_z$ <> stck_final_z$,
  3825.           [
  3826.           #output this little section if you want motion before the cutoff
  3827.           pbld, n$, "(OPEN MAIN HERE)", e$
  3828.           pbld, n$, "G4U500", e$  #
  3829.           subreturn = (stck_final_z$ - stck_init_z$) + stck_chuk_end_dz$
  3830.           pbld, n$, "G1G98", *subreturn, "F50.", "(SUB RETRACT POSITION)", e$  #This could be a G28 or a # macro variable also
  3831.           pbld, n$, "(CLOSE MAIN HERE)", e$  #(MAINCLOSE)
  3832.           pbld, n$, "G4U500", e$  #
  3833.          ]
  3834.        ]
  3835.  
  3836.  
  3837.            #Cutoff code goes here
  3838.  
  3839.  
  3840.       if transfer = 2,
  3841.         [
  3842.         pbld, n$, "G55", "G0", "B0.", "(SETUP SUB RETURN HOME)", e$    #Assuming G55 and B0 is set at home, this could be a G28 or a # macro variable
  3843.         pbld, n$, "M01", e$
  3844.         *e$
  3845.         ]
  3846.  
  3847.       spaces$ = prv_spaces$
  3848.  
  3849.  
  3850. pstck_flip$     #NCI code = 901 available variables:
  3851.                 #stck_spindle, stck_init_z, stck_final_z,
  3852.                 #stck_chuk_st_z, stck_chuk_st_x,
  3853.                 #stck_chuk_end_z, stck_chuk_end_x
  3854.                 if toolchng <> two, ptoolend$
  3855.                 toolend_flg = zero  #Do not execute ptoolend again after xfer
  3856.                 [
  3857.                  !spaces$
  3858.                  spaces$ = zero
  3859.                  #pbld, n$, "M00",e$
  3860.                  #if prv_spaces$ > 0, " ",e$
  3861.                  #"(STOCK FLIP)", e$
  3862.                  spaces$ = prv_spaces$
  3863.                 ]
  3864.  
  3865. pstck_bar_fd$   #NCI code = 902 available variables:
  3866.                 #stck_spindle, stck_op, stck_clear,
  3867.                 #stck_grip, stck_init_z, stck_final_z,
  3868.                 #stck_chuk_st_z, stck_chuk_st_x,
  3869.                 #stck_chuk_end_z, stck_chuk_end_x,
  3870.                 #stck_adv_fr, stck_appr_fr
  3871.                
  3872.                 if stck_op$ = 0,  # if NOT using the 'Tool Stop option'
  3873.                  [
  3874.                   if toolchng <> two, ptoolend$
  3875.                   toolend_flg = zero  #Do not execute ptoolend again after xfer
  3876.                  ]
  3877.                 else,
  3878.                  [
  3879.                   toolend_flg = one  #DO execute ptoolend after xfer
  3880.                   !spaces$
  3881.                   spaces$ = one
  3882.                   if stck_op$ = 0, "(Push Stock -",
  3883.                   if stck_op$ = 1,"(Push Stock -",
  3884.                   [
  3885.                   if stck_spindle$ = 0, "From Main Spindle)", e$
  3886.                   if stck_spindle$ = 1, "From Sub Spindle)", e$
  3887.                   ]
  3888.                   if stck_op$ = 2,
  3889.                   [
  3890.                   pbld, n$, sg00, stck_final_z$, e$
  3891.                   pbld, n$, pfxout, e$
  3892.                   pbld, n$, *sm00, "(ACCOTER LA BARRE)", e$
  3893.                   pbld, n$, sg00, *stck_clear$, e$
  3894.                   ]
  3895.                  ]
  3896.                 spaces$ = prv_spaces$
  3897.  
  3898. pchuck$          #NCI code = 903 available variables:
  3899.                 #clmp_spindle, clmp_op,  stck_chuk_st_z,
  3900.                 #stck_chuk_st_x, stck_chuk_end_z, stck_chuk_end_x
  3901.                 if clmp_op$ = two,
  3902.                   [
  3903.                   if toolchng <> two, ptoolend$
  3904.                   toolend_flg = zero  #Do not execute ptoolend again after xfer
  3905.                   ]
  3906.  
  3907.                 [
  3908.                   !spaces$
  3909.                   spaces$ = zero
  3910.                   pbld, n$, "M00",e$
  3911.                   if prv_spaces$ > 0, " ",e$
  3912.                   if clmp_op$ = 0, "(Clamp -",e$
  3913.                   if clmp_op$ = 1, "(Un-clamp -",e$
  3914.                   if clmp_op$ = 2, "(Re-position -",e$
  3915.                   if clmp_spindle$ = 0, " Left Spindle)", e$
  3916.                   if clmp_spindle$ = 1, " Right Spindle)", e$
  3917.                   spaces$ = prv_spaces$
  3918.                 ]
  3919.                 if clmp_op$ >= one, pchuck_unclamp
  3920.                 if clmp_op$ = two, pbld, n$, *stck_chuk_end_z$, e$
  3921.                 if clmp_op$ = zero | clmp_op$ = two, pchuck_clamp
  3922.  
  3923. pchuck_clamp    #user-defined postblock for chuck clamp
  3924.                 if clmp_spindle$ = zero, "M10", e$
  3925.                 if clmp_spindle$ = one, "M210", e$
  3926.  
  3927. pchuck_unclamp  #user-defined postblock for chuck unclamp
  3928.                 if clmp_spindle$ = zero, "M11", e$
  3929.                 if clmp_spindle$ = one, "M211", e$
  3930.  
  3931. ptailstock$      #NCI code = 904 available variables:
  3932.                 #tlstck_on, stck_init_z, stck_final_z
  3933.                 if toolchng <> two, ptoolend$
  3934.                 toolend_flg = zero  #Do not execute ptoolend again after xfer
  3935.                 [
  3936.                  !spaces$
  3937.                  spaces$ = zero
  3938.                  #pbld, n$, *sm01,e$
  3939.                  #if prv_spaces$ > 0, " ",e$
  3940.                  if tlstck_on$ = 0, pbld, *sm26, "(TS OUT)", e$
  3941.                  if tlstck_on$ = 1, pbld, *sm25, "(TS IN)", e$
  3942.                  pbld, n$, *sm01,e$
  3943.                  " ", e$
  3944.                  spaces$ = prv_spaces$
  3945.                 ]
  3946.  
  3947. psteadyrest$     #NCI code = 905 available variables:
  3948.                 #stck_init_z, stck_final_z
  3949.                 if toolchng <> two, ptoolend$
  3950.                 toolend_flg = zero  #Do not execute ptoolend again after xfer
  3951.                 [
  3952.                  !spaces$
  3953.                  spaces$ = zero
  3954.                  pbld, n$, "M00",e$
  3955.                  if prv_spaces$ > 0, " ",e$
  3956.                  "(Position Steadyrest)", e$
  3957.                  spaces$ = prv_spaces$
  3958.                 ]
  3959.  
  3960. # --------------------------------------------------------------------------
  3961. # Threading output
  3962. # --------------------------------------------------------------------------
  3963. pthread0$        #Pre-thread calculations
  3964.       # Calculate taper delta 'X' on Acceleration Clearance distance
  3965.       thdrdlt = (((thdx2$ - thdx3$) / (thdz1$ - thdz2$)) * thdzclr$)
  3966.       # Add to the original thread 'X' difference calculation
  3967.       thdrdlt = (thdrdlt + (thdx2$ - thdx3$)) * pl_ax_m0x
  3968.       #thdang = rad2deg$ * thdangle$      #lead-in angle
  3969.       #thdang = rad2deg$ * thda1$       #half of the thread angle
  3970.       thdang = rad2deg$ * thda2$        #thread angle (full included angle)
  3971.       thd_dirx = (thdx2$ - thdx3$) * pl_ax_m0x
  3972.       thd_dirz = (thdz1$ - thdz2$) * pl_ax_m0z
  3973.       thd_vlen = thdlead$/ nstarts$
  3974.       thd_dirx = vsa (thd_vlen, thd_dirx)
  3975.       if fr_pos$, pthreadpull
  3976.       else, thdpull = zero
  3977.  
  3978. pthreadpull     #Pre-thread calculations
  3979.       if thdpulloff$/(fr_pos$*10) > 0.99,thdpull = 99
  3980.       else, thdpull = (thdpulloff$/(fr_pos$*10))*100
  3981.  
  3982. pthdext$         #Calculation override for external thread
  3983.       #thddepth = thdlead * .61343         #Calc. thread depth
  3984.       #thdflat  = thdlead * .1667          #Calc. thread flat
  3985.  
  3986. pthdint$         #Calculation override for internal thread
  3987.       #thddepth = thdlead * .54127         #Calc. thread depth
  3988.       #thdflat  = thdlead * .125           #Calc. thread flat
  3989.  
  3990. pthdface$        #Calculation override for face thread
  3991.       #thddepth = thdlead * .61343         #Calc. thread depth
  3992.       #thdflat  = thdlead * .1667          #Calc. thread flat
  3993.  
  3994. pthrg32_1$       #G32 threading first
  3995.       comment$
  3996.       gcode$ = zero
  3997.       lrapid$
  3998.  
  3999. pthrg32_2$       #G32 threading second
  4000.       gcode$ = zero
  4001.       lrapid$
  4002.  
  4003. pthrg32_3$       #G32 threading third
  4004.       copy_x = vequ(x$)
  4005.       pcom_moveb
  4006.       pcan1, pbld, n$, psgfeed, *sthdgcode, pxout, pyout, pzout, pcout, pffr,
  4007.       strcantext, e$
  4008.       pcom_movea
  4009.       prv_gcode$ = m_one
  4010.  
  4011. pthrg32_4$       #G32 threading fourth
  4012.       gcode$ = zero
  4013.       lrapid$
  4014.  
  4015. pthrg92_1$       #G92 threading
  4016.       if thdpass$ = one, pthrg92_11
  4017.  
  4018. pthrg92_11      #G92 threading
  4019.       comment$
  4020.       gcode$ = zero
  4021.       lrapid$
  4022.       prv_feed = m_one
  4023.       prv_zabs = c9k
  4024.       prv_thdtype$ = m_one
  4025.  
  4026. pthrg92_2$       #G92 threading
  4027.  
  4028. pthrg92_3$       #G92 threading
  4029.       copy_x = vequ (x$)
  4030.       pcom_moveb
  4031.       pcan1, pbld, n$, psgfeed, sthdgcode, pfxout, pyout, pzout, pcout,
  4032.         [if thdrdlt & thdpass$ = one, *thdrdlt], pfr, strcantext, e$
  4033.       pcom_movea
  4034.       prv_gcode$ = m_one
  4035.  
  4036. pthrg92_4$       #G92 threading
  4037.  
  4038. pg32e$           #G32/G92 threading end
  4039.       gcode$ = zero
  4040.       lrapid$
  4041.  
  4042. pthrg76_1$       #G76 threading start point
  4043.       gcode$ = zero
  4044.       lrapid$
  4045.  
  4046. pg76$            #G76 threading
  4047.       comment$
  4048.       gcode$ = zero
  4049.       lrapid$
  4050.       sav_xa = vequ(copy_x)
  4051.       if thdface$ = zero, copy_x = thdx2$
  4052.       else, copy_z = thdx2$
  4053.       if thdface$ = zero, copy_z = thdz2$
  4054.       else, copy_x = thdz2$
  4055.       pcom_moveb
  4056.       nstart_cnt = zero
  4057.       while nstart_cnt < nstarts$, pg76nstart
  4058.       pcom_movea
  4059.       prv_gcode$ =  -1
  4060.       copy_x = vequ(sav_xa)
  4061.       copy_x = copy_x + (thd_dirx * (nstarts$ - one))
  4062.       copy_z = copy_z + (thd_dirz * (nstarts$ - one))
  4063.       pcom_moveb
  4064.       pe_inc_calc
  4065.       !gcode$, !xabs, !yabs, !zabs, !xinc, !yinc, !zinc
  4066.  
  4067. pg76nstart      #G76 threading, for multiple starts
  4068.       if old_new_sw = zero, pg76old
  4069.       else, pg76new
  4070.       nstart_cnt = nstart_cnt + one
  4071.       if nstarts$ <> one & nstart_cnt <> nstarts$,
  4072.       pbld, n$, *sgcode, thd_dirx, thd_dirz, e$
  4073.  
  4074. pg76old         #G76 threading old style
  4075.       pbld, n$, *sthdgcode, pfxout, pfzout, *thdrdlt, *thddepth$,
  4076.         *thdfirst$, *thdang, pffr, e$
  4077.  
  4078. pg76new         #G76 threading new style (on two lines)
  4079.       pbld, n$, *sthdgcode, *nspring$, *thdpull, *thdang, *thdlast$, *thdfinish$, e$
  4080.       pbld, n$, *sthdgcode, pfxout, pfzout, *thdrdlt, *thddepth$, *thdfirst$, pffr, e$
  4081.  
  4082. # --------------------------------------------------------------------------
  4083. # Lathe canned cycle output
  4084. # --------------------------------------------------------------------------
  4085. pg71old         #Output G71-G72 canned cycle routines, old style
  4086.       pbld, n$, *scclgcode, *ng70s, *ng70e, *xstckcc, *zstckcc,
  4087.         *depthcc, pffr, e$
  4088.  
  4089. pg71new         #Output G71-G72 canned cycle routines, new style, first
  4090.       if gcodecc = 1, result = nwadrs (stru, depthcc)
  4091.       else, result = nwadrs (strw, depthcc)
  4092.       pbld, n$, *scclgcode, *depthcc, *clearcc, e$
  4093.       pbld, n$, *scclgcode, *ng70s, *ng70e, *xstckcc, *zstckcc, pffr, e$
  4094.  
  4095. pg73old         #Output G73 canned cycle routines, old style
  4096.       pbld, n$, *scclgcode, *ng70s, *ng70e, *g73x, *g73z,
  4097.         *xstckcc, *zstckcc, *ncutscc, pffr, e$
  4098.  
  4099. pg73new       #Output G73 canned cycle routines, new style, first
  4100.       pbld, n$, *scclgcode, *g73x, *g73z, *ncutscc, e$
  4101.       pbld, n$, *scclgcode, *ng70s, *ng70e, *xstckcc, *zstckcc, pffr, e$
  4102.  
  4103. pg74old         #Output G74-G75 canned cycle routines, old style
  4104.       pbld, n$, *scclgcode, pfxout, pfzout, *grvspcc, *grvdpcc,
  4105.         *clearcc, pffr, e$
  4106.  
  4107. pg74new         #Output G74-G75 canned cycle routines, new style, first
  4108.       pbld, n$, *scclgcode, *clearcc, e$
  4109.       pbld, n$, pfsgfeed, *scclgcode, pfxout, pfzout, *grvspcc,
  4110.         *grvdpcc, pffr, e$
  4111.  
  4112. prcc_setup$      #Lathe canned cycle setup
  4113.                 #Capture values from rough
  4114.       sav_iprcc = c1_ipr_actv
  4115.       sav_feedcc = c1_fr_pos
  4116.       if orient$ = one|orient$ = two|orient$ = five|orient$ = 6, lccdirx = one
  4117.       else, lccdirx = m_one
  4118.       if orient$ = one|orient$ = four|orient$ = five|orient$ = 8, lccdirz = one
  4119.       else, lccdirz = m_one
  4120.       if lathecc > zero, cc_stop_fcc = one
  4121.       else, cc_stop_fcc = zero
  4122.       #G74/G75
  4123.       if lathecc = three,
  4124.         [
  4125.         lcc_xcst = vequ (copy_x)
  4126.         if dopeckcc = zero,
  4127.           [
  4128.           depthcc = zero
  4129.           clearcc = zero
  4130.           ]
  4131.         if directcc > one,
  4132.           [
  4133.           gcodecc = four
  4134.           grvspcc = stepcc
  4135.           grvdpcc = depthcc
  4136.           ]
  4137.         else,
  4138.           [
  4139.           gcodecc = five
  4140.           grvspcc = depthcc
  4141.           grvdpcc = stepcc
  4142.           ]
  4143.         ]
  4144.       else,
  4145.         [
  4146.         if n1_cc_pos,
  4147.           [
  4148.           sav_xa = vequ(copy_x)
  4149.           #Shift for cutter comp. start position
  4150.           copy_x = copy_x + (lcc_move * lccdirx)
  4151.           copy_z = copy_z + (lcc_move * lccdirz)
  4152.           pcom_moveb
  4153.           compok = zero
  4154.           lcc_cc_pos = one
  4155.           ]
  4156.         else, lcc_cc_pos = zero
  4157.         ]
  4158.       if mi10$ & (tool_op$ = 202 | tool_op$ = 203),     #CRF
  4159.         [
  4160.         crf_xsav1 = x$
  4161.         crf_zsav1 = z$
  4162.         ]
  4163.       sub_seq_typ$ = 0
  4164.  
  4165. prcc_call_st$    #Rough canned cycle start
  4166.       if tool_op$ <> 208,
  4167.         [
  4168.         sav_subout = subout$
  4169.         sav_omitsq = omitseq$
  4170.         omitseq$ = one
  4171.         extprg$ = one
  4172.         subout$ = three
  4173.         prv_gcode$ = m_one #Added (06/25/01)
  4174.         ]
  4175.  
  4176. prcc_call_end$   #Rough canned cycle end
  4177.       # Restore cc_1013 to the value it held prior to the rough  # 1/17/03
  4178.       # groove canned cycle. cc_1013 was changed in ptoolend.    # 1/17/03
  4179.       if tool_op$ = 208 | tool_op$ = 62, cc_1013$ = sav_cc_1013     # 1/17/03
  4180.  
  4181.       if tool_op$ <> 208,
  4182.         [
  4183.         omitseq$ = sav_omitsq
  4184.         #Close the ext file
  4185.         result = fclose (sbufname3$)
  4186.         #Open the ext file as a buffer
  4187.         #Use the size to determine the start and end sequence
  4188.         subout$ = sav_subout
  4189.         size3 = rbuf(three, zero)
  4190.         if omitseq$ = one,
  4191.           [
  4192.           ng70s = n$
  4193.           ng70e = n$ + seqinc$
  4194.           ]
  4195.         else,
  4196.           [
  4197.           if old_new_sw = zero, ng70s = n$ + seqinc$
  4198.           else, ng70s = n$ + (seqinc$ * two)
  4199.           ng70e = ng70s + (seqinc$ * (size3 - one))
  4200.           ]
  4201.         pwrite_g70
  4202.         ]
  4203.       #Setup the stock and clearance directions
  4204.       g73x = vsub (lcc_xcst,lcc_xcend)
  4205.       if old_new_sw = zero, g73x = g73x * pl_ax_m0x
  4206.       else, g73x = g73x * dia_mult
  4207.       g73z = g73z * pl_ax_m0z
  4208.       xstckcc =  xstckcc * dia_mult * lccdirx
  4209.       zstckcc =  zstckcc * lccdirz * pl_ax_m0z
  4210.       clearcc =  clearcc * lccdirz * pl_ax_m0z
  4211.       #Write the cycle definition
  4212.       sav_feed = feed
  4213.       sav_ipr = ipr_actv$
  4214.       feed = sav_feedcc
  4215.       ipr_actv$ = sav_iprcc
  4216.       if lathecc = three,
  4217.         [
  4218.         #Setup the previous position for inc. in G74/G75 cycle
  4219.         sav_xa = vequ(xabs) #Save the cycle end
  4220.         copy_x = vequ(lcc_xcst) #The cycle start raw
  4221.         pshft_map_xa
  4222.         pxyzcout  ##The cycle start in machine terms
  4223.         ps_inc_calc #Recalculate incremental
  4224.         pe_inc_calc #Update previous at start
  4225.         xabs = vequ(sav_xa) #Restore the cycle end
  4226.         ps_inc_calc #Recalculate incremental
  4227.         ]
  4228.       if old_new_sw = zero,
  4229.         [
  4230.         if gcodecc < three, pg71old
  4231.         if gcodecc = three, pg73old
  4232.         if gcodecc > three, pg74old
  4233.         ]
  4234.       else,
  4235.         [
  4236.         if gcodecc < three, pg71new
  4237.         if gcodecc = three, pg73new
  4238.         if gcodecc > three, pg74new
  4239.         ]
  4240.       if lathecc = three,
  4241.         [
  4242.         #Set the cycle end position at the original start
  4243.         copy_x = vequ(lcc_xcst) #The cycle start raw
  4244.         pshft_map_xa
  4245.         pxyzcout  ##The cycle start in machine terms
  4246.         ps_inc_calc #Position at start
  4247.         pe_inc_calc #Update previous
  4248.         ps_inc_calc #Recalculate incremental
  4249.         ]
  4250.       feed = sav_feed
  4251.       ipr_actv$ = sav_ipr
  4252.       if tool_op$ <> 208,
  4253.         [
  4254.         #Bug2 is off to prevent execution crashes with long strings
  4255.         bug2$ = zero
  4256.         #Write the cycle profile, sequence are written now
  4257.         rc3 = one
  4258.         while rc3 <= size3,
  4259.           [
  4260.           sav_eob = eob$           #save out eob character as it's getting lost
  4261.           eob$ = 32                #save out eob character as it's getting lost
  4262.           prv_eob$ = 32            #save out eob character as it's getting lost
  4263.           #Write the lathe canned cycle profile
  4264.           string3 = rbuf (three, rc3)
  4265.           if rc3 = two,
  4266.             [
  4267.             #Add the finish spindle speed to the first move
  4268.             speed = n1_ss
  4269.             #Mastercam is reporting 0 and 2 backwards for parameter 10124
  4270.             #Note that G71 type 1 and 3 are never allowed (can't change Z dir)
  4271.             #if g71type = 2 | g71type = 3, pbld, *n$, *string3, *speed, e$
  4272.             #if g71type = 1 | g71type = 0, pbld, *n$, *string3, *speed, "W0.", e$
  4273.             if g71type = 2 | g71type = 3, pbld, *n$, *string3, e$
  4274.             if g71type = 1 | g71type = 0, pbld, *n$, *string3, e$
  4275.             ]
  4276.           else,
  4277.             [
  4278.             if omitseq$ = one & rc3 = size3 + one, pbld, *n$, *string3, e$
  4279.             else, pbld, n$, *string3, e$
  4280.             ]
  4281.           eob$ = sav_eob          #save out eob character as it's getting lost
  4282.           ]
  4283.         #Close the buffer
  4284.         result = fclose (three)
  4285.         #Remove the ext file
  4286.         result = remove (sbufname3$)
  4287.         bug2$ = sav_bug2
  4288.         ]
  4289.  
  4290. pfcc_call$       #G70 recall output postblock
  4291.       if cc_stop_fcc = zero,
  4292.         [
  4293.         pread_g70
  4294.         if foundcc = zero, result = mprint(sfccerror)
  4295.         ]
  4296.       no_nc_out$ = zero
  4297.       cc_stop_fcc = zero
  4298.  
  4299. pread_g70       #Read G70 recall buffer
  4300.       foundcc = zero
  4301.       size2 = rbuf (two, zero)
  4302.       wc2 = one
  4303.       while wc2 <= size2 & foundcc = zero,
  4304.         [
  4305.         fcc_subid = rbuf (two, wc2)
  4306.         if fcc_subid = sub_op_id$,
  4307.           [
  4308.           gcodecc = zero
  4309.           ng70s = fcc_ng70s
  4310.           ng70e = fcc_ng70e
  4311.           pbld, n$, *scclgcode, *ng70s, *ng70e, e$
  4312.           foundcc = one
  4313.           ]
  4314.         ]
  4315.  
  4316. pwrite_g70      #Write G70 recall buffer
  4317.       fcc_subid = sub_op_id$
  4318.       fcc_ng70s = ng70s
  4319.       fcc_ng70e = ng70e
  4320.       fcc_subid = wbuf (two, rc2)
  4321.       if mi10$ & (tool_op$ = 202 | tool_op$ = 203),     #CRF
  4322.         [
  4323.         #Set the crf_flg to indicate that it's a canned rough and finish
  4324.         #Must be set after the output of the N (indicator of the end of the shape) so we can replace the Z coordinate at the right time.
  4325.         crf_line = sub_op_id$
  4326.         crf_xsav1 = wbuf(4,crf_line)
  4327.         prv_xabs = c9k
  4328.         ]
  4329.  
  4330. # --------------------------------------------------------------------------
  4331. #Subprogram output
  4332. #sub_trnstyp - 0=mirror, 1=rotate, 2=scale, 3=translate
  4333. #sub_trnmthd (mirror) - 0=X axis, 1=Y axis, 2=line
  4334. #sub_trnmthd (rotate) - 0=tplane, 1=tplane origin only, 2=coordinates
  4335. # --------------------------------------------------------------------------
  4336. pmiscint$        #Capture the top level absinc for subprograms
  4337.       if sub_level$ <= zero, absinc$ = mi2$
  4338.       ref_ret = mi3$
  4339.       synch_flg = mi5$
  4340.  
  4341. psub_call_m$     #Call to main level, single tool
  4342.       psub_call_trans
  4343.  
  4344. psub_call_mm$    #Call to main level, multiple tools
  4345.       psub_call_trans
  4346.  
  4347. psub_call_trans #Translate level calls from toolchange, user
  4348.       #Mirror and coordinate rotate subs not allowed with lathe
  4349.       if sub_trnstyp$ <> three & posttype$ = two, result = mprint(slthrmerror)
  4350.       if (sub_trnstyp$ = one & sub_trnmthd$ = two)
  4351.       | sub_trnstyp$ = zero, result = mprint(smilrmerror)
  4352.       sav_absinc = absinc$
  4353.       pindex
  4354.       if home_type > one,
  4355.         [
  4356.         if sub_mny_t$,
  4357.           [
  4358.           absinc$ = zero
  4359.           pbld, n$, pwcs, e$
  4360.           pbld, n$, *sgcode, pfxout, pfyout, pfzout, pfcout, e$
  4361.           pe_inc_calc
  4362.           ps_inc_calc
  4363.           ]
  4364.         ]
  4365.       else,
  4366.         [
  4367.         if home_type = one, result = mprint(shomeserror)
  4368.         else,
  4369.           [
  4370.           if sub_mny_t$, result = mprint(smny50error)
  4371.           ]
  4372.         #Apply G50 shift and correct incremental position
  4373.         if sub_sec_no$ & sub_trnstyp$ = three,
  4374.           [
  4375.           sub_trnsx$ = vmap(sub_trnsx$, hmtx1)
  4376.           sub_trnsx$ = vscl(m_one, sub_trnsx$)
  4377.           sub_trnsx$ = sub_trnsx$ * dia_mult
  4378.           sub_trnsy$ = sub_trnsy$ * y_mult
  4379.           sub_trnsz$ = sub_trnsz$ * z_mult
  4380.           pbld, n$, *sg50, *sub_trnsx$, [if y_axis_mch, *sub_trnsy$],
  4381.             *sub_trnsz$, e$
  4382.           prv_xia = vadd(prv_xia, sub_trnsx$)
  4383.           ps_inc_calc
  4384.           ]
  4385.         if toolchng = zero | home_type < two,
  4386.           [
  4387.           pbld, n$, *sgcode, pfxout, pfyout, pfzout, pfcout, e$
  4388.           pe_inc_calc
  4389.           ps_inc_calc
  4390.           ]
  4391.         ]
  4392.       absinc$ = sav_absinc
  4393.       result = nwadrs(strp, main_prg_no$)
  4394.       pbld, n$, "M98", *main_prg_no$, e$
  4395.       result = force(feed,feed) #Force feed in sub
  4396.  
  4397. psub_st_m$       #Header in main level
  4398.       result = nwadrs(stro, main_prg_no$)
  4399.       " ", e$
  4400.       *main_prg_no$, e$
  4401.  
  4402. psub_end_m$      #End in main level
  4403.       n$, "M99", e$
  4404.  
  4405. psub_call_s$     #Call to sub level
  4406.       if tool_op$ = 201,  pread_g70
  4407.       else, foundcc = zero
  4408.  
  4409.       if foundcc = zero,
  4410.         [
  4411.         result = nwadrs(strp, sub_prg_no$)
  4412.         sub_prg_no$ = sub_prg_no$ + 1000 #Add sub number offset
  4413.         pbld, n$, "M98", *sub_prg_no$, e$
  4414.         ]
  4415.  
  4416. psub_st_s$       #Header in sub leveln
  4417.       result = nwadrs(stro, sub_prg_no$)
  4418.       " ", e$
  4419.       *sub_prg_no$, e$
  4420.  
  4421. psub_end_s$      #End in sub level
  4422.       n$, "M99", e$
  4423.  
  4424. # --------------------------------------------------------------------------
  4425. # Canned Text
  4426. # --------------------------------------------------------------------------
  4427. pcan            #Canned text - before output call
  4428.       strcantext = sblank
  4429.       if cant_no$ > zero,
  4430.         [
  4431.         if cant_pos1$ = zero | cant_pos1$ = three, pcant_1
  4432.         if cant_pos2$ = zero | cant_pos2$ = three, pcant_2
  4433.         if cant_pos3$ = zero | cant_pos3$ = three, pcant_3
  4434.         if cant_pos4$ = zero | cant_pos4$ = three, pcant_4
  4435.         if cant_pos5$ = zero | cant_pos5$ = three, pcant_5
  4436.         if cant_pos6$ = zero | cant_pos6$ = three, pcant_6
  4437.         if cant_pos7$ = zero | cant_pos7$ = three, pcant_7
  4438.         if cant_pos8$ = zero | cant_pos8$ = three, pcant_8
  4439.         if cant_pos9$ = zero | cant_pos9$ = three, pcant_9
  4440.         if cant_pos10$ = zero | cant_pos10$ = three, pcant_10
  4441.         if cant_pos11$ = zero | cant_pos11$ = three, pcant_11
  4442.         if cant_pos12$ = zero | cant_pos12$ = three, pcant_12
  4443.         if cant_pos13$ = zero | cant_pos13$ = three, pcant_13
  4444.         if cant_pos14$ = zero | cant_pos14$ = three, pcant_14
  4445.         if cant_pos15$ = zero | cant_pos15$ = three, pcant_15
  4446.         if cant_pos16$ = zero | cant_pos16$ = three, pcant_16
  4447.         if cant_pos17$ = zero | cant_pos17$ = three, pcant_17
  4448.         if cant_pos18$ = zero | cant_pos18$ = three, pcant_18
  4449.         if cant_pos19$ = zero | cant_pos19$ = three, pcant_19
  4450.         if cant_pos20$ = zero | cant_pos20$ = three, pcant_20
  4451.         pbld, n$, strcantext, e$
  4452.         strcantext = sblank
  4453.         ]
  4454.  
  4455. pcan1           #Canned text - with move
  4456.       strcantext = sblank
  4457.       if cant_no$ > zero,
  4458.         [
  4459.         if cant_pos1$ = one | cant_pos1$ = four, pcant_1
  4460.         if cant_pos2$ = one | cant_pos2$ = four, pcant_2
  4461.         if cant_pos3$ = one | cant_pos3$ = four, pcant_3
  4462.         if cant_pos4$ = one | cant_pos4$ = four, pcant_4
  4463.         if cant_pos5$ = one | cant_pos5$ = four, pcant_5
  4464.         if cant_pos6$ = one | cant_pos6$ = four, pcant_6
  4465.         if cant_pos7$ = one | cant_pos7$ = four, pcant_7
  4466.         if cant_pos8$ = one | cant_pos8$ = four, pcant_8
  4467.         if cant_pos9$ = one | cant_pos9$ = four, pcant_9
  4468.         if cant_pos10$ = one | cant_pos10$ = four, pcant_10
  4469.         if cant_pos11$ = one | cant_pos11$ = four, pcant_11
  4470.         if cant_pos12$ = one | cant_pos12$ = four, pcant_12
  4471.         if cant_pos13$ = one | cant_pos13$ = four, pcant_13
  4472.         if cant_pos14$ = one | cant_pos14$ = four, pcant_14
  4473.         if cant_pos15$ = one | cant_pos15$ = four, pcant_15
  4474.         if cant_pos16$ = one | cant_pos16$ = four, pcant_16
  4475.         if cant_pos17$ = one | cant_pos17$ = four, pcant_17
  4476.         if cant_pos18$ = one | cant_pos18$ = four, pcant_18
  4477.         if cant_pos19$ = one | cant_pos19$ = four, pcant_19
  4478.         if cant_pos20$ = one | cant_pos20$ = four, pcant_20
  4479.         ]
  4480.       if cstop$, strcantext = strcantext + sm00
  4481.       if cgstop$, strcantext = strcantext + sm01
  4482.       #Output of strcantext occurs at the end of the output line
  4483.  
  4484. pcan2           #Canned text - after output call
  4485.       strcantext = sblank
  4486.       if cant_no$ > zero,
  4487.         [
  4488.         if cant_pos1$ = two | cant_pos1$ = five, pcant_1
  4489.         if cant_pos2$ = two | cant_pos2$ = five, pcant_2
  4490.         if cant_pos3$ = two | cant_pos3$ = five, pcant_3
  4491.         if cant_pos4$ = two | cant_pos4$ = five, pcant_4
  4492.         if cant_pos5$ = two | cant_pos5$ = five, pcant_5
  4493.         if cant_pos6$ = two | cant_pos6$ = five, pcant_6
  4494.         if cant_pos7$ = two | cant_pos7$ = five, pcant_7
  4495.         if cant_pos8$ = two | cant_pos8$ = five, pcant_8
  4496.         if cant_pos9$ = two | cant_pos9$ = five, pcant_9
  4497.         if cant_pos10$ = two | cant_pos10$ = five, pcant_10
  4498.         if cant_pos11$ = two | cant_pos11$ = five, pcant_11
  4499.         if cant_pos12$ = two | cant_pos12$ = five, pcant_12
  4500.         if cant_pos13$ = two | cant_pos13$ = five, pcant_13
  4501.         if cant_pos14$ = two | cant_pos14$ = five, pcant_14
  4502.         if cant_pos15$ = two | cant_pos15$ = five, pcant_15
  4503.         if cant_pos16$ = two | cant_pos16$ = five, pcant_16
  4504.         if cant_pos17$ = two | cant_pos17$ = five, pcant_17
  4505.         if cant_pos18$ = two | cant_pos18$ = five, pcant_18
  4506.         if cant_pos19$ = two | cant_pos19$ = five, pcant_19
  4507.         if cant_pos20$ = two | cant_pos20$ = five, pcant_20
  4508.         pbld, n$, strcantext, e$
  4509.         strcantext = sblank
  4510.         ]
  4511.  
  4512. pcant_1         #Canned text - output call
  4513.       cant_pos = cant_pos1$
  4514.       cantext$ = cant_val1$
  4515.       pcant_out
  4516.  
  4517. pcant_2         #Canned text - output call
  4518.       cant_pos = cant_pos2$
  4519.       cantext$ = cant_val2$
  4520.       pcant_out
  4521.  
  4522. pcant_3         #Canned text - output call
  4523.       cant_pos = cant_pos3$
  4524.       cantext$ = cant_val3$
  4525.       pcant_out
  4526.  
  4527. pcant_4         #Canned text - output call
  4528.       cant_pos = cant_pos4$
  4529.       cantext$ = cant_val4$
  4530.       pcant_out
  4531.  
  4532. pcant_5         #Canned text - output call
  4533.       cant_pos = cant_pos5$
  4534.       cantext$ = cant_val5$
  4535.       pcant_out
  4536.  
  4537. pcant_6         #Canned text - output call
  4538.       cant_pos = cant_pos6$
  4539.       cantext$ = cant_val6$
  4540.       pcant_out
  4541.  
  4542. pcant_7         #Canned text - output call
  4543.       cant_pos = cant_pos7$
  4544.       cantext$ = cant_val7$
  4545.       pcant_out
  4546.  
  4547. pcant_8         #Canned text - output call
  4548.       cant_pos = cant_pos8$
  4549.       cantext$ = cant_val8$
  4550.       pcant_out
  4551.  
  4552. pcant_9         #Canned text - output call
  4553.       cant_pos = cant_pos9$
  4554.       cantext$ = cant_val9$
  4555.       pcant_out
  4556.  
  4557. pcant_10        #Canned text - output call
  4558.       cant_pos = cant_pos10$
  4559.       cantext$ = cant_val10$
  4560.       pcant_out
  4561.  
  4562. pcant_11        #Canned text - output call
  4563.       cant_pos = cant_pos11$
  4564.       cantext$ = cant_val11$
  4565.       pcant_out
  4566.  
  4567. pcant_12        #Canned text - output call
  4568.       cant_pos = cant_pos12$
  4569.       cantext$ = cant_val12$
  4570.       pcant_out
  4571.  
  4572. pcant_13        #Canned text - output call
  4573.       cant_pos = cant_pos13$
  4574.       cantext$ = cant_val13$
  4575.       pcant_out
  4576.  
  4577. pcant_14        #Canned text - output call
  4578.       cant_pos = cant_pos14$
  4579.       cantext$ = cant_val14$
  4580.       pcant_out
  4581.  
  4582. pcant_15        #Canned text - output call
  4583.       cant_pos = cant_pos15$
  4584.       cantext$ = cant_val15$
  4585.       pcant_out
  4586.  
  4587. pcant_16        #Canned text - output call
  4588.       cant_pos = cant_pos16$
  4589.       cantext$ = cant_val16$
  4590.       pcant_out
  4591.  
  4592. pcant_17        #Canned text - output call
  4593.       cant_pos = cant_pos17$
  4594.       cantext$ = cant_val17$
  4595.       pcant_out
  4596.  
  4597. pcant_18        #Canned text - output call
  4598.       cant_pos = cant_pos18$
  4599.       cantext$ = cant_val18$
  4600.       pcant_out
  4601.  
  4602. pcant_19        #Canned text - output call
  4603.       cant_pos = cant_pos19$
  4604.       cantext$ = cant_val19$
  4605.       pcant_out
  4606.  
  4607. pcant_20        #Canned text - output call
  4608.       cant_pos = cant_pos20$
  4609.       cantext$ = cant_val20$
  4610.       pcant_out
  4611.  
  4612. pcant_out       #Canned text - build the string for output
  4613.       #Assign string select type outputs
  4614.       if cant_pos < three, #cant_pos indicates canned text output
  4615.         [
  4616.         #Assign string select global variables
  4617.         if cantext$ = 3, bld = one
  4618.         if cantext$ = 4, bld = zero
  4619.         if cantext$ = 9, exact = one
  4620.         if cantext$ = 10, exact = zero
  4621.         #Build the cantext string from strings
  4622.         if cantext$ = 1, strcantext = strcantext + sm00
  4623.         if cantext$ = 2, strcantext = strcantext + sm01
  4624.         #Build the cantext string from string selects
  4625.         if cantext$ = 5 | cantext$ = 6,
  4626.           [
  4627.           if cantext$ = 5, tlstk = zero
  4628.           else, tlstk = one
  4629.           rslt_upd = updstr (stlstk)
  4630.           strcantext = strcantext + stlstk
  4631.           ]
  4632.         if cantext$ = 7 | cantext$ = 8,
  4633.           [
  4634.           if cantext$ = 7, chute = zero
  4635.           else, chute = one
  4636.           rslt_upd = updstr (schute)
  4637.           strcantext = strcantext + schute
  4638.           ]
  4639.         #Build the cantext string from cantext number
  4640.         if cantext$ > 10,
  4641.           [
  4642.           strtextno = no2str(cantext$)
  4643.           strcantext = strcantext + strm + strtextno
  4644.           ]
  4645.         ]
  4646.       else, #cant_pos indicates coolant output
  4647.         [
  4648.         coolant_bin = flook (two, cantext$) #Create binary value for each coolant using lookup table
  4649.         if frac(cantext$/two),
  4650.           [
  4651.           if all_cool_off,
  4652.             [
  4653.             if coolant_on, pbld, n$, *sall_cool_off, e$
  4654.             coolant_on = zero
  4655.             suppress = 1               #WBT added this for null toolchange with "First command shuts all off"
  4656.                                        #and turn off selected in the second op, post outputs M9 twice
  4657.             ]
  4658.           else, coolant_on = coolant_on - coolant_bin/2 #Odd = off command, subtract appropriate binary value.
  4659.           ]
  4660.         else,                                         #Even = on command
  4661.           [   #Determine if this coolant is already on
  4662.           local_int = zero
  4663.           coolantx = zero
  4664.           while local_int < 20,
  4665.             [
  4666.             result2 = and(2^local_int, coolant_on)
  4667.             local_int = local_int + one
  4668.             if result2 = coolant_bin, suppress = one
  4669.             ]
  4670.           ]
  4671.         if suppress <> 1, #Don't output an on code for a coolant that is already on
  4672.           [
  4673.           if not(frac(cantext$/two)), coolant_on = coolant_on + coolant_bin #Maintain binary sum of all coolants currently on
  4674.           coolantx = cantext$ - 50                                          #Create a coolantx value for string select
  4675.           pbld, n$, *scoolantx, e$
  4676.           ]
  4677.         suppress = zero
  4678.         ]
  4679.  
  4680.  
  4681. slicense : "IN-HOUSE SOLUTIONS INC."
  4682.  
  4683. # --------------------------------------------------------------------------
  4684. # Position calculations, generally these do not need to be modified
  4685. # --------------------------------------------------------------------------
  4686. #The variables for absolute output are xabs, yabs, zabs.
  4687. #The variables for incremental output are xinc, yinc, zinc.
  4688. #They are found from the input variables x, y, z (typically) which are
  4689. #copied to copy_x, copy_y, copy_z.  These are passed to the mapping routine
  4690. #to get raw machine coordinates xa, ya, za.  These are used in pxyxcout to
  4691. #get the output xabs, yabs, zabs.  ps_inc_calc is called to get xinc, yinc,
  4692. #zinc.  cfeed_x, cfeed_y, cfeed_z are the unshifted positions for feed
  4693. #calculations.
  4694. # --------------------------------------------------------------------------
  4695. pxyzcout      #Perform calls for mapping coordinates and shifts
  4696.       if posttype$ <> two & y_axis = zero & millcc = zero & fmtrnd(xca) = zero & fmtrnd(yca) = zero & mach_plane = zero, czero_csav = prv_csav
  4697.       pplane_mod
  4698.       if cuttype = one, pxyzcout0                   #Turning
  4699.       if abs(cuttype) = two                         #Right/Left Face cut
  4700.       | abs(cuttype) = three, pxyzcout2             #Cross cut
  4701.       if cuttype = four, pxyzcout4                  #Y axis substitution
  4702.       if cuttype = five, pxyzcout5                  #Multisurf Rotary
  4703.       #C axis control modifications
  4704.       if posttype$ <> two,
  4705.         [
  4706.         pcoutrev
  4707.         if not(one_rev) | (op_id$ = last_op_id),   #MU00004
  4708.           [
  4709.           if rot_dir, cabs = c_wnd * m_one
  4710.           else, cabs = c_wnd
  4711.           ]
  4712.         else,
  4713.           [
  4714.           while csav >= 360, csav = csav - 360
  4715.           while csav < 0, csav = csav + 360
  4716.           if rot_dir, cabs = csav * m_one
  4717.           else, cabs = csav
  4718.           last_csav = csav
  4719.           rev = 0
  4720.           ]
  4721.         if c_axistype > one | millcc,
  4722.           [
  4723.           pindxcalc
  4724.           if c_axistype = three,
  4725.             [
  4726.             #Check if in tolerance
  4727.             cdelta = frac(abs(cabs)/ctable)
  4728.             if cdelta > ixtol & cdelta < 1-ixtol,
  4729.               [
  4730.               result = mprint(sindxerror)
  4731.               exitpost$
  4732.               ]
  4733.             indx_out = cabs
  4734.             ]
  4735.           if c_axistype = two, #Signed direction calculation
  4736.             [
  4737.             #Warn if a move greater than 360
  4738.             if abs(prvc_wnd - c_wnd) > 360, result = mprint(ssignerror)
  4739.             ]
  4740.           ]
  4741.         if y_axis = zero,
  4742.           [
  4743.           if cir_at_zero = one, gcode$ = one #only C is moving
  4744.           if cir_at_zero = m_one & (xa < zero | prv_xa < zero), c_ax_flp = one
  4745.           else, c_ax_flp = zero
  4746.           ]
  4747.         if millcc,
  4748.           [
  4749.           if fmtrnd(cabs) = 360, cabs = zero  #Always try to start at zero
  4750.           if interp_flg,
  4751.             [
  4752.             if abs(cuttype) = two, ppolar_fcyc
  4753.             ]
  4754.           else, xabs = abs(xabs)
  4755.           ]
  4756.         ]
  4757.       pfcalc
  4758.  
  4759. pxyzcout0       #Lathe and machine coordinates
  4760.       #This portion (tool_op$ = 202/203) is still the roughing cycle,
  4761.       #we must replace X and Z at this time (before the spindle call)
  4762.       if (tool_op$ = 202 | tool_op$ = 203) & gcode$ = 0 & mi10$ & cutpos2$ = 4,     #CRF
  4763.         [
  4764.         crf_line = fcc_subid
  4765.         size4 = rbuf(4,0)
  4766.         if crf_line <= size4, crf_xsav2 = rbuf(4,crf_line)
  4767.         if cutpos2$ = 4,       #if it's cutpos2$ = 4 (end of path) we want to add the move to the
  4768.           [                    #pre canned cycle position but not replace the move from MP
  4769.           cfeed_x = crf_xsav2
  4770.           cfeed_z = crf_zsav2
  4771.           pax_shift
  4772.           prapidout
  4773.           ]
  4774.         if cutpos2$ = 0,       #Cutpos2$ = 0 is before an op, we want to replace the move from MP at this time
  4775.           [
  4776.           xa = crf_xsav2
  4777.           za = crf_zsav2
  4778.           ]
  4779.         ]
  4780.       #This portion (tool_op$ = 201) is now the finishing cycle,
  4781.       #we must replace X and Z at this time so Mastercam's coordinates don't override our work
  4782.       if tool_op$ = 201 & gcode$ = 0 & mi10$,     #CRF
  4783.         [
  4784.         crf_line = fcc_subid
  4785.         size4 = rbuf(4,0)
  4786.         if crf_line <= size4, crf_xsav2 = rbuf(4,crf_line)
  4787.         xa = crf_xsav2
  4788.         za = crf_zsav2
  4789.         ]
  4790.       cfeed_x = vequ(xa)
  4791.       csav = c$
  4792.       pax_shift
  4793.       ipr_type = zero
  4794.  
  4795. pxyzcout4       #Calculations for Y axis substitution (mapped)
  4796.       cfeed_x = xa + (rotdia$/two)
  4797.       cfeed_y = zero
  4798.       cfeed_z = za
  4799.       csav = ya * (360 / (pi$ * rotdia$))
  4800.       pax_shift
  4801.       if millcc, ipr_type = zero
  4802.       else, ipr_type = one
  4803.  
  4804. pxyzcout2       #Polar conversion, Cross cut, Right/Left Face cut
  4805.       #Drill polar is toolplane drilling toward center
  4806.       #if not a coincident axis (Face cut)
  4807.       if (y_axis | (opcode$ = three & abs(cuttype) <> two)), pxyzcout0
  4808.       else,
  4809.         [
  4810.         cfeed_x = sqrt(xa^2 + ya^2)
  4811.         cfeed_y = zero
  4812.         cfeed_z = za
  4813.         #if opcode$ = three & abs(cuttype) = three, csav = c$
  4814.         #else, csav = atan2(ya, xa) + c$
  4815.         if opcode$ = three & abs(cuttype) = three, csav = c$
  4816.         else,
  4817.           [
  4818.           if abs(cuttype) = 2,
  4819.             [
  4820.             if fmtrnd(xa) = fmtrnd(prv_xa) & fmtrnd(ya) = fmtrnd(prv_ya), csav = prv_csav
  4821.             else, csav = atan2(ya, xa) + c$   #on the face you need to add c$ in case of twisted face plane
  4822.             ]
  4823.           else,
  4824.             [
  4825.             csav = c$         #cross cutting with rotary turned on (NOT AXIS SUB!)
  4826.             cfeed_y = ya      #C only indexes to plane and then Y motion
  4827.             ]
  4828.           ]
  4829.         pax_shift
  4830.         ipr_type = one
  4831.         if not(millcc & abs(cuttype) = two),
  4832.           [
  4833.           if fmtrnd(xa) = zero & fmtrnd(ya) = zero & opcode$ <> three,
  4834.             pnt_at_zero = one
  4835.           ]
  4836.         ]
  4837.  
  4838. pxyzcout5       #Multisurf rotary axis motion
  4839.       #map to machine co-ordinate matrix
  4840.       axisx$ = vequ(caxisx)
  4841.       vtoolx_rot = rotv(oneeighty,vtoolx$)
  4842.       axisx$ = vequ(aaxisx)
  4843.       xa = rotp(oneeighty,xa)
  4844.       csav = atan2(vtooly_rot, vtoolz_rot)
  4845.       axisx$ = vequ(caxisx)
  4846.       xa = rotp (-csav, xa)
  4847.       cfeed_x = vequ(xa)
  4848.       pax_shift
  4849.       csav = csav + c$
  4850.       ipr_type = one
  4851.  
  4852. ppolar_fcyc     #Output values for face, polar conversion cycle
  4853.       xabs = (xa + dia_shift) * dia_mult
  4854.       yabs = zero
  4855.       zabs = (za + z_shift) * z_mult
  4856.       cabs = (ya + y_shift) * y_mult
  4857.       ipr_type = zero
  4858.  
  4859. pax_shift       #Apply multiplier and shift positions, csav was recalculated
  4860.       xabs = (cfeed_x + dia_shift) * dia_mult
  4861.       yabs = (cfeed_y + y_shift) * y_mult
  4862.       zabs = (cfeed_z + z_shift) * z_mult
  4863.       #Apply axis shift for lower turrets
  4864.       if posttype$ <> two & (lathtype = zero | lathtype = two),
  4865.         csav = csav + c_shift
  4866.       if posttype$ = two,
  4867.         [
  4868.         yabs = zero
  4869.         csav = zero
  4870.         ]
  4871.  
  4872. pplane_mod    #Modify the multiplier based on plane, see psw_str_mult
  4873.       if plane$ = zero,
  4874.         [
  4875.         dia_mult = prv_dia_mult * pl_ax_m0x
  4876.         y_mult = prv_y_mult * pl_ax_m0y
  4877.         z_mult = prv_z_mult * pl_ax_m0z
  4878.         ]
  4879.       else,
  4880.         [
  4881.         if plane$ = one,
  4882.           [
  4883.           dia_mult = prv_dia_mult * pl_ax_m1x
  4884.           y_mult = prv_y_mult * pl_ax_m1y
  4885.           z_mult = prv_z_mult * pl_ax_m1z
  4886.           ]
  4887.         else, #plane = two
  4888.           [
  4889.           dia_mult = prv_dia_mult * pl_ax_m2x
  4890.           y_mult = prv_y_mult * pl_ax_m2y
  4891.           z_mult = prv_z_mult * pl_ax_m2z
  4892.           ]
  4893.         ]
  4894.  
  4895. pcoutrev        #Rotary axis revolution calculation (Modify for wind-up)
  4896.       if cir_at_zero = one,
  4897.         [
  4898.         #Arcs at center position the c axis
  4899.         if cuttype =  -2 | abs(cuttype) = three,
  4900.         csav = czero_csav - sweep$
  4901.         else, csav = czero_csav + sweep$
  4902.         ]
  4903.       #C does not move going to CL
  4904.       if pnt_at_zero, csav = last_csav
  4905.       cdelta =  fmtrnd(csav) - last_csav  #This calculates once, for rev
  4906.       while abs(cdelta) > ctol, #If motion exceeds ctol, add wind-up
  4907.         [
  4908.         if cdelta > zero,
  4909.           [
  4910.           rev = rev - one
  4911.           cdelta = cdelta - 360
  4912.           ]
  4913.         else,
  4914.           [
  4915.           rev = rev + one
  4916.           cdelta = cdelta + 360
  4917.           ]
  4918.         ]
  4919.  
  4920.       #if cwind & (toolchng | (toolchng0)), #CWIND IS NOT WORKING CORRECTLY ON EITHER SETTING MU00007
  4921.       #  [
  4922.       #  sav_rev = rev
  4923.       #  ]
  4924.       if cuttype <> four, c_wnd = rev * 360 + csav
  4925.       else, c_wnd = sav_rev * 360 + csav
  4926.       last_csav = csav
  4927.       @c_wnd
  4928.       #Now switch to c_wnd which is the absolute winding C calculation
  4929.       #Modify for shortest direction if toolchange or toolplane
  4930.       #but not with axis subs
  4931.       if c_axistype <> three,
  4932.         [
  4933.         if abs(prvc_wnd - c_wnd) > 180
  4934.           & (toolchng | (y_axis & cuttype < four)),
  4935.           [
  4936.           while abs(prvc_wnd - c_wnd) > 180,
  4937.             [
  4938.             if prvc_wnd > c_wnd, rev = rev + one
  4939.             else, rev = rev - one
  4940.             c_wnd = rev * 360 + csav
  4941.             ]
  4942.           @c_wnd
  4943.           ]
  4944.         ]
  4945.  
  4946. pindxcalc       #Index move calculations, direction is shortest exc. Asub
  4947.       if pnt_at_zero | cdelta = zero, indx_mc = prv_indx_mc
  4948.       else,
  4949.         [
  4950.         cdelta = fmtrnd(c_wnd) - prvc_wnd
  4951.         if cuttype = four, #Just look at the direction
  4952.           [
  4953.           if cdelta >= zero, indx_mc = one
  4954.           else, indx_mc = zero
  4955.           ]
  4956.         else,
  4957.           [
  4958.           #Phase shift delta 10 revolutions, check odd/even for direction
  4959.           if frac(int((cdelta + 3600)/180)/two), indx_mc = zero
  4960.           else, indx_mc = one
  4961.           ]
  4962.         ]
  4963.       #Set range 0-360
  4964.       while cabs < zero, cabs = cabs + 360
  4965.       while cabs > 360, cabs = cabs - 360
  4966.  
  4967. pfcalc          #Feedrate calculations, gcode 0 does not evaluate
  4968.       #if abs(c_wnd-prvc_wnd)<vtol$ | c_axistype=three | drillcur$
  4969.       #wbt added c_resolution. Post must only enter pfclc_deg_inv if C motion >= to the resolution of the axis output occurs
  4970.       if abs(c_wnd-prvc_wnd) < c_resolution | c_axistype=three | drillcur$
  4971.       | ipr_type=zero | prv_pnt_at_zero | gcode$ = zero, pfcalc_u_min
  4972.       else, pfclc_deg_inv
  4973.  
  4974. pfcalc_u_min    #Feedrate unit/min
  4975.       feed = fr_pos$
  4976.       if feed > maxfeedpm, feed = maxfeedpm
  4977.       if posttype$ = 1 & mi6$ = 1, feed = feed/speed         #test whether or not feed/rev is working with dpm
  4978.       prvfrdeg = feed
  4979.  
  4980. pfclc_deg_inv   #Feedrate deg/min, xa and ya are assumed relative to origin
  4981.       #Average last radius to current radius
  4982.       ldelta = ((cfeed_x+prv_cfeed_x)/two)^two+((cfeed_y+prv_cfeed_y)/two)^two
  4983.       circum = sqrt(ldelta) * two * pi$
  4984.       if circum = zero, circum = c9k          #Don't allow Zero
  4985.       ldelta = (cfeed_x-prv_cfeed_x)^two+(cfeed_y-prv_cfeed_y)^two
  4986.       ldelta = sqrt(ldelta+(cfeed_z-prv_cfeed_z)^two)
  4987.       cdelta = ((abs(c_wnd - prvc_wnd))/360)*circum
  4988.       if ldelta = zero, cldelta = cdelta
  4989.       else, cldelta = sqrt(cdelta^two + ldelta^two)
  4990.       if cldelta = zero, cldelta = c9k
  4991.       #Feedrate deg/min control and calculation
  4992.       frdeg = abs(cdelta/cldelta) * abs(fr_pos$ * (360/circum))
  4993.       if abs(frdeg - prvfrdeg) > frdegstp | ipr_type <> prv_ipr_type,
  4994.         [
  4995.         #Control output of frdeg
  4996.         prvfrdeg = frdeg
  4997.         feed = frdeg
  4998.         ]
  4999.       if fmtrnd(frdeg) = zero, feed = fr_pos$
  5000.       if frdeg > maxfrdeg, feed = maxfrdeg
  5001.       if posttype$ = 1 & mi6$ = 1, feed = feed/speed         #test whether or not feed/rev is working with dpm
  5002.  
  5003. #Incremental calculations
  5004. ps_inc_calc     #Incremental calculations, start
  5005.       xia = fmtrnd(xabs)
  5006.       yia = fmtrnd(yabs)
  5007.       zia = fmtrnd(zabs)
  5008.       xinc = vsub (xia, prv_xia)
  5009.       if posttype$ <> two, ps_cinc_calc
  5010.  
  5011. ps_cinc_calc    #Incremental calculations, start rotary
  5012.       cia = fmtrnd(cabs)
  5013.       cinc = cia - prv_cia
  5014.  
  5015. pe_inc_calc     #Incremental calculations, end
  5016.       prvc_wnd = fmtrnd(c_wnd)      #Avoid updating until called explicitly
  5017.       !cfeed_x, !cfeed_y, !cfeed_z, !ipr_type  #These are used in pxyzcout
  5018.       !x$, !y$, !z$, !xa, !ya, !za
  5019.       !xia, !yia, !zia, !cia
  5020.       #!cc_pos$, !cutpos2     #01/23/04
  5021.       !cutpos2$     #01/23/04     #don't update cc_pos here as it doesn't allow for lathe cutter comp to function properly.
  5022.  
  5023. # --------------------------------------------------------------------------
  5024. # Mapping routines, maps input to basic machine coordinates (side view)
  5025. # --------------------------------------------------------------------------
  5026. pmatrix_su      #Setup mapping matrix
  5027.       hmtx1 = matt(m1$)
  5028.       hmtx1 = mmul(hmtx1, smtx1)
  5029.       if cuttype = one, mmtx1 = matt(m1$)
  5030.       if cuttype = two, mmtx1 = matt(smtx1)
  5031.       if cuttype =  -2,mmtx1 = matt(bmtx1)
  5032.       if cuttype = three | cuttype = five, mmtx1 = matt(cmtx1)
  5033.       if cuttype =  -3, mmtx1 = matt(crmtx1)
  5034.       if cuttype = four, mmtx1 = matt(amtx1)
  5035.       mmtx1 = mmul(mmtx1, smtx1)
  5036.  
  5037. pshft_map_xc    #Remove workshift and map to lathe coordinates, center
  5038.       xca = vadd (xc$, tox$)  #Always shift to origin
  5039.       if plane$ = one,
  5040.         [
  5041.         result = xca
  5042.         xca = zca
  5043.         zca = yca
  5044.         yca = result
  5045.         ]
  5046.       if plane$ = two,
  5047.         [
  5048.         result = yca
  5049.         yca = zca
  5050.         zca = result
  5051.         ]
  5052.       xca = vmap (xca, mmtx1)
  5053.  
  5054. pshft_map_ijk    #Remove workshift and map to lathe coordinates, ijk
  5055.       if arctype$ = one, #Absolute is shifted
  5056.         [
  5057.         if wcs_origin, iout = vadd (i$, tox$)
  5058.         else, iout = vequ (i$)
  5059.         ]
  5060.       else, iout = vequ (i$)
  5061.       iout = vmap (iout, mmtx1)
  5062.  
  5063. pshft_map_xa     #Remove workshift and map to lathe coordinates, xyz
  5064.       if wcs_origin, xa = vadd (copy_x, tox$)
  5065.       else, xa = vequ (copy_x)
  5066.       xa = vmap (xa, mmtx1)
  5067.  
  5068. pmap_home     #Set the location for home position
  5069.       xa = vequ(xh$)
  5070.       if map_home,
  5071.         [
  5072.         if wcs_origin, xa = vadd(xa, tox$)
  5073.         xa = vmap(xa, hmtx1)
  5074.         ]
  5075.       pplane_mod
  5076.       pxyzcout0 #basic toolplane positioning
  5077.  
  5078. pmap_plane    #Map NCI plane to machine plane
  5079.       mach_plane = plane$
  5080.       #Cross
  5081.       if cuttype=3 & plane$<two, mach_plane = abs(plane$ - one)
  5082.       #Top
  5083.       if (abs(cuttype)<=one | abs(cuttype)>=4),
  5084.       mach_plane = plane$ - one
  5085.       if mach_plane = m_one, mach_plane = two
  5086.  
  5087. # --------------------------------------------------------------------------
  5088. # NCI file pre-read look ahead routines
  5089. # Build the toolchange buffer, sets cycle and turret flags
  5090. # --------------------------------------------------------------------------
  5091. pwrttparam$      #Information from parameters
  5092.       #"pwrttparam", ~prmcode$, ~sparameter$, e$
  5093.       if prmcode$ = 15145, metvals   = rpar(sparameter$,1)
  5094.       if opcode$ = 104, result = fprm (opcode$)
  5095.       if prmcode$ = 15346, comp_type = rpar(sparameter$, 1)
  5096.       if prmcode$ = 20103, stinsert2 = sparameter$
  5097.       if prmcode$ = 20110, stholder2 = sparameter$
  5098.       if prmcode$ = 20100, stcustom2 = rparsngl(sparameter$, 2)
  5099.       if prmcode$ = 20002, stcode2 = sparameter$ #Manufacturer's tool code
  5100.       if prmcode$ = 20012, stplane1 = sparameter$
  5101.  
  5102. pwrtt$           #Buffer toolchange information, tooltable = 3 calls on 1003
  5103.       if gcode$ = 1001, psetup
  5104.       pcut_cctyp
  5105.       if opcode$=104 | opcode$=105 | opcode$=three | opcode$=16, cc_pos$ = zero
  5106.       if gcode$ <> 1001, plast_recd
  5107.       pcur_recd
  5108.       if gcode$ <> 1003, cc_pos$ = zero
  5109.       !opcode$, !tool_op$
  5110.       if gcode$ = 1003,
  5111.         [
  5112.         size1 = rbuf (one, zero)
  5113.         rc1 = one
  5114.         if rc1 < size1, preadcur_nxt
  5115.         if cc_1013$ = zero, cc_pos$ = zero
  5116.         ]
  5117.       if (tool_info = 2 | tool_info = 3) & gcode$ <> 1003 & op_id$ <> last_op_id, pWrite_buf
  5118.       last_op_id = op_id$
  5119.  
  5120. pRead_buf
  5121.           Idx_Start = NumToolMin
  5122.           Idx_End = NumToolMax
  5123.           !spaces$
  5124.           spaces$ = zero
  5125.          
  5126.           size6 = rbuf(5,0)
  5127.           while Idx_Start <= Idx_End,
  5128.            [
  5129.            rc6 = 1
  5130.            while rc6 <= size6,
  5131.             [
  5132.             NumTool_1 = rbuf(6,rc6)
  5133.             if NumTool_1 = Idx_Start,
  5134.              [
  5135.              rc5 = rc6 - 1
  5136.              sTool = rbuf(5,rc5)
  5137.              "(T", *sTool, ")", e$
  5138.              ]
  5139.             ]
  5140.             Idx_Start = Idx_Start + 1
  5141.            ]
  5142.            spaces$ = prv_spaces$
  5143.  
  5144. pWrite_buf #writes on each pwrtt$ call
  5145.            tnote = t$
  5146.            NumTool_1 = t$
  5147.            strtool$ = ucase(strtool$)
  5148.            stinsert2 = ucase(stinsert2)
  5149.            stplane1 = ucase(stplane1)
  5150.  
  5151.            if posttype$ = 2, #LATHE TOOLS
  5152.             [
  5153.             if stcustom2 >= 5, #Custom Geometry Tools
  5154.             sTool = no2str(tnote) + ", " + strtool$ + ", " + stcode2
  5155.             else,
  5156.            
  5157.             if stcustom2 = 4, #Drills, Taps, Reamers
  5158.             sTool = no2str(tnote) + ", " + stholder2 + ", " + strtool$
  5159.             else,
  5160.            
  5161.             #if stcustom2 = 1, #Threading Tools
  5162.             #sTool = no2str(tnote) + ", " + "TEST"
  5163.             #else,
  5164.            
  5165.             sTool = no2str(tnote) + ", " + strtool$ + ", " + stholder2 + ", " + stinsert2
  5166.             ]
  5167.            else, #MILL TOOLS
  5168.             [
  5169.             if (stplane1 = "RIGHT" | stplane1 = "LEFT"),
  5170.             sTool = no2str(tnote) + ", " + strtool$ + ", " + "LIVE-T Z"
  5171.             else,
  5172.             sTool = no2str(tnote) + ", " + strtool$ + ", " + "LIVE-T X"
  5173.             ]
  5174.            sTool = wbuf(5,wc5)
  5175.            NumTool_1 = wbuf(6,wc6)
  5176.          
  5177. ptooltable # Write tool table, scans entire file, null tools are negative
  5178.            #if you want repetitive tool output, keep the abs( ) in ptooltable and remove the >= t$ from the pwrtt call to this block
  5179.            #tnote = abs(t$) * 100 + abs(tloffno$)
  5180.            #tnote = abs(t$)
  5181.            tnote = t$
  5182.            #tldianote = abs(tldia$) #Oct-20-08 AEH
  5183.            #if opcode$ = 3 | opcode$ = 16, toffnote = tlngno$
  5184.            #else, toffnote = tloffno$
  5185.            stinsert2 = ucase(stinsert2)
  5186.            stplane1 = ucase(stplane1)
  5187.            !spaces$
  5188.            spaces$ = zero
  5189.            
  5190.            if posttype$ = 2,    #lathe tools
  5191.              [
  5192.              if stcustom2 >= 5, scomm_str, *tnote, ", " plistcomm, ", " stcode2, scomm_end, e$
  5193.              else,
  5194.              scomm_str, *tnote, ", " plistcomm, ", " *stholder2, ", " *stinsert2, scomm_end, e$
  5195.              ]
  5196.            else,                  #mill tools
  5197.              [
  5198.              if (stplane1 = "RIGHT" | stplane1 = "LEFT"), scomm_str, *tnote, ", ", plistcomm, ", " "LIVE-T Z", scomm_end, e$
  5199.              else,
  5200.              scomm_str, *tnote, ", ", plistcomm, ", " "LIVE-T X", scomm_end, e$
  5201.              ]
  5202.            spaces$ = prv_spaces$
  5203.            
  5204. plistcomm  # Comments from tool library
  5205.            strtool$=ucase(strtool$)
  5206.            if strtool$=snull, strtool$ = snocomm
  5207.            *strtool$
  5208.  
  5209.            nstrlen = strlen(strtool$)
  5210.            counter = 1
  5211.            #while counter <= (20-nstrlen), pspace
  5212.  
  5213. pspace     # Creates spaces based on tool comment length
  5214.            " "
  5215.            counter = counter + 1
  5216.  
  5217. ptspace    # Creates spaces based on tool number
  5218.            if t$ < 10, "  "
  5219.            if t$ >= 10 & t$ < 100, " "
  5220.  
  5221. pdspace    # Creates spaces based on diameter offset number
  5222.            if tloffno$ < 10, "  "
  5223.            if tloffno$ >= 10 & tloffno$ < 100, " "
  5224.  
  5225. pdiamspc   # Creates spaces based on diameter offset number
  5226.            #if tldia$ < 10, "  "
  5227.  
  5228. punit      # Tool unit
  5229.            if met_tool$, "mm"
  5230.            else, 34
  5231.  
  5232. pcur_recd       #Write to the current tool record
  5233.       c1_gcode = gcode$
  5234.       pmatrix_su
  5235.       pset_turret
  5236.       pmap_home
  5237.       c1_xh = vequ(xabs)
  5238.       c1_tox = vmap (tox$, mmtx1)
  5239.       c1_cc_pos = cc_pos$
  5240.       if gcode$ <> 1003, c1_tool = abs(t$)
  5241.       else, c1_tool = zero
  5242.       c1_tloffno = tloffno$
  5243.       c1_maxss = maxss$
  5244.       c1_ss = abs(ss$)
  5245.       if cool_w_spd = zero, c1_spdir = spdir$ + one
  5246.       else, c1_spdir = (spdir$ + one) + (fsg2(coolant$) * three)
  5247.       c1_css_actv = css_actv$
  5248.       c1_fr_pos = fr_pos$
  5249.       c1_ipr_actv = ipr_actv$
  5250.       c1_coolant = coolant$
  5251.       c1_nextdc = nextdc$
  5252.       c1_posttype = posttype$
  5253.       c1_cuttype = cuttype
  5254.       c1_lathtype = lathtype
  5255.       c1_gcodecc = gcodecc
  5256.       c1_lathecc = lathecc
  5257.       c1_millcc = millcc
  5258.       c1_y_axis = y_axis
  5259.       if opcode$ = 104,
  5260.         [
  5261.         if face_thd <> two, x_min$ = abs(xmaj_thd)
  5262.         else,
  5263.           [
  5264.           if abs(zstrt_thd) > abs(zend_thd), x_min$ = abs(zstrt_thd)
  5265.           else, x_min$ = abs(zend_thd)
  5266.           ]
  5267.         x_max$ = x_min$
  5268.         ]
  5269.       c1_spindle_no = spindle_no$
  5270.       c1_gcode = wbuf (one, wc1)
  5271.  
  5272. plast_recd      #Update the last record(s) for min-max and point
  5273.       rc1 = wc1 - one
  5274.       c1_gcode = rbuf (one, rc1)
  5275.       if prv_opcode$ <> 104,
  5276.         [
  5277.         c1_x_min = x_min$
  5278.         c1_x_max = x_max$
  5279.         ]
  5280.       rc1 = wc1 - one               #rc1 is used to write also
  5281.       c1_gcode = wbuf (one, rc1)
  5282.  
  5283. pcut_cctyp      #Find the type of cut for the tool buffer
  5284.                 #y_axis
  5285.                 #posttype
  5286.                 #cuttype
  5287.                 #lathtype
  5288.       y_axis = zero
  5289.       cuttype = zero
  5290.       if posttype$ = two, cuttype = one
  5291.       else,
  5292.         [
  5293.         if mill5$, cuttype = five
  5294.         else,
  5295.           [
  5296.           if rotary_type$ = one, cuttype = four
  5297.           else,
  5298.             [
  5299.             @m1$, @m2$, @m3$, @m7$, @m8$, @m9$
  5300.             if m7$ = m_one & m8$ = zero & m9$ = zero, cuttype =  -2
  5301.             if m7$ = one & m8$ = zero & m9$ = zero, cuttype = two
  5302.             if m1$ = m_one & m2$ = zero & m3$ = zero, cuttype = three
  5303.             if m1$ = one & m2$ = zero & m3$ = zero, cuttype =  -3
  5304.             if rotary_type$ = three | rotary_type$ = zero, y_axis = one
  5305.             ]
  5306.           ]
  5307.         ]
  5308.       lathtype = lturret$ + spindle_no$ * two
  5309.       #Check for errors
  5310.       if rotary_type$,
  5311.         [
  5312.         if (abs(cuttype) = two & rotary_axis$ <> three)
  5313.         | (abs(cuttype) = three & rotary_axis$ <> one),
  5314.           result = mprint(saxiserror)
  5315.         if cuttype = four & tlplnno$ <> one, result = mprint(stoperror)
  5316.         ]
  5317.       else,
  5318.         [
  5319.         if cuttype = zero, result = mprint(scutterror)
  5320.         ]
  5321.       #gcodecc, determine G74/G75 direction during processing
  5322.       #lathecc
  5323.       #millcc
  5324.       gcodecc = zero
  5325.       lathecc = zero
  5326.       if tool_op$ > 201,
  5327.         [
  5328.         if tool_op$ = 202 | tool_op$ = 203,
  5329.           [
  5330.           gcodecc = one
  5331.           lathecc = one
  5332.           if tool_op$ = 203, lathecc = m_one
  5333.           ]
  5334.         else,
  5335.           [
  5336.           if tool_op$ = 204 | tool_op$ = 205,
  5337.             [
  5338.             gcodecc = two
  5339.             lathecc = one
  5340.             if tool_op$ = 205, lathecc = m_one
  5341.             ]
  5342.           else,
  5343.             [
  5344.             if tool_op$ = 206 | tool_op$ = 207,
  5345.               [
  5346.               gcodecc = three
  5347.               lathecc = two
  5348.               if tool_op$ = 207, lathecc =  -2
  5349.               ]
  5350.             else,
  5351.               [
  5352.               if tool_op$ = 208,
  5353.                 [
  5354.                 gcodecc = four
  5355.                 lathecc = three
  5356.                 ]
  5357.               ]
  5358.             ]
  5359.           ]
  5360.         ]
  5361.       if mi4$<>zero & opcode$ <> three & (cuttype=four | abs(cuttype)=two),
  5362.          millcc = mi4$
  5363.       else, millcc = zero
  5364.  
  5365. psetup          #Setup post based on NCI settings
  5366.       sbufname3$ = spathnci$ + snamenci$ + sextext$
  5367.       spathext$ = spathnci$
  5368.       snameext$ = snamenci$
  5369.       #Set metric defaults
  5370.       if met_tool$ = one,
  5371.         [
  5372.         conversion = 1000
  5373.         vtol$ = vtol_m
  5374.         maxfeedpm = maxfeedpm_m
  5375.         lcc_move = lcc_move_m
  5376.         ]
  5377.       #Setup for old or new style canned cycles
  5378.       if old_new_sw = one,
  5379.         [
  5380.         result = newfs (26, thddepth$)
  5381.         result = newfs (26, thdfirst$)
  5382.         ]
  5383.       else,
  5384.         [
  5385.         result = nwadrs (stra, thdang)
  5386.         result = nwadrs (stri, thdrdlt)
  5387.         result = nwadrs (strk, thddepth$)
  5388.         result = nwadrs (strd, thdfirst$)
  5389.         #Lathe canned cycle old style conversion
  5390.         result = nwadrs (strd, depthcc)
  5391.         result = nwadrs (strd, ncutscc)
  5392.         result = nwadrs (stri, g73x)
  5393.         result = nwadrs (strk, g73z)
  5394.         result = nwadrs (stri, grvspcc)
  5395.         result = nwadrs (strk, grvdpcc)
  5396.         ]
  5397.       result = nwadrs(str_cax_abs, cabs)
  5398.       result = nwadrs(str_cax_inc, cinc)
  5399.       result = nwadrs(str_index, indx_out)
  5400.       sc_minus = str_cax_abs + sc_minus
  5401.       breakarcss = breakarcs$
  5402.  
  5403. # --------------------------------------------------------------------------
  5404. # Turret and cut type change setup, do not edit
  5405. # --------------------------------------------------------------------------
  5406. pset_turret     #Set the machine conditions and mapping based on the turret
  5407.       if lathtype = one | use_only_tl, pltype1
  5408.       else,
  5409.         [
  5410.         if lathtype = zero, pltype0
  5411.         else,
  5412.           [
  5413.           if lathtype = two, pltype2
  5414.           else, pltype3
  5415.           ]
  5416.         ]
  5417.       psw_str_mult
  5418.  
  5419. pltype0         #Bottom turret/Left spindle
  5420.       if cuttype = one,
  5421.         [
  5422.         #Lathe
  5423.         max_speed = max_speedl0
  5424.         min_speed = min_speedl0
  5425.         sw_string = scase_bl_c1
  5426.         ]
  5427.       else,
  5428.         [
  5429.         #Mill
  5430.         max_speed = max_speedm0
  5431.         min_speed = min_speedm0
  5432.         sw_string = scase_bl_c2 #case two is the default
  5433.         if cuttype =  -2,sw_string = scase_bl_c_2
  5434.         if cuttype = three, sw_string = scase_bl_c3
  5435.         if cuttype = -3, sw_string = scase_bl_c3r
  5436.         if cuttype = four & abs(c1_millcc) = one, sw_string = scase_bl_c4c
  5437.         if cuttype = four & c1_millcc = zero, sw_string = scase_bl_c4
  5438.         if cuttype = five, sw_string = scase_bl_c5
  5439.         ]
  5440.  
  5441. pltype1         #Top turret/Left spindle
  5442.       if cuttype = one,
  5443.         [
  5444.         #Lathe
  5445.         max_speed = max_speedl1
  5446.         min_speed = min_speedl1
  5447.         sw_string = scase_tl_c1
  5448.         ]
  5449.       else,
  5450.         [
  5451.         #Mill
  5452.         max_speed = max_speedm1
  5453.         min_speed = min_speedm1
  5454.         sw_string = scase_tl_c2 #case two is the default
  5455.         if cuttype =  -2,sw_string = scase_tl_c_2
  5456.         if cuttype = three, sw_string = scase_tl_c3
  5457.         if cuttype = -3, sw_string = scase_tl_c3r
  5458.         if cuttype = four & abs(c1_millcc) = one, sw_string = scase_tl_c4c
  5459.         if cuttype = four & c1_millcc = zero, sw_string = scase_tl_c4
  5460.         if cuttype = five, sw_string = scase_tl_c5
  5461.         ]
  5462.  
  5463. pltype2         #Bottom turret/Right spindle
  5464.       if cuttype = one,
  5465.         [
  5466.         #Lathe
  5467.         max_speed = max_speedl2
  5468.         min_speed = min_speedl2
  5469.         sw_string = scase_br_c1
  5470.         ]
  5471.       else,
  5472.         [
  5473.         #Mill
  5474.         max_speed = max_speedm2
  5475.         min_speed = min_speedm2
  5476.         sw_string = scase_br_c2 #case two is the default
  5477.         if cuttype =  -2,sw_string = scase_br_c_2
  5478.         if cuttype = three, sw_string = scase_br_c3
  5479.         if cuttype = -3, sw_string = scase_br_c3r
  5480.         if cuttype = four & abs(c1_millcc) = one, sw_string = scase_br_c4c
  5481.         if cuttype = four & c1_millcc = zero, sw_string = scase_br_c4
  5482.         if cuttype = five, sw_string = scase_br_c5
  5483.         ]
  5484.  
  5485. pltype3         #Top turret/Right spindle
  5486.       if cuttype = one,
  5487.         [
  5488.         #Lathe
  5489.         max_speed = max_speedl3
  5490.         min_speed = min_speedl3
  5491.         sw_string = scase_tr_c1
  5492.         ]
  5493.       else,
  5494.         [
  5495.         #Mill
  5496.         max_speed = max_speedm3
  5497.         min_speed = min_speedm3
  5498.         sw_string = scase_tr_c2 #case two is the default
  5499.         if cuttype =  -2,sw_string = scase_tr_c_2
  5500.         if cuttype = three, sw_string = scase_tr_c3
  5501.         if cuttype = -3, sw_string = scase_tr_c3r
  5502.         if cuttype = four & abs(c1_millcc) = one, sw_string = scase_tr_c4c
  5503.         if cuttype = four & c1_millcc = zero, sw_string = scase_tr_c4
  5504.         if cuttype = five, sw_string = scase_tr_c5
  5505.         ]
  5506.  
  5507. psw_str_mult    #Apply sw_string to variables and strings
  5508.       #c axis type
  5509.       #c_axistype = plcval (sw_string, 8)    #c_axistype comes from machine def
  5510.       if rot_index = 1, c_axistype = 3
  5511.       else,
  5512.         [
  5513.         if rot_type = 0 | rot_type = 2, c_axistype = 1
  5514.         if rot_type = 1, c_axistype = 2
  5515.         ]
  5516.       #reverse spindle
  5517.       spd_rev = plcval (sw_string, 7)
  5518.       #plane 0
  5519.       rslt_plc = plcval (sw_string, 6)
  5520.       if rslt_plc = zero,
  5521.         [
  5522.         sg02 = sxg02
  5523.         sg03 = sxg03
  5524.         sg41 = sxg41
  5525.         sg42 = sxg42
  5526.         ]
  5527.       else,
  5528.         [
  5529.         sg02 = sxg03
  5530.         sg03 = sxg02
  5531.         sg41 = sxg42
  5532.         sg42 = sxg41
  5533.         ]
  5534.       #plane 1
  5535.       rslt_plc = plcval (sw_string, five)
  5536.       if rslt_plc = zero,
  5537.         [
  5538.         sg02_1 = sxg02
  5539.         sg03_1 = sxg03
  5540.         sg41_1 = sxg41
  5541.         sg42_1 = sxg42
  5542.         ]
  5543.       else,
  5544.         [
  5545.         sg02_1 = sxg03
  5546.         sg03_1 = sxg02
  5547.         sg41_1 = sxg42
  5548.         sg42_1 = sxg41
  5549.         ]
  5550.       #plane 2
  5551.       rslt_plc = plcval (sw_string, four)
  5552.       if rslt_plc = zero,
  5553.         [
  5554.         sg02_2 = sxg02
  5555.         sg03_2 = sxg03
  5556.         sg41_2 = sxg41
  5557.         sg42_2 = sxg42
  5558.         ]
  5559.       else,
  5560.         [
  5561.         sg02_2 = sxg03
  5562.         sg03_2 = sxg02
  5563.         sg41_2 = sxg42
  5564.         sg42_2 = sxg41
  5565.         ]
  5566.       #plane 0
  5567.       rslt_plc = plcval (sw_string, three)
  5568.       rslt_upd = updstr (swstr)
  5569.       sg17 = swstr
  5570.       #plane 1
  5571.       rslt_plc = plcval (sw_string, two)
  5572.       rslt_upd = updstr (swstr)
  5573.       sg19 = swstr
  5574.       #plane 2
  5575.       rslt_plc = plcval (sw_string, one)
  5576.       rslt_upd = updstr (swstr)
  5577.       sg18 = swstr
  5578.       #plane 0, x axis
  5579.       rslt_plc = plcval (sw_string, m_one)
  5580.       pl_ax_m0x = -((rslt_plc * two) - one)
  5581.       rslt_plc = plcval (sw_string,  -2)
  5582.       pl_ax_m0y = -((rslt_plc * two) - one)
  5583.       rslt_plc = plcval (sw_string,  -3)
  5584.       pl_ax_m0z = -((rslt_plc * two) - one)
  5585.       rslt_plc = plcval (sw_string,  -4)
  5586.       pl_ax_m1x = -((rslt_plc * two) - one)
  5587.       rslt_plc = plcval (sw_string,  -5)
  5588.       pl_ax_m1y = -((rslt_plc * two) - one)
  5589.       rslt_plc = plcval (sw_string,  -6)
  5590.       pl_ax_m1z = -((rslt_plc * two) - one)
  5591.       rslt_plc = plcval (sw_string,  -7)
  5592.       pl_ax_m2x = -((rslt_plc * two) - one)
  5593.       rslt_plc = plcval (sw_string,  -8)
  5594.       pl_ax_m2y = -((rslt_plc * two) - one)
  5595.       rslt_plc = plcval (sw_string,  -9)
  5596.       pl_ax_m2z = -((rslt_plc * two) - one)
  5597.  
  5598. [STARTBIN]
  5599.  
  5600. # --------------------------------------------------------------------------
  5601. # Post Text --  Use Control Definition Manager to modify
  5602. # --------------------------------------------------------------------------
  5603.  
  5604. [CTRL_TEXT_XML_BEGIN]  # Post text edits MUST be made with Control Definition Manager.
  5605. <?xml version="1.0" encoding="UTF-8"?>
  5606. <mp_xml_post_text xml:space="preserve">
  5607.     <control>
  5608.         <control_label>CTRL_MT_MILL|DEFAULT</control_label>
  5609.         <language>fr-CA</language>
  5610.         <misc_integers>
  5611.             <misc_1>
  5612.                 <text>""</text>
  5613.             </misc_1>
  5614.             <misc_2>
  5615.                 <text>Abs/Inc. [0=ABS, 1=INC]</text>
  5616.             </misc_2>
  5617.             <misc_3>
  5618.                 <text>Ref. Return [0=G28,1=G30]</text>
  5619.             </misc_3>
  5620.             <misc_4>
  5621.                 <text>Mill Cyc G107/G112 [0=OFF,1=ON]</text>
  5622.             </misc_4>
  5623.             <misc_5>
  5624.                 <text>Synch Spindles [0=OFF,1=ON]</text>
  5625.             </misc_5>
  5626.             <misc_6>
  5627.                 <text>Feed/Rev [0=OFF,1=ON]</text>
  5628.             </misc_6>
  5629.             <misc_7>
  5630.                 <text>Clamp [1=CLAMP,2=BRAKE,3=OFF]</text>
  5631.             </misc_7>
  5632.             <misc_8>
  5633.                 <text>""</text>
  5634.             </misc_8>
  5635.             <misc_9>
  5636.                 <text>""</text>
  5637.             </misc_9>
  5638.             <misc_10>
  5639.                 <text>CRF X value [0=orig,1=post]</text>
  5640.             </misc_10>
  5641.         </misc_integers>
  5642.         <misc_reals>
  5643.             <misc_1>
  5644.                 <text>""</text>
  5645.             </misc_1>
  5646.             <misc_2>
  5647.                 <text>""</text>
  5648.             </misc_2>
  5649.             <misc_3>
  5650.                 <text>""</text>
  5651.             </misc_3>
  5652.             <misc_4>
  5653.                 <text>""</text>
  5654.             </misc_4>
  5655.             <misc_5>
  5656.                 <text>""</text>
  5657.             </misc_5>
  5658.             <misc_6>
  5659.                 <text>""</text>
  5660.             </misc_6>
  5661.             <misc_7>
  5662.                 <text>""</text>
  5663.             </misc_7>
  5664.             <misc_8>
  5665.                 <text>""</text>
  5666.             </misc_8>
  5667.             <misc_9>
  5668.                 <text>""</text>
  5669.             </misc_9>
  5670.             <misc_10>
  5671.                 <text>""</text>
  5672.             </misc_10>
  5673.         </misc_reals>
  5674.         <simple_drill>
  5675.             <description>
  5676.                 <text>Drill/Counterbore - G83/G87</text>
  5677.             </description>
  5678.             <first_peck>
  5679.                 <text>""</text>
  5680.             </first_peck>
  5681.             <subsequent_peck>
  5682.                 <text>""</text>
  5683.             </subsequent_peck>
  5684.             <peck_clearance>
  5685.                 <text>""</text>
  5686.             </peck_clearance>
  5687.             <retract_amount>
  5688.                 <text>""</text>
  5689.             </retract_amount>
  5690.             <shift>
  5691.                 <text>""</text>
  5692.             </shift>
  5693.         </simple_drill>
  5694.         <peck_drill>
  5695.             <description>
  5696.                 <text>Peck Drill - longhand</text>
  5697.             </description>
  5698.             <first_peck>
  5699.                 <text>""</text>
  5700.             </first_peck>
  5701.             <subsequent_peck>
  5702.                 <text>""</text>
  5703.             </subsequent_peck>
  5704.             <peck_clearance>
  5705.                 <text>""</text>
  5706.             </peck_clearance>
  5707.             <retract_amount>
  5708.                 <text>""</text>
  5709.             </retract_amount>
  5710.             <shift>
  5711.                 <text>""</text>
  5712.             </shift>
  5713.         </peck_drill>
  5714.         <chip_break>
  5715.             <description>
  5716.                 <text>Drill/Peck - G83/G87</text>
  5717.             </description>
  5718.             <first_peck>
  5719.                 <text>Peck</text>
  5720.             </first_peck>
  5721.             <subsequent_peck>
  5722.                 <text>""</text>
  5723.             </subsequent_peck>
  5724.             <peck_clearance>
  5725.                 <text>""</text>
  5726.             </peck_clearance>
  5727.             <retract_amount>
  5728.                 <text>""</text>
  5729.             </retract_amount>
  5730.             <shift>
  5731.                 <text>""</text>
  5732.             </shift>
  5733.         </chip_break>
  5734.         <tap>
  5735.             <description>
  5736.                 <text>Tapping - G84/G88</text>
  5737.             </description>
  5738.             <first_peck>
  5739.                 <text>""</text>
  5740.             </first_peck>
  5741.             <subsequent_peck>
  5742.                 <text>""</text>
  5743.             </subsequent_peck>
  5744.             <peck_clearance>
  5745.                 <text>""</text>
  5746.             </peck_clearance>
  5747.             <retract_amount>
  5748.                 <text>""</text>
  5749.             </retract_amount>
  5750.             <shift>
  5751.                 <text>""</text>
  5752.             </shift>
  5753.         </tap>
  5754.         <bore1>
  5755.             <description>
  5756.                 <text>Boring - G85/G89</text>
  5757.             </description>
  5758.             <first_peck>
  5759.                 <text>""</text>
  5760.             </first_peck>
  5761.             <subsequent_peck>
  5762.                 <text>""</text>
  5763.             </subsequent_peck>
  5764.             <peck_clearance>
  5765.                 <text>""</text>
  5766.             </peck_clearance>
  5767.             <retract_amount>
  5768.                 <text>""</text>
  5769.             </retract_amount>
  5770.         </bore1>
  5771.         <bore2>
  5772.             <first_peck>
  5773.                 <text>""</text>
  5774.             </first_peck>
  5775.             <subsequent_peck>
  5776.                 <text>""</text>
  5777.             </subsequent_peck>
  5778.             <peck_clearance>
  5779.                 <text>""</text>
  5780.             </peck_clearance>
  5781.             <retract_amount>
  5782.                 <text>""</text>
  5783.             </retract_amount>
  5784.             <shift>
  5785.                 <text>""</text>
  5786.             </shift>
  5787.         </bore2>
  5788.         <misc1>
  5789.             <subsequent_peck>
  5790.                 <text>""</text>
  5791.             </subsequent_peck>
  5792.             <peck_clearance>
  5793.                 <text>""</text>
  5794.             </peck_clearance>
  5795.             <retract_amount>
  5796.                 <text>""</text>
  5797.             </retract_amount>
  5798.         </misc1>
  5799.         <drill_cycle_descriptions>
  5800.             <simple_drill>
  5801.                 <text>Drill/Counterbore - G83/G87</text>
  5802.             </simple_drill>
  5803.             <peck_drill>
  5804.                 <text>Peck Drill - longhand</text>
  5805.             </peck_drill>
  5806.             <chip_break>
  5807.                 <text>Drill/Peck - G83/G87</text>
  5808.             </chip_break>
  5809.             <tapping>
  5810.                 <text>Tapping - G84/G88</text>
  5811.             </tapping>
  5812.             <boring_1>
  5813.                 <text>Boring - G85/G89</text>
  5814.             </boring_1>
  5815.         </drill_cycle_descriptions>
  5816.         <canned_text>
  5817.             <canned_text_1>
  5818.                 <text>Program Stop</text>
  5819.             </canned_text_1>
  5820.             <canned_text_2>
  5821.                 <text>Optional Stop</text>
  5822.             </canned_text_2>
  5823.             <canned_text_3>
  5824.                 <text>Block Delete on</text>
  5825.             </canned_text_3>
  5826.             <canned_text_4>
  5827.                 <text>Block Delete off</text>
  5828.             </canned_text_4>
  5829.             <canned_text_5>
  5830.                 <text>Return Tailstock</text>
  5831.             </canned_text_5>
  5832.             <canned_text_6>
  5833.                 <text>Advance Tailstock</text>
  5834.             </canned_text_6>
  5835.             <canned_text_7>
  5836.                 <text>Return Chute</text>
  5837.             </canned_text_7>
  5838.             <canned_text_8>
  5839.                 <text>Advance Chute</text>
  5840.             </canned_text_8>
  5841.             <canned_text_9>
  5842.                 <text>Exact Stop on</text>
  5843.             </canned_text_9>
  5844.             <canned_text_10>
  5845.                 <text>Exact Stop off</text>
  5846.             </canned_text_10>
  5847.         </canned_text>
  5848.     </control>
  5849. <control>
  5850.         <control_label>CTRL_MT_LATHE|DEFAULT</control_label>
  5851.         <language>fr-CA</language>
  5852.         <misc_integers>
  5853.             <misc_1>
  5854.                 <text>""</text>
  5855.             </misc_1>
  5856.             <misc_2>
  5857.                 <text>Abs/Inc. [0=ABS, 1=INC]</text>
  5858.             </misc_2>
  5859.             <misc_3>
  5860.                 <text>Ref. Return [0=G28,1=G30]</text>
  5861.             </misc_3>
  5862.             <misc_4>
  5863.                 <text>Mill Cyc G107/G112 [0=OFF,1=ON]</text>
  5864.             </misc_4>
  5865.             <misc_5>
  5866.                 <text>Synch Spindles [0=OFF,1=ON]</text>
  5867.             </misc_5>
  5868.             <misc_6>
  5869.                 <text>""</text>
  5870.             </misc_6>
  5871.             <misc_7>
  5872.                 <text>""</text>
  5873.             </misc_7>
  5874.             <misc_8>
  5875.                 <text>""</text>
  5876.             </misc_8>
  5877.             <misc_9>
  5878.                 <text>""</text>
  5879.             </misc_9>
  5880.             <misc_10>
  5881.                 <text>CRF X value [0=orig,1=post]</text>
  5882.             </misc_10>
  5883.         </misc_integers>
  5884.         <misc_reals>
  5885.             <misc_1>
  5886.                 <text>""</text>
  5887.             </misc_1>
  5888.             <misc_2>
  5889.                 <text>""</text>
  5890.             </misc_2>
  5891.             <misc_3>
  5892.                 <text>""</text>
  5893.             </misc_3>
  5894.             <misc_4>
  5895.                 <text>""</text>
  5896.             </misc_4>
  5897.             <misc_5>
  5898.                 <text>""</text>
  5899.             </misc_5>
  5900.             <misc_6>
  5901.                 <text>""</text>
  5902.             </misc_6>
  5903.             <misc_7>
  5904.                 <text>""</text>
  5905.             </misc_7>
  5906.             <misc_8>
  5907.                 <text>""</text>
  5908.             </misc_8>
  5909.             <misc_9>
  5910.                 <text>""</text>
  5911.             </misc_9>
  5912.             <misc_10>
  5913.                 <text>""</text>
  5914.             </misc_10>
  5915.         </misc_reals>
  5916.         <simple_drill>
  5917.             <description>
  5918.                 <text>Drill/Counterbore - G83</text>
  5919.             </description>
  5920.             <first_peck>
  5921.                 <text>""</text>
  5922.             </first_peck>
  5923.             <subsequent_peck>
  5924.                 <text>""</text>
  5925.             </subsequent_peck>
  5926.             <peck_clearance>
  5927.                 <text>""</text>
  5928.             </peck_clearance>
  5929.             <retract_amount>
  5930.                 <text>""</text>
  5931.             </retract_amount>
  5932.             <shift>
  5933.                 <text>""</text>
  5934.             </shift>
  5935.         </simple_drill>
  5936.         <peck_drill>
  5937.             <description>
  5938.                 <text>Peck Drill - longhand</text>
  5939.             </description>
  5940.             <first_peck>
  5941.                 <text>Peck</text>
  5942.             </first_peck>
  5943.             <subsequent_peck>
  5944.                 <text>""</text>
  5945.             </subsequent_peck>
  5946.             <peck_clearance>
  5947.                 <text>""</text>
  5948.             </peck_clearance>
  5949.             <retract_amount>
  5950.                 <text>""</text>
  5951.             </retract_amount>
  5952.             <shift>
  5953.                 <text>""</text>
  5954.             </shift>
  5955.         </peck_drill>
  5956.         <chip_break>
  5957.             <description>
  5958.                 <text>Drill/Peck - G83</text>
  5959.             </description>
  5960.             <first_peck>
  5961.                 <text>Peck</text>
  5962.             </first_peck>
  5963.             <subsequent_peck>
  5964.                 <text>""</text>
  5965.             </subsequent_peck>
  5966.             <peck_clearance>
  5967.                 <text>""</text>
  5968.             </peck_clearance>
  5969.             <retract_amount>
  5970.                 <text>""</text>
  5971.             </retract_amount>
  5972.             <shift>
  5973.                 <text>""</text>
  5974.             </shift>
  5975.         </chip_break>
  5976.         <tap>
  5977.             <description>
  5978.                 <text>Tapping - G84</text>
  5979.             </description>
  5980.             <first_peck>
  5981.                 <text>""</text>
  5982.             </first_peck>
  5983.             <subsequent_peck>
  5984.                 <text>""</text>
  5985.             </subsequent_peck>
  5986.             <peck_clearance>
  5987.                 <text>""</text>
  5988.             </peck_clearance>
  5989.             <retract_amount>
  5990.                 <text>""</text>
  5991.             </retract_amount>
  5992.             <shift>
  5993.                 <text>""</text>
  5994.             </shift>
  5995.         </tap>
  5996.         <bore1>
  5997.             <first_peck>
  5998.                 <text>""</text>
  5999.             </first_peck>
  6000.             <subsequent_peck>
  6001.                 <text>""</text>
  6002.             </subsequent_peck>
  6003.             <peck_clearance>
  6004.                 <text>""</text>
  6005.             </peck_clearance>
  6006.             <retract_amount>
  6007.                 <text>""</text>
  6008.             </retract_amount>
  6009.         </bore1>
  6010.         <bore2>
  6011.             <first_peck>
  6012.                 <text>""</text>
  6013.             </first_peck>
  6014.             <subsequent_peck>
  6015.                 <text>""</text>
  6016.             </subsequent_peck>
  6017.             <peck_clearance>
  6018.                 <text>""</text>
  6019.             </peck_clearance>
  6020.             <retract_amount>
  6021.                 <text>""</text>
  6022.             </retract_amount>
  6023.             <shift>
  6024.                 <text>""</text>
  6025.             </shift>
  6026.         </bore2>
  6027.         <misc1>
  6028.             <subsequent_peck>
  6029.                 <text>""</text>
  6030.             </subsequent_peck>
  6031.             <peck_clearance>
  6032.                 <text>""</text>
  6033.             </peck_clearance>
  6034.             <retract_amount>
  6035.                 <text>""</text>
  6036.             </retract_amount>
  6037.         </misc1>
  6038.         <drill_cycle_descriptions>
  6039.             <simple_drill>
  6040.                 <text>Drill/Counterbore - G83</text>
  6041.             </simple_drill>
  6042.             <peck_drill>
  6043.                 <text>Peck Drill - longhand</text>
  6044.             </peck_drill>
  6045.             <chip_break>
  6046.                 <text>Drill/Peck - G83</text>
  6047.             </chip_break>
  6048.             <tapping>
  6049.                 <text>Tapping - G84</text>
  6050.             </tapping>
  6051.         </drill_cycle_descriptions>
  6052.         <stock_transfer_custom_parameters>
  6053.             <custom_integer_1>
  6054.                 <text>Cutoff Tool? [0=no output]</text>
  6055.             </custom_integer_1>
  6056.             <custom_integer_2>
  6057.                 <text>Use Torque Skip?</text>
  6058.             </custom_integer_2>
  6059.             <custom_real_1>
  6060.                 <text>Rapid Position</text>
  6061.             </custom_real_1>
  6062.             <custom_real_2>
  6063.                 <text>Feed Position</text>
  6064.             </custom_real_2>
  6065.             <custom_real_3>
  6066.                 <text>Tool Initial Position</text>
  6067.             </custom_real_3>
  6068.         </stock_transfer_custom_parameters>
  6069.     </control>
  6070. <control>
  6071.         <control_label>CTRL_MT_MILL|HYUNDAIKIA_SKT_FANUC</control_label>
  6072.         <language>en-US</language>
  6073.         <misc_integers>
  6074.             <misc_1>
  6075.                 <text>""</text>
  6076.             </misc_1>
  6077.             <misc_2>
  6078.                 <text>Abs/Inc. [0=ABS, 1=INC]</text>
  6079.             </misc_2>
  6080.             <misc_3>
  6081.                 <text>Ref. Return [0=G28,1=G30]</text>
  6082.             </misc_3>
  6083.             <misc_4>
  6084.                 <text>Mill Cyc G107/G112 [0=OFF,1=ON]</text>
  6085.             </misc_4>
  6086.             <misc_5>
  6087.                 <text>Synch Spindles [0=OFF,1=ON]</text>
  6088.             </misc_5>
  6089.             <misc_6>
  6090.                 <text>""</text>
  6091.             </misc_6>
  6092.             <misc_7>
  6093.                 <text>""</text>
  6094.             </misc_7>
  6095.             <misc_8>
  6096.                 <text>""</text>
  6097.             </misc_8>
  6098.             <misc_9>
  6099.                 <text>""</text>
  6100.             </misc_9>
  6101.             <misc_10>
  6102.                 <text>CRF X value [0=orig,1=post]</text>
  6103.             </misc_10>
  6104.         </misc_integers>
  6105.         <misc_reals>
  6106.             <misc_1>
  6107.                 <text>""</text>
  6108.             </misc_1>
  6109.             <misc_2>
  6110.                 <text>""</text>
  6111.             </misc_2>
  6112.             <misc_3>
  6113.                 <text>""</text>
  6114.             </misc_3>
  6115.             <misc_4>
  6116.                 <text>""</text>
  6117.             </misc_4>
  6118.             <misc_5>
  6119.                 <text>""</text>
  6120.             </misc_5>
  6121.             <misc_6>
  6122.                 <text>""</text>
  6123.             </misc_6>
  6124.             <misc_7>
  6125.                 <text>""</text>
  6126.             </misc_7>
  6127.             <misc_8>
  6128.                 <text>""</text>
  6129.             </misc_8>
  6130.             <misc_9>
  6131.                 <text>""</text>
  6132.             </misc_9>
  6133.             <misc_10>
  6134.                 <text>""</text>
  6135.             </misc_10>
  6136.         </misc_reals>
  6137.         <simple_drill>
  6138.             <description>
  6139.                 <text>Drill, Simple - G83/G87</text>
  6140.             </description>
  6141.             <first_peck>
  6142.                 <text>""</text>
  6143.             </first_peck>
  6144.             <subsequent_peck>
  6145.                 <text>""</text>
  6146.             </subsequent_peck>
  6147.             <peck_clearance>
  6148.                 <text>""</text>
  6149.             </peck_clearance>
  6150.             <retract_amount>
  6151.                 <text>""</text>
  6152.             </retract_amount>
  6153.             <shift>
  6154.                 <text>""</text>
  6155.             </shift>
  6156.         </simple_drill>
  6157.         <peck_drill>
  6158.             <description>
  6159.                 <text>Drill, Full Retract - G83/G87</text>
  6160.             </description>
  6161.             <subsequent_peck>
  6162.                 <text>""</text>
  6163.             </subsequent_peck>
  6164.             <peck_clearance>
  6165.                 <text>""</text>
  6166.             </peck_clearance>
  6167.             <retract_amount>
  6168.                 <text>""</text>
  6169.             </retract_amount>
  6170.             <shift>
  6171.                 <text>""</text>
  6172.             </shift>
  6173.         </peck_drill>
  6174.         <chip_break>
  6175.             <description>
  6176.                 <text>Drill, Chip Break, Longhand</text>
  6177.             </description>
  6178.             <shift>
  6179.                 <text>""</text>
  6180.             </shift>
  6181.         </chip_break>
  6182.         <tap>
  6183.             <description>
  6184.                 <text>Tapping - G84/G88</text>
  6185.             </description>
  6186.             <first_peck>
  6187.                 <text>""</text>
  6188.             </first_peck>
  6189.             <subsequent_peck>
  6190.                 <text>""</text>
  6191.             </subsequent_peck>
  6192.             <peck_clearance>
  6193.                 <text>""</text>
  6194.             </peck_clearance>
  6195.             <retract_amount>
  6196.                 <text>""</text>
  6197.             </retract_amount>
  6198.             <shift>
  6199.                 <text>""</text>
  6200.             </shift>
  6201.         </tap>
  6202.         <bore1>
  6203.             <description>
  6204.                 <text>Boring - G85/G89</text>
  6205.             </description>
  6206.             <first_peck>
  6207.                 <text>""</text>
  6208.             </first_peck>
  6209.             <subsequent_peck>
  6210.                 <text>""</text>
  6211.             </subsequent_peck>
  6212.             <peck_clearance>
  6213.                 <text>""</text>
  6214.             </peck_clearance>
  6215.             <retract_amount>
  6216.                 <text>""</text>
  6217.             </retract_amount>
  6218.         </bore1>
  6219.         <bore2>
  6220.             <description>
  6221.                 <text>Boring - Custom</text>
  6222.             </description>
  6223.             <first_peck>
  6224.                 <text>""</text>
  6225.             </first_peck>
  6226.             <subsequent_peck>
  6227.                 <text>""</text>
  6228.             </subsequent_peck>
  6229.             <peck_clearance>
  6230.                 <text>""</text>
  6231.             </peck_clearance>
  6232.             <retract_amount>
  6233.                 <text>""</text>
  6234.             </retract_amount>
  6235.             <shift>
  6236.                 <text>""</text>
  6237.             </shift>
  6238.         </bore2>
  6239.         <misc1>
  6240.             <description>
  6241.                 <text>Reamer</text>
  6242.             </description>
  6243.             <first_peck>
  6244.                 <text>""</text>
  6245.             </first_peck>
  6246.             <subsequent_peck>
  6247.                 <text>""</text>
  6248.             </subsequent_peck>
  6249.             <peck_clearance>
  6250.                 <text>""</text>
  6251.             </peck_clearance>
  6252.             <retract_amount>
  6253.                 <text>""</text>
  6254.             </retract_amount>
  6255.             <shift>
  6256.                 <text>""</text>
  6257.             </shift>
  6258.         </misc1>
  6259.         <misc2>
  6260.             <description>
  6261.                 <text>Drill Simple - Longhand</text>
  6262.             </description>
  6263.             <first_peck>
  6264.                 <text>""</text>
  6265.             </first_peck>
  6266.             <subsequent_peck>
  6267.                 <text>""</text>
  6268.             </subsequent_peck>
  6269.             <peck_clearance>
  6270.                 <text>""</text>
  6271.             </peck_clearance>
  6272.             <retract_amount>
  6273.                 <text>""</text>
  6274.             </retract_amount>
  6275.             <shift>
  6276.                 <text>""</text>
  6277.             </shift>
  6278.         </misc2>
  6279.         <drill_cycle_9>
  6280.             <description>
  6281.                 <text>Drill, Full Retract - Longhand</text>
  6282.             </description>
  6283.             <dwell>
  6284.                 <text>""</text>
  6285.             </dwell>
  6286.             <subsequent_peck>
  6287.                 <text>""</text>
  6288.             </subsequent_peck>
  6289.             <retract_amount>
  6290.                 <text>""</text>
  6291.             </retract_amount>
  6292.             <shift>
  6293.                 <text>""</text>
  6294.             </shift>
  6295.         </drill_cycle_9>
  6296.         <misc1_custom_parameters>
  6297.             <parameter_1>
  6298.                 <text>Return Feed</text>
  6299.             </parameter_1>
  6300.             <parameter_2>
  6301.                 <text>""</text>
  6302.             </parameter_2>
  6303.             <parameter_3>
  6304.                 <text>""</text>
  6305.             </parameter_3>
  6306.             <parameter_4>
  6307.                 <text>""</text>
  6308.             </parameter_4>
  6309.             <parameter_5>
  6310.                 <text>""</text>
  6311.             </parameter_5>
  6312.             <parameter_6>
  6313.                 <text>""</text>
  6314.             </parameter_6>
  6315.             <parameter_7>
  6316.                 <text>""</text>
  6317.             </parameter_7>
  6318.             <parameter_8>
  6319.                 <text>""</text>
  6320.             </parameter_8>
  6321.             <parameter_9>
  6322.                 <text>""</text>
  6323.             </parameter_9>
  6324.             <parameter_10>
  6325.                 <text>""</text>
  6326.             </parameter_10>
  6327.         </misc1_custom_parameters>
  6328.         <drill_cycle_9_custom_parameters>
  6329.             <parameter_1>
  6330.                 <text>Entry Feed</text>
  6331.             </parameter_1>
  6332.             <parameter_2>
  6333.                 <text>Exit Feed</text>
  6334.             </parameter_2>
  6335.             <parameter_3>
  6336.                 <text>""</text>
  6337.             </parameter_3>
  6338.             <parameter_4>
  6339.                 <text>""</text>
  6340.             </parameter_4>
  6341.             <parameter_5>
  6342.                 <text>""</text>
  6343.             </parameter_5>
  6344.             <parameter_6>
  6345.                 <text>""</text>
  6346.             </parameter_6>
  6347.             <parameter_7>
  6348.                 <text>""</text>
  6349.             </parameter_7>
  6350.             <parameter_8>
  6351.                 <text>""</text>
  6352.             </parameter_8>
  6353.             <parameter_9>
  6354.                 <text>""</text>
  6355.             </parameter_9>
  6356.             <parameter_10>
  6357.                 <text>""</text>
  6358.             </parameter_10>
  6359.         </drill_cycle_9_custom_parameters>
  6360.         <drill_cycle_descriptions>
  6361.             <simple_drill>
  6362.                 <text>Drill, Simple - G83/G87</text>
  6363.             </simple_drill>
  6364.             <peck_drill>
  6365.                 <text>Drill, Full Retract - G83/G87</text>
  6366.             </peck_drill>
  6367.             <chip_break>
  6368.                 <text>Drill, Chip Break, Longhand</text>
  6369.             </chip_break>
  6370.             <tapping>
  6371.                 <text>Tapping - G84/G88</text>
  6372.             </tapping>
  6373.             <boring_1>
  6374.                 <text>Boring - G85/G89</text>
  6375.             </boring_1>
  6376.             <boring_2>
  6377.                 <text>Boring - Custom</text>
  6378.             </boring_2>
  6379.             <misc_drill_1>
  6380.                 <text>Reamer</text>
  6381.             </misc_drill_1>
  6382.             <misc_drill_2>
  6383.                 <text>Drill Simple - Longhand</text>
  6384.             </misc_drill_2>
  6385.             <custom_drill_9>
  6386.                 <text>Drill, Full Retract - Longhand</text>
  6387.             </custom_drill_9>
  6388.             <custom_drill_10>
  6389.                 <text>""</text>
  6390.             </custom_drill_10>
  6391.             <custom_drill_11>
  6392.                 <text>""</text>
  6393.             </custom_drill_11>
  6394.             <custom_drill_12>
  6395.                 <text>""</text>
  6396.             </custom_drill_12>
  6397.             <custom_drill_13>
  6398.                 <text>""</text>
  6399.             </custom_drill_13>
  6400.             <custom_drill_14>
  6401.                 <text>""</text>
  6402.             </custom_drill_14>
  6403.             <custom_drill_15>
  6404.                 <text>""</text>
  6405.             </custom_drill_15>
  6406.             <custom_drill_16>
  6407.                 <text>""</text>
  6408.             </custom_drill_16>
  6409.             <custom_drill_17>
  6410.                 <text>""</text>
  6411.             </custom_drill_17>
  6412.             <custom_drill_18>
  6413.                 <text>""</text>
  6414.             </custom_drill_18>
  6415.             <custom_drill_19>
  6416.                 <text>""</text>
  6417.             </custom_drill_19>
  6418.             <custom_drill_20>
  6419.                 <text>""</text>
  6420.             </custom_drill_20>
  6421.         </drill_cycle_descriptions>
  6422.         <canned_text>
  6423.             <canned_text_1>
  6424.                 <text>Program Stop</text>
  6425.             </canned_text_1>
  6426.             <canned_text_2>
  6427.                 <text>Optional Stop</text>
  6428.             </canned_text_2>
  6429.             <canned_text_3>
  6430.                 <text>Block Delete on</text>
  6431.             </canned_text_3>
  6432.             <canned_text_4>
  6433.                 <text>Block Delete off</text>
  6434.             </canned_text_4>
  6435.             <canned_text_5>
  6436.                 <text>Return Tailstock</text>
  6437.             </canned_text_5>
  6438.             <canned_text_6>
  6439.                 <text>Advance Tailstock</text>
  6440.             </canned_text_6>
  6441.             <canned_text_7>
  6442.                 <text>Return Chute</text>
  6443.             </canned_text_7>
  6444.             <canned_text_8>
  6445.                 <text>Advance Chute</text>
  6446.             </canned_text_8>
  6447.             <canned_text_9>
  6448.                 <text>Exact Stop on</text>
  6449.             </canned_text_9>
  6450.             <canned_text_10>
  6451.                 <text>Exact Stop off</text>
  6452.             </canned_text_10>
  6453.         </canned_text>
  6454.     </control>
  6455.     <control>
  6456.         <control_label>CTRL_MT_LATHE|HYUNDAIKIA_SKT_FANUC</control_label>
  6457.         <language>en-US</language>
  6458.         <misc_integers>
  6459.             <misc_1>
  6460.                 <text>""</text>
  6461.             </misc_1>
  6462.             <misc_2>
  6463.                 <text>Abs/Inc. [0=ABS, 1=INC]</text>
  6464.             </misc_2>
  6465.             <misc_3>
  6466.                 <text>Ref. Return [0=G28,1=G30]</text>
  6467.             </misc_3>
  6468.             <misc_4>
  6469.                 <text>Mill Cyc G107/G112 [0=OFF,1=ON]</text>
  6470.             </misc_4>
  6471.             <misc_5>
  6472.                 <text>Synch Spindles [0=OFF,1=ON]</text>
  6473.             </misc_5>
  6474.             <misc_6>
  6475.                 <text>""</text>
  6476.             </misc_6>
  6477.             <misc_7>
  6478.                 <text>""</text>
  6479.             </misc_7>
  6480.             <misc_8>
  6481.                 <text>""</text>
  6482.             </misc_8>
  6483.             <misc_9>
  6484.                 <text>""</text>
  6485.             </misc_9>
  6486.             <misc_10>
  6487.                 <text>CRF X value [0=orig,1=post]</text>
  6488.             </misc_10>
  6489.         </misc_integers>
  6490.         <misc_reals>
  6491.             <misc_1>
  6492.                 <text>""</text>
  6493.             </misc_1>
  6494.             <misc_2>
  6495.                 <text>""</text>
  6496.             </misc_2>
  6497.             <misc_3>
  6498.                 <text>""</text>
  6499.             </misc_3>
  6500.             <misc_4>
  6501.                 <text>""</text>
  6502.             </misc_4>
  6503.             <misc_5>
  6504.                 <text>""</text>
  6505.             </misc_5>
  6506.             <misc_6>
  6507.                 <text>""</text>
  6508.             </misc_6>
  6509.             <misc_7>
  6510.                 <text>""</text>
  6511.             </misc_7>
  6512.             <misc_8>
  6513.                 <text>""</text>
  6514.             </misc_8>
  6515.             <misc_9>
  6516.                 <text>""</text>
  6517.             </misc_9>
  6518.             <misc_10>
  6519.                 <text>""</text>
  6520.             </misc_10>
  6521.         </misc_reals>
  6522.         <simple_drill>
  6523.             <description>
  6524.                 <text>Drill, Simple - G83</text>
  6525.             </description>
  6526.             <first_peck>
  6527.                 <text>""</text>
  6528.             </first_peck>
  6529.             <subsequent_peck>
  6530.                 <text>""</text>
  6531.             </subsequent_peck>
  6532.             <peck_clearance>
  6533.                 <text>""</text>
  6534.             </peck_clearance>
  6535.             <retract_amount>
  6536.                 <text>""</text>
  6537.             </retract_amount>
  6538.             <shift>
  6539.                 <text>""</text>
  6540.             </shift>
  6541.         </simple_drill>
  6542.         <peck_drill>
  6543.             <description>
  6544.                 <text>Drill, Full Retract - G83</text>
  6545.             </description>
  6546.             <subsequent_peck>
  6547.                 <text>""</text>
  6548.             </subsequent_peck>
  6549.             <peck_clearance>
  6550.                 <text>""</text>
  6551.             </peck_clearance>
  6552.             <retract_amount>
  6553.                 <text>""</text>
  6554.             </retract_amount>
  6555.             <shift>
  6556.                 <text>""</text>
  6557.             </shift>
  6558.         </peck_drill>
  6559.         <chip_break>
  6560.             <description>
  6561.                 <text>Drill, Chip Break, Longhand</text>
  6562.             </description>
  6563.             <shift>
  6564.                 <text>""</text>
  6565.             </shift>
  6566.         </chip_break>
  6567.         <tap>
  6568.             <description>
  6569.                 <text>Tapping - G84</text>
  6570.             </description>
  6571.             <first_peck>
  6572.                 <text>""</text>
  6573.             </first_peck>
  6574.             <subsequent_peck>
  6575.                 <text>""</text>
  6576.             </subsequent_peck>
  6577.             <peck_clearance>
  6578.                 <text>""</text>
  6579.             </peck_clearance>
  6580.             <retract_amount>
  6581.                 <text>""</text>
  6582.             </retract_amount>
  6583.             <shift>
  6584.                 <text>""</text>
  6585.             </shift>
  6586.         </tap>
  6587.         <bore1>
  6588.             <first_peck>
  6589.                 <text>""</text>
  6590.             </first_peck>
  6591.             <subsequent_peck>
  6592.                 <text>""</text>
  6593.             </subsequent_peck>
  6594.             <peck_clearance>
  6595.                 <text>""</text>
  6596.             </peck_clearance>
  6597.             <retract_amount>
  6598.                 <text>""</text>
  6599.             </retract_amount>
  6600.             <shift>
  6601.                 <text>""</text>
  6602.             </shift>
  6603.         </bore1>
  6604.         <bore2>
  6605.             <first_peck>
  6606.                 <text>""</text>
  6607.             </first_peck>
  6608.             <subsequent_peck>
  6609.                 <text>""</text>
  6610.             </subsequent_peck>
  6611.             <peck_clearance>
  6612.                 <text>""</text>
  6613.             </peck_clearance>
  6614.             <retract_amount>
  6615.                 <text>""</text>
  6616.             </retract_amount>
  6617.             <shift>
  6618.                 <text>""</text>
  6619.             </shift>
  6620.         </bore2>
  6621.         <misc1>
  6622.             <description>
  6623.                 <text>Reamer</text>
  6624.             </description>
  6625.             <first_peck>
  6626.                 <text>""</text>
  6627.             </first_peck>
  6628.             <subsequent_peck>
  6629.                 <text>""</text>
  6630.             </subsequent_peck>
  6631.             <peck_clearance>
  6632.                 <text>""</text>
  6633.             </peck_clearance>
  6634.             <retract_amount>
  6635.                 <text>""</text>
  6636.             </retract_amount>
  6637.             <shift>
  6638.                 <text>""</text>
  6639.             </shift>
  6640.         </misc1>
  6641.         <misc1_custom_parameters>
  6642.             <parameter_1>
  6643.                 <text>Return Feed</text>
  6644.             </parameter_1>
  6645.             <parameter_2>
  6646.                 <text>""</text>
  6647.             </parameter_2>
  6648.             <parameter_3>
  6649.                 <text>""</text>
  6650.             </parameter_3>
  6651.             <parameter_4>
  6652.                 <text>""</text>
  6653.             </parameter_4>
  6654.             <parameter_5>
  6655.                 <text>""</text>
  6656.             </parameter_5>
  6657.             <parameter_6>
  6658.                 <text>""</text>
  6659.             </parameter_6>
  6660.             <parameter_7>
  6661.                 <text>""</text>
  6662.             </parameter_7>
  6663.             <parameter_8>
  6664.                 <text>""</text>
  6665.             </parameter_8>
  6666.             <parameter_9>
  6667.                 <text>""</text>
  6668.             </parameter_9>
  6669.             <parameter_10>
  6670.                 <text>""</text>
  6671.             </parameter_10>
  6672.         </misc1_custom_parameters>
  6673.         <drill_cycle_descriptions>
  6674.             <simple_drill>
  6675.                 <text>Drill, Simple - G83</text>
  6676.             </simple_drill>
  6677.             <peck_drill>
  6678.                 <text>Drill, Full Retract - G83</text>
  6679.             </peck_drill>
  6680.             <chip_break>
  6681.                 <text>Drill, Chip Break, Longhand</text>
  6682.             </chip_break>
  6683.             <tapping>
  6684.                 <text>Tapping - G84</text>
  6685.             </tapping>
  6686.             <misc_drill_1>
  6687.                 <text>Reamer</text>
  6688.             </misc_drill_1>
  6689.         </drill_cycle_descriptions>
  6690.         <stock_transfer_custom_parameters>
  6691.             <custom_integer_1>
  6692.                 <text>Cutoff Tool? [0=no output]</text>
  6693.             </custom_integer_1>
  6694.             <custom_integer_2>
  6695.                 <text>Use Torque Skip?</text>
  6696.             </custom_integer_2>
  6697.             <custom_real_1>
  6698.                 <text>Rapid Position</text>
  6699.             </custom_real_1>
  6700.             <custom_real_2>
  6701.                 <text>Feed Position</text>
  6702.             </custom_real_2>
  6703.             <custom_real_3>
  6704.                 <text>Tool Initial Position</text>
  6705.             </custom_real_3>
  6706.         </stock_transfer_custom_parameters>
  6707.     </control>
  6708. </mp_xml_post_text>
  6709. [CTRL_TEXT_XML_END]
  6710.  
Tags: mastercam
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement