ADAU1701 Volume Control Using MCU
Hello Bob!
I just need to ask about volume control using 8bit MCU as a master to control the sigma DSP ADAU1701 volume using push buttons Everytime i push either Volume UP/DOWN, the MCU writes to the appropriate DSP param address. I have problems implementing it in software. How do you do it? In my understanding, you READ first, then increment/decrement by a fixed value, then WRITE the new 4 byte data to the param address. Is this correct? If possible can you give me some sample to code to manipulate such data to get the correct value and write it to the DSP address?
Using volume control no slew:
Gain(dB) Value Data
0 1 0x00 0x80 0x00 0x00
-2 0.7940 0x00 0x65 0xAC 0x8C
-4 0.6309 0x00, 0x50, 0xC3, 0x36
-6 0.5011 0x00, 0x40, 0x26, 0xE7
. . .
. . .
. . .
. . .
I found it confusing how I can get the current value and get a correct incremented value afterwards when I want some volume change. I have tried to program it by myself but I cannot get the correct value, as displayed by the logic analyzer.
Regards & Thanks
Dan
Audio Signal Processors
8
bit
microcontroller
volume
SigmaDSP Audio Processors
control_character
adau1701
Show More
Hello Dan,
It appears from your description that you have your microcontroller boot the -1701 and remain in control of your product's functions during operation. In such a system, the micro keeps track of the settings for stuff like volume and EQ. Although a read-modify-write procedure could work fine, it is often easier to implement a write-only scheme. After booting the DSP at power up, the micro writes initial parameters for all control settings -- either from a default starting state, or based on previous user settings stored in NV memory. When the user changes a setting, the micro stores this new value, then converts it into the related parameter value and writes it to the DSP. This is easier since no reads are involved.
First, decide how to format each setting in the micro's memory. For example, a volume setting could be calibrated in dB, with zero the maximum (non-attenuated) value, and 100 the minimum (equal to 100 dB below max). Or you could go from zero to 50, where 50 is the maximum volume, decreasing in 2dB steps as you go toward zero. I'll use this format as an example, since you mentioned 2dB steps in your post.
Inspecting SigmaStudio's parameter results for several dB settings suggests the following formula to convert from the zero - 50 volume setting "S" to the needed parameter value "V": V = 10 ^ ( -0.1 * ( 50 - S) ) As long as your micro's C compiler has math functions, this is easily coded.
Next you need to translate this decimal parameter to the bytes that the DSP can use. Nando.One wrote a good tutorial about this at:
https://ez.analog.com/message/61175#61175
I attached an example C file which computes the set of five filter coefficients from a parametric EQ setting -- a bit more complex than the volume example, but likely you'll need to control EQ in your project as well. Coefficient calculations are based on Brett's spreadsheet at
https://ez.analog.com/docs/DOC-1819
Where I work we like to use PIC processors and the C compiler from Custom Computer Services (CCS). The latter has a make8 function that breaks up the parameters into bytes.
Once you have the needed parameter bytes, you can write them to the appropriate locations in the DSP. To avoid nasty sounds when updating your parameters, use the safeload method described in the -1701 data sheet and Nando.One's tutorial. Although parameter values are four-bytes each with the top nibble zero (28 bits), you load five bytes for each parameter. There needs to be a dummy byte in the middle, as explained at https://ez.analog.com/thread/6429
Best regards,
Bob
Awesome work, Bob! This is a great guide.
Wow! Thanks a lot BOB! Very well explained. Now, i get the clearer picture of what im gonna do!
My current setup though consists of the MINI evaluation board for ADAU1701 with the built in external EEPROM. The reason i did implement the read-modify-write procedure is that i want to control the sigma DSP thru MCU without modifying the board layout, i mean the DSP is physically attached to the EEPROM making it SELFBOOT no matter what i do (UP/DOWN) with the WP PIN (S5 Switch). Currently, I cannot do the default_downoad() function using the MCU, so I can easily implement what u suggest(write only scheme), since the dsp automatically boots from the EEPROM. So, I try to modify the parameter on the flly without worrying about saving the current setting during power down, but, this later will be implemented as well. so for now, i would just like to test the volume control thru MCU.
I'll keep posted once I finish the implementation.
Thank,
Dan
Please log in to reply.