Friday, 25 March 2016

The NJM2073D: an amp for the Pi

The NJM2073D is a low cost, easy to use, audio amplifier chip with a maximum power of about 2 Watts.


It can be used as a stereo amplifier for portable devices like a music player or a radio, and is available for just over £1.


I have a couple of Raspberry Pi applications that need audio, so this device looks like a good option.


The NJM2073D consists of two independent amplifiers which may be configured as a stereo pair, or used in bridge mode, to provide a single channel at higher power.

1 channel of the stereo pair

When used as a stereo pair, the output must be connected to a speaker via a large electrolytic capacitor to block the output d.c. voltage.

Both amps in bridge mode


When used in bridge mode, the output d.c. voltage is the same for both outputs, so these bulky coupling capacitors are not required.

I've built and tested both configurations, but since these chips are small, 8 pin devices and quite cheap, I decided to use them in bridge mode for both of my two applications.

The mono amp


The first application was to add mono sound to my TontecPi, which just needed to provide audio alarms via eSpeak. Each of the two channels from the Pi are simply summed together.

Mono from stereo

The voltage divider formed by the 470 Ohm resistor and each 100k, gave enough volume when the software levels were set to 100%. My Gambas program allows adjustment from "loud" to "whisper" by executing an amixer command.

I found a small, ex-desktop elliptical speaker in a junk box which probably has a power rating between 500 - 800mW. This was perfect for this application.

Supply Voltage and noise


As the TontecPi needs 12V for the LCD display and 5V for the Pi, I used a 12V power supply and the good old 78B5.0 to produce 5V. The Pi typically draws about 250mA at 5V so the 1A version of the 78B5.0 is more than adequate. And with the supply fitted to a daughter board and connected directly to the gpio connector, there is no need for an over-rated, over-voltage supply as there generally is when using the micro USB connector.

The NJM2073D has a very wide operating supply range: 1.8 - 15Volts. So it should be possible to power the amp directly from the Pi 5Volt supply.

However the Pi is a very noisy beast. On the TontecPi the noise was less apparent because the volume was relatively low and I connected the amp to 12Volts, so the 78B5.0 provided a kind in barrier to noise on the 5V rail.

With the second application (a kitchen radio) the basic noise level was more noticeable and there were additional issues created by an earth loop.

An earth loop is created when you have two or more connections (at separate points) from your common rail back to the power supply common. This can create circulating (noise) currents, which can appear as inputs to your amp, which are then amplified.

With the amp connected to the Pi 5V supply, I couldn't find an easy way to stop or filter out the switching noise from getting into the amp circuit and creating a dreadful sound from the speakers. So once again I used a 78B5.0 and a 12V mains power supply.

The amp & 5V power daughter board


So if you manage to get good results with amp and Pi running from the same 5V supply, please let me know.

My earth loop noise was greatly reduced by breaking the audio screen connection from Pi-to-volume-control-to-amp.

volume control wiring


Pi audio output or USB audio?


There are quite a few comments on the net about the quality (or lack of) when using the Pi audio jack. I have a spare Adafruit USB audio module, so decided to compare this with direct audio output from the Pi jack socket.

Testing with the Adafruit USB audio module

The noise level for the two options seemed to be much the same. But the sound quality did seem to be slightly better (unless I was kidding myself) with the Adafruit module.

Anyway, I plan to do some more tests, which will probably form the basis of another post.

The Lego approach


Unlike Lego, where the bits are perfectly designed and manufactured to fit together, there are a few compromises with this Pi + amp + speaker design.

If I were designing (say) a radio properly, I'd start with the requirements for sound quality and level, and enclosure size. In this application I didn't have a huge range of speakers to choose from, but I think I got lucky with these drives from Spiratronics.

Step 2 would be the audio amp. For my 10W max speakers I'd be looking for an amp with low distortion and suitable power, probably in the range 3 - 5W. So again the 2073 is not a bad choice.

However, there is a bit of a mis-match between the output level of the Pi and the gain of the audio amp. In both my applications I have set the Pi output to maximum in order to obtain the best signal-to-noise ratio. Because the gain of the amp is high, I've had to dramatically attenuate the signal level at the input to the amp.

The datasheet for the NJM2073 amp shows a reduced gain configuration which uses negative feedback. As I didn't have the necessary resistor values (or anything close) I didn't try this. But this will certainly be a consideration for any future Pi audio amps.

No comments:

Post a Comment