Sunday, November 24, 2013

Improving the bass response of a (cheap) subwoofer amplifier system by *reducing* its bass response

Several weeks ago I happened to be at a local electronics type store (I'll admit it, it was Radio Shack!) and they had on clearance - for a pretty good price - a nice-looking set of computer speakers (40-288).  This set consists of a pair of small-ish speakers for the upper-bass, midrange and highs along with a single, larger-ish "subwoofer" for bass.  I didn't get these for a computer, but to reinforce the sound from a small, flat-screen TV that I have near my electronics workbench that has appallingly bad internal speakers.

Figure 1:
The inexpensive speaker/subwoofer system.
Click on the image for a larger version.
Upon connecting them to the TV I was immediately struck by the fact that they sounded OK - except that the bass sounds were frequently breaking up at moderate volumes during musical bass notes and the sound of explosions - which are very common on TV.  I flipped the subwoofer on end and noted that, as expected, it was a ported enclosure (see Figure 3) which is typical for low-frequency speakers, large and small.

Knowing the size of the speaker's enclosure - roughly a cube that is 11.5cm on a side internally - and also the diameter of the speaker itself - about 6cm - I also knew that it could not provide extremely low bass-frequency response.  Based on a guess, I figured that its usable frequency response would extend down to roughly 125 Hz or so:  You just can't get much lower than that with reasonable efficiency using a simple ported box and (inexpensive) bass driver that is that small!

The problem:

The problem with the design of this subwoofer is one that is commonly seen:  If the system is "asked" to amplify frequencies well below the range that may be reproduced by the bass driver and its enclosure, several things are likely to happen:
  • Power will be wasted with the speaker's cone flapping about and frequencies well below those in which it is likely to be able to move air efficiently.  What this means is that instead of working on frequencies that can be reproduced, much of the amplifier's power will be used up (e.g. wasted) on these other "useless" (to the speaker, anyway) frequencies!
  • The speaker itself may be damaged.  On a ported enclosure such as this, driving with too low a frequency, the speaker just can't transfer energy to the air mass efficiently and in so doing, its cone moves too "easily."  If this happens the speaker's excessive cone excursions can cause physical damage and heat can even build up in the voice coil assembly.  The latter is a bit less likely to happen with this small of a speaker and with the modest amplifier power level involved, but it is still possible.
  • It will sound terrible.  With the amplifier clipping, trying to amplify too much low-frequency range content that cannot be reproduced, and with the speaker itself flapping about trying to reproduce the low-frequency sound, you can end up with distortion, popping and buzzing.
Connecting it to an audio generator I swept from about 1 kHz down to 10 Hz or so and as expected, the crossover point from the smaller speakers to the subwoofer was in the general area of 200 Hz - not sharp, but definitely there.

I also saw that the speaker was still being fed power when I got down below 10 Hz, at which point uselessly flapping about as there was no way that it could reasonably be expected to efficiently transduce energy at that frequency - and that was the reason why it sounded like it was breaking up on low bass notes!  Careful observation revealed that the amplifier seemed to have a slight "peaking" effect in the area of 100-200 Hz - likely done to slightly emphasize the frequencies best conveyed by the subwoofer.  (I didn't reverse-engineer the circuit enough to determine if this was intentional or not.)

The "fix"

Figure 2:
 Bottom-side location of the capacitor to be changed along
with the added 10k resistor.
Click on the image for a larger version.
Popping apart the satellite speaker that contained the amplifier I started poking around with an oscilloscope while varying the frequency of the audio generator and quickly found where the wipers of the dual volume control went over to a pair of surface-mount 3.6k resistors and the audio from the left and right channels were combined ("3R1" and "3R2" in Figure 2).  I then followed the audio through a 2.2 uF coupling capacitor (mounted on the other side of the board) and then to the input of the audio amplifier for the subwoofer - a stereo chip configured to drive the subwoofer in bridge mode to achieve maximum power power output for the supply voltage.

Note:  I didn't remove the heat sinks, so I don't know which audio amplifier chips are used in this speaker system.

At this point something struck me:  In comparing with the oscilloscope, the audio level "before" and "after" the 3.6k resistors used to combine the left and right channel I could see that there was practically no difference, indicating that the amplifier itself minimally loaded the audio line beyond that point.  Having just followed this signal path I also knew that there was nothing that limited the low frequency response of the amplifier to something within a reasonable range of what the speaker itself was likely to be able to reproduce!

To satisfy my hunch I replaced the 2.2uF capacitor with a 0.022uF capacitor and noted that it only just started rolling off the frequency response below 100 Hz, indicating that the amplifier's input impedance was likely in the range of 50-100k, so with the 2.2uF coupling capacitor, the amplifier was going to amplify signals down to less than 1 Hz with minimal rolloff! What I needed to do was to limit the frequency range of the amplifier to something more reasonable in terms of what the speaker was likely to be able to reproduce!

To do this, there are two reasonable options:
  • Build a nice, multi-pole high pass filter that will sharply cut off the audio below a certain frequency - say, 100 Hz.  This would require either a transistor or two or an op amp along with a handful of other components and would be built upon a small circuit board that was added into the enclosure and connected inline with the subwoofer amplifier's audio path.
    Figure 3:
    The bottom side of the subwoofer cabinet showing
    the driver and port.  If you throw too-low a frequency at this sort
    of speaker it just thrashes around and doesn't really
    produce much sound.  It's always  best to send only those frequencies
    to the sub's amplifier that the speaker will be able to reproduce!
    Click on the image for a larger version.
  • Just kludge it and make a simple R/C high pass filter.  This wouldn't as sharply cut off the low frequencies, but it would likely do the job of preventing ridiculously low frequencies from getting to the amplifier and cause it to waste effort!
I chose the latter.

In poking around on the audio input pin of the amplifier I saw that there was no DC offset, so I temporarily connected a 10k resistor between it and what appeared to be a nearby ground - at least, it was where there was a capacitor connected across the input to roll off the high frequencies above which the subwoofer was not supposed to amplify.  Temporarily tacking the 2.2uF back into place, I saw with the oscilloscope that the 10k resistor made almost no difference the subwoofer's output level and that its output remained clean.  I then made the 10k resistor a permanent part of the circuit, soldering it on the bottom side of the board as can be seen in Figure 2.

Grabbing a calculator I crunched a few numbers and decided that a 0.1uF capacitor (a nice, round value) in place of the original 2.2uF capacitor would be worth trying as it, in conjunction with the 10k resistor, would provide a -6dB roll off frequency of about 159 Hz - a fact confirmed using the oscilloscope and audio generator.  With the amplifier's slight "peaking" noted above, the power wasn't down by 6dB at 160 Hz, but closer to 100 Hz at the -6dB point.  (I used a plastic capacitor rather than a ceramic capacitor because the latter would have had terrible temperature stability.)

Feeding some music with a lot of low bass into the speaker system, it seemed to sound just fine:  Reasonable low-frequency response and no obvious distortion - even at fairly high audio levels.  Tacking the 2.2uF capacitor back into place the perceived bass response improved slightly, but now the audio amplifier was breaking up badly with obvious clipping and distorting as before.  Taking the 2.2uF capacitor off again I tacked another 0.1uF across the first (for a total of 0.2uF) to set the hypothetical -6dB frequency to about 80 Hz and could hear a very slight increase in amplitude of the bass notes and a bit of occasional clipping at fairly high volume, but it didn't seem to be worth it to have the extra capacitor on there so I left it at just 0.1uF.

Figure 4:
The completed modifications - along with the added
heat sink material.  This is just a scrap of copper - probably from a
piece of water pipe - that I cut down the side, cut tabs to match the chip's
"heat sink" and ground pins on the foil side of the circuit board, and then,
using a very hot soldering iron to get the job done quickly, attached
it to the circuit board.  The foil side of the circuit board faces up
within the box so the heat actually radiates better this way!
Click on the image for a larger version.
While having the unit apart I noticed that the heat sink of the subwoofer's amplifier chip was far too hot to touch after a few minutes of abuse from the signal generator.  Typically, these sorts of chips have built-in thermal protection, so it was not too likely to be damaged by getting hot, but this thermal protection often works by causing the amplifier to cut its power back - usually causing distortion.

To be sure, my reducing the frequency response of the amplifier greatly reduced that amplifier chip's thermal load, but I decided to solder a bit of scrap copper to the heat sink fins on the "bottom" side of the board (which actually faces up when the board is installed) to increase its heat dissipation ability.

Now, with the very low frequencies eliminated from the amplifier it could put more power into reproducing those low frequencies that were well within its capabilities without wasting it on frequencies that were too low.

Putting the entire thing back together, it now works fine in its intended role:  As a half decent sounding speaker system for the small TV!


This page stolen from

Monday, November 11, 2013

Attention-getting brake light "modulator" for a motorcycle.

Figure 1:
Figuring out how to remove the tail light.  It required
removing the bracket and license-plate holder just to
get to the bolts that hold the light in place.
Click on the image for a larger version.

My brother recently got a Yahama Bolt, a fairly new-model, medium-sized motorcycle.  As is the case with most motorcycle riders, "preventing invisibility" is always a big deal as it is often the case that casual riders of bikes of all sorts (motorized or not!) tangle with a car when the driver of the latter didn't see them!

Among a few other things done to enhance safety and visibility, he wanted to "modulate" the brake light - that is, rather than just going on and off with the application of the brake, that it do "something else" as well.

It is becoming more common that some new-model vehicles blink their brake lights in some sort of attention-getting flash sequence - and doing so makes a lot of sense:  The human brain is very good at detecting when something changes or is out of the ordinary so anything that stands out from the routine is likely to grab a bit of extra attention!  The hope is that if even a single driver is jolted out of a sleepy stupor or their attention drawn from their texting by this sort of thing that it will be worthwhile.

 First, the obligatory warnings and weasel words:
  •  The brake light system is a safety device on which your life - and the lives of others - may depend.  Modifying it in any way runs the risk of reducing its reliability, particularly if due care has not been taken during design, building and installation to maximize reliability.
  • There are no warranties or guarantees, expressed or implied, as to the suitability of this project for its intended use, or for any other use.
  • Nothing in this article should be construed as offering an opinion as to the legality of the use of this sort of device.  It is up to YOU to determine if this device is legal/lawful to use.
  • If you choose to construct a device similar to this, it is up to YOU to make it as reliable and safe as possible and YOU assume any risks should any injury to anyone occur as a direct or indirect result of this sort of device!  The author of this article will not be held responsible for any injury or damage or other liability that might result!
  • Improper design, construction and wiring could result in damage to the vehicle's electrical system and/or wiring as well as other safety concerns.  YOU must assure that the work/modification has been done properly to minimize any risks as well as be aware that doing so may void warranties, reduce reliability, cause damage, etc.
  • Finally, the assertion that a "modulated" brake light catching the attention of other motorists and possibly improving overall safety is an opinion rather than a statement based on scientific research or fact and anyone reading this page and/or taking inspiration from it should take it as such!  It is up to YOU to determine if, in fact, this sort of project has positive or negative effects on overall safety!
  • You have been warned!

Figure 2:
 On the bench, the unit  in "dim" (tail light)  mode.
Click on the image for a larger version.
Figuring it out:

First, we analyzed the existing brake/tail light assembly of the Bolt after removing it from the bike.

Using three wires for connection (including a black "ground" wire) it consists of an array of 19 high-brightness red LEDs and internally, it seems to be "diode-ORed" between the two voltage sources.  If voltage is applied to the tail light wire (blue), the 19 LEDs light rather dimly and the entire assembly pulls about 40 milliamps at 14 volts.  If, however, you apply the same voltage to the brake wire (yellow) approximately 400 milliamps is pulled and the result is enough light to give you a bit of a headache and cause you to see red and green spots for several minutes!

Further analysis indicated that the tail light voltage was applied any time that the ignition key was on.  As you might expect, the brake light voltage appeared only when you applied them:  No special PWM (Pulse-width modulation) or anything else was present, this likely due to the fact that this light assembly was (probably) designed to drop in where one might have had an old-style, dual-filament incandescent lamp.

With its using only on/off voltages, this project would be easy!

The build:
Figure 3:
Throwing together the code for the tiny computer.
Click on the image for a larger version.

As strange as it might seem, the easiest way to make a device that flashes the light in a particular pattern is to throw a computer at it!

Fortunately, this is something that is pretty cheap and easy to do these days and I knocked out some very quick "C" code using a compiler for a low-end PIC microprocessor - a PIC12F675.  The device used was an 8-pin DIP (through-hole) processor chip (the same size as a 555 timer) that has a number of useful peripherals like A/D converters, built-in timers and a few other things - but I wouldn't need most of them:  I picked it because it was the smallest, simplest microcontroller that I had laying around.  Some of its features - like the watchdog timer and "brown-out reset" would be used to make sure that it "booted up" reliably and quickly, within a few 100's of microseconds after power was applied, every time.

While the computer code could have been done in assembly, I used C since I have the development tools (suitable tools can also be found for free...) and it was be very easy to bang out quick, dirty, and reliable code just to blink the light!

In the code I defined an array of 0's and 1's in program memory that corresponded to the desired blink pattern (0 = off, 1 = on) and indicating the end of the array is a "255":  The code would simply step through the array from the beginning and stop when it hit "255", leaving the light on.  Between each step a short delay (25 milliseconds) was added to slow down the process and make the blinking perceptible:  Without it, the entire sequence of blinks would have occurred in a few 10's or hundreds of microseconds and may not have even been noticeable!

Figure 4:
 Building the prototype on solderless prototype
board for initial hardware and software debugging.
Click on the image for a larger version.
Just because I was lazy, I defined all of the PIC's pins as outputs (except for the one that can only be used as an input - which I grounded) and the output pin that worked out to be the most conveniently located when I crammed the parts on the board was routed through a series resistor (R3) to an NPN transistor, Q2.  The collector of this transistor was connected to the base of a PNP power transistor (Q1) via another resistor (R2) and when the PIC set the pin to high, the NPN was turned on, yanking down on the PNP's base and turning it on, applying power to the brake light lead.  The total voltage drop across Q1 when the light was on?  Less than 200 millivolts (and a fraction of a watt heat dissipation) - barely even worth mentioning, let alone even noticeable in its effect of the light brightness!

Note:  In the diagram below, I happened to use pin 7 since it was closest to R3, but I could have used any one of the other output pins (shown with no connection in Figure 6) instead.  Do not connect multiple pins together.

To keep the computer happy a 78L05 regulator (U1) was used to drop the 12-15 volts of the motorcycle's power bus to the 5 volts required.  Because vehicular electrical systems are often "noisy" with spikes and glitches, I used a series resistor (R1, 47 ohms) and a filter capacitor (C1, 47 microfarads) to "clean up" the power applied to the regulator.  These components were selected so that not only would spikes be filtered out, but even very brief taps and releases of the brakes would trigger or re-trigger the computer quickly and reliably.  There is also another resistor, R4 which, should the processor NOT boot up for some reason, will pull the base of Q2 high and turn on the light since the hardware default of the processor is to have its pins in a high-Z state:  After all, we do want the light to WORK if your life may be depending on it!

In just a few minutes I had a circuit and its code working on a piece of wireless prototyping board.  After a bit more fiddling of the code to make it flash the desired sequence at the rate that my brother wanted, we were ready to commit ourselves to building a "permanent" version.

Figure 5:
 The newly-built board, ready for testing shown
laying atop the initial version of the
 schematic diagram that was built onto the
prototype board seen in Figure 4.
Click on the image for a larger version.
After analyzing the unused volume inside the tail light enclosure I could see that there was just enough room to cram a small board below the portion of the assembly containing the LEDs (see Figure 8) so I proceeded to build the circuit onto a small piece appropriately-sized phenolic prototype board. As can be seen from the pictures, I didn't make the board any larger or taller than absolutely necessary - at least with through-hole components - nor did I use a socket for the processor since I didn't want there to be the possibility of it falling out.  Were this device to have been built using surface-mount components it could have easily ended up being about the size of a postage stamp!

Once the circuit was built and tested I mixed a big blob of 5-minute 2-part epoxy and liberally coated both sides of the circuit board - this, to completely immobilize the circuitry to protect it from vibration as well as moisture.  Constantly rotating the board for a few minutes to keep the epoxy from dripping off, it soon began to set up and I then used a heat gun to warm it (to about 180F) - just hot enough that I could smell the epoxy, all the while moving the board about since the heat momentarily caused it to re-flow.  After 2-3 minutes of that, the hot epoxy had hardened to the consistency of a rubber pencil eraser so I let it cool.  In another 10 minutes at room temperature it was almost rock-hard, the curing process having been greatly accelerated by the application of heat.

The unit was re-tested and found to be working so we could now wire and mount it within the tail light enclosure.

Figure 6:
 The final version of the schematic diagram of the circuit for "modulating" the brake light.
While pin 7 (CP0) was used to drive Q2, pin 2, 3, 5 or 6 could have been used instead since all of the other pins shown in the diagram as being unconnected flash the sequence as well. While not shown in the above diagram, it is recommended that a resistor with a value of between 10k and 100k be connected between the emitter of
Q1 and the collector of Q2.
Click on the image for a larger version.
For wiring onto the existing circuit I bared a short section of the insulation of the light's black wire (ground) and soldered it to the circuit.  Then, cutting the light's original yellow "tail light" wire I put the circuit inline with it, soldering and insulating the connections with heat-shrink tubing.  I then squirted a small blob of silicone seal on the inside of the milky-white plastic housing containing the LEDs where the board would go and plopped it into the small gap where I'd already pre-fit it.  Reassembling tail light housing, it all fit perfectly as seen in Figure 8.

Figure 7:
 The tested and working board, now coated with epoxy and
ready for install.
Click on the image for a larger version.
Testing once again on the workbench to verify that it worked after putting it all back together (it did!) we went back to the garage and after a several minutes of squinting and cramped fingers we managed to get all six of the bolts that hold the light and the shield/license plate holder assembly in place back together using some blue thread locker so that they wouldn't rattle loose.

We now had the light on the bike and working!

What does it flash?

When programming the PIC processor, we changed our minds several times about what, exactly, it would flash.  We first thought of the Morse code "V" which is "di-di-di-dahh" - like the beginning of Beethoven's 5th symphony.

We then tried the word "STOP" in Morse code and adjusted the speed to taste, ending up with a rate of about 44 words-per-minute so that the entire sequence completed in much less than a second.

Ultimately, we ended up with a different Morse message entirely, also sent at around 44 words-per-minute.  This turned out to be a very short, two-word message - the first word being "OH" - the result being a very distinctive, bright, and attention-getting flash sequence.

Can you guess the rest of the message?

Figure 8:
 The completed board, now inside the tail light housing, almost ready to be re-mounted on the bike.  On the underside of the white housing containing the LEDs there is a gap with an angled plastic area, just big enough for the board and the wires entering the enclosure to fit.  Not visible, the board is secured in place to the white plastic using a blob of RTV
(Silicone (tm)) adhesive.
Click on the image for a larger version.

Getting the code:

FWIW, the HEX code for this project - targeted for the PIC12F675 and PIC12F683 - may be found at the link below.

By downloading this .HEX file you indicate your understanding and acceptance of all risks involved in using it, including those that might result in hazard to life and safety and that you have read and understood the warnings near the top of this post.  

There are no warranties expressed or implied and it is up to the end user to determine the suitability and safety for their purpose!

Here are two .HEX files, one targeted for the PIC12F675 and PIC12F683.  The code is identical in function, but allows the builder a choice of processors:
Note:  It was "discovered" that with most programmers, the original .HEX code could not be used due to a hardware conflict with the !MCLR on pin 4.  The .HEX code above and the schematic in Figure 6 have been modified accordingly by tying pin 4 to pin 1.

While I'm not prepared to build custom boards to be installed (it's a matter of time and liability) I can supply a pre-programmed chip at a nominal cost for someone who might be willing to build a board, themselves:  Contact me if you are interested.


This page stolen from