One Bit Sigma Delta DAC

XCore Project reviews, ideas, videos and proposals.
User avatar
Berni
Respected Member
Posts: 363
Joined: Thu Dec 10, 2009 10:17 pm

Post by Berni »

Well i done PWM audio on xmos before in the SD card wav player. Was a little noisy but other than that it worked nicely.
User avatar
lilltroll
XCore Expert
Posts: 956
Joined: Fri Dec 11, 2009 3:53 am
Location: Sweden, Eskilstuna

Post by lilltroll »

Berni wrote:Well i done PWM audio on xmos before in the SD card wav player. Was a little noisy but other than that it worked nicely.
Well, lets see if I can get some 60+ dB SNR then. I need to practice my C-coding skills. So I will try to do it without looking so much of the avaiable code - at least not from the start.
Probably not the most confused programmer anymore on the XCORE forum.
User avatar
Berni
Respected Member
Posts: 363
Joined: Thu Dec 10, 2009 10:17 pm

Post by Berni »

60dB SNR in your dreams.

i could really hear the noise when it was producing 'silence'. Altho using hardware PWM on a dsPIC worked a lot better, still you could only get 8bits of resolution. If you want to get some proper audio out of it forget about PWM. Its simple and it works fine for some basic sound. It might be a much better idea to try a resistor DAC since that will allow very high bit depths and sample rates, but this method is I/O expensive and just as timing critical.Best method you can use is a real audio DAC chip running off its own oscillator.That way samples are exactly in sync with the clock and SNR in the order of 100dB is possible. So for proper audio just take the proper DAC chip, they are cheep,small and easy to interface with a xmos chip.
lurcher
Member
Posts: 14
Joined: Sun Jan 24, 2010 5:53 pm

Post by lurcher »

Converting DSD to analog just requires a low pass filter. But I haven't actually done it so I can't speak with any certainty, but I would have thought it was more than possible to convert to DSD with a less than 100MHz clock.

I think we are talking about two different encodings, what you describe as creating 0v output would be a continuous stream of '0', what I am suggesting is a stream of 10101010101 with a 50% mark space ratio.
User avatar
lilltroll
XCore Expert
Posts: 956
Joined: Fri Dec 11, 2009 3:53 am
Location: Sweden, Eskilstuna

Post by lilltroll »

So my PWM is running a sin calculated by double floats. The amount of distortion feeding the XC-1 speaker is ... intresting. :mrgreen:

:?: You are talking about PCM->PDM (Pulse Density Modulation) and by minimizing the "running" quantization error we are able to do something "more efficient" than PWM if we have limited time resolution. Depending on the error we deside if we should go Up or Down in the PDM code (If the source is a PCM signal). And the PDM can be converted to an analog signal by LP-filtering.
Something to try out tommorow ... if there isn't already 200 old examples posted on the XMOS-forums - well tomorrow I guess I know - and it good XC practice for me :D
Probably not the most confused programmer anymore on the XCORE forum.
lurcher
Member
Posts: 14
Joined: Sun Jan 24, 2010 5:53 pm

Post by lurcher »

Yep, that was my thought, you sacrifice the above band noise for lower clock rate. Hopefully I will have a working XMOS system soon as well, so it will be a good exercise.
User avatar
Andy
Respected Member
Posts: 279
Joined: Fri Dec 11, 2009 1:34 pm

Post by Andy »

lilltroll wrote:So my PWM is running a sin calculated by double floats. The amount of distortion feeding the XC-1 speaker is ... intresting. :mrgreen:

:?: You are talking about PCM->PDM (Pulse Density Modulation) and by minimizing the "running" quantization error we are able to do something "more efficient" than PWM if we have limited time resolution. Depending on the error we deside if we should go Up or Down in the PDM code (If the source is a PCM signal). And the PDM can be converted to an analog signal by LP-filtering.
Something to try out tommorow ... if there isn't already 200 old examples posted on the XMOS-forums - well tomorrow I guess I know - and it good XC practice for me :D
I'm very interested in hearing any suggestions on how to improve the audio quality output without resorting to using an external DAC.
User avatar
Woody
XCore Addict
Posts: 165
Joined: Wed Feb 10, 2010 2:32 pm

Post by Woody »

I've been doing some work on a ClassD amplifier recently and I've been getting some good results compared to others posted here: -90.3dB SNR, 85.4dB Dynamic Range, 3W(RMS) per channel. This is for a stereo implementation with a BOM cost of ~$1.54 (1000 off).

I'm upsampling the audio from 48kHz to 384kHz as outlined in my previous post. But then I'm using PWM rather than sigma delta. As lilltroll explained, a sigma delta implementation has big fixed steps in time, whereas the width of a PWM can be extended by a relatively small amount. This is 10ns when using the standard reference frequency of 100MHz, but I increase this to 400MHz (2.5ns) on an L1 device (200MHz/5.0ns is possible on a G4), giving extra precision. Additional precision is obtained by maintaining an accumulated error from one pulse to the next one.

I'm turning it all into an app note that should be available 'soon'. Of course I'll post to this thread when it's available. Happy to discuss aspects of it here though.
User avatar
Andy
Respected Member
Posts: 279
Joined: Fri Dec 11, 2009 1:34 pm

Post by Andy »

Woody wrote:I've been doing some work on a ClassD amplifier recently and I've been getting some good results compared to others posted here: -90.3dB SNR, 85.4dB Dynamic Range, 3W(RMS) per channel. This is for a stereo implementation with a BOM cost of ~$1.54 (1000 off).

I'm upsampling the audio from 48kHz to 384kHz as outlined in my previous post. But then I'm using PWM rather than sigma delta. As lilltroll explained, a sigma delta implementation has big fixed steps in time, whereas the width of a PWM can be extended by a relatively small amount. This is 10ns when using the standard reference frequency of 100MHz, but I increase this to 400MHz (2.5ns) on an L1 device (200MHz/5.0ns is possible on a G4), giving extra precision. Additional precision is obtained by maintaining an accumulated error from one pulse to the next one.

I'm turning it all into an app note that should be available 'soon'. Of course I'll post to this thread when it's available. Happy to discuss aspects of it here though.
Sounds good! Have you tried listening to the PWM audio before the amplifier stage i.e. straight to a powered speaker? If so, what's the quality like?

I noticed the code you posted uses floats - have you looked at a fixed point implementation?
User avatar
Woody
XCore Addict
Posts: 165
Joined: Wed Feb 10, 2010 2:32 pm

Post by Woody »

I've been concentrating on trying to produce a PA solution rather than a DAC that needs a PA, so I've not really spent much time on that. I have had a single 1 bit port driving an RC filter for testing. From my experience I wouldn't expect much better performance than that which I've posted though. Are you going to drive a speaker or is it basically a DAC solution you're after?

The code I posted with floats was for early simulations I was doing. I've implemented the actual classD code using fixed point arith.