To get some rocking audio going, we thought about wiring a BeagleBone Black up to a personal favorite device of ours: a c. 1960 Gruntal amplifier and radio:
We then thought better of it and decided to go with something a wee bit smaller for our recipe: the TPA2016 PCB, which contains a Texas Instruments chipset and is packaged as a final product by Adafruit:
It doesn't pack quite the volume as an ancient tube-based amp, but this surface-mount PCB amp is a heck of a lot handier and easier to use than our antique beauty. Also, it delivers nearly 3W of power for our tunes, plenty of volume for many situations. Additionally, its I2C interface allows us to control audio gain via software instead of using jumpers, switches, or other physical hardware.
In this recipe, you will learn how to set up and test the device on a breadboard with speakers and BeagleBone Black. Afterwards, in a later recipe, we'll use it as part of our kit to set up a listening library on the BBB.
I2C background and usage
I2C (pronounced "eye-squared-C" or "eye-two-see") is a hardware bus intended for motherboards and daughterboards to communicate easily. It is frequently leveraged in embedded applications and typically used in accelerometers, magnetometers, and other sensors, as well as other add-ons requiring low voltage. In our case, we will use it to run a very small audio amplifier.
Other than its power leads, the bus only uses two wires to communicate: SCL and SDA. The first one is the clock line, SCL, which is used to sync any data passing over the bus. The second line, SDA, carries the actual data. I2C also utilizes a simple master/slave relationship between devices, with the bus allowing the roles to be interchangeable. I2C is also good at noise filtering, which is a relevant feature for our recipe.
Working with I2C pins on the BBB is pretty straightforward. There are three I2C buses implemented on the BBB, but only one of these is easy to use:
I2S bus
I2C should not be confused with Integrated Interchip Sound (I2S), another serial bus available on the BBB. Unlike I2C, which is bidirectional, I2S only handles data in one direction. Coincidentally, I2S is typically used as an interface to communicate PCM audio data between devices, commonly with a Digital to Analog Converter (DAC) audio device, though we will not use it in our audio recipes. There are several helpful tutorials on making a DAC, interface with I2S and connecting it to the BBB, such as the one at http://bit.ly/1HQMc1N.
Here are the materials we need:
To prep the PCB amp, we followed some of the guidance provided by Adafruit's tutorial to work with their board (https://learn.adafruit.com/adafruit-tpa2016-2-8w-agc-stereo-audio-amplifier). Perform the following steps:
This recipe is not a general how-to on soldering. If you have never soldered a wire or joint on a PCB, consult the following excellent tutorials:
How to Solder—Through-hole Soldering: https://learn.sparkfun.com/tutorials/how-to-solder---through-hole-soldering/
NYU's ITP soldering lesson: https://itp.nyu.edu/physcomp/Labs/Soldering
Adafruit's excellent guide to soldering: https://learn.adafruit.com/adafruit-guide-excellent-soldering
Instructable secrets of good soldering: http://www.instructables.com/id/How-to-solder-the-secrets-of-good-soldering/
After this, you can begin by inserting the long pins of a header strip with 8 pins into the breadboard, short pins sticking up, as shown in the following picture:
As it is important to get your PCB amp mounted on an even plane, the easiest way to do this is by using the leftover pins to support the board on the opposite edge. To clarify, these pins will not be soldered; they are only there for temporary support.
You then need to solder up the headers on the PCB amp, as you can see on the left-hand side in this picture. We used lead-free solder; so, when finished, the joints will look dull instead of the typically shiny cast from a well-poured leaded joint.
Following this, with a wire stripper, cut away the wire ends, as you can see in the following image:
In case there is any uncertainty from the diagram, here is a table clarifying how to wire it up:
FUNCTION |
BeagleBone Black |
TPA2016 amplifier |
Breadboard component |
---|---|---|---|
Power |
P9_5 (5V) or P9_3 (3.3V)—5V for full capacity of the amp |
VDD | |
Ground |
P9_1 |
GND | |
I2C |
P9_19 (SCL) |
SCL | |
I2C |
P9_20 (SDA) |
SDA | |
Audio input—left speaker |
L+ |
L+ on 3.5mm headphone jack | |
Audio input—right speaker |
R+ |
R+ on 3.5mm headphone jack | |
Audio ground |
L- to R- | ||
Audio ground |
R- |
R- on 3.5mm headphone jack |
.py
file called audio-amp-test1.py
.$ git clone https://github.com/HudsonWerks/audio-amplifier.git
nano
window:$ $ cd audio-amplifier $ sudo nano audio-amp-test1.py
Success (we hope)! Give yourself a high-five for getting dirtier with your board and adding some PCB add-ons to the mix.
3.143.9.115