ΣSigmaStudio Ask AI Русский Log in

ADAU1450 volume setting from microcontroller

SigmaDSP & SigmaStudio Reini Feb 3, 2018 00:00 2 replies Original on forum ↗
Subscribe
Reini Question
Feb 3, 2018 00:00

Hello all,

I could use your help with the following:

We have an Adau1450 connected with I2C to a microcontroller. In the 1450 is a volume controller which I have to set with 8.24 fixedpoint values. But I don't want to do complex computations in my microcontroller, that's what the DSP can do much better :-)

So, I was thinking, can I calculate the right volume setting in the DSP if I feed it with integer values in the range of, say, -9600 to +600 (which represent a volume range of -96.00dB to +6.00dB) ? In the DSP there should be some calculation, which converts the integer dB values to a fixedpoint value for a Single Volume component. Or is it possible to write the calculated value directly to the I2C address of an other volume slider?

The fixedpoint values have a range of about -128.00 to +128.00 Where can I find how the DSP converts integer to fixedpoint values? I now use a lookup table in the microcontroller with fixedpoint values for volumes in range of -96dB to +6dB in steps of 0.5dB. But then I thought, why not feeding the requested value in dB's to the DSP, and let him/her do the math? I really want to get rid of the lookuptable and want to be able to set the volume more accurate then in steps of 0.5dB

For the lookuptable I wrote a small Delphi program which creates a table. To convert a dB value to fixedpoint 8.24 I use the following code:

One_dB := 0.11512925464970228420089957273422;
Volume := -96.0; // one entry, others are -95.5, -95.0, -94.5, -94.0, .. etc.VolFixedPoint := Exp(Volume*One_dB);RegisterValue := Round(VolFixedPoint*$01000000); // ADAU1450

RegisterValue is the value what is added to the table.

This calculation should be done in the DSP if that is possible of course :-)

Hope someone has a hint :-)

With kind regards,

Reini

Audio Signal Processors

adau1450

SigmaDSP Audio Processors

KJBob Reply
Feb 3, 2018 00:00

Hello Reini,

The Sigma 300 (ADAU145x, ect.) DSPs have base-2 Log and 2^x functions which can perform "log" dB conversions fo you. Below is a working example using the 2^x function. Your uC only needs to safeload the appropriate volume setting as an integer number in dB hundredths -- for example, + 6.02 dB enters as "602." It's easy to safeload this into a DC source as shown in the Capture Window. The project's gain blocks perform the needed conversions from dB hundredths to dB (divide by 100), from 32.0 to 8.24 formats (multiply by 2^24), from base-10 log to base-2 log (divide by log (2)), and finally, the usual formula: linear gain = 10^(dB/20). The gains are split up to keep each factor below the 8.24 limit of +(128-LSB).

The attached project runs on the ADAU1452 eval board.

Best regards,

Bob

6f366dee7e86ec2b9ed419e9d20bac5e.png
6f366dee7e86ec2b9ed419e9d20bac5e.png
6f366dee7e86ec2b9ed419e9d20bac5e.png-620x420.png
6f366dee7e86ec2b9ed419e9d20bac5e.png-620x420.png
Reini Reply
Feb 3, 2018 00:00

Hello Bob,

Thank you so much for this answer. It is EXACTLY what I need. I did not realise I can use and cascade gains like this :-) This is really an eyeopener. With this I spare more than 1k bytes in my microcontroller firmware, but also important, the speed and most important, the ability to set gain to values other than 0.5dB intervals. With this solution I am able to set a gain of, for example -5.30dB

Thanks again!

With kind regards,

Reini