[PIC] How to calculate dB in PIC?

Status
Not open for further replies.

helmi_mjd

Member level 2
Joined
Feb 20, 2011
Messages
45
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Visit site
Activity points
1,668
Hi!
My project is about how to determine decibel (dB) level of an audio. If this dB level passing the threshold value, other operation will be triggered. I would like to know, is it possible to calculate dB value from ADC value directly? If yes how to do it? If no how can i do it? I'm using dsPIC30F and c30 compiler. Please help me.

Thank you.
 

Hello!

Instead of doing your homework, let's think together:

Physically, how is dB defined?
Once you get the definition, you will probably understand at once how to do.

Dora.
 

You are measuring DB of audio Then 1st you need audio to electrical transducer like Capaciter mike etc.
Now you have DB in electrical form then adc can measure it and with the help of google you can calibrate it.
 

Hello!

Instead of doing your homework, let's think together:

Physically, how is dB defined?
Once you get the definition, you will probably understand at once how to do.

Dora.

Thanks for your reply.
We know commonly dB is defined as:
dB = 10log(P1/P0) where (P1/P0) is power ratio. And if taking voltage as an example, we have dB = 20log(V1/V0). Now we know we can use ADC to convert voltage, is it correct to defined dB = 20log(m/2^N) where m is the ADC value and N is ADC resolution (eg. 12 bit)?
 

Now we know we can use ADC to convert voltage, is it correct to defined dB = 20log(m/2^N) where m is the ADC value and N is ADC resolution (eg. 12 bit)?
Won't be correct if it doesn't accidentally match the correct reference level. For audio applications, you are usually measuring dBm, which is dB relative to 1 mW into 600 ohm, respectively 0.775 Veff. So there will be a scaling factor reflecting the measurement circuit gain and ADC reference voltage.

Furthermore, how do you convert the audio signal (AC voltage) to ADC input? There should be a precision rectifier and a filter circuit with defined characteristic, e.g. peak hold with slow decay (VU meter).
 

Furthermore, how do you convert the audio signal (AC voltage) to ADC input? There should be a precision rectifier and a filter circuit with defined characteristic, e.g. peak hold with slow decay (VU meter).

Thanks for your reply FvM. Actually i refer to some other article, for example from this website:
http://http://www.eeherald.com/section/design-guide/esmod19.html

So, this is not true? Sincerely I'm not good in signal processing and I'm looking for idea to solve this problem.:smile:
 

The article is referring to the case that the ADC samples the audio data at full bandwidth, e.g. 44 kS/s as usual for CD audio. PIC30 can basically do this, but the software is more involved than with an external rectifier. The absolute value and peak or average level calculation has to performed at full sample rate.
 

The article is referring to the case that the ADC samples the audio data at full bandwidth, e.g. 44 kS/s as usual for CD audio. PIC30 can basically do this, but the software is more involved than with an external rectifier.

Thanks again for your reply. Actually I'm using dsPIC30F to do this task. Basically my project is similar to the one shown in the figure in the article except microphone is replaced by the hydrophone (eg. underwater microphone).

The absolute value and peak or average level calculation has to performed at full sample rate.

Sorry, I'm not understand this part. Do you mean I have to absolute value, peak/average value of the signal? Then, is it possible for me to calculate dB value from this operation?
 

Do you mean I have to absolute value, peak/average value of the signal? Then, is it possible for me to calculate dB value from this operation?
A dB level can't be assigned to the instantaneous value of an AC signal. E.g. because it's undefined for negative values. The required operation depends on your application. It might be effective value, average rectified value, peak value.
 

E.g. because it's undefined for negative values. The required operation depends on your application. It might be effective value, average rectified value, peak value.

Hi FvM, I have made some further research and I found the following circuit from microchip. Is this circuit what you mean by the above statement?

 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…