DSPRelated.com
Forums

How to do digital dithering in FPGA

Started by billy k December 5, 2012
All-

I have 14-bit A/D samples in FPGA and I want to perform dithering to
eliminate harmonics.  How can I do it?

I added the signal with Gaussian noise and did subtract dithering.  And
that didn't work. Any suggestion is very appreciated.

Thank you.

Billy
On 12/5/2012 8:42 PM, billy k wrote:
> All- > > I have 14-bit A/D samples in FPGA and I want to perform dithering to > eliminate harmonics. How can I do it? > > I added the signal with Gaussian noise and did subtract dithering. And > that didn't work. Any suggestion is very appreciated. > > Thank you. > > Billy
When you say you want to eliminate harmonics, do you mean you want to work around linearity problems in the ADC which are causing harmonics? Or are you talking about harmonics introduced elsewhere? Is the ADC implemented in the FPGA? Rick
"billy k" <9383@dsprelated> writes:

> All- > > I have 14-bit A/D samples in FPGA and I want to perform dithering to > eliminate harmonics. How can I do it? > > I added the signal with Gaussian noise and did subtract dithering. And > that didn't work. Any suggestion is very appreciated.
Billy, Did you add the dither to the digital samples AFTER the A/D? That won't work. You have to add analog dither to the analog signal BEFORE the ADC. Once you've quantized an undithered analog signal, you can't recover the information you've lost. -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com
billy k wrote:
> All- > > I have 14-bit A/D samples in FPGA and I want to perform dithering to > eliminate harmonics. How can I do it? >
Harmonics of the fundamental, or aliasing products? Dithering will not help with general distortion. It will only help with quantization distortion/noise*. http://oldweb.mit.bme.hu/books/quantization/dither.pdf Yes, that's a firehose, but it's very good water in the firehose. *technically, it's still correlated for sufficiently deterministic systems...
> I added the signal with Gaussian noise and did subtract dithering. And > that didn't work. Any suggestion is very appreciated. > > Thank you. > > Billy >
-- Les Cargill
On 12/5/12 8:42 PM, billy k wrote:
> > I have 14-bit A/D samples in FPGA and I want to perform dithering to > eliminate harmonics. How can I do it? >
are they already 14-bit samples or are you quantizing to 14 bits? once you've already quantized those samples, it's pretty hard to get the toothpaste back into the tube. adding wideband (bandlimited white) noise won't do much to mask the bad harmonics except if they are at a much lower amplitude than the signal you're interested in. might not do anything useful.
> I added the signal with Gaussian noise and did subtract dithering.
how are you doing "subtractive dithering"? did these 14-bit samples come from another source (with wider words) that was dithered and quantized? if so, and if you can synchronize the RNG that generated the dither before quantizing to these particular samples (and there *is* a way to do that with the LSB of the past N quantized words), you can perform what we call in the audio industry "subtractive dither". it's like this: adding rectangular dither increases the quantization noise power by 3.01 dB but we do it to decouple the mean (the 1st moment) quantization error from the signal getting quantized. or, by adding triangular dither, that increases the quantization noise power by 4.77 dB and it decouples both the 1st and 2nd moments (the mean and the variance) of the quantization error from the signal getting quantized. if you do subtractive dither (which might be a good idea for 14 bits, that ain't a particularly wide fixed-point word), you can recover that 3.01 dB or 4.77 dB and reduce the energy of the quantization noise back to the level that it was before dithering. that is what subtractive dither is.
> And that didn't work. Any suggestion is very appreciated.
well, i dunno what you're trying to do. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Randy Yates <yates@digitalsignallabs.com> wrote:

(snip)
>> I have 14-bit A/D samples in FPGA and I want to perform dithering to >> eliminate harmonics. How can I do it?
>> I added the signal with Gaussian noise and did subtract dithering. And >> that didn't work. Any suggestion is very appreciated.
> Did you add the dither to the digital samples AFTER the A/D? That won't > work. You have to add analog dither to the analog signal BEFORE the ADC.
> Once you've quantized an undithered analog signal, you can't recover the > information you've lost.
Dithering can be useful if they are requantized. If, for example, you have 16 bits from the ADC, but only want to process 14, you can dither the low bits. If that is what you want, my favorite (which I do in software, not yet in an FPGA) is to use a CRC polynomial, and compute the running CRC from the data, then use bits of that for dithering. I never did any calculations to show that was good or bad, and the data I used it on probably has enough noise not to need it. -- glen
As others have pointed out, it's too late to add dither once you already have the samples. The only hope is that your harmonics are low order and constant with frequency, then you might be able to adaptively extract the coefficients of a power series that describes the non-linearity, and once you have these coefficients you could compensate for the distortion. 

 Not to be pessimistic, but this rarely works in practice because the sources of ADC non-linearity are seldom that simple or well-behaved. Also you may run into problems with aliased harmonics as the frequency increases.

Bob
Hi,

> Dithering can be useful if they are requantized. If, for example, you
have 16 bits from the ADC, but only want to process 14, you can dither the low bits.
> As others have pointed out, it's too late to add dither once you already
ha ve the samples. In other words, do your math in a higher precision, say, 16 bits. Then add dither, and round to 14 bits. All this happens before the ADC. And it is this reduction of bit width, not the AD conversion in itself, that causes correlated quantization noise. Compare the digital spectrum against the actual measured spectrum from the ADC output. If those two don't match, your "harmonics" are caused by other problems, for example ADC nonlinearity.
oops, A/D conversion, not D/A as assumed by my previous post. Please
disregard.


I am processing the samples from a 14-bit A/D converter in FPGA. What I am
thinking is to improve the signal quality around the noise floor by doing
digital dithering, which means after quantization.

In Matlab simulation, I can see that the dithering working if I do it
before quantization.
http://www.flickr.com/photos/90829131@N02/8250863216/in/photostream

But I do not see any improvement when I did the dithering in the digital
domain.
http://www.flickr.com/photos/90829131@N02/8250895890/in/photostream

I will try Glen's suggestion to re-quantize 14-bit to 12-bit.

Thank you all.

Billy

>On 12/5/12 8:42 PM, billy k wrote: >> >> I have 14-bit A/D samples in FPGA and I want to perform dithering to >> eliminate harmonics. How can I do it? >> > >are they already 14-bit samples or are you quantizing to 14 bits? once >you've already quantized those samples, it's pretty hard to get the >toothpaste back into the tube. adding wideband (bandlimited white) >noise won't do much to mask the bad harmonics except if they are at a >much lower amplitude than the signal you're interested in. might not do >anything useful. > >> I added the signal with Gaussian noise and did subtract dithering. > >how are you doing "subtractive dithering"? > >did these 14-bit samples come from another source (with wider words) >that was dithered and quantized? if so, and if you can synchronize the >RNG that generated the dither before quantizing to these particular >samples (and there *is* a way to do that with the LSB of the past N >quantized words), you can perform what we call in the audio industry >"subtractive dither". > >it's like this: adding rectangular dither increases the quantization >noise power by 3.01 dB but we do it to decouple the mean (the 1st >moment) quantization error from the signal getting quantized. or, by >adding triangular dither, that increases the quantization noise power by >4.77 dB and it decouples both the 1st and 2nd moments (the mean and the >variance) of the quantization error from the signal getting quantized. > >if you do subtractive dither (which might be a good idea for 14 bits, >that ain't a particularly wide fixed-point word), you can recover that >3.01 dB or 4.77 dB and reduce the energy of the quantization noise back >to the level that it was before dithering. that is what subtractive >dither is. > >> And that didn't work. Any suggestion is very appreciated. > >well, i dunno what you're trying to do. > > >-- > >r b-j rbj@audioimagination.com > >"Imagination is more important than knowledge." > > >