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: Electronics Workbench

Electrical & Electronic gadgets

  • LED Bulb: Mechanical FAIL

    LED Bulb: Mechanical FAIL

    Replacing the second torchiere lamp shade required unscrewing its 100 W equivalent LED bulb, which required far too many turns and eventually felt sufficiently wrong to reveal the problem:

    LED Bulb - unscrewed base
    LED Bulb – unscrewed base

    The entire metal base shell unscrewed from the plastic housing and twisted off the lead from what looks like a PTC fuse in series with the center contact; the cute little pigtail effect suggests I’ve wrecked the epoxy-to-wire seal.

    It had a five year warranty which, alas, expired three years ago. This style of bulb has fallen out of favor, so I may as well get some Quality Shop Time out of it.

    I don’t know how the factory machinery attached the lead to the contact button, but I’m going to go primal on it with some solder. The trick will be soldering it after assembly, so the first step is to drill through the middle of the button.

    Grab it nose-down in the Sherline’s three-jaw chuck, flip it over, grab the chuck in the drill press vise, line it up, center-drill the button, then drill right through that sucker:

    LED Bulb - base drilling setup
    LED Bulb – base drilling setup

    Of course, the contact came loose from the base, because I pretty much drilled right through the rivet flange holding it in place:

    LED Bulb - removed center contact
    LED Bulb – removed center contact

    Nothing a dab of epoxy can’t fix, though. I scuffed up the outside of the contact to remove the nickel (?) plating and expose the underlying brass to improve its solderability.

    After the epoxy cured, align wire with hole, screw the base onto the lamp shell, and it’s ready for soldering:

    LED Bulb - base ready for solder
    LED Bulb – base ready for solder

    The hole is way too large for the wire, but I wasn’t about to wreck a tiny drill on what might have been a weld nugget. In any event, the bigger the blob, the better the job:

    LED Bulb - soldered base
    LED Bulb – soldered base

    Just like light bulb bases used to look, back in the day.

    With a bit of luck, it’ll sit in that socket for another seven years.

    It could happen, ya never know.

  • Gyros Miniature Circular Saw Blade & Mandrel Tinkering

    Gyros Miniature Circular Saw Blade & Mandrel Tinkering

    The Small Envelope o’ Slitting Saw Blades also disgorged several Gryos Ultra-fine blades and their mandrel with a broken screw jammed in place. Unlike similar Dremel-ish cutoff wheels with a mandrel threaded M2×0.4 mm, these blades have a 1/16 inch = 64 mil hole fitting the mandrel’s screw:

    Gyros mandrel - broken screw size
    Gyros mandrel – broken screw size

    The 1-72 brass screw came heartbreakingly close to fitting and the M2 SHCS obviously won’t play. I can’t measure super-fine threads, but I can count: 16 threads on the stub occupy about the same distance as 18 threads on the 1-72 screw, so 72 × 8 / 9 = 64 tpi and it’s a 1-64 screw, not the far more standard 1-72.

    The blade hole just barely fit a #51 = 67 mil drill and measuring my assortment of mandrels produced one with the only M1.8×0.35 (OD = 71 mil) screw I’ve ever seen, so I drilled the blade with a #50 = 70 mil drill:

    Gyros miniature saw blade - hole enlarging
    Gyros miniature saw blade – hole enlarging

    Should the oddball screw in that mandrel break, the next step will be a #48 = 76 mil drill to fit the blade around the M2×0.4 screw for cheap and readily available mandrels.

    So, being left with a broken screw stub in the original Gyros mandrel, I soaked the scene in Kroil overnight, then applied a tiny screw extractor with amazingly good results:

    Gyros mandrel - broken screw extraction
    Gyros mandrel – broken screw extraction

    I did eventually find one 1-64 screw in the Big Box o’ Tiny Screws, although its infinitesimal head seems intended for gentler duty than clamping a saw blade to the end of a whirling shaft.

    Hand-held Dremel mandrels have, as far as I can tell, no particular runout specs, so chucking them in a Sherline spindle collet pretty much guarantees only a few teeth on one side of the saw will do all the cutting. Which, I hope, will suffice for my simple needs.

  • Astable Multivibrator: Red RGB Piranha

    Astable Multivibrator: Red RGB Piranha

    A red LED has a sufficiently low forward voltage to run with a MOSFET astable multivibrator and a pair of run-down AA alkaline cells:

    Astable AA Alkaline - red
    Astable AA Alkaline – red

    The red LED is actually part of an RGB Piranha, just to see how it compares to an as-yet-unbuilt version with a single red LED in the same package.

    The LED drops 1.9 V of the 2.75 V from the mostly used-up AA cells:

    Astable Piranha Red - 2.75 alkaline - V LED
    Astable Piranha Red – 2.75 alkaline – V LED

    The original 33 Ω ballast resistor showed a peak current of 11 mA in a 30 ms pulse:

    Astable Piranha Red - 2.75 alkaline - V 33 ohm
    Astable Piranha Red – 2.75 alkaline – V 33 ohm

    Replacing it with a 12 Ω resistor boosts the current all the way to 12 mA:

    Astable Piranha Red - 2.75 alkaline - V 12 ohm
    Astable Piranha Red – 2.75 alkaline – V 12 ohm

    The 2N7000 gate sees a just bit more than 2 V, barely enough to get the poor thing conducting, which makes the ballast resistor mostly decorative. The MOSFET datasheet puts its 1 mA threshold somewhere between 0.8 and 3 V, so it could be worse.

    Keep in mind the DSO150’s 1 MΩ input impedance sat in parallel with the 1 MΩ gate pulldown resistor forming the RC differentiator when I measured the gate voltage; I’ll leave the simulation as an exercise for the interested reader. The blinks were noticeably dimmer and perhaps a bit shorter, although eyeballometric calibration is notoriously hard.

    The slightly revised schematic-layout doodle stacks the transistors along the negative bus bar:

    Astable wiring layout - stacked 2N7000
    Astable wiring layout – stacked 2N7000

    Flipping the bottom transistor over to snuggle the two timing caps next to each other would eliminate the long jumper wire and probably look better.

  • Floor Lamp Rebasing

    Floor Lamp Rebasing

    The torchiere floor lamp in the sewing room suffered a catastrophic failure:

    Floor lamp - failed plastic base shell
    Floor lamp – failed plastic base shell

    Contrary to what you might think from seeing the shattered plastic base, we didn’t use the lamp as a club or battering ram. Apparently the designer expected the thin plastic surrounding the hole to withstand all the torque produced by the long pole against the cheap concrete / mortar / grout / whatever lump in the base. As we can recall, this lamp came to us from either a yard sale or a roadside debris harvest, so I suppose the hardware outlasted any reasonable expectation.

    The Basement Laboratory Warehouse disgorged the pole and base from a similar lamp, albeit sporting black paint and a smaller rod connecting its pole to its somewhat larger weight. Not being too fussy about decor, I embiggened the hole in the black base to fit the white lamp’s threaded rod:

    Floor lamp - enlarging replacement base
    Floor lamp – enlarging replacement base

    The dust on the base shows why you shouldn’t stand motionless in the Basement Laboratory for very long.

    The alert reader will have noted the cord passing through a strain relief grommet in the white base. Rather than dismantle the entire lamp, I just cut the cord, ran it through the new base weight, reinstalled the washer + nut, then crimped on a pair of solderless connectors:

    Floor lamp - cord splice
    Floor lamp – cord splice

    The new base doesn’t offer much in the way of attachment points, so I added a cable tie to keep the strain off the connectors:

    Floor lamp - cord strain relief
    Floor lamp – cord strain relief

    A strip of genuine 3M duct tape with double-thick adhesive now traps the cord inside that small channel and, given that the lamps spends most of its time standing quietly in a corner, the cord should be fine for long enough.

  • KeyboardIO Atreus: RGB LED Firmware

    KeyboardIO Atreus: RGB LED Firmware

    Having wired a WS2812 RGB LED into my KeyboardIO Atreus, lighting it up requires some QMK firmware configuration. It’s easiest to set up a “new” keymap based on the QMK Atreus files, as described in the QMK startup doc:

    qmk new-keymap -kb keyboardio/atreus -km ednisley

    Obviously, you’ll pick a different keymap name than I did. All the files mentioned below will reside in the new subdirectory, which starts out with only a keymap.c file copied from the default layout.

    The rules.mk file enables RGB Lighting, as well as Auto Shift and Tap Dance:

    AUTO_SHIFT_ENABLE = yes			# allow automagic shifting
    TAP_DANCE_ENABLE = yes			# allow multi-tap keys
    
    RGBLIGHT_ENABLE = yes			# addressable LEDs
    

    If you had different hardware, you could specify the driver with a WS2812_DRIVER option.

    QMK can also control single-color LEDs with PWM (a.k.a. backlighting), and per-key RGB LEDs (a.k.a. RGB Matrix). These functions, their configuration / controls / data, and their documentation overlap and intermingle to the extent that I spent most of my time figuring out what not to include.

    Some configuration happens in the config.h file:

    #define RGB_DI_PIN B2
    #define RGBLED_NUM 1
    
    // https://github.com/qmk/qmk_firmware/blob/master/docs/ws2812_driver.md
    //#define WS2812_TRST_US 280
    //#define WS2812_BYTE_ORDER WS2812_BYTE_ORDER_GRB
    
    #define RGBLIGHT_LAYERS
    #define RGBLIGHT_EFFECT_RGB_TEST
    #define RGBLIGHT_LIMIT_VAL 63
    
    #define NO_DEBUG
    #define NO_PRINT
    

    The first two lines describe a single WS2812 RGB LED wired to pin B2 (a.k.a. MOSI) of the Atmel 32U4 microcontroller. The default Reset duration and Byte Order values work for the LED I used

    Protip: swapping the order from GRB to RGB is a quick way to discover if the firmware actually writes to the LED, even before you get anything else working: it’ll be red with the proper setting and green with the wrong one.

    Dialing the maximum intensity down works well with a bright LED shining directly at your face from a foot away.

    Turning on RGBLIGHT_LAYERS is what makes this whole thing happen. The RGBLIGHT_EFFECT_RGB_TEST option enables a simple test animation at the cost of a few hundred bytes of code space; remove that line after everything works.

    The last two lines remove the debugging facilities; as always with microcontroller projects, there’s enough room for either your code or the debugger required to get it running, but not both.

    With those files set up, the keymap.c file does the heavy lifting:

    // Modified from the KeyboardIO layout
    // Ed Nisley - KE4ZNU
    
    #include QMK_KEYBOARD_H
    
    enum layer_names {
        _BASE,
        _SHIFTS,
        _FUNCS,
        _NLAYERS
    };
    
    // Tap Dance
    
    enum {
        TD_SPC_ENT,
    };
    
    qk_tap_dance_action_t tap_dance_actions[] = {
        [TD_SPC_ENT] = ACTION_TAP_DANCE_DOUBLE(KC_SPC, KC_ENT),
    };
    
    
    // Layer lighting
    
    // Undefine this to enable simple test mode
    // Also put #define RGBLIGHT_EFFECT_RGB_TEST in config.h
    
    #define LED_LL
    
    #ifdef LED_LL
    
    const rgblight_segment_t PROGMEM ll_0[] = RGBLIGHT_LAYER_SEGMENTS( {0,1,HSV_WHITE} );
    const rgblight_segment_t PROGMEM ll_1[] = RGBLIGHT_LAYER_SEGMENTS( {0,1,HSV_MAGENTA} );
    const rgblight_segment_t PROGMEM ll_2[] = RGBLIGHT_LAYER_SEGMENTS( {0,1,HSV_CYAN} );
    const rgblight_segment_t PROGMEM ll_3[] = RGBLIGHT_LAYER_SEGMENTS( {0,1,HSV_BLUE} );
    const rgblight_segment_t PROGMEM ll_4[] = RGBLIGHT_LAYER_SEGMENTS( {0,1,HSV_GREEN} );
    const rgblight_segment_t PROGMEM ll_5[] = RGBLIGHT_LAYER_SEGMENTS( {0,1,HSV_RED} );
    const rgblight_segment_t PROGMEM ll_6[] = RGBLIGHT_LAYER_SEGMENTS( {0,1,HSV_YELLOW} );
    
    const rgblight_segment_t* const PROGMEM ll_layers[] = RGBLIGHT_LAYERS_LIST(
        ll_0,ll_1,ll_2,ll_3,ll_4,ll_5,ll_6
    );
    
    #endif
    
    void keyboard_post_init_user(void) {
    
    #ifdef LED_LL
        rgblight_layers = ll_layers;
        rgblight_set_layer_state(0, 1);
    #else
        rgblight_enable_noeeprom();
        rgblight_mode_noeeprom(RGBLIGHT_MODE_RGB_TEST);
    //    rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 3);
    #endif
    
    }
    
    
    #ifdef LED_LL
    
    layer_state_t layer_state_set_user(layer_state_t state) {
        for (uint8_t i=0 ; i < _NLAYERS; i++)
            rgblight_set_layer_state(i, layer_state_cmp(state, i));
    
        return state;
    }
    #endif
    
    
    // Key maps
    
    const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
      [_BASE] = LAYOUT(                             // base layer for typing
        KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,                      KC_Y,    KC_U,    KC_I,    KC_O,    KC_P    ,
        KC_A,    KC_S,    KC_D,    KC_F,    KC_G,                      KC_H,    KC_J,    KC_K,    KC_L,    KC_SCLN ,
        KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_GRV,  KC_LALT, KC_N,    KC_M,    KC_COMM, KC_DOT,  KC_SLSH ,
        LT(_FUNCS,KC_ESC), KC_TAB, KC_LGUI,  KC_BSPC, KC_LSFT,  KC_LCTL, KC_ENT , TD(TD_SPC_ENT),  MO(_SHIFTS), KC_MINS, KC_QUOT, KC_BSLS),
    
      [_SHIFTS] = LAYOUT(                           // shifted chars and numpad
        KC_EXLM, KC_AT,   KC_UP,   KC_DLR,  KC_PERC,                  KC_PGUP, KC_7,    KC_8,   KC_9, KC_HOME,
        KC_LPRN, KC_LEFT, KC_DOWN, KC_RGHT, KC_RPRN,                  KC_PGDN, KC_4,    KC_5,   KC_6, KC_END,
        KC_LBRC, KC_RBRC, KC_HASH, KC_LCBR, KC_RCBR, KC_CIRC, KC_AMPR,KC_ASTR, KC_1,    KC_2,   KC_3, KC_PLUS,
        KC_NO  , KC_INS,  KC_LGUI, KC_DEL , KC_BSPC, KC_LCTL, KC_LALT,KC_SPC,  KC_TRNS, KC_DOT, KC_0, KC_EQL ),
    
      [_FUNCS] = LAYOUT(                            // function keys
        KC_INS,  KC_HOME, KC_UP,   KC_END,  KC_PGUP,                   KC_UP,   KC_F7,   KC_F8,   KC_F9,   KC_F10  ,
        KC_DEL,  KC_LEFT, KC_DOWN, KC_RGHT, KC_PGDN,                   KC_DOWN, KC_F4,   KC_F5,   KC_F6,   KC_F11  ,
        KC_NO,   KC_VOLU, KC_NO,   KC_NO,   RESET,   _______, _______, KC_NO,   KC_F1,   KC_F2,   KC_F3,   KC_F12  ,
        KC_NO,   KC_VOLD, KC_LGUI, KC_LSFT, KC_BSPC, KC_LCTL, KC_LALT, KC_SPC,  TO(_BASE), KC_PSCR, KC_SLCK, KC_PAUS )
    };
    

    Undefine LED_LL to enable the test mode, compile, flash, and the LED should cycle red / green / blue forever; you also need the RGB_TEST option in the config.h file.

    Define LED_LL and layer lighting should then Just Work™, with the LED glowing:

    • White for the basic layer with all the letters
    • Magenta with the Fun key pressed
    • Cyan with the Esc key pressed

    The key map code defines colors for layers that don’t yet exist, but it should get you started.

    For convenience, I wadded all three QMK files into a GitHub Gist.

    The LED is kinda subtle:

    Atreus keyboard - LED installed
    Atreus keyboard – LED installed

    As you might expect, figuring all that out took much longer than for you to read about it, but now I have a chance of remembering what I did.

  • KeyboardIO Atreus: RGB LED Installation

    KeyboardIO Atreus: RGB LED Installation

    Having scouted out the territory inside the KeyboardIO Atreus, adding an LED requires taking it completely apart to drill a hole in the aluminum faceplate:

    Atreus keyboard - panel drilling
    Atreus keyboard – panel drilling

    Reattaching the plate to the PCB with only three screws allows marking the hole position on the PCB, which is much easier than pretending to derive the position from first principles:

    Atreus keyboard - LED marking
    Atreus keyboard – LED marking

    Despite appearances, I traced the hole with a mechanical pencil: black graphite turns shiny silvery gray against matte black soldermask. Also, the PCB trace is off-center, not the hole.

    Overlay the neighborhood with Kapton tape to protect the PCB from what comes next:

    Atreus keyboard - Kapton tape

    Snip a WS2812 RGB LED from a strip, stick it in place with eyeballometric alignment over the target, and wire it up:

    Atreus keyboard - LED wiring
    Atreus keyboard – LED wiring

    Despite the terrible reliability of WS2812 RGB LEDs mounted on PCB carriers, a different set on a meter of high-density flex tape have worked reasonably well when not thermally stressed, so I’ll assume this one arrived in good order.

    Aligning the LED directly under the hole required a few iterations:

    Atreus keyboard - LED positioning
    Atreus keyboard – LED positioning

    The iridescent green patch is a diffraction pattern from the controller chip’s internal circuitry.

    The data comes from MOSI, otherwise known as B2, down in the lower left corner:

    Atmel 32U4 - JTAG pins
    Atmel 32U4 – JTAG pins

    Actually lighting the LED now becomes a simple matter of software QMK firmware.

  • Enover Outlet Timer: Over-powered Zener Diode

    Enover Outlet Timer: Over-powered Zener Diode

    This being the season of lights, I deployed some outlet timers to turn them on at dusk and off at bedtime. The timers spend much of the rest of their lives plugged into outlets in the Basement Laboratory to keep their internal NiMH backup batteries charged, although they’re not controlling anything:

    Enover outlet timer - overview
    Enover outlet timer – overview

    This one is labeled ENOVER, but it’s essentially identical to all the others sporting random alphabetic names; I have a few more labeled UKOKE in the same plastic case. The current crop uses a different case and has one fewer button, but don’t expect any real difference.

    One of the timers had a blank display and didn’t respond to button pushes or a pin punch poked in the RESET hole, so I dismantled it to see what was inside.

    Both the hot and neutral terminals had stray wire strands:

    Enover outlet timer - stray wire strand
    Enover outlet timer – stray wire strand

    The power board had the usual missing components, suggesting it had been cheapnified after passing whatever regulatory inspection it might have endured to get a CE mark on its dataplate:

    Enover outlet timer - power board - overview
    Enover outlet timer – power board – overview

    The alert reader may have already noticed the mmmmm smoking gun:

    Enover outlet timer - scorched diode
    Enover outlet timer – scorched diode

    Incredibly, Z1 has a part number wrapped around it! A quick lookup shows a 1N4749A is a 24 V 1 W Zener diode, neatly matching the 24 V relay. The datasheet gives a 10.5 mA test current and a 38 mA maximum regulator current, with a caveat: “Valid provided that electrodes at a distance of 10mm from case are kept at ambient temperature”

    The relay datasheet says 8.3 mA nominal coil current, a mere 200 mW, which is much easier to dissipate in wire wrapped around a steel core than in a little diode.

    Evidently the poor diode ran rather hot before becoming a dead short, because a phenolic PCB (definitely not at ambient temperature) ought not discolor like that.

    Indeed, measuring Z1 in another, still functional, Enover timer showed 25 V and a similarly discolored patch around Z1, suggesting the circuit design requires a bit more disspation from the diode than it can comfortably deliver.

    I replaced it with a 1N970B from the Basement Laboratory Warehouse, rated for only 0.5 W in a seemingly identical case, buttoned the whole thing up, and left it in the middle of the concrete basement floor overnight. It wasn’t smoking and continued working in the morning, so I defined things to be no worse than before and declared victory.

    Should when the next one fails the same way, I’ll epoxy a small heatsink to that poor diode and its leads to reduce its overall temperature.

    For future reference, the underside of the PCB shows a distinct lack of post-soldering flux cleanup:

    Enover outlet timer - power board - solder side
    Enover outlet timer – power board – solder side

    I swabbed it with denatured alcohol, although doing so certainly didn’t make any change to its behavior.

    Memo to Self: no-clean flux is a thing.

    It’s worth noting no other components show signs of overheating, despite the diode becoming a short circuit, so R1 (a big power resistor) is most likely the shunt regulator’s dropping resistor and can survive the additional power.

    Should the diode fail open, the rest of the circuitry will be toast.