Numeryx Home > User/Programmer

Programming 6.00

An-108, Copyright © by Gil Hagiz
Last updated Jul-18-2005
For version 6.00 and later
(For version 5.11)

Introduction

This application note describes the plain NC programming for creating a post processor.
For manual programming, in addition to the standard g and m codes there are g-codes for polar, spherical and toroidal coordinates, and the programmer can use the built-in Basic-like computer language that can do:

These functions are described in the programming manual, chapter #4.

  1. Letter addresses
  2. Note: the @ sign is used to extend the number of addresses above 26.

    A	Rotary axis - angle about X axis
    B	Rotary axis - angle about Y axis
    C	Rotary axis - angle about Z axis
    @C	Chamfer (with radius compensation)
    D	Dwell (non modal)
    E	Distance (with radius compensation)
    F	Feed
    G	Preparatory function
    H	5-axis TCP mode
    I,J,K	Absolute polar center, offset for a Cartesian arc
    L	Not used
    M	Miscellaneous
    N	Block number
    O	Not used
    P	Angle for polar coordinates, look ahead angle
    @P	Vertical angle for spherical coordinates
    Q	Fillet (with radius compensation)
    R	Radius for Polar coordinates
    @R	Smaller radius for toroidal coordinates
    S	Spindle speed
    T	Tool number
    U,V,W	Secondary Cartesian axes
    X,Y,Z	Primary Cartesian axes

    Notes: the addresses X,Y,Z,U,V,W,A,B,C can be assigned to the 8 axes in any combination.
    Unused addresses can be used as parameters to sub-programs.

    For drilling canned cycles the following addresses are used, not affecting their modal value:

    R	Reference plane - Z at beginning of drilling
    Z	Z at bottom
    F	Feed for drilling or pitch for tapping (see details below)
    Q	Step for peck drilling
    D	Dwell at bottom

    These addresses should be written in the block after the drilling-G (see drilling cycles below).

  3. G-Codes
  4. This list doesn't include g-codes that are used mostly in manual programming like polar and spherical coordinates, pocket milling, etc.

    1. Standard
    2. g0	Positioning.
      	Optionally, if Z goes up it will move first; if Z goes down XY will move first.
      g1	Linear interpolation of all programmed axes. Vector feed.
      g2,g3	CW, CCW circular interpolation in the selected plane, with IJ or R (-R).
      	If both IJ and R are written IJ are used.
      	If the end point is same as the start point a full circle is cut.
      	I,J,K are set to zero if not programmed.
      
      g4	No operation. Dwell can be programmed under D in any block.
      g5	No motion. IJK=programmed XYZ.
      
      g8	No stop, single shot.
      g9	Exact stop, single shot.
      
      g17-g19 Plane select XY, ZX, YZ.
      g40	Tool radius compensation cancel. Length offset on.
      g41,g42 Tool radius compensation left or right. Length offset on.
      g41.1	Ball and Bull nose radius compensation, using vector IJK.
      g42.2	Same as g41.1 but offset in the negative direction of vector IJK.
      
      g52	Local coordinates.
      g53	Machine coordinates.
      g54-g59.3 Work coordinates.
      g60	Uni-directional approach positioning.
      g61,g64	Exact stop, cutting mode.
      g62	Tool compensation controls exact stop.
      g70,g71	Inch-Metric.
      g80-g86	Drilling canned cycles.
      g90,g91	Absolute-incremental.
      g92	Zero shift.
      g93-g95	Feed: inverse time (1/min), per min, per rev.

    3. Drilling canned cycles
    4. Note: these cycles are programmable.

      g80	Canned cycles cancel
      g81 Drilling g82 Drilling with dwell (counter boring) g83 Peck drilling with periodic withdrawal g83.1 Peck drilling with periodic chip breaking g84 Flexible tap, Pitch g84.1 Flexible tap, TPI g84.2 Rigid tap, Pitch g84.3 Rigid tap, TPI To cut a left hand thread enter negative value for S. g85 Boring g86 Boring with spindle stop g98 The tool retracts to the initial Z (default) g99 The tool retracts to the R plane g90 R (R-plane) and Z at the bottom of the hole are given as absolute positions (default) g91 R is the relative distance from the initial Z to the reference plane. Z is the depth of the drilling from R-plane. Both R and Z are expected to be negative for normal drilling.

      Drilling cycles are written in positioning blocks g0 or g10 (polar coordinates) or g60.
      The drilling cycles work for 5-axis machines as well. Z always moves in the tool direction.
      For more details Click here

    5. Notes
    6. More g-codes are available for manual programming, e.g. polar and spherical coordinates.

      G-codes from different groups can be written in the same line with other g-codes:

      [g0 to g5]
      [g8, g9]
      [g17 to g19]
      [g53 to g59.3]
      [g61, g62, g64]
      [g70 g71]
      [g73, g74, g80 to g86]
      [g90, g91]
      [g93, g94, g95]
      [g98, g99]

      If g-codes of same group are programmed in the same line the last one will be active.
      g40 to g42, and g codes that take data like g52 and g92, g60, g200 and up (programmable g-codes) require their own line.
      For tool comp G-codes, no XYZ data or any motion G-code should be written.

  5. M-functions
  6. M-functions 0 to 99 can be used.

    All M-functions are programmable. M0 and M2/M30 Hold and End a program internally but usually are programmed to do additional tasks, like turning spindle and coolant off.

    1. Standard
    2. m0,m1	Program stop, optional stop
      m2,m30	Program end
      m3-m5	Spindle CW, CCW, Stop
      m5.1	Wait for spindle stop
      m6	Tool change
      m7-m9	Mist, flood, off
      m19	Oriented spindle stop (canceled with another spindle command)
      m48,m49	Override enabled, disabled
      m50	Cancel dynamic offset; optionally go to machine zero

      Usually m5 calls m9 and m2 stops everything.

    3. Specific
    4. These M-functions are used internally when needed:

      m41-m44	Gear low, med, high, neutral
      m80-m99	Tool changer

  7. Programming
    1. Format
    2. A program should be a text file free of formatting codes.
      File name follows DOS format 8.3. Any extension is allowed except .BAK.
      Max program length is about 3,000,000 lines or 250 MB.

    3. EOB mark
    4. Both CR-LF (ASCII 13,10, Dos style) and LF (ASCII 10, Unix style) are recognized. Can be mixed.

    5. Case
    6. Lower and upper case are treated the same. Can be mixed.

    7. Beginning of Program
    8. No special mark. Do not use the percent (%) sign.

    9. End of Program
    10. Use either m2 or m30, the latter displays program running time.
      If last line of program is reached m2 is appended automatically.

    11. Comments
    12. Use backslash (\). Anything after a backslash, until end-of-line, is ignored.
      In addition, open parenthesis '(' in the beginning of a line is considered comment as well.
      Note that comments are not displayed on the screen.

    13. Block number
    14. Can optionally be used, with or without N.
      Range: 0 to 9,999,999.
      Decimal point cannot be used.
      Order is unimportant.
      If block number is used it is displayed.
      Block number must be used for jumping to that block.

    15. Program name
    16. Can be written as a comment in the first line, which must be n-zero. Example:
      n\ABC-1234
      Both Dos name and program name are displayed when the program is loaded.

    17. Block Skip
    18. Block skip command is the slash (/). It is recognized at the beginning of a block.
      This is a programmable option. If not used the slash is ignore.

    19. Empty line
    20. Empty lines are ignored.

    21. Spacing
    22. Spaces can optionally be used anywhere but not inside a number or NC address: Example:

      X123	OK
      X 123	Error

    23. Zero
    24. Leading and trailing zeros are not required and ignored.
      If no number follows an address it is assumed to be zero. In this case space must follow.
      Example:

      X123y46.8   Z-.34 C A

    25. Decimal Point
    26. The following addresses use integers internally, in a limited range:

      N	 0 to 9,999,999
      G	 -255 to 255 (with one decimal)
      M	 0 to 99 (with one decimal); M's above 100 are used for special internal functions.
      T	 0 to 253
      H	 0 to 65535
      S	 0 to 999,999

      For all other addresses, decimal point can be freely used or ignored. Example of valid entries of 123 mm or Inch:

      X123 Y123. Z123.0

      An NC address can hold an eight-digit number with floating decimal point.
      The internal buffer is 15 digit wide (15 digits) so that incremental data does not accumulate errors.

    27. Parameters
    28. A parameter is a variable that can hold a 15-digit number.
      Parameters are mostly used with manual programming, therefore the description here is very brief.
      Parameters #1 to #99 are always available to the user, but up to additional 8000 parameters can be used by m100/m101 (off/on). M101 can be set as the default if so desired.
      In a program, values are assigned to parameters by the equal sign:

      n10 #1=100 #2=-1 #3=-#3
      n20 #10=#11=#17=0
      All arithmetic operators, parentheses, and most functions can be used for calculations according to standard precedence. PI (3.14) accuracy is 15 digits.
      A parameter is assigned to a letter-address with or without the equal sign. The equal sign must be used for calculations:
      X#21 y=#21+10 z=(#23+sin(30)-1)*7

    29. Incremental
    30. All floating-point addresses and variables can use + for incremental. Note that g91 uses incremental data for the axes only, while + can be used for other addresses or parameters.

      X1000 x+1  y+-2 #12+=1

    31. M functions
    32. All M-functions are programmable. A list of special M is provided for every machine.
      One M function can be written in a block. M-function is executed after the motion in the block ends.
      Most M-functions cause exact stop.
      If M and D are programmed in the same block then D may be used by the M-cycle; if not then D is executed after the M ends.

    33. G2/G3
    34. These codes are not limited to one quadrant. A full circle can be programmed in one block if the end point is not programmed, or it is the same as the starting point.
      Either IJ or R can be used. If both are used then R is ignored. (R is set to the radius).
      For plane select g17, g18, g19 use IJ, KI, JK.
      With any circular interpolation, Z and other axes can be programmed for linear move during the circular cut. Vector feed is always used.
      When R is used 2 arcs can be generated: for up to 180 deg use R, above 180 deg use –R.

    35. Tool Change
    36. Use M6 T_ for automatic or manual tool change.
      M6 is ignored if the tool is already loaded in the spindle.
      M6 is usually written in a positioning block that moves the tool to a safe position before calling M6.
      M6 preserves user's data like scale, mirror, fixture offset, rotation, etc. No g53 is required.
      M6 doesn't resume spindle and coolant.
      Usually M6 activates tool length compensation.
      If a tool changer can be prepared for the next tool, write T_ in a line that does not include:
      g40, g41, g42, m6. (Usually in the next line after m6).

    37. Tool Offset Number
    38. Use g40 to g42 with T_ for tool compensation. No other data should be written in that block.
      Tool data is entered in a tool table so compensation can be taken from any tool number, not necessarily the tool in the spindle.
      Tool data for each tool in the tool table can be length or radius or both.
      G40 cancels radius compensation but keeps length compensation. G40 T cancels all compensations.
      Tool data can be read and/or modified in the program by using variables TL, TR and TS (Bull nose smaller radius).
      Example:

      If TR>10 then <error message> end
      TR+=1   \increase tool radius by 1
      G40 to G42 do not generate any motion. The next g0 or g1 block moves the tool tangent to next cut.
      Z motion inside corners is handled correctly without canceling the compensation.
      Note: H and D are used for other functions. G43 and G49 are not used.

    39. Dwell
    40. Dwell in seconds can be programmed under address D in any block.
      Shortest dwell is 0.01 sec. Max dwell is 300,000 years.
      Dwell is always the last operation in a block, regardless of where it is written in the block.
      Dwell causes an exact stop before it begins. Dwell can be skipped by pressing CS.
      G4 is a no-operation block, since D can be written in any block.

    41. Home select
    42. Home select (fixture offset) is done by g54 to g59 and g59.1 to g59.3.
      G92 can be used with XYZ.
      If none is written, g54 is the default.
      In addition to Home selection, G52, in its own block, can be used for local coordinates.

    43. Plane Select
    44. Standard G17 to G19 are used.
      If none is written at the beginning of a program the default is g17.

    45. Scale & Mirror
    46. The command Scale is used:

      Scale x2 y2 z1
      Axes that are not written do not change. The selected plane axes must have same scale.
      F can be used in the Scale command, to multiply all subsequent feeds by a constant.
      For mirror image use negative scale for any number of axes:
      Scale x-1
      Note: Scale behaves like a g-code and must be written in its own line.

    47. Rotate
    48. To rotate a part program use the Rotate command in its own line or with the first motion command where rotation is desired:

      n10 rot(30)
      n20 g0 x100 y200 z
       or
      n20 g0 x100 y200 z rot(30)
      The location of the Rot command in the line is unimportant.
      The rotation is performed in the selected plane (g17 to g19).
      The rotation is about the current zero (fixture offset and/or local coordinates).
      Rotate is canceled with any of the plane select codes or with Rot(0).

    49. Spindle
    50. Use m3/m4 with spindle speed under S to start the spindle.
      S can take a value from 1 to 999,999.
      If S is too high, it is limited internally and no error is displayed.
      S without m3/m4 doesn't change the speed.
      If the machine has two or more gears the correct gear will be selected.
      While the spindle accelerates, a positioning command can be executed. G1, however, waits for correct spindle speed. To save time, write your program as follows:

      n10 m3 s2000		\Spindle command
      n20 g0 x10 y5 z1	\positioning
      n30 g1 z-.5		\G1 waits until RPM=2000
      .....

    51. Feed
    52. Vector feed is always used. G64 can always be used. There is no need to reduce feed before small circles, corners, or small increments, this is done internally.
      Increments as low as 0.001 mm (0.00004") can be used.
      Low F should be used when the process requires it.

    53. User Messages
    54. Use the command Print anywhere in a block, even more than once:

      Pr "Use tool number ",#14
      (display the value of parameter #14)
      Print and math are executed before any motion in that block.

    55. Help
    56. A single block of text in a file can be defined as Help. This could be for example a header text.
      To mark the text as Help write Help before it and close it with a backslash (\), which must be the first character in a line.
      The text line should not be longer than 77 characters each. Example:

      Help
      Program 1234
      Use tools 1 to 5
      . . . .
      \
      N10 g_ . . . .
      When the program is loaded pressing F1 displays this help.

    57. Defaults
    58. If the program is in Reset mode then CS starts the program from its beginning while first setting the following defaults:

    59. Don't
    60. Do not use D, H, P. They have different functions in NCPLUS.
      Also do not use g43 and g49.

  8. 5-axis milling
  9. For details Click Here