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

  • Clock-radio Backup Battery vs Current Drain

    Clock-radio battery hack
    Clock-radio battery hack

    The little red Battery Sentinel LED on our old Realistic (a.k.a. Tandy a.k.a. Radio Shack) clock radio was on this morning, which means that, once again, the backup battery needs attention.

    It’s supposed to use an ordinary 9V battery, but it ate two or three of those a year. Given the absurd cost of 9V batteries relative to AA cells, that stopped making sense pretty quickly.

    Most devices with backup batteries draw essentially zero power from them during normal operation. This gadget draws 6 µA.

    An alkaline 9V battery has a capacity of about 500 mAh, maybe more with a low-drain load like this. That should last for a few years:

    500e-3 / 6e-6 = 83k hours = 500 weeks = 10 years

    Alas, the clock battery monitor is really fussy and triggers the LED when the voltage drops under about 8.5 V.

    [Update: the clock does a “battery test” every day, which probably accounts for the short battery life. I haven’t measured that current… or the duration of the test.]

    Fortunately, the clock case has a recessed bottom that fits a standard AA cell holder like a glove. I wired up 1-1/2 4-cell holders (yes, I should have used 7 cells, but I wasn’t sure what the upper voltage limit might be) to a standard 9V battery snap connector and screwed the assembly to the case.

    Now all I must put up with are the weak AA cells I got from batteries.com; the most recent order was a disappointment.

    Memo to Self: That snap connector has red = negative / black = positive!

  • Separate X Sessions Do Not Work in Kubuntu 8.10

    I sent this in as a bug to Launchpad, where it became Bug 337777 (not octal, BTW) and was marked as a duplicate of Bug 192413. It’s been triaged as Low priority, so I think my days of using KDE are, alas, pretty much finished.

    Herewith, the straight dope, just in case you were thinking of doing the same thing.

    ————-

    In Kubuntu 7.04, I managed to manually configure separate X sessions using two nVidia video cards driving two monitors. The setup involves a 1600×1200 landscape monitor on the left and a 1680×1050 monitor rotated 90 degrees CCW on the right.

    In Kubuntu 7.10, this worked reasonably well.

    In Kubuntu 8.04 / KDE3, this works poorly. X seems to regard the right-hand monitor as being 1600 (1680?) x 1200, so all windows maximize incorrectly and “centered” dialogs appear off-center to the upper right on that screen. I installed an nVidia-based dual-head card in the hopes that it would work better, but that made no difference. The setup is usable (I’m using it now), but not desirable.

    The automatic configuration tools fall flat on their face: any attempt to use the standard KDE display tools pooches xorg.conf. I must carefully tweak xorg.conf to keep this setup working in the face of any X changes.

    In Kubuntu 8.10 / KDE4.2, this configuration flat-out doesn’t work. After considerable manual fiddling, I got a blank X session on the right with the default X cursor and a black background; the mouse pointer moves from one screen to the other, but that’s as good as it gets. The left screen works more-or-less normally, but with some weirdnesses. Diligent searching reveals this is the common endpoint for all folks attempting this configuration: KDE4 simply doesn’t support separate X sessions.

    I do not want Twinview / Xinerama (which also work poorly for this configuration), because I typically edit a single document in portrait mode on the right screen while flipping between circuit simulators / web browsers / PDF documents / PCB layout editors on the left screen. A single X session using two screens does not support that functionality; particularly in KDE4 which seems to lack the advanced window positioning controls of KDE3.

    Because KDE4 is mandatory with 8.10, I can’t downgrade to KDE3, which might work.

    Although KDE4 seems to be the future, it would be immensely more usable if it didn’t introduce serious regressions from previous functionality. I will gladly trade off all the Plasmoid foo-foos and Compiz go-fast-stripes to get stable X capabilities that work the same way as 7.04.

    The to-be-expected alpha-version issues in 9.04 prevent me from even installing it at this point, so I cannot say whether it’s an improvement or not. From what I read in the forums, things do not look promising.

    Perhaps this is less of a “bug report” and more of a plea for stability: please, first make KDE4 *work*, then make it pretty!

    ————-

    For what it’s worth, I installed Xubuntu in that partition, added one line (Option “Rotate” “CCW”) to xorg.conf, and It Just Worked. XFCE is a bit lacking in creature comforts, but it works in this configuration. I think I can get used to that.

  • Old Kenmore Sewing Machine Foot Control Repair

    Foot control - inside view
    Foot control – inside view

    One of Mary’s first investments when she got out of college was a sewing machine and she’s been using it ever since. Of late, it’s gotten a bit sporadic and the foot control seemed to be at fault.

    The symptoms were that the foot control required too much travel (equivalently: foot pressure) to get up to speed, it started abruptly (poor speed regulation), and sometimes cut out without warning.

    So I took it apart to see what I could do.

    Two pins in the side hold the top cover in place and serve as pivots. Loosen the two visible screws in the center of two of the bottom feet, hold the top half of the case down, and slide the pins out.

    A wedge on the top half presses down on the middle of the steel bar, pressing it into the rheostat. A dab of silicone lube on the wedge greatly improved that action.

    Rheostat graphite wafers and contacts
    Rheostat graphite wafers and contacts

    The speed control itself is brutally simple: a carbon-pile rheostat in series with the 120 VAC 1 A sewing machine motor. The ceramic case and heatsink tab tell you that things get pretty toasty inside that Bakelite case.

    Disassembly is obvious, which is one of the nice things about old electrical gadgets: you can puzzle out how they work and how the parts fit together just by looking. A slew of graphite disks slides out from two cylindrical tunnels in the ceramic case, followed by two graphite contact buttons. The brass fittings on the front have carbon dust on their raised surfaces, but are basically just stamped & machined metal parts.

    No fancy electronics, no firmware, just a high-power (and utterly non-inductive!) carbon variable resistor.

    The rheostat has three modes, in increasing order of pressure:

    • Off — no pressure on the foot control
    • Resistive speed control — resistance varies with foot pressure
    • Full throttle — rheostat resistance shorted by front switch
    Rheostat speed control contacts
    Rheostat speed control contacts

    With no pressure on the foot control, there’s a generous gap between the contact bar on the back surface and the two graphite buttons sticking out of the ceramic case. There’s no way for the contacts to close by shaking or accident.

    A bit more foot pressure connects those two buttons through the shorting bar across the back. Light pressure on the graphite disks means a relatively high resistance, on the order of several hundred ohms, and relatively low current to the motor. Of course, that also means the motor has poor starting torque, but … a sewing machine doesn’t need a lot of torque.

    Increasing foot pressure squeezes the disks together and decreases the resistance. It drops to a few tens of ohms, perhaps lower, but it’s hard to get a stable measurement. The motor averages all that out and trundles along at a reasonably steady pace.

    Rheostat full-speed contacts
    Rheostat full-speed contacts

    Finally, the brass disk in the central case tunnel shorts the tabs on the two brass end contacts and lets the motor run at full speed. Increasing the foot pressure beyond that point doesn’t change anything; the spring-loaded shaft can’t deform the tabs.

    The steel shaft and contact disk can short one or the other of the two piles, but that just decreases the already small resistance by about half. That might give the motor a speed boost instantly before jumping to full speed.

    As nearly as I can tell, the carbon disks evaporated over the decades, as the piles seems quite loose and required a lot of foot motion to reach the first contact point. I lathe-turned a pair of brass disks about three wafers thick, so that they’d take up the empty space in the piles.

    I also filed the brass end fittings flat so that they contact the disks over more of their surface. The first two disks looked like they had hot spots: loose carbon collected in the areas where the contacts didn’t quite touch them. I doubt that actually improved anything, but it’s the thought that counts.

    The spacers worked reasonably well, although I wound up removing one graphite disk from each pile to ensure the full-speed contacts would close properly. They’re in a small plastic bag tucked under the aluminum heatsink tab, where they can’t get lost. With any luck, the bag won’t melt around them.

    Rheostat with brass spacer button
    Rheostat with brass spacer button

    A few days later, the sewing machine stopped working entirely. The foot control itself seemed to be working correctly, but a bit of poking around showed that the cord had a broken conductor just outside the strain relief. I cut the cord off at the strain relief, hacksawed the strain relief apart, then rewired it. The cord is now four inches shorter and everything works fine again.

    I think this would be a nice candidate for a PWM controller, but then I’d have to shoehorn all that circuitry into the base of the sewing machine or add another cord to the foot control. Ptui, this works well enough.

    Memo to Self: Replace the entire cord next time.

  • Machining a Shoulder Ring in a Hole

    Step bit making an annular ring
    Step bit making an annular ring

    I needed a shoulder around the inside of a hole, upon which to mount a big fat 10-mm white LED. The intent was that the LED leads go through the hole, the edge of its case sits on the shoulder, and a blob of hot-melt glue (epoxy for the final version) holds everything in place.

    I was all set for some CNC milling when it occurred to me that there was an easier way.

    The bottom flange on the LED case was scant of 11 mm, so a 13/32″ bit would be just just slightly too small and a 7/16″ bit would be just slightly too large. One of my step bits has 1/32″ increments in that range, sooo

    I grabbed the part in a Sherline 3-jaw chuck (I’d just drilled & tapped the three radial holes using that chuck), centered it in the drill press using a 5/16″ drill that just fit the existing center hole, crunched the chuck (lightly!) in the vise with the hole over the gap in the middle of the vise body (thus leaving room for the step bit), and drilled the hole 7/16″ about 1 mm down.

    (It’s not that I’ve never drilled right into the vise body, but I try to avoid doing that sort of thing more often than absolutely necessary.)

    The LED flange sat on 13/32″ annulus like I’d bored it to the exact measurements, with the leads passing through the hole as if I intended it to be that way.

    It doesn’t always work out this neatly…

    The Sherline chuck is resting on a pair of 5/16″ lathe bits that hold it up off the vise body, because its threaded hub isn’t quite large enough to make a stable base. Similarly, I used a pair of 1/4″ bits to space that plastic ring up from the chuck and get it level, but removed them lest I chew up the step bit. Yes, I took the drilling slow & easy.

    Those little Sherline chucks come in handy around the shop, not just on the Sherline mill, for little jobs like this!

  • Extracting Digital Camera Multi-burst Images

    Multi-burst image of trebuchet firing
    Multi-burst image of trebuchet firing

    Digital camera, at least the ones I have, include a “multi-burst” (Sony DSC-H5 and DSC-F717) or “multi-continuous” (Casio EX-Z850) shutter mode that takes a bunch of pictures in quick succession, then combines them into a single JPG image file.

    The Sony cameras create a 4×4 array. This image of a small trebuchet comes from the F717 and is 1280×960, so each sub-image is 320×240. The time between images is 1/30 second and the shutter speed is 1/125 second.

    Extracting the sub-images is trivially easy with the ImageMagick convert function:

    convert -crop 320x240 dsc02594.jpg shot-%02d.jpg
    Sub-image shot-11.jpg from the sequence
    Sub-image shot-11.jpg from the sequence

    You must specify the size of the sub-images to extract, which you can determine by RTFM or simple division, and convert extracts all the tiles into files named, in this case, shot-00.jpg through shot-15.jpg. The files appear in left-to-right, top-to-bottom order, which is most likely the sensible way for cameras to store them.

    The C printf-style format string %02d forces two-digit sequence numbers. You can omit that and the sequence will start with shot-0.jpg, but you must then contend with the usual hassles of shot-1.jpg and shot-10.jpg.

    Can you tell the designers were computer geeks?

    With 16 separate images in hand, you can have your way with them, using all your usual image-manipulation tools.

    ImageMagick can convert the images into an animated GIF:

    convert -delay 50 shot-*jpg shot-ani.gif
    Animated GIF from separate images
    Animated GIF from separate images

    That’s nigh onto 7 MB of image, which seems excessive for what it is, but there you have it. Obviously, you can de-res the images to fit the space available.

    The -delay 50 option should set the frame delay to 50 ticks at the default 100 ticks per second, but some display software ignores the frame rate within the file. Assuming, that is, that the usual spam filters don’t swat animated GIFs right out of the bitstream.

    You can also convert the images into a movie, as I discussed in more detail there. The ffmpeg program does a fine job of it:

    ffmpeg -r 3 -i shot-%02d.jpg shot.mp4

    Actually, convert can do that all by itself if you install mpeg2encode.

    One cannot upload movies to one’s free WordPress blog without buying a space expansion, so you’ll have to take my word that it works.

    The Sony cameras provide control over the interval between the images, allowing 1/30, 1/15, and 1/7.5 second intervals, but the Casio evidently just does the best it can. If you know the interval, you can determine interesting things like velocity and acceleration, so that’s something to look for when you’re buying a camera.

    Perhaps you can calibrate your camera using a pendulum?

    Memo to Self: Use the tripod!

  • Old PCs: The Gift That Keeps on Giving

    A friend gave me an old Aptiva, upon which I was going to install Puppy Linux.

    But, first I let it start up Win ME just for old time’s sake. What the heck, it’s a classic.

    The first thing up is a prompt asking permission to install Compuserve, which I really don’t need. As is usually the case with shovelware, that program doesn’t show up in the Start Menu, so I did some rummaging around.

    Firing up msconfig and looking at the auto-started stuff revealed, among the usual stuff, this interesting file:

    c:\windows\nav.exe                   .vbs

    That pretty much pushes the Compuserve popup to the back of the queue.

    Note the long string of blanks in the middle. That, in combination with Windows Explorer’s default “Hide known file extensions” setting, is an old trick, but, then, this is an old box.

    Sooo, at one time there was a virus on that box masquerading as good ol’ Norton AntiVirus. The offending file seems to be missing now, so something killed it without removing its auto-start setting.

    Either my friend removed NAV, too, or the virus shot it in the head. There’s all manner of NAV config files and clutter lying around, but no executables.

    In goes the Puppy CD, reboot, and I install its slightly backlevel ClamAV package. No problem with that; it’ll use the most recent virus signatures and, heck, any problems on this box are half a decade old.

    After mulling over the Windows ME partition for a while, ClamAV reported:

    /mnt/sda1/Program Files/Netscape/Users/Default/Mail/Trash: W95.Matrix.SCR FOUND
    /mnt/sda1/Program Files/Netscape/Users/Default/Mail/Inbox: W32.Magistr.B FOUND
    /mnt/sda1/_RESTORE/ARCHIVE/FS346.CAB: Worm.Kido-18 FOUND
    ----------- SCAN SUMMARY -----------
    Known viruses: 513471
    Engine version: 0.91.2
    Scanned directories: 1821
    Scanned files: 44557
    Infected files: 3
    Data scanned: 10721.32 MB
    Time: 73200.595 sec (1220 m 0 s)

    Feeding the obvious keywords into Google produces the comforting result that these are all old news:

    However, Kido is a Conficker / Downadup variant, which is disturbing. The hit is almost certainly a false positive, as it’s in a CAB file, we don’t run any Windows machines, and they’re behind a hardware firewall that’s in full effect.

    Handing the offending file to VirusTotal shows that ClamAV is the outlier and all the others are perfectly happy: Current status: finished Result: 1/39 (2.57%)

    To quote Ripley: “I say we take off and nuke the entire site from orbit. It’s the only way to be sure.

    Memo to Self:

    • Run ClamAV (not ClamWin) before booting Windows
    • Do not plug in the network cable until the box is known-clean
    • It’s time for a reverse wireless firewall when our young lady invites friends over

    Windows: http://www.clamwin.com/

    Linux: http://www.clamav.net/

  • RC Snubber Resonant Design

    An RC snubber is just a resistor and capacitor in series that damps out the oscillations occurring when a switched inductive circuit turns off.

    How this is supposed to work is that the snubber capacitance forms a resonant tank circuit with the inductance, the resistor absorbs the tank’s energy, and the oscillations damp out quickly.

    In practice, snubber circuits tend to be ill-designed, simply because it seems there’s no good way to measure the actual inductance and stray capacitance at the switch. Folks tend to apply a 100-ohm resistor and a 100 nF capacitor and hope for the best. Sometimes that works. Most of the time it’s suboptimal.

    You can do better than that.

    Forward converter switch, transformer, and snubber
    Forward converter switch, transformer, and snubber

    Here’s the key chunk of simple-minded forward converter I’m doing for a Circuit Cellar column. It’s an LTSpice IV model, not an actual schematic, but the hardware is pretty close to what you see here. The “Stray” capacitance at C5 represents a measured value, not an actual component. The transformer parameters come from my measurements there.

    A microcontroller drives the transistor switch, which draws current through the transformer primary and transfers power to the secondary winding; the turns ratio is 1:25, so a 6 V input becomes a 150 V output. When the microcontroller shuts off the switch, the collector voltage pops up to about 11 V, at which point the stack of diodes turns on and the inductor begins to discharge. The diode forward-bias characteristics keep a more-or-less constant voltage until the current becomes essentially zero, so the collector voltage declines only slightly as the current drops.

    When the current drops enough that the diodes don’t conduct very much, the collector node is in a peculiar condition: there’s no place for the remaining energy to go!

    Undamped collector ringing
    Undamped collector ringing

    This scope shot shows the result. The drive pulse (top trace) pulls the collector voltage (bottom trace) to zero, it snaps up to 11.5 V, and then declines to about 10 V before the diodes switch off. At that point the collector voltage rings like a bell: 8 V peak-to-peak at 10 kHz. That’s a very low frequency because the primary reflects the fairly substantial stray capacitance in the zillion-turn secondary winding.

    In order to form a resonant circuit, you need some idea of the existing inductance and capacitance. You can’t just clip a meter in there to measure them, because their values depend on the frequency, layout, and actual hardware.

    One good experimental technique is pretty well summarized in Maxim’s AN-3835, which deals with Cold-Cathode Fluorescent Lamp drivers. Pay no attention to the CCFL stuff, as snubber fundamentals are the same wherever you go.

    Basically, you add a test capacitance across the transistor (from collector to ground, similar to C5 in the schematic) and measure the new ringing frequency. Fiddle with the test capacitance until the frequency is half of what it started at. Use reasonably short lead lengths, particularly for applications that don’t involve actual transformers or inductors; surface-mount capacitors are your friends.

    What you’re doing is fiddling with this equation:

    F = 1 / (2 π sqrt (L C))

    Because of the square root around LC, when you increase the capacitance by a factor of 4, the frequency decreases by a factor of 2. So the test capacitance required to cut the frequency in half is three times the original stray capacitance. Got that?

    Knowing the original stray capacitance, which is 1/3 the test capacitor value, and the original ringing frequency, you can figure out the actual inductance:

    L = 1 / ((2 π F)^2 C)

    Now the magic happens…

    You know the inductance and capacitance of the tank circuit and its resonant frequency. At that frequency, the inductive and capacitive reactances are equal:

    XL = 2 π F L
    XC = 1 / (2 π F C)

    In fact, they’re also equal to what’s called the characteristic impedance of the circuit:

    Z = sqrt(L / C)

    The resonant frequency is about 10 kHz and an additional 60-some-odd nF dropped the frequency to about 5 kHz. Fairly obviously, your stock of caps will affect the precision of the results. Let’s suppose the stray capacitance, shown as C5, is about

    C5 = 60 / 3 = 20 nF.

    The inductor is then:

    L = 13 mH

    The characteristic impedance works out to:

    Z = 800 ohms

    Take those numbers with a grain of salt, but twiddling the scope cursors will get you pretty close in your own circuit.

    In order to swamp any variations in the stray capacitance (during the production run or whatever), pick the snubber capacitance to be at least four times the stray capacitance, rounded up to the next standard value. In this case, that works out to the traditional 100 nF, but that need not be the case.

    Snubbed oscillation
    Snubbed ringing

    You want to kill the ringing stone cold dead, so pick the snubber resistance equal to the characteristic impedance. That makes it a tank circuit with:

    Q = R sqrt(C / L) = 1

    Which is a pretty low Q, all things considered.

    The scope shot shows the result with an 820 Ω resistor and a 100 nF capacitor: wham, no ringing!

    Notice that the collector voltage is slightly lower immediately after the transistor switches off, as compared to the undamped case, because there’s now some juice going into the RC snubber. The overall converter efficiency will drop and you can trade off Q for efficiency for resistor dissipation in the usual manner.

    Pretty slick, huh?

    Update: you might want to put the snubber directly across the winding in higher-powered systems, to keep the snubber current out of the power supply. In this case it doesn’t matter all that much.