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.

Month: February 2016

  • Raspberry Pi: Jessie Lite Setup for Streaming Audio

    As a first pass at a featureless box that simply streams music from various sources, I set up a Raspberry Pi with a Jessie Lite Raspbian image. I’m mildly astonished that they use dd to transfer the image to the MicroSD card, but it certainly cuts out a whole bunch of felgercarb that comes with a more user-friendly interface.

    I used dcfldd (for progress reports while copying) and verify the copied image:

    sudo dcfldd statusinterval=10 bs=4M if=/mnt/diskimages/ISOs/Raspberry\ Pi/2015-11-21-raspbian-jessie-lite.img of=/dev/sdb
    sudo dcfldd statusinterval=10 bs=4M if=/dev/sdb of=/tmp/rpi.img count=350
    truncate --reference /mnt/diskimages/ISOs/Raspberry\ Pi/2015-11-21-raspbian-jessie-lite.img /tmp/rpi.img
    diff -s /tmp/rpi.img /mnt/diskimages/ISOs/Raspberry\ Pi/2015-11-21-raspbian-jessie-lite.img
    

    That fits neatly on a minuscule 2 GB MicroSD card:

    df -h
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/root       1.8G  1.1G  549M  67% /
    devtmpfs        214M     0  214M   0% /dev
    tmpfs           218M     0  218M   0% /dev/shm
    tmpfs           218M  4.5M  213M   3% /run
    tmpfs           5.0M  4.0K  5.0M   1% /run/lock
    tmpfs           218M     0  218M   0% /sys/fs/cgroup
    /dev/mmcblk0p1   60M   20M   41M  34% /boot
    

    Set the name of the Raspberry Pi to something memorable, perhaps streamer1.

    Disable IPV6, because nothing around here supports it, by tweaking /etc/modprobe.d/ipv6.conf:

    alias ipv6 off
    

    Enable the USB WiFi dongle by adding network credentials to /etc/wpa_supplicant/wpa_supplicant.conf:

    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    
    network={
     ssid="your network SSID goes here"
     psk="pick your own"
    }
    

    Nowadays, there’s no need for a fixed IP address, because after adding your public key to the (empty) list in ~/.ssh/authorized_keys, you can sign in using a magic alias:

    ssh -p12345 pi@streamer1.local
    

    I have absolutely no idea how that works, nor how to find out. If it ever stops working, I’m doomed.

    The Raspberry Pi Model B+ has “improved” audio that, to Mary’s ears, comes across as pure crap; even my deflicted ears can hear low-level hissing and bad distortion at moderate volumes. An old Creative Labs Sound Blaster USB box sidesteps that problem, but requires a tweak in /etc/asound.conf to route the audio to the proper destination:

    # Make USB sound gadget the default output
    
    pcm.!default {
     type hw card 1
    }
    ctl.!default {
     type hw card 1
    }
    

    ALSA then seems to default to the wrong channel (or something), although this tweak in the middle of /usr/share/alsa/alsa.conf may not be needed:

    #pcm.front cards.pcm.front
    pcm.front cards.pcm.default
    

    Good old mplayer seems to handle everything involved in streaming audio from the Interwebs.

    Set up blank /etc/mplayer/input.conf and ~/.mplayer/input.conf files to eliminate kvetching:

    # Dummy file to quiet the "not found" error message
    

    Set up ~/.mplayer/config thusly:

    prefer-ipv4=true
    novideo=true
    #ao=alsa:device=hw=1.0
    ao=alsa
    format=s16le
    #mixer-channel=Master
    softvol=true
    volume=25
    quiet=true
    

    The commented-out ao option will force the output to the USB gadget if you want to route the default audio to the built-in headphone jack or HDMI output.

    Telling mplayer to use its own software volume control eliminates a whole bunch of screwing around with the ALSA mixer configuration.

    The quiet option silences the buffer progress display, while still showing the station ID and track information.

    With that in hand, the Public Domain Project has a classical music stream that is strictly from noncommercial:

    mplayer -playlist http://relay.publicdomainproject.org/classical.aac.m3u
    

    Send them a sack of money if you like them as much as we do.

    By contrast, the local NPR station comes across as talk radio:

    mplayer http://live.str3am.com:2070/wmht1
    

    You can’t feed nested playlists into mplayer, but fetching the contents of the stream playlists produces a one-station-per-line playlist file that one might call RadioList.txt:

    http://relay.publicdomainproject.org:80/classical.aac
    http://relay.publicdomainproject.org:80/jazz_swing.aac
    http://live.str3am.com:2070/wmht1
    

    So far, I’ve been manually starting mplayer just to get a feel for reliability and suchlike, but the setup really needs an autostart option with some user-friendly way to select various streams, plus a way to cleanly halt the system. A USB numeric keypad may be in order, rather than dinking around with discrete buttons and similar nonsense.

    There exists a horrible hack to transfer the stream metadata from mplayer onto an LCD, but I’m flat-out not using PHP or Perl. Perhaps the Python subprocess management module will suffice to auto-start a Python program that:

    • starts mplayer with the default playlist
    • parses mplayer’s piped output
    • updates the LCD accordingly
    • reads / translates keypad input

    This being a Pi, not an Arduino, one could actually use a touchscreen LCD without plumbing the depths of absurdity, but that starts looking like a lot of work…

  • Raspberry Pi Model B+ Reset Connector

    Turns out Raspberry Pi boards have provision for a Reset switch, but you gotta dig for it. On the Model B+, it’s labeled RUN:

    Raspberry Pi BPlus - RUN header
    Raspberry Pi BPlus – RUN header

    Soldering in that 2-pin header and plugging a pushbutton switch on a short cable will suffice until I get around to thinking of / scrounging a suitable case.

    Poking the button forces a power-on reset, which you shouldn’t do with the RPi running, lest you trash the filesystem. After shutting down with sudo halt, however, the switch does exactly what’s needed: restarts the CPU from scratch.

    The RPi draws little enough power that there’s no point in actually pulling the plug; stressing that Micro-B connector is definitely a Bad Idea.

  • Hollow State Electronics: Desk Decorations

    I did a lightning talk / show-n-tell last Tuesday at the MHV LUG meeting and covered one end of a table with the Neopixel-lit bulbs & vacuum tubes & hard drive platters I’ve been playing with:

    MHVLUG – Hollow State Decorations – Lightning Talk

    Some of the posts won’t go live for a week, but here’s a peek into the future:

    Vacuum Tube LEDs - IBM 21HB5A Beam Power Tube - violet amber phase
    Vacuum Tube LEDs – IBM 21HB5A Beam Power Tube – violet amber phase

    Dang, that came out well…

  • Vacuum Tube LEDs: Halogen Lamp Success

    The Neopixel-illuminated halogen lamp looks much, much better than I expected:

    Vacuum Tube LEDs - halogen lamp - red phase
    Vacuum Tube LEDs – halogen lamp – red phase

    The ceramic ring screws down around the socket shell and pulls it up against the base; the threads have only as much precision as required to keep it from falling off. I may need to add a leveling shim just so I don’t have to explain why it’s always crooked.

  • Linux Mint Login: HTML vs. GDM

    Linux Mint uses an HTM-based login screen that displays an assortment of lush images. That would be fine, except that on the Lenovo Q150, the rendering engine (or whatever you call it) drives one core at full throttle whenever the login screen is up. That turns out to be all the time when I’m signed in through ssh and, for that box, the HTML engine is just a sucking chest wound.

    To fix that:

    System → Login → Theme tab

    Mint Linux - Login Theme Selection
    Mint Linux – Login Theme Selection

    Then pick any theme using GDM rather than HTML; they’re marked to the right of the theme name.

    Being that type of guy, I picked SimpleGreeter, which presents a dead-centered field in a blank screen:

    Mint Linux - SimpleGreeter Login
    Mint Linux – SimpleGreeter Login

    Set it to auto-select the previous user (in the Options tab) and you’re good to go.

    Burns zero CPU and works for me, anyhow.

  • Knurled Metric Inserts

    These seem like they ought to come in handy for fastening things to 3D printed objects:

    Kurled Inserts - M2 M3 M5
    Kurled Inserts – M2 M3 M5

    The assorted screws come from the Small Can o’ Small Screwlike Things, all harvested from various dead bits of consumer electronics:

    Kurled M3 Inserts
    Kurled M3 Inserts

    These would benefit from a heated staking tool that slides them into the hole parallel to the axis and flush with the surface. Such things are commercially available, of course, but for my simple needs something involving a cartridge heater, a wall wart, and a drill press may suffice.

    It would be better if the inserts had actual knurls, rather than splines. So it goes.

    For the record (thread x length x Knurl OD x Body OD):

    • M2 x 4 x 3.5 x 2.8
    • M2 x 6 x 3.5 x 2.7
    • M3 x 4 x 4.5 x 3.8
    • M3 x 8 x 5.0 x 3.9
    • M5 x 10 x 7.5 x 6.9

    The actual measurements seem to vary within ±0.02 of nominal and I doubt the manufacturing consistency justifies any assumption tighter than ±0.1 mm.

    The M3 inserts really do have two different ODs.

    The M5 insert was listed as “7 mm OD” and measures 7.5 mm, which suggests a typo in the description.

    The polygonal hole adjustment I use produces dead-on diameters for small vertical holes:

    HoleWindage = 0.2;
    
    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);
    }
    

    So an ordinary cylinder() with the nominal knurl OD or a PolyCyl() with the nominal body OD should suffice. Horizontal holes can probably use a plain old cylinder() with the nominal body OD, because they need reaming anyway.

    Perhaps a dab of epoxy would bond better with the plastic around a nominal-size hole than forcing the insert into an undersized hole or heat-bonding the insert. Some experimentation is in order.

    Ten bucks for the entire collection (five bags of 50 inserts each = 250 little brass doodads = 4¢ each), shipped free halfway around the planet, seemed reasonable, given that inch size knurled brass inserts run anywhere from 50¢ to upwards of $2 a pop and a Genuine Helicoil 4-40 insert sets you back just shy of a buck.

    An Amazon vendor offers 4-40 inserts for $0.24 each in single quantities, but with $9.25 shipping. [le sigh]

    Inch-size inserts with knurled rings intended for ultrasonic bonding seem to be 5¢ to 15¢ on eBay. I think the straight-side versions will work better than the tapered ones for heat or epoxy bonding.

    It knurls my knuckles that we here in the US haven’t gone solidly metric. Yes, I have a goodly assortment of metric hardware in addition to the harvested fasteners shown above, but it definitely wasn’t cheap & readily available.

  • Filament Drive Jam

    So, while printing the first pass of the halogen lamp base, this happened:

    Lamp Base - wrecked print
    Lamp Base – wrecked print

    The first layer went down fine, but the filament stopped feeding after laying down the small linear patch along the right side. The wrinkles come from me peeling it off the platform while it was still hot and flexy.

    Although feeding PETG at 75 mm/s for infill worked so far (I mean, sheesh, look at all the stuff I’ve made in the last year), this involved a fairly large expanse of filament and maybe, just maybe, the high flow rate cooled the nozzle enough to increase the extrusion pressure and eventually strip the filament.

    I shoved the filament hard enough to get it feeding again, bumped the extrusion temperature to 260 °C and started another print, whereupon things went swimmingly for the first 12.2 mm. Alas, the filament jammed again, just below the top of the hole for the USB adapter, where you see the odd line in the middle of the finished base:

    Lamp Base - USB port
    Lamp Base – USB port

    Because it’s now printing a relatively thin cylinder at relatively slow speeds (less infill per perimeter), the “feeding too fast” argument falls flat on its face: obviously, something else is wrong.

    Removing the fans showed a bit of plastic on the drive gear teeth, but nothing too terrible:

    M2 Filament Drive - jam front view
    M2 Filament Drive – jam front view

    The witness mark on the planetary gearbox output shaft still lines up with the mark on the gear, so the tiny grub screw hasn’t come loose. Note the slight misalignment between the bottom of the filament drive and the hot end inlet; I’ve already snipped the filament and done some retraction.

    A small struggle involving needle nose pliers dragged this classic gouged filament from the drive:

    Stripped PETG Filament
    Stripped PETG Filament

    This spool of PETG filament started out at 1.70 mm, but this section measures 1.80 mm. That’s at the high end of the ±0.05 mm tolerance around the nominal 1.75 mm, but, frankly, I don’t take the tolerance too seriously.

    Undamaged filament from the spool didn’t push smoothly through the drive, so I reamed out the entire path with a 2 mm drill (actually, a #46 drill = 2.05 mm). I don’t recall if I did that before mounting the drive, but even if I did, I’d expect some crud and distortion to accumulate after a while; it’s been running without much attention since last March.

    Reassembling the drive and feeding the filament to just above the hot end showed a slight misalignment:

    M2 Filament Dive - misaligned front view
    M2 Filament Dive – misaligned front view

    I cured that by loosening the screws and rotating the whole drive slightly clockwise:

    M2 Filament Dive - realigned front view
    M2 Filament Dive – realigned front view

    Viewed from the side, the drive positions the filament slightly too far to the rear:

    M2 Filament Dive - alignment side view
    M2 Filament Dive – alignment side view

    I didn’t (think to) check if the hole in the snout has become bellmouthed, but it wouldn’t take much. In any event, the filament fed into the hot end without incident, so maybe there’s enough slop to cover that misalignment. Maybe I should add a small shim behind the drive?

    With the filament drive working again, I had Slic3r chop the bottom off the solid model of the lamp base and create the G-Code for just the top section, which printed without any problem at all.

    I drilled eight holes in the bottom surface of the new ring, slobbered epoxy around the ring and tucked it into the holes, used a pair of brass rods to align the two parts, and clamped them together while the epoxy cured:

    Lamp Base - clamping
    Lamp Base – clamping

    I should be using black PETG anyway, so we’ll call this one a prototype and move on.

    So that’s where the line came from…