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: Improvements

Making the world a better place, one piece at a time

  • Layered Paper: SVG Generator

    Layered Paper: SVG Generator

    Changing the formula generating the matrix values and cleaning up some infelicitous code choices produces a much more pleasing result:

    Layered paper - circular rainbow
    Layered paper – circular rainbow

    The random squares still look OK, though:

    Layered Paper - SVG generator results
    Layered Paper – SVG generator results

    Thresholding the distance from a randomly chosen point creates circular rainbows:

    CenterPoint = (choice(range(args.width)),choice(range(args.height)))
    
    CellMatrix = [[math.hypot(x - CenterPoint[X],y - CenterPoint[Y])
                    for y in range(args.height)]
                    for x in range(args.width)]
    
    dmax = max(list(chain.from_iterable(CellMatrix)))
    
    LayerThreshold = (ThisLayer/Layers)*dmax
    

    The Python program generates one SVG image file representing a single layer, as determined by the Bash one-liner invoking it:

    for i in {00..16} ; do python Layers\ -\ 200mm.py > Test_$i.svg ; done
    

    In real life you’d also use a different random seed for each set of layers, but that’s just another command line optIon.

    Import those 17 SVG images into LightBurn, arrange neatly, snap each one to the middle of the workspace grid (and thus the aligned template), then Fire The Laser:

    Layered Blocks - circular colors - 200mm 16x16 - LightBurn layout
    Layered Blocks – circular colors – 200mm 16×16 – LightBurn layout

    Feeding paper into the laser in rainbow (actually, heavily augmented / infilled EIA color code) order, plus the black mask, produces the aforementioned pleasing result:

    Layered Paper - rainbow oblique view
    Layered Paper – rainbow oblique view

    Glue the sheets in the assembly fixture:

    Layered Paper - gluing fixture side view
    Layered Paper – gluing fixture side view

    The white layer is uncut, other than the four alignment holes (with a rivnut poking up) and its binary layer number (16, backwards because upside-down), and appears in only the farthest corners of the rainbow.

    Protip: doing the stack upside-down means you smear glue stick on the hidden side of each sheet. If you avoid slobbering glue into the cut square holes, nothing can go wrong.

    Making these things produces the happiest chip tray ever:

    Layered Paper - rainbow chip tray
    Layered Paper – rainbow chip tray

    I swept half a dozen pictures worth of squares into a small box and gave it away to someone with a larger small-child cross-section than mine, whereupon a slight finger fumble turned the contents into a glitter bomb. Sorry ’bout that.

    The Python source code as a GitHub Gist:

    # Generator for rainbow block layered paper
    # Ed Nisley – KE4ZNU
    # 2025-08-03 cargo-culted from svg library examples
    import svg
    import math
    from argparse import ArgumentParser
    from random import randint, choice, seed
    from itertools import chain
    from pprint import pprint
    INCH = 25.4
    X = 0
    Y = 1
    def as_mm(number):
    return repr(number) + "mm"
    parser = ArgumentParser()
    parser.add_argument('–layernum', type=int, default=0)
    parser.add_argument('–colors', type=int, default=16)
    parser.add_argument('–seed', type=int, default=1)
    parser.add_argument('–width', type=int, default=16)
    parser.add_argument('–height', type=int, default=16)
    parser.add_argument('–debug', default=False)
    args = parser.parse_args()
    PageSize = (round(8.5*INCH,3), round(11.0*INCH,3))
    SheetCenter = (PageSize[X]/2,PageSize[X]/2) # symmetric on Y!
    SheetSize = (200,200) # overall sheet
    AlignOC = (180,180) # alignment pins in corners
    AlignOD = 5.0 # … pin diameter
    MatrixOA = (170,170) # outer limit of cell matrix
    CellCut = "black" # C00 Black
    SheetCut = "red" # C02 Red
    HeavyCut = "rgb(255,128,0)" # C05 Orange black mask paper is harder
    HeavyCellCut = "rgb(0,0,160)" # C09 Dark Blue ditto
    Tooling = "rgb(12,150,217)" # T2 Tool
    DefStroke = "0.2mm"
    DefFill = "none"
    ThisLayer = args.layernum # determines which cells get cut
    Layers = args.colors # black mask = 0, color n = not perforated
    SashWidth = 1.5 # between adjacent cells
    CellSize = ((MatrixOA[X] – (args.width – 1)*SashWidth)/args.width,
    (MatrixOA[Y] – (args.height – 1)*SashWidth)/args.height)
    CellOC = (CellSize[X] + SashWidth,CellSize[Y] + SashWidth)
    if args.seed:
    seed(args.seed)
    #— accumulate tooling layout
    ToolEls = []
    # mark center of sheet for drag-n-drop location
    ToolEls.append(
    svg.Circle(
    cx=SheetCenter[X],
    cy=SheetCenter[Y],
    r="2mm",
    stroke=Tooling,
    stroke_width=DefStroke,
    fill="none",
    )
    )
    # mark page perimeter for alignment check
    if False:
    ToolEls.append(
    svg.Rect(
    x=0,
    y=0,
    width=as_mm(PageSize[X]),
    height=as_mm(PageSize[Y]),
    stroke=Tooling,
    stroke_width=DefStroke,
    fill="none",
    )
    )
    # center huge box on matrix center
    if False:
    ToolEls.append(
    svg.Rect(
    x=as_mm(SheetCenter[X] – 2*SheetSize[X]/2),
    y=as_mm(SheetCenter[Y] – 2*SheetSize[Y]/2),
    width=as_mm(2*SheetSize[X]),
    height=as_mm(2*SheetSize[Y]),
    stroke=Tooling,
    stroke_width=DefStroke,
    fill="none",
    )
    )
    #— accumulate sheet cuts
    SheetEls = []
    # cut perimeter
    SheetEls.append(
    svg.Rect(
    x=as_mm(SheetCenter[X] – SheetSize[X]/2),
    y=as_mm(SheetCenter[Y] – SheetSize[Y]/2),
    width=as_mm(SheetSize[X]),
    height=as_mm(SheetSize[Y]),
    stroke=SheetCut if ThisLayer > 0 else HeavyCut,
    stroke_width=DefStroke,
    fill="none",
    ),
    )
    # cut layer ID holes except on mask layer
    if ThisLayer > 0:
    c = ((1,1))
    h = f'{ThisLayer:0{Layers.bit_length()}b}'
    for i in range(Layers.bit_length()):
    SheetEls.append(
    svg.Circle(
    cx=as_mm(SheetCenter[X] + c[X]*AlignOC[X]/2 – (i + 2)*AlignOD),
    cy=as_mm(SheetCenter[Y] + c[Y]*AlignOC[Y]/2),
    r=AlignOD/4 if h[-(i + 1)] == '1' else AlignOD/8,
    stroke=SheetCut,
    stroke_width=DefStroke,
    fill="none",
    )
    )
    # cut alignment pin holes except on mask layer
    if ThisLayer > 0:
    for c in ((1,1),(-1,1),(-1,-1),(1,-1)):
    SheetEls.append(
    svg.Circle(
    cx=as_mm(SheetCenter[X] + c[X]*AlignOC[X]/2),
    cy=as_mm(SheetCenter[Y] + c[Y]*AlignOC[Y]/2),
    r=as_mm(AlignOD/2),
    stroke=SheetCut,
    stroke_width=DefStroke,
    fill="none",
    )
    )
    #— calculate matrix contents
    CenterPoint = (choice(range(args.width)),choice(range(args.height)))
    CellMatrix = [[math.hypot(x – CenterPoint[X],y – CenterPoint[Y])
    for y in range(args.height)]
    for x in range(args.width)]
    dmax = max(list(chain.from_iterable(CellMatrix)))
    if args.debug:
    print(CenterPoint)
    print(dmax)
    pprint(CellMatrix)
    print()
    #— accumulate matrix cuts
    LayerThreshold = (ThisLayer/Layers)*dmax
    if args.debug:
    print(LayerThreshold)
    MatrixEls = []
    for i in range(args.width):
    x =i*CellOC[X]
    for j in range(args.height):
    y = j*CellOC[Y]
    if args.debug:
    print(i)
    print(j)
    print(CellMatrix[i][j])
    if ThisLayer == 0: # black mask
    s = HeavyCellCut
    elif LayerThreshold < CellMatrix[i][j]: # rest of sheets above color layer
    s = CellCut
    else:
    s = Tooling # at or below color layer
    MatrixEls.append(
    svg.Rect(
    x=as_mm(SheetCenter[X] – MatrixOA[X]/2 + x),
    y=as_mm(SheetCenter[Y] – MatrixOA[Y]/2 + y),
    width=as_mm(CellSize[X]),
    height=as_mm(CellSize[Y]),
    stroke=s,
    stroke_width=DefStroke,
    fill="none",
    )
    )
    #— assemble and blurt out the SVG file
    if not args.debug:
    canvas = svg.SVG(
    width=as_mm(PageSize[X]),
    height=as_mm(PageSize[Y]),
    elements=[
    ToolEls,
    SheetEls,
    MatrixEls
    ],
    )
    print(canvas)
  • Layered Paper: Random Block Generator MVP

    Layered Paper: Random Block Generator MVP

    This definitely isn’t ready for prime time, but it’s already much better than the manual process and a few notes are in order.

    The general idea is to have a Python program generate a set of SVG images, each one describing a single layer of paper in the stack:

    Layered Paper - Random Blocks - MVP - single layer
    Layered Paper – Random Blocks – MVP – single layer

    As expected, there’s a Python SVG library handling the details of creating SVG images.

    Define a bunch of “constants” with all the physical measurements and suchlike:

    PageSize = (round(8.5*INCH,3), round(11.0*INCH,3))
    
    SheetCenter = (PageSize[X]/2,PageSize[X]/2)     # symmetric on Y!
    
    SheetSize = (200,200)           # overall sheet
    
    AlignOC = (180,180)             # alignment pins in corners
    AlignOD = 5.0                    #  … pin diameter
    
    MatrixOA = (170,170)            # outer limit of cell matrix
    
    CellCut = "black"               # C00 Black
    SheetCut = "red"                # C02 Red
    HeavyCut = "rgb(255,128,0)"     # C05 Orange        black mask paper is harder
    HeavyCellCut = "rgb(0,0,160)"   # C09 Dark Blue     ditto
    Tooling = "rgb(12,150,217)"     # T2  Tool
    
    DefStroke = "0.2mm"
    DefFill = "none"
    

    Then marking the middle of the layout with that little circle looks like this:

    ToolEls = []                    # accumulates tooling layout
    # mark center of sheet for drag-n-drop location
    ToolEls.append(
        svg.Circle(
            cx=SheetCenter[X],
            cy=SheetCenter[Y],
            r="2mm",
            stroke=Tooling,
            stroke_width=DefStroke,
            fill="none",
        )
    )
    

    Cutting the perimeter and four alignment holes:

    SheetEls = []                   # accumulates sheet cuts
    # cut perimeter
    SheetEls.append(
        svg.Rect(
            x=as_mm(SheetCenter[X] - SheetSize[X]/2),
            y=as_mm(SheetCenter[Y] - SheetSize[Y]/2),
            width=as_mm(SheetSize[X]),
            height=as_mm(SheetSize[Y]),
            stroke=SheetCut if ThisLayer > 0 else HeavyCut,
            stroke_width=DefStroke,
            fill="none",
        ),
    )
    # cut alignment pin holes except on mask layer
    if ThisLayer > 0:
        for c in ((1,1),(-1,1),(-1,-1),(1,-1)):
            SheetEls.append(
                svg.Circle(
                    cx=as_mm(SheetCenter[X] + c[X]*AlignOC[X]/2),
                    cy=as_mm(SheetCenter[Y] + c[Y]*AlignOC[Y]/2),
                    r=as_mm(AlignOD/2),
                    stroke=SheetCut,
                    stroke_width=DefStroke,
                    fill="none",
                )
            )
    

    Burning the layer ID in binary:

    # cut layer ID holes except on mask layer
    if ThisLayer > 0:
        c = ((1,1))
        h = f'{ThisLayer:0{Layers.bit_length()}b}'
        for i in range(Layers.bit_length()):
            SheetEls.append(
                svg.Circle(
                    cx=as_mm(SheetCenter[X] + c[X]*AlignOC[X]/2 - (i + 2)*AlignOD),
                    cy=as_mm(SheetCenter[Y] + c[Y]*AlignOC[Y]/2),
                    r=AlignOD/4 if h[-(i + 1)] == '1' else AlignOD/8,
                    stroke=SheetCut,
                    stroke_width=DefStroke,
                    fill="none",
                 )
            )
    

    Filling the matrix of blocks with random numbers turned out to be a one-liner:

    CellMatrix = [[randint(1,args.colors) for _ in range(args.height)] for _ in range(args.width)]
    
    

    That matrix is a constant for all the layers, which is why you must feed the program the same random number seed to generate the layers.

    Given the layer number and that matrix, deciding what to do for each hole is a walk through the cells:

    MatrixEls = []                  # accumulates matrix cuts
    for i in range(args.width):
        x =i*CellOC[X]
        for j in range(args.height):
            y = j*CellOC[Y]
    
            if ThisLayer == 0:                          # black mask
                s = HeavyCellCut
            elif ThisLayer < CellMatrix[i][j]:          # rest of sheets above color layer
                s = CellCut
            else:
                s = Tooling                             # at or below color layer
    
            MatrixEls.append(
                svg.Rect(
                    x=as_mm(SheetCenter[X] - MatrixOA[X]/2 + x),
                    y=as_mm(SheetCenter[Y] - MatrixOA[Y]/2 + y),
                    width=as_mm(CellSize[X]),
                    height=as_mm(CellSize[Y]),
                    stroke=s,
                    stroke_width=DefStroke,
                    fill="none",
                )
            )
    

    After accumulating all the other elements in similar lists, this creates and emits the entire SVG file to stdout:

    canvas = svg.SVG(
        width=as_mm(PageSize[X]),
        height=as_mm(PageSize[Y]),
        elements=[
            ToolEls,
            SheetEls,
            MatrixEls
        ],
    )
    
    print(canvas)
    

    The whole program has a bit more going on, but those are the high points.

    Invoke the program with a Bash one-liner:

    for i in {00..08} ; do python Layers.py --layernum=$i > Test_$i.svg ; done
    

    That produces nine SVG image files that you import into LightBurn and arrange in a tidy array:

    Layered Paper - Random Blocks - MVP - LightBurn import
    Layered Paper – Random Blocks – MVP – LightBurn import

    I discovered that holding down the Shift key while importing the SVG files stacks them at the workspace origin (the upper-right corner for my machine) in the order of the file names, so clicking on the stack selects successive layers in the right order; just drop each one wherever you need it, then tidy the lineup.

    The Python program sets the vector stroke colors using LightBurn palette values, so that LightBurn automagically assigns them to the appropriate layers. It turns out the black paper I used for the mask requires different speed / power values than the other colored paper.

    I put the alignment features on a different layer than the matrix holes to make them more visible, even though they have the same speed / power values.

    Align the template so the middle of the layer pattern is in the middle of the grid, then use LightBurn’s Print and Cut to align the template with the fixture on the laser platform:

    Layered Paper - Random Blocks - MVP - template
    Layered Paper – Random Blocks – MVP – template

    Then the process requires just a few clicks per layer:

    • Drop a sheet of paper into the fixture
    • Click to select a layer layout
    • Ctrl-D to duplicate it
    • P to snap it to the middle of the grid
    • Alt-S to Fire The Laser
    • Del to delete that layer (which is why it’s a duplicate!)
    • Iterate until done!

    Which looks pretty much like you’d expect:

    Layered Paper - Random Blocks - cutting
    Layered Paper – Random Blocks – cutting

    Take the stack of paper to the workbench, use an Xacto knife to cut the tabs holding the square into the Letter page, apply glue stick, stack in the fixture, and iterate to create a solid sheet with lots of holes:

    Layered Paper - Random Blocks - MVP
    Layered Paper – Random Blocks – MVP

    More refinement is in order, but that’s the overview …

  • PolyDryer Humidity: 30 Days Later

    PolyDryer Humidity: 30 Days Later

    A month after the last desiccant change, the silica gel looks like this:

    Polydryer - 30 day beads
    Polydryer – 30 day beads

    The top cup contains fresh-from-stock dry (regenerated) silica gel beads and the others, left-to-right and top-to-bottom, come from PolyDryer boxes:

    Material%RHWeight – gIncrease – gWater gain – %
    PETG White1426.81.87.2
    PETG Black2026.81.87.2
    PETG Orange1326.81.87.2
    PETG Blue1526.91.97.6
    PETG-CF Blue1927.42.49.6
    PETG-CF Black2827.32.39.2
    PETG-CF Gray2727.12.18.4
    TPU Clear1326.81.87.2
    Sum of weights215.98.0
    Measured weight216.38.1

    I expected some correlation between the indicated humidity and the weight of adsorbed water vapor, but that’s not the case.

    The bottom row suggests there’s also little-to-no correlation between bead color and humidity, at least at this low end of the scale.

    The indicator cards tucked into the boxes roughly correlate with the meter reading, but they’re much easier to interpret in person.

    The old chart of adsorption vs. relative humidity suggests the results are plausible, with the 27-ish %RH being higher than you’d expect from 9-ish % adsorption:

    Desiccant adsorption vs humidity
    Desiccant adsorption vs humidity

    So they’re all set up with 25 g of fresh silica gel, although the boxes no long have the same humidity meters they started with. This likely makes little difference, as I have no way to calibrate them.

  • CNC-3018XL: Reversing the Axes

    CNC-3018XL: Reversing the Axes

    The CNC-3018XL fit into its new home with the Run/Hold buttons toward the front:

    3018CNC - new orientation
    3018CNC – new orientation

    Which is rotated 180° from its previous orientation, putting Quadrant I and the most-positive coordinates in the left-front corner. Rather than stand on my head while trying to use the jog keypad upside-down, I reversed the axis directions by changing the GRBL Direction port invert mask value from its previous 4:

    $3=7

    Because the home switch positions haven’t changed, reverse the Homing dir invert mask from 0:

    $23=3

    The XY origin remains in the center of the platform, so the G54 XY offset didn’t change. The Z offset puts the Pilot pen tip 10 mm above the platform, which will change as you (well, I) touch it off on the paper:

    G10 L2 P1 X-169.0 Y-149.5 Z-44.0

    Jog to the left rear corner (with Z at the home position) and set the G28 park position:

    G28.1

    Jog to the right front corner (also Z homed) where (manual) tool changes take place:

    G30.1

    Configure bCNC for manual tool changes without probing at the G30 position:

    bCNC probe config
    bCNC probe config

    The machine will move to the tool change position at each Tn M6, the operator (that would be me) inserts tool pen n as needed, pokes the Run button, and watches it draw pretty pictures in a resolutely techie manner:

    3018CNC - Spirograph test pattern
    3018CNC – Spirograph test pattern

    For completeness, the current GRBL settings:

    $$
    $0=10
    $1=100
    $2=0
    $3=7
    $4=0
    $5=0
    $6=0
    $10=1
    $11=0.010
    $12=0.020
    $13=0
    $20=1
    $21=0
    $22=1
    $23=3
    $24=100.000
    $25=2000.000
    $26=25
    $27=1.250
    $30=1000
    $31=0
    $32=0
    $100=401.284
    $101=400.000
    $102=400.000
    $110=3000.000
    $111=3000.000
    $112=3000.000
    $120=1000.000
    $121=1000.000
    $122=1000.000
    $130=338.000
    $131=299.000
    $132=44.000
    $#
    [G54:-169.000,-149.500,-34.450]
    [G55:0.000,0.000,0.000]
    [G56:0.000,0.000,0.000]
    [G57:0.000,0.000,0.000]
    [G58:0.000,0.000,0.000]
    [G59:0.000,0.000,0.000]
    [G28:-335.000,-3.310,-3.450]
    [G30:-1.000,-297.000,-1.000]
    [G92:0.000,0.000,0.000]
    [TLO:0.000]
    [PRB:0.000,0.000,0.000:0]
    

    The weird $100 X axis step/mm value is correct, because QC escapes are a thing.

  • Kenmore 158 Sewing Machine: COB LEDs Redux

    Kenmore 158 Sewing Machine: COB LEDs Redux

    Having harvested the COB LED lighting from the Kenmore 158 Mary gave to a friend, I took advantage of a sewing pause to install the hardware on the 158 she now uses:

    Kenmore 158 - needle light detail
    Kenmore 158 – needle light detail

    That’s the sandblasted presser foot atop the original glare-y metal plates.

    For the record, this is inside the machine’s power connector:

    Kenmore 158 - power connector wiring
    Kenmore 158 – power connector wiring

    Power for the original glowworm incandescent light comes from the two rightmost terminals: 120 VAC switched by the machine’s power button. Those terminals now go to a new, much more flexy, cable for the 12 VDC power supply, with a step-up supply for the needle LEDs.

    An overview of the wire routing:

    Kenmore 158 - COB LED wire routing
    Kenmore 158 – COB LED wire routing

    There’s now a 9-pin JST SM connector between the repurposed serial cable and the LEDs, mostly so I can add another light bar to the front in the unlikely event it becomes necessary.

    The rear light bar wire once again burrows into the machine above the presser foot lever:

    Kenmore 158 - COB LED bar wire routing
    Kenmore 158 – COB LED bar wire routing

    All the LED wiring fans out through the endcap:

    Kenmore 158 - COB LED needle heatsink
    Kenmore 158 – COB LED needle heatsink

    You can just barely see the edge of the strip of LEDs epoxied to the bottom of the machine nose, on the right of the needle.

    If I were inclined to rebuild the needle LEDs, I’d use flexy silicone wiring instead of the Teflon insulated coax. The black insulation wouldn’t be nearly as pretty, but it’d be *way* easier to cut to length and solder.

    The patient survived the operation and sewing should resume shortly …

  • CNC-3018XL: Foam Feet

    CNC-3018XL: Foam Feet

    The 3018XL plotter now lives on a different bench than it grew up on and the stepper motors resonate the plywood benchtop wonderfully well. After finding the machine weighs enough to flatten small foam blocks under the Official Feet, I cut out four 60×80 mm foot pad brackets:

    3018XL - foam foot pad bracket
    3018XL – foam foot pad bracket

    They’re attached to the 2040 frame extrusions with M4 screws into tee nuts; the third hole is there just in case it became necessary. I’m not sure whether MDF will bend under that offset load, but having all four brackets perfectly fit into two pieces of MDF left over from previous projects was a compelling justification.

    Some utility knife work produced the foam pads from a big sheet of polyethylene packing material:

    3018XL - foam foot pad - installed
    3018XL – foam foot pad – installed

    A piece of double-sided duct tape with amazingly gooey adhesive joins foam and bracket.

    If the resonance was annoying to my deflicted hearing, it must have been pretty bad. Now, even Mary thinks it sounds OK.

    Now, to discover whether the machine’s weight squashes those big foam blocks.

  • Snowflake Coaster: One Year Later

    Snowflake Coaster: One Year Later

    After more-or-less constant use under a cup in the bathroom, a Snowflake Coaster has reached the end of its life:

    Snowflake coaster - 1 yr use
    Snowflake coaster – 1 yr use

    The acrylic flake is fine, but the wood has mildewed:

    Snowflake coaster - 1 yr use - detail
    Snowflake coaster – 1 yr use – detail

    It’s second from the left in the bottom row:

    Snowflake Coaster - assortment
    Snowflake Coaster – assortment

    All except the pair in the left column had a coat or two of rattlecan clear, which suggests wood-ish coasters need something much more durable, along the lines of clearcoat epoxy. No surprise there!