"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)."
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.
I don't really understand what you mean, or how to do it. Could you please elaborate?
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)
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
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.
DVDdoug:
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.