Adding Bluetooth to Vintage Headphones – Part 2

bm62_bluetooth_headset

First part of the article.

I received the parts and the PCBs:

pcbs1.jpg

First thing I noticed is that the hole for the screw that will press the button is missing. The cutout in the soldermask is there but not the hole. Damn you cheap chinese PCB manufacturers!

All right, now I remember: I did the PCB cutout in the soldermask and decided to draw it on the mechanical layer later*.

pcbs2.jpg

Well, it’s nothing a Dremel and a needle file can’t fix. And I need to countersink the holes for the screw heads anyway.

Yet another detail: I measured the diameter of the hole of the option for a bigger axis screw (M3) to be 4mm. I might have decided to postpone the before-order-review of my PCB for later™ too…

Anyway, I’m curious to see if everything fits as nicely as in my 3D model. Let’s start with the potentiometer.

The PCB holding the potentiometer and the screw for the pushbutton (hole on the left):

pot1.jpg

The other side, which will be attached to the  headphone ear cup and holds the axis screw:

pot2.jpg

Not bad**. (The nut on the axis screw which sets the spacing of the two PCBs is missing on the photo.)

The whole fist surprisingly well on the side of the ear cup:

potcup.jpg

You can see the pushbutton and its actuator screw.

On the other side, the potentiometer sticks out enough to be pushed or turned:

potcupoutside.jpg

Now the main PCB with the BM62 Bluetooth module and the PIC microcontroller, and the small PCB for the USB socket and the RGB LED:

mainpcb.jpg

They fit nicely too:

fitsornot.jpg

After this, I could build the bracket for the USB and LED PCB. I made it of 2mm thick acrylic sheets which I glued together. The light pipe for the RGB LED is the same material:

ledpcb1.jpg

The glue is two components epoxy. Note the BM62 Bluetooth antenna sticking out from under the main PCB.

The result on the other side is quite ok:

rgb_led_headset_bluetooth.jpg

I filed and sanded the piece of acrylic so it’s flush with the ear cup plastic and gives a diffused light.

One thing I didn’t think through enough is the mounting of all the mechanical parts together.  Because the PCB holding the potentiometer blocks the access to the screws attaching the first PCB to the side of the ear cup, it has to be assembled last. But then the axis screw touches the USB PCB making it impossible to put a nut on it. And you can’t pre-assemble it because you need access the screws holding the other half to the ear cup. Neither can the two PCBs have an angle, because the screw pushing the button has a hole limiting the PCBs angle against each other. Vicious circle. I ended up filing a corner of the PCB holding the USB connector to have space to put the locking nut for the axis screw and inserting the actuator screw last..

Apparently, having your ways with a professional 3D software doesn’t make you instantly a mechanical engineer.

At the end it was tight, but everything could fit without too much cursing. The LiPo battery sits flat against the main board.

bm62_headset_assembly.jpg

Now let’s take care of the guts!

The BM62 Bluetooth module

Microchip advertizes it as “a fully-certified Bluetooth module for designers who want to add Bluetooth wireless audio and voice applications to their products.” and “Easy to configure with User Interface (UI) tool, a Windows® configuration utility or directly by MCU”

A serial interface can be used to command the module (enter pairing mode, wake up, volume etc). For the configuration, there is an onboard EEPROM, also accessible through the serial interface. Microchip provides tools to help with the development (for free and without login/registration -a nice touch):

  • A program to edit the configuration.
  • An utility to download the configurations to the module’s EEPROM.
  • A program to configure the BM62 DSP.
  • A tool to connect to the BM62 via the serial interface and to change and query all the settings and the module status (the Command Set Tool).
  • Some documentation (for the serial protocol).

The first step would be to use the Command Set Tool to play with the module and to get familiar with the different modes.

In reality, I spent some hours trying to connect the tool to the BM62 without success. After cursing the entire earth and the human lineage, I saw on a forum post that the serial interface of the BM62 has to be enabled in the EEPROM configuration first.

This is how looks the user configuration file to generate:

eeprom conf.png

It’s only a part of the EEPROM binary and has to be wrapped with the help of another Microchip tool, “MPET”.

I am not sure there is a comprehensive documentation for every bitfield. Luckily, Microchip’s program “UITool” can generate the text file. Unfortunately, it looks like it was coded by someone with no idea of software design, or anything about Windows 7 and above.

A polite welcome message greats you at launch:

uiwelcome.png

Then, things get a bit messier. Luckily, there is a help function with a nice yellow notepady background:

uihelp1.png

Ok, never mind.

Note also that the help windows sizes are kind of random but fixed, so depending of your screen resolution and DPI setting, it can happen that the scroll bar isn’t long enough:

uisuck.png

The best is, once you generated the text file with your configuration, you still have to go through the MPET thing (a dozen or so clicks, three files to open), put the BM62 in ROM boot mode by holding a pin low while powering it up (too bad if you already soldered a battery – you’ll have to disconnect it), upload the configuration with the third tool and, finally, test your new modifications. Don’t expect to try small changes, unless you have plenty of time.

Anyway, I managed to enable the serial interface of the module. From there, I could connect with the Command Set Tool:

CommandSetToolBM62.png

It looks like it was done by the same unpaid intern, but it gets the job done. A nice touch is the log section: it shows and translates the received and sent data. You can even copy the messages into the Windows clipboard. Woohoo!

The tool gave me a good start with the BM62 and helped me to test and tweak the configuration. It was convenient to debug my hardware and my code, especially in case of doubt.

The PIC code

The PIC18LF4550 will  manage the BM62 module, the pushbutton and the potentiometer.

The program has to:

  • Wake up and power off the BM62 module
  • Put the module into Bluetooth pairing mode
  • Read the potentiometer value and send it to the BM62
  • Put the PIC in sleep mode as often as possible to save the power

For this we have:

  • The pushbutton
  • The potentiometer
  • The red LED of the RGB LED
  • The serial interface

The pushbutton will trigger an interrupt (INT0 -pin RB0). The ADC acquisition will be triggered by the Timer1 and Capture Compare module 2. I tried to use the High/Low-Voltage Detect module to see if the USB cable was plugged and the battery charging (to for example, configure the PIC to act as a USB-serial converter, for debug purposes) but because the PIC gets its power from the BM62 “SYS_PWR” pin, the voltage was too dependent of the current the PIC was pulling from it, making the detection unreliable.

Speaking of the SYS_PWR pin, it’s the output of the BM62 internal power source switch (battery or USB) but it’s a pity the datasheet doesn’t give the current capabilities of this pin.BM62_power_tree.png

(There are three other pins with voltages from the BM62, VDDA, BK_OUT and VDD_IO, but here, the datasheet says you’re not supposed to use them).

Low power design

The BM62 power consumption is around 15mA when streaming music, so the current taken by the PIC at that time isn’t really a problem and because it runs on the internal oscillator, it will be around 2mA max. anyway. The concern is when the headset is in sleep mode, with the BM62 powered off (10uA power off quiescent current). The PIC18LF4550 has a sleep mode current between 1uA and 2uA, quite good.

But the problem is everything else. Here, I messed things up by connecting the potentiometer between the power rail and the ground. With a value of 270 Ohms, the current would have been 11mA all the time, enough to drain the 800mAh LiPo battery I chose in two days. Bad design. Luckily I had spare pads for the PIC I/Os and I connected the Vcc of the potentiometer to the PIC (through a 1KOhm resistor) and I am only switching it on when I need to convert the value. I am also putting all the other IOs in high impedance (inputs) to minimize the sleep current.

I measured the total battery current in sleep mode (both the PIC and the BM62) around 100uA. It gives more than 200 days in standby.

Driving the BM62

Because I hate to spend more time on the embedded code than on the electronics for one-off projects like that, I tried to keep the things as simple as possible. First, I was using the BM62 module’s configurable control pins, but it ended up to be half unreliable, half annoying because of the time needed to change and upload the BM62 EEPROM configuration. I went for the serial communication instead.

Here, Microchip provides an Excel file which lists all the commands and parameters. Someone had the good idea to make a sheet (tab) per command, so you end up with a file with more than 100 tabs. And the links to go back to the command list don’t seem to work with LibreOffice. Luckily, there is a doc file with the same content and linearly organized. It also gives the timings for the data and the error handling. Each serial command is composed of:

  • Start byte (0xAA)
  • Length (2 bytes)
  • Operation code
  • Parameters
  • Checksum

With an optional 0x00 byte at the beginning of each transmission, in case the USART controller of your system can interrupt on this break character (like the PIC18F4550).

The checksum is described as:

Check sum rule: Summation of every byte after START WORD(LENGTH, COM.ID, COM PARAM, CHK SUM) is 0xXX00

Well, it’s not. Here again I found the answer on a forum. Yes, you have to sum the bytes from the length to the last byte before the checksum, but then invert the value and add 1 to it. Here is a working code:

uint8_t calculateChecksum(uint8_t* startByte, uint8_t* endByte)
{
 uint8_t checksum = 0;
 while(startByte <= endByte)
 {
  checksum += *startByte;
  startByte++;
 }
 checksum = ~checksum + 1;
 return checksum;
}

And here, for reference, the function I wrote to pause or play the music when you push the potentiometer button while the BM62 is streaming:

void TogglePause(LEM_state_t *s)
{
 char buf[7];
 buf[0] = 0xAA; 
 buf[1] = 0x00;
 buf[2] = 0x03;
 buf[3] = 0x04;//music control
 buf[4] = 0x04;//reserved ??
 buf[5] = 0x07;//play pause toggle
 buf[6] = calculateChecksum(&buf[1], &buf[5]);
 bm62Puts(buf, 7);
}

An other little detail missing from the documentation is about the two LEDs controlled by the BM62. Of course, you want a blue LED to flash when streaming, because you know, Bluetooth. The other LED can be green. Unfortunately, I could find nowhere in the datasheet or the tools which one of the two pins called LED1 and LED2 is for which color. Of course Murphy got me and I had to bodge the PCB to invert the two. For reference: the LED2 output is forthe blue one.

The source code can be found on my Github. Because I only included the files directly related to the BM62, you won’t be able to compile them directly (I omitted all the USB-serial converter files from Microchip). The code is quickly written and doesn’t reflect my magnificent embedded C skills… 😉

Wrap-up

I made a short clip to show the headset working:

I’m very pleased with the results. I can use the headset a whole week, using it a few hours everyday on a single charge thanks to the 800 mAh LiPo battery combined with the low power consumption of the PIC and the BM62 module. The headset doesn’t seem heavier than before and the sound quality is the same. FTW!

Have a gif before you go :

BM62 LEM Headset.gif

*never

**good enough

Advertisements

Vintage headphones mod – The ultimate hipstery conclusion

I started this blog by modding some “vintage” headphones, replacing the original bad speakers by a pair of Sennheisers. It was almost two years ago.

Last month finally happened what usually happens to audio jack cables: “qsdfg#efdfg#jnd#qdfg#skdglcvnqse” instead of my usual music (which is almost the same, but without the “#”s ).

I decided to totally pimp the new cable by using one of those “fabric 220V cables”. I had the idea for a while, but I didn’t realise the fabric covering isn’t actually glued to the cable and you can use it on an other cable.

I got one on eBay, 1.99€/metre, plus a 5-metre long jack/jack cable of reasonable quality:

01-Fabric-audio-cableI cut the audio cable in half so I can still use the other half for something else (or as a spare).

The fabric covering is very easy to strip (it slides off) but more difficult to put back. It was a good idea to put tape on the cut end of the audio cable, so it could slide easier.

Then, I just glued the fabric to the jack plug and secured it with a cable tie when it was drying:

02-Fabric-audio-cable

Soldering the cable back in the headphones:

04-Fabric-audio-cable(you can see how easily the fabric strips off and also the tape at the end of the audio cable to help with the sliding-in)

After, I added some turns of thin electrical tape, to avoid the fabric fibres to strip out:

03-Fabric-audio-cable

Et voilà:

Headphones1(After testing the new cable, I realised it was the audio socket of my iPhone that had a problem, not the headphones’ jack.. )

Modding a Vintage Marantz 4240 Amplifier / Receiver to add a Remote Control

I already posted this mod on various forums and had Hackaday article written about it, but I thought it would be cool to write a few words about it here.

Marantz 4240 Quadriaradial Receiver

I got it broken, so cheap and repaired it (power amp transistors dead). Then, I decided to add a remote control by motorizing the knobs.

And how it’s made inside:

You can download a pdf document describing the electronics and mechanics here:

PDF Document (8Mb)

The next step of this project will be to make a standalone remote control. I already have some ideas (RF link, controls on a touch sensitive surface, LED feedback), but I have to find a solution for the casing. Maybe something 3D-printed.

Vintage headphones mod

Two years ago at work, I saved those French brand LEM DR80CR headphones form the bin (I work at an airport).

LEM DR 80 CR Headphones Senheiser modded

After opening them up and checking the available space in the earcups, I decided to upgrade them for Hi-Fi. The original earcups contained crappy 8 ohm speakers, like the ones in cheap alarm clocks, impedance-balanced with a small transformer. (The primary purpose of the headphones was to listen to air traffic radio, not music).

LEM DR 80 CR Senheiser modded

Then, I bought Sennheiser HD205 headphones. They have a good quality sound with compact and comfortable earpads. (Unfortunately, I don’t have any photo of the teardown, but the build quality is good, lots of screws and superior moulded hard plastic). They’re more than enough for music listening. Any headphones above $200 are just a rip-off (unless they have other features than just music reproduction)

Sennheiser HD_205_II

The LEM headphones have removable imitation leather earpads. Under them, I found an aluminium gird plate where the speakers were attached to. The gird was riveted to the earcups plastic.

LEM Headphones Sennheiser

First, I removed the speakers, the transformer and all the original parts, leaving only the wires running from one earcup to the other. I cut out an opening in the aluminium gird where I could fit the Sennheiser earcups. I had to cut off some plastic, but I could leave the screw wells and the leather/foam ear cushions plus the plastic assembly that is volume-matched with the speakers.

LEM Headphones Sennheiser

I made holes for screws in the aluminium gird, to be able to attach the Sennheiser speakers to. I had to make small pieces of soft plastic to link the speakers to the gird. They also act kind of springs and cancel vibrations.

LEM Headphones Sennheiser

I also left the Sennheiser wire and jack plug. I’m still looking for a nicer one, that would be spring-shaped with a fabric ext. insulation (if someone have brand names…).

Was it worth it?

Totally! The LEM headphones have a unique vintage look (I did the mod before the vintage-headphones-signed-by-famous-douchebags started to be sooo popular), combined with the great Sennheiser sound quality. Plus, they now have a greater noise isolation due to the double earpads (it’s almost dangerous to walk on the street, as I barely hear cars coming) and stay pretty comfortable to wear, even several hours in a row.

On a more electronics-focused side, there’s plenty of room in the earcups to fit batteries and circuits to make for example, a Bluetooth version.

In conclusion, except for the jack cable I still have to find, it’s a complete win!