Hi ,all I am currently trying to implement Chebyshev Type I filter on embedded microcontroller - STM32F101 (using C language).This is a microcontroller of ARM cortex M3 type.It is possible to implement this filter in IIR form using CMSIS-DSP APIs.These APIs require single-point precision (floating) input for all data,including coefficients. For determining the filter coefficients I have used Matlab fdatool (If you have another easier ,and more importantly ,free tools to implement this task,please tell me). The problem is that either by exporting the coefficients (SOS form,Direct Form I ) to Matlab workspace or by generating C header file it is unclear to me which coefficients I should place in my API - I have 3 sections (stages) and I am required to give the coefficients in a form of : {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...} where b1x and a1x are the coefficients for the first stage, b2x and a2x are the coefficients for the second stage, and so on. The array contains a total of 5*numStages values. ( API full description is given at http://tech.munts.com/MCU/Frameworks/ARM/stm32f4/libs/STM32F4xx_DSP_StdPeriph_Lib_V1.0.0/Libraries/CMSIS/Documentation/DSP_Lib/html/group___biquad_cascade_d_f1.html ) So the question is how can I extract the coefficients either from Matlab workspace or from c header file ? Thank You

# using fdatool and cmsis

Started by ●January 14, 2012

Posted by ●January 15, 2012

On Sat, 14 Jan 2012 15:06:04 -0600, Vl4ever wrote:> Hi ,all > I am currently trying to implement Chebyshev Type I filter on embedded > microcontroller - STM32F101 (using C language).This is a microcontroller > of ARM cortex M3 type.It is possible to implement this filter in IIR > form using CMSIS-DSP APIs.These APIs require single-point precision > (floating) input for all data,including coefficients. For determining > the filter coefficients I have used Matlab fdatool (If you have another > easier ,and more importantly ,free tools to implement this task,please > tell me). > The problem is that either by exporting the coefficients (SOS > form,Direct Form I ) to Matlab workspace or by generating C header file > it is unclear to me which coefficients I should place in my API - I have > 3 sections (stages) and I am required to give the coefficients in a form > of : > {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...} > where b1x and a1x are the coefficients for the first stage, b2x and a2x > are the coefficients for the second stage, and so on. The array > contains a total of 5*numStages values. > ( API full description is given at > http://tech.munts.com/MCU/Frameworks/ARM/stm32f4/libs/STM32F4xx_DSP_StdPeriph_Lib_V1.0.0/Libraries/CMSIS/Documentation/DSP_Lib/ html/group___biquad_cascade_d_f1.html> ) > So the question is how can I extract the coefficients either from Matlab > workspace or from c header file ?The problem with working with tools that do all the thinking for you is that even if you are equipped to do the thinking yourself, you often have to reverse-engineer the tools' results if you need to do something off of the path that the tool designer laid out for you. Can you identify the coefficients for the filter that fdatool is generating, and are they separated (or can you separate them) into groups of individual 2nd-order filter functions? If so, then the coefficients for each one of those filter stages is probably the coefficients that you need to enter into your set-up code. Beyond that -- well, the world is awash with DSP tools, many of them flawed, and I don't keep track of how each one works. -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com

Posted by ●January 15, 2012

what you can do is to find the roots of numerator and denominator polynomial. Then take pairs of conjugates, multiply each out and you've got the coefficients for a second order stage. The required matlab functions are roots() and poly(), i.e. roots(poly(vec)) == vec. This could serve as a starting point :>> [b, a] = cheby1(10, 0.5, 0.5) >> figure(); grid on; hold on; plot(roots(b), 'ro'); plot(roots(a), 'xb');

Posted by ●January 16, 2012

>On Sat, 14 Jan 2012 15:06:04 -0600, Vl4ever wrote: > >> Hi ,all >> I am currently trying to implement Chebyshev Type I filter on embedded >> microcontroller - STM32F101 (using C language).This is amicrocontroller>> of ARM cortex M3 type.It is possible to implement this filter in IIR >> form using CMSIS-DSP APIs.These APIs require single-point precision >> (floating) input for all data,including coefficients. For determining >> the filter coefficients I have used Matlab fdatool (If you have another >> easier ,and more importantly ,free tools to implement this task,please >> tell me). >> The problem is that either by exporting the coefficients (SOS >> form,Direct Form I ) to Matlab workspace or by generating C header file >> it is unclear to me which coefficients I should place in my API - Ihave>> 3 sections (stages) and I am required to give the coefficients in aform>> of : >> {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...} >> where b1x and a1x are the coefficients for the first stage, b2x and a2x >> are the coefficients for the second stage, and so on. The array >> contains a total of 5*numStages values. >> ( API full description is given at >> http://tech.munts.com/MCU/Frameworks/ARM/stm32f4/libs/ >STM32F4xx_DSP_StdPeriph_Lib_V1.0.0/Libraries/CMSIS/Documentation/DSP_Lib/ >html/group___biquad_cascade_d_f1.html >> ) >> So the question is how can I extract the coefficients either fromMatlab>> workspace or from c header file ? > >The problem with working with tools that do all the thinking for you is >that even if you are equipped to do the thinking yourself, you often have>to reverse-engineer the tools' results if you need to do something off of>the path that the tool designer laid out for you. > >Can you identify the coefficients for the filter that fdatool is >generating, and are they separated (or can you separate them) into groups>of individual 2nd-order filter functions? If so, then the coefficients >for each one of those filter stages is probably the coefficients that you>need to enter into your set-up code. > >Beyond that -- well, the world is awash with DSP tools, many of them >flawed, and I don't keep track of how each one works. > >-- >Tim Wescott >Control system and signal processing consulting >www.wescottdesign.com >First of all,thank you for your response.Yes,I am able to see the coefficients in Matlab workspace ( It is called SOS and it is 3x6 matrice with numbers ,and according to documentation ,those ARE the coefficients).But beside of this there is another vector,which is called G and this is probably the gain and it is 4x1 ,and it is getting me confused - what should I multiply with this vector-all the matrice ,or just part of that?) Well , how would you calculate those coefficients 'manually' ,could you give me a direction to a right path ? Thank You.

Posted by ●January 16, 2012

On Jan 16, 6:25�am, "Vl4ever" <moikef@n_o_s_p_a_m.gmail.com> wrote:> >On Sat, 14 Jan 2012 15:06:04 -0600, Vl4ever wrote: > > >> Hi ,all > >> I am currently trying to implement Chebyshev Type I filter on embedded > >> microcontroller - STM32F101 (using C language).This is a > microcontroller > >> of ARM cortex M3 type.It is possible to implement this filter in IIR > >> form using CMSIS-DSP APIs.These APIs require single-point precision > >> (floating) input for all data,including coefficients. For determining > >> the filter coefficients I have used Matlab fdatool (If you have another > >> easier ,and more importantly ,free tools to implement this task,please > >> tell me). > >> The problem is that either by exporting the coefficients (SOS > >> form,Direct Form I ) to Matlab workspace or by generating C header file > >> it is unclear to me which coefficients I should place in my API - I > have > >> 3 sections (stages) and I am required to give the coefficients in a > form > >> of : > >> �{b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...} > >> where b1x and a1x are the coefficients for the first stage, b2x and a2x > >> are the coefficients for the second stage, and so on. The �array > >> contains a total of 5*numStages values. > >> ( API full description is given at > >>http://tech.munts.com/MCU/Frameworks/ARM/stm32f4/libs/ > >STM32F4xx_DSP_StdPeriph_Lib_V1.0.0/Libraries/CMSIS/Documentation/DSP_Lib/ > >html/group___biquad_cascade_d_f1.html > >> ) > >> So the question is how can I extract the coefficients either from > Matlab > >> workspace or from c header file ? > > >The problem with working with tools that do all the thinking for you is > >that even if you are equipped to do the thinking yourself, you often have > >to reverse-engineer the tools' results if you need to do something off of > >the path that the tool designer laid out for you. > > >Can you identify the coefficients for the filter that fdatool is > >generating, and are they separated (or can you separate them) into groups > >of individual 2nd-order filter functions? �If so, then thecoefficients> >for each one of those filter stages is probably the coefficients that you > >need to enter into your set-up code. > > >Beyond that -- well, the world is awash with DSP tools, many of them > >flawed, and I don't keep track of how each one works. > > >-- > >Tim Wescott > >Control system and signal processing consulting > >www.wescottdesign.com > > First of all,thank you for your response.Yes,I am able to see the > coefficients in Matlab workspace ( It is called SOS and it is 3x6 matrice > with numbers ,and according to documentation ,those ARE the > coefficients).But beside of this there is another vector,which is called G > and this is probably the gain and it is 4x1 ,and it is getting me confused > - what should I multiply with this vector-all the matrice ,or just part of > that?) > Well , how would you calculate those coefficients 'manually' ,could you > give me a direction to a right path ? Thank You.- Hide quoted text - > > - Show quoted text -In the documentation for fdatool it tells you that each row of SOS matrix is a 2nd order section, first three entries are the numerator and last three entries are the denominator. The corresponding row of the gain matrix is the gain applied to that 2nd order section. The last row of the gain matrix is the gain applied to the over filter. It's all right there in the documentation. Maurice Givens

Posted by ●January 16, 2012

> The >last row of the gain matrix is the gain applied to the over filter. >It's all right there in the documentation. > >Maurice Givens >Could you point me to the documentation ? Thank You. This could sound as a dumb question ,but what do you mean by gain applied to the over filter? Does that mean that multiplication is applied after the first three multiplications? or beforehand?

Posted by ●January 16, 2012

On 1/16/2012 1:32 PM, Vl4ever wrote:>> The >> last row of the gain matrix is the gain applied to the over filter. >> It's all right there in the documentation. >> >> Maurice Givens >> > Could you point me to the documentation ? Thank You. > This could sound as a dumb question ,but what do you mean by gain applied > to the over filter? Does that mean that multiplication is applied after the > first three multiplications? or beforehand?Typo. Read "overall". If I'm not mistaken it should be the product of the other three gains. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Posted by ●January 17, 2012

>On 1/16/2012 1:32 PM, Vl4ever wrote: >>> The >>> last row of the gain matrix is the gain applied to the over filter. >>> It's all right there in the documentation. >>> >>> Maurice Givens >>> >> Could you point me to the documentation ? Thank You. >> This could sound as a dumb question ,but what do you mean by gainapplied>> to the over filter? Does that mean that multiplication is applied afterthe>> first three multiplications? or beforehand? > >Typo. Read "overall". If I'm not mistaken it should be the product of >the other three gains. > >Jerry >-- >Engineering is the art of making what you want from things you can get. >����������������������������������������������������������������������� >All right.And what should I do with that ?

Posted by ●January 17, 2012

On Tue, 17 Jan 2012 03:08:17 -0600, "Vl4ever" <moikef@n_o_s_p_a_m.gmail.com> wrote: [snip]>All right.And what should I do with that ?Maybe you should look at rbj's Audio EQ Cookbook. http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt

Posted by ●January 17, 2012

On Sat, 14 Jan 2012 15:06:04 -0600, "Vl4ever" <moikef@n_o_s_p_a_m.gmail.com> wrote: [snip]>The problem is that either by exporting the coefficients (SOS form,Direct >Form I ) to Matlab workspace or by generating C header file it is unclear >to me which coefficients I should place in my API - I have 3 sections >(stages) and I am required to give the coefficients in a form of : > {b10, b11, b12, a11, a12, b20, b21, b22, a21, a22, ...} >where b1x and a1x are the coefficients for the first stage, b2x and a2x are[snip]>So the question is how can I extract the coefficients either from Matlab >workspace or from c header file ? >Thank You >This whole post is kind of nut balls. I mean the guy has the manuals for the API and for MATLAB at his disposal. IT is not hard to match them up and make the application work. Unless the numbering is just totally insane this should be plug and play from MATLAB. Mark DeArman