View Full Version : PWM Source to ADC Input

capricorn one
06-08-2016, 11:12 PM
Curious if anyone has a working solution for this:

I have a 16-bit PWM audio source coming from a display unit (unfilitered) and I want to plug it into the ADC input of the teensy using the AudioInputAnalog object of the Audio library. My source is a 3.3V PWM waveform coming from a 74LVC1G08 driver chip. There's a circuit example for converting PWM to Line Out as well as a circuit for Line In to ADC for the teensy, so I could obviously put the two together to achieve what I want. I'm just wondering if I can get away with less components, seems like some of them (10uF i.e.) will be redundant.

06-08-2016, 11:31 PM
Another, perhaps more efficient approach could be to feed the PWM directly into a digital pin of the teensy and using the newest improved FreqMeasureMulti library v0.22 (don't let you fool by the name, it allows really to capture each single pulse and the pauses in-between with a 20.48ns resolution) to get the digital values back without losing quality by first converting the PWM to analog and then analog to digital.

capricorn one
06-08-2016, 11:37 PM
Yeah, I agree, that would be more efficient and elegant and somewhat lossless, but it's not supported in the Audio library as far as I know? Unless someone has already written an object to handle this, I suppose it would be pretty straight forward.

06-09-2016, 02:50 PM
I'm curious what sends a 16 bit PWM audio signal? What frequency does it use?

06-09-2016, 03:36 PM
That's an excellent question. Having 16bit audio PWM at 44100 samples/s would require a pulse clock of about 2.9GHz...

capricorn one
06-10-2016, 07:36 AM
Hmm... good point about the clock, I'm basing it off of what the webpage says here for the Diablo processor which drives some of the 4D systems displays. See here :


It does say on the website 16-bit PWM audio, but I agree, after thinking about this, maybe that's not really 16 bit? Or maybe since it's a GPU it's capable of doing that somehow?

Also, I realize on most of the displays, this audio output is filtered to analog, but I'm using the pin output, which has no filtering.

Oh, and the for the frequency, you can actually set that as one of the internal functions from 4k to 65k, according to this :


see Snd_Pitch(pitch) function.

06-12-2016, 01:37 PM
Out of curiosity, I did a little searching. I found this thread.


Looks like the this chip's PWM audio output is probably only 8 bits. Sure, their marketing info says it's 16 bits, but that's really not technically feasible (for a variety of reasons). I'd put a lot more trust in the support reply #2 on that thread, admitting it's only 8 bits and low quality. Reply #10 is also interesting, getting a bit defensive when pressed for technical details, but admitting "if you use a 16bit file only the high 8 bits will be used" seems to sum things up nicely.

I'm sure they probably have some twisted logic for claiming it's 16 bits. Perhaps supporting 16 bit WAV files (by discarding the low 8 bits) makes it 16 bits?

capricorn one
06-12-2016, 09:48 PM
Wow, thanks for finding that Paul!

Going to have to make some changes to my design in that case, 8 bits definitely won't do. Should have known that was too good to be true, thanks for doing the digging.