 Hello and welcome to this introduction to microphones. In this video I'm going to cover the details of the PDM to PCM conversion. PDM to PCM conversion is the set of processes and methods involved in the conversion of a single bit PDM output to a standard digital signal in PCM format. Several steps are involved in the process. We have a low pass filter, a decimation phase, a high pass filter for DC offset removal, and finally a gain stage. We will go in deep in each one of the involved steps to see why it's required and will give a general idea on how it can be implemented. A low pass filter is a filter that passes signals with a frequency lower than a selected cutoff frequency and attenuates signals with frequencies higher than the cutoff frequency. The low pass filter is required in PDM to PCM conversion to remove the high frequency noise, which characterize the PDM output and it's used also to avoid aliasing and noise in the resulting PCM. Since we are dealing with digital signals, we are going to use a digital filter for this stage and specifically a finite impulse response filter or FIR. You can think at the operation of FIR filtering as a moving average. Each output sample is computed as an average of the last and input samples. So this is the first sample, the second sample, the third sample and so on and so forth. The main difference with averaging is that the input samples are not weighted equally as it would be with a simple average. But specific coefficients are used to weight each input sample used. The FIR filter then can be thought as the set of specific coefficients to be used to weight the input samples in order to obtain a specific effect on the output. Let's see this filter in action by analyzing how it works on a hypothetical signal. The first PCM output sample will be the sum of the product of the first and input samples with the filter coefficients. The second PCM sample will be the result of applying the same operation on the next and samples of the input. The third output sample will be obtained by applying the filter on the next and samples and so on. So at this point the output signal is filtered and the high frequency noise we saw in the original PDM stream will be mostly attenuated. One important thing to be pointed out, which is common to all FIR filters, is that each output sample depends only on some of the input samples. There is no dependency on previous output. The second operation to be performed is the decimation. Decimation is the operation of discarding sum of the samples of the signal in order to reduce the sampling frequency. As we saw, the signal must be filtered properly in order to avoid any issue of alias. More in detail, a decimation ratio equal to M means to keep one sample every M samples discarding the others. For example, given this hypothetical signal and using a decimation ratio equal to 3, we are going to keep those samples and eliminate the others. The resulting signal will have a sampling frequency equal to the original sampling frequency divided by the decimation ratio. As we saw in the operations of filtering and decimation, we compute some PCM samples that are going to be discarded just after in the decimation stage. In order to optimize greatly the process and avoid unnecessary processing, we can simply avoid to compute the samples that will be later discarded in the decimation phase. This is possible because we are using a FIR filter and each output sample depends only on the input samples. There is no dependency on previous outputs. In this way, the process we went through previously assuming a decimation ratio equal to 3 will become compute the first sample, do not compute the second sample and do not compute the third sample because those are going to be discarded in any case, compute the fourth sample and so on and so forth. In this way, we avoid wasting processing power in computing samples which are going to be discarded. The next step is a high pass filter. A high pass filter is a filter that passes a signal with a frequency higher than a certain cutoff frequency and attenuates signals with frequencies lower than the cutoff frequency. In the PDM to PCM scenario, this high pass filter is used to remove the DC offset which can be present in the output signal. When a DC offset is present, the average of the signal is not zero as it should be, but rather it is centered on a positive or negative value. A simple single pole recursive filter is enough to cancel this effect by filtering the frequency below a specific cutoff. Usually this cutoff is below 20 Hz to not impact the signal inside the human listener range. Gain is the process of adjusting the level of the audio by increasing or decreasing the amplitude of the signal. This can be simply done by multiplying each sample by a constant value. Gain is used to focus on softer sound which could be too low in the overall PCM range. It can be described as the volume of the recording and it must be added properly in order not to reduce the PCM resolution. Let's now briefly focus on how to tune the parameters in order to obtain a PCM stream at a desired sampling frequency. So we have three parameters involved. The first one is the PDM sampling frequency. The PDM sampling frequency is equal to the microphone clock. Please note that there are always limits to the clock frequency that a microphone can accept. The second one is the PCM sampling frequency, which is the desired frequency of the output PCM stream. Typical PCM frequencies are 16 kHz for voice acquisition, 32 or 48 kHz when a wider spectrum is needed. The last parameter is the decimation ratio, which is the ratio between PDM and PCM sampling frequencies. Depending on the way decimation is performed, for example with a software library or with an hardware peripheral, not all the values for the decimation ratio may be available. Typical values for the STM32 software library for example are 64, 80 or 128. The PCM sampling frequency is the ratio between the PDM frequency or the microphone clock and the decimation ratio. So here are some examples. If you want to obtain a PCM stream at 16 kHz, you can use a clock equal to 1.280 MHz and the decimation ratio equal to 80. You can obtain a PCM stream at 32 kHz using a clock equal to 2.048 MHz and the decimation factor equal to 64. You can obtain a PCM stream at 48 kHz using a clock equal to 3.072 MHz and the decimation factor equal to 64. In general, microphone clock and decimation ratio can be tuned to obtain the desired PCM sampling frequency. More information are available in these documents. Look for the next videos in this series on the ST YouTube channel. Thank you.