A Gainclone for the PC Age

Despite being increasingly used for entertainment, most PCs don’t have very good sound systems. The low voltage power supplies used in PCs preclude building a good quality amplifier in the case. External “PC speakers” tend to be more impressive in their product design then their audio performance.  Attaching a regular hi-fi amp works well, but it integrates poorly with the PC environment.

Good quality audio speakers are readily available off the shelf (so to speak!). Let’s look at what type of amp would be needed to hook them up. The Gainclone amplifier has proved very popular with hobbyists since construction is straightforward and the resulting amplifier has an impressive performance specification. Most designs discussed online are aimed at audiophile applications. Here is a design for connection the a PC. It powers up and down with the PC and audio input can optionally be taken over USB.

This article covers the full design and construction of the amplifier.

If you have any questions or spot any errors please contact me at: malcolmrix@malkie.com

 

 

 

 

 

 

The Design Concept

Here are many more pictures of the project and construction

Please read these Warnings and Disclaimers

National LN3886 Data Sheet

Here are the basic features for the PC oriented amplifier:

·         High quality audio amplifier with moderate output power (25-75W RMS). This is readily delivered by hi-fi amplifier chip LM3886 used in ‘Gainclone’ type

·         Most preamp functions can be handled by the PC so we won’t need a lot of controls on the front panel

·         The amp needs to turn on and off when the PC does

·         Option to have the audio input over USB rather than analog cables (known as “external USB sound card”)

I wanted to incorporate some other ideas more commonly seen in PC’s than audio equipment:

·         Switching Power Supply. At this point people might think I’m smoking something, but actually it works very well. My first Gainclone used a heavy torroidal transformer and a linear regulated power supply. It works well but is bulky, expensive, and inefficient. Switching power supplies are more efficient and cheaper, but close attention needs to be paid to startup and noise issues.

·         Fan Cooling. Audiophile power amplifiers shun cooling fans due to background noise, but pay a heavy penalty in size. A small temperature controlled fan will be almost silent and will allow a lot of saving on heatsinks. It can be arranged to run only when the amp is hot (and loud) hence reducing the noise further.

Circuit and Operation

Amplifier

Audio input comes from either the Line-Out of the PC or an external sound card (described later). A small filter consisting of 680Ω/47pF excludes any RF signals from entering the case. 470nF input capacitor should have a high voltage rating since it protects against line voltages being connected to the amplifier, since it is in the signal path it should be a high quality type.

A volume control is added for convenience since the PC volume controls are often hard to locate in a hurry when you suddenly find your music is blasting the whole neighborhood. The volume control should be a multi-ganged type for each amplifier input. All the tone, balance and other controls are all on the PC’s software control panels so it is not necessary to implement them in hardware.

The amplifier design is pretty much follows the reference design in National’s LM3886 amplifier data sheet, where it is also fully described. 220pF across the amplifier inputs removes clicks from turning on florescent lights and the like. The mute function is not used, so a 10KΩ resistor must be provided to pull the pin to the negative rail. The speaker outputs are run through a relay. This has several useful functions, it avoids thumps when the amp is powered on, fade away when it is powered down, and can be used to disconnect the speakers (the load) if the amplifier overheats. The control circuits are described later.

Switching Power Supply

The LM3886 amplifier requires symmetric positive and negative power supplies. Assuming you are using 8Ω hi-fi speakers then a power supply of +/- 20-35V is typical. The exact voltage used will dictate the output power available when the volume is cranked up (and the waste heat dissipated by the amplifier IC). See p14 of the National LM3886 data sheet for curves that relate output power to supply voltage and the power dissipation by the amplifier. Be careful not to exceed maximum ratings.

The most commonly available switching power supply in this range is 24V (the next, 48V, is too high). You can probably increase the supply voltage slightly to 25V or 26V using its calibration adjustment. I used 60W supplies for a stereo amplifier, but they can be overloaded and shut down at very high output power. Use 100W supplies if you like your music seriously loud. The amplifier output power is about 40W RMS per channel.

Under startup and overload a linear power supply (one based on a power transformer) with either draw more current or the rail voltages will droop until the overload passes. As long as nothing gets too overloaded for too long you are fine. Switching power supplies are quite different and will shut down automatically if their rated power is exceeded (in this case about 2.5A). They will retry every second or so until the load is in spec.

As usual in these designs, the amplifier has large capacitors on the power rails for smoothing. At power-on they present a virtual short circuit. If directly connected the switching power supply will just shut down. A soft-start circuit is needed, which puts a resistor in series with the capacitor until it is charged to operating voltage. The resistor needs to be removed (shorted) once the amplifier is up and running.

When using two power supplies it is possible to overload one of them and have it shut-down leading to an asymmetric latch-up of the amplifier. The soft start circuit needs to be designed to address this too.

Two 60W, 24V DC switching power supplies are wired in series. AC power is controlled by a relay which is actuated by USB activity (more of this later). In addition a conventional power switch is provided for isolation.

At power-on a 10Ω resistor is in circuit and limits the current into the smoothing capacitors. When each supply voltage exceeds the zener voltage the FETs will trigger turning on the relay which shorts the current limiting resistor. The p-channel FET is harder to turn on so a lower voltage zener diode is used. In normal operation the soft-start will cut out in about 0.5 sec. If either of the supplies is overloaded then both of the resistors will be re-engaged to allow the power supply to restart.

The resistor presents some safety concerns. It is only engaged for a short time, so its power rating need not be very high, 5W is fine in normal operation – but if the soft-start circuit fails and it is left in circuit then it potentially dissipates a lot of power (the worst case fault condition could present the total PSU load). A thermal fuse is essential to prevent the resistor overheating in case of a sustained overload or failure of the soft-start circuit. It can only be omitted if the resistor has a much higher power rating, or substantial heatsink.

An inductor can also be placed on the input to block noise from the power supply. I’m not sure this has much effect, probably because of the large smoothing caps and that the switching frequency is above the audible range anyway. The smoothing capacitor is implemented as three 3500uF on each supply rail. Using multiple capacitors improves the ripple current performance (they are also easier to mount on the PCB). The 2.2KΩ resistor discharges the capacitors for safety after the amplifier is turned off.

 

Linear Power Supply (alternate design)

If you are not enthusiastic about using the switching power supply design, then this linear supply based on a conventional (usually torroidal) power transformer will work fine. The voltage regulators are optional, but introduce a margin of safety against AC line voltage variation when operating close to the maximum voltage of the amplifier IC. If omitted then greater care is needed in choice of the line transformer. The DC line voltage is the AC transformer output voltage multiplied by 1.41 (square root of 2). Use maximum line voltage (for example 120V in US), not nominal (110V), for the calculation.

 

USB Connectivity

The circuit diagram shows two options for audio inputs. The first is conventional analog audio, the alternate is a USB external sound card. The circuit diagrams show both and a way to switch between them, but only one is strictly needed.

The external sound card can be easily purchased a module from a computer store (see photos). I removed the internal circuitry and wired it into the PCB. The headphone output can be connected directly to the amplifier line input (the levels are about the same, but don’t omit the DC blocking capacitor since LM3886 is an operational amplifier and will amplify any residual DC offset). The microphone input can be ignored, or run to the front panel if needed.

We want the amplifier to turn on with the PC. If this was a commercial product then a USB microcontroller would be implemented to identify the amplifier to the PC. That would be a complex project for an enthusiast so we will use a trick here. The USB standard requires USB devices and the PC ping each other every 8mS while the PC is turned on. This activity can easily be detected by looking for activity on the USB line. Note: You cannot use the USB power to detect the PC is on since it is maintained even when the PC is shut down.

If you are using the USB audio input then activity can be detected on the USB that feeds it. If not, you will need to embed a USB device in the amplifier. I used a mouse module from which all the optical and mechanical parts had been stripped. The PC does not care that multiple mice are connected to the system (movements are just summed). This one won’t be moving.

The 2N7000 FET detects a signal on the USB bus. Its high input impedance should not disturb the USB signals significantly. The 74LS122 is a retriggerable one-shot that extends the short polling pulses into a constant signal. A further FET is used to drive the power up relay of the amplifier. All these circuits, including the relay are driven by the 5V supply from USB.

 

Fan Control and Over-Temperature Detection

A passive cooled heatsink for this powerful amplifier can be quite bulky. In this design I used a smaller heatsink designed for a PC CPU. These heat sinks are good for around 60W but need to be fan cooled. Since the amplifier (unlike the CPU) does not product much heat when audio output it low then it is a good idea to cut the fan when it is not needed to keep down background noise and save power.

A 5K thermistor is embedded in the amplifier heatsink. 5.6V zener diode provides a stable reference voltage for the measurement circuits. LM393 comparators compare a resistance bridge containing the thermistor with one made of fixed value resistors (you may need to change the values slightly depending on the exact characteristic of the thermistor that you can get). The 220K positive feedback resistor makes the comparator act as a Schmitt trigger with about 2°C of hysteresis. One comparator detects the heatsink is warming up and turns on the fan. It can be adjusted, but should be set at about 35°C. The other comparator is used to disconnect the speakers if the temperature exceeds about 50°C (it will also quickly connect at power-up and disconnect at power down). If the supply voltage selected is above 24V, then a series resistor may need to be used to limit the current through the relay coil.

This whole circuit and the fan power is run from a LM317 adjustable regulator. This allows the fan speed to be setup to balance noise vs. cooling efficiency. It does not matter than the supply to the LM393 is also varied since the reference for the temperature measuring circuits comes from the zener diode.

Options

My intent here has been to show the entire design since I know some people might need the details to be able to construct a working amplifier. That being said there are a number of ways the design can be adjusted:

1.       The circuit shows both USB and conventional audio inputs and a way of switching between them. One or the other can be used and the switch omitted.

2.       The fan can be run continuously, although with increased wear and noise. Use caution if omitting the over-temperature detection

3.       Switching power supply can be substituted for a linear design based on a transformer (described above)

4.       USB power-on can be substituted for a conventional power switch

Construction

Here are some general tips. Check the photos too:

·         High voltages are present. The AC power wiring is a shock hazard. Ensure all power wiring is double insulated and cannot be accidentally touched, even if you are working inside the chassis. At over 50V between V+ and V- the DC power supply poses a lower level shock hazard. Ensure you are working in a dry environment and avoid touching the circuit when in operation.

·         Put the whole project in a metal case. Safety earthing of the power supply module and case is needed. You should run the ground from the AC power line plug directly to a lug bolted to the chassis. Use crimps, rather than solder for this connection (it could be melted in a fault condition). Don’t omit the fuse!

·         Pay attention to layout. Keep the circuits around the audio amplifier as compact as possible. Keep signal paths short. Place decoupling capacitors close to the amplifier. Separate the signal and power grounds. Run both as trees (connected without loops) to a single common point, usually the chassis ground.

·         A custom PCB is nice, but it is not essential. The performance will be fine if the amplifier is constructed on a prototype board (see photos). The power rails to the amplifier and from the amplifier to the speakers carry significant current, so use thicker wiring to reduce resistive losses.

·         It is likely you will need to put the volume control at the front and the amplifier at the back of the case. Run the signals between them on shielded coax cables.

·         Check the power supply before connecting it to the amplifier. Check all the wiring carefully with a multi-meter before powering it up. Turn on for the first time without the speakers connected. The amplifier should draw about 0.15A from each supply rail. With audio inputs shorted check the voltage across the speaker outputs. It should be <80mV. When idling like this the heatsink should be very slightly warm, strong heating suggests oscillation or a fault. If anything does not seem right, turn off and recheck the construction. If all is okay connect a speaker and test the audio. There should be no hum or noise from the speaker with the volume control turned to full and no audio input.

·         Take care when soldering the thermal fuses into the soft-start circuit (they can be triggered by soldering heat!). Use a large pair of plyers on the leads as a heat sink during soldering. The thermal fuse should be mounted touching the 10Ω current limiting resistor.

·         The amplifier chips should never be operated without being bolted to a substantial heatsink, even during testing.  The metal tab on the LM3886 is at V- and must never contact chassis ground. An insulator is normally placed under the IC and under the retaining screw (see photos). Mica insulators need thermal compound to ensure good contact, silicone insulators do not.

·         PC heat sinks often come with fans attached. You can use that or any 12V DC fan. Select one that is quiet in operation. I found a thin 80mm fan with 0.09A power consumption worked well and was almost silent when run at 9V. Connect the +ve to the red lead and black to ground. The other wire (color varies) can be ignored and left open.

·         A small heatsink should be put on the LM317 voltage regulator

·         Don’t forget the power for the USB parts of the circuit comes from the USB signal cable. Make sure to disconnect it before working on the circuit.

·         The “USB sound card” can be bought as a PC add-on, the circuit extracted from the housing and incorporated into the amplifier. The headphone jack can be connected to the amplifier input, but don’t forget the input decoupling capacitor to remove DC offset.

·         The USB mouse module was removed from an Asus brand optical mouse (any brand should do). All the mechanical components were discarded and the LEDs and optical receivers were removed from the board. As such it will still communicate its presence with the PC but won’t register any movement.

·         Pay attention to layout around the USB power-up relay. AC power is connected to the relay contacts. Keep good separation between the power wiring and the control circuits, and that the power wiring cannot be accidentally touched when troubleshooting the board.

·         Keep the USB signal lines very short. The data frequency is quite high has a tight impedance specification. If you cannot avoid wider spacing run D+ and D- as a twisted pair of small wires.

·         For temperature measurement I used a hermetically insulated bead thermistor on a fly lead. I used epoxy resin to glue it into a hole drilled into the top of the heatsink. The correct fan start-up temperature can also be set by running the amplifier and adjusting it to cut in when the heatsink is slightly hot to the touch. Don’t forget the hysteresis of the circuit when making the adjustment. Once the fan is on you will need to wait until the heatsink cools a little before it turns off again.

·         The shutdown circuit can be checked using a glass of water and a thermometer. Get the water to about 60°C and dip the thermistor into it. The speakers should cut out. Remove the thermistor from the water and wait a moment and they should come back on. Do not try this unless the thermistor is a type that is 100% electrically insulated from the water! In any case don’t forget to test the circuit works.

Getting the Parts

·         Check Ebay for the switching power supplies if you can’t source them easily. They should run about US$20 each. 24V is a standard voltage. The next standard voltage, 48V, is too high for operation of the LM3886.

·         All resistors are 1/4W unless otherwise stated. Values in the circuit diagram are in ohms (Ω).

·         With 25V power supply rails, smoothing capacitors should have a minimum 35V rating. This will need to increase to 50V if 35V supplies are used. Other capacitors need to be rated about 50% higher than the supply rails of the circuits in which they are used. Values on the circuit diagram are in Farads (F).

·         I used an AMD processor heatsink but dispensed with the fan since it was noisy. I drilled and tapped two M3 holes for the amplifier retaining screw.  Another hole was needed to mount the temperature sensor. If you omit the fan the heat sink will need to be much larger and be mounted in a position where air can rise over it.

·         Three relays are used (2 * 24V and one 5V type). They should be rated 250V and 3A. If the 24V relays are hard to obtain then consider a 12V type with a series resistor (check the power rating on the resistor too!)

·         The BS250 FET can be substituted by any p-channel FET with appropriate voltage (60V) and current rating (0.1A). The 2N7000 FETs should not be so hard to find, but they can also be substituted. Many of the relay switches could also be implemented with bipolar transistors (you will need to adjust the base resistors though). The IRF510 should be easy to find but is overkill, it can also be substituted with any n-channel FET with better than 0.5A power rating.

·         You can buy cool volume controls where an LED can be mounted inside and lights up the pointer

·         The 0.47mH inductors are about 15 turns of thick enameled wire on a torroidal ferrite core. The exact value is not so important; home winding is fine. The cores can be bought loose or extracted from old computer power supplies.

 

(c) 2009 Malcolm Rix