Reading meters with a controller on the ADAU1452

Hi, sorry to bother you again:

I would like to the read the signal level so I have added a "Level Detector - Direct Read - Single Level Detector"

I am reading it (named MAINMETERLEFT) via the SPI interface given the following registers exported from SigmaStudio:

/* Module MainMeterLeft - Single Level Detector*/
#define MOD_MAINMETERLEFT_COUNT                        2
#define MOD_MAINMETERLEFT_DEVICE                       "IC1"
#define MOD_MAINMETERLEFT_ALG0_SINGLEBANDLEVELREADS3001_ADDR 0
#define MOD_MAINMETERLEFT_ALG0_SINGLEBANDLEVELREADS3001_VALUE SIGMASTUDIOTYPE_8_24_CONVERT(0)
#define MOD_MAINMETERLEFT_ALG0_SINGLEBANDLEVELREADS3001_TYPE SIGMASTUDIOTYPE_8_24
#define MOD_MAINMETERLEFT_ALG0_SINGLEBANDLEVELREADS3001LEVEL_ADDR 100
#define MOD_MAINMETERLEFT_ALG0_SINGLEBANDLEVELREADS3001LEVEL_VALUE SIGMASTUDIOTYPE_8_24_CONVERT(0)
#define MOD_MAINMETERLEFT_ALG0_SINGLEBANDLEVELREADS3001LEVEL_TYPE SIGMASTUDIOTYPE_8_24

is it "MOD_MAINMETERLEFT_ALG0_SINGLEBANDLEVELREADS3001LEVEL_ADDR " that I should read ?

What sort of value should I get ?

sometimes I get a value of ffc9ed50 and other times its 0028677b or similar numbers. This leads me to believe that I am seeing the sample values and not a calculated dB value.

Is there a way to read the dB value or is this calculation done in SigmaStudio ?

thanks again for your guidance

PhilipJ



Split the post from another thread and renamed the topic.
[edited by: DaveThib at 6:39 PM (GMT 0) on 4 Nov 2019]
Parents
  • +1
    •  Analog Employees 
    on Nov 4, 2019 7:10 PM

    Hello Philipj451,

    You had asked a similar question a while back. Here is the post. 

    https://ez.analog.com/dsp/sigmadsp/f/q-a/103498/adau1452---adau1452reading-signal-level-via-spi/307319#307319

    The meter you pulled out of the toolbox is the Direct Read Single Level Detector. This one is one of the low instruction use in the DSP type so the DSP does very little with the data. In this case, basically, nothing. It reads the data and gives you an address to read the data. It is basically a READBACK so it is not very good if you need for something to be accurate. It will give you an idea of what the level is but you may miss peaks and you have to do all the calculations on your microcontroller. It is giving you the 8.24 number from inside the core so you have to translate it to a floating point number from the fixed point and then calculate the RMS values and filter it over time with a time constant. 

    If you have available MIPS then use the "Single Level Detector w Numerical Display" from the toolbox. This one does some of the processing on the DSP but not all of it. You still need to do some calculations on your microcontroller. 

    Here is a display of the parameters of this style of meter:

    I highlighted the parameters that pertain to the meter. You will see that there is a time constant and hold and decay time. The hold is calculated to be 10ms of samples at the sample rate set in SigmaStudio. So therefore, if you want to not miss any peaks you should be reading this every 10ms. 

    There are three significant variables you need to understand. They are in red because they are always being changed by the DSP. 

    rms, is the double precision value that is the average of the squares, so not exactly the RMS but still useful. It is filtered with a filter that uses the time constants that are stored in the parameters. 

    X, is the high word of the double precision rms value. 

    X_Lo, is the low word of the rms and that is usually not vey useful. 

    LinX is the input data unchanged. This is like the meter you chose that only has the instantaneous current sample. 

    So in your micro you would have to read this X value which is probably good enough resolution or read the rms value. Then convert it to floating point and then get the log and calculate the dB level. 

    Now, I did experiment with doing all of this in the DSP. To do it I used a peak accurate envelope generator, the Log2 function and a multiplier to obtain a number in dBFS and it looks like it is usable. I just did this quickly with a little test program but you can read the READBACK and get the number at any time. It does the averaging etc, so you would only need to read the 32 bit number and convert it from an 8.32 number. You could just truncate the factional part if you do not care to show less than 1dB of resolution. 

    I just used a test program I use for testing inputs and outputs when troubleshooting hardware issues. So you will see the meter calculation up at the top. 

    Dave T

    ADAU1452 Channel Test Program and level calculation-Mute.zip

Reply
  • +1
    •  Analog Employees 
    on Nov 4, 2019 7:10 PM

    Hello Philipj451,

    You had asked a similar question a while back. Here is the post. 

    https://ez.analog.com/dsp/sigmadsp/f/q-a/103498/adau1452---adau1452reading-signal-level-via-spi/307319#307319

    The meter you pulled out of the toolbox is the Direct Read Single Level Detector. This one is one of the low instruction use in the DSP type so the DSP does very little with the data. In this case, basically, nothing. It reads the data and gives you an address to read the data. It is basically a READBACK so it is not very good if you need for something to be accurate. It will give you an idea of what the level is but you may miss peaks and you have to do all the calculations on your microcontroller. It is giving you the 8.24 number from inside the core so you have to translate it to a floating point number from the fixed point and then calculate the RMS values and filter it over time with a time constant. 

    If you have available MIPS then use the "Single Level Detector w Numerical Display" from the toolbox. This one does some of the processing on the DSP but not all of it. You still need to do some calculations on your microcontroller. 

    Here is a display of the parameters of this style of meter:

    I highlighted the parameters that pertain to the meter. You will see that there is a time constant and hold and decay time. The hold is calculated to be 10ms of samples at the sample rate set in SigmaStudio. So therefore, if you want to not miss any peaks you should be reading this every 10ms. 

    There are three significant variables you need to understand. They are in red because they are always being changed by the DSP. 

    rms, is the double precision value that is the average of the squares, so not exactly the RMS but still useful. It is filtered with a filter that uses the time constants that are stored in the parameters. 

    X, is the high word of the double precision rms value. 

    X_Lo, is the low word of the rms and that is usually not vey useful. 

    LinX is the input data unchanged. This is like the meter you chose that only has the instantaneous current sample. 

    So in your micro you would have to read this X value which is probably good enough resolution or read the rms value. Then convert it to floating point and then get the log and calculate the dB level. 

    Now, I did experiment with doing all of this in the DSP. To do it I used a peak accurate envelope generator, the Log2 function and a multiplier to obtain a number in dBFS and it looks like it is usable. I just did this quickly with a little test program but you can read the READBACK and get the number at any time. It does the averaging etc, so you would only need to read the 32 bit number and convert it from an 8.32 number. You could just truncate the factional part if you do not care to show less than 1dB of resolution. 

    I just used a test program I use for testing inputs and outputs when troubleshooting hardware issues. So you will see the meter calculation up at the top. 

    Dave T

    ADAU1452 Channel Test Program and level calculation-Mute.zip

Children
No Data