Contents - Index - Previous - Next


CNC File Specification for WELmill


It is essential that NC code is correctly formatted otherwise WELmill will not be able to process it. This applies regardless of how the code is created, manually or by software.

For a CNC file to be recognised and processed by WELmill it must have the following characteristics:

1. The first line of the file must consist only of a percent sign (%) placed in the first column. Nothing else is allowed on this line.

2. Lines after the percent sign starting with an asterisk (*) are treated as comment lines. Use this feature to include useful information at the top of the file, such the part name and the billet dimensions, and also to label the various machining operations within the file.

3. Code lines may include an apostrophe ('). The apostrophe and anything following it are treated as a comment. Use this feature to explain the function of a line of code.

4. Code lines do not need to be numbered but they are helpful to people reading the code. If lines are to be numbered, the lines must start with an uppercase N. The N is the first field in a line of code.

5. If used, the letter N will be immediately followed by a number. If code is being created manually, it is suggested that line numbers increment in tens to allow for insertions. In code produced by CADCAM software, numbers can increment in ones.

6. Any amount of white space (including none), which may include punctuation marks such as a comma, may be used to separate the various fields on a line.

7. The second field can be either:

one of the following G-codes
(note the uppercase letters for all commands and the format - no leading zeroes)

G0   (rapid move)
G1   (move at feed rate)
G2   (clockwise arc at feed rate)
G3   (counter-clockwise arc at feed rate)  
G4   (dwell
- a pause of so many seconds)

or one of the following special codes

Tn   (Tool Number n, where n is in the range 1 to 99)
Sxxx (set spindle speed to xxx revs/min)

8. A tool number line (T) is always followed by a spindle speed (S) line. The first command in a code file must be a T command with a tool number, eg T6. Any syntactically correct code prior to the first T command is ignored. Any other characters prior to the first T command will cause an error report.

9. Each G-code is followed, as appropriate for the command, by X, Y, Z, R, I, J, F and P fields and their values.

G0 and G1 codes have X, Y and Z fields. These are the co-ordinates of the end of a linear movement. The movement can be in any of the three planes, XY, XZ or YZ. It can also be a movement in all three planes, ie a full 3 axis XYZ movement: such a movement was not possible with the original Emco controller.

G2 and G3 codes have X and Y fields only (no Z field). G2 and G3 can only be used for arcs in the X-Y plane. The X and Y values are the co-ordinates of the end of an arc. The co-ordinates of the start of the arc are set by the preceding command. Viewed from above: with G2 the arc is cut clockwise; with G3 the arc is cut counter-clockwise.

G4 has only a P field. Its value is the duration of the dwell in seconds. For example, for a dwell of 5 seconds the line of code will read N30 G4 P5

G1, G2 and G3 have an F field. This is the cutting feed rate (mm/min) and is set to a maximum of 499mm/min. G0 does not have an F field. G0 takes its speed from the rapid traverse rate declared in Options - Settings. The maximum permitted value is 600mm/min.

G2 and G3 can have either an R field or I and J fields: this is to give manual programmers a choice of method. I and J fields are preferable and should be used in CADCAM software post processors.

The R field option: R is the radius of the arc. Arcs using the R field can have an included angle of up to and including 180 degrees. A arc with an included angle greater than 180 degrees must be split into two parts. The code format is, for example, N120 G2 X50 Y50 R10 F300

The I and J fields option:  
I and J are the relative distances, in X and Y respectively, from the start of the arc to the centre of the arc and must be preceded by a minus sign when necessary. Only one line of code is required to fully define an arc up to and including a circle.The code format is, for example,
N139 G3 X55 Y60 I20 J-25 F300

Manual programmers should note that, in any code listing, there can be G2 and G3 lines with an R field and there can be other G2 and G3 lines with I and J fields

10. Any field value remains the same (ie it is modal) until a new value is declared. It is not necessary to repeat a field value that remains unchanged from the previous command but many people find a code listing easier to read if it is repeated. The one exception to this modal rule is that the F (feed rate) value must be restated for the next G1 or G2 or G3 command which follows a G0 command.

11. The units of measurement used by WELmill are millimetres only. They may be positive or negative and include as many decimal places as desired.

12. The X, Y and Z values must be absolute values only, ie all measured from an origin point where X = 0, Y = 0, Z = 0. This point is normally the top, left, front corner of the billet (but see Setting the Origin for Machining). Incremental values are not allowed.

13. The end of the code listing should be marked by a % sign. This is optional but its use will reassure a user that the code listing is complete.

The % sign can be placed on a line by itself after the last line of code, eg
N123 G0 Z50
%

or, it can be preceded by a line number, eg
N123 G0 Z50
N124%

And, in the latter case, it can have a comment on the same line, eg
N123 G0 Z50
N124%  'end of code

14. WELmill does not use any M codes.

There is a detailed illustration and explanation of code for WELmill in the section titled Example of Manually Created NC Code

CAD Software as an Aid to NC Code Preparation
Code File Header Information
Example of Manually Created NC Code
Speeds and Feeds for High Speed Steel (HSS) Tools
Speeds and Feeds for Tipped Tools (not HSS)
WELmill NC code file extension