Thursday, March 28, 2013

Adding Bluetooth remote control to computer speakers

Introduction

Some time ago, I had to replace the volume pot/power switch in my Creative computer speakers.
Unfortunately, they use a non-standard pot with a switch, and I didn't bother finding a proper replacement, just did a quick fix with a generic pot and switch.
It worked well, but looked bad. So now I decided to repair it properly and put everything back together, while I'm working on it, might as well mod it a bit...

The volume control PCB and my quick fix

At first I just wanted to add a rotary encoder instead of the volume pot, but if I'm going to put a microcontroller inside I might as well add some more features, so I grabbed an LED and a Bluetooth module and got to work...

Hardware

Here's a list of hardware used in this project:

Creative 5.1 speakers

TPL0202 digital potentiometer

Rotary encoder with switch

ATmega8A

RGB SMD LED

BTM-5 Bluetooth SPP module

And here's a basic diagram of the whole thing:

Basic diagram of the project

Speaker PCB

The original volume/power/bass control PCB is very simple, just two pots, two jack sockets, some resistors, cable connector and an LED.
The main speaker unit supplies 5V to this board, and the speakers are turned on when this 5V is applied to one of the pins.
Unfortunately I have overestimated the power of of that 5V source and so my modification requires an external 5V power supply, but that's no problem.
There is not much I had to do to the PCB, just removed the pot, removed the green power led, changed some resistors (because the original pot was 50k and the digital one is 10k) and cut out some more room for the rotary encoder.

Digital potentiometer

I'm using a TPL0202 digital potentiometer from Texas Instruments. It has two outputs, 256-position resolution and is controlled via SPI.
The chip is QFN16, but I have somehow managed to solder it (after a couple of tries :P) onto a home-made PCB using hot air.

Rotary encoder

It's just a 20-step encoder with a button. The button is used for a couple of functions. Firstly, it is used as a power switch. Secondly, when the button is pressed while turning the knob, the volume is changed in more precise steps. And lastly, when pressed during power-up, it causes the chip to enter the bootloader (yes! wireless software update!).
The shaft of the encoder sticks out higher than the original knob, but instead of shortening it, I've decided to make the knob a little taller (with a piece of PVC), so there is no gaping hole and it is easier to manipulate.

The microcontroller

The ATmega8A is the best chip ever, costs less than $1 and has so much to offer.
Here's the schematic:

Schematic of the microcontroller part

I've uploaded a serial bootloader to the chip, which allows me (thanks to the Bluetooth SPP module) to update the firmware wirelessly (trust me, I'm not opening that case ever again ;P).

RGB LED

Every project needs blinkenlights! I used a cheap SMD RGB LED, controlled with software PWM by the uC. It lights up when the speakers are turned on and shows the current volume in color (pink means 'ear damage imminent').

Bluetooth module

The module I'm using is a BTM-5 SPP module. It acts as a UART-Bluetooth bridge and works automatically and transparently. It's the easiest way to add wireless connectivity to your project.
You can get one of those off ebay for less than $10.

The communication protocol is just a couple of short commands sent over UART to the chip, for example: 'on', 'off', 'get' (get the current volume), 'v099' (set volume to 99).

Crazy Clever. Think I would have been tempted to go for broke and simply replace the entire enclosure with a featureless plastic box and gone to ONLY bluetooth control...but that's just me extending on your great idea.

Awesome. How much trouble would it be to actually stream audio to that control pod? Would you have to have any processing done on the actual pod itself or could you just send the song over the bluetooth?