The Smell of Molten Projects in the Morning

Ed Nisley's Blog: Shop notes, electronics, firmware, machinery, 3D printing, laser cuttery, and curiosities. Contents: 100% human thinking, 0% AI slop.

Tag: CNC

Making parts with mathematics

  • Makergear M2: Post and Hole Calibration Test Objects

    Despite the profusion of surface-finish and print quality test objects, I really care about the dimensions of a 3D printed object, because I tend to build widgets rather than art objects. These two objects, from walter’s Hole and Column Test Print, produce calibrated holes and columns from 0.20 mm to 10.00 mm in diameter, incrementing by 0.20 mm, that should slip neatly together:

    M2 - walter hole-column test
    M2 – walter hole-column test

    Of course, they didn’t, but they came surprisingly close for a first attempt.

    The 0.20 and 0.40 posts simply aren’t there, because they’re too small to print with a 0.35 mm diameter nozzle. The 0.60 through 1.40 mm posts were present, albeit fugly, and posts larger than that looked increasingly better.

    Although all the holes were present, in the sense that you could see a disturbance in the top and bottom infill pattern, the first visibly open hole appeared at the 0.80 mm spot… and it was immeasurably small. Some holes had misplaced perimeter strands stretching across the openings, which is probably due to excessive speed from my fiddling around with the numbers.

    Measuring them with a digital caliper, with no effort at finding the best orientation, then slapping the data into a Libreoffice spreadsheet, produces an interesting graph:

    M2 - Initial Hole and Post Diameter Calibration
    M2 – Initial Hole and Post Diameter Calibration

    Above about 3 mm diameter: posts are 0.1 mm too small and holes are 0.3 mm too small. Around 2 mm, posts are too big and holes are way too small. What’s important: above maybe 2.5 mm, the error is essentially constant and does not scale with diameter, so a simple Finagle Constant (or two) can solve (most of) the problem.

    Some experiments involving slic3r’s small-perimeter speed seem in order; it was 25 mm/s for these pieces.

    More care in measurement would produce better answers, but the real question is whether you can produce holes and columns with known sizes; the answer (as expected) remains “with some care”. That’s not surprising; I expect to have an M2 + PLA version of the small hole diameter Finagle Constant that I’ve been using with Skeinforge + Thing-O-Matic; the correction will certainly fall in the same ballpark.

    The slic3r configuration:

    ; generated by Slic3r 0.9.8 on 2013-04-01 at 16:20:49
    
    ; layer_height = 0.25
    ; perimeters = 1
    ; top_solid_layers = 3
    ; bottom_solid_layers = 3
    ; fill_density = 0.10
    ; perimeter_speed = 100
    ; infill_speed = 300
    ; travel_speed = 500
    ; scale = 1
    ; nozzle_diameter = 0.35
    ; filament_diameter = 1.70
    ; extrusion_multiplier = 0.9
    ; perimeters extrusion width = 0.40mm
    ; infill extrusion width = 0.40mm
    ; first layer extrusion width = 0.39mm
    

    The source code comes from the Thingiverse customizer as bare G-Code, so there’s not much point in reproducing it here.

  • Makergear M2: Fundamental Test Object

    Building these things seems to be the simplest and best way to figure out whether you have all the pieces flying in formation:

    Thinwall box - first success
    Thinwall box – first success

    I took that picture after cracking them off the glass plate, then putting them back: the box really does line up with the skirt while printing. There’s another object visible in the background; that little box really was the first completely successful object.

    It’s adapted from Coasterman’s classic calibration set, redone in OpenSCAD so it’s easy to modify. A pair of Minkowski sums produce two shapes that ensure the wall remains exactly one thread wide all the way around the perimeter.

    [Update: The revised version works better.]

    When your printer can print one of these, then you can move on to more complex objects, secure in the knowledge that you’ve established:

    • Proper bed leveling and height setting: measure the skirt thickness
    • Both the layer thickness and width match your settings
    • Extrusion temperature: not too hot, not too cold
    • Printing speed / acceleration for all layers
    • First layer adhesion to platform
    • Minimum layer time to prevent melting / slumping
    • Filament diameter
    • Extrusion “packing density” multiplier: the fundamental fudge factor
    • Accurate steps/mm for all axes to get exact XYZ dimensions
    • Mechanical stability and rigidity

    Basically, this object leaves no place for errors to hide. It doesn’t check infill, the various perimeter speeds, solid layers, and suchlike, but all the fundamentals must be correct or you’ll see painfully obvious flaws.

    For example, there’s a bit of a zipper at the layer changes. It’s better than the Thing-O-Matic ever was, but it improved as I twiddled the Retraction settings on later objects.

    No, the first few didn’t work quite that well:

    M2 - Thinwall box with previous attempts
    M2 – Thinwall box with previous attempts

    For what it’s worth, the last problem turned out to be a loose setscrew in the X axis motor pulley that produced a layer shift that closely resembled a stepper motor losing steps. All of the setscrews now sport a dab of low-strength Loctite, so that problem shouldn’t happen again.

    Yes, I did the happy dance…

    The slic3r header:

    ; generated by Slic3r 0.9.8 on 2013-03-26 at 11:01:10
    
    ; layer_height = 0.25
    ; perimeters = 1
    ; top_solid_layers = 3
    ; bottom_solid_layers = 3
    ; fill_density = 0.20
    ; perimeter_speed = 100
    ; infill_speed = 150
    ; travel_speed = 500
    ; scale = 1
    ; nozzle_diameter = 0.35
    ; filament_diameter = 1.70
    ; extrusion_multiplier = 0.9
    ; perimeters extrusion width = 0.40mm
    ; infill extrusion width = 0.40mm
    ; first layer extrusion width = 0.39mm
    

    The solid model has no surprises:

    Thinwall Open Box - solid model
    Thinwall Open Box – solid model

    The OpenSCAD source code:

    // Thin wall open box calibration piece
    // Adapted from Coasterman's Calibration set
    // Ed Nisley - KE4ZNU - Dec 2011
    // Adjust for Slic3r/M2 - March 2013
    
    //-------
    //- Extrusion parameters must match reality!
    //  None of the fill parameters matter
    
    ThreadThick = 0.25;
    ThreadWidth = 0.40;
    
    Protrusion = 0.1;           // make holes end cleanly
    
    function IntegerMultiple(Size,Unit) = Unit * ceil(Size / Unit);
    
    //-------
    // Dimensions
    
    Height = IntegerMultiple(5.0,ThreadThick);
    
    WallThick = ThreadWidth;
    
    CornerRadius = 2.0;
    CornerSides = 4*8;
    
    SideLen = 20.0 - 2*CornerRadius;
    
    Rotation = 45;
    
    //-------
    
    module ShowPegGrid(Space = 10.0,Size = 1.0) {
    
    Range = floor(50 / Space);
    
    for (x=[-Range:Range])
    for (y=[-Range:Range])
    translate([x*Space,y*Space,Size/2])
    %cube(Size,center=true);
    }
    
    //-------
    
    ShowPegGrid();
    
    rotate(Rotation)
    translate([0,0,Height/2])
    intersection() {
    difference() {
    minkowski() {
    cube([SideLen,SideLen,Height],center=true);
    cylinder(r=CornerRadius,h=Protrusion,$fn=CornerSides);
    }
    minkowski() {
    cube([(SideLen - 2*WallThick),(SideLen - 2*WallThick),2*Height],center=true);
    cylinder(r=CornerRadius,h=Protrusion,$fn=CornerSides);
    }
    }
    cube([2*SideLen,2*SideLen,Height],center=true);
    }
    

    [Update: You should use the code from the revised version.]

  • Makergear M2: Z Axis Numbers

    Now that I understand why the M2 Z axis stepper gets so hot, the question is: does it matter?

    The Z axis stage moves very smoothly along the two guide rails, so there’s little friction and no binding involved. I can’t weigh the thing without dismantling the whole printer, which isn’t going to happen right now, but some crude experiments indicate that 7 pounds = 3 kgf = 30 N isn’t too far from the truth.

    The 8 mm OD leadscrew has a 4-start thread at 3.25 turn/inch = 0.311 inch/turn = 0.13 turn/mm = 7.8 mm/turn.

    [Update: Thanks to Jetguy for pointing out the blindingly obvious fact that it’s really 8 mm/turn = 0.125 turn/mm and you can do the inch conversion yourself if you need it. That doesn’t materially affect the results, given that they have about one significant figure of accuracy to start with.]

    The firmware uses 1/16 microstepping at 400 step/mm = 3077 3200 step/turn.

    Using a pull scale to, yes, pull a string wound around the knob on the Z axis leadscrew shows about 1 pound raises the platform at a slow, constant speed. The polygonal knob is about 35 mm in diameter, so the torque works out to 11 ounce·inch = 80 mN·m. Presumably, holding the platform at a given position would require somewhat less torque, but I can’t measure that with any confidence.

    The motor has very little excess torque: a gentle touch can stall the Z axis motor as it raises the stage. I guesstimate the motor produces 150 mN·m, tops, during low-speed motion at 600 mA.

    Lowering the stage requires no effort at all: it falls under its own weight, prompting me to install those bumpers. The design doesn’t have much compliance, but it’s well-adjusted and works fine.

    Searching with the appropriate keywords produces a 17HD-B8X300-H motor from Kysan:

    • 12 V
    • 400 mA
    • 30 Ω
    • 42 mH
    • 2.6 kg·cm = 260 mN·m

    That’s a close-enough match to suggest my measurements are in the right ballpark. The extremely high resistance and inductance indicate this is the wrong motor for a high-performance microstepping application.

    The firmware has DEFAULT_MAX_ACCELERATION = 30 mm/s2 for the Z axis. It’s 9000 for X and Y, 10000 for the extruder. The extremely low Z acceleration says there’s something badly wrong with this setup.

    There is also a DEFAULT_ACCELERATION = 3000 for all axes. I don’t know how that interacts with the per-axis limit, but I’m certain the Z axis doesn’t come close to that value.

    I do not know how the firmware actually handles motor steps while ramping up and down, but I do intend to clamp a current probe around a motor wire and measure what goes on. Let us assume it works in the usual way all ideal components behave in physics labs.

    Assuming a constant 30 mm/s2 acceleration for the first half of a 0.25 mm Z axis move, the time should be:

    0.25 / 2 = (1/2) * 30 * t2
    t = 90 ms

    At the end of that ramp-up, the Z stage will be trundling along at:

    v2 = 2 * 30 * 0.25/2
    v = 2.8 mm/s

    The move requires exactly 50 steps = 0.25/2 mm * 400 step/mm.

    Assuming the same deceleration during the second half of the move, a 0.25 mm layer change requires about twice that long: 180 ms for 100 steps.

    Along the X axis, a 0.25/2 mm move requires 5.3 ms and reaches a peak speed of 47 mm/s. The total move requires 11 ms and 22.22 steps (= 0.25 mm * 88.88 step/mm, obviously rounded to 22).

    I think a difference of more than an order of magnitude matters, although some actual measurements are definitely appropriate.

  • Makergear M2: Z-axis Stepper Motor

    Several users have observed that the stepper motor driving the M2’s Z axis leadscrew gets very hot. I measured about 140 °F = 60 °C on the as-built motor, so I loosened the screws and raised the motor slightly:

    M2 Z axis motor - raised
    M2 Z axis motor – raised

    I eased some heatsink compound underneath by putting dabs on a slip of paper and painting it on the bottom of the motor case, lowered the Z stage to the bottom of its travel, and tightened the mounting screws:

    M2 Z axis motor - added thermal compound
    M2 Z axis motor – added thermal compound

    That reduced the temperature to about 120 °F = 50 °C, which still seemed excessive for a short-stack motor mounted on a fairly large chunk of stainless steel. The motor also sounded quite rough during homing and long manual moves, sooo … something was wrong. I bet you know where this is going, right?

    Let’s start with the firmware side and determine what current the motor should be seeing.

    The M2 uses a slightly modified version of the Marlin firmware running on a RAMBo 1.1b board. The basic RAMBo doc gives these equations relating the peak winding current Imax to the constant W that defines it in the firmware:

    Vref = 0.8 * Imax
    W = 255 * (Vref / 1.66)

    Mashing those together produces this:

    W = 255 * (0.8 * Imax) / 1.66

    The default Z axis stepper current constant W (called Z_CURRENT in the Marlin source) is 135. The board in my M2 has R30 = 3.3 kΩ, which sets the maximum possible current to 2 A. Working the equation backwards, a Z_CURRENT = 135 will produce a peak winding current of 1.1 A.

    However, a nearby comment in the source code suggests this is should be about 0.75 A. The original RAMBo board had a maximum possible current of 1.5 A, but running those numbers doesn’t agree. Another comment suggests 185 corresponds to about 1 A, which isn’t right, either. There’s nothing new about stale comments not corresponding to the actual hardware; I’ve done that myself.

    With 1.1 A in hand, let’s unplug the cable and measure the winding resistance.

    Not much to my surprise, the motor has 28 Ω windings. The M2 uses a 19 V supply for the steppers, so the maximum motor current works out to 19 V/28 Ω  = 680 mA, but it must be less than that to allow the microstepping controller to manage the current.

    It seems that Makergear is connecting a high-resistance stepper intended for a simple H-bridge drive to a high-performance microstepping controller. For some background on why that combination doesn’t work, see my analysis of the original MBI Thing-O-Matic steppers.

    I thought we all agreed we weren’t going to do that any more. Maybe nobody sells a low-resistance motor-with-integral-leadscrew?

    Anyhow.

    The only thing to do in the short term is to reduce the peak current to a rational value around 600 mA:

    74 = 255 * (0.8 * 0.6) / 166

    I set it to a nice, round 75 and reloaded the firmware, which immediately made the motor hum, rather than growl, on long moves. The case temperature didn’t drop by very much, because the poor motor still dissipates about 11 W, not much less than the original 13 W. There’s only so much heat you can pull out of the case and these little motors are actually rated for maybe 5 W, tops.

    The motor’s overall performance didn’t change, which is good, because it didn’t have much performance to begin with. The X and Y motors can accelerate at 9000 mm/s2, but the Z motor limit is 30 mm/s2; it doesn’t really accelerate, it sort of gains momentum in a stately manner.

    Next: let’s see if it really matters.

  • Makergear M2 vs. LinuxCNC: Project Overview

    M2 - cushwa Owl - half scale
    M2 – cushwa Owl – half scale

    During the course of my Makerbot Thing-O-Matic experience, I concluded:

    • Enthusiasm may get a product out, but engineering makes it work
    • Plywood and plastic do not produce a stable 3D printer
    • Measurements matter
    • 8-bit microcontrollers belong in the dustbin of history

    With that in mind, I’ve long thought that LinuxCNC (formerly EMC2) would provide a much better basis for the control software required for a 3D printer than the current crop of Arduino-based microcontrollers. LinuxCNC provides:

    • Hard real time motion control with proven performance
    • A robust, well-defined hardware interface layer
    • Ladder-logic machine control
    • Isolated userspace programming
    • Access to a complete Linux distro’s wealth of programs / utilities
    • Access to an x86 PC’s wealth of hardware gadgetry

    Rather than (try to) force-fit new functions in an Arduino microcontroller, I decided it would be interesting to retrofit a DIY 3D printer with a LinuxCNC controller, improve the basic hardware control and sensing, instrument the extruder, then take measurements that might shed some light on DIY 3D printing’s current shortcomings.

    The overall plan looks like this:

    • Start with a Makergear M2
    • See what the stock hardware can do
    • Replace the RAMBo controller with LinuxCNC
    • See what the hardware can do with better drivers
    • Adapt the G-Code / M-Code processing to use more-or-less stock Marlin G-Code
    • Add useful controllers along the lines of the Joggy Thing
    • Improve the platform height / level sensing
    • Rebuild the extruder with temperature and force sensors
    • Start taking measurements!

    My reasons for choosing the Makergear M2 as the basis for this project should be obvious:

    • All metal: no plywood, no acrylic (albeit a plastic filament drive)
    • Decent stepper motors (with one notable exception)
    • Reasonable hot end design
    • Good reputation

    The first step of the overall plan included a meticulously documented M2 build that I figured would take a month or two, what with the usual snafus and gotchas that accompany building any complex mechanism. Quite by coincidence, a huge box arrived on my birthday (the Thing-O-Matic arrived on Christmas Eve, so perhaps this is a tradition), the day when I learned that Mad Phil had entered his final weeks of life.

    As the Yiddish proverb puts it: If you wish to hear G*d laugh, tell him of your plans.

    So I converted a box of parts into a functional M2 3D printer over the course of four intense days, alternating between our living room floor and a card table in Phil’s home office, showing him how things worked, getting his advice & suggestions, and swapping “Do you remember when?” stories. Another few days sufficed for software installation, configuration, and basic tuneup; I managed to show him some shiny plastic doodads just before he departed consensus reality; as nearly as I can tell, we both benefited from the distractions.

    Which means I don’t have many pictures or much documentation of the in-process tweakage that produced a functional printer. The next week or so of posts should cover the key points in enough detail to be useful.

    Not to spoil the plot or anything: a stock M2 works wonderfully well.

    Owl - half size - left
    Owl – half size – left

    For example, a half-scale cushwa owl printed in PLA at 165 °C with no bed cooling and these Slic3r parameters:

    • 500 mm/s move
    • 300 mm/s infill
    • 200 mm/s solid infill
    • 100 mm/s internal perimeter
    • 50 mm/s bottom layer
    • 30 mm/s external perimeter
    • 1 mm retract @ 300 mm/s

    The beak came out slightly droopy and each downward-pointing feather dangles a glittery drop. There’s room for improvement, but that’s pretty good a week after opening a box o’ parts…

  • Broom Handle Screw Thread: Replacement Plug

    Somehow, we wound up with a broom handle and a broom head, the former missing a threaded stub that was firmly lodged in the latter. A few minutes of Quality Shop Time sawed off the end of the handle and unscrewed the stub to produce this array of fragments:

    Broken broom handle thread
    Broken broom handle thread

    It’s a cylindrical Thing tailor-made for (or, back in the day, by!) a lathe. My lathe has quick-change gears that can actually cut a 5 TPI thread, but that seems like a lot of work for such a crude fitting. Instead, an hour or so of desk work produced this:

    Broom Handle Screw - solid model - overview
    Broom Handle Screw – solid model – overview

    Some after-the-fact search-fu revealed that the thread found on brooms and paint rollers is a 3/4-5 Acme. Machinery’s Handbook has 13 pages of data for various Acme screw threads, making a distinction between General Purpose Acme threads and Stub Acme Threads: GP thread depth = 0.5 × pitch, Stub = 0.3 × pitch. For a 5 TPI thread = 0.2 inch pitch, that’s GP = 0.1 inch vs. Stub = 0.06 inch.

    I measured a 5.0 mm pitch (which should be 5.08 mm = 0.2 inch exactly) and a crest-to-root depth of 1.4 mm = 0.055 inch, which makes them look like 3/4-5 Stub Acme threads. But, I didn’t know that at the time; a simple half-cylinder 2.5 mm wide and 1.25 mm tall was a pretty close match to what I saw on the broken plastic part.

    Although OpenSCAD’s MCAD library has some screw forms, they’re either machine screws with V threads or ball screws with spheres. The former obviously weren’t appropriate and the latter produced far too many facets, so I conjured up a simpler shape: 32 slightly overlapping cylinders per turn, sunk halfway in the shaft at their midpoint, and tilted at the thread’s helix angle.

    Broom Handle Screw - thread model closeup
    Broom Handle Screw – thread model closeup

    The OpenSCAD source code has a commented-out section that removes a similar shape from the shaft between the raised thread, but that brought the rendering to its knees. Fortunately, it turned out to be unnecessary, but it’s there if you want it.

    With the shaft diameter set to the “root diameter” of the thread and the other dimensions roughly matching the broken plastic bits, this emerged an hour later:

    Broom handle screw plug - as built
    Broom handle screw plug – as built

    The skirt thread was 0.25 to 0.30 mm thick, so the first-layer height tweak and packing density adjustments worked fine and all the dimensions came out perfectly. The cylindrical thread form doesn’t have much overhang and the threads came out fine; I think the correct straight-sided form would have more problems.

    The hole down the middle accommodates a 1/4-20 bolt that applies enough clamping force to keep the shaft in compression, which ought to prevent it from breaking in normal use. I intended to use a hex bolt, but found a carriage bolt that was exactly the right length and had a head exactly the same diameter as the shaft, so I heated it with a propane torch and mushed its square shank into the top of the hexagonal bolt hole (the source code now includes a square recess):

    Broom handle screw plug - in handle
    Broom handle screw plug – in handle

    The dimples on the side duplicate the method that secured the original plastic piece: four dents punched into the metal handle lock the plastic in place. It seems to work reasonably well, though, and is certainly less conspicuous than the screws I’d use.

    Screwing it in place shows that it’s slightly too long (I trimmed the length in the source code):

    Broom handle installed
    Broom handle installed

    It’s back in service, ready for use…

    The OpenSCAD source code:

    // Broom Handle Screw End Plug
    // Ed Nisley KE4ZNU March 2013
    
    // Extrusion parameters must match reality!
    //  Print with +1 shells and 3 solid layers
    
    ThreadThick = 0.25;
    ThreadWidth = 2.0 * ThreadThick;
    
    HoleWindage = 0.2;
    
    function IntegerMultiple(Size,Unit) = Unit * ceil(Size / Unit);
    
    Protrusion = 0.1;			// make holes end cleanly
    
    //----------------------
    // Dimensions
    
    PI = 3.14159265358979;
    
    PostOD = 22.3;              // post inside metal handle
    PostLength = 25.0;
    
    FlangeOD = 24.0;            // stop flange
    FlangeLength = 3.0;
    
    PitchDia = 15.5;            // thread center diameter
    ScrewLength = 20.0;
    
    ThreadFormOD = 2.5;         // diameter of thread form
    ThreadPitch = 5.0;
    
    BoltOD = 7.0;               // clears 1/4-20 bolt
    BoltSquare = 6.5;          	// across flats
    BoltHeadThick = 3.0;
    
    RecessDia = 6.0;			// recesss to secure post in handle
    
    OALength = PostLength + FlangeLength + ScrewLength; // excludes bolt head extension
    
    $fn=8*4;
    
    echo("Pitch dia: ",PitchDia);
    echo("Root dia: ",PitchDia - ThreadFormOD);
    echo("Crest dia: ",PitchDia + ThreadFormOD);
    
    //----------------------
    // Useful routines
    
    module Cyl_Thread(pitch,length,pitchdia,cyl_radius,resolution=32) {
    
    Cyl_Adjust = 1.25;                      // force overlap
    
        Turns = length/pitch;
        Slices = Turns*resolution;
        RotIncr = 1/resolution;
        PitchRad = pitchdia/2;
        ZIncr = length/Slices;
        helixangle = atan(pitch/(PI*pitchdia));
        cyl_len = Cyl_Adjust*(PI*pitchdia)/resolution;
    
        union() {
            for (i = [0:Slices-1]) {
                translate([PitchRad*cos(360*i/resolution),PitchRad*sin(360*i/resolution),i*ZIncr])
                    rotate([90+helixangle,0,360*i/resolution])
                        cylinder(r=cyl_radius,h=cyl_len,center=true,$fn=12);
            }
        }
    }
    
    module PolyCyl(Dia,Height,ForceSides=0) {			// based on nophead's polyholes
    
      Sides = (ForceSides != 0) ? ForceSides : (ceil(Dia) + 2);
    
      FixDia = Dia / cos(180/Sides);
    
      cylinder(r=(FixDia + HoleWindage)/2,
               h=Height,
    	   $fn=Sides);
    }
    
    module ShowPegGrid(Space = 10.0,Size = 1.0) {
    
      Range = floor(50 / Space);
    
    	for (x=[-Range:Range])
    	  for (y=[-Range:Range])
    		translate([x*Space,y*Space,Size/2])
    		  %cube(Size,center=true);
    
    }
    
    //-------------------
    // Build it...
    
    ShowPegGrid();
    
    difference() {
        union() {
            cylinder(r=PostOD/2,h=PostLength);
            cylinder(r=PitchDia/2,h=OALength);
            translate([0,0,PostLength])
                cylinder(r=FlangeOD/2,h=FlangeLength);
            translate([0,0,(PostLength + FlangeLength)])
                Cyl_Thread(ThreadPitch,(ScrewLength - ThreadFormOD/2),PitchDia,ThreadFormOD/2);
        }
    
        translate([0,0,-Protrusion])
            PolyCyl(BoltOD,(OALength + 2*Protrusion),6);
        translate([0,0,(OALength - BoltHeadThick)])
            PolyCyl(BoltSquare,(BoltHeadThick + Protrusion),4);
    
    //    translate([0,0,(PostLength + FlangeLength + ThreadFormOD)])
    //        Cyl_Thread(ThreadPitch,(ScrewLength - ThreadFormOD/2),PitchDia,ThreadFormOD/2);
    
    	for (i = [0:90:270]) {
    		rotate(i)
    			translate([PostOD/2,0,PostLength/2])
    				sphere(r=RecessDia/2,$fn=8);
    	}
    }
    
  • G-Code and M-Code Grand Master List

    Here’s a combined and sorted list of all the G-Code and M-Code commands for (as many of) the Free Software G-Code interpreters (that I could find) relevant to DIY 3D printing. With any luck, I now know:

    • What a given command does
    • What other interpreters do with that command

    The short descriptions come from tables on the original source pages, perhaps with a bit of massaging to make things more uniform; I did as little rearranging and editing as possible.

    If you see anything wrong or have another G-Code interpreter I should include, let me know…

    3D Printer G-Code and M-Code Commands
    
    27 Feb 2013
    Ed Nisley - KE4ZNU
    
    V3 - NIST RS274NGC V3- http://www.nist.gov/manuscript-publication-search.cfm?pub_id=823374
    LC - LinuxCNC - http://www.linuxcnc.org/docs/
    RG - ReplicatorG - http://replicat.org/gcodes and /mcodes
    JF - Jetty Firmware - http://replicat.org/mcodes at bottom
    RR - RepRap - http://reprap.org/wiki/G_codes (cross-linked from many G-Code pages)
    MF - Marlin Firmware dialect of RR (via Dan Newman)
    
    G0  LC  Coordinated Straight Motion Rapid
    G0  MF  same as G1
    G0  RG  Rapid Motion
    G0  RR  Rapid move
    G0  V3  rapid positioning
    G1  LC  Coordinated Straight Motion Feed Rate
    G1  MF  Coordinated Movement X Y Z E
    G1  RG  Coordinated Motion
    G1  RR  Controlled move
    G1  V3  linear interpolation
    G2  LC  Coordinated Helical Motion Feed Rate
    G2  MF  CW ARC
    G2  RG  Arc - Clockwise
    G2  V3  circular/helical interpolation (clockwise)
    G3  LC  Coordinated Helical Motion Feed Rate
    G3  MF  CCW ARC
    G3  RG  Arc - Counter Clockwise
    G3  V3  circular/helical interpolation (counterclockwise)
    G4  LC  Dwell
    G4  MF  Dwell S<seconds> or P<milliseconds>
    G4  RG  Dwell
    G4  RR  Dwell
    G4  V3  dwell
    G5.1    LC  Quadratic B-Spline
    G5.2    LC  NURBs Block Open
    G5.3    LC  NURBs Block Close
    G7  LC  Diameter Mode (lathe)
    G8  LC  Radius Mode (lathe)
    G10 LC  L10 Set Tool Table, Calculated, Workpiece
    G10 LC  L11 Set Tool Table, Calculated, Fixture
    G10 LC  L1  Set Tool Table Entry
    G10 LC  L20 Coordinate System Origin Setting Calculated
    G10 LC  L2  Coordinate System Origin Setting
    G10 RG  Create Coordinate System Offset from the Absolute one
    G10 RR  Head Offset
    G10 V3  coordinate system origin setting
    G17 LC  Arc plane XY
    G17 RG  Select XY plane (default)
    G17 V3  XY-plane selection
    G17.1   LC  Arc plane UV
    G18 LC  Arc plane ZX
    G18 RG  Select XZ plane (not implemented)
    G18 V3  XZ-plane selection
    G18.1   LC  Arc plane WU
    G19 LC  Arc plane YZ
    G19 RG  Select YX plane (not implemented)
    G19 V3  YZ-plane selection
    G19.1   LC  Arc plane VW
    G20 LC  Unit of Measure - inch
    G20 RG  Inches as units
    G20 RR  Set Units to Inches
    G20 V3  inch system selection
    G21 LC  Unit of Measure - millimeter
    G21 RG  Millimeters as units
    G21 RR  Set Units to Millimeters
    G21 V3  millimeter system selection
    G28 LC  Go to Predefined Position
    G28 MF  Home all Axis
    G28 RG  Home given Axes to maximum
    G28 RR  Move to Origin
    G28 V3  return to home
    G28.1   LC  Store Predefined Position
    G29-G32 RR  Bed probing
    G30 LC  Go to Predefined Position
    G30 RG  Go Home via Intermediate Point (not implemented)
    G30 V3  return to secondary home
    G30.1   LC  Store Predefined Position
    G31 RG  Single probe (not implemented)
    G32 RG  Probe area (not implemented)
    G33 LC  Spindle Synchronized Motion
    G33.1   LC  Rigid Tapping
    G38.2   LC  Probe toward, stop on contact, error
    G38.2   V3  straight probe
    G38.3   LC  Probe toward, stop on contact
    G38.4   LC  Probe away, stop on release, error
    G38.5   LC  Probe away, stop on release
    G40 LC  Cancel Cutter Compensation
    G40 V3  cancel cutter radius compensation
    G41 LC  Cutter Compensation - left
    G41 V3  start cutter radius compensation left
    G41.1   LC  Dynamic Cutter Compensation - left
    G42 LC  Cutter Compensation - right
    G42 V3  start cutter radius compensation right
    G42.1   LC  Dynamic Cutter Compensation - right
    G43 LC  Use Tool Length Offset from Tool Table
    G43 V3  tool length offset (plus)
    G43.1   LC  Dynamic Tool Length Offset
    G49 LC  Cancel Tool Length Offset
    G49 V3  cancel tool length offset
    G53 LC  Motion in Machine Coordinate System
    G53 RG  Set absolute coordinate system
    G53 V3  motion in machine coordinate system
    G54-G59 RG  Use coordinate system from G10 P0-5
    G54 LC  Select Coordinate System 1
    G54 V3  use preset work coordinate system 1
    G55 LC  Select Coordinate System 2
    G55 V3  use preset work coordinate system 2
    G56 LC  Select Coordinate System 3
    G56 V3  use preset work coordinate system 3
    G57 LC  Select Coordinate System 4
    G57 V3  use preset work coordinate system 4
    G58 LC  Select Coordinate System 5
    G58 V3  use preset work coordinate system 5
    G59 LC  Select Coordinate System 6
    G59 V3  use preset work coordinate system 6
    G59.1   LC  Select Coordinate System 7
    G59.1   V3  use preset work coordinate system 7
    G59.2   LC  Select Coordinate System 8
    G59.2   V3  use preset work coordinate system 8
    G59.3   LC  Select Coordinate System 9
    G59.3   V3  use preset work coordinate system 9
    G61 LC  Path Control Mode - exact path
    G61 V3  set path control mode: exact path
    G61.1   LC  Path Control Mode - exact stop (same as G61)
    G61.1   V3  set path control mode: exact stop
    G64 LC  Path Control Mode - Optional Tolerance
    G64 V3  set path control mode: continuous
    G73 LC  Drilling Cycle with Chip Breaking
    G76 LC  Multi-pass Threading Cycle (Lathe)
    G80 LC  Cancel Motion Modes
    G80 V3  cancel motion mode (including any canned cycle)
    G81 LC  Drilling Cycle
    G81 V3  canned cycle: drilling
    G82 LC  Drilling Cycle with Dwell
    G82 V3  canned cycle: drilling with dwell
    G83 LC  Drilling Cycle with Peck
    G83 V3  canned cycle: peck drilling
    G84 V3  canned cycle: right hand tapping
    G85 LC  Boring Cycle, No Dwell, Feed Out
    G85 V3  canned cycle: boring, no dwell, feed out
    G86 LC  Boring Cycle, Stop, Rapid Out
    G86 V3  canned cycle: boring, spindle stop, rapid out
    G87 V3  canned cycle: back boring
    G88 V3  canned cycle: boring, spindle stop, manual out
    G89 LC  Boring Cycle, Dwell, Feed Out
    G89 V3  canned cycle: boring, dwell, feed out
    G90 LC  G91 Distance Mode
    G90 MF  Use Absolute Coordinates
    G90 RG  Absolute Positioning
    G90 RR  Set to Absolute Positioning
    G90 V3  absolute distance mode
    G90.1   LC  Arc Distance Mode - absolute IJK
    G91 MF  Use Relative Coordinates
    G91 RG  Relative Positioning
    G91 RR  Set to Relative Positioning
    G91 V3  incremental distance mode
    G91.1   LC  Arc Distance Mode - incremental IJK
    G92.1   V3  cancel offset coordinate systems and set parameters to zero
    G92 LC  Coordinate System Offset
    G92 MF  Set current position to cordinates given
    G92 RG  Define current position on axes
    G92 RR  Set Position
    G92 V3  offset coordinate systems and set parameters
    G92.1   LC  Cancel Coordinate System Offsets
    G92.2   LC  Cancel Coordinate System Offsets
    G92.2   V3  cancel offset coordinate systems but do not reset parameters
    G92.3   LC  Restore Axis Offsets
    G92.3   V3  apply parameters to offset coordinate systems
    G93 LC  Feed Mode - Inverse time
    G93 V3  inverse time feed rate mode
    G94 LC  Feed Mode - Units per minute
    G94 RG  Feed rate mode (not implemented)
    G94 V3  units per minute feed rate mode
    G95 LC  Feed Mode - Units per revolution
    G96 LC  Constant Surface Speed
    G97 LC  RPM Mode
    G97 RG  Spindle speed rate
    G98 LC  Canned Cycle Z Retract Mode
    G98 V3  initial level return in canned cycles
    G99 LC  Canned Cycle Z Retract Mode
    G99 V3  R-point level return in canned cycles
    G161    RG  Home negative
    G162    RG  Home positive
    
    M0  LC  Program Pause
    M0  RG  Unconditional Halt (not supported on SD)
    M0  RR  Stop
    M0  V3  program stop
    M1  LC  Program Pause - optional
    M1  RG  Optional Halt (not supported on SD)
    M1  RR  Sleep
    M1  V3  optional program stop
    M2  LC  Program End
    M2  RG  End program
    M2  V3  program end
    M3  LC  Spindle Control - clockwise ON
    M3  RG  spindle on, CW
    M3  RR  Spindle On, Clockwise (CNC specific)
    M3  V3  turn spindle clockwise
    M4  LC  Spindle Control - counterclockwise ON
    M4  RG  spindle on, CCW
    M4  RR  Spindle On, Counter-Clockwise (CNC specific)
    M4  V3  turn spindle counterclockwise
    M5  LC  Spindle Control - OFF
    M5  RG  spindle off
    M5  RR  Spindle Off (CNC specific)
    M5  V3  stop spindle turning
    M6  LC  Tool Change
    M6  RG  Tool change. This code waits until the toolhead is ready before proceeding. This is often used to wait for a toolhead to reach the its set temperature before beginning a print. ReplicatorG also supports giving a timeout with M6 P<secs>.
    M6  V3  tool change
    M7  LC  Coolant Control - mist ON
    M7  RG  coolant A on (flood coolant)
    M7  RR  Mist Coolant On (CNC specific)
    M7  V3  mist coolant on
    M8  LC  Coolant Control - flood ON
    M8  RG  cooland B on (mist coolant)
    M8  RR  Flood Coolant On (CNC specific)
    M8  V3  flood coolant on
    M9  LC  Coolant Control - OFF
    M9  RG  all coolants off
    M9  RR  Coolant Off (CNC specific)
    M9  V3  mist and flood coolant off
    M10 RG  close clamp
    M10 RR  Vacuum On (CNC specific)
    M11 RG  open clamp
    M11 RR  Vacuum Off (CNC specific)
    M13 RG  spindle CW and coolant A on
    M14 RG  spindle CCW and coolant A on
    M17 MF  Enable/Power all stepper motors
    M17 RG  enable motor(s)
    M17 RR  Enable/Power all stepper motors
    M18 MF  Disable all stepper motors; same as M84
    M18 RG  disable motor(s)
    M18 RR  Disable all stepper motors
    M20 MF  List SD card
    M20 RR  List SD card
    M21 MF  Init SD card
    M21 RG  open collet
    M21 RR  Initialize SD card
    M22 MF  Release SD card
    M22 RG  close collet
    M22 RR  Release SD card
    M23 MF  Select SD file (M23 filename.g)
    M23 RR  Select SD file
    M24 MF  Start/resume SD print
    M24 RR  Start/resume SD print
    M25 MF  Pause SD print
    M25 RR  Pause SD print
    M26 MF  Set SD position in bytes (M26 S12345)
    M26 RR  Set SD position
    M27 MF  Report SD print status
    M27 RR  Report SD print status
    M28 MF  Start SD write (M28 filename.g)
    M28 RR  Begin write to SD card
    M29 MF  Stop SD write
    M29 RR  Stop writing to SD card
    M30 LC  Program End - exchange pallet shuttles
    M30 MF  Delete file from SD (M30 filename.g)
    M30 RG  program rewind
    M30 RR  Delete a file on the SD card
    M30 V3  program end, pallet shuttle, and reset
    M31 MF  Output time since last M109 or SD card start to serial
    M40-M46 RG  change gear ratio (0 - 6)
    M40 RR  Eject
    M41 RR  Loop
    M42 MF  Change pin status via gcode
    M42 RR  Stop on material exhausted / Switch I/O pin
    M43 RR  Stand by on material exhausted
    M48 LC  Feed & Spindle Overrides - Enable
    M48 V3  enable speed and feed overrides
    M49 LC  Feed & Spindle Overrides - Disable
    M49 V3  disable speed and feed overrides
    M50 LC  Feed Override Control
    M50 RG  read spindle speed
    M51 LC  Spindle Override Control
    M52 LC  Adaptive Feed Control
    M53 LC  Feed Stop Control
    M60 LC  Pallet Change Pause
    M60 V3  pallet shuttle and program stop
    M61 LC  Set Current Tool Number
    M62 LC  Output Control - synchronized ON
    M63 LC  Output Control - synchronized OFF
    M64 LC  Output Control - immediate ON
    M65 LC  Output Control - immediate OFF
    M66 LC  Input Control - wait
    M67 LC  Analog Output Control - synchronized
    M68 LC  Analog Output Control - immediate
    M70 RG  Display message on machine, with optional timeout specified by P-code in seconds
    M71 RG  Pause activity and display message, resuming build on button push. Optional timeout specified by P-code in seconds. If timeout is specified and no button is pushed, machine should shut down or reset.
    M72 RG  Play a song or tone defined by the machine, by a P-code specifying a song type. Default songs are Error Sound (P0), a Ta-da sound (P1), and a warning sound (P2). all other sounds are user or machine specific, with P2 the default for unknown sounds.
    M73 RG  Manually set build percentage. Valid P values are 0 to 100, values over 100 are rounded down to 100
    M80 MF  Turn on Power Supply
    M80 RR  ATX Power On
    M81 MF  Turn off Power Supply
    M81 RR  ATX Power Off
    M82 MF  Set E codes absolute (default)
    M82 RR  set extruder to absolute mode
    M83 MF  Set E codes relative while in Absolute Coordinates (G90) mode
    M83 RR  set extruder to relative mode
    M84 MF  Disable steppers until next move, or use S<seconds> to specify an inactivity timeout, after which the steppers will be disabled.  S0 to disable the timeout.
    M84 RR  Stop idle hold
    M85 MF  Set inactivity shutdown timer with parameter S<seconds>. To disable set zero (default)
    M92 MF  Set axis_steps_per_unit - same syntax as G92
    M92 RR  Set axis_steps_per_unit
    M98 RR  Get axis_hysteresis_mm
    M99 RR  Set axis_hysteresis_mm
    M100    LC  through M199   User Defined M codes
    M101    RR  Extruder on, fwd
    M101    RR  Turn extruder 1 on Forward / Undo Extruder Retraction
    M102    RR  Extruder on, reverse
    M102    RR  Turn extruder 1 on Reverse
    M103    RR  Extruder off
    M103    RR  Turn all extruders off / Extruder Retraction
    M104    MF  Set extruder target temp
    M104    RR  Set Extruder Temperature
    M104    RR  Snn set temperature in degrees Celsius
    M105    MF  Read current temp
    M105    RR  get extruder temperature
    M105    RR  Get Extruder Temperature
    M106    MF  Fan on
    M106    RR  Fan On
    M106    RR  turn fan on
    M107    MF  Fan off
    M107    RR  Fan Off
    M107    RR  turn fan off
    M108    RR  Set Extruder's Max Speed (Rnnn = RPM, Pnnn = PWM)
    M108    RR  Set Extruder Speed
    M109    MF  Wait for extruder current temp to reach target temp.
    M109    RR  Set Extruder Temperature and Wait
    M109    RR  Snnn set build platform temperature in degrees Celsuis
    M110    RR  Set Current Line Number
    M110    RR  Snnn set chamber temperature in degrees Celsius
    M111    RR  Set Debug Level
    M112    RR  Emergency Stop
    M113    RR  Set Extruder PWM
    M114    MF  Display current position
    M114    MF  Output current position to serial port
    M114    RR  Get Current Position
    M115    MF  Capabilities string
    M115    RR  Get Firmware Version and Capabilities
    M116    RR  Wait
    M117    MF  display message
    M117    RR  Get Zero Position
    M118    RR  Negotiate Features
    M119    MF  Output Endstop status to serial port
    M119    RR  Get Endstop Status
    M120    RR  M121, M122 Snnn set the PID gain for the temperature regulator (not currently supported by ReplicatorG)
    M123    RR  M124 Snnn set iMax and iMin windup guard for the PID controller (not currently supported by ReplicatorG)
    M126    JF  use acceleration for subsequent instructions
    M126    RG  valve open (acceleration on for subsequent instructions in the Jetty Firmware)
    M126    RR  Open Valve
    M127    JF  disable acceleration for subsequent instructions
    M127    RG  valve close (acceleration off for subsequent instructions in the Jetty Firmware)
    M127    RR  Close Valve
    M128    RR  Extruder Pressure PWM
    M128    RR  get position
    M129    RR  Extruder pressure off
    M129    RR  get range (not currently supported by ReplicatorG)
    M130    RR  Set PID P value
    M130    RR  set range (not currently supported by ReplicatorG)
    M131    RR  Set PID I value
    M132    RR  Set PID D value
    M133    RR  Set PID I limit value
    M134    RR  Write PID values to EEPROM
    M136    RR  Print PID settings to host
    M140    MF  Set bed target temp
    M140    RR  Bed Temperature (Fast)
    M141    RR  Chamber Temperature (Fast)
    M142    RR  Holding Pressure
    M143    RR  Maximum hot-end temperature
    M160    RR  Number of mixed materials
    M190    MF  Wait for bed current temp to reach target temp.
    M190    RR  Wait for bed temperature to reach target temp
    M200    JF  reset (to pick up changes)
    M200    MF  Set filament diameter
    M200    RR  reset driver
    M200    RR  Set filament diameter / Get Endstop Status
    M201    JF  set maximum rates of acceleration/deceleration
    M201    MF  Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
    M201    RR  Set max printing acceleration
    M202    MF  Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!!
    M202    RR  clear buffer (not currently supported by ReplicatorG)
    M202    RR  Set max travel acceleration
    M203    JF  set maximum feed rates
    M203    MF  Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec
    M203    RR  Set maximum feedrate
    M204    JF  set default rates of acceleration
    M204    MF  Set default acceleration: S normal moves T filament only moves (M204 S3000 T7000) im mm/sec^2  also sets minimum segment time in ms (B20000) to prevent buffer underruns and M20 minimum feedrate
    M204    RR  Set default acceleration
    M205    JF  set minimum feed rates and planner speed
    M205    MF   advanced settings:  minimum travel speed S=while printing T=travel only,  B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk, E=maximum E jerk
    M205    RR  advanced settings
    M206    JF  set extruded noodle diameter, extruder maximum reverse feed rate, extruder deprime, slowdown limit, and direction of extruder feed
    M206    MF  set additional homeing offset
    M206    RR  set home offset
    M207    JF  set JKN Advance parameters K and K2
    M207    RR  calibrate z axis by detecting z max length
    M208    JF  set extruder steps per millimeter
    M208    RR  set axis max travel
    M209    JF  turn acceleration planner on or off; enable or disable override of gcode temperature settings
    M209    RR  enable automatic retract
    M215    JF  set steps per millimeter for each axis
    M216    JF  set maximum speed changes for each axis
    M220    MF  S<factor in percent> set speed factor override percentage
    M220    RR  Set speed factor override percentage
    M221    MF  S<factor in percent> set extrude factor override percentage
    M221    RR  set extrude factor override percentage
    M226    RR  Gcode Initiated Pause
    M227    RR  Enable Automatic Reverse and Prime
    M228    RR  Disable Automatic Reverse and Prime
    M229    RR  Enable Automatic Reverse and Prime
    M230    RR  Disable / Enable Wait for Temperature Change
    M240    MF  Trigger a camera to take a photograph
    M240    RR  Start conveyor belt motor / Echo off
    M241    RR  Stop conveyor belt motor / echo on
    M245    RR  Start cooler
    M246    RR  Stop cooler
    M300    RR  Play beep sound
    M300    RR  Snnn set servo 1 position
    M301    MF  Set PID parameters P I and D
    M301    RR  Set PID parameters - Hot End
    M301    RR  Snnn set servo 2 position
    M302    MF  Allow cold extrudes
    M303    MF  PID relay autotune S<temperature> sets the target temperature. (default target temperature = 150C)
    M304    RR  Set PID parameters - Bed
    M310    RG  (filepath) logging
    M311    RG  stop logging
    M312    RG  (message) log message
    M320    RG  acceleration on for subsequent instructions
    M321    RG  acceleration off for subsequent instructions
    M400    MF  Finish all moves
    M420    RR  Set RGB Colors as PWM
    M500    MF  stores paramters in EEPROM
    M500    RR  stores paramters in EEPROM
    M501    MF  reads parameters from EEPROM (if you need reset them after you changed them temporarily).
    M501    RR  reads parameters from EEPROM
    M502    MF  reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
    M502    RR  reverts to the default "factory settings".
    M503    MF  print the current settings (from memory not from eeprom)
    M503    RR  Print settings
    M999    MF  Restart after being stopped by error