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.

Author: Ed

  • Fairing Arcs

    In CNC machining, at least the kind I do on my Sherline CNC mill, you can’t mill around acute inside corners: a round milling bit doesn’t fit into a straight-sided angle. You must add a fairing arc that smoothly connects the two sides; the catch is that “smooth” means it’s tangent to the sides. And EMC2 is really, really fussy about smooth, to the point where you can’t just wing it with a calculator and type in the numbers.

    Fairing arc doodles
    Fairing arc doodles

    There are nice analytic geometry methods for finding the intersection of two line segments, then laying in the arc that connects them, but this example weighs in at over two pages of G-Code. Mostly, what I need is an arc that connects a vertical or horizontal edge to an angled edge, so some simplification is in order.

    Herewith, the quick-and-dirty…

    The cutter enters from the left side, moving horizontally to the right, and will depart along the line toward P1, which might be the next corner of the part. The two material edges meet at P0, the vertex of the angle. The fairing arc is tangent to the two edges at PA and PB, centered at PC, and with a radius R.

    We know the coordinates of P0 and P1 and the arc radius. That radius must be larger than the cutter radius, as you can’t tuck a fat cutter into a narrow corner.

    The problem is to find PA, PB, and PC, so that we can write the G-code commands that travel along the sides & the arc.

    The first step is finding Φ (Phi), the angle between the outgoing edge and the X axis:

    Φ = arctan Δy/Δx = arctan (P1y – P0y) / (P1x – P0x)

    I’m pretty sure if you use a 4-quadrant arctan, as shown in the doodle, all the angles will work out perfectly on either side of the axis, but it’s easy enough to fake the signs to get the right answer in any specific case. If you wanted a general solution, you’d have a two-page subroutine, right?

    You’ll need the complement of that angle, hereinafter known as Theta:

    Θ = 90 – Φ

    Find the distances between various points using good old trig and right triangles:

    • CBx = R · sin Φ
    • CBy = R · cos Φ
    • P0PBy = R · (1 – cos Φ)
    • P0PBx = P0PBy · tan Θ

    Then the coordinates fall out thusly:

    Plastic Spring with Faired Corners
    Plastic Spring with Faired Corners
    • PCy = P0y + R
    • PBy = PCy – CBy
    • PBx = P0x + P0PBx
    • PCx = PBx – CBx
    • PAx = PCx
    • PAy = P0y

    Remember, you do not figure all this out with your calculator and plug the numbers into the G-code, not if you have any sense. If you have just a few corners, write the commands directly, otherwise gimmick up a little subroutine. Earlier versions of EMC2 used numbered parameters (#100), but now that you can have named parameters (#<_Fairing_Radius>), what’s holding you back?

    For example:

    #<_CBy>	= [#<_Fairing_Radius> * COS [#<_Phi>]]	(Y distance PC to PB)

    If your edge doesn’t come in from the left, then manual 90 degree rotations apply.

    0: (x,y) -> (x,y)
    90: (x,y) -> (y,-x)
    180: (x,y) -> (-x,-y)
    270: (x,y) -> (-y,x)

    If you’re using a CAD program to lay out your parts, all this is largely irrelevant. I hammer out the G-code for the simple 2-1/2-D parts I make by hand, so rounding off a few corners comes in handy.

    Because the lines & arc define the material edge contour, you can mill on either side of it and use cutter radius compensation to make the answer come out right. Works like a champ!

    For what it’s worth, the arc is tangent at PA and PB, making the line from PC to the corner (a.k.a. vertex) P0 the bisector of angle Φ. That’s not directly useful here, but keep it in mind when you solve similar problems.

    Update: As of mid-January, the newest trunk version of EMC2 can automagically insert fillets when cutter comp is turned on. That’ll be in the stable version in a while, after which I’ll need this math only for decorative fillets. That’s fine with me!

  • Fluorescent Shop Lights, Early Failures Thereof

    A decade ago I installed a few dozen two-tube fluorescent fixtures (a.k.a. “shop lights”) throughout the basement. Visitors always say something like “Wow, I can actually see what I’m doing!” That was the whole point, of course.

    Being that sort of bear, I write the date on one end of a fluorescent tube when I replace it. Tubes seem to last 3-5 years, which is short compared to the 20k power-on hours touted on the carton: 5 years * 300 days/yr * 6 hr/day = 9 k hours. That’s an overestimate, as I don’t spend all my time crouched in my basement laboratory, honest.

    It turns out that there’s also a spec for the number of lamp turn-ons (“starts”) hidden deep in the lamp datasheets. For example, if you manage to browse the current Lamp and Ballast catalog at http://www.sylvania.com/ProductCatalogs/, you’ll find that a 20k hour rated life comes at “3 hr/start”, which works out to a mere 6.7k starts over the expected life.

    More starts = shorter life.

    I tend to turn the lights off if I think I’ll be upstairs for a few hours, which happens a lot during the winter.  My back of the envelope says that the tubes fail right around the expected value: 5 years * 300 days/yr * 4 starts/day = 6 k starts.

    Lately I’ve had a rash of early lamp failures and it seems the fixtures are failing after a decade; nothing lasts any more. I’m now installing electronic-ballast fixtures that fire right up in the winter and don’t have that annoying subliminal flicker. At a cost of $20 each, I’m not replacing all of them at once, I assure you.

    The only real problem with fluorescent lamps is that they make white people look dead. I managed to buy a contractor pack of warm-white tubes at the local Lowe’s, but they’re hard to find around here. Go for the lowest color temperature bulbs you can find.

  • Sunglass Repair

    Making the fixture
    Making the fixture

    One of the screws on Mary’s sunglasses came apart. Wonder of wonders, the nut fell off in the kitchen, made a click when it hit the floor, and we managed to collect all the pieces.

    The temples attach to the lens frame with two tiny screws apiece. The screw heads are slightly embedded in the temples, but you can see why this didn’t work nearly as well in practice as it did in the design studio.

    The trick is to align the screw properly so it fits through the lens and frame after the adhesive sets up. The holes are 6 mm on center and more-or-less 55 mils in diameter (obviously, they’re metric screws, but this is the US and we do the best we can with antique units).

    Clamping and curing
    Clamping and curing

    That’s what CNC is all about: making it trivial to poke holes exactly 6 mm apart on center. I drilled two holes in some scrap acrylic sheet using Manual mode on my Sherline / EMC2 mill:

    g83 z-7 r1 q0.5 f100
    g0 x6
    g83 z-7 r1 q0.5 f100
    g0 z100

    I have it set to start up in metric units, which still seems to be legal here.

    cimg2858-sunglass-repair-success
    Success!

    Add a teeny dab of JB Weld, hold everything together overnight with a clothespin, and it’s all good in the morning.

    The trick is to check the leftover epoxy first to see if it’s fully cured before you move the actual piece.

    Memo to self: epoxy takes forever to cure at 55 F.

    Update: Pretty much as expected, that little dot of epoxy didn’t hold nearly as well as the original brazing. I tried a somewhat larger dot, but Mary was unhappy with the glasses anyway and we finally tossed ’em out.

    Of course I salvaged the screws & nuts & suchlike: you gotta have stuff!

  • Geek Scratch Paper

    Grid scratch paper pad
    Grid scratch paper pad

    Everybody needs doodle paper, but geeks need graph paper. What to do?

    Go to http://incompetech.com/graphpaper/ and set up a half-page grid with 5×8 1-inch divisions, 0.5-inch mid divisions, and 0.1-inch minor divisions (I think 1 / 0.6 / 0.3 pt line widths look nice). The obvious metric divisions are a bit too fine for my taste, but 2 cm – 1 cm – 2 mm might work.

    Fetch the PDF, load it into The GIMP at 300 dpi, expand the canvas to a full-page sheet (8.5×11 inches), duplicate the grid so you have two on one sheet, save it as a PNG for later use.

    If you don’t have a full-bleed printer, pick a full-page size that’ll print within whatever margins your printer enforces. You really want those one-inch grids to remain one inch, right?

    Print a few dozen copies, whack ’em in half, and bind ’em on the long edge. Add a thin cardboard backing sheet (Mr Breakfast Cereal Box, meet Mr Paper Cutter) so the bottom sheet stays neat.

    I have an old IBICO (since absorbed by GBC) plastic comb binding machine, but it’s easy enough to line the sheets up and coat the edge with white paper glue, rubber cement, or, for the true geek, liquid electrical tape.

    Pre-position pads wherever you’re ordinarily at a loss for scratch paper: neat doodles!

    PS: Put some money in his tip jar when you use his graph paper. It’s a nice gesture.

    [Update: Inexplicably, I didn’t have a picture of a pad. Here you go… low res, but you get the general idea. Great for off-the-cuff graphing, too.]

  • Daily Yard Picture

    5 November 2008
    5 November 2008

    Being that sort of bear, I took a picture of the back yard from our patio every day at 7 am wall-clock time. DST/EST changeovers threw their usual monkey wrenches into the mix, not to mention my lack of attention to the camera’s internal clock settings, but I eventually got 321 pictures of the same scene at more or less the same time of day.

    That’s all well and good, but this is the movie age…

    The plan: use ffmpeg or maybe mencoder to convert the still images into a movie.

    • Zero: copy the files to a unique subdirectory to protect the originals!
    • One: sort & rename by date
    • Two: resize images
    • Three: convert to a movie
    • Four: . . . profit!
    10 November 2008
    10 November 2008

    I’d uploaded the files whenever I used the camera for something else, so the actual file dates were fairly well scrambled and didn’t correspond to the EXIF data inside the image file. Digikam‘s batch file rename operation can sort out the files in ascending order of EXIF date and rename them into something a bit more uniform & boring like 0001.jpg, which is vital for ffmpeg.

    I used the camera’s full resolution, which is much too large for video, so I created Yet Another Subdirectory called Smaller to hold the reduced-size images. Imagemagick‘s convert program then squishes them down:

    for f in *jpg ; do convert -verbose -resize 640x480 $f Smaller/$f; done

    You can smash them even further to get a teeny postage-stamp movie for your media player.

    Make the movie:

    ffmpeg -r 3 -i %04d.jpg daily-3.mp4

    The file specifier %04d must exactly match the filename sequence and a missing file will stop ffmpeg dead in its tracks. The file names coming out of your camera won’t work if they’re not exactly sequential, which is highly unlikely over the course of the year.

    You can use mencoder:

    mencoder "mf://*.jpg" -mf fps=10 -o daily800.avi -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=800

    Then it’s showtime! I’d upload it, but you don’t have a need to know for our backyard activiites.

    There, now, wasn’t that easy?

    I didn’t actually figure all this out from first principles, of course. The basics are out there if you rummage around for a while with the obvious keywords.

    Memo to self: affix a stable camera platform to the side of the house!

  • Unusual Tea Additive

    Green tea is supposed to be good for you and Tazo China Green Tips is supposed to be pretty good tasting, so I’ve been sipping a cuppa or two in the morning. Teabags are a spendy way to buy tea, so I’ve been buying half a kilo at a shot from cooking.com, storing it in glass jars, and teaspooning it into a tea ball infuser over the course of the next year.

    This interesting additive appeared in one of my teaballs; fortunately I was awake enough to notice it before it wound up in hot water.

    Beetle found in Tazo Green Tea
    Beetle found in Tazo Green Tea

    It looked pretty much like the hull of a generic Asian Garden Beetle, although we haven’t seen anything quite like it in our gardens. Not a big deal, as garden beetles are fairly inoffensive critters, but not something that should make its way into a bag of lah-dee-dah tea. On the other paw, it’s hard to filter stuff like that out of the stream.

    Fought my way through the Flash-saturated Tazo site, sent a note to the Customer Service folks, eventually had a pleasant phone chat. After convincing her that I wasn’t rabidly angry and that it really was one of their beetles, she dispatched fifteen bucks worth of Starbucks gift card.

    It seems Starbucks either owns Tazo, both of ’em are controlled by the same outfit, or something like that. She was in the Starbucks Customer Service chain o’ command, anyway.

    Beetle bottom view
    Beetle bottom view

    So I picked up three boxes of Tazo tea bags at the local Starbucks: more China Green Tips and some Green Tea with Lemon Grass (which doesn’t appear on their website). Left me with three cents on the card; I’m not a regular customer, so it’s now in the pile of cards I use as measurement shims in the workshop.

    I’d been adding lemon grass from our garden to the morning cuppa for a pleasant lemon scent. The Tazo version includes Lemon Verbena, some mint, and other flavors that cranked the scent up to 11 and the taste far into my ptui range. Unpleasant, indeed.

    For what it’s worth, if you’ve tried & disliked other green teas, give Tazo China Green Tips a shot. It’s delicate and much better than the other (far cheaper) green teas I’ve tried; Salada Green Tea is particularly noxious.

    One of the China Green Tips reviewers on cooking.com comments “I found a rather long, nasty, kinky hair … I was shocked. I threw out the whole bag  … I was unable to drink tea for a week”.

    Mexican Bean Beetle on Soybeans
    Mexican Bean Beetle on Soybeans

    Now, party people, I’m here to tell you that food just doesn’t pop out of the ground in a pristine state. Maybe it’s because we eat a lot of food from our own gardens, but passengers like that, let alone the odd hair, just aren’t an issue. Consider, for example, this critter that made it all the way into the house on some soybeans: he’s likely related to the Asian Garden Beetle family and not all that far back in their family trees.

    If you want to really worry about something, ask yourself whether your tea grew downwind of, say, Zhejiang Happy Face Metal Refinery Complex Number Six. No way to tell about that, other than through a detailed chemical analysis of every cuppa.

    Bon appétit!

  • Udev rule to create /dev/scanner

    For some unknown reason, Kubuntu 8.04 doesn’t create a /dev/scanner link while it’s figuring out all the SCSI devices. I wanted to make the link sort of generic for any scanner that I might plug in, but I had to settle for a unique udev match.

    The scanner popped out of udev as /dev/sg5 this time and

    udevinfo --query=all --attribute-walk --name=/dev/sg5
    

    emits this useful chunk:

    looking at parent device '/devices/pci0000:00/0000:00:1e.0/0000:05:05.0/host4/target4:0:2/4:0:2:0':
        KERNELS=="4:0:2:0"
        SUBSYSTEMS=="scsi"
        DRIVERS==""
        ATTRS{device_blocked}=="0"
        ATTRS{type}=="3"
        ATTRS{scsi_level}=="3"
        ATTRS{vendor}=="HP      "
        ATTRS{model}=="C7670A          "
        ATTRS{rev}=="3945"
        ATTRS{state}=="running"
        ATTRS{timeout}=="0"
        ATTRS{iocounterbits}=="32"
        ATTRS{iorequest_cnt}=="0x656"
        ATTRS{iodone_cnt}=="0x656"
        ATTRS{ioerr_cnt}=="0x2"
        ATTRS{modalias}=="scsi:t-0x03"
        ATTRS{evt_media_change}=="0"
        ATTRS{queue_depth}=="2"
        ATTRS{queue_type}=="none"
    

    Plucking the readable bits out produces this stanza for/etc/udev/rules.d/60-symlinks.rules

    #-- hack to create /dev/scanner
    SUBSYSTEMS=="scsi", ATTRS{vendor}=="HP", ATTRS{model}=="C7670A", SYMLINK+="scanner"
    

    Then you can use that to fire up xsane thusly:

    sane hp:/dev/scanner

    With that in hand, edit GIMP’s ~/.gimp-whatever/menurc and ~/.gimp-whatever/pluginrc to replace sg5 (or whatever) with scanner.

    Works like a champ…

    The straight dope on writing udev rules is at http://www.reactivated.net/writing_udev_rules.html

    Memo to self: there’s got to be a way to make this generic, perhaps by piggybacking on whatever udev stanza assigns the scanner group to that /dev/sg? device.

    Update: make sure you’re in the scanner group

    sudo usermod -a -G scanner username