# Single volume gain math

Hello,

I used the "Single Volume " for user gain. The user should be able to adjust the gain through our GUI.

It would be great if you let me know how to do the conversion from dB to "value" and to "hex".  The value for 0 dBu is "1" as it shown in the data captured window.

Range is 0  to - 80 dB currently.

Would the conversion be different for negative and positive gains?

Thanks, Semi

•      Hello,

The conversion from dB to linear gain (for both positive and negative dB):

G = 10 ^ (dB/20)

To convert the linear gain to an integer (32.0 format) variable, multiply by (2^24) which is 16777216.

Example:  -20 dB     G = 10 ^ (-20/20)  =  10 ^ (-1)    =  0.1

Integer value = 0.1 * 16777216  = 1677722  base 10,  equal to hex 19 99 9A   -- the same as the Capture Window shows for -20 dB.

Inside your microcontroller you'll have the binary value stored as a long integer, you just need to break this 32 bit word into four 8-bit bytes for safeloading.  My C compiler has a "make8" function for this purpose.

Best regards,

Bob