Calculators / NC backplot, editor and NC to DXF

Calculators

NC backplot, editor and NC to DXF

See the toolpath of a machining center or lathe program line by line, including the G71 to G76 lathe cycles and G16 polar coordinates, draw the cut edge of a CAM program, measure it, and convert it to DXF to check against the drawing. Edit the program too: renumber N, find and replace, shift coordinates, scale F and S, split by tool, compare two programs, add decimal points and convert old programs. Everything runs in your browser; the program never leaves your computer.

or paste the program below
Edit program
Send to machine (RS-232)SimulateTool offsets (G10)

Find a G or M code

    Enter or click to put the code at the caret. Meanings are for Fanuc controls; always check the machine’s manual.

    Machine data, for the time, the G00 path and the program size
    XYZ
    Rapidm/min
    Accelerationm/s²

    Program—
    Tool changes—
    Estimated time—
    X cutting range—
    Y cutting range—
    Depth Z—

     

    How to check a program

    1. Choose the machine, then paste or open the program. Look first at the list of lines to check yourself that appears.
    2. Press ▶ or drag the position bar to follow the path line by line. The active codes (such as G90 G41 D03 G43 H03) show under the view. Put the cursor on any line of the program and its path is highlighted.
    3. Press Measure and click two points. The converter snaps to line ends, arc centres and hole centres, and shows both points' coordinates and the distance between them, to compare with the drawing. Or click on an arc (away from its ends and centre) to see its radius R, centre, angle and arc length.
    4. Download the DXF and open it in CAD with the drawing. The file's 0,0,0 is the program's work zero: move the drawing so the datum used to set the zero sits on 0,0, without scaling.
    5. Download SVG gives the drawing as the view on screen, in mm or inches, to open in a browser, put in a document or edit in Inkscape. Each tool is its own layer, as in the DXF. The view from above is at true size; a turned view such as the iso view is a flat picture, so depths cannot be measured from it. To turn the part in 3D, open the DXF in CAD.

    Editing the program

    • Colours and line numbers: G codes, M codes, coordinates, feeds and speeds, tools and comments each have a colour. A red line number is a line to check; point at it to see why, and click a number to go to its line.
    • Codes as you type: type G or M and a digit and a list of the codes that start with it opens at the caret, with what each does and its usual format. Arrow keys choose, Enter or Tab puts it in, Esc closes it. G1 also offers G01.
    • The line explained: under the editor, each word of the caret’s line is given in plain words, read with the modes in force from the lines above (R is a radius after G02 but the R level in a drilling cycle; X Y in a drilling cycle drill another hole). Words a code usually needs and the line lacks, such as Q of G83, are shown in red, with the usual format of the line’s codes. The format has a box for each value: Enter or Put in line writes them into the line (a box emptied takes that word out, and whole numbers for X Y Z R F get a decimal point, 50 becoming 50.). The lessons the codes come from are in Thai.
    • Find code (or Ctrl+K) searches by code or by words, such as tap, dwell or cutter compensation, for the machine chosen; Enter or a click puts the code at the caret. Meanings are for Fanuc controls; a machine’s own codes, such as its M codes, are in its manual.
    • Every tool previews first: it lists the lines that change, old beside new, and redraws the path with the present one faint behind it. Nothing changes until you press Apply. Undo last edit (or Ctrl+Z, for programs under about 200 KB) takes it back.
    • Renumber N numbers the lines that have N, or every line with code. P and Q of G70 to G73, M99 P, M97 P, M98 Q and GOTO are changed to match, within the same program, and Q of M98 P Q within program P.
    • Number tool changes puts N1, N2, … (or the tool number) on each tool change, so the operator can search for it and restart at that tool, and removes the other N numbers except those referred to. On a machining center the N goes on the line with the T: the M06 line, or a T line just above it. A restart skips every line before the N, so each tool is checked for setting G90, a work offset, S, M03/M04 and G43 H itself (on a lathe: S, M03/M04 and G96/G97); those that do not are listed. A T given well before the M06, while the previous tool is still cutting, is flagged too: a restart at that M06 would load whatever tool is waiting.
    • Remove N keeps the numbers other lines refer to.
    • Remove comments takes out comments in brackets, all of them or only those with non-ASCII text such as Thai.
    • Shift moves the program: X Y Z positions in G90 and the R level of drilling cycles on a machining center, Z only on a lathe. G91 moves, G53, coordinate settings (G10 G52 G92, G50 on a lathe), lines with variables and I J K are left alone and named, so check them. New values are written with a decimal point. Moving the work offset at the machine is often simpler and safer.
    • Scale F and S multiplies feeds and speeds by a percentage, for every tool or one, such as 80% for a harder material. Thread leads, tapping feeds (unless F and S change together, which keeps the tap in step) and G50 S are left alone.
    • Convert old program gives a decimal point to every distance written without one, read in the unit you choose (X25000 as 25, 250 or 2.5 mm, or X25 as 25 mm), and names the old forms to convert by hand: G92, G50 X Z on a lathe, G45 to G48, G28 through an absolute point and G29. As options it changes M02 to M30, removes lines that only hold G27, and changes G44 to G43 (the tools must then be measured again, or the H values have their sign flipped). F S T P, G04 dwell times, G10 lines and lines with variables are left alone. Check the path against the drawing before applying.
    • Split by tool makes one program per tool, each with the safety line from the start of the program and M30 at the end, to download one by one or all at once: for a machine with little memory, or to run one tool again.
    • Compare shows the lines that differ from another program (open a file or paste it), or from this program as opened: − lines are only in the other, + lines only in the editor. Its path is drawn faint in the view. N numbers, comments, and spaces with letter case can each be left out of the comparison, to see only the changes that matter to the machine, or counted, to see every change.
    • Setup sheet opens a page to print for the operator: the program, units, work offsets, cutting range, time, a picture of the path, each tool with its offsets, cuts, holes and time, the lines to check, and lines to sign.
    • Download program saves the program as edited, with the opened file's line ending; Send to machine opens it on the DNC page. The page asks before you leave with edits not saved.

    Time, size and safety checks

    • Estimated time: cutting moves at their feed (per minute, or per revolution at the spindle speed, with G96 worked out at each diameter and limited to G50 S), rapids with every axis moving at once at its own rapid rate, so a rapid lasts as long as its slowest axis takes, dwells, and the tool change time for each change. The tool list shows each tool's share. With axis accelerations, each move also speeds up and slows down as a controller's motion planner does: speed changes at the acceleration the moving axes allow (a diagonal cut is held back by its slowest axis, and no cut goes faster than an axis's rapid rate), the speed at a corner between two cutting moves is limited by its angle, speeds are planned along each run of cutting moves so a short move cannot reach full feed, arcs slow down with a small radius, and each rapid starts and ends at rest. Enter 0 to leave acceleration out. Real machines differ with their look-ahead and control parameters, so compare with a timed run and adjust the acceleration to match. G71 to G73 roughing passes and G76 threading passes are counted from the passes the converter works out, an estimate.
    • Rapid rate and acceleration of each axis (X Y Z, or X and Z on a lathe, where X is the slide, on the radius), tool change time, offset table and memory are kept in this browser for each kind of machine.
    • Program size is the file as it would be saved, in KB and in metres of paper tape (0.1 in a character), the unit older controllers give their memory in. Over the memory entered, send it over DNC while machining instead.
    • Safety checks add to the lines to check: a cutting move before the spindle starts, a cutting move with no F, G41 or G42 with no D, and G00 moves into the material: on a machining center, sideways at or below the highest level any tool cuts sideways at; on a lathe, into the material as the cuts made before it leave it: the bar behind the face (the front of the cuts that move in X) and inside the largest diameter, turned down at each Z to the smallest diameter an earlier outside cut reached there, and opened out by the bores of tools that cut inside (drills on the centre line, and tools whose comment says DRILL, BORING or ID, for which moving in means a larger X). Moves made by G71 to G76 are left out. They catch common mistakes, not every collision.
    • Common programming mistakes, from the book's tables and more, are listed too: two G codes of one group on a line; G04 P with a decimal point; nested brackets in a comment; a repeated program number; a drilling cycle not cancelled with G80 before M06, G28 or M30; M06 without retracting Z first; G90 left out after G91 G28; M03 with no S for the tool; M05 on a line that moves; G43 H not matching the tool; G41 G42 G40 on an arc line; a Z-only move under radius compensation; an arc line with no R or I J K (a G01 left out); F values that look like the other feed mode; no G17, no G20 or G21, no work offset, no M30; a subprogram ending with M30 or returning in G91; and on a lathe, G96 without G50 S, G97 without S, G90 alone, and cutting with offset row 00.
    • Offset table: choose memory type A or B if the machine keeps H and D in one register, to be warned when D uses the same number as H. On memory type C (separate H and D columns, as on most current Fanuc controls) the same number is fine.

    Tool list

    • Layer: on a machining center, the T number put into the spindle with M06 sets the layer; moves before the first tool change are on layer T00. On a lathe it is the first two digits of the T word: T0101 is tool 01 (the last two digits are the offset row).
    • Comment in the program is the text in brackets on the tool change line, or on a line holding only a comment just above it, which may be about something else.
    • Cutting moves counts the G01 G02 G03 moves, including each hole's feed in; it is not a distance or a time.
    • Drill size is used only to draw a circle round each hole in the view and the file. If the comment has a size, the converter fills it in first; it may be wrong, so check it.

    What is in the file

    • Layers by tool: each tool has its own set of layers; for tool T01:
      • T01: cutting moves G01 G02 G03
      • T01-RAPID: rapid moves G00, dashed. Turn this layer off to see only the cuts.
      • T01-ROUGH (lathe): the roughing passes of G71 G72 G73 and the threading passes of G76 before the last, an estimate, on a layer of their own.
      • T01-HOLE: holes from canned drilling cycles, as a point at the bottom of each hole, and a circle of the drill size at the R level when a drill size is entered in the tool list
      • T01-EDGE (machining center, whenCut edge is on): the edge the tool cuts, one tool radius from a centre-line (G40) path, from the tool diameters in the tool list
      Moves before the first tool change are on layer T00.
    • Arcs are real arcs (ARC), so CAD can snap to their centres and measure their radii. Arcs with the third axis moving at the same time (helical) are joined 3D lines, because DXF has no helix.
    • Machining center: the file keeps 3D coordinates. AutoCAD, BricsCAD and FreeCAD can turn it to see the depth; LibreCAD and QCAD show the top view only.
    • Lathe: drawn like a turned-part drawing, with Z to the right and the radius up. X in the program is a diameter, so it is drawn at half the X value. Layer CENTERLINE is the work's axis. Choose Lower half to add a mirrored copy on layer T01-MIRROR and see the full shape.
    • Units as in the program: a G21 program gives a file in mm, a G20 program a file in inches, so CAD that reads the setting imports it at the right size. With neither G20 nor G21 the converter takes mm. If the units change part way, the file uses the first ones found, and the line is listed among the lines to check.

    Limits

    • Radius compensation G41 G42: the view and the file show the path as programmed, which follows the part edge, so it lies right on the drawing. If CAM wrote the program as the tool centre path, the line is a tool radius away from the part edge.
    • G00 is drawn as a dog-leg, each axis at the rapid rate entered in the machine data, so the corner is in the right place only when those rates match the machine. The drawn line takes each axis at a constant speed; on a real machine the axes speed up and slow down, so the corner is rounded and sits slightly off the drawn one, most of all on short moves. This is about the drawn shape only: the estimated time still counts acceleration. For a machine set to rapid in a straight line, turn off Dog-leg G00. The DXF always has G00 as a straight line.
    • No material removal or collision checking: the view shows the path only. Use it to check positions and sizes, not whether the tool or the chuck will hit the part.
    • Subprograms must be in the same text: the converter follows M98 into a subprogram when it is in the pasted text or the opened file, so put subprograms after the main program; see the sample O1202 with subprogram O1201. Repeats (L, or a count in front of the program number such as P31201) are all drawn. If the subprogram is not found, or it is an M198 call from external memory, the line is listed among the lines to check.
    • Corners ,R and ,C on a machining center are drawn as rounds and chamfers when they sit between two G01, G02 or G03 cutting moves in the same plane, such as Y50. ,R10. followed by X75.. Two cases are drawn sharp and listed among the lines to check:
      • a corner whose two sides already meet smoothly, or one larger than the cuts beside it, where the control stops with an alarm;
      • R written without the comma, such as Y50. R10., which a Fanuc control does not round either: write ,R10.
    • Lathe chamfers and corner R: both Fanuc functions are drawn. The 90° function: X18. K-1. (I on a Z move, K on an X move, or C), Z-14. R2., per side and signed toward the next block, which must move along the other axis. Direct drawing dimensions: ,C ,R between straight lines at any angle, and ,A, the angle of the line counterclockwise from +Z, for an end point the drawing leaves out, such as X32. ,A150. ,R3.. A machine has only one of them switched on; the converter reads both. A wrong sign, a taper with I K R, or a corner not followed by a G01 is listed with the alarm the control gives, and drawn sharp. See the motion commands chapter.
    • Lathe canned cycles: G90 G92 G94 are drawn with every pass. G71 G72 G73 draw their roughing passes, lighter, worked out the way a Fanuc control makes them: the profile P to Q moved by the finishing allowances U W; G71 cuts along Z and G72 along X, one depth of cut (U or W of the first block) deeper each pass, backs off at 45° by the retract R and returns, then makes one pass along the profile; G73 repeats the profile R times, from the relief U W in to the allowance. The older one-block form with D is read too. When the profile's first block (P) also gives Z for G71, or X for G72 (W0 or U0 will do), the cycle is type II: the profile may dip into up to 10 pockets, each pass follows the profile up instead of backing off at 45°, and the area nearest the start point is taken all the way down before each pocket in turn. A pocket in a type I profile is listed, since a Fanuc control stops with an alarm there. This is an estimate: controls differ in how they retract and finish the last pass, and with no R the retract is taken as 0.5 mm. Untick Roughing passes to hide them. G70 draws the profile from line P to Q, which is the line to check against the drawing. G76 draws every threading pass from its two blocks: the depths QnQ\sqrt{n}, never less than the least depth Q of the first block, down to the height P less the finish allowance R, then the finish passes, the same depths as the thread turning calculator. Each pass starts back toward the start point by (P − depth) × tan(half the tool angle), because the tool feeds in down the flank that faces the start point, as Fig. 4.2.7 of the Fanuc 0i-F lathe manual draws it (angle 00 feeds straight in; for a thread cut toward +Z the rule is mirrored, which the manual does not show); the passes before the last are lighter and hide with the roughing passes. With chamfering in P the end of each pass leaves at 45°. The older one-block G76 (X Z I K D F A P) is drawn too, with a straight pull-out (its chamfering is switched with M23 and M24 and its length is a parameter), and the least depth and finish allowance taken as 0 since they are machine parameters; P3 and P4 cut the depth D every pass. G74 pecks along Z by Q and steps along X by P, G75 pecks along X by P and steps along Z by Q, returning R of the first block between pecks and backing off by R of the second at the bottom; P and Q are radius values, as the Fanuc manual gives them.
    • Cut edge (machining center): a program from CAM is usually written on the tool centre line (G40), so the part edge is one tool radius to the side of the path. Choose the side in the toolbar: right of travel is where the part is with M03 and climb milling, which CAM uses by default; left of travel is conventional milling with M03 (with M04 the two swap); both sides shows the whole width the tool cuts. Enter each tool's diameter in the tool list (a size in mm in the tool's comment is read for you). Each cut moves sideways by the radius, arcs keep their centre, the tool rolls round outside corners, and inside corners between two lines are trimmed. Moves under G41 or G42 are left out because their path is already the part edge; so are moves along Z only, arcs smaller than the tool, and arcs in G18 or G19. The edge goes on each tool's-EDGE DXF layer.
    • Polar coordinates and local zero (machining center): G16 reads the first axis of the plane as the radius and the second as the angle from +X, as the Fanuc 0i-F manual gives it. A radius under G90 is measured from the work zero, or the local zero set by G52; one under G91 from the current position. Under G91 the angle adds to the last one, soG91 Y60. K5 steps round a circle. G16 starts with radius 0 and angle 0 (parameter 10351 bit 5 PCC = 0; the 0i-C compatible setting takes them from the current position instead), so a line with an angle and no radius before any radius is listed to check. G52 moves the zero by its values until the next G52 (G52 X0 Y0 cancels).
    • Macros (Fanuc and Haas Custom Macro B): variables #1 to #33 and#100 up, + - * /, brackets[ ], and SIN COS ATAN SQRT ROUND FIX FUP and the other functions (angles in degrees) are worked out.IF [...] GOTO, IF [...] THEN andWHILE [...] DO1 to END1 are followed. G65 P9010 X.. Y.. passes its values into the macro's #24, #25 and so on, and G66 calls the macro after every move until G67. Put the macro program after the main program. Values kept in the machine, such as tool offsets (#2001), work offsets (#5221), probe results (#5061) and #500 up, are listed underValues held in the machine, one box each, for the values on the machine's screens; a box left empty is taken as 0 and listed to check. The values are kept in this browser and go with the program to the simulation. The modes and positions (#4001 to #4120, #5001, #5041) come from the program. #3000 stops with its alarm message, and a loop that runs more than 100,000 blocks is stopped. During playback the variables each block sets, and the arguments a G65 call passes, are shown under the modes, with every variable set so far; locals inside a macro are named with its program number. What DPRNT sends after POPEN is listed with its line, the numbers in the #100[53] format. G31 (skip) is drawn as a feed move to its end point; the real move stops where the probe touches, which the page cannot know. A G or M code the machine's parameters set to call a macro (Fanuc 6050 to 6059: a G code calls O9010 to O9019; 6080 to 6089: an M code calls O9020 to O9029; 6071 to 6079: an M code calls O9001 to O9009 as M98) is entered underMacro codes, such asG101=O9010; inside the program it calls, that code has its usual meaning, so an M06 macro can give the real M06. M99 P returns to that N in the calling program, and Haas M97 P runs the lines from that N in the same program. Fanuc M98 Q does the same with no P, and M98 P Q starts program P at that N (some controls, such as Series 30i, with parameter 6005#0 SQC set to 1). Every line's macro statements are also checked, whether the program reaches them or not: WHILE DO and END that do not pair or that cross, loop numbers outside 1 to 3 or nested more than three deep, a GOTO to an N the program does not have, brackets that do not pair, words that are not functions, and writing to a read-only variable such as #5001.
    • Rotation, mirror image and scaling(machining center): G68 X Y R turns the path about the centre by R degrees, counterclockwise seen from +Z in G17; G51.1 X0 mirrors it across the line X0, so arcs run the other way and G41 becomes G42;G51 X Y P scales X and Y about the centre (P2., or P2000 without a decimal point), or each axis by I J K. Used together they nest in the Fanuc order G51, G51.1, G68, and G91 moves and subprograms follow them, as on the control. Cancel with G69, G50.1 and G50. Whether Z is scaled depends on a machine parameter, so it is not scaled here and the line is listed; so are G68 or G51.1 under G41 G42, a G68 with no centre, and a first move after G68 with one axis or in G91.
    • Rotary axes: moves are drawn on the part. The A axis is taken as running along X through Y0 Z0 of the work zero, with no roll-over, and +A carries the tool round the part by the right-hand rule about +X; check the real direction in the machine's manual. F under G93 is read as one over the block's time in minutes. G68.2 with G53.1 draws the program on the tilted plane. G43.4 and G43.5 draw only the tool tip's path on the part, not how the tool tilts or how the machine's axes move, which take a full machine simulation to check. Elsewhere B and C are not followed: a line that moves them away from 0 is listed among the lines to check.
    • Values without a decimal point: a Fanuc controller reads X10 as 0.010 mm unless a parameter is set. Choose what your machine does.