VS1053b:Mic Recording:Convert sampled data back to mV

Writing software that inputs and/or outputs audio and performs DSP algorithms such as filters, new codecs or audio effects.
Post Reply
zulunation
User
Posts: 18
Joined: Mon 2012-02-06 23:04

VS1053b:Mic Recording:Convert sampled data back to mV

Post by zulunation » Mon 2020-09-14 20:03

Hi ALL,

I am recording the sound using MIC NP inputs and everything is fine. I am using PCM mode for recording.
I want to recalculate the samples back to millivolts.
There are two unknown parameters.

1. Auto gain: As i see from datasheet it is always enabled. How does it works and it there any way to disable it?
2. Mono ADC: I need to know the reference voltage to recalculate the digital output to analog input.

Is there any additional description on above issues?

Thanks,

Hannu
Senior User
Posts: 92
Joined: Mon 2016-05-30 11:54

Re: VS1053b:Mic Recording:Convert sampled data back to mV

Post by Hannu » Tue 2020-09-15 8:07

Hello!

I'm not really expert with VS1053 but I'll try to give some ideas what to try and see if it works.
You might be interested: http://www.vlsi.fi/fileadmin/software/V ... corder.pdf That document explains the AGC quite well.

datasheet gives:
Disabling AGC: SCI_AICTRL1, bits 15..0 Recording gain (1024 = 1×) or 0 for automatic gain control
Channels can be selected SCI_AICTRL3 register.

Back to mV scale is little bit trickier. I think you need to feed some known signal, take a look encoded data and repeat until you know the values/function how it transfers. This measurement is probably quite noise sensitive.

User avatar
Henrik
VLSI Staff
Posts: 1174
Joined: Tue 2010-06-22 14:10

Re: VS1053b:Mic Recording:Convert sampled data back to mV

Post by Henrik » Tue 2020-09-15 12:26

Hello!
zulunation wrote:
Mon 2020-09-14 20:03
I am recording the sound using MIC NP inputs and everything is fine. I am using PCM mode for recording.
I want to recalculate the samples back to millivolts.
There are two unknown parameters.

1. Auto gain: As i see from datasheet it is always enabled. How does it works and it there any way to disable it?
Automatic gain control is active if SCI_AICTRL = 0 while recording. For a neutral digital gain of 1, set SCI_AICTRL = 1024.

However, do note that there is a DC removal filter, so you actually have to have sound in the inputs. If you try to measure a DC value (example: 0.04V), the DC removal filter of VS1053 will make the output stay at or around zero after a short while.
2. Mono ADC: I need to know the reference voltage to recalculate the digital output to analog input.
I can give a rough estimate, but as Hannu said, if you want greater accuracy, you will need to calibrate your unit with e.g. a 1 kHz sine wave. We don't calibrate microphone gain very accurately, because normally a decibel here or there doesn't matter.

Anyhow, a rough estimate for the differential microphone input full range is 140 mVpp (50 mVrms) or 180 mVpp (64 mVrms), depending on whether the reference voltage is 1.23 V or 1.65 V (the reference voltage is set with bit SS_REFERENCE_SEL in register SCI_STATUS). How you further your calculations from there depends on whether you are more interested in peak values, in which case you just look for the highest absolute value, or if you are interested in RMS power, in which case you need to use a formula similar to the following:

rmsPower = sqrt((s(1)*s(1) + s(2)*s(2) + ... + s(n) * s(n)) / n);
where n is the number of samples over which you calculate the RMS, and s(1) through s(n) are your samples. Also, using a windowing function (e.g. Hann or Blackman) results in more stable numbers.

Then, to convert this to decibel scale:
rms_dB = 20*log(rmsPower)/log(10);

KInd regards,
- Henrik
Good signatures never die. They just fade away.

zulunation
User
Posts: 18
Joined: Mon 2012-02-06 23:04

Re: VS1053b:Mic Recording:Convert sampled data back to mV

Post by zulunation » Tue 2020-09-15 23:04

Hi, and thanks for reply

I will pass a test signal and calibrate.

I would like to clear some moments.

If AICTRL1 = 0 that autogain is enabled and AICTRL2 value is used as a maximum gain.
If AICTRL = 1x (1024) then autogain is disabled and value of AICTRL2 is not important.

Am i correct?

If reference voltage is 1.23V then full range is 140 mVpp. How it is calculated?
I thought maximum input on the ADC is 1.23/2 = 615mV. Half for positive signal and half for negative.
I mean input voltage can be equal to the reference or half of the reference voltage.
Where I am wrong?

Hannu
Senior User
Posts: 92
Joined: Mon 2016-05-30 11:54

Re: VS1053b:Mic Recording:Convert sampled data back to mV

Post by Hannu » Wed 2020-09-16 8:40

Someone hopefully corrects me if I'm wrong.

First is differential part. If voltage difference is 0 V, then you'll get 0 on ADC.

After differential input pins there is mic amplifier with of gain 20X (26dB). After that you can think the signal is single-ended line level, biased around reference and then fed to ADC through multiplexer inside the chip as shown in the ADC chapter.

For our luck the level values are given in the datasheet in MLEV16 and MLEV12 with max 180 and 140 mVpp AC.

One thing which isn't mentioned is ADC value X means Y mVpp as usually it doesn't matter. What matters is that every time you get same ADC value for same voltage. And again this is AC signal. So the calibration is key to find few points and then connect the dots.

And last thing... DC biasing. MICN and MICP have their own biasing circuitry and those should be decoupled with capacitors as shown in for example: http://www.vlsi.fi/fileadmin/evaluation ... xxpp17.pdf R17 handles that with no signal the difference is really 0 and capacitors C1 and C2 separates DC biases from microphone and differential input pins

User avatar
Henrik
VLSI Staff
Posts: 1174
Joined: Tue 2010-06-22 14:10

Re: VS1053b:Mic Recording:Convert sampled data back to mV

Post by Henrik » Wed 2020-09-16 10:34

Hi!

I am adding a bit to what Hannu wrote.
zulunation wrote:
Tue 2020-09-15 23:04
I would like to clear some moments.

If AICTRL1 = 0 that autogain is enabled and AICTRL2 value is used as a maximum gain.
If AICTRL = 1x (1024) then autogain is disabled and value of AICTRL2 is not important.

Am i correct?
Yes, set SCI_AICTRL1 = 1024, and you have both disabled autogain and have set the digital gain for best dynamic range.
zulunation wrote:
Tue 2020-09-15 23:04
If reference voltage is 1.23V then full range is 140 mVpp. How it is calculated?
I thought maximum input on the ADC is 1.23/2 = 615mV. Half for positive signal and half for negative.
I mean input voltage can be equal to the reference or half of the reference voltage.
Where I am wrong?
The microphone input is differential.
So, if MICP = +35mV and MICN = -35mV, then input is +70mV.
Conversely, if MICP = -35mV and MICN = +35mV, then input is -70mV.
At these extremes, peak-to-peak input is +70mV - -70mV = 140mVpp.

In single-ended line input mode, the maximum for Left and Right inputs is 2050 mVpp (with 1.23V reference), in other words about 1.23V±1.03V. Because the center point is around 1.23V, the input must have a DC Block filter which is shown in all of our example schematics.

Kind regards,
- Henrik
Good signatures never die. They just fade away.

zulunation
User
Posts: 18
Joined: Mon 2012-02-06 23:04

Re: VS1053b:Mic Recording:Convert sampled data back to mV

Post by zulunation » Mon 2020-09-21 20:42

So as I understood MICN and MICP goes inside to differential amplifier. Which is has 26dB fixed gain.
Then there is a variable gain amplifier which we can control via registry settings.
After that a single line goes to ADC which is connected to reference voltage.

Am i correct?

Hannu
Senior User
Posts: 92
Joined: Mon 2016-05-30 11:54

Re: VS1053b:Mic Recording:Convert sampled data back to mV

Post by Hannu » Wed 2020-09-23 7:25

The AGC is on digital side of the ADC but the your idea of the ADC is otherwise correct. The datatsheet figure 19 shows the block diagram of ADC path.

Post Reply