Ed Nisley's Blog: Shop notes, electronics, firmware, machinery, 3D printing, laser cuttery, and curiosities. Contents: 100% human thinking, 0% AI slop.
There I was, in the kitchen, minding my own business, when I felt something crawling up my shin…
Dog Tick – Ventral
It’s 5 mm from snout to rump, so it’s most likely a dog tick, not a deer tick, not that that makes me feel much better. It’s stuck to a strip of adhesive tape to prevent it from going anywhere and was flat enough to have not fed on anybody recently.
That picture didn’t require focus stacking, although I gave it a try anyway with inconclusive results. I must conjure up a much more rigid camera mount before that works well; a mini tripod isn’t good enough.
Something has gone badly wrong with the yellow bulk ink that I’m using in the Canon S630. Over the winter a precipitate formed in the bottles:
Sediment in ink bottles
And in the ink tanks:
Sediment in ink tank
But now that the Basement Laboratory has warmed up, not only does the precipitate remain, but some of it is growing:
Growth in ink tank
The picture doesn’t do it justice; it looks like pond scum in there. Only the yellow ink behaves like that, so it’s likely some contaminant in that batch. Because I buy ink in pint bottles, it’s a long time since that batch arrived and there’s no point in kvetching to the vendor. IIRC, I actually got this bottle from a friend who scrapped out his S630; he’d been refilling cartridges from the same source, too.
I ordered four sets of five tanks (CMYKK) from the usual eBay vendor for 20 bucks and will toss the old tanks & ink when those arrive.
There’s a set of four bulk ink bottles from a long-dead HP2000C printer on the shelf, but I suspect the ink chemistry differs by enough to ruin the Canon’s printhead… which is discontinued, so when the head dies, the printer dies, too.
Mary took me along on a Master Gardener tour of the plantings at Quaker Hill Native Plant Gardens (*) in Pawling, NY. We saw plenty of good-looking plants with enough light to make hand-held pictures come out wonderfully well, at least when my other mistakes canceled out.
This is an Echinacea, part of a much larger planting.
It’s cropped from the original image, resized slightly to 1050×1680, and now serves as a screen backdrop on the portrait monitor.
(*) The owners are among the 100 richest people in the country, so a staff of 70 maintaining the estate seems perfectly normal. Over the last two decades, they reshaped the entire 400-odd acre landscape to make the property look exactly right, to the extent that the many (synthetic) cliffs & (pumped) waterfalls consist of enormous boulders that a stone dresser reassembled and blended together from the largest sections that could be trucked in. The water features are visible from low earth orbit…
A hinge started squeaking, which required nothing more than a long pin punch, a soft hammer, and a dab of oil.
The unplated steel hinges in our house date back to the middle of the last century and all of them have a convenient hole in the bottom for a pin punch: much fancier than the raw edge of the folded frame and the butt end of the hinge pin. You drive the hinge pin upward with a few taps, lube it, and tap it back in again with a soft hammer (perhaps against a folded rag), and you’re done.
On the other side of door, however, lies one of our follies. For reasons that made perfect sense at the time, the hallway has five different shades of white paint:
Flat walls
Eggshell ceiling
Gloss trim
Semigloss front door
Epoxy hinges
The hallway has three branches, two openings, and ten doors. The white really sets off the hardwood floors and doors, while brightening what would otherwise be a rather dim area, but never, ever again will we make that mistake.
On the other paw, the hinges came out well. I took them off all those doors and jambs, cleaned the steel, gave ’em two rattle coats of white epoxy, and reinstalled. Much nicer than contemporary “shiny brass” plating or raw steel.
As part of our discussion around those Hall effect switches, I cautioned our Larval Engineer that she can’t use capacitors to “smooth out” mechanical switch bounce, even though all of her cronies and (most likely) her profs will advocate doing exactly that. The subject also came up at the local hackerspace when she showed off her project, so I should explain why capacitors don’t solve the problem.
Here’s some switch contact bounce:
Switch bounce – black panel-mount
Another push on the button, just to show how unpredictable the bounces can be:
Switch bounce – black panel-mount – 2
Note the horizontal scale: 10 ms/div. The smaller glitches appear only by courtesy of the scope’s glitch-catching mode; they’re down around a few microseconds.
Now, let’s add the canonical 100 nF “debounce” capacitor in parallel with the contacts and record another set of bounces:
Switch bounce – black panel-mount – 100 nF cap
Notice that the switch contacts bounce in a completely unpredictable manner.
The pullup resistor is a rather stiff 1 kΩ, so the RC time constant is τ = 1 kΩ × 100 nF = 100 μs, but that applies only to the rising edges of the waveform as the switch opens. You can, indeed, see a slight rounding of those corners: the voltage requires about 5τ = 500 μs to reach 99% of the final voltage.
The capacitor also forms an LC tank circuit with the usual parasitic wiring inductance, producing spikes that exceed the supply voltage: that’s the first half-cycle of the tank oscillation as the switch opens. The Q is fairly low due to the relatively high resistance, so the oscillations die out quickly. If this were feeding a microcontroller’s input pin, its input protection diodes would clamp the spikes to one diode drop above the supply voltage and below 0 V, but that’s an entirely different study.
It should be obvious that adding the cap hasn’t done diddly squat to debounce the switch transition.
Increasing the pullup resistor to the usual 10 kΩ will increase the time constant to τ = 1 ms, round off the leading edges a bit more, and further reduce the Q. It won’t debounce the longest transitions, which are on the order of 20 ms for this particular switch. You can’t increase the pullup too much, because you want enough current through it to ensure a valid logic level despite external noise (which is also an entirely different study); 100 kΩ may be as much as you can stand.
But that’s just for glitches due to the switch opening. The closed switch puts a dead short across the capacitor, so the cap provides no filtering as the switch closes: the microcontroller will see every single low-going bounce. The photos show only bounces during the open→closed switch transition, but the closed→open transition can be equally ugly: yes, switches bounce closed as they open.
That means the microcontroller will see glitches as the switch opens.
So let’s increase the capacitor enough that the voltage can’t rise beyond the logic threshold until the switch stops bouncing. Ignoring LC tank effects, the voltage rises as 1 – e-t/τ, so we need that value to be less than 0.25 (for a bit of margin) of the supply voltage after the longest possible bounce as the switch opens. Let’s assume the switch has a single closed (low) glitch after a long time being open (high), at which time the voltage must still be under the logic threshold to prevent a false input. The datasheets only give the maximum bounce duration, if they give any bounce time at all, so let’s assume the longest bounce will be 60 ms.
That says τ = -60 ms / ln(0.75) = 210 ms. Given a 10 kΩ pullup, that’s C = 210 ms / 10 Ω = 21 μF.
No problem, right? Let’s just put a 22 μF electrolytic cap across every switch and be done with it!
Well, except for the fact that most pushbutton switches can’t tolerate that much energy through their contacts. Assuming a 100 mΩ resistance and ignoring stray inductance, the initial current will be 5 V / 100 mΩ = 50 A with a time constant of τ = 22 μF × 100 mΩ = 2 μs. At the usual 5 V logic supply, the cap stores 22 μF × (5 V)2 = 550 μJ of energy, so we’re now burning the switch contacts with a 250 W pulse. Some switches have a maximum energy rating to deter exactly this design blunder, but you should not assume the lack of such a rating means the switch can handle anything you throw at it.
No problem, let’s just put a resistor in series with the switch to reduce the initial current.
I think you can see where this is going, though, so I’ll leave all that as an exercise for the student.
Moral of the story: you must do debouncing in software by filtering the raw switch input. The trick will be to get that code right, which isn’t nearly as simple as you might think. In fact, the first half-dozen techniques you come up with won’t work, so use a dependable library and test the results… which is an entirely different study, too.
If it’s any consolation, I didn’t know this stuff when I was a Larval Engineer, either. In fact, I didn’t learn much of it until after I made all the usual mistakes…
Thinking about those batteries in the context of a really big LED tail light for a bike leads to wondering about the variation in LED forward voltages; it’s possible to drive LEDs in parallel if they’re well-matched for forward voltage. A quick-and-dirty test is in order to get some first-pass numbers… and I have bags of nominally identical red and amber LEDs.
Applying a fixed voltage that produces 20 mA through 14 randomly chosen LEDs of each color, then measuring the voltage across each diode:
LED
Red V
Amber V
1
1.895
1.939
2
1.893
1.921
3
1.903
1.918
4
1.895
1.921
5
1.891
1.918
6
1.935
1.906
7
1.891
1.926
8
1.904
1.930
9
1.901
1.923
10
1.894
1.927
11
1.901
1.914
12
1.894
1.939
13
1.901
1.933
14
1.903
1.925
Minimum
1.891
1.906
Average
1.900
1.924
Maximum
1.935
1.939
Pushing 20 mA through the five lowest voltage red LEDs requires 9.54 V. Applying that voltage to the five highest red LEDs produces 18.2 mA.
Putting those two strings-of-five in parallel with 9.52 V produces 40 mA total: 16.6 mA in the low string and 19.9 mA in the high string, all measured with a fancy Tek Hall effect probe. No, those aren’t reversed and, yes, I did check twice: it makes no sense at all.
Temperature matters a lot in such measurements and I wasn’t controlling for that, plus I didn’t have a constant-current supply. Better numbers await better instrumentation, but I think binning a couple bags of 100 LEDs based on forward current should be straightforward.
After I get the next GPS+voice interface running on the (yet-to-be-bought) Wouxun KG-UV3D radio, a pair of reasonably new 1A17KG-3 7.4 V 1.7 A·h lithium battery packs will be floating around with nothing to do; the GPS interface connects an external battery to the radio, so there’s no need for the OEM battery.
Before doing anything else, it’d be useful to know the actual capacity. The pack has flush terminals, so I snipped off two lengths of shield braid, jammed a wire into each one, and taped them in place:
Battery pack – braid contacts
That obviously wasn’t going to last, so I added some closed-cell foam:
Battery pack – foam compression
And then, ever so gently, crunched a clamp around the whole mess:
Battery Pack – clamped contacts
Crude, but workable, although the ragged start to the test showed I was too gentle. Another click of the clamp and everything settled down just fine:
Wouxun Pack
In round numbers, the pack delivers 1.6 A·h down to 7.0 V and then falls off very rapidly to the 6.0 V that ended the test.
A string of three red / amber LEDs adds up to 3×1.9 = 5.7 V. A dumb DC blinky light running from 7.4 V has 77% efficiency, which isn’t all that bad, and 70% at the start. A current-regulating switcher might give 85% to 90% at the cost of considerable circuit complexity and wouldn’t be feasible for four independent blinky channels.
The starting voltage, fresh from the charger, is just shy of 8.5 V, which is why I figured I could get away with 9 V from the external pack through the GPS interface. So far, so good.
Obviously, if those packs are to be useful, I must conjure up a better battery holder. Having already designed a battery-shaped case for the GPS interface, it should be easy enough to build a radio-shaped mount for the pack.