Preamplifier, phono stage & spectrum analyser

My design goal was to create a high-performance preamplifier that:

  • Noiselessly switches 6 inputs with up to 12dB gain – with very low noise, cross-over distortion and high channel separation
  • A neutral colour signature
  • Ultra-low noise digitally controllable volume control, 64dB range in 0.5dB steps
  • Very high-performance phono stage, MM extensible to MC
  • Professional grade enclosure
  • Front panel and IR remote controls
  • Spectrum and VU analysis of source with a dynamic range exceeding 60dB, providing up to 1/6 octave analysis to 20kHz
  • Integrated streamer and DAC
  • High-quality headphone amplifier
  • Integrated bubblesoft server for Tidal streaming

This is what I ended up with.

In this post I’d like to talk about some of the build challenges, solutions and the overall outcomes.

Architecture

Back in 2017 the original architecture was conceived based on a set of boards which could be developed over-time. A professional-grade mechanical enclosure was created to house the electronics and platform for the software.  These are the key aspects of the architecture:

  • Raspberry Pi controller running a custom control application written in Python to drive the display, manage the controls and interfaces including remote control.
  • Resistor ladder based volume control, switched by relays with a digital interface – for ultra-low noise performance
  • Relay based source selection
  • HW controllable mute and first stage gain selection
  • Rotary controllers for source, screen menu and volume control
  • Large ( 256x 64 pixel) OLED display (3″) – for source and spectrum analysis
  • 4 x line level inputs, 1 x internal DAC input, 1 x phono stage input
  • 2 x 12v trigger controls for amp/external PSU power control

This was conceived using 6 boards:

  • Control board:  Rotary Enc buffer, Pi power control, 12v output buffer
  • Raspberry Pi
  • Volume control and ADC/DAC board
  • Audio buffer and source selection board
  • Phono preamp
  • Low noise power supply

Hardware Design

The circuits were either developed from classic designs or reuse of open source designs.  These fell into two types digital and analogue.

Two versions of the preamp were built with only control board and raspberry pi in common. The power supply, in particular, is based on LM317 devices creating seven independently regulated rails, with digital and analogue power supply fully galvanically isolated.

To achieve the low noise goals very considerable effort was required to optimise the grounding connectivity between boards and within the chassis. Design of the grounding architecture took many iterations.  In the end, a star of stars approach was adopted – one for digital and one for analogue.  The two grounds were connected at the ADC input to ensure an absolute minimum of digital noise flowed into the analogue circuits.  A ground-breaker (rectifier, R & C) was used to isolate the ground from earth/chassis to maintain good RF / EMI screening.

The resistor based volume controls required considerable research into the optimum noise vs power vs impedance.  In the end, a low impedance volume control was implemented with an impedance of 1k.  As resistor noise is the square of resistance this level represented the best balance of performance to op-amp drive currents.  Most op-amps can drive 600 ohms, but not lower.  A 7 step design was used using E24 value resistors and implemented using low cost 1% metal film components.

A two-stage, op-amp based buffer was designed to serve the purposes of buffering the volume control ladder, providing a high input impedance (100k) and low output impedance (100 ohms).  Very careful attention was made to the layout of the grounds on the audio board to ensure excellent channel separation and source isolation.  For example, the left and right channel grounds were only connected at the analogue star ground.  Relays are used for channel selection, plus for mute and gain control.  These are all open circuit with power off as a failsafe.  +18dB of gain is switchable for low-level inputs eg phono stage. Overall +12dB is provided giving 8v output for standard 2v line input.  NB: I believe is probably too much and unity gain would be better to give better range to the volume control.

The choice of ADC was less than straightforward as few audio-grade ADCs are readily available for the Raspberry Pi.  An initial design using an Arduino provided a single-channel 9-bit implementation.  This gave about 40dB dynamic range – an acceptable minimum.  v2 of the preamp used the SGTL5000 device in commercially available Fe-Pi board using I2C for control and I2S for audio stream interfaces.  This provides a full bandwidth (44.1kHz sample rate), 16 bit (15 usable) solution with a theoretical 96dB dynamic range.  This proved very successful and straightforward to implement.  The ADC input did not need level shifting as it was AC coupled and the DAC output is sufficient to connect directly to a source input.

With 8 relays on the audio board and 7 relays for the volume control, an integrated driver solution was chosen.  This is based on the ULM2808 Darlington driver and PCF8754 I2C demultiplexer.  This significantly reduced the component count to access all the relays via I2C.  The main OLED is interfaced by the SPI bus and a test OLED based on i2c was also installed on the volume board for testing purposes.  The remaining controls were connected directly (or via transistor buffers) to GPIO pins for power on/off detect, rotary encoder switches (all RC buffered), headphones detect, IR sensor and power-off control.

Software Architecture

Software is a critical element in the overall performance of the preAMP in particular for the low-level controls of source selection and volume.  Whilst the software is deliberately not a contributor to how the amp sounds, the software is fundamental to the look, feel and overall comfort in use.

A fully object-oriented approach to the software design was taken, to achieve a high degree of flexibility in particular to the screen design.  The intention was to conceive and rapidly implement a number of screens using “frame” components that can be assembled differently to create new configurations.

The basic design pattern is Model-View-Controller implemented in three base classes:

  • Platform – comprising all the HW drivers and interfaces and data storage for parameters such as source selected, volume level, audio samples, track metadata etc
  • Screen – comprising a family of screens based on configurations of Frame classes. Where a Frame is a base component eg a single channel spectrum analyser, a VU meter channel, a source indication, volume level display etc
  • PreDAC – overall control class comprising the event manager and event callbacks.

The control flow of the Software is event-based. Events come from real-world events such as sample arrived, rotary encoder turned, power button pressed.  To animate the display incidental screens are controlled by Timer events eg volume change, screen saver etc.  There is a critical timing loop to ensure that the real time display is visibly in time with the music.  The maximum refresh rate of the OLED display over SPI is 40 frames per sec (ie 25ms).  Audio is sampled at 44.1kHz across 2 channels, with a buffer of 2k frames (ie 11 ms/per channel).  Hence, depending on the processing time of each sample (using a digital fast Fourier transform) depends on whether a sample is dropped or not.  Generally, there is not a timing over-run and every sample is displayed.  However, if other inputs are received eg volume changes or a full stereo spectrum is analysed over-runs do occur.  This is not considered onerous as the display is intended to be an indicative visualisation not a precise measurement.

There are several optimisations that could be performed to reduce the probability of over-runs such as the use of the GPU for DFT calculation, reduced sample rate, use of AsyncIO Python architecture.

The Framecore class was developed to provide a set of base primatives to be used with a Frame.  These include left, right, centre, top alignment, drawing resursively frames within frames (ie nesting) with relative alignment. This class significantly reduced the code two prototype new Screens to a few lines, efficiently reusing Frame components. Over 10 screens were developed including: Stereo Spectrum Analyers, VU meters (vertical, horizontal and analogue meter style),  track metadata and source selection.

The Platform base class comprises a set of classes one for each HW module. This greatly simplifies the interface from the Screens to access the data within the system.  Drivers for each HW board eg Volume control and Source control, plus interfaces for the remote control driver and streamer interface to collect changes to track metadata.  All Platform classes trigger events and update their data models.

As the 3 layers are distinct, the complexity within each is greatly simplified in the API each present.  This results in a highly modular and extensible SW architecture, with compromising real-time performance.

Sound Quality

As an amplifier, all that ultimately matters is how does it sound?  The grounding scheme, with independent channels used in v2 from v1 made a significant improvement in cross-talk (none is audible). Also, the volume control is very smooth and contributes no audible noise or distortion. As an Op-Amp based design the choice of op-amp is the major component influencing the sound quality.  Burr Brown OPA2130 used in v1 provided excellent clarity and transparency with a pleasant slight warm/tube sound.  v2 uses LM49720 op-amps which has a lower noise and distortion floor on paper, this resulted in a cleaner, crisper overall sound with great detail and transparency.  Subjectively, this produces a very natural, authentic sound quality that is highly pleasing drawing the listener into turn up the volume and listen for long periods without fatigue.

 

Leave a comment