Technical discussions about the TI C54x DSPs (including the c5401, c5402, c5402a, c5404, c5407, c5409, c5409a, c5410, c5410a, c5416, c5420, c5421, c5441, c549, c5470 and c5471).
Hello,
I'm trying to implement a cascading iir and here's my code for the first
second order z transform. I'm I going about this correctly? My output is
good till a particular value and then it starts having problems. Any help
or links to a good example would be great!
Thanks,
Grant
float b[3] = {1,2,1};
float a[3] = {1,-1.9985996261556458,0.99952100328066507};
float y[151]={0};
int i=0;
char wait;
while(i<151)
{
x[i] *= 7.0818881108085789e-7;
if(i==0)
y[i] = x[i];
if(i==1)
y[i] = x[i] + b[1]*x[i-1] - a[1]*y[i-1];
if (i>1)
y[i] = x[i] + b[1]*x[i-1] + b[2]*x[i-2] - a[1]*y[i-1] -
a[2]*y[i-2];
cout<<y[i]<<" "<<i<<"\n";
i++;
}
x = x * 7.0818881108085789e-7;
y = b[0]*x + d[0];
d[0] = b[1]*x - a[1]*y + d[1];
d[1] = b[2]*x - a[2]*y + d[2];
cout<<y<<" "<<x<<" "<<x1<<"
"<<x2<<"\n";
i+=.001;
same results
--- In c...@yahoogroups.com, "Grant Jennings" <gtjennings@...> wrote:
>
> Hello,
>
> I'm trying to implement a cascading iir and here's my code for the first
> second order z transform. I'm I going about this correctly? My
output is
> good till a particular value and then it starts having problems.
Any help
> or links to a good example would be great!
>
> Thanks,
> Grant
>
> float b[3] = {1,2,1};
> float a[3] = {1,-1.9985996261556458,0.99952100328066507};
> float y[151]={0};
> int i=0;
> char wait;
>
> while(i<151)
> {
> x[i] *= 7.0818881108085789e-7;
> if(i==0)
> y[i] = x[i];
> if(i==1)
> y[i] = x[i] + b[1]*x[i-1] - a[1]*y[i-1];
> if (i>1)
> y[i] = x[i] + b[1]*x[i-1] + b[2]*x[i-2] - a[1]*y[i-1] -
> a[2]*y[i-2];
> cout<<y[i]<<" "<<i<<"\n";
>
> i++;
> }
>