Skip to the content
2 layers87 × 47 mmDSPDAC, the printed circuit board in 3D

A design for a 4-channel USB DSP+DAC

Size
87 × 47 mm
Copper layers
2
Thickness
1.6 mm
Parts
53
Nets
80
Pads
219
Tracks, vias
276, 22
Pours
6
Routed
Yes
KiCad
KiCad 7 (file 20221018)
Created
15 Oct 2023
Updated
10 Nov 2023

Overview

DSPDAC is an open-source printed circuit board by jeroen94704, from the jeroen94704/TeensyDSPDAC repository on GitHub. It is a 2-layer board of 87 × 47 mm with 53 parts on 80 nets, routed with 276 tracks and 22 vias.

It is built around the PCM5102APW. Its parts include 29 capacitors, 7 connectors, 6 resistors, 4 ICs and 2 diodes. It belongs with the audio and music boards and the NXP (LPC, Kinetis, i.MX RT) boards of this library.

Main components

1

README

README.md

WARNING

This is a work in progress. Feel free to build your own (I've verified the design works), but be aware this will not be a plug-and-play experience, as the design needs some work.

Introduction

This is a 4-channel USB DAC with advanced DSP capabilities. The DSP functionality is provided by a Teensy 4.0 and the DAC stage is built around a pair of TI PCM5102A's.

Beauty shot of the PCB rendered by KiCad

The Teensy's UART1, I2C0 and I2C1 ports are available through dedicated pin-headers. The UART is compatible with an FTDI 6-pin dupont connector (although, inevitably, I swapped RX and TX). The I2C headers are pin-compatible with those ubiquitous I2C OLED display modules. The remaining unused Teensy pins are broken out on a pair of pin-headers on both sides of the board.

This DSP/DAC is a companion project to my take on the HexiBase mini-subwoofer. I wanted a way to properly match that sub to the pair KEF Q150's I use as desktop speakers, and this seemed like a fun project to do myself. I'm not an electronics engineer, so this is completely based off of the reference circuits in the respective components' datasheets.

Programming the DSP

DSP functionality can be designed using PJRC's Audio System Design Tool. Initially I wanted to use Chip Audette's OpenAudio F32 Design Tool, but that library does not support the I2S2 output, which this board needs. The code generated by these tools is not a complete Arduino Sketch, but can be copy-pasted into an existing sketch. For example, below is a design of a DSP for a 2.1 speaker setup. It takes a USB stereo input signal and creates a separate subwoofer channel with just the low frequencies:

A DSP design consisting of a USB input, 2 filters, a mixer and 2 I2S outputs

This design results in the following code:

text
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioInputUSB            usb1;           //xy=167.1666717529297,283.1666564941406
AudioFilterStateVariable filter2;        //xy=403.16668701171875,341.16668701171875
AudioFilterStateVariable filter1;        //xy=407.16668701171875,218.16665649414062
AudioMixer4              mixer1;         //xy=569.1666870117188,284.1666564941406
AudioOutputI2S2          i2s2_1;         //xy=718.1666870117188,347.16668701171875
AudioOutputI2S           i2s1;           //xy=721.1666870117188,231.16665649414062
AudioConnection          patchCord1(usb1, 0, filter1, 0);
AudioConnection          patchCord2(usb1, 1, filter2, 1);
AudioConnection          patchCord3(filter2, 0, mixer1, 1);
AudioConnection          patchCord4(filter2, 2, i2s2_1, 0);
AudioConnection          patchCord5(filter1, 0, mixer1, 0);
AudioConnection          patchCord6(filter1, 2, i2s1, 0);
AudioConnection          patchCord7(mixer1, 0, i2s1, 1);
// GUItool: end automatically generated code

Programming the Teensy

The code generated by the Design Tool can be pasted into an existing Arduino sketch after downloading and installing Teensyduino. The variable declarations are enough to start the DSP process, so if all you want is audio then the only things you need to add are a call to AudioMemory, unmuting the DAC's in setup() and handling the volume set on the host in the loop() function. So given the above code, the complete sketch could be as simple as:

text
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioInputUSB            usb1;           //xy=167.1666717529297,283.1666564941406
AudioFilterStateVariable filter2;        //xy=403.16668701171875,341.16668701171875
AudioFilterStateVariable filter1;        //xy=407.16668701171875,218.16665649414062
AudioMixer4              mixer1;         //xy=569.1666870117188,284.1666564941406
AudioOutputI2S2          i2s2_1;         //xy=718.1666870117188,347.16668701171875
AudioOutputI2S           i2s1;           //xy=721.1666870117188,231.16665649414062
AudioConnection          patchCord1(usb1, 0, filter1, 0);
AudioConnection          patchCord2(usb1, 1, filter2, 1);
AudioConnection          patchCord3(filter2, 0, mixer1, 1);
AudioConnection          patchCord4(filter2, 2, i2s2_1, 0);
AudioConnection          patchCord5(filter1, 0, mixer1, 0);
AudioConnection          patchCord6(filter1, 2, i2s1, 0);
AudioConnection          patchCord7(mixer1, 0, i2s1, 1);
// GUItool: end automatically generated code

void setup() 
{

If you want to add more functionality, such as controls (buttons, dials) or a display you can implement this in the same sketch.

Bit-depth and volume control (a bit of a rant, I'm afraid)

While both the processor on the Teensy and the external DACs are 32-bit capable, I belatedly discovered the Teensy Audio Library is entirely 16-bit. This is quite unfortunate, as this has implications for the final sound quality. Here's the problem: The Teensy registers as a 16-bit capable USB sound device, and outputs 16-bit data over I2S to the DACs. For maximum sound quality we want to utilize the full 16-bit range, as this results in the most accurate analog waveforms. However, the DACs have a 2.1 Vrms line-level output, which is very high. This line-level signal is amplified by a power-amp before it can drive the speakers. A power-amp has a fixed gain, for example 20, 30 or 40 dB, which corresponds to 10, 32 or 100 times the input voltage. But even a modest gain of 20 dB would turn the 2.1 Vrms signal of the DACs into a speaker-destroying, ear-splitting amplified signal, so we need to have some form of volume control. This is done by adding attenuation (the opposite of amplification) somewhere in this chain. We can do this digitally on the host PC or Teensy or analog(ly?) on the line-level signal. Attenuating the speaker-level signal would produce large amounts of heat, so that's not an option.

Digital volume control reduces the bit-depth, because in order to reduce the peak-peak voltage of the output signal we need to feed the DAC with smaller numbers (= fewer bits). If our digital processing is done using 24- or 32-bits this is not a problem since most source-material (including CD-quality) is 16-bit. A 16-bit signal can be attenuated by -48dB (for 24-bit DSP) or -96dB (for 32-bit DSP) without loosing any information/sound-quality. Unfortunately at this point we don't have that luxury with the Teensy. It receives, processes and outputs audio data fully in 16-bits, so attenuating the signal by e.g. -18 dB (1/8th gain) already reduces the bit-depth from 16 to 13.

That leaves us with analog volume control. In practice, this means running the line-level signal through a voltage divider, typically a logarithmic potentiometer with 2 or more stacked together for multi-channel volume control. Unfortunately anything you do with an anlog signal introduces some amount of noise, which gets amplified and therefore impacts sound-quality.

All of the above is partly specific to my situation. I purchased 3 cheap mono amplifiers without understanding any of this, and it turns out they are hardwired with a 36 dB gain. This would turn the 2.1 Vrms signal into a monstrous 132 Vrms speaker signal if the amps were capable of producing that. In practice, of course, they are limited by their supply voltage and start clipping the signal long before that. But in my case this means the signal needs attenuation by -16 dB just to prevent the amps from clipping. And even then the speaker-level signal is way too loud to be usable. So I'm still debating what to do with this. I might try to modify the mono-amps to a lower gain, and I'm also looking into ways to do the DSP in 32 bits. I'll probably need to do both, I suspect.

Cost

It's a pretty compact board (87x47mm, or about 3.42" x 1.85"), so getting the bare PCB fabricated by one of the large cheap Chinese PCB manufacturers is very affordable. For reference, I would have paid ~€3 for 5 boards (€0.60 per board). However, as an experiment I decided to try the assembly service they offer. With the through hole and pricier SMD (DACs and voltage regulator) components omitted this came to a total of ~€27 for 5 partially populated boards (€5.40 per board). The remaining components (excluding the pinheaders and screw terminals, which I have in stock by default) cost about :

  • Teensy 4.0: €27
  • 2x PCM5102A DAC: €3.40
  • 1x LT1962 3.3V regulator: €1.85
  • USB-C port: €1

So the total is about €40 per board for components + partial assembly. Now you can't order just 1 board, so it's more expensive than that, but if you do all soldering yourself I expect you would save at another €10 or so. Obviously this design is not on par with high-end audio gear, of course, but given that many consumer-grade USB DACs use the same DAC chip, and the DSP features are similar to something like a miniDSP I'd say this is a pretty good deal.

Enclosure and Amplifier

The board has mounting holes for installation in an enclosure, but they are not placed to fit any particular model. If you use a metal enclosure make sure is is connected to the plated mounting holes (on the Teensy/USB-C port side of the board), which connects to the protective earth of the USB-C port.

For my own build I plan to create a custom, 3D-printed enclosure and I will add a link to that design once it's done.

While it's probably superfluous to mention this for most: The output of this board is a line-level signal, so you need to add an amplifier before you can hook up speakers. Which amplifier(s) to get is up to you and beyond the scope of this document. There are MANY 1-, 2- and 4-channel amplifiers to choose from, either in module-form (for integration into your own DSP+DAC+AMP) or standalone off-the-shelf.

Donate

If you find this project useful a small donation is much appreciated (but by no means required or expected): https://ko-fi.com/jeroen94704

License

This design is ©2023 Jeroen Bouwens and is licensed under CC BY-NC-SA 4.0. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/

Parts

53
QtyValueFootprintReferences
80.1 uFCapacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC5, C6, C7, C9, C17, C18, C19, C21
810 uFCapacitor_SMD:CP_Elec_4x5.4C1, C2, C3, C4, C13, C14, C15, C16
410uCapacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC25, C26, C28, C29
42.2 nFCapacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC11, C12, C23, C24
42.2 uFCapacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC8, C10, C20, C22
4470Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR1, R2, R3, R4
2LEDLED_SMD:LED_0805_2012Metric_Pad1.15x1.40mm_HandSolderD1, D2
2MountingHole_PadMountingHole:MountingHole_3.2mm_M3_DIN965_Pad_TopBottomH1, H2
2MountingHole_PadMountingHole:MountingHole_3.2mm_M3_DIN965H3, H4
2PCM5102APackage_SO:TSSOP-20_4.4x6.5mm_P0.65mmU1, U2
10.01uCapacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC27
1270Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR5
15.2uHInductor_SMD:L_10.4x10.4_H4.8L1
1620Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolderR8
1I2C0Connector_PinSocket_2.54mm:PinSocket_1x04_P2.54mm_VerticalJ5
1I2C1Connector_PinSocket_2.54mm:PinSocket_1x04_P2.54mm_VerticalJ6
1LT1962-3.3Package_SO:MSOP-8_3x3mm_P0.65mmU3
1OUT1_L+RTerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-4-5.08_1x04_P5.08mm_HorizontalJ1
1OUT2_L+RTerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-4-5.08_1x04_P5.08mm_HorizontalJ2
1Teensy4.0Teensy:Teensy40_SMTU4
1Teensy_UARTConnector_PinHeader_2.54mm:PinHeader_1x06_P2.54mm_VerticalJ3
1UnusedPins_1Connector_PinSocket_2.54mm:PinSocket_1x04_P2.54mm_VerticalJ4
1UnusedPins_2Connector_PinSocket_2.54mm:PinSocket_1x07_P2.54mm_VerticalJ8

Similar boards

  • 6 layers243.8 × 243.8 mmRaven, the printed circuit board in 3D

    Raven

    agranlund/raven

    Homemade MC68060 + DSP56303 Atari-compatible computer. Hardware, firmware, and software stack

    331 parts87
  • 2 layers54 × 60.5 mmTape, the printed circuit board in 3D

    Tape

    jrowny/mixtape2

    My second iteration of a cassette-style mp3 player

    38 parts82MIT
  • 2 layers140 × 170 mmCdi, the printed circuit board in 3D

    Cdi

    ThroatyMumbo/NESCD

    An unofficial CD drive add-on for the NES.

    28 parts78MIT
  • 2 layers232 × 134 mmType2 v2, the printed circuit board in 3D

    Type2 v2

    Alxdreee/TYPE-2

    Touch-capacitive polyphonic synthesizer powered by ESP32-S3

    18 parts68GPL-3.0
  • 2 layers55 × 100 mmESP32AY revD2, the printed circuit board in 3D

    ESP32AY revD2

    djspawnbrest/ESP32AY

    ZxPod - ESP32 based AY multiformat player

    138 parts59GPL-3.0
  • 2 layers76 × 63.5 mmPicoTracker, the printed circuit board in 3D

    PicoTracker

    xiphonics/picoTracker-pcb

    Buy the official kit at xiphonics store # Trademark Notice

    98 parts36CC0-1.0
  • 4 layers40 × 100 mmJPL.mp3, the printed circuit board in 3D

    JPL.mp3

    jpetkauskas/JPL.mp3

    Files for ESP32 based MP3 player

    72 parts33
  • 2 layers58.8 × 55.7 mmAiO i2s DAC, the printed circuit board in 3D

    AiO i2s DAC

    martinroger/ipodesp32

    An iPod emulator for 2006-2013 BMW Mini Coopers that need Bluetooth

    102 parts24MIT

Questions

How big is the DSPDAC PCB?

It measures 87 × 47 mm and has 2 copper layers, 1.6 mm thick.

What parts does the DSPDAC use?

53 parts, built around the PCM5102APW. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the DSPDAC KiCad files?

From the jeroen94704/TeensyDSPDAC repository on GitHub, at the commit this page was made from: the board is DSPDAC.kicad_pcb and its schematic DSPDAC.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the DSPDAC design in my own project?

Its repository states no licence, so its author keeps all rights: ask jeroen94704 before reusing the design.