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

  • OpenSCAD vs. Skeinforge 40: Bogus G-Code

    My first pass at the NEMA 17 motor mount bracket used additive modeling, glomming together several blocks made from cube primitives:

    • The motor mounting plate, less five holes
    • Two side struts to stiffen the motor plate
    • The baseplate, minus two mounting holes

    Makes perfect sense to me; perhaps I’m an additive kind of guy. That produced an OpenSCAD model with positive surfaces for the various parts and negative surfaces inside the holes:

    NEMA 17 Mount - additive model
    NEMA 17 Mount – additive model

    Compile that through CGAL, export as STL, inhale into RepG 25, and you (well, I) get what looks to be a fine object in the preview pane:

    NEMA 17 RepG preview - additive
    NEMA 17 RepG preview – additive

    Then run it through Skeinforge 40, which emits a flurry of messages along these lines:

    [19:11:08] Warning, the triangle mesh slice intersects itself in getLoopsFromCorrectMesh in triangle_mesh.
    [19:11:08] Something will still be printed, but there is no guarantee that it will be the correct shape.
    [19:11:08] Once the gcode is saved, you should check over the layer with a z of:
    [19:11:09] 0.165
    

    The usual searching suggested that sometimes Skeinforge has problems with coincident surfaces, such as between the motor mount plate and the struts and the base, or coincident edges where two blocks abut. Judging from the messages, the problem ran all the way to the top of the struts. Oddly, Skeinview didn’t show any problems, so the G-Code was (presumably) OK.

    Error messages tend to make me twitchy, though. I modified the OpenSCAD code to extend the struts 0.1 mm inside the base and ran that model through the software stack, which produced not a single complaint about anything, anywhere.

    Success!

    However, painful experience has caused me to review the G-Code for every single object with the Skeinlayer plugin, which, right on cue, revealed this interesting anomaly:

    NEMA 17 Mount - Skeinview - Bad gcode
    NEMA 17 Mount – Skeinview – Bad gcode

    That happened for every layer in the square motor mount plate: the lower right corner is fine, the upper left seems to be the negative of the actual solid model. The holes are filled, the plate is empty. The Skirt outline ignores the smaller holes, goes around the large one, and continues on its merry way.

    I putzed around for a while and discovered that the failure seems acutely sensitive to the side strut thickness. Yeah, like that makes any sense.

    Any variations along those lines that I tried generated either:

    • A flurry of mesh error messages, with seemingly good G-Code
    • No error messages whatsoever, with totally bogus G-Code

    Running the STL files through netfabb Cloud Service produced the same diagnostic for both:

    Number of holes: 3
    Number of shells: 2
    Mesh is not manifold and oriented.
     We unfortunately have not yet enough experience with the occuring server loads, that we can securely enable shell merging at the moment.
    

    However, the repaired STL files produce correct G-Code: evidently OpenSCAD spits out bogus STL data. The fact that RepG/SF treats the two files differently suggests improved diagnostics would be in order, but that’s in the nature of fine tuning.

    So I junked the additive model and went subtractive, chewing the recesses out of one huge block:

    NEMA 17 Stepper Mount - solid model
    NEMA 17 Stepper Mount – solid model

    That worked:

    Number of holes: 0
    Number of shells: 1
    Mesh is manifold and oriented.
    

    I like processes that don’t emit error messages or result in mysterious failures, although it’s not obvious that subtractive modeling will always produce correct results. Heck, I’m not sure I can think in terms of negative volumes all that well.

    The OpenSCAD code for the additive model, with a highlight on the conditional that will trigger the two errors:

    // NEMA 17 stepper motor mount
    // Ed Nisley KE4ZNU August 2011
    
    include </home/ed/Thing-O-Matic/lib/MCAD/units.scad>
    
    //-- Layout Control
    
    Layout = "Build";				// Build Show None
    
    Examine = "None";				// Mount Stand None
    
    //-- Extrusion parameters
    
    ThreadThick = 0.33;
    ThreadWT = 2.0;
    ThreadWidth = ThreadThick * ThreadWT;
    
    HoleWindage = 0.3;			// enlarge hole dia by this amount
    
    function IntegerMultiple(Size,Unit) = Unit * ceil(Size / Unit);
    
    //-- Useful sizes
    
    Tap2_56 = 0.070 * inch;
    Clear2_56 = 0.082 * inch;
    Head2_56 = 0.156 * inch;
    Head2_56Thick = 0.055 * inch;
    Nut2_56Dia = 0.204 * inch;
    Nut2_56Thick = 0.065 * inch;
    
    Tap3_48 = 0.079 * inch;
    Clear3_48 = 0.096 * inch;
    Head3_48 = 0.184 * inch;
    Head3_48Thick = 0.058 * inch;
    Nut3_48Dia = 0.201 * inch;
    Nut3_48Thick = 0.073 * inch;
    
    Tap4_40 = 0.089 * inch;
    Clear4_40 = 0.110 * inch;
    Head4_40 = 0.211 * inch;
    Head4_40Thick = 0.065 * inch;
    Nut4_40Dia = 0.228 * inch;
    Nut4_40Thick = 0.086 * inch;
    
    Tap10_32 = 0.159 * inch;
    Clear10_32 = 0.190 * inch;
    Head10_32 = 0.373 * inch;
    Head10_32Thick = 0.110 * inch;
    Nut10_32Dia = 0.433 * inch;
    Nut10_32Thick = 0.130 * inch;
    
    NEMA17_ShaftDia = 5.0;
    NEMA17_ShaftLength = 24.0;
    NEMA17_PilotDia = 0.866 * inch;
    NEMA17_PilotLength = 0.080 * inch;
    NEMA17_BCD = 1.725 * inch;
    NEMA17_BoltDia = 3.5;
    NEMA17_BoltOC = 1.220 * inch;
    
    //-- Mount Sizes
    
    MountSide = IntegerMultiple(NEMA17_BCD,ThreadWidth);
    MountThick = IntegerMultiple(8.0,ThreadThick);
    
    MountBoltDia = 3.0;
    
    StrutThick = IntegerMultiple(5.0,ThreadWidth);
    StrutHeight = MountSide;
    
    StandThick = IntegerMultiple(4.0,ThreadWidth);
    
    UprightLength = IntegerMultiple(MountSide + 2*StrutThick,5);
    
    StandBoltAllowance = IntegerMultiple(Head10_32,5);
    StandBoltOC = UprightLength + 2*StandBoltAllowance;
    
    StandLength = IntegerMultiple(StandBoltOC + 2*StandBoltAllowance,ThreadWidth);
    StandWidth = IntegerMultiple(2*StandBoltAllowance,ThreadThick);
    
    echo(str("Stand Base: ",StandLength," x ",StandWidth));
    echo(str("Stand Bolt OC: ",StandBoltOC));
    
    //-- Convenience values
    
    Protrusion = 0.1;		// make holes look good and joints intersect properly
    
    BuildOffset = 3 * ThreadWidth;
    
    //----------------------
    // Useful routines
    
    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);
    
    }
    
    //----------------------
    // Motor Mount plate
    
    module MotorMount() {
    
      difference() {
    	translate([0,0,MountThick/2])
    	  cube([MountSide,MountSide,MountThick],center=true);
    if (true) {
    	translate([0,0,-Protrusion])
    	  PolyCyl(NEMA17_PilotDia,(MountThick + 2*Protrusion));
    }
    else {
    	translate([0,0,MountThick - NEMA17_PilotLength])
    	  PolyCyl(NEMA17_PilotDia,(NEMA17_PilotLength + Protrusion));
    	translate([0,0,-Protrusion])
    	  PolyCyl(1.5*NEMA17_ShaftDia,(MountThick + 2*Protrusion));
    }
    	for (x=[-1,1])
    	  for (y=[-1,1])
    		translate([x*NEMA17_BoltOC/2,y*NEMA17_BoltOC/2,-Protrusion])
    		  PolyCyl(MountBoltDia,(MountThick + 2*Protrusion));
      }
    
    }
    
    //----------------------
    // Stand to support the plate
    
    module Stand() {
    
      difference() {
    
    	union() {
    	  translate([0,0,StandThick/2])
    		cube([StandLength,StandWidth,StandThick],center=true);
    	  for (x=[-1,1])						// side support struts
    if (true)	// this causes bizarre negative rendering and a diagonal negative section
    		translate([(x*((MountSide + StrutThick)/2)),0,
    				  (StandThick + StrutHeight/2 - Protrusion/2)])
    		  cube([StrutThick,StandWidth,(StrutHeight + Protrusion)],center=true);
    else	// this generates "triangle slice mesh intersects iself"
    		translate([(x*((MountSide + StrutThick)/2)),0,
    				  (StandThick + StrutHeight/2)])
    		  cube([StrutThick,StandWidth,StrutHeight],center=true);
    	}
    
    	for (x=[-1,1])
    	  translate([x*StandBoltOC/2,0,-Protrusion])
    		PolyCyl(Clear10_32,StandThick + 2*Protrusion);
      }
    }
    
    //----------------------
    // Combined for single build
    
    module Combined() {
    
    //  union() {
    	translate([-MountSide/2,0,0])
    	  MotorMount();
    
    	translate([StandThick,0,StandWidth/2])
    	  rotate([90,0,270])
    		Stand();
    
    //  }
    }
    
    //----------------------
    // Lash everything together
    
    ShowPegGrid();
    
    if (Examine == "Mount")
      MotorMount();
    
    if (Examine == "Stand")
      Stand();
    
    if (Layout == "Build" && Examine == "None") {
      translate([MountSide/2,0,0])
    	Combined();
    }
    
    if ((Layout == "Show") && Examine == "None") {
      translate([-StandWidth/2,0,StandThick])
    	rotate([0,90,0])
    	  Combined();
    }
    

    OpenSCAD depends on CGAL for all the 3D heavy lifting, which puts any STL export problems further upstream.  I suppose I could open Yet Another RepG ticket to get better diagnostics, but the others haven’t gotten much attention so far and I suppose it’s not really their problem anyway.

  • Stepper Dynamometer Mechanics

    Combine two of those mounts with one of those couplers, add two NEMA 17 steppers (the one on the right is that one), slide a baseplate underneath, sprinkle with various screws, and shazam you get a stepper motor dynamometer:

    Stepper Dynamometer
    Stepper Dynamometer

    The baseplate puts the mounts 65 mm apart on the 10-32 screw centers, which is entirely a function of the coupler length, and is easy with manual CNC on the Sherline.

    Changing the motors is straightforward: loosen coupler setscrew, remove base screws, slide motor away from coupler, remove mount screws. Won’t happen that often, methinks.

    The general idea is to drive one stepper with a known current, apply a known resistive load to the other motor’s windings, and then plot torque vs. speed. It won’t be quite that simple, of course, but should produce some interesting data.

     

  • Stepper Motor Shaft Coupler

    This simple cylinder connects two NEMA 17 stepper motors together:

    Stepper Shaft Coupler
    Stepper Shaft Coupler

    It’s quick-and-dirty:

    • Cut 2+ inches of 0.375 drill rod, face both ends
    • Drill #8 = 0.199 inch = 5.06 mm (because #9 = 0.196 inch = 4.98 mm is a bit too snug)
    • Cross-drill #41 in the Sherline (because #43 makes for stiff tapping)
    • Tap 4-40 for the setscrews
    • File off rough edges, run #8 drill through the bore to clean out tapping chips &c

    Now, you probably don’t want to do this in real life, because you want a coupler with a bit of compliance to soak up the inevitable misalignment and dampen the mechanical resonances.

  • NEMA 17 Stepper Motor Mount

    This mount will hold a NEMA 17 stepper firmly in place so I can attach things to the shaft:

    NEMA 17 Mount on build plate
    NEMA 17 Mount on build plate

    The baseplate holes fit 10-32 screws, which work in the plastic sheet that will go below this thing, and the motor mount plate holes fits 3 mm bolts for the motors. Washers under the heads, of course. Build with three additional shells, three solid layers, and 0.25 fill for useful rigidity; the flanges came out completely solid.

    Somewhat to my surprise, this didn’t show any signs of delamination due to the rather low 190 °C extrusion temperature. The flanges aren’t all that massive, though, so perhaps trouble still lies await.

    The OpenSCAD solid model uses subtractive construction, for reasons that I’ll go into later:

    NEMA 17 Stepper Mount - solid model
    NEMA 17 Stepper Mount – solid model

    The OpenSCAD source code:

    // NEMA 17 stepper mount for dynamometer
    // Ed Nisley KE4ZNU August 2011
    
    include </home/ed/Thing-O-Matic/lib/MCAD/units.scad>
    
    //-- Layout Control
    
    Layout = "Build";				// Build Show
    
    //-- Extrusion parameters
    
    ThreadThick = 0.33;
    ThreadWT = 2.0;
    ThreadWidth = ThreadThick * ThreadWT;
    
    HoleWindage = 0.3;			// enlarge hole dia by this amount
    
    function IntegerMultiple(Size,Unit) = Unit * ceil(Size / Unit);
    
    //-- Useful sizes
    
    Tap10_32 = 0.159 * inch;
    Clear10_32 = 0.190 * inch;
    Head10_32 = 0.373 * inch;
    Head10_32Thick = 0.110 * inch;
    Nut10_32Dia = 0.433 * inch;
    Nut10_32Thick = 0.130 * inch;
    
    NEMA17_ShaftDia = 5.0;
    NEMA17_ShaftLength = 24.0;
    NEMA17_PilotDia = 0.866 * inch;
    NEMA17_PilotLength = 0.080 * inch;
    NEMA17_BCD = 1.725 * inch;
    NEMA17_BoltDia = 3.5;
    NEMA17_BoltOC = 1.220 * inch;
    
    //-- Mount Sizes
    
    MountWidth = IntegerMultiple(NEMA17_BCD,ThreadWidth);		// use BCD for motor clearance
    MountThick = IntegerMultiple(8.0,ThreadThick);				// for stiffness
    
    MountBoltDia = 3.0;
    
    StandThick = IntegerMultiple(5.0,ThreadWidth);				// baseplate
    
    StrutThick = IntegerMultiple(4.0,ThreadWidth);				// sides holding motor mount
    
    UprightLength = MountWidth + 2*StrutThick;
    
    StandBoltHead = IntegerMultiple(Head10_32,5);				// bolt head rounded up
    StandBoltOC = IntegerMultiple(UprightLength + 2*StandBoltHead,5);
    
    StandLength = StandBoltOC + 2*StandBoltHead;
    StandWidth = IntegerMultiple(2*StandBoltHead,ThreadThick);
    
    StandBoltClear = (StandLength - UprightLength)/2;			// flat around bolt head
    
    MotorRecess = StandWidth - MountThick;
    
    echo(str("Stand Base: ",StandLength," x ",StandWidth," x ",StandThick));
    echo(str("Stand Bolt OC: ",StandBoltOC));
    echo(str("Strut Thick: ",StrutThick));
    
    //-- Convenience values
    
    Protrusion = 0.1;		// make holes look good and joints intersect properly
    
    BuildOffset = 3 * ThreadWidth;
    
    //----------------------
    // Useful routines
    
    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);
    
    }
    
    //----------------------
    // Combined stand and mounting plate
    
    module Combined() {
    
      difference() {
    	translate([StandThick/2,0,StandWidth/2])
    	  cube([(MountWidth + StandThick),StandLength,StandWidth],center=true);
    	translate([-Protrusion/2,0,StandWidth - (MotorRecess - Protrusion)/2])
    	  cube([(MountWidth + Protrusion),MountWidth,(MotorRecess + Protrusion)],center=true);
    	translate([0,0,-Protrusion])				// pilot hole
    	  PolyCyl(NEMA17_PilotDia,(MountThick + 2*Protrusion));
    	for (x=[-1,1])								// motor bolt holes
    	  for (y=[-1,1])
    		translate([x*NEMA17_BoltOC/2,y*NEMA17_BoltOC/2,-Protrusion])
    		  PolyCyl(MountBoltDia,(MountThick + 2*Protrusion));
    	for (y=[-1,1])								// cutouts over bolts
    	  translate([-Protrusion/2,
    				y*((StandLength - StandBoltClear)/2 + Protrusion),
    				StandWidth/2])
    		cube([(MountWidth + Protrusion),
    			 (StandBoltClear + Protrusion),
    			 (StandWidth + 2*Protrusion)],center=true);
    	for (y=[-1,1])								// stand bolt holes
    	  translate([(MountWidth/2 - Protrusion),y*StandBoltOC/2,StandWidth/2])
    		rotate([0,90,0])
    		  PolyCyl(Clear10_32,StandThick + 2*Protrusion,8);
    
      }
    
    }
    
    //----------------------
    // Lash everything together
    
    ShowPegGrid();
    
    if (Layout == "Build") {
      translate([0,0,0])
    	Combined();
    }
    
    if (Layout == "Show") {
      translate([-StandWidth/2,0,(StandThick + MountWidth/2)])
    	rotate([0,90,0])
    	  Combined();
    }
    
  • Thing-O-Matic: Broken G91 Relative Motion

    It would be handy, while doing the fast / coarse home stuff, to switch to G91 relative positioning mode and back off the switches by 2 mm by using a simple G0 X2 Y2 Z-2 that doesn’t depend on knowing the exact coordinates of the endpoint, but it seems relative positioning doesn’t work for any but the most trivial cases.

    After some fiddling, this short routine produces a very fast, very long, fully coordinated XY move to some position in the +X +Y direction at the G1 X2 F100 command after the G91 command sets relative motions; it should move 2 mm away from the X switch. When the machine arrives at the new (unexpected) position, it then does the expected slow 2 mm Y and Z moves:

    G21 (set units to mm)
    G90 (set positioning to absolute)
    (- coarse home axes)
    G162 Z F1000 (home Z to get nozzle out of danger zone)
    G161 Y F4000 (retract Y to get X out of front opening)
    G161 X F4000 (now safe to home X)
    (- back off switches)
    G91
    G1 X2 F100
    G1 Y2 F100
    G1 Z-2 F100
    G90

    I gave up and used an absolute move with hardcoded XYZ coordinates that should be pretty close to the stored values.

    There’s a RepG ticket for that.

    Obviously, I’m going where no other Thing-O-Matic operator has gone before. I do that a lot, don’t I?

  • Thing-O-Matic: Revised Homing

    After adding F feed speed parameters to all the G0 commands in my start.gcode (to work around that bug), I decided to use the new-with-firmware-2.8 feature that stores the home offsets in the Thing-O-Matic’s EEPROM. That turned out to be, one might say, a thinly documented feature, so this may be a useful summary…

    The Official Way to set the EEPROM, which you can find in ReplicatorG/scripts/calibration/Thing-O-Matic calibration.gcode, goes a little something like this:

    • Manually position the nozzle dead center on the build plate, just touching the surface
    • Use G92 to set all axes to 0.0
    • Home the axes to the switches
    • Use M131 X Y Z A B to store the current values in EEPROM

    Having already found good values for those offsets as part of the aluminum build plate adventure, I jammed them into EEPROM using RepG’s Machine→Motherboard Onboard Preferences. The values I’m using are:

    • X = -53.0
    • Y = -59.0
    • Z = 116.0

    For some unknown reason that has nothing to do with floating point representation (I mean sheesh even the 32-bit version of IEEE 754 floating point has at least 10 decimal digits of precsion), RepG modifies only the negative values sufficiently to be bothersome:

    • X = -52.964
    • Y = -58.976

    Having stored the offsets, I wondered how to fetch them. That is also, of course, completely undocumented, but I eventually traced down the answer in (deep breath)

    skein_engines/skeinforge-35/skeinforge_application/prefs/SF35-Thingomatic-HBP-Stepstruder/alterations/start.gcode

    That’s not true for all the start.gcode files you might find, though, and there are many such in far more obvious places.

    So, OK, I fetch the EEPROM coordinates using M132 after doing both the coarse home (they’ll be pretty close) and the fine home (they’ll be dead on, modulo the changes), then wipe the nozzle and poke the Z-minimum height switch (which is why I really really care about random changes in the stored values) to find the actual height above the aluminum build surface.

    At exactly this position it would be nice to set only the Z height to the actual switch thickness, but G92 sets all un-mentioned axes to zero, so you can’t set just one axis. I have no idea how M131 and M132 behaves in that regard; none of this stuff is documented anywhere that I can find and this stopped being funny a while ago.

    So, knowing the XYZ coordinates of the switch, I reset the XYZAB axes using G92.

    The current working start.gcode that I devoutly hope will continue to work for a while:

    (---- start.gcode begins ----)
    (MakerBot Thing-O-Matic with aluminum HBP and Z-min platform switch)
    (Tweaked for TOM 286 - Ruttmeister MK5 stepper extruder mod)
    (Ed Nisley - KE4ZNU - July 2011)
    (Hack to work around bad G0 speed)
    (- set initial conditions)
    G21		(set units to mm)
    G90		(set positioning to absolute)
    (- begin heating)
    M104 S210 T0	(extruder head)
    M109 S110 T0	(HBP)
    (- coarse home axes)
    G162 Z F1000	(home Z to get nozzle out of danger zone)
    G161 Y F4000	(retract Y to get X out of front opening)
    G161 X F4000	(now safe to home X)
    M132 X Y Z A B	(fetch home offsets from EEPROM)
    (- fine home axes)
    G0 X-51 Y-55 Z114 F400	(back off switches)
    G161 Y F200
    G161 X F200
    G162 Z F200
    M132 X Y Z A B	(fetch home offsets from EEPROM)
    (- manual nozzle wipe)
    G0 F6000 X0 Y0 Z10	(pause at center to build confidence)
    G4 P500
    G0 X40 Y-57.0 Z10	(move to front, avoid wiper blade)
    G0 X56				(to wipe station)
    G0 Z6.0				(down to wipe level)
    M6 T0				(wait for temperature settling)
    G1 Y-45	F1000		(slowly wipe nozzle)
    (-----------------------------------------------)
    (- Make sure the XY position matches the G92    )
    (- home Z downward to platform switch)
    G0 F6000 X56.4 Y7.6 Z3		(get over build platform switch)
    G161 Z0 F50					(home downward very slowly)
    G92 X56.4 Y7.6 Z1.60		(set Z height)
    G0 F6000 Z6.0				(back off switch to wipe level)
    (-----------------------------------------------)
    (- start extruder and re-wipe)
    G0 X56 Y-45     (set up for wipe from rear)
    G1 Y-57.0 F1000 (wipe to front)
    M108 R2.0		(set stepper extruder speed)
    M101			(Extruder on, forward)
    G4 P4000  	    (take up slack, get pressure)
    M103			(Extruder off)
    G4 P4000  	    (Wait for filament to stop oozing)
    G1 Y-45	F1000	(slowly wipe nozzle again)
    G0 F6000 X0		(get away from wiper blade)
    (- build some pressure)
    M108 R2.0		(set stepper extruder speed)
    M101			(start extruder)
    G4 P100			(run for a bit)
    (---- start.gcode ends ----)
    
    

    For what it’s worth, I put that file in the sf_40_alterations directory, blew away the previous versions in all the profiles, and replaced them with symlinks to that single file. When the next change comes along, I can modify one file and all the profiles will pick up the change at once.

  • Helmet Mirror: Smaller Mirror Shaft

    This is the slightly smaller mount corresponding to the OpenSCAD code there for the two-section inspection mirror shaft, hot from the printer:

    Helmet mirror mount on build platform - smaller mirror shaft
    Helmet mirror mount on build platform – smaller mirror shaft

    It’s about the same as the previous version, despite trimming a few millimeters from the diameters and spacings:

    Helmet mirror mount size comparison
    Helmet mirror mount size comparison

    I’ll print the next one in a darker color. At least it’s not pink…

    The OpenSCAD source:

    // Helmet mirror mount
    // Ed Nisley KE4ZNU June 2011
    
    include </home/ed/Thing-O-Matic/lib/MCAD/units.scad>
    include </home/ed/Thing-O-Matic/lib/MCAD/boxes.scad>
    include </home/ed/Thing-O-Matic/lib/visibone_colors.scad>
    
    //-- Layout Control
    
    Layout = "Build";					// Build Fit Show None
    
    Examine = "None";				// AzMount ElMount ElBody ElPlate HelmetPlate None
    
    //-- Extrusion parameters
    
    ThreadThick = 0.33;
    ThreadWT = 2.0;
    ThreadWidth = ThreadThick * ThreadWT;
    
    HoleWindage = 0;			// enlarge hole dia by this amount
    
    //-- Useful sizes
    
    Tap2_56 = 0.070 * inch;
    Clear2_56 = 0.082 * inch;
    Head2_56 = 0.156 * inch;
    Head2_56Thick = 0.055 * inch;
    Nut2_56Dia = 0.204 * inch;
    Nut2_56Thick = 0.065 * inch;
    
    Tap3_48 = 0.079 * inch;
    Clear3_48 = 0.096 * inch;
    Head3_48 = 0.184 * inch;
    Head3_48Thick = 0.058 * inch;
    Nut3_48Dia = 0.201 * inch;
    Nut3_48Thick = 0.073 * inch;
    
    Tap4_40 = 0.089 * inch;
    Clear4_40 = 0.110 * inch;
    Head4_40 = 0.211 * inch;
    Head4_40Thick = 0.065 * inch;
    Nut4_40Dia = 0.228 * inch;
    Nut4_40Thick = 0.086 * inch;
    
    //-- Azimuth Mount
    
    AzMountDia = 12.0;
    AzMountLength = 14.0;
    
    AzFacets = 30;
    
    echo(str("Azmuth mount dia: ",AzMountDia," length: ",AzMountLength));
    
    //-- Mirror sizes
    
    MirrorShaftDia = 3.60;
    MirrorShaftOffset = -1.5;				// vertical offset from center of AzMountBody
    MirrorShoulderLen = 3*MirrorShaftDia;
    MirrorShoulderDia = min(AzMountDia,MirrorShaftDia + 6*ThreadWidth);
    
    MirrorStudDia = Tap3_48;
    MirrorStudLen = 2.0;
    
    //-- Elevation Mount / Body / Plate
    
    ElMountDia = AzMountDia;
    ElMountLength = 2.0 + ElMountDia;
    
    ElMountBase = 2.0;
    
    ElMountRounding = 2.0;
    
    ElMountFacets = AzFacets;
    
    ElBodyWidth = ElMountDia;
    ElBodyBlockLength = ElMountLength + AzMountLength/2 - MirrorShaftOffset;
    ElBodyThick = 8.0;
    
    echo(str("Elevation body overall: ",(ElBodyBlockLength + ElBodyWidth/2)," width: ",ElBodyWidth));
    
    ElPlateTall = ElBodyBlockLength + 0.70*ElBodyWidth;
    ElPlateWidth = 1.25 * ElPlateTall;
    ElPlateThick = Nut3_48Thick + 3*ThreadThick;
    
    ElPlatePlusX = ElPlateThick + (ElMountDia/2 + ElMountBase) + ElBodyThick;
    
    echo(str("Elevation plate tall: ",ElPlateTall," width: ",ElPlateWidth));
    
    ElArcRadius = (3/4) * ElBodyBlockLength;
    ElArcThick = 4*ThreadWidth;
    ElArcHeight = (1/2) * ElBodyThick;
    ElArcAngle = 35;
    ElArcFacets = 32;
    
    ElPlateFacets = 52;
    
    //-- Helmet Interface Plate
    
    HelmetCX = 60.0;
    HelmetMX = 4.0;
    HelmetRX = (pow(HelmetMX,2) + pow(HelmetCX,2)/4)/(2*HelmetMX);
    
    HelmetPlateC = max(ElPlateTall,ElPlateWidth);
    HelmetPlateTheta = atan(HelmetPlateC/HelmetRX);
    HelmetPlateM = 2*HelmetRX*pow(sin(HelmetPlateTheta/4),2);
    
    HelmetPlateThick = ThreadThick*(ceil(HelmetPlateM/ThreadThick) + 1);
    
    //-- Bearing Interfaces
    
    BearingWidth = 3*ThreadWidth;
    
    BearingOverlap = 3*ThreadThick;
    BearingClearance = 1*ThreadThick;
    
    BearingStudDia = min(AzMountDia,ElBodyWidth) - 2*BearingWidth;
    
    //-- Convenience values
    
    Protrusion = 0.1;		// make holes look good
    
    //----------------------
    // Useful routines
    
    module PolyCyl(Dia,Height) {			// based on nophead's polyholes
    
      Sides = ceil(Dia) + 2;
      FixDia = Dia / cos(180/Sides);
    
      cylinder(r=(FixDia + HoleWindage)/2,
               h=Height,
    	   $fn=Sides);
    }
    
    PegSize = 1.0;
    
    module ShowPegGrid(Size) {
    	for (x=[-5:5])
    	  for (y=[-5:5])
    		translate([x*10,y*10,Size/2])
    		  cube(Size,center=true);
    
    }
    
    //----------------------
    // Azimuth Mount
    
    module AzMount() {
    
      difference() {
    	union() {
    	  cylinder(r=AzMountDia/2,h=AzMountLength,$fn=AzFacets);		// body
    	  translate([0,0,AzMountLength/2 + MirrorShaftOffset])
    		rotate([-90,0,0])
    		  cylinder(r=MirrorShoulderDia/2,
    				   h=MirrorShoulderLen,$fn=AzFacets);				// mirror shaft shoulder
    
    	  if (Layout != "Fit")
    		for (y=[0:1])												// shoulder support
    		  translate([-AzMountDia/2,(4*y + AzMountDia/2 + ThreadWidth),0])
    			difference() {
    			  cube([AzMountDia,2*ThreadWidth,AzMountLength/6]);
    			  translate([AzMountDia/2,-Protrusion,AzMountLength/2 + MirrorShaftOffset])
    				rotate([-90,0,0])
    				  cylinder(r=MirrorShoulderDia/2,h=ThreadWidth + 2*Protrusion);
    			}
    	}
    
        translate([0,-Head3_48/2,AzMountLength/2 + MirrorShaftOffset])
          rotate([-90,0,0])
    		PolyCyl(MirrorShaftDia,(AzMountDia + MirrorShoulderLen));	// mirror shaft
    
        translate([0,-(Head3_48/2 - Protrusion),AzMountLength/2 + MirrorShaftOffset])
    	  rotate([90,0,0])
    		PolyCyl(MirrorStudDia,MirrorStudLen+Protrusion);			// mirror stud
    
        translate([0,0,
    	       Head3_48Thick - (AzMountLength - MirrorShaftDia)/2 + MirrorShaftOffset - Protrusion])
          PolyCyl(Head3_48,AzMountLength + Protrusion);					// mounting screw head
    
        translate([0,0,-Protrusion])
          cylinder(r=(Clear3_48 + HoleWindage)/2,
    	  h=(AzMountLength + 2*Protrusion),
    	  $fn=ceil(Clear3_48)+2);										// mounting screw clearance
    
    	translate([0,0,AzMountLength/2 + Head3_48Thick + MirrorShaftDia/2 + MirrorShaftOffset - Protrusion])
    	  cylinder(r1=(Head3_48/cos(180/7) + HoleWindage)/2,
    			   r2=Clear3_48/2,
    			   h=(3*ThreadThick + Protrusion),
    			   $fn=7);												// overhang support
    
        translate([0,0,AzMountLength/2 + MirrorShaftOffset])
          rotate([0,90,0])
    		PolyCyl(Tap2_56,AzMountDia/2 + Protrusion);					// setscrew hole
    
        translate([0,0,AzMountLength - (BearingOverlap + BearingClearance)])
    	  PolyCyl(BearingStudDia,
    			  BearingOverlap + BearingClearance + Protrusion);		// bearing surface
    
      }
    
    }
    
    //----------------------
    // Elevation Mount
    
    module ElMount() {
    
      difference() {
    
    	union() {
    
    	  translate([(ElMountDia/4 + ElMountBase/2),0,(ElMountLength/2 + BearingOverlap)])
    		rotate([0,90,0])
    		  cube([ElMountLength,ElMountDia,(ElMountDia/2 + ElMountBase)],
    			  center=true);											// mounting block
    
    	  translate([0,0,BearingOverlap]) {
    //		color([0.4,0.3,0.3,0.7])
    		cylinder(r=ElMountDia/2,
    				 h=ElMountLength - ElMountDia/2,
    				 $fn=ElMountFacets);								// cylinder to Az
    
    //		color([0.3,0.4,0.3,0.7])
    		translate([0,0,ElMountLength - ElMountDia/2]) {				// curved interface
    		  intersection() {
    			cylinder(r=ElMountDia/2,h=ElMountDia/2,$fn=ElMountFacets);
    			translate([0,ElMountDia/2,0])
    			  rotate([90,0,0])
    				cylinder(r=ElMountDia/2,h=ElMountDia,$fn=ElMountFacets);
    		  }
    		}
    
    	  }
    
    	  cylinder(r=(BearingStudDia - HoleWindage)/2,h=BearingOverlap);	// bearing stud
    	}
    
    	translate([0,0,-Protrusion])
    	  PolyCyl(Tap3_48,(3/4)*ElMountLength + BearingOverlap + Protrusion);	// AzMount screw
      }
    }
    
    //----------------------
    // Elevation Body
    
    module ElBody() {
    
      difference() {
    	union() {
    	  translate([-ElBodyBlockLength,-ElBodyWidth/2,0])
    		cube([ElBodyBlockLength,ElBodyWidth,ElBodyThick]);
    	  translate([0,0,ElBodyThick])
    		cylinder(r=(ElBodyWidth - 2*BearingWidth)/2,h=BearingOverlap);
    	  cylinder(r=ElBodyWidth/2,h=ElBodyThick,$fn=ElMountFacets);
    	}
    
    	PolyCyl(Clear3_48,ElBodyThick + BearingOverlap + Protrusion);
    
    	translate([0,0,-Protrusion])
    	  PolyCyl(Head3_48,Head3_48Thick);
    
    	translate([-ElArcRadius,0,ElBodyThick - ElArcHeight/2])
    	  rotate([0,-90,0])
    		PolyCyl(Tap2_56,ElBodyBlockLength - ElArcRadius + Protrusion);
    
    	translate([0,0,ElBodyThick - (ElArcHeight + BearingClearance)])
    	  difference() {
    		cylinder(r=ElArcRadius + (ElArcThick/2 + BearingClearance),
    				 h=ElArcHeight + BearingClearance + Protrusion,
    				 $fn=ElArcFacets);
    		cylinder(r=ElArcRadius - (ElArcThick/2 + BearingClearance),
    				 h=ElArcHeight + BearingClearance + Protrusion,
    				 $fn=ElArcFacets);
    	  }
    
      }
    
    }
    
    //----------------------
    // Elevation Plate
    
    module ElPlate() {
    
      union() {
    	difference() {
    	  translate([ElBodyWidth/2 - ElPlateTall/2,0,0])
    		scale([ElPlateTall,ElPlateWidth,1.0])
    		  cylinder(r=0.5,h=ElPlateThick,$fn=ElPlateFacets);
    	  translate([0,0,-Protrusion])
    		PolyCyl(Tap3_48,ElPlateThick + 2*Protrusion);
    	  translate([0,0,ElPlateThick - (BearingOverlap + BearingClearance)])
    		PolyCyl(BearingStudDia,(BearingOverlap + BearingClearance) + Protrusion);
    	  translate([0,0,-Protrusion])
    		cylinder(r=Nut3_48Dia/2,h=(1.1*Nut3_48Thick + Protrusion),$fn=6);
    	}
    
    	translate([0,0,ElPlateThick])
    	difference() {
    	  cylinder(r=ElArcRadius + ElArcThick/2,
    			   h=ElArcHeight,
    			   $fn=ElArcFacets);
    	  cylinder(r=ElArcRadius - ElArcThick/2,
    			   h=ElArcHeight + Protrusion,
    			   $fn=ElArcFacets);
    	  rotate([0,0,90 - ElArcAngle])
    	    translate([ElArcRadius + ElArcThick,0,ElArcHeight/2])
    		  cube([2*ElArcRadius + ElArcThick,
    				2*ElArcRadius + ElArcThick,
    				ElArcHeight + Protrusion],
    				center=true);
    	  rotate([0,0,-(90 - ElArcAngle)])
    	    translate([ElArcRadius + ElArcThick,0,ElArcHeight/2])
    		  cube([2*ElArcRadius + ElArcThick,
    				2*ElArcRadius + ElArcThick,
    				ElArcHeight + Protrusion],
    				center=true);
    	}
      }
    }
    
    //----------------------
    // Helmet Interface Plate
    
    module HelmetPlate() {
    
      difference() {
    	scale([ElPlateTall,ElPlateWidth,1.0])
    	  cylinder(r=0.5,h=HelmetPlateThick,$fn=ElPlateFacets);
    
    	translate([0,0,HelmetRX + HelmetPlateThick - HelmetPlateM])
    	  sphere(r=HelmetRX,$fn=256,$fs=0.1);
    
      }
    }
    
    //----------------------
    // Lash it together
    
    if (Examine == "AzMount")
      AzMount();
    
    if (Examine == "ElMount")
      ElMount();
    
    if (Examine == "ElBody")
      ElBody();
    
    if (Examine == "ElPlate")
      ElPlate();
    
    if (Examine == "HelmetPlate")
      HelmetPlate();
    
    if ((Layout == "Build" || Layout == "Show") && Examine == "None") {
      translate([-10,-20,0])
    	rotate([0,0,90])					// mis-align top fill from ElMount
    	  AzMount();
    
      translate([-10,20,ElMountLength + BearingOverlap])
    	rotate([0,180,-90])
    	  ElMount();
    
      translate([0,0,0])
    	rotate([0,0,0])
    	  ElBody();
    
      translate([10,15,0])
    	rotate([0,0,215])					// mis-align top fill from ElBody
    	  ElPlate();
    
      translate([20,-20,0])
    	rotate([0,0,-45])
    	  HelmetPlate();
    
      if (Layout == "Show")
    	ShowPegGrid(PegSize);
    
    }
    
    if ((Layout == "Fit") && Examine == "None") {
      translate([0,0,-(AzMountLength/2 + MirrorShaftOffset)])
    	color(MFG) AzMount();
    
      translate([0,0,AzMountLength/2 - MirrorShaftOffset - BearingOverlap])
    	color(DHC) ElMount();
    //	color([  0/255, 204/255, 204/255,0.5]) ElMount();
    
    	translate([ElMountDia/2 + ElMountBase,0,0])
    	  rotate([0,90,0])
    		color(DFC) ElBody();
    
    	translate([ElPlatePlusX,0,0])
    	  rotate([180,90,0])
    		color(LHC) ElPlate();
    
    	translate([ElPlatePlusX,0,ElPlateTall/2 - ElBodyWidth/2])
    	  rotate([0,90,0])
    		color(LWM) HelmetPlate();
    }