Hi In 1 of my projects i need to implement 2 filters on input data. The frequency at which the filter is tuned is decided by the input of a GPIO. for example lets say i have to implement 2 low pass filters that could have passband frequencies from (20,40,80,150,600 KHz etc). The Gpio input decides which 2 filters to implement. Can i implement this using the IIR TI C2000 filter library? Essentially i would like to design filters for each of these values using the eZiir Matlab script & select 2 of them depending on the GPIO input. Is this possible using the library? If yes how? Is IIR library better or FIR? Any help is highly appreciated. Thanks. I have attached the code below. /* Create an Instance of IIR5BIQD16 module and place the object in "iirfilt" section */ #pragma DATA_SECTION(iir, "iirfilt"); IIR5BIQ16 iir=IIR5BIQ16_DEFAULTS; /* ============================================================================= Modify the delay buffer size to comensurate with the no of biquads in the filter Size of the Delay buffer=2*nbiq ==============================================================================*/ /* Define the Delay buffer for the cascaded 6 biquad IIR filter and place it in "iirfilt" section */ #pragma DATA_SECTION(dbuffer,"iirfilt"); int dbuffer[2*IIR16_LPF_NBIQ]; /* ============================================================================= Modify the array size and symbolic constant to suit your filter requiremnt. Size of the coefficient array=5*nbiq ==============================================================================*/ /* Define the Delay buffer for the cascaded 6 biquad IIR filter and place it in "iirfilt" section */ const int coeff[5*IIR16_LPF_NBIQ]=IIR16_LPF_COEFF; /* Finter Input and Output Variables */ int xn,yn; void main() { /* IIR Filter Initialisation */ iir.dbuffer_ptr=dbuffer; iir.coeff_ptr=(int *)coeff; iir.qfmat=IIR16_LPF_QFMAT; iir.nbiq=IIR16_LPF_NBIQ; iir.isf=IIR16_LPF_ISF; iir.init(&iir); /*--------------------------------------------------------------------------- Nothing running in the background at present ----------------------------------------------------------------------------*/ while(1) { iir.input=xn; iir.calc(&iir); yn=iir.output; } best regards Vikram
Using IIR Filter Library for different frequencies on TI eZdsp f2812
Started by ●March 3, 2006
Reply by ●March 3, 20062006-03-03
I believe you can achieve what you are after fairly easilly. The way I would approach it would be to select a different set of filter co-efficients based upon the desired response (cutoff freq) and then use these co-efficients in the same filter algorithm. You could set up an array of a filter co-efficients and index into the array based on the GPIO status. If you have a functioning filter, based upon TI's library, you would need to adjust the called filter routine to allow a pointer to the desired filter co-efficients (offset into your array) as a passed paramater as opposed to the hard coded constant in their examples. With this goal in mind, I would hazzard the statement that an IIR filter may be 'better' because they are more efficient than FIR filters in their memory use to store the coefficients. Since you are storing multiple filters in memory, the fewer co-efficients you have to store the better. The down side to IIR is that it can be sensitve to co-efficient precision, especially in a fixed point processor and can suffer from overflow. As a result you will need to be carefull with scaling. IIR filters are also not inherently stable like FIR filters and stability must be designed in.
Reply by ●March 3, 20062006-03-03
>I believe you can achieve what you are after fairly easilly. The way I >would approach it would be to select a different set of filter >co-efficients based upon the desired response (cutoff freq) and then >use these co-efficients in the same filter algorithm. You could set up >an array of a filter co-efficients and index into the array based on >the GPIO status. If you have a functioning filter, based upon TI's >library, you would need to adjust the called filter routine to allow a >pointer to the desired filter co-efficients (offset into your array) >as a passed paramater as opposed to the hard coded constant in their >examples. > >With this goal in mind, I would hazzard the statement that an IIR >filter may be 'better' because they are more efficient than FIR filters >in their memory use to store the coefficients. Since you are storing >multiple filters in memory, the fewer co-efficients you have to store >the better. The down side to IIR is that it can be sensitve to >co-efficient precision, especially in a fixed point processor and can >suffer from overflow. As a result you will need to be carefull with >scaling. IIR filters are also not inherently stable like FIR filters >and stability must be designed in. > >Thanks for your reply. Can you show me what exactly you mean in paragraph 1 on the sample code that I attached. Are you saying that I initialize the coeff array depending on the GPIO pin or change the structure format of the filter. Thanks. Best regards Vikram
Reply by ●March 6, 20062006-03-06
To implement this code would take a lot more time and effort than I have to spend on it right now. In Psuedo Code format, however, here is the gist of what you want to do: IIR16_COEFFECIENTS coeff_array[2] = {filter1, filter2}; // create an array of your coeffecients structures selection_var = read_GPIO(); // read your selection criteria (assume 2 filters) process_filter(coeff_array[selection_var]); The above passes a pointer to a set of filter coeffecients based upon the status of the GPIO pin. The big part will be rewriting the filter algorithm to accept the pointer to the filter coefficients that is variable as opposed to hard coded. In the sample code you posted, which looks like it is from Ti's sample library, I believe that the filter coefficients are already in the form of a pointer in the structure that gets assigned to iir. You will need to either modify the structure or write some code to assign the value in the structure based upon the status of the GPIO pin.
Reply by ●March 6, 20062006-03-06
Noway2 wrote:> To implement this code would take a lot more time and effort than I > have to spend on it right now. > > In Psuedo Code format, however, here is the gist of what you want to > do: > > IIR16_COEFFECIENTS coeff_array[2] = {filter1, filter2}; // create an > array of your coeffecients structures > > selection_var = read_GPIO(); // read your selection criteria (assume 2 > filters) > process_filter(coeff_array[selection_var]); > > The above passes a pointer to a set of filter coeffecients based upon > the status of the GPIO pin. The big part will be rewriting the filter > algorithm to accept the pointer to the filter coefficients that is > variable as opposed to hard coded. In the sample code you posted, which > looks like it is from Ti's sample library, I believe that the filter > coefficients are already in the form of a pointer in the structure that > gets assigned to iir. You will need to either modify the structure or > write some code to assign the value in the structure based upon the > status of the GPIO pin.It's hard to run an efficient MAC that way. I would store all coefficients in flash or ROM, and move the appropriate set into the MAC's coefficient buffer in RAM when the filter is called for. That way, the routine itself needn't change at all. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●March 6, 20062006-03-06
>Noway2 wrote: >> To implement this code would take a lot more time and effort than I >> have to spend on it right now. >> >> In Psuedo Code format, however, here is the gist of what you want to >> do: >> >> IIR16_COEFFECIENTS coeff_array[2] = {filter1, filter2}; // create an >> array of your coeffecients structures >> >> selection_var = read_GPIO(); // read your selection criteria (assume 2 >> filters) >> process_filter(coeff_array[selection_var]); >> >> The above passes a pointer to a set of filter coeffecients based upon >> the status of the GPIO pin. The big part will be rewriting the filter >> algorithm to accept the pointer to the filter coefficients that is >> variable as opposed to hard coded. In the sample code you posted,which>> looks like it is from Ti's sample library, I believe that the filter >> coefficients are already in the form of a pointer in the structurethat>> gets assigned to iir. You will need to either modify the structure or >> write some code to assign the value in the structure based upon the >> status of the GPIO pin. > >It's hard to run an efficient MAC that way. I would store all >coefficients in flash or ROM, and move the appropriate set into the >MAC's coefficient buffer in RAM when the filter is called for. That way,>the routine itself needn't change at all. > >Jerry >-- >Engineering is the art of making what you want from things you can get. >����������������������������������������������������������������������� >Thanks I'm gonna try your method. Hope it works. Best regards Vikram