Trying to understand RMS limiter example in knowledge base
Posted: Mon May 02, 2016 7:56 am
I can make sense of most of the code in the example below, but I'm confused by the line
rdfx avg,0.001
I understand that it is preparing a number to be saved as the running average of the (halved, summed, and squared) inputs. I don't understand how it is getting the average. As I read the code, it looks like it takes 0.001*(new value - running average) and adds it to the running average. Is the 0.001 to make it a slower change over time? So at 32k clock, it would take about 30mS for a constant offset to accumulate? Could the 0.001 be changed to make a faster or slower reacting sensor?
Thanks
This is the example from the knowledge base:
The RMS limiter could be built this way:
;rms limiter, approx 10dB limiting range.
equ sigin reg0
equ avg reg1
rdax adcl,0.5
rdax adcr,0.5
wrax sigin,1
mulx sigin ;square
rdfx avg,0.001
wrax avg,1 ;average
log 0.5,0 ;[square
exp 1,0 ;root]
log -1,-0.125 ;[1/X, set thresh @2 bits (2/16ths)
exp 1,0 ;]
mulx sigin ;gain reduce
sof 1.5,0 ;restore level
wrax dacl,1
wrax dacr,0
rdfx avg,0.001
I understand that it is preparing a number to be saved as the running average of the (halved, summed, and squared) inputs. I don't understand how it is getting the average. As I read the code, it looks like it takes 0.001*(new value - running average) and adds it to the running average. Is the 0.001 to make it a slower change over time? So at 32k clock, it would take about 30mS for a constant offset to accumulate? Could the 0.001 be changed to make a faster or slower reacting sensor?
Thanks
This is the example from the knowledge base:
The RMS limiter could be built this way:
;rms limiter, approx 10dB limiting range.
equ sigin reg0
equ avg reg1
rdax adcl,0.5
rdax adcr,0.5
wrax sigin,1
mulx sigin ;square
rdfx avg,0.001
wrax avg,1 ;average
log 0.5,0 ;[square
exp 1,0 ;root]
log -1,-0.125 ;[1/X, set thresh @2 bits (2/16ths)
exp 1,0 ;]
mulx sigin ;gain reduce
sof 1.5,0 ;restore level
wrax dacl,1
wrax dacr,0