Go Down

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

#### mrears92

##### Apr 05, 2016, 03:44 pm
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:

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

#1
##### Apr 05, 2016, 04:00 pm
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

#2
##### Apr 05, 2016, 04:10 pm
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

#### LMI1

#3
##### Apr 05, 2016, 04:37 pmLast 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

#4
##### Apr 05, 2016, 04:46 pm
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

#5
##### Apr 05, 2016, 05:18 pm
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.

#### LMI1

#6
##### Apr 05, 2016, 09:39 pmLast 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