Go Down

Topic: Microphone question (Read 1 time) previous topic - next topic

maverick2411

So I have made a microhpone amplifier by myself for Arduino like this
http://www.learningaboutelectronics.com/Articles/Arduino-microphone-circuit.php


When I connect it and start serial record and completely loose potentiometer it registers values that range mostly 400-500 to 1023, so I'm curious how can I atleast roughly calculate decibels? Without actual SPL meter.
This is a mic http://www.tme.eu/hr/details/ld-mc-9765w/mikrofoni-i-slushalice/loudity/

Paul_KD7HB

So I have made a microhpone amplifier by myself for Arduino like this
http://www.learningaboutelectronics.com/Articles/Arduino-microphone-circuit.php


When I connect it and start serial record and completely loose potentiometer it registers values that range mostly 400-500 to 1023, so I'm curious how can I atleast roughly calculate decibels? Without actual SPL meter.
This is a mic http://www.tme.eu/hr/details/ld-mc-9765w/mikrofoni-i-slushalice/loudity/
You really need to read again, the text in the first link you gave. It specifically states "This circuit is only capable of detecting whether there is sound in the environment or not. ". It nowhere states you can measure the sound level or anything else about the sound.

Paul

maverick2411

But these and similar kinds of circuits can be bought in stores, I don't see why couldn't I measure sound levels. When I actually can, and I am using VU meter that shows that. ??

Paul_KD7HB

But these and similar kinds of circuits can be bought in stores, I don't see why couldn't I measure sound levels. When I actually can, and I am using VU meter that shows that. ??
Because DB measurement is logarithmic and the circuit you show is linear. I suppose, with calibration, the Arduino could compute the DB of the relative voltage over a small range.

Paul

maverick2411

Because DB measurement is logarithmic and the circuit you show is linear. I suppose, with calibration, the Arduino could compute the DB of the relative voltage over a small range.

Paul
How to do that?

Wawa

#5
Apr 20, 2017, 01:23 am Last Edit: Apr 20, 2017, 01:29 am by Wawa
This article basically tells you how to connect the output of a power (op)amp to an arduino pin.
I wonder how long the input pin will survive that.

Replace the 100uF output cap for a 10k resistor.
That will give you pin protection, and adds ~2.5volt bias to the pin.
Assuming you power the circuit from Arduino's 5volt rail.

The code in the article is very basic. I would use double (positive and negative) peak detection in my software.
And yes, dynamic range will be very small.
Leo..

Paul_KD7HB


maverick2411

#7
Apr 20, 2017, 03:33 pm Last Edit: Apr 20, 2017, 03:41 pm by maverick2411
This article basically tells you how to connect the output of a power (op)amp to an arduino pin.
I wonder how long the input pin will survive that.

Replace the 100uF output cap for a 10k resistor.
That will give you pin protection, and adds ~2.5volt bias to the pin.
Assuming you power the circuit from Arduino's 5volt rail.

The code in the article is very basic. I would use double (positive and negative) peak detection in my software.
And yes, dynamic range will be very small.
Leo..
I power it from 6v battery :D Forget the code, I don't use that code. I need somehow calculate atleast roughly as I said dB from what my microphone can read ...

maverick2411

Hello guys I suppose somebody here could tell me, what does it actually mean if my microphone has -38dB sensitivity and if I get some digital values that range 0-1023 (my mic does'nt recognize anything below 400), can I actually calculate decibels change and what is the referent point for my measuremnts? like decibel point where decibels change their amplitude.... I have this amplifier

DVDdoug

#9
Apr 22, 2017, 10:36 pm Last Edit: Apr 22, 2017, 10:41 pm by DVDdoug
WARNING - Your microphone amplifier puts-out an AC audio signal (it goes positive and negative).  The Arduino can be damaged by negative voltages!

Quote
Hello guys I suppose somebody here could tell me, what does it actually mean if my microphone has -38dB sensitivity
It's an incomplete spec and I don't know what it means.

Decibels need a reference.   SPL (acoustic Sound Pressure Level) is always positive, and the 0dB SPL reference is (approximately) the quietest sound that can be heard.

dBV is one of the electrical measures where 0dBV is one volt.   -38dBV is about 12.6 millivolts.   But, without knowing what SPL level gives you an electrical signal of -38dBV, it's useless.  dBV can be negative or positive, but it's usually negative.

db VU is another (older) electrical-audio dB reference.   Most modern "VU meters" are not true VU meters.

Digital levels are measured  in dBFS (decibels full scale) where 0dB is the "biggest number" a 16-bit or 24-bit (etc.) integer can hold, or 0dBFS is 1.0 when using floating-point numbers.    In integer formats, dBFS can never go positive.   With floating-point it can got positive, but it's usually negative.

Quote
and if I get some digital values that range 0-1023 (my mic does'nt recognize anything below 400)
Are you saying you're not getting any readings less than 400?    That's because the Arduino's input is "floating".    A 1K - 10K resistor between the Arduino's analog input and ground will "pull down" the input to zero when there's no signal from the amplifier.

But WAIT -  Replace C4 with a wire, or a ~1K resistor, or just "short out" the capacitor.    Without the capacitor the amplifier's output (and the Arduino's input) will be "biased" at about 2.5V (half the amplifier's supply voltage).    That will prevent the signal from going negative (and you won't need the other resistor to ground)

With the 2.5V bias, silence should read about 512 and you can subtract that out in software.  

Quote
can I actually calculate decibels change
dB change is calculated as 20 x log(A/Aref) where A is amplitude (voltage or your ADC reading, etc.).

For example, if your reference reads 100 and your new reading is 200, that's a  +6dB change.    And, if you happen to know that 100* corresponds to 70dB SPL, that means 200 is 76dB SPL   And, 50 would be 6dB less than the reference or 64dB SPL.

Quote
and what is the referent point for my measuremnts? like decibel point where decibels change their amplitude.... I have this amplifier
If you want to read dB SPL, you'll need a real SPL meter to calibrate the one you're building.

COMPLICATIONS - You are sampling an audio waveform and even a constant tone or sine wave will give you "random looking" readings.   You'll need to find the peaks, or find the average or RMS.  (Note that the average of a sine wave is zero, so you need to average the absolute values.)   Normal audio is even more "random like".

SPL measurements are even more complicated and if that's what you're trying to do, search the forum for "SPL".







* With a biased input, you'll need to subtract the bias before making any calculations.

maverick2411

#10
Apr 22, 2017, 11:11 pm Last Edit: Apr 22, 2017, 11:23 pm by maverick2411
Thank you finally someone took time and answered me. So I here are full specs of microphone
http://www.tme.eu/en/Document/ded0e1bb90e4cffc97cd4d292bdf15d4/LD-MC-9765W_DTE.pdf

Ok before anything I use 6V, cause it says I can use 4 AA batteries, so the amplitude would be 6V and 0V of that sin wave and 3V would be zero-point?

So basically if I remove that C4 i SHOULDN'T get reading lower than 512? And when I make some noise my serial reading should go above 512? Or lower than it or both of it? I'm gonna try tommorow i have PCB so I need to dissolve it.
Also found this helpful page
https://electronics.stackexchange.com/questions/96205/how-to-convert-volts-in-db-spl

Grumpy_Mike

Quote
so the amplitude would be 6V and 0V
And would be too much to feed into an Arduino without damaging it.

Quote
So basically if I remove that C4 i SHOULDN'T get reading lower than 512?
No he never said that. Please read the post again and ask specifically about things you don't understand about the answer.

Quote
i have PCB so I need to dissolve it.
Well that is a solution then.   ;)

maverick2411

So my microphone sensitivity is -38dB +- 2dB at 0dB=1 V/Pa
My unit gain is 200, i put 4.7 k resitor instead C4. I get values from 610-620 to 1023. I use 6 V for amplifier circuit but Arduino only reads 5V , so my working range is 3V  to 5V.

How to calculate decibels from that ?

Grumpy_Mike

Quote
I get values from 610-620 to 1023.
Then the circuit is not working correctly. You should get values above and below the no signal point.
Connect a 10K from pin 2 to ground of your LM386, and also connect another 10K between pin 2 and 5V. This will bias the amplifier in the middle of the rail.

DVDdoug

#14
Apr 23, 2017, 06:47 pm Last Edit: Apr 24, 2017, 04:49 pm by DVDdoug
NOTES:
- Please search the forum for "SPL".    Like I said, there are lots of complications (including averaging and frequency weighting).    You can make something like an SPL meter but it's difficult to make an accurate one.   And, if you need accuracy your meter has  to be calibrated with a known sound level, which means you need an SPL meter to make an SPL meter.

-  I'm making lots of calculations and I may make a mistake or two.    Please double-check all of my calculations!  - You might want to set up a spreadsheet.

EDIT - I just found one mistake that propagated to more errors, and I corrected it....  But there could be more...

Quote
I get values from 610-620 to 1023.
With silence "biased" at 3V, you should read about 613 (1023 x (3/5) ).    So 610-620 is just about perfect with no sound (allowing for some background noise).

Turn-down the amplifier's volume/gain control before reading silence.

I hope you're getting some lower readings too...    Ideally with a "loud" signal, the voltage should swing between zero and +6V (covering the full ADC range from 0-1023).    The amp probably won't go down to zero but with a 6V supply, you're reading 1023 so you're obviously hitting 5V.

Subtract the bias before making any dB calculations!


Quote
So my microphone sensitivity is -38dB +- 2dB at 0dB=1 V/Pa
It's hard to make sense out of that....   1Pa is 94dB SPL,     I'm pretty sure you can't get 1V out of the mic without amplification.

Maybe they are saying -38dBV -(38dB relative to 1V) at 94dB SPL.   I already calculated that as 12.6mV.   That's an RMS AC voltage, so about 17.5mV peak at 94dB SPL.

A gain of 200 gives you 3.5V which means your amplifier is clipping (maxed out) at 94dB SPL (with the volume/gain control turned-up all the way).     But, we can still use 94dB SPL = 3.5V as a reference for our dB calculations.    

If the ADC were able to read above 512 (after subtracting the bias), 3.5V, it would read 716 (1023 x 3.5/5).  We can use 94dB SPL = 716 as our reference.   (You can re-calculate a new reference of 100dB or 0dB if you want to simplify your sketch.)

Just to make things "easy", let's say you get a reading of 100 (after subtracting the bias).   20log (100/716) = -17dB (relative to 94dB SPL)   Subtract and we get 77dB SPL.

The formula in your Arduino sketch would be SPL = 94 - (20 * log (x/716)).     Where x is the peak analog reading after subtracting the bias.    

Corrected - The formula in your Arduino sketch would be SPL = 94 + (20 * log (x/716)).

With the bias reading 613 the maximum 9adjusted) reading is 410 for a maximum SPL of 89dB SPL.  (Any louder than that, and you'll just get 89dB.)



Go Up