DSPRelated.com
Forums

Integrate PDM to PCM?

Started by Tom Becker October 13, 2016
spope33@speedymail.org (Steve Pope) writes:
> [...] > An IIR filter with an order at least one greater than the order > of the S-D modulator is the baseline choice.
That's what Bob said too. Where does this "one greater than the order of the S-D modulator" come from? -- Randy Yates, DSP/Embedded Firmware Developer Digital Signal Labs http://www.digitalsignallabs.com
On Mon, 17 Oct 2016 16:14:17 -0700, robert bristow-johnson wrote:

> On Thursday, October 13, 2016 at 3:11:39 PM UTC-4, Tim Wescott wrote: >> On Thu, 13 Oct 2016 09:03:48 -0700, Tom Becker wrote: >> >> > As a bat call recording enthusiast I'd like to use a pair of digital >> > MEMS elements whose ultrasonic performance appears to be well suited. >> > >> > The Knowles SPH0641LM4H-1 mic output is PDM and can run at 4.8MHz. I >> > want to stay in digital domain, ultimately recording 16-bit PCM at >> > 192kHz. Researching PDM-to-PCM conversion algorithms suggests >> > low-pass filtering. Analog's ADAU7002Z PDM to I2S converter might be >> > useful but appears to only produce 96kHz PCM. >> > >> > Can I, instead, integrate the 1-bit stream in a 16-bit counter, >> > incrementing or decrementing per each clocked PDM bit at 4.8MHz, and >> > latch the counter value at 192kHz? >> >> Sounds like a plan, except that there's a good chance of a DC bias >> that'll make your integrator run away. >> >> I'd put a DC-blocking algorithm in there someplace. If you're doing >> this in an FPGA it should be simplicity itself to do so; just remember >> that it's an IIR filter and therefor will need attention paid to data >> path widths. >> >> > and, given any finite word width, there should be error feedback to keep > it from limit cycling outputting DC. > > you know Tim, this thing: > https://groups.google.com/forum/?/comp.dsp/2QCyFGjGfxU/sRfVfvajbZAJ#!
searchin/comp.dsp/tim$27s$20better$20dc$20blocker%7Csort:relevance/ comp.dsp/OyUj74kMJWU/ojctmNuR3HwJ
> > r b-j
Assuming that guy is reliable, yes. -- www.wescottdesign.com
On Mon, 17 Oct 2016 20:06:17 -0400, Randy Yates wrote:

> Tim, > > First of all let me state that I think your idea (re: using an I2C and a > lookup table) is innovative. I give the approach an "A" for innovation. > But as I've touched on, some parts of the approach I don't think would > work out. I've one more comment below about this.
Granted, I was thinking harder about how to make it all fit in an ATMega. "Works poorly" is better than "never tried to make it work" -- yes?
>> >> One thing about an integrator-comb filter is that it nulls out the very >> frequencies that would alias down to DC, so it may not be that bad. > > That is true. > > If I'm looking at this right, a moving-average filter is going to be a > really crappy filter for decimation. The quantization noise from the > modulator, regardless of its specifics, is going to have significant > power at frequencies the MA won't filter out, so it would alias back to > baseband after decimation. I think.
One would have to know the noise characteristics. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com I'm looking for work -- see my website!
On Tuesday, October 18, 2016 at 11:30:12 AM UTC-4, Tim Wescott wrote:
> On Mon, 17 Oct 2016 16:14:17 -0700, robert bristow-johnson wrote: > > > On Thursday, October 13, 2016 at 3:11:39 PM UTC-4, Tim Wescott wrote: > >> On Thu, 13 Oct 2016 09:03:48 -0700, Tom Becker wrote: > >> > >> > As a bat call recording enthusiast I'd like to use a pair of digital > >> > MEMS elements whose ultrasonic performance appears to be well suited. > >> > > >> > The Knowles SPH0641LM4H-1 mic output is PDM and can run at 4.8MHz. I > >> > want to stay in digital domain, ultimately recording 16-bit PCM at > >> > 192kHz. Researching PDM-to-PCM conversion algorithms suggests > >> > low-pass filtering. Analog's ADAU7002Z PDM to I2S converter might be > >> > useful but appears to only produce 96kHz PCM. > >> > > >> > Can I, instead, integrate the 1-bit stream in a 16-bit counter, > >> > incrementing or decrementing per each clocked PDM bit at 4.8MHz, and > >> > latch the counter value at 192kHz? > >> > >> Sounds like a plan, except that there's a good chance of a DC bias > >> that'll make your integrator run away. > >> > >> I'd put a DC-blocking algorithm in there someplace. If you're doing > >> this in an FPGA it should be simplicity itself to do so; just remember > >> that it's an IIR filter and therefor will need attention paid to data > >> path widths. > >> > >> > > and, given any finite word width, there should be error feedback to keep > > it from limit cycling outputting DC. > > > > you know Tim, this thing: > > https://groups.google.com/forum/?/comp.dsp/2QCyFGjGfxU/sRfVfvajbZAJ#! > searchin/comp.dsp/tim$27s$20better$20dc$20blocker%7Csort:relevance/ > comp.dsp/OyUj74kMJWU/ojctmNuR3HwJ > >
this is a better link (to the original, mono-spaced ASCII post): https://groups.google.com/forum/?/comp.dsp/2QCyFGjGfxU/sRfVfvajbZAJ#!original/comp.dsp/OyUj74kMJWU/ojctmNuR3HwJ
> > Assuming that guy is reliable, yes. >
pretty reliable. looking at that post, i was skeptical at first but i analyzed it as i was writing the response. it is a valuable refinement to my "trick" and, in my opinion, your alg should be stated as the "canonical" form since it is equivalent to mine but has fewer instructions. r b-j
> One would have to know the noise characteristics.
I thought I'd seen some detail of the Knowles modulator, even spectrum, on their site but I can't find it now; I'm probably confusing it with Analog or InvenSense (who bought Analog's digital mic line). I've asked the regional Knowles rep if he can dig something up or, lacking that, if Knowles can recommend a demodulation scheme for ultrasonic service. Actually, maybe I should be looking at InvenSense mics instead. I don't see an ultrasonic mention yet, but "The complete ICS-52000 solution consists of a MEMS sensor, signal conditioning, an analog-to-digital converter, decimation and antialiasing filters..." sounds like the work is already done. https://www.invensense.com/wp-content/uploads/2016/10/DS-000121-ICS-52000-data-sheet-v1.1.pdf We'll see. Tom
A response from InvenSense:

"Our analog microphones are not characterized and specified to ultrasonic f=
requencies, but they do maintain good response with low noise out to well a=
bove 40 kHz. We have also released a digital PDM microphone (ICS-41352) wit=
h a response specified up to 85 kHz. This mic and the related documents sho=
uld be on our website soon."

Tom
Knowles sent a much more informative application note on the SPH0641LU4H-1 MEMS microphone, including the noise spectra to 80kHz at 4.8MHz.  The sigma-delta converter is 4th-order; its S/N at 80kHz is >100dB (pg 17).  I've posted it on Dropbox: https://dl.dropboxusercontent.com/u/91727438/Application%20Note%20Multi-Mode%20Digital%20Microphone%20SPH0641LU4H-1%20V1.1%20101314.pdf

This is encouraging and might let me off the hook somewhat, no?  I'm wondering if my original idea of a bidirectional counter integration (which the ATMega can do in hardware) might work, after all - although DC run-away might still be a problem.

Tom
On Wed, 19 Oct 2016 14:29:10 -0700, Tom Becker wrote:

> Knowles sent a much more informative application note on the > SPH0641LU4H-1 MEMS microphone, including the noise spectra to 80kHz at > 4.8MHz. The sigma-delta converter is 4th-order; its S/N at 80kHz is > >100dB (pg 17). I've posted it on Dropbox: > https://dl.dropboxusercontent.com/u/91727438/Application%20Note%20Multi-
Mode%20Digital%20Microphone%20SPH0641LU4H-1%20V1.1%20101314.pdf
> > This is encouraging and might let me off the hook somewhat, no?
Somewhat. I get about -76dBfs worth of noise total, mostly at the high frequencies. You'll have hiss, for sure.
> I'm > wondering if my original idea of a bidirectional counter integration > (which the ATMega can do in hardware) might work, after all - although > DC run-away might still be a problem.
You really need something that has a downward slope with frequency that matches the 24dB/octave rise of the noise. An integrator will give you 6dB/octave, across all frequencies, and it has that problem of low- frequency run-away. You really need a 4-th or 5-th order filter, with a cutoff as low as you can put it while still hearing the Bat Tone. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com I'm looking for work -- see my website!
Tim Wescott <tim@seemywebsite.really> writes:

> On Fri, 14 Oct 2016 23:09:51 -0400, Randy Yates wrote: > >> Tim Wescott <seemywebsite@myfooter.really> writes: >> >>> On Thu, 13 Oct 2016 21:20:10 -0700, Tom Becker wrote: >>> >>>>> ... set up an SPI port to clock at 4.8MHz [] then you have a look up >>>>> table: >>>>> 0 has 0 bits on, >>>>> 1 has 1 bit on, >>>>> 2 has 1 bit on, >>>>> 3 has 2 bits on, >>>>> etc. >>>>> The output of that table gets 4 subtracted from it... >>>> >>>> Ah. So eight bits (0-255) @4.8MHz becomes three bits (0-7) @600kHz, >>>> offset by -4 makes it bipolar? So now I have 3-bit PCM @600kHz? How >>>> do I get from there to 16-bit @192kHz? >>>> >>>> Tom >>> >>> Low-pass filter. >> >> And resample. It's not a simple decimation either. >> >> You also will have an unwanted sync in the spectrum due to the >> disjointed 8-bit "integration." > > That kinda depends on the noise characteristics going into the > integration (AND I DON'T THINK IT NEEDS THE QUOTES).
(emphasis mine) I wanted to get back and address this one more thing, Tim. Why not, i.e., why not the quotes? What you've described (i.e., counting the number of bits over an 8-sample interval) looks to me like a moving average filter followed by decimation. This is not an integrator. The z-transform (before decimation) is not H(z) = z / (z - 1)! -- Randy Yates, DSP/Embedded Firmware Developer Digital Signal Labs http://www.digitalsignallabs.com
Tom Becker <gtbecker@rightime.com> writes:

> Knowles sent a much more informative application note on the > SPH0641LU4H-1 MEMS microphone, including the noise spectra to 80kHz at > 4.8MHz. The sigma-delta converter is 4th-order; its S/N at 80kHz is >>100dB (pg 17). I've posted it on Dropbox: > https://dl.dropboxusercontent.com/u/91727438/Application%20Note%20Multi-Mode%20Digital%20Microphone%20SPH0641LU4H-1%20V1.1%20101314.pdf > > This is encouraging and might let me off the hook somewhat, no? I'm > wondering if my original idea of a bidirectional counter integration > (which the ATMega can do in hardware) might work, after all - although > DC run-away might still be a problem.
Tom, If your goal is to get a high resolution output, e.g., something on the order of 16 bits or greater at an 80 kHz bandwidth, I don't think you're even close. You're so far off that I wonder if you really understand the situation. Their spectral plot on p.17 is, as you've noted, is to 80 kHz. However, the undecimated sample rate is 4.8 MHz, which means you'll have frequency components all the way up to 2.4 MHz. That's a lot of frequency "area" that is unspecified. And if the part operates like a typical delta-sigma modulator, there's going to be a LOT of quantization noise power that's shaped into the upper area of the undecimated spectrum, WAY above 80 kHz for a 4.8 MHz sample rate. That's how these parts work. Now I haven't gone to the trouble to make an estimate of the total quantization noise power in the 80 kHz bandwidth they did specify, but it seems to me if you put a crappy moving average filter as your first filter and then decimate by 8, you are going to alias most of the quantization noise back into the decimated signal. Perhaps even most of it. So if the analog A/D is 1-bit, your resulting decimating signal is going to be awful. And no amount of subsequent filtering will remove it. -- Randy Yates, DSP/Embedded Firmware Developer Digital Signal Labs http://www.digitalsignallabs.com