• 3.2½ - DAC - Late Night Single Ended Thoughts

    MS-Dzo04/02/2024 at 08:26 0 comments

    Hello everyone !

    Last update was about the single ended filters, which i thought we were done with but somehow something really important dawned on me, let me explain :

    • Speakers impedances are usually standardized and really low, think 1, 2 ,4 , 8 Ohms. They can therefore be driven really hard (low impedance = high current). As such, they are always in BTL configuration.
    • Headphones impedances are not really standardized and rather high (30 Ohm to 600 Ohm). They really don't need that much power to be driven though, usually in the tens of mW.


    Here's the kicker, single ended outputs are usually reserved for signal transfer, not for for driving

    • RCA for instance is meant to go between a DAC and an amplifier, not an amplifier and a speaker.
    • 3.5mm / 6.25mm jacks don't carry the current needed to drive speakers, just the signal etc.
    In fact to my knowledge there is only one kind of driven single ended output : headphone out.
    The rule for signal transfer is low output impedance, high input impedance. We only need a few mA at most, and we want to be load independant....

    why not use an OpAmp ? an OPA1611 should deliver way enough power without coming close to bottlenecking on noise or THD...

    Literally just placing it after the single ended filter should do the trick, no clue how that flew above my head but yeah.

    A few design choices remain to be made : 

    • should we use the volume control from one of the ICs, or with a variable gain at the OpAmp ?
    • is the opamp really load independant for smaller loads ?


    Futher testing is required !

  • 3.2 - DAC - Test board design : Filter design Part 1

    MS-Dzo03/31/2024 at 00:55 0 comments

     Hello everyone !

    Little update on the DAC, let's see what we have in store for today.

    1 - Prototype Topology


    First things first, Since i'm doing an output stage, i'm going to have to deal with differentials filters, differentials amps, power supply filtering etc. The board will include those elements, but they'll be somewhat isolated (i need to test them after all ! ). The entire thing will be powered by a stabilized power supply, so expect banana plugs and BNC test points.

    Since my outputs can be differents (bridge tied vs single ended), It means that I will have to use AD and BD modulation.

    For testing, i also want a mono single ended output.


                                                                               (ripped straight from the datasheet)

    most headphones lines are single ended and not differential (Left and Right share a ground) so that's what i'm going to design at first.

    2 - Filter Design - Single Ended output  

    Let's start designing !  the datasheet says that the output PWM frequency for a 96kHz 24 bit audio signal will be over sampled x4 which is 384kHz. That's a lot less than i expected (I would have thought it'd reach the MHz range). So,  i think a higher order low pass will be needed because i doubt -20dB will cut it to remove all those high frequencies harmonics.

    I know the actual speakers can't reproduce those sounds, i'm mainly focusing on the EMI produced by all that switching over the cables.

    Might aswell go overkill, so here's my attempt at a 5th order Butterworth filter with a ~60KHz cut off frequency. I chose this frequency such that any ripple that happens after normalizing the components values would be ideally after 20KHz.

    I ended up with a sliiiight ripple but it's inevitable, and check this out, -72dB at 300KHz. Take that high frequencies !

    As for the ripple, it should be perfectly inaudible at 20KHz since it's only -0.007dB !

    Turns out having a whole semester about butterworth and chebyshev did prove useful after all, uh.
    By the way, the impedance of this filter is 80 Ohms because the headphones are use are 80 Ohms too, but after all, it doesn't really matter !  (haha...)

    Should i add a ferrite for EMI too ? i don't know ! Here's the circuit.

    please comment if you know more than me (you probably do !) because this filter design seems good enough for me...

    Wait... you hear that ? Holy jesus...


    What is that ? What the fuck is that ? That my friend is what happens when you do a hundred runs of monte carlo analysis with a 10% margin on error on all 5 components of the filter.

    So, three ways to deal with it : 

    • stop with the high order stupidity (i don't wanna :c) and pay more for 1% components (the results are good enough tbh)
    • find another filter design that is less sensible to single component value deviation (i don't know any) 
    • place the capacitors next to each other to mitigate thermal effects as much as possible, while also trying to pick the best matching ones myself.

    I'll go with solution one and three thank you

    I'll also have to wind my own inductor, which i've never done before. I never ever bought a toroid thingy either ! i've got so much to learn.

    Did you know that headphones impedance can reach as much as 600Ω ? Here's the response with perfect components but with variable output impedances (from 1Ω to 200Ω) :
    and, just to test something, here's a second order LC low pass filter response for an impedance varying between 1Ω and 1kΩ


    Uh oh....

    3 - Load dependency - Buffer Stage ?

    So, changing the load changes the frequency response : if you...

    Read more »

  • 3.1 - DAC - Making mistakes, general design, more big picture stuff

    MS-Dzo03/07/2024 at 00:54 0 comments

    Hello everyone, i've been hard at work   ̶g̶e̶t̶t̶i̶n̶g̶ ̶m̶y̶ ̶c̶a̶d̶e̶n̶c̶e̶ ̶l̶i̶c̶e̶n̶s̶e̶ ̶b̶a̶c̶k̶ on the DAC, but also "redrawing" the whole project.

    First things first, let's address a few important points/thoughts I had since last time :

    1. What will the Output Unit (DAC unit / DAC / Power amp) topology be like.
    2. Changing the mixing algorithm
    3. I2S means Inter-IC Sound, so how can i make a modular system (ie : multiple PCB for multiple inputs/outputs) since length of track will be variable ?
    4. the choice of ICs need to be done so I can start designing the circuit.
    5. How do I test this.

    Let's see those points in detail.


    1 - Output Unit structure details / Amplifier talk.

    One thing that might have not been clear before is that the mixing unit acts as a separation between the sound sources and the amps/headphones/whatever : Any data out of the mixer either goes back to the sources through USB (as a microphone input) or get sent out through I2S. What we're currently designing is the "DAC", or the output unit, used to transform the I2S into analog signals that can then get amplified by any kind of analog amp.

    Analog amplifiers come into a really wide range of configuration, each with their own unique ups and downs. Class A, B etc. are easy enough to make but are rather inefficient, while class D amps are the opposite : really complex, really fiddly, really efficient. Making a class D amp entirely by myself is out of the question, but chips do exist that allow for the dreaded analog to 1 bit modulation. Most class D amps out there are made with ICs taking analog in and spitting HF PWM out that get filtered back to ~20Hz - 20kHz.

    The idea is therefore to create a "comparator amplifier" that acts as closely as possible as an ideal opamp in comparator mode : taking the HF PWM signal (with "Voltage High" and "Voltage Low") and spitting out a symetrical Signal (±V amplifier) such that both waveform are exactly the same, just with different amplitudes.

    Here's the structure of the output unit with power amplifier attached.

    As you can see, volume control is entirely determined by the power supply of the entire output stage.

    In our case, the output unit actually needs at least 2 analog output : Line Out and Headphones Out.  I'll just do the same comparator Amplifier + Filtering Combo on the same PWM input to get both signals, with different V_amp voltages for each.

    I'll also allow a PWM output because my portable DAC unit won't have a beefy variable voltage source needed for the power amplifier part. Therefore, i want to future proof it by being able to be connected to such an amp down the line : making different modules make prototyping much easier.


    NB : by choosing this method, i completely bypass the analog pre amplifier needed for the input module that i was supposed to design now, which mean i'll have to design it later.

    NB : This output module is entirely optional, there exist many I2S to Analog DACs out there. I'm just designing it because it's fun.

    NB : This method moves the complexity away from the actual amplifier design and toward the power supply design.


    2 - Sound with 32 bit-depth makes no sense

    In the introduction of the project, I devised a few ways to deal with potential overflow. Since i wanted to not deal with distortion so much, i decided to just put the 24 bits + overflow onto a 32 bit channel and pretend everything was fine. it's not fine.

    So, let's say we have a 32 bit DAC chip, working with a specific voltage. It takes I2S as an input and output an analog signal using what is black magic for our intents and purposes. That output should be perfectly linear. Well, let's say we're using a symmetrical 5V power supply. The DAC's resolution is 10/(2^32) volts, or roughly 2.33 nanovolts. Let's be clear, that's absolutely impossible to achieve, which means the least significant bits of our signal are straight up noise. The DACs are more expensive, I2S timings are tighter,...

    Read more »

  • 3 - OUTPUT MODULE

    MS-Dzo02/10/2024 at 07:00 0 comments

    What is it ?

    The Output module will probably be one of the first module completed. Here it is :



    That's right, we don't have any hard processing to do, maybe a bit of filtering here and there, a few potentiometers for volume control but overall it should be manageable. The DAC will be bought according to its availability and specs.

    The Line Level will be used to connect to other beefy Amps, whereas the Headphone level will straight up be usable.

    Why do it first ?

    There is a very easy way to test the preamplifiers and the bridge : making a dedicated audio DAC, such as the ones you can buy. We just need to connect our USB bridge to the DAC.

    Voila ! a DAC.

    Once this device work, we will know our I2S bridge and Preamp works, which mean we can start working on the Input and Mixer modules !

    From now on, this is on what i will be working and report.

  • 2 - INPUT MODULE

    MS-Dzo02/10/2024 at 05:38 0 comments

    What is it ?

    The Input module doesn't technically needs to exist for a purely digital system, but as I plan to use this with analog devices (microphones and instruments) so I am designing it.

    This module is therefore separated in two specific part :

    • The ADC, transforming the analog values to an I2S stream to be processed by the Mixer Module
    • The USB Bridge, which acts as an USB slave and talks to an USB Master (a computer) over duplex USB audio to recieve and transmit audio streams. Those I/O streams are transformed/comes from I2S streams.

    From this description, it is therefore clear that the Input Module is a magic box that looks like this :  


    NB : the USB bridge only works as a slave. I have no plan on making it work with USB headphones, or USB microphones. I don't know how nor am I interested in that feature for now.


    Also important is the fact that the USB bridge will probably be on this module : this allow clean cable management on a rack which is noice. unpopulated components will be placed on the main mixer PCB so that if you want only 2 USB devices and 4 analog inputs you don't have to buy 6 MCUs instead of 2.


    Analog Processing - The Plan

    As you can see, the Analog part has some processing in it, and it is crucial. Our analog devices might need phantom power, an attenuator, a pre-amp, the input might be balanced, stereo, mono etc.

    The Input module is in fact the most important module because even if everything else works, if it isn't calibrated correctly the rest will sound like garbage : if the bridge doesn't work then no audio will reach the mixer/the user, if the analog part sucks then the processing won't give correct results etc.

    The processing chain will look something like this :


    NB : the mono/stereo/differential path are just for visuals. The "mono to stereo" module is the same for mono and differential, the low pass filter is the same for each three path. depending on the user input selection, certain modules will be shorted and ignored.


    Filtering is necessary to remove the aliasing that will come after the ADC.
    If the user amplify a signal that is already large enough, it will clip and create harmonics that will also create aliasing.

    To be honest, i don't know if both filters are necessary or only the one before the ADC. My small experience tells me to do both but i have no audio training and only saw it on highly specific metrology applications, way beyond the scope of audio. So, this will stay for now but if the OpAmps use are too expensive one might leave.

     

    Analog Processing - Phantom Power

    This will be short :  most of it will be taken from this amazing tutorial by DJJules and its included references : https://www.instructables.com/Build-the-Four-Channel-SSM2019-Phantom-Powered-Mic/

    Basically : you press the phantom power button and the inputs gets polarized to a specific voltage. He uses 15V, I have yet to decide what to use.


    Analog Processing - Preamp

    To be done : this part will be reused for other parts, so we will study this later.


    Analog Processing - Attenuators

    To be done, still have to check whether resistor cause too much noise vs using dedicated audio ICs ( it'll probably be resistors)


    Analog Processing - ADC

    This'll be short : I'll simply use an out of the box two channel ADC that outputs I2S at 24 bit 96kHz. That's all it has to do, and most modern ADCs are so good that most of the issues will be with my circuit, not the chip.


    Digital Processing - Bridge

    To be done : this part will be reused for other parts, so we will study this later.

  • 1 - MIXING MODULE

    MS-Dzo02/10/2024 at 02:38 0 comments

    In the general description of the project, I briefly mentioned the 4 core units of the project :

    1. a general use input module to be able to get analog data in
    2. a general use output module to be able to get analog data out
    3. an HID module to interact with the system
    4. the Mixing module to actually work on the data

    Those are obviously incredible simplified. In the next few logs i will write a bit about the inner workings of and limitations of each module, the protocols that will probably be used and why they'll be used.

    This one will be dedicated to the star of the show, the MIXING MODULE


    What does the mixer actually do ?

    The mixer is able to take digitalized audio streams, process independently and together, then output them to the outputs selected. Here are all the features that i want

    FeatureUse Case
    Stereo Sound through USB
    Using Headphones or 2.1 systems
    ModularityYou want to plug 2 PC and 1 guitar or 5 microphones and 1 PC
    Per Output Input selection
    You want Output 1 with Input 1, Output 2 with Input 1 and 2
    Per Input volume control
    Allow to turn down your microphone if it's too loud
    Per Output volume controlAllow to turn down music if it's too loud
    Each Input get its own EQ / filterIf your microphone is hissing, you can remove it from all the outputs easily
    Each Output gets its own EQ / filterMake using a subwoofer or a tweeter at high power easier
    Each Output gets its own delay lineAllows to synchronize all outputs, if one is too delayed because of filtering

    Specs aren't the point of this project, i want them to be lax enough to have fun and to learn : I'm not looking for a 0.0001% THD or something like that, at least not for now.

    My setup is rack mounted, so it'd be fun if the modules were rack mounted too / something akin to eurorack in a 19 server rack ?  ¯\_(ツ)_/¯


    What Audio Streams format are we choosing, and why ?

    the audio streams will be encoded in PCM over I2S because it's a standard and makes creating input and output modules easier since compatible ICs already exist.

    NB : every stream from now on is considered stereo, until specified otherwise

    In simple terms, PCM means that the audio signal is encoded by saving its amplitude at a specific frequency.  a 8bit 1kHz PCM stream means that every milisecond, you get a byte of data representing the amplitude of the audio signal. 0xFF is the maximum (positive values) , 0x00 is the minimum (negative value) and 0x0F is the middle point or zero.

    NB :  those values are not representative of volts or whatever, they're normalized. each ADC has a gain of "bits per volt" called resolution that ISN'T shared to the system. this means that over the entire processing chain, we have no clue how loud the sound is. This tie with issues like headroom, clipping etc.


    The fact that we are encoding amplitude makes mixing absurdly simple :

    NB : this result only works if all the streams are at the same frequency

    The mixer must be able to be used for recording music, so instead of the average 48kHz sampling frequency, we will go with 96kHz. This roughly means that if you want to process your instrument by slowing it down by a factor of 2, you will still end up with a 48kHz sampling frequency. This doesn't increase quality in any other way.

    N.B : Some acquisition cards go up to 384kHz for the same reasons, we could but we won't go near that since i have no way to actually test it nor do i care about it.

    With the same idea, we'll go into audiophile territory a bit and go with 24bit encoding instead of 16bit, even though the differences can't be heard. Following the same logic as choosing 96kHz over 48kHz, this will allow more flexibility when processing amplitude instead of frequency (ie : you can digitally amplify audio more before hearing distortions)

    So, instead of going with the usual 16bit 48kHz, the inputs are 24bit 96kHz streams, which isn't that special for high end audio hardware.


    Overflowing Issues and solutions


    Let's say i have 4 inputs...

    Read more »