Long story short is that I'm a programmer not a mathlete nor DSP guy and I'm in the unusual position of not being able to explain a formula. We're working with a board that uses a MATLAB "2nd Order Transfer Filter" to which I've seen some reference. We're verifying the tests and the reviewer walks up to me with "I don't get it." Taking a look at the MATLAB description gives me the formula:
Where [z1] and [z2] are history states. The actual diagram breaks down to the following Python snippet:
So how does the matrix-looking division given in the description break down into the code? I've been plugging away looking at different types of transforms but honestly, I'm not making much headway (hardware manuals make me sleepy). Any pointers from the crowd would be appreciated!
Code:
Out = In * [(A + Bz-1 + Cz-2)/(D + Ez-1 + Fz-2)]
Where [z1] and [z2] are history states. The actual diagram breaks down to the following Python snippet:
Code:
class SecondOrderTransferFunc:
def __init__(self):
self.hist1 = 0
self.hist2 = 0
self.num1 = 0.87
self.num2 = -1.55
self.num3 = 0.85
self.den1 = 1.0
self.den2 = -1.75
self.den3 = 0.92
def exec(self,input):
out = self.den1 * ((input * self.num1) + self.hist2)
self.hist2 = ((input * self.num2) + self.hist1) - (self.den2 * out)
self.hist1 = (input * self.num3) - (self.den3 * out)
return out
So how does the matrix-looking division given in the description break down into the code? I've been plugging away looking at different types of transforms but honestly, I'm not making much headway (hardware manuals make me sleepy). Any pointers from the crowd would be appreciated!