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.

Category: Software

General-purpose computers doing something specific

  • PiHole with DNS-over-HTTP: Revised

    More than a year later, the PiHole continues to work fine, but the process for installing the Cloudflare DoH machinery has evolved.

    (And, yes, it’s supposed to be DNS-over-HTTPS. So it goes.)

    To forestall link rot, the key points:

    cd /tmp ;  wget https://bin.equinox.io/c/VdrWdbjqyF/cloudflared-stable-linux-arm.tgz
    tar -xvzf cloudflared-stable-linux-arm.tgz 
    sudo cp cloudflared /usr/local/bin
    sudo chmod +x /usr/local/bin/cloudflared
    sudo cloudflared -v
    sudo useradd -s /usr/sbin/nologin -r -M cloudflared
    sudo nano /etc/default/cloudflared
    ----
    CLOUDFLARED_OPTS=--port 5053 --upstream https://1.1.1.1/dns-query --upstream https://1.0.0.1/dns-query 
    ----
    sudo chown cloudflared:cloudflared /etc/default/cloudflared
    sudo chown cloudflared:cloudflared /usr/local/bin/cloudflared
    sudo nano /etc/systemd/system/cloudflared.service
    ----
    [Unit]
    Description=cloudflared DNS over HTTPS proxy
    After=syslog.target network-online.target
    
    [Service]
    Type=simple
    User=cloudflared
    EnvironmentFile=/etc/default/cloudflared
    ExecStart=/usr/local/bin/cloudflared proxy-dns $CLOUDFLARED_OPTS
    Restart=on-failure
    RestartSec=10
    KillMode=process
    
    [Install]
    WantedBy=multi-user.target
    ----
    sudo systemctl enable cloudflared
    sudo systemctl start cloudflared
    sudo systemctl status cloudflared

    Then aim PiHole’s DNS at 127.0.0.1#5053. It used to be on port #54, for whatever that’s worth.

    Verify it at https://1.1.1.1/help, which should tell you DoH is in full effect.

    To update the daemon, which I probably won’t remember:

    wget https://bin.equinox.io/c/VdrWdbjqyF/cloudflared-stable-linux-arm.tgz
    tar -xvzf cloudflared-stable-linux-arm.tgz
    sudo systemctl stop cloudflared
    sudo cp ./cloudflared /usr/local/bin
    sudo chmod +x /usr/local/bin/cloudflared
    sudo systemctl start cloudflared
    cloudflared -v
    sudo systemctl status cloudflared

    And then It Just Works … again!

  • Garden Hose Valve Wrench: Reinforced

    Garden Hose Valve Wrench: Reinforced

    After five gardening seasons, my simple 3D printed wrench broke:

    Hose Valve Knob - fractured
    Hose Valve Knob – fractured

    Although Jason’s comment suggesting carbon-fiber reinforcing rods didn’t prompt me to lay in a stock, ordinary music wire should serve the same purpose:

    Hose Valve Knob - cut pins
    Hose Valve Knob – cut pins

    The pins are 1.6 mm diameter and 20 mm long, chopped off with hardened diagonal cutters. Next time, I must (remember to) grind the ends flat.

    The solid model needs holes in appropriate spots:

    Hose Valve Knob - Reinforced - Slic3r
    Hose Valve Knob – Reinforced – Slic3r

    Yes, I’m going to put round pins in square holes, without drilling the holes to the proper diameter: no epoxy, no adhesive, just 20 mm of pure friction.

    The drill press aligns the pins:

    Hose Valve Knob - pin ready
    Hose Valve Knob – pin ready

    And rams them about halfway down:

    Hose Valve Knob - pin midway
    Hose Valve Knob – pin midway

    Close the chuck jaws and shove them flush with the surface:

    Hose Valve Knob - pins installed
    Hose Valve Knob – pins installed

    You can see the pins and their solid plastic shells through the wrench stem:

    Hose Valve Knob - assembled
    Hose Valve Knob – assembled

    Early testing shows the reinforced wrench works just as well as the previous version, even on some new valves sporting different handles, with an equally sloppy fit for all. No surprise: I just poked holes in the existing model and left all the other dimensions alone.

    The OpenSCAD source code as a GitHub Gist:

    // Hose connector knob
    // Ed Nisley KE4ZNU – June 2015
    // 2020-05 add reinforcing rods
    Layout = "Build"; // [Knob, Stem, Show, Build]
    RodHoles = true;
    //- Extrusion parameters – must match reality!
    /* [Hidden] */
    ThreadThick = 0.25;
    ThreadWidth = 0.40;
    function IntegerMultiple(Size,Unit) = Unit * ceil(Size / Unit);
    Protrusion = 0.1;
    HoleWindage = 0.2;
    //——
    // Dimensions
    /* [Dimensions] */
    RodOD = 1.6;
    RodAngle = 35;
    /* [Hidden] */
    StemOD = 30.0; // max OD for valve-to-valve clearance
    BossOD = 16.0; // single-ended handle boss
    SlotWidth = 13.0;
    SlotHeight = 10.0;
    StemInset = 10.0;
    StemLength = StemInset + SlotHeight + 25.0;
    StemSides = 2*4;
    Align = 0*180/StemSides; // 1* produces thinner jaw ends
    KnobOD1 = 70; // maximum dia without chamfer
    KnobOD2 = 60; // top dia
    KnobSides = 4*4;
    DomeHeight = 12; // dome shape above lobes
    KnobHeight = DomeHeight + 2*SlotHeight;
    DomeOD = KnobOD2 + (KnobOD1 – KnobOD2)*(DomeHeight/KnobHeight);
    DomeArcRad = (pow(KnobHeight,2) + pow(DomeOD,2)/4) / (2*DomeHeight);
    RodBCD = (StemOD + BossOD)/2;
    //- Adjust hole diameter to make the size come out right
    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);
    }
    //– Stem for valve handles
    module Stem() {
    difference() {
    rotate(Align)
    cylinder(d=StemOD,h=StemLength,$fn=StemSides);
    translate([0,0,SlotHeight/2 – Protrusion/2])
    cube([2*StemOD,SlotWidth,(SlotHeight + Protrusion)],center=true);
    translate([0,0,-Protrusion])
    cylinder(d=BossOD,h=SlotHeight,$fn=2*StemSides);
    if (RodHoles)
    for (i=[-1:1])
    rotate(i*RodAngle + 90)
    for (j=[-1,1])
    translate([j*RodBCD/2,0,-Protrusion])
    rotate(180/4)
    PolyCyl(RodOD,2*SlotHeight,4);
    }
    }
    //– Hand-friendly knob
    module KnobCap() {
    difference() {
    scale([1.0,0.75,1.0])
    rotate(180/KnobSides)
    intersection() {
    translate([0,0,(KnobHeight-DomeArcRad)])
    sphere(r=DomeArcRad,$fa=180/KnobSides);
    cylinder(r1=KnobOD1/2,r2=KnobOD2/2,h=KnobHeight,$fn=KnobSides);
    cylinder(r1=KnobOD2/2,r2=KnobOD1/2,h=KnobHeight,$fn=KnobSides);
    }
    translate([0,0,-Protrusion])
    rotate(Align)
    cylinder(d=(StemOD + 2*ThreadWidth),h=(StemInset + Protrusion),$fn=StemSides);
    }
    }
    //- Build it
    if (Layout == "Knob")
    KnobCap();
    if (Layout == "Stem")
    Stem();
    if (Layout == "Build") {
    translate([-KnobOD1/2,0,0])
    KnobCap();
    translate([StemOD/2,0,StemLength])
    rotate([180,0,0])
    Stem();
    }
    if (Layout == "Show") {
    translate([0,0,0])
    Stem();
    translate([0,0,StemLength – StemInset])
    KnobCap();
    }

  • Soaker Hose End Plug

    Soaker Hose End Plug

    One of the soaker hoses in Mary’s Vassar Farms garden split lengthwise near one end:

    Soaker Hose Plug - hose split
    Soaker Hose Plug – hose split

    Although the hose is fully depreciated, I thought it’d be worthwhile to cut off the damaged end and conjure an end cap to see if a simple plug can withstand 100 psi water pressure.

    A pair of Delrin (because I have it) plugs with serrations fill the hose channels, with the outer clamp squishing the hose against them:

    Soaker Hose Plug - channel plugs - side view
    Soaker Hose Plug – channel plugs – side view

    In real life, they’ll be pushed completely into the hose, with a generous layer of silicone snot caulk improving their griptivity.

    I started with 8 mm plugs, but they didn’t quite fill the channels:

    Soaker Hose Plug - channel plugs - 8 mm test fit
    Soaker Hose Plug – channel plugs – 8 mm test fit

    Going to 8.5 mm worked better, although there’s really no way to force the granulated rubber shape into a snug fit around a cylinder:

    Soaker Hose Plug - channel plugs test fit
    Soaker Hose Plug – channel plugs test fit

    Fortunately, they need not be leakproof, because leaking is what the hose does for a living. Well, did for a living, back before it died.

    The clamps have a solid endstop, although it’s more to tidy the end than to hold the plugs in place:

    Soaker Hose End Plug - Slic3r
    Soaker Hose End Plug – Slic3r

    The clamps need aluminum backing plates to distribute the stress evenly across their flat sides:

    Soaker Hose Plug - installed
    Soaker Hose Plug – installed

    Those are 8-32 stainless steel screws. The standard 1 inch length worked out exactly right through no fault of my own.

    The OpenSCAD source code as a GitHub Gist:

    // Rubber Soaker Hose End Plug
    // Ed Nisley KE4ZNU June 2019
    // 2020-05 Two-channel hose end plug
    Layout = "Hose"; // [Hose,Block,Show,Build]
    //- Extrusion parameters must match reality!
    /* [Hidden] */
    ThreadThick = 0.25;
    ThreadWidth = 0.40;
    HoleWindage = 0.2;
    Protrusion = 0.1; // make holes end cleanly
    inch = 25.4;
    function IntegerMultiple(Size,Unit) = Unit * ceil(Size / Unit);
    //———-
    // Dimensions
    // Hose lies along X axis
    HoseTubeOD = 12.0; // water tube diameter
    HoseTubeOC = 12.5; // .. spacing
    HoseWebThick = 7.8; // center joining tubes
    Hose = [100,25.0,HoseTubeOD]; // X=very long, Y=overall width, Z=thickness
    HoseSides = 12*4;
    PlugLength = 25.0; // plugs in hose channels
    PlateThick = 5.0; // end block thickness
    WallThick = 2.0; // overall minimum thickness
    Kerf = 0.75; // cut through middle to apply compression
    ID = 0;
    OD = 1;
    LENGTH = 2;
    // 8-32 stainless screws
    Screw = [4.1,8.0,3.0]; // OD = head LENGTH = head thickness
    Washer = [4.4,9.5,1.0];
    Nut = [4.1,9.7,6.0];
    CornerRadius = Washer[OD]/2;
    ScrewOC = Hose.y + Washer[OD];
    echo(str("Screw OC: ",ScrewOC));
    BlockOAL = [PlugLength + PlateThick,ScrewOC + Washer[OD],2*WallThick + Hose.z]; // overall splice block size
    echo(str("Block: ",BlockOAL));
    //———————-
    // 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(d=(FixDia + HoleWindage),h=Height,$fn=Sides);
    }
    // Hose shape
    module HoseProfile() {
    rotate([0,-90,0])
    translate([0,0,-Hose.x/2])
    linear_extrude(height=Hose.x,convexity=4)
    union() {
    for (j=[-1,1]) // outer channels
    translate([0,j*HoseTubeOC/2])
    circle(d=HoseTubeOD,$fn=HoseSides);
    translate([0,0])
    square([HoseWebThick,HoseTubeOC],center=true);
    }
    }
    // Outside shape of splice Block
    // Z centered on hose rim circles, not overall thickness through center ridge
    module SpliceBlock() {
    difference() {
    hull()
    for (i=[-1,1], j=[-1,1]) // rounded block
    translate([i*(BlockOAL.x/2 – CornerRadius),j*(BlockOAL.y/2 – CornerRadius),-BlockOAL.z/2])
    cylinder(r=CornerRadius,h=BlockOAL.z,$fn=4*8);
    for (j=[-1,1]) // screw holes
    translate([0,
    j*ScrewOC/2,
    -(BlockOAL.z/2 + Protrusion)])
    PolyCyl(Screw[ID],BlockOAL.z + 2*Protrusion,6);
    cube([2*BlockOAL.x,2*BlockOAL.y,Kerf],center=true); // slice through center
    }
    }
    // Splice block less hose
    module ShapedBlock() {
    difference() {
    SpliceBlock();
    translate([(-Hose.x/2) + (BlockOAL.x/2) – PlateThick,0,0])
    HoseProfile();
    }
    }
    //———-
    // Build them
    if (Layout == "Hose")
    HoseProfile();
    if (Layout == "Block")
    SpliceBlock();
    if (Layout == "Show") {
    ShapedBlock();
    translate([(-Hose.x/2) + (BlockOAL.x/2) – PlateThick,0,0])
    color("Green",0.25)
    HoseProfile();
    }
    if (Layout == "Build") {
    SliceOffset = 0;
    intersection() {
    translate([SliceOffset,0,BlockOAL.z/4])
    cube([4*BlockOAL.x,4*BlockOAL.y,BlockOAL.z/2],center=true);
    union() {
    translate([0,0.6*BlockOAL.y,BlockOAL.z/2])
    ShapedBlock();
    translate([0,-0.6*BlockOAL.y,BlockOAL.z/2])
    rotate([0,180,0])
    ShapedBlock();
    }
    }
    }

    The original doodle, with dimensions vaguely related to the final model:

    Soaker Hose End Plug - hose dimensions
    Soaker Hose End Plug – hose dimensions

    There is, as far as I can tell, no standardization of dimensions or shapes across manufacturers, apart from the threaded hose fittings.

  • Glass Tiles: 2×2 Matrix

    Glass Tiles: 2×2 Matrix

    Start with a single cell holding a glass tile over a WS2812 RGB LED:

    Glass Tile - 1x1 cell test - purple phase
    Glass Tile – 1×1 cell test – purple phase

    A bit of OpenSCAD tinkering produces a simple 2×2 array with square interiors as a test piece:

    Glass Tile - 2x2 - PETG strings
    Glass Tile – 2×2 – PETG strings

    The excessive stringing and the booger in the upper-left cell come from absurdly thin infill tucked into the too-thin walls; Slic3r doesn’t (seem to) have a “minimum infill width” setting and it’ll desperately try to fit infill between two nearly adjacent perimeter threads.

    The little support spiders under the LED PCB recesses snapped right out, though, so I got that part right:

    Glass Tile - 2x2 - support spiders
    Glass Tile – 2×2 – support spiders

    The perimeter threads around the LED aperture aren’t quite fused, because it was only one layer thick and that’s not enough.

    A quick test with two LEDs showed the white PETG let far too much light bleed between the cells, which was no surprise from the single cell test piece.

    Fortunately, it’s all parametric, so a bit more tinkering produced a slightly chunkier matrix with a base for an Arduino Nano and M3 threaded brass inserts for the screws holding it together:

    Glass Tile Frame - 2x2 - Arduino Nano base - solid model
    Glass Tile Frame – 2×2 – Arduino Nano base – solid model

    Those two parts require about three hours of printing, much faster than I could produce them by milling pockets into aluminum or black acrylic slabs, and came out with minimal stringing.

    A little cleanup, some epoxy work, and a few dabs of solder later:

    Glass Tile - 2x2 - Arduino wiring
    Glass Tile – 2×2 – Arduino wiring

    An initial lamp test showed the white-ish glass tiles aren’t all quite the same color:

    Glass Tile - 2x2 - white color variation
    Glass Tile – 2×2 – white color variation

    I thought it was an LED color variation, too, but the slightly blue tint in the lower left corner followed the tile.

    The blurred horizontal strip across the middle is adhesive tape holding the tiles in place; I was reluctant to glue them in before being sure this whole thing would work. A peek into the future, though, shows it’s got potential:

    Glass Tile - 2x2 - first two units
    Glass Tile – 2×2 – first two units

    They do give off a definite Windows logo vibe, don’t they?

    The OpenSCAD source code as a GitHub Gist:

    // Illuminated Tile Grid
    // Ed Nisley – KE4ZNU
    // 2020-05
    /* [Configuration] */
    Layout = "Build"; // [Cell,CellArray,MCU,Base,Show,Build]
    Shape = "Square"; // [Square, Pyramid, Cone]
    Cells = [2,2];
    CellDepth = 15.0;
    Support = true;
    Inserts = true;
    /* [Hidden] */
    ThreadThick = 0.25;
    ThreadWidth = 0.40;
    HoleWindage = 0.2;
    function IntegerMultiple(Size,Unit) = Unit * ceil(Size / Unit);
    Protrusion = 0.1; // make holes end cleanly
    ID = 0;
    OD = 1;
    LENGTH = 2;
    Tile = [25.0 + 0.1,25.0 + 0.1,4.0];
    WallThick = 3*ThreadWidth;
    Flange = [4*ThreadWidth,4*ThreadWidth,0]; // ridge supporting tile
    Separator = [3*ThreadWidth,3*ThreadWidth,Tile.z – 1]; // between tiles
    Screw = [3.0,6.0,3.5]; // M3 SHCS, OD=head, LENGTH=head
    Insert = [3.0,4.2,8.0]; // threaded brass insert
    PCB = [15.0,8.0,2.5];
    LED = [5.0 + 2*HoleWindage,5.0 + 2*HoleWindage,1.0];
    LEDOffset = [0.0,(PCB.y – LED.y)/2 – 0.5,0.0]; // slight offset from +Y PCB edge
    CellOAL = [Tile.x,Tile.y,0] + Separator + [0,0,CellDepth] + [0,0,WallThick] + [0,0,PCB.z];
    ArrayOAL = [Cells.x*CellOAL.x,Cells.y*CellOAL.y,CellOAL.z]; // just the LED cells
    BlockOAL = ArrayOAL + [2*WallThick,2*WallThick,0]; // LED cells + exterior wall
    echo(str("Block OAL: ",BlockOAL));
    InsertOC = ArrayOAL – [Insert[OD],Insert[OD],0] – [2*WallThick,2*WallThick,0];
    echo(str("Insert OC: ",InsertOC));
    TapeThick = 1.0;
    Arduino = [44.0,18.0,8.0 + TapeThick]; // Arduino Nano to top of USB Mini-B plug
    USBPlug = [15.0,11.0,8.5]; // USB Mini-B plug insulator
    USBOffset = [0,0,5.5]; // offset from PCB base
    WiringBay = [BlockOAL.x – 4*WallThick,38.0,3.0];
    PlateOAL = [BlockOAL.x,BlockOAL.y,WallThick + Arduino.z + WiringBay.z];
    echo(str("Base Plate: ",PlateOAL));
    //————————
    module PolyCyl(Dia,Height,ForceSides=0) { // based on nophead's polyholes
    Sides = (ForceSides != 0) ? ForceSides : (ceil(Dia) + 2);
    FixDia = Dia / cos(180/Sides);
    cylinder(d=(FixDia + HoleWindage),h=Height,$fn=Sides);
    }
    //———————–
    // Base and optics in single tile
    module LEDCone() {
    hull() {
    translate([0,0,CellDepth + Tile.z/2])
    cube(Tile – [Flange.x,Flange.y,0],center=true);
    if (Shape == "Square") {
    translate([0,0,LED.z/2])
    cube([Tile.x,Tile.y,LED.z] – [Flange.x,Flange.y,0],center=true);
    }
    else if (Shape == "Pyramid") {
    translate([0,0,LED.z/2])
    cube(LED,center=true);
    }
    else if (Shape == "Cone") {
    translate([0,0,LED.z/2])
    cylinder(d=1.5*LED.x,h=LED.z,center=true);
    }
    else {
    echo(str("Whoopsie! Invalid Shape: ",Shape));
    cube(5);
    }
    }
    }
    // One complete LED cell
    module LEDCell() {
    difference() {
    translate([0,0,CellOAL.z/2])
    cube(CellOAL,center=true);
    translate([0,0,CellOAL.z – Separator.z + Tile.z/2])
    cube(Tile,center=true);
    translate([0,0,PCB.z + WallThick])
    LEDCone();
    cube([LED.x,LED.y,CellOAL.z],center=true);
    translate(-LEDOffset + [0,0,PCB.z/2 – Protrusion/2])
    cube(PCB + [0,0,Protrusion],center=true);
    }
    if (Support)
    color("Yellow") render()
    translate(-LEDOffset) {
    // translate([0,0,ThreadThick/2])
    // cube([PCB.x – 2*ThreadWidth,PCB.y – 2*ThreadWidth,ThreadThick],center=true);
    intersection() {
    translate([0,0,(PCB.z – ThreadThick)/2])
    cube([PCB.x – 2*ThreadWidth,PCB.y – 2*ThreadWidth,PCB.z – ThreadThick],center=true);
    union() { for (a=[0:22.5:359])
    rotate(a)
    translate([PCB.x/2,0,PCB.z/2])
    cube([PCB.x,2*ThreadWidth,PCB.z],center=true); }
    }
    }
    }
    // The whole array of cells
    module CellArray() {
    difference() {
    union() {
    translate([CellOAL.x/2 – Cells.x*CellOAL.x/2,CellOAL.y/2 – Cells.y*CellOAL.y/2,0])
    for (i=[0:Cells.x – 1], j=[0:Cells.y – 1])
    translate([i*CellOAL.x,j*CellOAL.y,0])
    LEDCell();
    if (Inserts) // bosses
    for (i=[-1,1], j=[-1,1])
    translate([i*InsertOC.x/2,j*InsertOC.y/2,0])
    rotate(180/8)
    cylinder(d=Insert[OD] + 3*WallThick,h=Insert[LENGTH],$fn=8);
    }
    if (Inserts) // holes
    for (i=[-1,1], j=[-1,1])
    translate([i*InsertOC.x/2,j*InsertOC.y/2,-Protrusion])
    rotate(180/8)
    PolyCyl(Insert[OD],Insert[LENGTH] + WallThick + Protrusion,8);
    }
    difference() {
    translate([0,0,CellOAL.z/2])
    cube(BlockOAL,center=true);
    translate([0,0,CellOAL.z])
    cube(ArrayOAL + [0,0,2*CellOAL.z],center=true);
    }
    }
    // Arduino bounding box
    // Origin at center bottom of PCB
    module Controller() {
    union() {
    translate([0,0,Arduino.z/2])
    cube(Arduino,center=true);
    translate([Arduino.x/2 – Protrusion,-USBPlug.y/2,USBOffset.z + TapeThick – USBPlug.z/2])
    cube(USBPlug + [Protrusion,0,0],center=false);
    }
    }
    // Baseplate
    module BasePlate() {
    difference() {
    translate([0,0,PlateOAL.z/2])
    cube(PlateOAL,center=true);
    translate([0,0,WallThick])
    Controller();
    translate([0,0,WallThick + PlateOAL.z/2])
    cube([Arduino.x – 2*2.0,WiringBay.y,PlateOAL.z],center=true);
    translate([0,0,PlateOAL.z – WiringBay.z + WiringBay.z/2])
    cube(WiringBay + [0,0,2*Protrusion],center=true);
    for (i=[-1,1], j=[-1,1])
    translate([i*InsertOC.x/2,j*InsertOC.y/2,-Protrusion])
    rotate(180/8) {
    PolyCyl(Screw[ID],2*PlateOAL.z,8);
    PolyCyl(Screw[OD],Screw[LENGTH] + 4*ThreadThick + Protrusion,8);
    }
    translate([0,0,ThreadThick-Protrusion])
    cube([17.0,45,2*ThreadThick],center=true);
    }
    linear_extrude(height=2*ThreadWidth + Protrusion) {
    translate([1,0,-Protrusion])
    rotate(-90) mirror([1,0,0])
    text(text="Ed Nisley",size=6,font="Arial:style:Bold",halign="center");
    translate([-6.5,0,-Protrusion])
    rotate(-90) mirror([1,0,0])
    text(text="softsolder.com",size=4.5,font="Arial:style:Bold",halign="center");
    }
    if (Support)
    color("Yellow")
    for (i=[-1,1], j=[-1,1])
    translate([i*InsertOC.x/2,j*InsertOC.y/2,0])
    for (a=[0:45:135])
    rotate(a)
    translate([0,0,(Screw[LENGTH] – ThreadThick)/2])
    cube([Screw[OD] – 2*ThreadWidth,2*ThreadWidth,Screw[LENGTH] – ThreadThick],center=true);
    }
    //———————–
    // Build things
    if (Layout == "Cell")
    LEDCell();
    else if (Layout == "CellArray")
    CellArray();
    else if (Layout == "MCU")
    Controller();
    else if (Layout == "Base")
    BasePlate();
    else if (Layout == "Show") {
    translate([0,0,PlateOAL.z + 10])
    CellArray();
    BasePlate();
    }
    else if (Layout == "Build") {
    translate([0,0.6*BlockOAL.y,0])
    CellArray();
    translate([0,-0.6*BlockOAL.y,0])
    rotate(90)
    BasePlate();
    }

  • Mini-lathe Metric Threading: Stackable Change Gear Generator

    Mini-lathe Metric Threading: Stackable Change Gear Generator

    Although OpenSCAD’s MCAD library includes a gear generator, I don’t profess to understand the relations between reality and its myriad parameters, plus I vaguely recall it has a peculiar definition for Diametral Pitch (or some such). Rather than fiddle with all that, I start with an SVG outline from Inkscape’s Gears extension and go all 3D on it.

    So, the “gear blank” looks like this after extruding the SVG:

    Mini-lathe change gear - 42 tooth - SVG import
    Mini-lathe change gear – 42 tooth – SVG import

    Producing this is a lot easier in OpenSCAD than in real life:

    Mini-lathe change gear - 42 tooth - solid model
    Mini-lathe change gear – 42 tooth – solid model

    OpenSCAD centers the blank’s bounding box at XY=0, which won’t be exactly on the bore centerline for gears with an odd number of teeth. One tooth sits at 0° and two teeth bracket 180°, so the bounding box will be a little short on one side

    A reference for gear nomenclature & calculations will come in handy.

    For a 21 tooth module 1 gear, which should be pretty close to the worst case in terms of offset:

    • Pitch dia = d = 21 × 1 = 21 mm
    • Tip dia = da = d + 2m = 23 mm
    • Tip radius = da/2 = 11.5 mm
    • Tooth-to-tooth angle = 360/21 = 17.143°
    • Radius to tangent across adjacent teeth = 11.5 × cos 17.143°/2 = 11.372 mm

    An actual metal 21 tooth gear measures 22.87 mm across a diameter, dead on what those numbers predict: 11.5 + 11.372 = 22.872 mm.

    So the bounding box will be 11.5 mm toward the tooth at 0° and 11.372 mm toward the gap at 180°. The offset will be half that, with the tooth at 0° sitting 0.063 mm too close to the origin. Gears with more teeth will have smaller errors.

    Given that we’re dealing with a gear “machined” from plastic goo, that’s definitely close enough:

    Mini-Lathe change gears - 1 mm - 45-50-45-60
    Mini-Lathe change gears – 1 mm – 45-50-45-60

    That’s an earlier version with the debossed legend.

    The code can also generate stacked gears for the BC shaft in the middle:

    Mini-lathe change gear - 42-55 tooth stacked - solid model
    Mini-lathe change gear – 42-55 tooth stacked – solid model

    In principle, the key locking the gears together isn’t needed and the bore could fit the inner shaft, rather than the keyed bushing, but then you’d (well, I’d) be at risk of losing the bushing + key in one easy operation.

    So it’s better to go with the bushing:

    Mini-Lathe change gears - stacked 50-42 - installed
    Mini-Lathe change gears – stacked 50-42 – installed

    Now, to cut some threads!

    The OpenSCAD source code as a GitHub Gist:

    // LMS Mini-Lathe
    // Change gears with stacking
    // Generate SVG outlines with Inkscape's Gear extension
    // Ed Nisley – KE4ZNU
    // 2020-05
    /* [Gears] */
    TopGear = 0; // zero for single gear
    BottomGear = 42;
    /* [Hidden] */
    ThreadThick = 0.25;
    ThreadWidth = 0.40;
    HoleWindage = 0.2;
    function IntegerMultiple(Size,Unit) = Unit * ceil(Size / Unit);
    Protrusion = 0.1; // make holes end cleanly
    Dir = ""; // empty string for current directory
    /* [Dimensions] */
    ShaftOD = 12.0;
    ShaftSides = 4*3;
    GearThick = 7.75;
    Keyway = [3.5 + HoleWindage,3.0 + HoleWindage,3*GearThick]; // x on radius, y on perim, z on axis
    LegendThick = 2*ThreadThick;
    LegendZ = (TopGear ? 2*GearThick : GearThick) – LegendThick;
    LegendRecess = [10,7,LegendThick];
    LegendEnable = (TopGear == 0 && BottomGear > 41) || (TopGear > 41);
    //———————-
    // Useful routines
    // Enlarge holes to prevent geometric shrinkage
    // based on nophead's polyholes
    // http://hydraraptor.blogspot.com/2011/02/polyholes.html
    // http://www.thingiverse.com/thing:6118
    module PolyCyl(Dia,Height,ForceSides=0) {
    Sides = (ForceSides != 0) ? ForceSides : (ceil(Dia) + 2);
    FixDia = Dia / cos(180/Sides);
    cylinder(r=(FixDia + HoleWindage)/2,
    h=Height,
    $fn=Sides);
    }
    //———————–
    // Build it!
    union() {
    difference() {
    union() {
    linear_extrude(GearThick,center=false,convexity=5)
    import(file=str(Dir,"Change Gear – ",BottomGear," teeth.svg"),
    center=true);
    if (TopGear)
    translate([0,0,GearThick])
    linear_extrude(GearThick,center=false,convexity=5)
    import(file=str(Dir,"Change Gear – ",TopGear," teeth.svg"),
    center=true);
    }
    rotate(180/ShaftSides)
    translate([0,0,-Protrusion])
    PolyCyl(ShaftOD,3*GearThick);
    translate([ShaftOD/2,0,Keyway.z/2 – Protrusion])
    cube(Keyway,center=true);
    if (LegendEnable) {
    translate([0,1.1*ShaftOD,LegendZ + LegendRecess.z/2])
    cube(LegendRecess + [0,0,Protrusion],center=true);
    if (TopGear) {
    translate([0,-1.1*ShaftOD,LegendZ + LegendRecess.z/2])
    cube(LegendRecess + [0,0,Protrusion],center=true);
    }
    }
    }
    if (LegendEnable)
    translate([0,0,LegendZ – Protrusion])
    linear_extrude(height=LegendThick + Protrusion,convexity=10) {
    translate([-0*2.5,1.1*ShaftOD])
    rotate(-0*90)
    text(text=str(BottomGear),size=5,font="Arial:style:Bold",halign="center",valign="center");
    if (TopGear)
    translate([-0*2.5,-1.1*ShaftOD])
    rotate(-0*90)
    text(text=str(TopGear),size=5,font="Arial:style:Bold",halign="center",valign="center");
    }
    }

  • Mini-Lathe Metric Threading: 42 Tooth Gear

    Mini-Lathe Metric Threading: 42 Tooth Gear

    Going from a 21 tooth gear to a 42 tooth gear means you must reduce the remaining train ratio by a factor of two for a given thread pitch. Here’s a 42-50-45-60 train, with the same -125 ppm error as the 21-50-60-40 train and no screw / washer clearance issues between the A screw and the C gear:

    Mini-Lathe change gears - 1 mm - 45-50-45-60
    Mini-Lathe change gears – 1 mm – 45-50-45-60

    The original 60-40 CD pair has a 3:2 ratio, the 45-60 CD pair is 3:4, so that’s where the factor-of-two reduction happens.

    The first pass at the solid model included a debossed legend:

    Mini-lathe 42 tooth change gear - Slic3r
    Mini-lathe 42 tooth change gear – Slic3r

    With a printed gear in hand, I realized the legend must be embossed below the surface, so as not to rub against an adjacent gear; better modeling is in order.

    The general idea is to set Inkscape’s (known-good) gear generator to the correct gear parameters (module 1 → 3.14 mm circular pitch, 20° pressure angle):

    Inkscape Gear Generator dialog
    Inkscape Gear Generator dialog

    Save the outline as an SVG:

    Inkscape Gear Generator result
    Inkscape Gear Generator result

    If you do like I did and neatly position the gear at the bottom-left origin, all SVG viewers will show only the Quadrant I arc, probably because Inkscape sets the SVG file to display it that way. I’ve made that mistake before and maybe, someday, I’ll remember.

    Load the SVG into OpenSCAD, which will find the entire gear, no matter where it falls in the coordinate space, and spike it at the origin:

    linear_extrude(8.0,center=false,convexity=5) 
     import(file="/the-source-directory/Mini-Lathe/Change Gear - 42 teeth.svg",center=true);
    

    The linear_extrude( … center=false … ) keeps the bottom of the blank at Z=0. The import( … center=true … ) puts the 2D shape at the XY origin. Because OpenSCAD centers the bounding box, gears with an odd number of teeth will be ever so slightly off-center, which would matter a whole lot more in a fancier machine tool than a mini-lathe.

    All of which produces a tidy 3D gear blank:

    Mini-lathe change gear - 42 tooth - SVG import
    Mini-lathe change gear – 42 tooth – SVG import

    OpenSCAD ignores SVG holes, which isn’t a problem for me, because I’d rather punch the bore, keyway, and so forth programatically.

    But that’s another story …

  • Nissan Fog Lamp: Arduino Firmware

    Nissan Fog Lamp: Arduino Firmware

    The upcycled Nissan fog lamp now has a desk stand:

    Nissan Fog Lamp - table mount
    Nissan Fog Lamp – table mount

    A knockoff Arduino Pro Mini atop a strip of foam tape drives the WS2812 RGB LEDs:

    Nissan Fog Lamp - table mount interior
    Nissan Fog Lamp – table mount interior

    Next time, I’ll cut the wires another inch longer.

    The firmware is a tidied-up version of the vacuum tube code, minus cruft, plus fixes, and generally better at doing what it does. The Pro Mini lacks a USB output, so this came from the same code running on a Nano:

    14:44:04.169 -> Algorithmic Art
    14:44:04.169 ->  RGB WS2812
    14:44:04.169 -> Ed Nisley - KE4ZNU - April 2020
    14:44:04.169 -> Lamp test: flash full-on colors
    14:44:04.169 ->  color: 00ff0000
    14:44:05.165 ->  color: 0000ff00
    14:44:06.160 ->  color: 000000ff
    14:44:07.155 ->  color: 00ffffff
    14:44:08.151 ->  color: 00000000
    14:44:09.180 -> Random seed: da98f7f6
    14:44:09.180 -> Primes: 7 19 3
    14:44:09.180 ->  Super cycle length: 199500 steps
    14:44:09.180 -> Inter-pixel phase: 1 deg = 26 steps
    14:44:09.180 ->  c: 0 Steps:  3500 Init:  1538 Phase:   2 deg PWM: 255
    14:44:09.180 ->  c: 1 Steps:  9500 Init:  7623 Phase:   0 deg PWM: 255
    14:44:09.213 ->  c: 2 Steps:  1500 Init:  1299 Phase:   6 deg PWM: 255
    14:44:19.265 -> Color 2     steps 1500  at 15101    ms 50       TS 201     
    14:45:34.293 -> Color 2     steps 1500  at 90136    ms 50       TS 1701    
    14:45:43.085 -> Color 1     steps 9500  at 98940    ms 50       TS 1877    
    14:45:47.332 -> Color 0     steps 3500  at 103192   ms 50       TS 1962    
    14:46:49.324 -> Color 2     steps 1500  at 165170   ms 50       TS 3201  
    … much snippage …
    17:26:52.896 -> Color 2     steps 1500  at 9769584  ms 50       TS 195201  
    17:28:07.926 -> Color 2     steps 1500  at 9844618  ms 50       TS 196701  
    17:29:11.000 -> Color 0     steps 3500  at 9907697  ms 50       TS 197962  
    17:29:22.974 -> Color 2     steps 1500  at 9919653  ms 50       TS 198201  
    17:30:27.941 -> Supercycle end, setting new color values
    17:30:27.941 -> Primes: 17 7 3
    17:30:27.941 ->  Super cycle length: 178500 steps
    17:30:27.941 -> Inter-pixel phase: 1 deg = 23 steps
    17:30:27.941 ->  c: 0 Steps:  8500 Init:  5415 Phase:   0 deg PWM: 255
    17:30:27.974 ->  c: 1 Steps:  3500 Init:  3131 Phase:   2 deg PWM: 255
    17:30:27.974 ->  c: 2 Steps:  1500 Init:   420 Phase:   5 deg PWM: 255
    17:30:46.394 -> Color 1     steps 3500  at 10003091 ms 50       TS 369     
    17:31:21.964 -> Color 2     steps 1500  at 10038658 ms 50       TS 1080  

    The “Super cycle length” is the number of 50 ms steps until the colors start repeating, something over an hour in that sample. When the code reaches the end of the supercycle, it picks another set of three prime numbers, reinitializes the color settings, and away it goes.

    The fog light looks pretty in action:

    Nissan Fog Lamp - blue phase
    Nissan Fog Lamp – blue phase

    The four LEDs don’t produce the same light pattern as the halogen filament and they’re distinctly visible when you squint against the glare:

    Nissan Fog Lamp - reflector LED detail
    Nissan Fog Lamp – reflector LED detail

    The shadow on the right comes from the larger hood support strut, the shadow on the left is the narrower strut, and the two other gaps show the beam angle gaps between the LEDs.

    You’ll see plenty of residual sandpaper scratches on the lens: my surface (re)finishing hand is weak.

    The LED beamwidth is so broad the “bulb” position inside the reflector doesn’t make much difference, particularly as it must, at most, wash a wall and ceiling at close range:

    Nissan Fog Lamp - wall wash light
    Nissan Fog Lamp – wall wash light

    All in all, a much-needed dose of Quality Shop Time.

    The Arduino source code as a GitHub Gist:

    // Neopixel Algorithmic Art
    // W2812 RGB Neopixel version
    // Ed Nisley – KE4ZNU
    #include <Adafruit_NeoPixel.h>
    #include <Entropy.h>
    //———-
    // Pin assignments
    const byte PIN_NEO = A3; // DO – data out to first Neopixel
    const byte PIN_HEARTBEAT = 13; // DO – Arduino LED
    #define PIN_MORSE 12
    //———-
    // Constants
    // number of pixels
    #define PIXELS 4
    // lag between adjacent pixels in degrees of slowest period
    #define PIXELPHASE 1
    // update LEDs only this many ms apart (minus loop() overhead)
    #define UPDATEINTERVAL 50ul
    #define UPDATEMS (UPDATEINTERVAL – 0ul)
    // number of steps per cycle, before applying prime factors
    #define RESOLUTION 500
    //———-
    // Globals
    Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXELS, PIN_NEO, NEO_GRB + NEO_KHZ800);
    uint32_t FullWhite = strip.Color(255,255,255);
    uint32_t FullOff = strip.Color(0,0,0);
    uint32_t MorseColor;
    struct pixcolor_t {
    unsigned int Prime;
    unsigned int NumSteps;
    unsigned int Step;
    float StepSize;
    float Phase;
    byte MaxPWM;
    };
    unsigned long int TotalSteps;
    unsigned long int SuperCycleSteps;
    byte PrimeList[] = {3,5,7,11,13,17,19,29}; // small primes = faster changes
    // colors in each LED and their count
    enum pixcolors {RED, GREEN, BLUE, PIXELSIZE};
    struct pixcolor_t Pixel[PIXELSIZE]; // all the data for each pixel color intensity
    uint32_t UniColor;
    unsigned long int MillisNow;
    unsigned long int MillisThen;
    //– Select three unique primes for the color generator function
    // Then compute all the step parameters based on those values
    void SetColorGenerators(void) {
    Pixel[RED].Prime = PrimeList[random(sizeof(PrimeList))];
    do {
    Pixel[GREEN].Prime = PrimeList[random(sizeof(PrimeList))];
    } while (Pixel[RED].Prime == Pixel[GREEN].Prime);
    do {
    Pixel[BLUE].Prime = PrimeList[random(sizeof(PrimeList))];
    } while (Pixel[BLUE].Prime == Pixel[RED].Prime ||
    Pixel[BLUE].Prime == Pixel[GREEN].Prime);
    if (false) {
    Pixel[RED].Prime = 1;
    Pixel[GREEN].Prime = 3;
    Pixel[BLUE].Prime = 5;
    }
    printf("Primes: %d %d %d\r\n",Pixel[RED].Prime,Pixel[GREEN].Prime,Pixel[BLUE].Prime);
    TotalSteps = 0;
    SuperCycleSteps = RESOLUTION;
    for (byte c = 0; c < PIXELSIZE; c++) {
    SuperCycleSteps *= Pixel[c].Prime;
    }
    printf(" Super cycle length: %lu steps\r\n",SuperCycleSteps);
    Pixel[RED].MaxPWM = 255;
    Pixel[GREEN].MaxPWM = 255;
    Pixel[BLUE].MaxPWM = 255;
    unsigned int PhaseSteps = (unsigned int) ((PIXELPHASE / 360.0) *
    RESOLUTION * (unsigned int) max(max(Pixel[RED].Prime,Pixel[GREEN].Prime),Pixel[BLUE].Prime));
    printf("Inter-pixel phase: %d deg = %d steps\r\n",(int)PIXELPHASE,PhaseSteps);
    for (byte c = 0; c < PIXELSIZE; c++) {
    Pixel[c].NumSteps = RESOLUTION * Pixel[c].Prime; // steps per cycle
    Pixel[c].StepSize = TWO_PI / Pixel[c].NumSteps; // radians per step
    Pixel[c].Step = random(Pixel[c].NumSteps); // current step
    Pixel[c].Phase = PhaseSteps * Pixel[c].StepSize; // phase in radians for this color
    printf(" c: %d Steps: %5d Init: %5d Phase: %3d deg",c,Pixel[c].NumSteps,Pixel[c].Step,(int)(Pixel[c].Phase * 360.0 / TWO_PI));
    printf(" PWM: %d\r\n",Pixel[c].MaxPWM);
    }
    }
    //– Helper routine for printf()
    int s_putc(char c, FILE *t) {
    Serial.write(c);
    }
    //——————
    // Set the mood
    void setup() {
    pinMode(PIN_HEARTBEAT,OUTPUT);
    digitalWrite(PIN_HEARTBEAT,LOW); // show we arrived
    Serial.begin(57600);
    fdevopen(&s_putc,0); // set up serial output for printf()
    printf("Algorithmic Art\r\n RGB WS2812\r\nEd Nisley – KE4ZNU – April 2020\r\n");
    Entropy.initialize(); // start up entropy collector
    // set up pixels
    strip.begin();
    strip.show();
    // lamp test: a brilliant white flash
    printf("Lamp test: flash full-on colors\r\n");
    uint32_t FullRGB = strip.Color(255,255,255);
    uint32_t FullR = strip.Color(255,0,0);
    uint32_t FullG = strip.Color(0,255,0);
    uint32_t FullB = strip.Color(0,0,255);
    uint32_t FullOff = strip.Color(0,0,0);
    uint32_t TestColors[] = {FullR,FullG,FullB,FullRGB,FullOff};
    for (byte i = 0; i < sizeof(TestColors)/sizeof(uint32_t) ; i++) {
    printf(" color: %08lx\r\n",TestColors[i]);
    for (int p=0; p < strip.numPixels(); p++) {
    strip.setPixelColor(p,TestColors[i]);
    }
    strip.show();
    delay(1000);
    }
    // get an actual random number
    uint32_t rn = Entropy.random();
    printf("Random seed: %08lx\r\n",rn);
    randomSeed(rn);
    // set up the color generators
    SetColorGenerators();
    MillisNow = MillisThen = millis();
    }
    //——————
    // Run the mood
    void loop() {
    MillisNow = millis();
    if ((MillisNow – MillisThen) >= UPDATEMS) { // time for another step?
    digitalWrite(PIN_HEARTBEAT,HIGH);
    TotalSteps++;
    strip.show(); // send out precomputed colors
    for (byte c = 0; c < PIXELSIZE; c++) { // compute next increment for each color
    if (++Pixel[c].Step >= Pixel[c].NumSteps) {
    Pixel[c].Step = 0;
    printf("Color %-5d steps %-5d at %-8ld ms %-8ld TS %-8lu\r\n",
    c,Pixel[c].NumSteps,MillisNow,(MillisNow – MillisThen),TotalSteps);
    }
    }
    // If all cycles have completed, reset the color generators
    if (TotalSteps >= SuperCycleSteps) {
    printf("Supercycle end, setting new color values\r\n");
    SetColorGenerators();
    }
    for (int p = 0; p < strip.numPixels(); p++) { // for each pixel
    byte Value[PIXELSIZE];
    for (byte c=0; c < PIXELSIZE; c++) { // compute new colors
    Value[c] = (Pixel[c].MaxPWM / 2.0) * (1.0 + sin(Pixel[c].Step * Pixel[c].StepSize – p*Pixel[c].Phase));
    }
    UniColor = strip.Color(Value[RED],Value[GREEN],Value[BLUE]);
    strip.setPixelColor(p,UniColor);
    }
    MillisThen = MillisNow;
    digitalWrite(PIN_HEARTBEAT,LOW);
    }
    }
    view raw AlgoArt-RGB.ino hosted with ❤ by GitHub