Issue with PDB and sampling avg ADC?

Status
Not open for further replies.

uuryuu

Member
Hello,

Im using the teensy 3.5. I have successfully been able to use the ADC and PDB together, by setting the PDB to 100kHz. Using my Func.Generator, I fed a 1khz sinewave into my ADC input.

HTML:
 adc->adc0->stopPDB();
  adc->adc0->startPDB(100000);

And then tested output of ADC and used my oscilloscope by toggling a digital pin high/low in the adc_isr() and I do get a 100khz samplerate.Awesome!!!
I also saved this data to a SD card to look at in matlab,and if I feed a 1kHz sinewave with a ADC samplerate of 100kHz, I should see 100 samples per sinewave. And I do!Great!

But I decided to trying using the setAveraging() to see how smooth I could get the sinewave:

HTML:
adc->adc0->setAveraging(2);

Now I thought if I average every 2 samples at 100kHz I should have a 50kHz samplerate,but I dont,I still have a samplerate of 100kHz.Using the methods above to test samplerate.
And dont get me wrong the signals are smoother,but im just wondering whats happening here? By setting the setAverage(2) just make the duration longer???
Kinda lost.

And ive also tried setting averaging from {2,3,4,5}
 
It tries to produce the derived sample rate that you specified (100,000), no matter how much averaging you do. In your example, 200,000 samples/sec need to be taken which is then reduced to 100,000 derived samples. Be careful about exceeding what is possible.
 
It tries to produce the derived sample rate that you specified (100,000), no matter how much averaging you do. In your example, 200,000 samples/sec need to be taken which is then reduced to 100,000 derived samples. Be careful about exceeding what is possible.

Thanks for the reply.

But just so im clear about what your saying: from my example

-ADC is set to 100kHz using PDB
-averaging is set to 2 (averages every 2 samples)
-I need to acquire 200,00 samples to have a correct 100khz samplerate,since the PDB will do what it takes to stay at a 100khz samplerate?

And apologies, im still reading the datasheet and the arduino libraries made for it......This just made me scratch my head.
I started with just averaging set to 1,and used my USB to power board and noticed my sinewaves were mehh.(used function gen. as input)
Then I tried using a external battery,and signals were better but still meh...(used function gen. as input)
So I tried averaging,noisey sinewave is blehhh.
 
> I need to acquire 200,00 samples to have a correct 100khz samplerate

I'd word it as "the setting and library will cause the ADC to acquire 200,000 samples/sec to produce the correct output rate of 100,000 derived samples/sec".

Best if you consider the averaging setting a minor noise reduction setting and forget about any effect it has on sample rate - it's transparent to you (until you exceed a speed limit).
 
Status
Not open for further replies.
Back
Top