Go Down

Topic: How do i work out DC offset? (Read 144 times) previous topic - next topic

mrears92

My code (From the Arduino Cookbook) gets the input from my electret microphone and prints readings from 0-1023

The code assumes the DC offset is half (512).

Im using and Adafruit electret microphone with an AMP:

https://cdn-shop.adafruit.com/datasheets/CMA-4544PF-W.pdf
AMP - https://cdn-shop.adafruit.com/datasheets/MAX4465-MAX4469.pdf

Code: [Select]
"To do the calculation, we need to know what value to use for the DC offset. To get a clean signal, the amplifier circuit for the microphone will have been designed to have a DC offset as close as possible to the middle of the possible range of voltage so that the signal can get as big as possible without distorting. The code assumes this and uses the value 512 (right in the middle of the analog input range of 0 to 1,023)."

How do i calculate the real DC offset?

BigBobby

When the microphone is putting out 0V, read the A/D many times and average.  It should be ~512, but the actual number will be a little different.

mrears92

When the microphone is putting out 0V, read the A/D many times and average.  It should be ~512, but the actual number will be a little different.
I don't really understand what you mean, or how to do it. Could you please elaborate?

Thank you

LMI

#3
Apr 05, 2016, 04:37 pm Last Edit: Apr 05, 2016, 04:38 pm by LMI
There is a problem because for instance I am not sure about question.

If you do exactly as it is written in Maxim datasheet MAX4465-MAX4469.pdf you usetwo equal resistors and they'll give about half of the supply voltage to the output. I have used a Mega2560, it uses 5V supply and has 10bits AD converter. So the DC offset 5/2=2.5V is 512.

You can check yours. Connect your amplifier but leave out the mic. Or be absolutely quiet. Then use analogRead(pin) command (in a sketch). That gives you your DC offset. (Heh. You can connect the mic now)


123Splat

Short the Mic, Bias the amp until you read a consistent analog value around 512, disconnect the short on the mic.  That should compensate for any negative swing of the mic signal

DVDdoug

Quote
How do i calculate the real DC offset?
In other words, you don't calculate it, you measure it (by using the code from the Analog Read Serial example, etc.).

...If you calculate it, the answer is half of the ADC's maximum reading of 1023 = 511.5.    We know the ADC puts-out an integer value, so truncated that's 511 and rounded it's 512.   

LMI

#6
Apr 05, 2016, 09:39 pm Last Edit: Apr 05, 2016, 09:39 pm by LMI
In other words, you don't calculate it, you measure it (by using the code from the Analog Read Serial example, etc.).
That's it.

Of course, if you take an average of all your measurements, you should get the same result. Because the microphone gives only AC. It's average is zero, so only DC offset stays.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy