Community news, upcoming events and general discussions
Threads: 34 Posts: 86
Get technical support from the community
Threads: 1351 Posts: 7325
Threads: 18 Posts: 64
Tell us how to make XDK better!
Threads: 35 Posts: 117
Share and discuss community member projects
Threads: 76 Posts: 337
is there an idea of time (in one, two month or end of year), when the acoustic sensor can be used?
Hi Hermann, as Mathias already said, the sensor can be used via ADC. For the XDK-framework implementation we have no release date yet. But I will keep you posted in this thread, if I know more. Kind regards, Manuel
is there a small tutorial how to read data via ADC from the Acoustic sensor and write the data as a CSV file on the SD-card?
I wrote some example code how to access the acoustic sensor via the ADC. You will have to initialize the ADC with the following code lines:
// Sets the supply voltage for the acoustic sensor
ADC_Init_TypeDef init = ADC_INIT_DEFAULT;
data.adcFreq = 7000000;
data.registerBaseAddress = ADC0;
data.cmuClk = cmuClock_ADC0;
data.init = init;
Including to this an implemention to read the data has to be done. The code below shows how to implement it:
ADC_singleAcq_t result = ADC_SINGLE_ACQ_DEFAULT;
// ADC single sample channel 4
result.adcChannel = adcSingleInpCh4;
result.initSingle.acqTime = adcAcqTime16;
printf("ADC Acoustic Voltage: %lu mV\n\r", (unsigned long) ADC_scaleAdcValue(&result));
In reference to the user guide the input pin for the acoustic sensor should be the pin PD4 and this pin is read by the ADC0 channel 4.
For the implementation of the SDcard, please refer to the SdCardExample and the XdkDataloggerDemo.
Please don't hesitate to ask if you have further questions.
Kind regards, Franjo
Thanks Franjo for the code!
I realised that I also need the following line to turn on the sensor during initialization:
welcome to the XDK community. Yes you are correct to set the supply voltage for the acoustic sensor. Thanks for sharing your improved implementation. I will add this to the implementation I posted before.
I wonder if the ADC's sampling rate should follow the Nyquist frequency. For example, if I want to detect all audible sounds I should set the sampling rate to at least 40KHz? (maybe 44.1KHz like CDs?)
I also wonder if increasing the sampling duration (by reducing the ADC clock or increasing adcAcqTime16 to adcAcqTime256) improves the accuracy of the acoustic sensor.
I needed to loop every 10ms or lower to get an accurate reading, otherwise the sensor will be inactive for too long to detect environmental sounds. (It may end up turning on during the gaps between the sounds, for example.)
in general you should use a sampling frequency that is two times higher then the highest signal frequency to receive all information from the signal source without any information loss, but sampling frequencies usually are much higher, sometimes even ten to twenty times higher then the signal frequency. 44.1 kHz should be okay to sample all audible sounds. I recommend to use an even higher sampling frequency.
Furthermore an increase of the sampling duration would have the opposite effect, because you are coverting an analog signal into a digital signal. This results in a really low accuracy. To receive a high accuracy you need a very short sampling duration.
Please note that the sampling rate is the inverse of the sampling duration and an other expression for the sampling frequency.
Therefore I suggest to use for your use case a sampling frequency that is much higher then the double signal frequency of the acoustic sensor.
I hope this could help you.
I've implemented the AKU340 using the code you posted. However I seem to be getting the same readings no matter the conditions eg. construction site, traffic, workshop, office.
How do I make it more sensitive?
my code example in this thread demonstrates only how to implement a functionality which accesses the acoustic sensor AKU340 via the ADC.
The example code contains no complete implementation for each application. In other words, I only shows how to access the AKU340 and not how to interpret the data. A complete implementation would require an additional timer task which measures the ADC data frequently and interprets the single measurements of the AKU340 to usable data like the root mean square value.
Fortunately another user had the same issue some time ago. Thus I recommend to take a look at this thread to get familiar with interpreting the AKU340 data.
Please note that this is only one possibility suggested by me.
Please tell me if this is helpful and do not hesitate to ask if you have further questions.
Thank you for your assistance.
I am now trying to conver the output voltage to db.
Am I correct to assume that input voltage is 2v as per the AKU340 datasheet?
I've also implemented a timer to sample readings every 2ms. However, my readings are still very small, around 3-5mV. And when converted to db, I get around -50 to -60db.
Do you know what is the reference db level?
I am using this formula:
db gain = 20 log10(Vout/Vin)
where Vout is the reading from the acoustic sensor.
I am glad to help.
Furthermore the code I provided works exactly with the kind of timer task you use. Thus it should deliver output voltages as root mean square values in a range up to 700mV. From my point of view, the input signal is classified as sound pressure and not as an input voltage that you are using to calculate the amplification.
Would you be so kind and tell me why are you referring to 2V as input voltage?
Additionally would you be so kind and tell me the goal of your implementation?
Do you want to calculate the amplification of the sensor itself or the former sound level?
Please tell me if this was helpful and do not hesitate to ask if you have further questions.
I got the 2V from the AKU340 data sheet which states the input range is 1.8-3.6V.
I am trying to measure the sound level.
Please advise on what is the right way to go about it.
Thanks again for your assistance!
I did a bit more reading and would like to know if this makes sense.
According to the AKU340 data sheet:
Sensitivity (TYP) = -38dbV/Pa [@ 94db SPL, 1kHz]
That gives a transfer factor of 12.5893mV/Pa.
i.e. 1 Pa or 94db will produce 12.5893mV
Therefore 1mv = 7.705db
Does this make sense?
I reviewed the data sheet very detailed once again and have to correct myself. I found the corresponding reference value for the sound pressure in the section 12.4. It is 20µPa for 1 kHz. This reference value for 94 db is equal to a sound pressure level 1 Pa. I am not quite sure about the results of your mentioned equation to estimate the transfer factor (amplifying factor). Am I right that you estimated the transfer factor for the sensitivity with 1Pa as reference value? If that is correct, you received the sensitivity between 2 measured values. Further 1Pa (referring to 94 dB) will not produce 12.5893mV as output, but a much larger value. To receive results that fits your purpose to estimate the transfer factor for 1mV, I recommend to estimate the correct output voltage for 1Pa reference sound pressure and then continue with following calculations.
Meanwhile I checked you mentioned voltage range between 1.8-3.6V. This specified ranged describes the variability of the supply voltage of the AKU340. In other words it explains which amount of supply voltage can be used for the acoustic sensor to be fully operational. Thus you can not use it in any kind to make predictions about the sound pressure level neither the transfer factor of the AKU340.
I hope my explanations are helpful. Please do not hesitate to ask if you have further questions.
Further 1Pa (referring to 94 dB) will not produce 12.5893mV as output, but a much larger value.
How much will 1Pa produce then?
How much dB will produce 1mV?
I got my transfer value by calculating and checking it against a couple of online resources.
Is my trasnfer value wrong?
I assume we need to clarify the meanings of different parameter since this resulted in a kind of confusion. Following I am going to clarify all of them:
First of all, the sound pressure level (SPL) describes the pressure p of an incoming soundwave in relation to the least hearable soundpressure p0 which is 20 µPa. Further 94dB SPL describe the relation between the sound pressure of 1 Pa and p0.
The sensitivity of the acoustic sensor is constant and describes the transfer factor measured by 1 Pa input sound pressure. You are correct to assume 12.6 mV output voltage by 1 Pa input sound pressure related to the -38dB V/Pa transfer factor.
Furthermore if you want to estimate environmental sound pressure level, you will have to estimate the input sound pressure first, and then make an estimation of the sound pressure level via p0. Thus the sound pressure level for 12.6 mV is not 7.705 dB, but 71.97 dB. Keep in mind that the sound pressure level is estimated logarithmic and therefore such an huge value is realistic in relation to your calculation.
Additionally please note that the examinations only rely to the amplitude of the measured sound wave and do not deal with the frequencies within the soundwave.