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: Science

If you measure something often enough, it becomes science

  • Arducam Motorized Focus Camera: Focusing Equation

    Arducam Motorized Focus Camera: Focusing Equation

    The values written to the I²C register controlling the Arducam Motorized Focus Camera lens position are strongly nonlinear with distance, so a simple linear increment / decrement isn’t particularly useful. If one had an equation for the focus value given the distance, one could step linearly by distance.

    So, we begin.

    Set up a lens focus test range amid the benchtop clutter with found objects marking distances:

    Arducam Motorized Focus camera - test setup
    Arducam Motorized Focus camera – test setup

    Fire up the video loopback arrangement to see through the camera:

    Arducam Motorized Focus test - focus infinity
    Arducam Motorized Focus test – focus infinity

    The camera defaults to a focus at infinity (or, perhaps, a bit beyond), corresponding to 0 in its I²C DAC (or whatever). The blue-green scenery visible through the window over on the right is as crisp as it’ll get through a 5 MP camera, the HP spectrum analyzer is slightly defocused at 80 cm, and everything closer is fuzzy.

    Experimentally, the low byte of the I²C word written to the DAC doesn’t change the focus much at all, so what you see below comes from writing a focus value to the high byte and zero to the low byte.

    For example, to write 18 (decimal) to the camera:

    i2cset -y 0 0x0c 18 0

    That’s I²C bus 0 (through the RPi camera ribbon cable), camera lens controller address 0x0c (you could use 12 decimal), focus value 18 * 256 + 0 = 0x12 + 0x00 = 4608 decimal.

    Which yanks the focus inward to 30 cm, near the end of the ruler:

    Arducam Motorized Focus test - focus 30 cm
    Arducam Motorized Focus test – focus 30 cm

    The window is now blurry, the analyzer becomes better focused, and the screws at the far end of the yellow ruler look good. Obviously, the depth of field spans quite a range at that distance, but iterating a few values at each distance gives a good idea of the center point.

    A Bash one-liner steps the focus inward from infinity while you arrange those doodads on the ruler:

    for i in {0..31} ; do let h=i*2 ; echo "high: " $h ; let rc=1 ; until (( rc < 1 )) ; do i2cset -y 0 0x0c $h 0 ; let rc=$? ; echo "rc: " $rc ; done ; sleep 1 ; done

    Write 33 to set the focus at 10 cm:

    Arducam Motorized Focus test - focus 10 cm
    Arducam Motorized Focus test – focus 10 cm

    Then write 55 for 5 cm:

    Arducam Motorized Focus test - focus 5 cm
    Arducam Motorized Focus test – focus 5 cm

    The tick marks show the depth of field might be 10 mm.

    Although the camera doesn’t have a “thin lens” in the optical sense, for my simple purposes the ideal thin lens equation gives some idea of what’s happening. I think the DAC value moves the lens more-or-less linearly with respect to the sensor, so it should be more-or-less inversely related to the focus distance.

    Take a few data points, reciprocate & scale, plot on a doodle pad:

    Arducam Motorized Focus RPi Camera - focus equation doodles
    Arducam Motorized Focus RPi Camera – focus equation doodles

    Dang, I loves me some good straight-as-a-ruler plotting action!

    The hook at the upper right covers the last few millimeters of lens travel where the object distance is comparable to the sensor distance, so I’ll give the curve a pass.

    Feed the points into a calculator and curve-fit to get an equation you could publish:

    DAC MSB = 10.8 + 218 / (distance in cm)
    = 10.8 + 2180 / distance in mm)

    Given the rather casual test setup, the straight-line section definitely doesn’t support three significant figures for the slope and we could quibble about exactly where the focus origin sits with respect to the camera.

    So this seems close enough:

    DAC MSB = 11 + 2200 / (distance in mm)

    Anyhow, I can now tweak a “distance” value in a linear-ish manner (perhaps with a knob, but through evdev), run the equation, send the corresponding DAC value to the camera lens controller, and have the focus come out pretty close to where it should be.

    Now, to renew my acquaintance with evdev

  • Monthly Image: Chestnut Burrs!

    Monthly Image: Chestnut Burrs!

    Much to our utter astonishment, this appeared on the driveway:

    Chestnut burr
    Chestnut burr

    We’ve since found half a dozen chestnut burrs in the yard, which means at least two trees (it takes two to cross-fertilize) are growing in the immediate area.

    We originally thought they were American Chestnuts, but Mary (being a Master Gardener) found enough references including comparative burr pictures to convince us they’re Chinese Chestnuts.

    We’ve seen squirrels carrying the burrs in their mouths from the trees to wherever they bury their food supply, as shown by this gnawed spot on the other side of the burr:

    Chestnut burr - gnawed section
    Chestnut burr – gnawed section

    I regard this as conclusive proof that squirrels either have no sense of pain or no lips, because I can’t imagine carrying that thing in my hand, let alone gnawing through it to extract the nuts inside.

    Each burr contains three nuts, although this empty husk shows some nuts can fail to fill out:

    Chestnut burr - interior with failed nut
    Chestnut burr – interior with failed nut

    We don’t know where the trees are, but the squirrels seem to carry the burrs across our yard from north to south, so they can’t be too far from us or each other.

    Despite our conclusion, it’s faintly possible they’re American Chestnuts, in which case they’re definitely survivors!

  • Discrete LM3909: Green LED at 1.15 V

    Discrete LM3909: Green LED at 1.15 V

    The green-LED discrete LM3909 is still flashing, even with its AA NiMH cells burned down to 1.15 V:

    LM3909 green LED - 1.15 V NiMH
    LM3909 green LED – 1.15 V NiMH

    If the truth be known, one of the cells is now reverse-charged to 200 mV, so that’s a bit beyond as low as it can go.

    The flash period has stretched to 8.7 s:

    LM3909 green LED - 1.17 V - 8.7s period
    LM3909 green LED – 1.17 V – 8.7s period

    The circuit boosts the battery by 800 mV to put 1.94 V across the green LED at the start of each flash:

    LM3909 green LED - 1.15 V - V LED
    LM3909 green LED – 1.15 V – V LED

    Admittedly, the LED isn’t particularly bright at 2.8 mA:

    LM3909 green LED - 1.15 V - LED current
    LM3909 green LED – 1.15 V – LED current

    But it’s still flashing!

    Swapping the cells into the LM3909 with a blue LED doesn’t produce any blinking, which is about what the earlier tests showed.

  • Praying Mantis: Ootheca Construction

    Praying Mantis: Ootheca Construction

    After not seeing any Praying Mantis activity in the Butterfly Bush for a few days, I discovered our armored hunter in the nearby decorative grass:

    Praying Mantis - building ootheca
    Praying Mantis – building ootheca

    The appendages at the tip of her abdomen were spread to the sides and her whole body moved in small circles, although I couldn’t get a good view of the proceedings. Building an ootheca apparently requires concerted effort, as she was still hard at work when dusk fell.

  • Monthly Science: Burnett Signal Timing

    Monthly Science: Burnett Signal Timing

    The NYS DOT has been improving the pedestrian crossings at the Burnett – Rt 55 intersection. I expect this will be a bullet item in their Complete Streets compliance document, with favorable job reviews for all parties. The situation for bicyclists using the intersection, which provides the only access from Poughkeepsie to the Dutchess Rail Trail, hasn’t changed in the slightest. No signal timing adjustments, no bike-capable sensor loops, no lane markings, no shoulders, no nothing.

    Here’s what NYS DOT’s Complete Streets program looks like from our perspective, with the four-digit frame numbers ticking along at 60 frame/sec.

    We’re waiting on Overocker Rd for Burnett traffic to clear enough to cross three lanes from a cold start:

    Burnett Signal - 2020-09-25 - front 0006
    Burnett Signal – 2020-09-25 – front 0006

    That building over there across Burnett is the NYS DOT Region 8 Headquarters, so we’re not in the hinterlands where nobody ever goes.

    We’re rolling:

    Burnett Signal - 2020-09-25 - front 0258
    Burnett Signal – 2020-09-25 – front 0258

    The Burnett signals just turned green, although the cars haven’t started moving yet, and we’re accelerating out of Overocker:

    Burnett Signal - 2020-09-25 - front 0463
    Burnett Signal – 2020-09-25 – front 0463

    About 1.5 seconds later, the vehicles have started moving and we’re lining up for the left side of the right-hand lane:

    Burnett Signal - 2020-09-25 - front 0752
    Burnett Signal – 2020-09-25 – front 0752

    There’s no traffic behind us, so we can ride a little more to the right than we usually do, in the hopes of triggering the signal’s unmarked sensor loop:

    Burnett Signal - 2020-09-25 - front 1178
    Burnett Signal – 2020-09-25 – front 1178

    We didn’t expect anything different:

    Burnett Signal - 2020-09-25 - front 1333
    Burnett Signal – 2020-09-25 – front 1333

    We’re rolling at about 12 mph and it’s unreasonable to expect us to jam to a stop whenever the signal turns yellow. Oh, did you notice the truck parked in the sidewalk over on the left?

    As usual, 4.3 seconds later, the Burnett signals turn red, so we’re now riding in the “intersection clearing” delay:

    Burnett Signal - 2020-09-25 - front 1593
    Burnett Signal – 2020-09-25 – front 1593

    Two seconds later, the Rt 55 signals turn green:

    Burnett Signal - 2020-09-25 - front 1711
    Burnett Signal – 2020-09-25 – front 1711

    Did you notice all three eastbound lanes of Rt 55 (on our right) were occupied? That means a driver can’t come zipping through without stopping at the green light in their direction.

    One second later, we’re still proceeding through the intersection, clearing the lethally smooth manhole cover by a few inches, and approaching the far side:

    Burnett Signal - 2020-09-25 - front 1771
    Burnett Signal – 2020-09-25 – front 1771

    Here’s what the intersection looks like behind me:

    Burnett Signal - 2020-09-25 - rear 1
    Burnett Signal – 2020-09-25 – rear 1

    Another second goes by and we’re pretty much into the far right lane , with the westbound traffic beginning to move:

    Burnett Signal - 2020-09-25 - front 1831
    Burnett Signal – 2020-09-25 – front 1831

    The pedestrian crossing ladder has fresh new paint. They milled off the old paint while reconstructing the crossing, so the scarred asphalt will deteriorate into potholes after a few freeze-thaw cycles. Not their problem, it seems.

    Although it’s been three seconds since Rt 55 got a green signal, the eastbound drivers remain stunned by our presence:

    Burnett Signal - 2020-09-25 - rear 2
    Burnett Signal – 2020-09-25 – rear 2

    After another second, we’re almost where we need to be:

    Burnett Signal - 2020-09-25 - front 1891
    Burnett Signal – 2020-09-25 – front 1891

    There’s a new concrete sidewalk on the right, with a wheelchair-accessible signal button I can now hit with my elbow when we’re headed in the other direction. It’s worth noting there is no way to reach Overocker by bicycle, other than riding the sidewalk; there’s only one “complete” direction for vehicular cyclists.

    One second later puts us as far to the right as we can get, given all the gravel / debris / deteriorated asphalt along the fog line near the curb:

    Burnett Signal - 2020-09-25 - front 1957
    Burnett Signal – 2020-09-25 – front 1957

    Which is good, because four seconds after the green signal for Rt 55, the pack has overtaken us:

    Burnett Signal - 2020-09-25 - rear 3
    Burnett Signal – 2020-09-25 – rear 3

    If you were the driver of the grayish car in the middle lane, directly behind the black one giving us plenty of room, you might be surprised at the abrupt lane change in front of you. Maybe not, because you had a front-row seat while we went through the intersection.

    Elapsed time from the green signal on Burnett: 25 seconds. My point is that another few seconds of all-red intersection clearing time wouldn’t materially affect anybody’s day and would go a long way toward improving bicycle safety.

    Unlike the pedestrian crossing upgrade, NYS DOT could fix this with zero capital expenditure: one engineer with keys to the control box, a screwdriver or keyboard (depending on the age of the controls), and the ability to do the right thing could fix it before lunch tomorrow.

    But it’s just a typical bike ride on NYS DOT’s Complete Streets, where their planners & designers claim to “promote pedestrian and bicycle travel for all persons.” Maybe that’s true somewhere in NYS DOT’s fantasies, but you’ll find far more evidence from our rides, with plenty of numbers, showing that’s not the case around here.

  • Funnel Web Spiders

    Funnel Web Spiders

    This critter took up residence in our kitchen window:

    Funnel web spider in window
    Funnel web spider in window

    She’s between the outer storm window and the inner sash, having secured her funnel web to both panes across the entire width of the window. We’d opened the storm window to clear an air conditioner vent and spiders know a good location when they see it.

    We know she’s female, because a (smaller) male appeared and conducted negotiations for the better part of an afternoon. After she accepted his offer of a small, somewhat battered, moth, the two hooked up for the rest of the day; we feared for his life, but he hung around until the next afternoon, then departed.

    She normally stays tucked inside the channel running along the edge of the window frame, with only the tips of those two front legs visible, and retreats at the slightest vibration, so we’ll leave her in peace until we must close the storm window.

  • Cicada Time

    Cicada Time

    Even though cicadas are completely harmless, Mary was quite startled to discover one crawling up the back of her garden pants:

    Cicada - left front
    Cicada – left front

    It seems the cicada mistook her for a tree.

    They’re handsome creatures:

    Cicada - left dorsal
    Cicada – left dorsal

    They’re very conspicuous on fabric:

    Cicada - right dorsal
    Cicada – right dorsal

    I teleported it to a maple tree, where it was better camouflaged:

    Cicada - on tree - right
    Cicada – on tree – right

    When last seen, it was headed upward at a pretty good pace. We wished it well on its adventures …