Published 31.11.2014 (built early 2014)
This design is to be connected to possibly lethal mains voltage. These are not detailed instructions, so do not try to build similar device without extensive understanding of electronics and electrical safety!
- All-in-one compact audio solution including digital signal processor, digital-to-analog-converter and preamplifier
- 4 digital SPDIF stereo inputs: 2 toslink and 2 coaxial (isolated)
- 4-channel analog balanced outputs for main speakers and subwoofer(s)
- Output channels can be independently mixed from input channels, added with versatile filtering options for digital room correction or crossover filters
- Main components: ADI ADSP21369 based miniSHARC DSP-kit, PCM1792A DACs, OPA2134/LME49724 opamps, PGA4311 volume control and FreeRTOS-based software running on ATmega324A to control everything
- Extensive software features: IR-remote code learning, selectable DSP-preset, input-/output-wise volume offset and channel balance, DAC filter steepness, input renaming
This is actually my first proper design which I have (almost) finished (they are never really completely finished, right?). The goal was quite ambitious since it is not the simplest design although still just an audio device. It is also not completely designed by me as the DSP-solution is half-ready OEM/DIY-board which I have integrated into my own device. That made it possible to include quite impressive processing power and functionality with reasonable efforts. Including design by someone else into your own, based on provided specifications, is also a good practice. I am quite happy with the device and it is working properly, I use it every day. However, when writing this I have already designed other devices such as the 4-channel DIY audio system (which is based on this DD Preamp to some extent) and learned a lot while doing it. Therefore, it is natural I already feel that I should have done some things differently in this one. But that is the process of learning.
Back panel looks quite DIY and in fact it is “machined” in my bathroom. This was the time before I found Schaeffer AG. Four XLRs are outputs, two toslinks and two RCAs are digital inputs and third RCA is output of the main channels (it is available from miniSHARC but actually it is not connected yet). DC-connector is 12 V output for one remote application I had in mind to control a relay. USB is for DSP-programming.
DD Preamp is a high-quality DSP-powered 4-channel preamplifier for desktop use with active speakers and active subwoofer(s) (2.1 or 2.2 system). 4 sources with digital SPDIF output (coaxial or toslink) can be connected to it and outputs are implemented with balanced XLR connectors. The device then operates as volume control, input selector and filter for room acoustic correction. Besides DSP (whose functionality is descrobed below), actual functionality is provided by embedded software, including features such as:
- Simple user interface with one rotary encoder with push-button and clear high-contrast alphanumeric vacuum fluorescent display
- Master volume and input selection as basic operation and menu for advanced features
- IR remote control possibility with learning function (support for NEC-codes).
- Volume offset for all physical inputs and second output pair
- Separate balance for both outputs
- Possibility to assign a name of source from pre-defined list (CD, DVD, etc..) for every physical input (opt1, opt2, etc..); both are showed on the display
- DAC filter roll-off selection (sharp/slow) and delta-sigma oversampling ratio (32x/64x/128x)
- DSP preset selection
Filters in DSP are set up using a PC-software called plugin. There are different plugins available for DSP-boards and plugin defines the functionality of the complete solution (where hardware certainly sets computational limitations). While PC is needed for setup, there are 4 slots where configurations can be stored and then later changed without PC. The device can be commanded by any infrared remote control using NEC codes (although it may be difficult to know which codes your remote is using). I am using the DSP for digital room correction so acoustic measurements are done to calculate filters.
Desktop measurement setup with DD Preamp, UMIK-1 measurement microphone, Genelec 8020B active monitors and a small subwoofer (under the table). Measurement software is Room EQ Wizard and miniSHARC plugin is used to set up the DSP. The point is to measure response at the listening spot and set up filters to compensate (the worst) deviations from the desired response (which is not necessarily flat).
My part of the design concerns a motherboard for miniSHARC DSP-board. Technically the DSP-board is separate despite being in the same enclosure. It is a closed undocumented system so I cannot communicate with it, only handle the audio signals. However, I found a way to change filter presets inside the DSP which I have described below in miniSHARC section. So basically I had a “black box” with stereo SPDIF-input and 8-channel I2S-output. My board provides four inputs with input selector, DA-converters followed by low-pass filters and buffers, volume control and software with user interface to control everything. Block-level implementation is shown below and electrical schematics are further below.
One main point in this was to use very compact enclosure. At first I had even smaller one but had to change it to fit everything. The size requirement was a bit too ambitious and by some changes the overall design would have been better. I have discussed about some flaws and potential improvements at the end of the page. Circuits around ICs are mostly based on examples in datasheets, no exceptional approaches have been used.
There are 4 digital stereo inputs, fed to mux IC acting as input selector, controlled by microcontroller (MCU). Selected SPDIF is fed to miniSHARC which includes SPDIF-receiver and sample rate converter. Master clock is taken from miniSHARC, since it can be only clock master, buffered and divided to DACs. Audio signal from miniSHARC is in I2S-format, fed to DACs with differential current output. This analog signal is converted to voltage (I/V) and low-pass filtered (LP filter), followed by buffers with another stage. These 4 differential signals are fed to stepped attenuator IC for volume control, once more buffered with possibility for fixed attenuation, and connected to XLR output connectors. MUX, DACs, stepped attenuators and VOL-FP (used for DSP preset change) are controlled by microcontroller (MCU). Power distribution network is not drawn.
Can be seen as pdf here. It is drawn with Kicad and has hierarchical sheets. First page is top level and blocks labeled “Sheet: name” are shown on following pages. Pin-like connections in blocks are hierarchical labels going between hierarchical levels or pages. Power labels are global throughout the document.
On the highest level on page 1, miniSHARC is connected to pin header P2 and other hierarchical blocks are input selector, two DAC/output stages, power supply and microcontroller (MCU). Main board and microcontroller board are connected with ribbon cable. Signal from input selector is SPDIF and connected to SPDIF input of miniSHARC. DSP has its own clock oscillator and external one cannot be used, unlike with some other miniDSP boards. Therefore, this master clock (MCLK) is taken from miniSHARC and buffered with CDCV304 clock buffer (IC1) for DACs. Word clock LRCK and bit clock BCK are simply divided passively.
Green PCB is the motherboard I have designed and blue PCB is miniSHARC. Voltage regulator heatsink is mounted on the enclosure. Behind display on the front panel are microcontroller board and VOL-FP add-on board for miniSHARC for changing filter presets. Overall appearance is a bit messy, mostly because of panel connectors instead of PCB-connectors.
Input selector has two isolation transformers (PE-65612) for coaxial SPDIF-connectors and two toslinks are wired out of the board. There are termination and bias circuit after the transformers for correct impedance and proper signal level for DS90C402 differential line receiver. Single ended signals are routed to a multiplexer with toslink-receivers. Multiplexer is controlled by two signals (OE1, OE2) from microcontroller. Output is routed to the SPDIF-input of miniSHARC.
DAC-circuits are mostly according to datasheet with the exception that I am not using differential amplifier at the end because I wanted to maintain balanced outputs. Analog outputs of PCM1792A are differential current outputs containing high-frequency components from DA-conversion, mostly located at rather high frequencies due to highly oversampling architecture and noise shaping. Low-pass filtering is needed to reduce the energy of high-frequency interference but cutoff frequency can be set quite high, approximately 200 kHz is suggested in datasheet, to guarantee minimum effect in audio band. The first op-amp stage after DAC is current-to-voltage-converter (I/V-stage) with first order low-pass filter, implemented with OPA2134. LME49724 fully differential op-amp is used as next low-pass filter stage and buffer with resistors to give proper voltage level. PGA4311 stepped attenuator runs on ±5 V so level cannot be too high and DC-components need to be removed before it (by the fully differential amplifier). It is recommended to drive PGA4311 with low impedance. After it are another buffers to ensure lower output impedance than PGA4311 has. Also resistors are provided to set fixed attenuation as a precaution.
Power supply is very simple with LM317/337 regulator pair for approximately ±12 V from which ±5 V for PGA4311s is taken as well as 5 V and 3.3 V for digital circuits. I knew this scheme is bad due to linear regulators and large voltage differences but I still didn’t know it would get that warm as it gets. I should have used switching regulators for digital supplies.
Microcontroller board has Atmel ATmega324A microcontroller with crystal and connectors to display, rotary encoder, IR-receiver and programmer.
I definitely would have wanted to make a 4-layer PCB but they are much more expensive than 2-layer, and I was also unsure about getting it right the first time. After all, this was my first factory made PCB. Moreover, Iteads, where I ordered my PCB from, does not make large enough 4-layer boards. Therefore, I decided to make it 2-layer 10×20 cm where 10×16 cm is the actual “mother board” and the last 10×4 cm is a microcontroller board. Iteads doesn’t allow real panelising so you can only mark the separate boards on silk screen and cut them by sawing. I won’t go into the details of the layout. It is decent and works but as pointed out, I would make things slightly differently now. I used panel connectors to save space on PCB but it is definitely better to use PCB-connectors to get better mechanical performance and neater appearance, possibly also better electrical performance. For that the holes need to be machined accurately which I obviously couldn’t do in my bathroom with hand-tools. This was done before I found Schaeffer AG.
Basically everything is controlled by Atmel ATmega324A microcontroller so functionality comes from the embedded software. Simpler program would have been enough but I wanted to push a bit further and the features are listed above. The purpose of the software is to respond to user actions and show information back to the user on display, otherwise it is just idling. Responding means switching input or sending commands via SPI to stepped attenuator to change volume. Basic functions could be done by simple program but due to extra features it got more complicated and especially remote control sets some time constraints as well. But it was not due to demanding software requirements but my will to learn new that made me choose FreeRTOS as a basis for the software. FreeRTOS is, as the name implies, Free Real Time Operating System ported to numerous different microcontroller and processor families. It is not the simplest and smallest of them but is very versatile and can be scaled by selecting needed feature set. It took quite some time to learn how to use the provided functionality and especially how it should be used to ensure deterministic operation. I won’t go into details of RTOS here, their website provides some basic information and API reference of the FreeRTOS kernel.
As an opinion, and without further experience on RTOSes, I can say that everything needed for using FreeRTOS is on their website but it is not always easy to find. Also the kernel has evolved over the years and documents have been made for different versions. It has also developed into a much more complex OS you never need or can use in small microcontrollers. However, thanks to its great scalability you can just exclude parts and reduce the compiled size and use in almost every controller. It needs few kB of flash and the amount of tasks you can run depends on the RAM available. With inefficient 8-bit controllers only few tasks is sensible and also the context switching shouldn’t occur too often or otherwise the FreeRTOS kernel suffocates the program. It may be worth buying one of the presumably better documentation sets.
I won’t go into the details of my software here and won’t provide the codes. This is mostly because it is such a huge mess when learning and developing at the same time. If I once find motivation to re-write it, then I may release the codes.
Device under development. Idle screen shows on upper row physical input name, assigned source name for that input, DSP configuration preset number (1), DAC filter steepness (symbol for sharp and slow) and on lower row volume in dB and delta-sigma oversampling ratio.
Video showing the operation. Display doesn’t blink in reality like in this video.
miniSHARC is a multi-purpose audio digital signal processor (using Analog Devices Sharc ADSP21369) which can be used in various filtering tasks in audio such as multi-way active speaker crossover filtering and equalisation. I am using it for digital room correction which is equalisation based on the characteristics of the audio system including room acoustics. These DSP boards by miniDSP Ltd are for OEM applications and custom products, therefore most of the products they sell cannot be used on their own. It is also the case with miniSHARC – it is a bare PCB without connectors and with interface you cannot find in commercial audio products. It needs a motherboard to provide needed connections, which is what I have done here. It accepts uncoded stereo (no coded multichannel formats) SPDIF input (but directly from coaxial RCA which has wrong signal level) but output is I2S which is a synchronous serial digital audio format with data and 3 clock signals. There are 2 input channels but 8 output channels so the input channels can be divided into various outputs with various filters.
Setting up DSP is programming all needed filters along with level, delay and compressor if needed. Filters can be set in parametric format (PEQ), biquad coefficients or FIR coefficients. These are done in PC-software, or plugin as they call them, so computer is always needed when setting up the DSP. 4 configuration sets can be stored and these changed also without PC. For digital room correction, acoustic measurements are necessary. I am using Room EQ Wizard (REW) software and UMIK-1 USB measurement microphone for measurements, and from REW you can export filter parameters and import them into the plugin. It is an iterative process of measure, setup, measure, listen, etc. MiniDSP website has some application notes for DSP-basics, digital room correction, acoustic measurements and how to get quickly started with REW. I have mostly followed these to get started. I am not an expert in this field yet and have a lot to learn and experiment when all my hardware is finally finished.
Below are some screenshots of the plugin, a PC-software used to set up filters and program the DSP. Therefore, no knowledge of DSP-programming or capacity limits are needed here. Here is the datasheet of the current plugin which determines technical capabilities of the DSP. New plugins may and most probably will be released. At the moment there are two versions of the same plugin for sampling frequencies of 48 kHz and 96 kHz. Software and DSP-board are designed and manufactured by miniDSP and I am just one of their customers, curious to take their products as part of my own designs to create impressive functionality with reasonable efforts.
This is mostly for people using miniSHARC and wondering how I am able to change the filter presets since I cannot communicate with the DSP-board. There is a possibility to save filter sets as presets in miniSHARC PC-software and then later change the active presets without PC. However, to do that it is required to have VOL-FP add-on card which provides rotary encoder and IR-receiver. By using IR, generic remote controller with NEC or Sony codes can be used to teach the commands to the device in PC-software. Besides some other functions these commands include preset-changing. What I have done, is to remove the IR-receiver from the VOL-FP board and wire a microcontroller pin to that. Then, by imitating NEC IR-codes the microcontroller is able to change presets in miniSHARC. Not very elegant but much easier to implement than reverse-engineering the undocumented 2-way custom communication protocol (according to miniDSP) between miniSHARC and VOL-FP.
Minisharc plugin – mixer. Here channel routing is set up. Output 1 and output 2 are left and right and output 3 subwoofer where both channels are summed (and filtered elsewhere). All settings can be saved into 4 different config presets which can be then changed without PC.
Minisharc plugin – crossover filters. Low-pass and high-pass filters can be added to channels, here high-pass for main channel. On the background can be seen setting panel for all channels including output level, crossover filter, FIR-filter, parametric/biquad, mute, invert, compressor and delay.
Minisharc plugin – parametric eq / biquad. Parametric filters can be set up or import coefficients. Here filter coefficients are from Room EQ Wizard for digital room correction.
Improvements / Faults
Luckily (or if I forget my Finnish over-humbleness its due to my careful design), it seems there was no severe design flaws. But for sure there are things I would do differently in a second iteration. The most significant single improvement affecting the overall design would be to use 4-layer PCB. Iteads didn’t offer 4-layer boards in that large size and ordering such board from some other factory would have cost many times more. Being unsure about my design I went for the 2-layer one. 4 layers would allow much lower inductance in power distribution. After all, the design uses many different power supplies and now the power distribution is done with long and thin traces and too much daisy-chaining. I would also use PCB-connectors, and extra layers would probably give the extra space needed for those. Then some external wires could be left out and overall appearance would be neater. Building would be also easier and the whole device mechanically more solid. One mistake I made with the PCB is that I chose 1 mm thickness thinking it would be electrically better. However, it is obviously a no-no in such a large board where you also stack another board. It simply bends, quite a lot. It needs support. After all, 4-layer board would make the design generally better, especially from overall EMC standpoint.
Power supplies are super simple and robust. I kinda like it since those 3-pin regulators just work. However, I’m also consuming excessive amount of power compared to what the whole device actually needs by using linear regulators in such wide voltage requirements. This is especially true for the VFD (which I didn’t know I would use when designing this – I just found it) which needs rather high current from 5 V which is again regulated from around 15 V. The power levels are still small but for the device this size and small heatsinks they generate a bit too much heat. Heatsink is mounted on the enclosure but the whole enclosure still gets quite warm. Now I would definitely use switch-mode regulators for digital supplies. Although switch-mode supplies are often considered not to be suitable for audio designs, here the DSP-board already uses one. And many of the modern power amplifiers are class D anyway.
After all, I am pretty amazed everything worked so well. Especially considering this is my first ‘real’ thing I have designed and finished. It took enormous amount of time and rather lots of money as well. And this gave me the spark to continue my designs to the miniD Preamp, HP DAC and 4-channel DIY audio system, and I am quite sure that was not all!
I have not given references list but used links directly to references. However, there is a list of some documents and books I think are worth reading on the main projects page. Feel free to comment and ask questions so I can clarify some things and further develop the description. At the moment it is still quite vague. It will not become detailed building instructions though.