Upgrading a BitHead, Part II: Microphone input

This is a story about putting in a lot of effort and getting a very small amount of value out. I just wanted to start off that way, because I know what you're going to be thinking the whole time you read this. The thing is, of course, I knew that this was going to be a lot of effort, and I knew what the upper bound was on the value of the results before I even started. But then again, what is time for, if not to be frittered away on silly projects?

Recently, at work, we moved to a new building that has even lower cube walls than before. And, to make matters worse, they took away our desk phones, with the expectation of using softphones from now on! This is something of a problem, I found, because I don't have a headset at work: my music listening setup was a pair of Shure SE215s, along with a HeadRoom BitHead amp. (You might remember that amp from a few years ago, when I upgraded it with new op-amps and noise filters.) It was neither the case that my SE215s had a microphone, nor that the BitHead amp had a circuit to deal with a microphone. So I did the only logical thing: I picked up a pair of q-JAYS (which I had been waiting for an excuse to do for a while), and decided to mod the BitHead to accept a microphone input.

Here's about how it went.

November - December 2017
Joshua Wise; CC BY-SA 3.0
(comments over on DreamWidth)

(click for big)

Version 1: Perfboard hijinx.
17:39, 2017-10-07

I tore the thing apart again to come up with a plan of attack. Apparently, the BitHead is based on a TI PCM2900 USB codec chip -- and, to my surprise, not only does the chip have a line-in pin, but it also has three HID-keyboard pins! I was in luck: I'd be able to use not just the microphone, but also the little buttons that go with it.

All I needed to do was to build a circuit to bias the microphone (microphones want to be powered in a very specific fashion), and to build a circuit to detect the specific resistance values that the headset would present for each button press. So off I went to DigiKey, and ordered a handful of parts: a few resistors and capacitors to make the bias network, and a microcontroller (specifically, an ATtiny102) to read the resistance values from the buttons and convert them to digital signals to send to the codec chip. In the mean time, a little bit of time soldering got me the pins I wanted on the part, and my new 4-pin headphones jack soldered down on the edge of the board:

Do you feel lucky, punk?
18:35, 2017-10-07
New connector is in...
00:21, 2017-10-08
And away I went, building the bias circuit. I ordered a bunch of surface mount parts, in 0603 form factor -- and one even in 0402. Why did I do this? I have no idea. The voltage regulator (for a 2.2V bias voltage), resistor, and DC blocking capacitor were easy enough, once I re-learned how to solder surface mount parts.
Why did I buy 0402s, again?
01:29, 2017-10-08
My attention next turned to the microcontroller. I wanted to find a way to test it other than in-circuit, so I soldered the micro down to a different piece of perfboard, and bonded it out to pin headers so I could put it in a breadboard. I realized that I didn't have any AVR programming hardware around, but I did have a USB-to-serial board around that was powered by an FT232, which people had apparently used in the past with success for programming the parts that I had. In an unsurprising twist of "in for a penny, in for a pound", the pins I needed on the FT232 weren't brought out to the headers on the board, but I had already played the "solder directly to the pins of a TSOP" game once that weekend, and I wasn't afraid to do it again.
In for a penny, in for a pound.
14:30, 2017-10-08
Visually, it seemed perfectly fine, except for the fact that it didn't work: the AVR programmer software couldn't seem to receive any data. I did some probing with a multimeter, and found that the receive pin -- unused on the breakout board that I had -- was shorted to ground. I cursed. Unwilling to be defeated so easily, I took the first answer that should cross any right-thinking person's mind when confronted with such a problem: I pulled the heat gun off the shelf, pulled the part off the board, and bent the pin that I cared about up in the air to solder directly to.
15:47, 2017-10-08
FTDI board all put back together. Wait, what was the actual goal of this project again?
16:10, 2017-10-08
Amazingly, once I got the software loaded on the device, it worked right the first try! This is unusual for me. I rarely write correct software on the first time, much less assembly-language software for a microcontroller that I've never worked with before, with peripherals that I've never used before. I must have had an integer underflow in terms of luck. Once I got the software up and running, I finished wiring the microcontroller onto the piece of perfboard, and tacked the perfboard down to the BitHead with a bit of hot glue.
The worst of the tiny stuff is wired up.
22:16, 2017-10-08
Assembled, with a programming header covered in Kapton tape.
00:40, 2017-10-16
It fits in the case, barely.
00:43, 2017-10-16

And so went the first iteration of it. There were a few problems with the first version, though: for one, it didn't really fit in the original case. And for another, the microphone was way too quiet: apparently the PCM2900 chip takes a "line-level" input, and the microphone is quite a lot below that. And, if I turned the gain up in software, there was an infernal whining sound; apparently, the microphone signal had some sort of noise coupled onto it from wherever I was drawing my power (which made sense, since I didn't use any decoupling capacitors to speak of).

I was going to need some analog gain -- an amplifier of some sort. And, clearly, this meant that I'd have to do it again, because there was no way I was going to solder an op-amp circuit onto that piece of perfboard. I was left with only one option: I was going to have to make a board for this.

Version 2: My first PCB in years...

Back when I was in high school, and even a good chunk of college, fabbing out a PCB was prohibitively expensive. For one, my project budget was basically nothing, but for another, PCBs were just plain and simple way more expensive back then! I remember prototype PCB runs being on the order of $250 for a few PCBs -- and that's if they're obvious rectangular PCBs that have nothing fancy about them, and if you were okay with them taking a month or so. So whenever I had cause to do a board back then, I'd do it at home, in my basement, with laser printer toner transfer to make an etch resist, and all manner of noxious chemicals to do the etching; and the quality always sucked, so I never designed with particularly small components.

These days, PCBs are dirt cheap, and fast. OSHPark prices entirely by size, with no minimum setup charge, at an insanely low $5 per square inch -- and for that, you get three copies of a two-layer board with solder mask and silk screen on both sides. If you want to go even cheaper than that, Seeed Studios will do a 15-in^2 board and give you 10 of them, all for $4.90, if you're willing to wait for it to arrive from China! PCB design software has come a long way, too -- the terrible user experience that EAGLE had to offer that you had to pay $100+ for a license for can now be had as open source software, too.

So, armed with all of these modern advancements in hobbyist electronics, I truly had no choice: I was going to make a board.

The first step in this affair was to take some measurements. I knew that I wanted my new board to sit down where the old headphones jack lived -- basically, I wanted it to be a 'headphones jack on steroids', that was (almost) a drop-in replacement for the old one. For bonus points, the headphones jacks that I chose for the first attempt happened to be flush-mounted -- that is to say, they occupied some of the same vertical space as the PCB, so it really would sit down exactly like the original! I took out my trusty NVIDIA ruler and took some photos of the board to scale, and started making measurements in Photoshop of the dimensions I'd need.

Front side of the board. There are some tight space constraints around the battery holder.
17:02, 2017-10-26
I spent a good long while doing schematic capture, and then laying it out in KiCad. Laying out a board took some initial re-learning curve, but once I was back in the groove of it, it took no time at all, and was quite a lot of fun!
Two weeks and $15 later, boards arrived! I started building one up -- they fit perfectly into the space they were supposed to land.
Unpopulated board seems like it's going to fit.
22:11, 2017-12-05
Easter egg.
23:39, 2017-12-07
Fully built up. Except for the potentiometer that I forgot to order, because I'm a dummy.
23:42, 2017-12-07
Board is alive with a dummy potentiometer, and fully checked out! Or so I thought.
00:01, 2017-12-09
Once the board was up and running, it was time to attach it down. I had included two plated holes in the board so that it'd solder directly onto where the old headphones jack lived, but I still needed to find a way to get the output wiring to the codec on the other side of the board. I picked a spot on the BitHead board that didn't have any traces, and got out a drill and got to business...
I forgot, is this getting worse or better?
11:31, 2017-12-09
It's like it was meant to be there!
22:52, 2017-12-10
The routing on the bottom actually looks pretty good.
22:50, 2017-12-10

It wasn't all perfect. The op-amp circuit I designed was, to put it lightly, full of crap. It picked up noise from basically everywhere. I came up with a rework to redesign it and fix it up, involving standing three components on their ends, and soldering to the other ends. (You can zoom in on the above, if you're so inclined to see it. And, thanks to kevtris on this one, who stared at my schematic and figured out what I did wrong in an instant, after I spent hours beating my head!) But after that fix, it worked! Microphone sound quality is not as audiophile-grade as the rest of the system, but it's certainly good enough for audioconferencing -- and, anyway, the MEMS microphones in these headsets are pretty miserable. I'm pretty proud of how it came out; visually, it doesn't offend more than it has to, and the results are as good as I could have hoped for.

From then, the only thing remaining was to fit it into its case. The extra components increased the Z-height of the unit just enough that it barely didn't fit into its enclosure. In the car-modding community, there exists this wonderful euphemism, "clearancing", which roughly means "to beat the snot out of with a sledgehammer until it fits"; in this case, I used a Dremel to "clearance" the some of the plastic away in the upper case. Finally, I reassembled it all -- and it all still works!

The Dremel's sanding wheel makes short work of the plastic involved.
17:32, 2017-12-31
Ready for final assembly.
18:06, 2017-12-31
All buttoned up, with headset controls working.

And that, I suppose, is the story of how I spent $107 in parts (including spares and duplicates...) and what must have been 40 or so hours of engineering time to add a microphone input to a headphones amp that cost about $150... seven years ago. I was going to say that it surely couldn't have been worth it, given how much the price of such things has dropped in the interim ... but as it turns out, nothing on the market has this feature! And anyway, the crossfeed circuit on the BitHead is really good, and giving it up would be a shame.

And anyway anyway, the most important thing is that this was cooler.

Joshua Wise, 2017

Oh, by the way: if you don't have a Dreamwidth account, but you want to get notified so you can read more things like this when I write them, I also have an e-mail list that you can sign up for. I promise I'll only send mail for things that I write that go here on this blog. So, you know, if that's your thing, there you go.

"It works!"