Stellaris RainbowLED (qs-rgb) Colour Fix

I have just received my two TI Stellaris Launchpads, and have been having a quick look at the software and usage. So far, it seems very impressive (especially given the promotional price) and the power and complexity of the ARM chip used is clear just looking at the default program installed. There is, however, a slight error in the software. On my two boards, if in a terminal you enter:

> rgb 00FF00

instead of the expected full green, it’s blue. Likewise, 0000FF gives green, not blue. This is obviously not a massive issue, but if you want to fix it simply replace lines 156 and 157 in the rgb_commands.c file with:

g_sAppState.ulColors[BLUE] = (ulHTMLColor & 0x0000FF) << 8;
g_sAppState.ulColors[GREEN] = (ulHTMLColor & 0x00FF00);

Recompile, and you’re done!

A relay attenuator preamplifier – bare bones

I recently acquired a second-hand Quad 306 power amplifier, which has notoriously high input sensitivity even after a couple of resistor changes to improve this (more on this another time). Having to keep the volume on the PC to about the 5th lowest increment did not leave a lot of room for volume alteration and kills the dynamic range achievable from the system. I had made up some boards a couple of years ago based on an excellent design by Jos van Eijnhoven, but had never got round to finishing either the boards themselves or the software for the control chip. Here, I would like to detail some of the features of this project.

Control board

All control of the inputs and attenuator (described below) are controlled by a PIC16F818 microcontroller, running at 4 MHz from the internal oscillator. The software is simple and loops through repeatedly to control the input selector and the attenuator. The code was written in Hi-Tech PICC 9.80, and it can be downloaded here. The only real point of interest is the code for the button to cycle through the inputs, which goes dead until it’s been sensed to be have been released. The value read from the ADC is shifted into the PORTB register directly. Also on board is a simple headphone amplifier based around TI’s TPA6120 chip. No input buffer is required for this as it will always be driven from a low-impedance source. This section will initially be left unpopulated as there’s a good chance I’ll put a better headphone amp in there at some point.


Although the majority of my listening is done through the PC these days, the flexibility to have another source or two connected was important. Thus, the design has inputs for 3 sources, with their respective grounds isolated. While this doubles the number of relays on board, it avoids any potential ground loop issues. The relays are driven by a ULN2003 transistor chip, in turn connected to and powered by the control board.

Inputs front

Relay attenuator board

Attenuation is provided using the design and values linked above, although on my own PCB. 6 relays (=6 bits) gives up to -64dB reduction across the range. The relays used are Omron G6K-2Ps, which are rather expensive but can often be found cheaply on eBay etc. Resistors are good quality Welwyn RC55s, available in all required values from Farnell. Again, the relays are driven by a ULN2003, all powered from the control board.


The buffer is there to change to the high impedance output from the attenuator board in to a low impedance output for use with a power amp, headphone amp etc. The design borrows heavily from the JISBOS (JFET input, Bipolar output) developed on Head-Fi, and subsequently maintained by Ti Kan (see refs at the bottom). I originally bought a pair of the boards, but it turns out the 1/8 W through-hole resistors are next to impossible to buy here any more. Additionally, I didn’t want too many holes in the chassis, so opted to design my own board using the original layout as a guide. Resistors are changed to SMD 0805 where appropriate, and the mounting holes are the same as for the attenuator board allowing them to be stacked. The output transistors hang out from the side, allowing them to be heatsunk.

Power supplies

As this is a digitally controlled system, two power supplies are required; one for the analog and one for the digital sections. The analog section is powered at ±13.5 V by a σ22, which while over-rated for this task gives a very clean tracking output. Due to the potentially quite high currents required in the digital section (up to 8 relays on at one time), a linear regulator to take the analog +13.5 V to +5 V was not ideal due to the heat sinking requirement. The digital section is powered by a very small switching power supply, which gives 2.1 A at 5 V and doesn’t need a transformer or any heat sinking which saves weight, space, and money.

References & Suppliers

I’ll put up a full selection of files after I’ve actually built it all up, but this is just an introduction to the project and I hope it’s useful for your own projects.

Relay attenuator design: Jos van Eijnhoven
σ22 power supply and maintainer of the JISBOS buffer project: Ti Kan (amb Labs)
Parts: Farnell, Rapid Electronics, Cricklewood Electronics
Case: AudioKit