UnDecima Audio Output from Arduino

13,031

Circuit Image

There is a project involving an Arduino that outputs audio signals to USB speakers using 10-bit PWM. Initially, the sound quality produced via PWM was unsatisfactory due to the limited processing speed of the Arduino, which is insufficient for high-frequency audio signals. For example, a 20 kHz audio signal requires PWM frequencies of at least 40-60 kHz. When considering 10-bit resolution, this results in a requirement of 40-60 MHz, which is beyond the capabilities of a small Arduino. The concept of creating a multichannel audio system has been under consideration for about a year, leading to the development of the UNDECIMA project. This system features 12 channels, comprised of one master channel and 11 linearly delayed copies of the same audio stream, resembling an acoustic phase array. The core of the project is a 10-bit multiplying digital-to-analog converter (DAC), specifically the DAC1022. The output of this IC is buffered with an operational amplifier (OPA) and demultiplexed using two 74HC4051 8-channel analog switches. The outputs of the switches are loaded with 0.01 µF sampling and hold capacitors to filter out unwanted noise from the sampling frequency. The DAC is configured for a single power supply. It is typically recommended to buffer the output with a high input impedance, high slew rate, rail-to-rail OPA, which is not available in this case, prompting the use of two variable voltage references based on NE5532 and a couple of potentiometers. The voltage difference between the two references creates a span, with the lower voltage providing an offset for the non-rail-to-rail OPA (LF351) with a slew rate of 13 V/µs. The OPA is heavily loaded by the sampling and hold capacitors, presenting a total capacitance of 0.12 µF at its output. To minimize distortion caused by overloading the OPA, the span cannot be adjusted too widely, and it is preset to 1.414 V, yielding a 1 V RMS output for a pure sine wave. Although adding 12 buffers and filters after the switches would resolve issues, the prospect of soldering over 100 electronic components on a breadboard is unappealing. The software component of the project is straightforward, implementing a sample-delay-output function within an interrupt subroutine, leaving the main loop empty. The setup configures 16 digital pins as outputs, with 10 representing the data bus, 5 as the address bus, and one as a checkpoint for performance measurement with an oscilloscope. Timer 2 generates a heartbeat, triggering an interrupt every 25 µs, or at 40 kHz. The ADC is set to sample from analog input A5, with the first four analog pins allocated to the data bus. The conversion prescaler is set to 1 MHz, allowing for rapid sampling. Two digital pins, D0 and D1, have been left free due to initial attempts to utilize them in the data bus being unsuccessful, leading to periodic issues with the Arduino not accepting updates. Each sample received from the ADC is shifted left by three bits to bypass D0 and D1 and to correct imperfections from the input preamplifier stage. Measurements indicate that each channel receives data for approximately a 1 µs window, which, while fast, is insufficient for managing 16 channels or processing data before output. In the current hardware setup, the OPA represents the bottleneck, as the DAC has a settling time of only 500 nanoseconds.

The UNDECIMA project represents an innovative approach to multichannel audio processing using an Arduino platform, integrating a sophisticated DAC and analog switching mechanism to achieve improved audio quality. The use of a 10-bit DAC1022 enables precise audio signal generation, while the buffering and filtering stages are crucial for maintaining signal integrity. The choice of NE5532 for voltage referencing, despite its limitations, showcases a cost-effective solution to achieve the necessary voltage levels for the OPA. The design's focus on minimizing distortion through careful configuration of the voltage span and the use of sampling and hold capacitors demonstrates an understanding of audio signal processing fundamentals.

The software architecture, relying on interrupt-driven sampling and output, is efficient for real-time audio processing, though the limitations of the Arduino's processing speed and the challenges faced with the data bus configuration highlight the trade-offs inherent in such a project. Future iterations could explore alternative microcontrollers with higher processing capabilities or additional signal processing techniques to enhance the system's performance, particularly in managing multiple audio channels simultaneously. Overall, the UNDECIMA project illustrates the potential of combining digital and analog techniques in audio applications, paving the way for more advanced audio systems based on microcontroller platforms.I already have one project where arduino outputs audio signal to USB speakers via software 10-bits PWM. In first, I was not satisfied with quality of sound generated via PWM. There are just not enough speed in arduino engine to run PWM well. For example for 20. 000 Hz audio, PWM has to be at least 2 3 times higher above normal frequency range, or 40 60 kHz. If we multiply this value with 10-bits resolution, we would get 40 60 MHz, that is too much for small arduino to drive. In second, the idea to create multichannel audio system was boggling my mind for about a year now. This is how UNDECIMA project was born. 1 + 11, or 12 channel ! audio system running on arduino UNO board with full 10-bits resolution maximum available with internal ADC.

Project gets its name because there is 1 Master channel, and 11 linearly delayed copy of the same audio stream, or Puppets channels, In its essence, this is acoustic Phase Array. As you can see on posted drawings, the heart  of the project is 10-bit multiplying (parallel) digital analog converterDAC1022.

Output of the IC than buffered with OPA and demultiplex`d  via two 74HC4051 8-channel analog switches. Outputs of the switches loaded by sampling and hold capacitors 0. 01 uF, to filter out unwanted sampling frequency noise. DAC isconfiguredfor single supply power line. Usually, they recommend to buffer output with / high input impedance / high slew rate / rail to rail / OPA in such configuration.

Which I don`t have, and it costs about half a price of DAC itself, So, this is why I implemented two variable voltage references based on NE5532 and couple of pots. Difference in voltages between tworeferences forms a span . Lower voltage creates an off-set for cheap non rail-to-rail OPA LF351, with adequate slew rate 13 V/usecond.

OPA is heavily loaded by sampling and holdcapacitors, which it sees as connected inparallel at its output, 0. 12 uF overall! To minimize distortion level due overloading of the OPA, span couldn`t be adjust too wide, and preset in current design 1.

414 V, providing exactly 1V RMS output for pure sine wave. I know, that 12 buffers / filters inserted after switches would solve a problem, but idea to solder more than 100 electronics components on a breadboard doesn`t look attractive for me. Software part of the project isstraightforward sample-delay-output  function, completely wrapped inside interrupt subroutine.

Main loop is empty. In setup 16 digital pins configured as outputs, 10 of them represent data bus, 5 are address bus and last one is check-point to measure performance withoscilloscope. Timer 2 defines a heartbeat , and fires interrupt every 25 usec, or at 40 kHz. ADC configured to take samples on analog input A5 (first 4 analog pins belong to data bus). Conversion prescaler: 1 MHz, allowing sampling to be completed with fast speed. I left two digital pins D0 and D1 free, as my initial attempts to use them in data bus failed. Arduinoperiodicallyrefuses to reload updates, I`m not sure if it`s Linux problem or on-board USB/RS232 converter.

Each sample, received from the ADC, is shifted left on two bits to skip D0 and D1, and plus one bit more (3 bits left shift overall) to fix imperfection  of input preamplifier stage, as NE5532 (again) non rail-to-rail  OPA. Look for drawings in Audio Input  blog. Measurements show that each channel is receiving a data for about 1 usec window , which is quite fast, nevertheless not fast enough to run 16 channels or to do something else with data before sending them out.

In current hardware implementation the bottle neck  is OPA, as DAC has settling time only 500 nanoseconds. 🔗 External reference




Warning: include(partials/cookie-banner.php): Failed to open stream: Permission denied in /var/www/html/nextgr/view-circuit.php on line 713

Warning: include(): Failed opening 'partials/cookie-banner.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/nextgr/view-circuit.php on line 713