>Hi guys/gals
>
>I'm new to DSP pogramming but am familiar to the high level concepts. I
>know how the output of a FIR filter is computed and how to generate the
>coeficients and tap count.
>
>I'm using ScopeFIR and have generated a 100 tap low pass filter. I have
>"quantized the coefficents to 16 bits because I'm planning to use this on
>the DsPic 30F6014. The 16bit A2D I'll be sampling outputs and outputting
0
>for -10V input and FFFF for +10V
>
>
>The DsPic has C librarys that call for the coefficients to be in fraction
>format. I assume the A2D sample also need to be in a compatable format
as
>well.
>
>What type of Coefficent export type out of ScopeFIR do I need to get the
>coefficents in the appropriate form for the DsPic C functions to be
happy?
>
>Do I need to do some kind of transform to the A2D samples to get them
into
>Fraction form as well?
>
>The output will be sent to a matching 16 bit DAQ (same +/- 10V) range and
>would like it to track the DC input to the A2D and reject the AC noise.
AA
>filter is in place. :)
>
>thanks
>
>
>
ok here is what you do:
I created a FIR as example I used a tool calleddsPIC FD lite for it:
create this as .s file
;
..............................................................................
; File fir.s
;
..............................................................................
.equ firNumTaps, 49
;
..............................................................................
; Allocate and initialize filter taps
.section .xdata,data,xmemory // see below
.align 128
//this are the taps change as required
firTaps:
hword
0x01F9, 0x020C, 0x021E, 0x0230, 0x0241, 0x0252, 0x0262, 0x0271, 0x0280
hword
0x028E, 0x029C, 0x02A8, 0x02B4, 0x02BF, 0x02C9, 0x02D2, 0x02DA, 0x02E2
hword
0x02E8, 0x02ED, 0x02F2, 0x02F5, 0x02F8, 0x02F9, 0x02FA, 0x02F9, 0x02F8
hword
0x02F5, 0x02F2, 0x02ED, 0x02E8, 0x02E2, 0x02DA, 0x02D2, 0x02C9, 0x02BF
hword
0x02B4, 0x02A8, 0x029C, 0x028E, 0x0280, 0x0271, 0x0262, 0x0252, 0x0241
hword 0x0230, 0x021E, 0x020C, 0x01F9
;
..............................................................................
; Allocate delay line in (uninitialized) Y data space
.section .ybss,bss,ymemory // see below
.align 128
firDelay:
.space firNumTaps*2
;
..............................................................................
; Allocate and intialize filter structure
.section .data
.global _firFilter
_firFilter:
hword firNumTaps
hword firTaps
hword firTaps+firNumTaps*2-1
hword 0xff00
hword firDelay
hword firDelay+firNumTaps*2-1
hword firDelay
If you use the FD lite the bit I marked see below will be wrong change it
as IK have done in here
you also need an .h file
#ifndef FIR_H
#define FIR_H
extern FIRFilterStructure firFilter;
#endif /* FIR_H */
/* The following C-code fragment demonstrates how to call the filter
routine
#include "FIR_Filter.h"
#include "fir.h"
// NUM_SAMPLES defines the number of samples in one block of input data.
// This value should be changed as needed for the application
#define NUM_SAMPLES 100
{
// Declare input and output sample arrays.
int inSamples[NUM_SAMPLES], outSamples[NUM_SAMPLES];
// Call the FIRFilterInit routine to zero out the delay line
FIRFilterInit( &firFilter );
// Call BlockFIRFilter for each block of input samples
// This routine would normally be called inside a FOR or a DO-WHILE
loop
// Only one instance has been shown
BlockFIRFilter( &firFilter, &inSamples, &outSamples, NUM_SAMPLES );
}
*/
which is also created by FD lite and it actually does explain the rest you
have to do --- note that I called the filter "fir" (maybe not a good choice
as it confuses things) so replace that with the name of your filter.
That should do the trick
This message was sent using the Comp.DSP web interface on
www.DSPRelated.com
Reply by Tim Wescott●March 17, 20052005-03-17
Mook Johnson wrote:
> Hi guys/gals
>
> I'm new to DSP pogramming but am familiar to the high level concepts. I
> know how the output of a FIR filter is computed and how to generate the
> coeficients and tap count.
>
> I'm using ScopeFIR and have generated a 100 tap low pass filter. I have
> "quantized the coefficents to 16 bits because I'm planning to use this on
> the DsPic 30F6014. The 16bit A2D I'll be sampling outputs and outputting 0
> for -10V input and FFFF for +10V
>
>
> The DsPic has C librarys that call for the coefficients to be in fraction
> format. I assume the A2D sample also need to be in a compatable format as
> well.
>
> What type of Coefficent export type out of ScopeFIR do I need to get the
> coefficents in the appropriate form for the DsPic C functions to be happy?
>
> Do I need to do some kind of transform to the A2D samples to get them into
> Fraction form as well?
>
> The output will be sent to a matching 16 bit DAQ (same +/- 10V) range and
> would like it to track the DC input to the A2D and reject the AC noise. AA
> filter is in place. :)
>
> thanks
>
>
You will have to check your documentation from Microchip, but it is most
likely that the fraction format is just a 2's complement number that is
interpreted as a fraction -- i.e. instead of the LSB having a bit weight
of 1 and the MSB (sign bit of a 16-bit number) having a bit weight of
32768 a fractional number that ranges from -1 (0x8000) to almost +1
(0xffff) will have a LSB bit weight of 1/32768 and a MSB (sign) bit
weight of 1.
Assuming this is correct then your ADC will have to have it's MSB
reversed so -10V results in 0x8000 and +10V (well, 9.9997V) will result
in 0x7fff, with 0V (0x8000 out of the ADC) will be 0x0000.
I'm familiar with neither the ScopeFIR or the DsPIC, but I suspect that
you just need to export the FIR coefficients as a vector of integers
that range from -32768 to 32767 and make them into a C array. You
should be able to just tell the DsPIC to interpret them as fractional.
Assuming that the DAC format matches the ADC then you'll have to do the
same sign bit inversion on the DAC as you did on the ADC.
--
Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
Reply by Mook Johnson●March 17, 20052005-03-17
Hi guys/gals
I'm new to DSP pogramming but am familiar to the high level concepts. I
know how the output of a FIR filter is computed and how to generate the
coeficients and tap count.
I'm using ScopeFIR and have generated a 100 tap low pass filter. I have
"quantized the coefficents to 16 bits because I'm planning to use this on
the DsPic 30F6014. The 16bit A2D I'll be sampling outputs and outputting 0
for -10V input and FFFF for +10V
The DsPic has C librarys that call for the coefficients to be in fraction
format. I assume the A2D sample also need to be in a compatable format as
well.
What type of Coefficent export type out of ScopeFIR do I need to get the
coefficents in the appropriate form for the DsPic C functions to be happy?
Do I need to do some kind of transform to the A2D samples to get them into
Fraction form as well?
The output will be sent to a matching 16 bit DAQ (same +/- 10V) range and
would like it to track the DC input to the A2D and reject the AC noise. AA
filter is in place. :)
thanks