#41280 - nicouiuc - Wed Apr 27, 2005 2:24 am
Hi,
I am using the XPort for the GBA and Im trying to implement a filter on the GBA. The equations, called every 1ms, for that look like:
The values of x1 and a1 are 12 bits. I tried to set this filter up on the GBA, but it doesnt work at all. I tried scaling the 0.0009975 by 2^20, and the 1.9975 and .9975 by 4096. So, e.g. the first line looks like:
(I now compute 2^20 * the original y2, y1 and y0 should already be scaled by that amount as they are derived from y2)
This gives some very strange values after seconds, I think I have a problem of overlowing registers somewhere, also I tried to use signed long long int for all variables. I can only fix it by immidiately making a divison by 2^14, but then I loose already a big amount of precision, which seems to hurt my algorithm...
Also, it seems that it matters if I divide by the power of 2 or use the shift operator. I guess thats caused by different rounding/truncation, right? And i sometimes get different results for positive than for negative values...
Does anyone know a way how to implement this stuff best?
~Nico
I am using the XPort for the GBA and Im trying to implement a filter on the GBA. The equations, called every 1ms, for that look like:
Code: |
y2 = 0.0009975 * x1 - 0.0009975 * x0 + 1.9975*y1 - 0.9975*y0; b2 = 0.0024953 * a1 - 0.0024937 * a0 + 1.9975*b1 - 0.9975*b0; x0 = x1; y0 = y1: y1 = y2: a0 = a1; b0 = b1: b1 = b2; |
The values of x1 and a1 are 12 bits. I tried to set this filter up on the GBA, but it doesnt work at all. I tried scaling the 0.0009975 by 2^20, and the 1.9975 and .9975 by 4096. So, e.g. the first line looks like:
Code: |
y2 = 1046 * x1 - 1046 * x0 + (8182*y1 - 4086*y0)/4096; x0 = x1; y0 = y1: y1 = y2: |
(I now compute 2^20 * the original y2, y1 and y0 should already be scaled by that amount as they are derived from y2)
This gives some very strange values after seconds, I think I have a problem of overlowing registers somewhere, also I tried to use signed long long int for all variables. I can only fix it by immidiately making a divison by 2^14, but then I loose already a big amount of precision, which seems to hurt my algorithm...
Also, it seems that it matters if I divide by the power of 2 or use the shift operator. I guess thats caused by different rounding/truncation, right? And i sometimes get different results for positive than for negative values...
Does anyone know a way how to implement this stuff best?
~Nico