, , , , ,

This post demonstrates the SPL meter described earlier running in an NXP LPC810 ARM CORTEX-M0+ microprocessor. The computed SPL level is output as an analog signal and displayed on the meter movement.

Here is a short video showing its reaction to a bike horn. Watch the meter and LED when I honk the horn.

This is part of a series of articles on the general subject of audio signal processing from air to information. Previous installments include:

What really happened

As described in the previous post, the microphone is clocked by the SPI peripheral in master mode, which is also reading the PDM bit stream it produces. It polls for the 16-bit shift register to fill, then runs the filters to form a PCM sample. As samples become available, they are included in the current SPL window.

When the SPL window is filled, the SPL is computed from the sum of absolute sample values using our fast piece-wise linear approximation to 8*log2(). The SPL is scaled to control a PWM output (implemented with the SCT peripheral) so that dead silent is modulated at 0% and louder than possible at 100%. Every 20th finished SPL value is also printed, in the 8*log2() scale, along with the mean sample value of the window which shows the magnitude of the DC offset inherent in the PDM data stream from the microphone.

Since the CPU is running on 3.3V, the modulation ranges from 0V to 3.3V max. In practice, the loudest measurable SPL value is 120 dB(SPL), displayed as 206 out of 255, 80.8% PWM, or 2.7V.

Source Code

The source code for this demonstration has been added to the fossil repository. As of this post, it is in the form of a ZIP file exported from the LPCxpresso IDE, suitable for directly importing into your IDE workspace.

To get a copy, use this finely crafted link to download the zip directly from the public repository.

You can also clone the whole repository yourself and look in the folder named zips for LPC810_PDM_Demo.zip, which will give you the source kit to the ATTiny85 version of the demo as well.

Once you have LPC810_PDM_Demo.zip, launch LPCxpresso and let it open your workspace. In its Quickstart Panel, click “Import project(s)”, and then browse to your zip file. That should unzip the file into your workspace and make the project available to build and modify.

(Written with StackEdit.)