C
This code base on language C have the propose to get information about this sensor and display it.
First part that we need to write on our code is the libraries that we are going to use. In this case we are going to use
BCDS_BSP_Mic_AKU340.h
/************************************************************
* AcousticSensor.c
************************************************************/
/* system header files */
#include
/* additional interface header files */
#include "FreeRTOS.h"
#include "timers.h"
#include "KnowledgebaseAcousticSensor.h"
#include "BCDS_CmdProcessor.h"
#include "BCDS_Assert.h"Currently, the API does not provide a built-in function to convert these values from their byte representation into the representation of the output voltage of the AKU340 or the measured sound pressure. To calculate the sound pressure level, we use the next part of the code:
** First, the sound pressure to output voltage conversion ratio of the AKU340 is calculated using the math.c library into a linear value from its logarithmic data sheet specification. Afterwards, the ADC conversion ratio is calculated by with the maximal input voltage of the ADC and the 4096 representable states. Additionally the ratio is multiplied by 1000 for a presentation in milli volts.
Then, the function calcSoundPressure() is used to calculate the sound pressure representation in milli pascal by using the previous calculated conversion ratios for the ADC and the AKU340 and the passed measured raw value read from the acoustic sensor.
BSP_Mic_AKU340_Sense() is used and data can be read as follows from the acoustic sensor.
Finally we declared the main part of the program where we need to call all the function that we previously defined. Also define the timers.
Acoustic sensor requires a timer or operating task, which runs on a very short sampling period, such as 1 to 10 ms approximately to produce appropriate results, when measuring ambient noise.
Last updated
Was this helpful?