malik_123
Member level 4
i have made a FIR filter with 80 taps.
filter coefficient are
low pass filter of Fc=200 Hz;
data=[ -1,
-1,
2,
2,
-3,
-3,
5,
5,
-7,
-8,
11,
11,
-16,
-16,
23,
23,
-34,
-33,
50,
47,
-74,
-66,
109,
95,
-163,
-134,
246,
189,
-378,
-264,
593,
360,
-961,
-474,
1642,
590,
-3176,
-679,
10324,
17098,
10324,
-679,
-3176,
590,
1642,
-474,
-961,
360,
593,
-264,
-378,
189,
246,
-134,
-163,
95,
109,
-66,
-74,
47,
50,
-33,
-34,
23,
23,
-16,
-16,
11,
11,
-8,
-7,
5,
5,
-3,
-3,
2,
2,
-1,
-1,
1
];
i then fed it with the sin wave data
frequency =150Hz;
s1=[0,
828,
974,
316,
-602,
-1024,
-602,
316,
974,
828,
0,
-828,
-974,
-316,
602,
1024,
602,
-316,
-974,
-828,
'
'
'
' (255 points )];
my matlab code is working properly and i get the values of
out_put=[0,
27140552,
31904130,
10362078,
-19726756,
-33556948,
-19726756,
10362078,
31904130,
27140552,
0,
-27140552,
-31904130,
-10362078,
19726756,
33556948,
19726756,
-10362078,
-31904130,
-27140552,
(repeating 176 points)
]
but my goal is to implement it on the Dspic processor. 30f4013;
it has the accumulator of 40 bit.
i need to extract 16 bit values from it , which exactly replicate the filter out put .
how to do it , how to scale the value . i shifted the valuses and then plot the result but it was not the replica of the wave form which i got from my matlab program
please help
Added after 1 hours 13 minutes:
i am now using the arithimatic shift to right to get the desired 16 bit value.
for this i am shifting the bits 10 times to right. and extracting the values
the effect will be of dividing the values by 2^10.
all the other values are correct except two values
-33556948,
and
33556948
it get wrongly converted to
32765 instead of -32765
-32766 instead of 32766
what could be the reason of this error ?
please help
filter coefficient are
low pass filter of Fc=200 Hz;
data=[ -1,
-1,
2,
2,
-3,
-3,
5,
5,
-7,
-8,
11,
11,
-16,
-16,
23,
23,
-34,
-33,
50,
47,
-74,
-66,
109,
95,
-163,
-134,
246,
189,
-378,
-264,
593,
360,
-961,
-474,
1642,
590,
-3176,
-679,
10324,
17098,
10324,
-679,
-3176,
590,
1642,
-474,
-961,
360,
593,
-264,
-378,
189,
246,
-134,
-163,
95,
109,
-66,
-74,
47,
50,
-33,
-34,
23,
23,
-16,
-16,
11,
11,
-8,
-7,
5,
5,
-3,
-3,
2,
2,
-1,
-1,
1
];
i then fed it with the sin wave data
frequency =150Hz;
s1=[0,
828,
974,
316,
-602,
-1024,
-602,
316,
974,
828,
0,
-828,
-974,
-316,
602,
1024,
602,
-316,
-974,
-828,
'
'
'
' (255 points )];
my matlab code is working properly and i get the values of
out_put=[0,
27140552,
31904130,
10362078,
-19726756,
-33556948,
-19726756,
10362078,
31904130,
27140552,
0,
-27140552,
-31904130,
-10362078,
19726756,
33556948,
19726756,
-10362078,
-31904130,
-27140552,
(repeating 176 points)
]
but my goal is to implement it on the Dspic processor. 30f4013;
it has the accumulator of 40 bit.
i need to extract 16 bit values from it , which exactly replicate the filter out put .
how to do it , how to scale the value . i shifted the valuses and then plot the result but it was not the replica of the wave form which i got from my matlab program
please help
Added after 1 hours 13 minutes:
i am now using the arithimatic shift to right to get the desired 16 bit value.
for this i am shifting the bits 10 times to right. and extracting the values
the effect will be of dividing the values by 2^10.
all the other values are correct except two values
-33556948,
and
33556948
it get wrongly converted to
32765 instead of -32765
-32766 instead of 32766
what could be the reason of this error ?
please help