The Electric Henhouse

chx_composite

This spring three lovely chicks joined our family, Betty, Penny, and Ginger. Ginger discovered her inner rooster in due time, and was rehomed—we are not zoned for the crowing half of the species. To protect the birds from freezing during our winter travels, and to let them out at the sunrise, they have been housed in the electric henhouse. At dawn and dusk the hens are released or secured by a linear actuator, locking in heat, wind and potential predators locked out.

Betty watching the installation of the electric henhouse.

betty_looking_at_install

The heart of the electric henhouse is a bare-chip variant of the Arduino. It connects to a realtime clock with battery backup to get the time. The time, in turn, is used with calculated sunrise and sunset so the door opens at sunrise and closes shortly after sunset when the birds have settled down for the night. The ATMega runs at 5 volts, and so a dual H-bridge is used to provide the linear actuator with the power it needs.

parts_overview

The overall code architecture is straightforward, every second the processor checks the time. If the time is between the sunrise and sunset, tell the motor to open, otherwise close. The motor module maintains a state so that it won’t try to open an open door. The linear actuator is cleverly designed, it won’t strain to open when it is always open and it won’t close when all the way closed.

The only code module with much complexity is the sunrise and sunset calculation, which is an approximation based on a US Naval Observatory code, with only minor modifications. I tested it by running the calculation over a series of days throughout the year and comparing with published almanac.

I purchased two separate FTDI USB-to-serial chips to program the bare ATMega chip, and was unable to get either of them working. I followed programming instructions similar to those here, and those worked every time.

The linear actuator is visible at the top. It slides the door (currently open).

20141221-0067

You can get the code on GitHub.

Ear Tips for Noise Canceling Headphones

Most people have never tried in-ear headphones. They get ear wax on them, so to don’t share well. Wearing them on stage, musicians can hear their own instruments without going deaf. Since musicians use them for performance in-ear headphones are also called monitors, just like the speakers that point toward the band from the front of the stage.

Distraction, from airplane noise, office noise, maybe your own keyboard, annoys. Three headphones solve the problem. Most famously, Bose’s active noise canceling Quiet Comfort line and similar products by other makers. Passive noise reduction from sealed over-ear headphones is about 10 dB. In-ear monitors offer passive isolation between 20 and 30 dB.

I demoed the Bose phones years ago, and they hissed with the noise cancellation on. The sound quality was neither exceptional nor awful, but was poor for a $300 price. World-class sound quality is available from makers like Etymotic and Westone with in-ear monitors that provide as much isolation as active noise canceling models.

But in-ear monitors have one major drawback, they go in your ear canal. That means that they can get gross with ear wax, can be painful or itchy, and they can wear out. In my nine years using in-ear monitors I only ever found the foam tips from the manufacturer comfortable. The three-flange silicon tips isolate amazingly, but itch like fire after twenty minutes and hurt like a drill after sixty. The foam tips are comfortable, almost as isolating as the three-flange tips, but cannot be fully cleaned and wear out after three months.

tip_catalog

The most recent time I wore out a pair of foam tips, I decided it was time to look at the alternatives. I hoped to find, ideally, a comfortable silicon tip with the isolation of the foam tips or an inexpensively replaceable foam tip. It seems to be sort of a niche market, and I failed to find any useful comparisons on the web. So, I did my own.

I purchased a sizing kit from Westone, another from Monster, and a pack of the universally-liked Comply foam tips. Testing included a few leftover tips from the headphone’s original purchase, and I included those in the comparison.

I evaluated each tip for fit, seal, pain, itching, sound quality, isolation, and microphonics. Fit, seal, sound quality, and isolation are all related. With in-ear phones a poor seal means poor isolation and poor bass response and poor sound quality. Good fit depends on having the correct size tip for your ear. Medium tips from most manufacturers fit my ears well. The calipers in the picture below show a base diameter around 0.465 in (1.18 cm).

comply-tip-size

Most of the tip designs are old. Grubby among my grandfather’s shooting supplies, foam and triple flange tips were familiar to me twenty-five years ago. Recently Westone introduced a single-flange tip focusing on good seal and comfort. These, along with other single-flange tips, suffer from awful microphonics. When cables rub against anything, like your arm as you move the mouse, the motion travels along the cables and makes loud popping noises. Single-flange tips have the worst microphonics.

The best overall tips for me are Comply’s T-100 PLT medium foam tip. They cause no pain or itching, seal great and offer very good isolation, have low microphonics, and sound very good. Like all foam tips, they will wear out in three months and get waxy and gross. And they are neither the most isolating nor the quietest.

The best sounding tips are the Westone silicone three-flange tips, which offer by far the best isolation and by a small margin the best sound. After twenty minutes they also offer crushing pain and infernal itching. The three-flange tips have a place in my kit, but I don’t use them long.

Westone’s single flange tips are silicone, and are comfortable. My notes describe the itching from Westone’s silicone three-flange tip as extreme. After that, finding any silicone tip bearable was a surprise. The Westone Star tip is comfortable. It has poor microphonics, and poor isolation; it has no place on an airplane or a noisy office. On the other hand, Star Tips are cleanable and provide some isolation, so they are candidates for the gym. These also have a place in my kit.

The rest of the tips are unsurprising. Everything from Monster had poor isolation and had distracting microphonics due to a poor design. All of the other fitting foam tips are acceptable, but none are as good as Comply’s. All the other silicone tips are unacceptable for me, too painful, too itchy, too microphonic, and sound too poor. The results for all tips that fit reasonably well are in the table at the end.

I tested these tips with an hour-long playlist from mixed genre, seven songs in all. It starts with D. Barenboim/Berliner Staatskapelle recording of Beethoven’s Symphony 9, included to show dynamic range of symphonic instrumentation. The next two songs have typical mid-pitch-heavy pop songs including Adele’s One and Only off her album 21, and Erica Badu’s Four Leaf Clover from Baduism. Next, Erica Badu’s Rimshot shows the performance with an extreme deep bass opening line. Sweet Jane from the Cowboy Junkies is more typical pop. A mid-heavy but delicate sound and detailed sound from Miloš Karadaglić’s album Mediterráneo with his performance of Granados’ Danzas españolas, Op.-No. 2 Oriental. Finally, a very detailed song from Rush, The Necromancer off their album Caress of Steel has shown the weaknesses of many sound systems. I chose an hour-long playlist because in my experience in-ear monitors often lead to such itching and pain in the ears that I want to claw them out of ears screaming after forty minutes.

Monster produced the only foam tips I avoid. To fit my earphones you put the tiny red rubber rings around the earphone and then slide the tip over the top. The result was poor isolation and poor microphonics.

monster-tip

Tip

Size

Fit

Seal

Sound

Iso.

Mic.

Pain

Itch

Westone Classic Foam

Med

G

G

G

G

G

G

G

Westone Silicone White 3-flange

G

E

E

E

G

M

VP

Comply Foam T-100 PLT

Med

G

G

VG

VG

VG

VG

VG

Westone Star Silicone Black 1-flange

Med

G

G

VG

P

P

VG

VG

Westone Classic Foam

Med-Long

G

G

G

G

G

VG

G

Westone Truefit+ Foam

Med

G

G

G

G

G

G

VG

Westone Silicone Black 1-flange

Med

G

G

G

G

P

G

G

Westone Star Silicon Black 1-flange

Med-Long

G

G

VG

P

P

P

G

Weston Truefit+ Foam

Med-Long

G

VG

G

VG

G

G

G

Westone Silicone Clear 1-flange

Med

G

P

P

P

P

P

G

Westone Classic Foam

Small-Long

G

P

P

P

G

VG

G

Monster Foam

Med

G

G

G

P

P

G

G

My wife put me onto Bloglovin for those who follow with an aggregator. If you like, Follow my blog with Bloglovin. Finally, I have had no contact with the makers of these products, and I wasn’t compensated or paid in any way. Quite the contrary, I bought all the equipment reviewed here.

Some Curious Micrographs

We have an old microscope and a camera adapter for it. Occasionally we dig it out, and light some small stuff up. Several weeks ago my son’s science workbook had a multiple choice question, roughly “which of these would look different under a microscope”

  • salt in water
  • sugar in water
  • pollen in water

An experiment seemed in order. After exploring those boring solutions we explored other things. The first is the tip of a technical pen. I believe the narrow diameter part is the wire, and the large diameter is the tube. I suppose the fillet is a meniscus of ink.

Rotring Technical Pen Tip

20140207-23

The feather is cool enough to look at, but within the feather is a single fiber from a blue yarn that my wife was crocheting with.

A Feather and a Colored Thread

20140207-30

At the request of my son, I plucked one of my precious head hairs. I had hoped to see the surface structure of the hair, a tiny scaled surface. It is visible, but not clearly. Still, pretty cool.

A Hair at the Root

20140207-14

We looked at paper, too. But paper was not that interesting until we compared three different types. Notebook paper, a Kleenex, and slice of technical drawing paper (like vellum). The difference between the fibers is amazing.

A Tissue and a Strip of Technical Drawing Paper

20140207-10

My son wanted to look at candle wax too, but the toothpick we used to get it is far more interesting.

Toothpick with Candle Wax

20140207-19

You think that milk has been homogenized and so it should look like a smooth, uniform material. I was fascinated to observe a sandy or granular structure under an optical microscope. The microscope cannot really resolve the individual particles, but it can show that the particles are there.

Milk

20140207-24

The final picture is shows the microchip inside a slow-fade RGB LED. This LED fades through the gamut of colors, and macroscopically looks identical to any other LED. The picture is blurry because it is imaged through the acrylic body of the LED. Nevertheless, the microchip structure is visible. At the bottom you can see four solder joints, one for ground (or Vcc) and red, green, and blue components.

Microchip Inside a Slow-fade LED

20140207-29

In Youth and Beauty

I bought two pieces of art to hang from my son’s elementary school. I loved them immediately. The abstract tiles where done by my son’s 3rd and 4th grade class. The tree was made by a 1st and 2nd grade class. Both pieces of art are really lovely. The tree has a cool property, like a scene in Ferris Bueller. The art changes its character from far away to as close anyone would care to get. First, the tiles of abstract images of persons and animals was made under the rule that the student not pick up the pen during the drawing and then there are rules for filling with color, like a graph coloring rule.

20131230-05

The other artwork is a sort of mosaic of paper circles colored and glued to a black foam core board. The tree shots zoom in with three steps doubling the zoom at each step.

01-20131224-Tree

 

02-20131224-Tree-inset03-20131224-167

 

04-20131224-167-inset05-20131224-168

 

06-20131224-169-inset07-20131224-171

Arduino Flickering Candle

Update December 24, 2013: Mokus refined his code so that the distribution is now well-behaved (nearly normal) and the PSD no longer turns up at high frequencies). The plots and post have been updated to reflect this change. He will push code to the same link as available.


In my previous post on Candle Flame Flicker I describe the statistics of the optical intensity flicker from a candle in terms of the probability density of the brightness samples and in terms of the power spectral density of the brightness. In this article I discuss how to make an Arduino drive an LED to flicker in a way that is statistically similar to the measurements I took on a real candle.

In the measurements I observed the spectral roll-off of the candle to start between about 5 and 8 Hz, and to decline at a nominal rate of around 44 dB for each decade increase in frequency. The 2nd-order infinite impulse response filter is computationally efficient in terms of using a small amount of memory and requiring few calculations. However, the Arduino is not good at floating point arithmetic. On the Arduino, floating point is done in software, has relatively few bits of precision, and is about 4 to 40 times slower than fixed point (integer) math. It is quite difficult to find useful benchmarks. The basic process is to create white noise and then filter it to the correct spectral shape. Afterward, the signal is scaled to have the appropriate variance and offset with a constant to represent the average brightness of the “flame”.

The approach I used was to design the IIR in Python with scipy’s signal module. I specified a 2nd order lowpass Butterworth filter, specifying a cutoff frequency of 8 Hz, and a sample frequency of 60 Hz. I normalized the coefficients to work in a 16 bit integer space, following Randy Yates’ 2010 Practical Considerations in FIR Fixed Filter Implementations, mainly. From a synthesis perspective, there is some prior art. Philip Ching, a student at Cornell synthesized candle noise quite cleverly, though he neither reported nor replicated the correct statistics. A fellow with the handle Mokus did a very, very tiny implementation for a microcontroller with only 64 bytes of RAM. He helped me modify his code so I could compare his statistics, and after adjustment his spectrum and distribution match fairly well. The high-frequency of his PSD looks a little different from the other methods, but these may not be noticeable to the observer. Finally, there was Eric Evenchick’s coincidental post on hackaday. Mokus reported that Evanchick’s implementation has too slow an update rate; I noticed that Evanchick did not report on the statistics he was targeting nor what he achieved. I did not recreate his work to test.

Then, on to the tests. I really was interested in building and comparing statistics from a 16 bit implementation, a 32 bit implementation in both a Direct Form I and a Direct Form II implementation. Indeed, I had great difficulty getting the filters to perform because I kept misdesigning the integer coefficients and overflowing the registers. As I sought a solution to the 2nd-order filter approach, I also created a 4-stage digital equivalent of an RC filter. The 4-stage RC approach was always stable though it needed a higher sample rate and used much more processor power to create statistically consistent results. On the other hand, it has a more accurate spectrum. A comparison of three different 16-bit methods to Mokus’ and to the actual measurements is shown in the figure below. The legend shows the mean, standard deviation, and their ratio to the right of the label. The All my filters did a credible job of reconstructing the histogram.

histo_compare_16

The power spectral density (PSD) of the different methods tells a different story. The Direct Form II 16 bit filter is the most visually appealing of the methods I tried. It rolls off more like the physical data than the other methods, except compared to the 4-stage RC filter. The Direct Form II filter is more computationally efficient.

psd_compare_16

The results for the 32-bit versions show greater variance than the 16-bit versions, but the quality is not markedly better.

histo_compare_32

psd_compare_32

 

I wrote a proof code for the Arduino UNO both to see it flicker and to test the processor speed—separate parts of the code. The results are that compiling with 1.0.3 resulted in a 4,722 byte program that calculated 10,000 new values in 6,292 ms, or 629 microseconds per value. In theory this could produce a sample rate of nearly 1.6 KHz. Or another way of thinking about this is that the final code uses about 629 us/17 ms or about 4% of the processor capability of the Arduino UNO. That leaves a lot of resources available to do other Arduino work or maybe means it can fit in a cheaper processor.

I have released two pieces of code under the GNU Public License 3, you can get the Python I used for filter design and the Arduino test code at the links. If you want the data, please contact me through the comments and I am willing to provide it.

Bespoke Monitor Stand

I’m using two reams of paper to hold my monitor at the right height. These reams are totally functional. However, I’m trying to learn to make passable hand-cut dovetail joints and I had material from an old keyboard tray that does not fit with my office’s new furniture.

As a tangent, before starting this project I rebuilt the woodworking bench my grandfather gave me before he died. I think he would agree it was an expedient bench, and not an excellent bench. I’m glad to improve it. He made the bench top from unsanded 2×12 inch pine planks, with only moderate knots but with pretty awful warping.

I made my new bench top from his old one. I reground, honed, and lapped the blades, and squared the soles of the two jack planes I inherited. Then I planed out the cup, twist, and bow from the top surface. I planed the bottom surface to a lesser degree, but enough for the bench top to sit true.

I epoxied the handle back together on my inherited Bailey No. 7 jointer plane, reground the blade, honed the blade, and reground the chip breaker. Then I clamped the boards face-to-face, and squared the edges. I glued and clamped the top together, making it effectively a single solid piece of wood that was flatter and stiffer than it even had been.

It was connecting to use the hand planes I inherited, sharpened, lapped, and repaired the handles. More connection to square a benchtop I also inherited. I feel good that somewhere in the roughly 40 gallons of wood shavings (no exaggeration), are dents and oil stains my father made as a boy. And now my daughter and son are leaving dings in the new surface, and I feel good about that too.

20130303-123-2

I made bench dogs using oak dowel and springy stainless I repurposed from an old windshield wiper blade. The work great and cost about 25 cents a piece. Funny that I seriously considered buying brass ones at over $10 each until I learned how easy these are to make.

20130310-25-2-2

This post, though, is not really about the bench. The working bench was a nice foundation on which to build…a bespoke dovetail monitor stand.

Hand cut dovetails are not intellectually challenging. You can learn the concepts of how to do it with a few hours browsing tutorials. You need a good saw, but I made do with a mediocre one. You need to have a set of chisels and they need to be sharp. So, in a few hours you know how to make handcut dovetails. Trouble is, you can lean how to play piano the same way.

The guys who cut these in four seconds flat while whistling are like Rachmaninoff, only they’re dustier than he was when he did his work. I’m working up to Peanuts’ Schroeder.

20130310-05

It is made from an oak veneer birch plywood, but not multiply. The dovetails are cut at 14 degrees, as clearly indicated by Veritas’s sales literature for dovetail marking guides. The effect of the dovetails with sheet goods is rather cool. It makes the wood look hinged on the ends. It is pretty strong too, though I wouldn’t want a child to stand on the top.

20130310-25-zoom

The better fitting parts, like the example above, are really pretty good. Over the length of the joint there are places that gap a little. The thin oak veneer flaked off at the joints in some cases, and so the structural gaps are actually smaller than the surface gaps.

20130310-06

Sushi Dinner

Tonight we made a sushi dinner, and for the first time included kid-specific items. I used sweetened egg, tamago, sheet cut and pressed with rice in cookie cutters. We made stars and sushi boys. They love the California rolls, shrimp pieces, and vegetable-tamago rolls as much, but it was still fun to make.

My rice recipe and the idea for the shaped pieces came to me from Barber and Takemura’s Sushi, Taste and Technique. It turned out a double recipe of rice was not enough, so you can see at the back pinwheels. Probably we should call them tortilla maki.

CompositeSushiDinner