Sign in

username:

password:



Not a member?

Search c54x



Search tips

Subscribe to c54x



c54x by Keywords

5409 | 5416 | AD5 | ADC | BIOS | Boot | Booting | Bootloader | C540 | C5402 | C5409 | C5416 | CCS | Codec | DMA | Dmad | DSK | DSKPlus | Dsplib | EVM | FFT | FIR | Flash | GPIO | HPI | Initialization | Interrupt | JTAG | LOG_printf | MCBSP | RFFT | RTDX | Sampling | STLM | UART | VC540

Ads

Discussion Groups

Discussion Groups | TMS320C54x | Re: [Fwd: Re: code working on simulator but not on device?]

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).

  

Post a new Thread

Re: [Fwd: Re: code working on simulator but not on device?] - Jeff Brower - May 18 8:37:06 2006



Megha-

> I had a query in Q format. I am using iircas51 for IIR filter. In that
> the coefficient data type should be DATA thats defined as short. So my
> query is its not necessary to use Q15 format. I can aswell use Q2.13
> format.  But jeff is there any function to convert float to Q2.13 as
> there is for float to Q15.

To convert floating-point coefficients to Q13, multiply by 8192 (instead
of 32768 for Q15).

I.e. multiplier = 2 ^^ Q

This assumes all of your coefficients are less than +/- 4.0

-Jeff

> Jeff Brower <j...@signalogic.com> wrote:   Megha- I had one question.
> In functions like butter (for filters) we declare a variable Wn (the cut
> off frequency). ex: [B,A] = BUTTER(N,Wn). In this Wn value is between 0
> and 1, where 1 means half of sampling rate. What I am not understanding is
> where is it getting sample rate value from. I saw some codes and in that
> the sample rate value is not declared before using the command. Directly
> the command is used. Where is it getting sample rate value from?
> What I understand is suppose I have to run that filter design on an AIC.
> And AIC is set at some sampling rate ex 48KHz. Then the code is
> understanding that sample rate and setting Wn accordingly. Kindly correct
> me if I am wrong.
> If your actual sampling rate is 48 kHz, and you want lowpass Butterworth
> filter with 2 kHz cutoff, then set Wn = 0.0833.
> Digital filters don't "know" the actual analog sampling rate; they only
> know the Z-plane unit circle, or 0 to 1 as you mention.  In this example,
> if you vary the sampling rate (reprogram the AIC) then the filter cutoff
> is always 0.0833*fs/2.
> -Jeff
>
> Jeff Brower <j...@signalogic.com> wrote:  Megha-
>   I tried getting more material on maxflat but I am not getting much. I am
> not understanding what exactly SOS and G stand for.
> If I want coeff for IIRCAS51 (cascaded IIR filter design with biquads qith
> 5 coefficients) I want 3 coeff for zero (numerator) and 2 for poles
> (denominator). I am not getting how to get those. i am not understanding
> what does what stand for.
> Maxflat() is for Butterworth IIR filter design.  It's one option -- you
> also might want Chebyshev or elliptic design.Another MATLAB function for
> converting direct-form transfer function to cascade of biquad sections is
> tf2sos().  Here are some pages that might give you some clues:
> http://www.math.psu.edu/local_doc/matlab/toolbox/signal/tf2sos.html
> http://www.ee.ic.ac.uk/pcheung/teaching/ee3_Study_Project/iir_lab2.pdf-Jeff
> Jeff Brower <j...@signalogic.com> wrote:  Megha-
>  > This is in continuation to my previous mail. I also tried with a
> breakpoint at my
>> next statement after fltoq15. If I run that. It stops in between and
>> gives the
>> error:
>> Trouble running Target CPU: Attempted write to ROM at Addr:0x00ffff,
>> Page:0
>> I guess it is because of the infinite loop thing. Kindly reply and
>> suggest
>> something.Waiting for your reply.Your code is trying to write somwhere
>> in mem locations 0x8000-0xffff, which are
> external Flash as you mentioned before. Writing directly to Flash area
> won't work
> (although there is a way, which involves a series of Flash chip-specific
> commands).
> You have to check the C code ptr and array address values just before the
> breakpoint
> to see why they are not pointing at onchip or offchip SRAM.Also, did you
> see the c55x group thread about IIR cascade fixed-point filters? I've
> included a copy of the latest message below. If you're not subscribed to
> the c55x
> group, you should. C55xx devices are the next generation after C54xx --
> both 16-bit
> fixed-point.-Jeff
>  -------- Original Message --------
> Subject: Re: [c55x] IIR filter coefficients in iircas5 dsplib
> Date: Tue, 16 May 2006 08:37:25 +0200
> From: Christian Narvaez
> To: c...@yahoogroups.com thanks Misan, thanks RK:
> indeed this was the problem... I have successfully implemented the
> filter now.CNnasim ahmed ha scritto:
>> hi christian,
>> u r trying to get q14 fixed point format but dsplib
>> has q15 format, i suggest u to use both in same format . u can
>> multiply with 2^15 . And two q15 multiplication results q2.30. here 2
>> sign bit presents so u hav to modify that according to ur desired
>> output format. i hope it will help u , if u hav any prob u can send me
>> message.
>>
>> regards misan
>>
>> */Christian Narvaez /* wrote:
>>
>> Hi,
>> I am having a problem trying to implement an IIR filter on an TI c55x.
>> I have calculated the filter on matlab getting the following
>> coefficients for 2 second order sections:
>>
>> SOS
>> 1.0000 1.6854 1.0000 1.0000 -1.7197 0.8565
>> 1.0000 -1.9999 1.0000 1.0000 -1.8899 0.9250
>> G
>> 1.0000
>> 0.1041
>> 1.0000
>>
>> Simulations perform as expected.
>> Since the coefficients are between ]-2..2[ I transform the SOS matrix
>> as SOS_fix = SOS*2^14:
>>
>> SOS_fix
>> 16384 27614 16384 16384 -28175 14033
>> 16384 -32766 16384 16384 -30964 15155
>>
>> The question is: can I run this coefficients on iircas5 of the TI
>> dsplib? I know dsplib is Q.15 while my coefficients are Q.14, but I
>> suppose this is not a problem if the filter's input is small
>> enough not
>> to cause any overflow. Unfortunately this does not work, the
>> output is
>> completely wrong.
>>
>> The second think I tried was to multiply the numerator
>> coefficients of
>> the second section of the filter by 0.1041 (according to G), before
>> converting them to Q.14, getting this:
>>
>> SOS_fix_G
>> 16384 27614 16384 16384 -28175 14033
>> 1706 -3412 1706 16384 -30964 15155
>>
>> But this also does not work.
>>
>> Does anyone have any idea how I should convert my coefficients in
>> order
>> to work with iircas5?
>>
>> Thanks.
>>
>> Christian
>
> ---------------------------------
> New Yahoo! Messenger with Voice. Call regular phones from your PC and save
> big.



(You need to be a member of c54x -- send a blank email to c54x-subscribe@yahoogroups.com )

Re: [Fwd: Re: code working on simulator but not on device?] - megha daga - May 18 14:21:32 2006

Dear Jeff
Thanks for the reply. But I guess I need the format in Q15 to use it in the command iircas51.
Even if I convert it to Q13, it wont work. 
Can you suggest a method so that I can quantize/normalize my whole data between 1 and -1. After
that I can convert it into Q15 and I guess that should work.
Kindly reply.
Thanking You
Megha Daga

Jeff Brower <j...@signalogic.com> wrote: Megha-

> I had a query in Q format. I am using iircas51 for IIR filter. In that
> the coefficient data type should be DATA thats defined as short. So my
> query is its not necessary to use Q15 format. I can aswell use Q2.13
> format.  But jeff is there any function to convert float to Q2.13 as
> there is for float to Q15.

To convert floating-point coefficients to Q13, multiply by 8192 (instead
of 32768 for Q15).

I.e. multiplier = 2 ^^ Q

This assumes all of your coefficients are less than +/- 4.0

-Jeff

> Jeff Brower  wrote:   Megha- I had one question.
> In functions like butter (for filters) we declare a variable Wn (the cut
> off frequency). ex: [B,A] = BUTTER(N,Wn). In this Wn value is between 0
> and 1, where 1 means half of sampling rate. What I am not understanding is
> where is it getting sample rate value from. I saw some codes and in that
> the sample rate value is not declared before using the command. Directly
> the command is used. Where is it getting sample rate value from?
> What I understand is suppose I have to run that filter design on an AIC.
> And AIC is set at some sampling rate ex 48KHz. Then the code is
> understanding that sample rate and setting Wn accordingly. Kindly correct
> me if I am wrong.
> If your actual sampling rate is 48 kHz, and you want lowpass Butterworth
> filter with 2 kHz cutoff, then set Wn = 0.0833.
> Digital filters don't "know" the actual analog sampling rate; they only
> know the Z-plane unit circle, or 0 to 1 as you mention.  In this example,
> if you vary the sampling rate (reprogram the AIC) then the filter cutoff
> is always 0.0833*fs/2.
> -Jeff
>
> Jeff Brower  wrote:  Megha-
>   I tried getting more material on maxflat but I am not getting much. I am
> not understanding what exactly SOS and G stand for.
> If I want coeff for IIRCAS51 (cascaded IIR filter design with biquads qith
> 5 coefficients) I want 3 coeff for zero (numerator) and 2 for poles
> (denominator). I am not getting how to get those. i am not understanding
> what does what stand for.
> Maxflat() is for Butterworth IIR filter design.  It's one option -- you
> also might want Chebyshev or elliptic design.Another MATLAB function for
> converting direct-form transfer function to cascade of biquad sections is
> tf2sos().  Here are some pages that might give you some clues:
> http://www.math.psu.edu/local_doc/matlab/toolbox/signal/tf2sos.html
> http://www.ee.ic.ac.uk/pcheung/teaching/ee3_Study_Project/iir_lab2.pdf-Jeff
> Jeff Brower  wrote:  Megha-
>  > This is in continuation to my previous mail. I also tried with a
> breakpoint at my
>> next statement after fltoq15. If I run that. It stops in between and
>> gives the
>> error:
>> Trouble running Target CPU: Attempted write to ROM at Addr:0x00ffff,
>> Page:0
>> I guess it is because of the infinite loop thing. Kindly reply and
>> suggest
>> something.Waiting for your reply.Your code is trying to write somwhere
>> in mem locations 0x8000-0xffff, which are
> external Flash as you mentioned before. Writing directly to Flash area
> won't work
> (although there is a way, which involves a series of Flash chip-specific
> commands).
> You have to check the C code ptr and array address values just before the
> breakpoint
> to see why they are not pointing at onchip or offchip SRAM.Also, did you
> see the c55x group thread about IIR cascade fixed-point filters? I've
> included a copy of the latest message below. If you're not subscribed to
> the c55x
> group, you should. C55xx devices are the next generation after C54xx --
> both 16-bit
> fixed-point.-Jeff
>  -------- Original Message --------
> Subject: Re: [c55x] IIR filter coefficients in iircas5 dsplib
> Date: Tue, 16 May 2006 08:37:25 +0200
> From: Christian Narvaez
> To: c...@yahoogroups.com thanks Misan, thanks RK:
> indeed this was the problem... I have successfully implemented the
> filter now.CNnasim ahmed ha scritto:
>> hi christian,
>> u r trying to get q14 fixed point format but dsplib
>> has q15 format, i suggest u to use both in same format . u can
>> multiply with 2^15 . And two q15 multiplication results q2.30. here 2
>> sign bit presents so u hav to modify that according to ur desired
>> output format. i hope it will help u , if u hav any prob u can send me
>> message.
>>
>> regards misan
>>
>> */Christian Narvaez /* wrote:
>>
>> Hi,
>> I am having a problem trying to implement an IIR filter on an TI c55x.
>> I have calculated the filter on matlab getting the following
>> coefficients for 2 second order sections:
>>
>> SOS
>> 1.0000 1.6854 1.0000 1.0000 -1.7197 0.8565
>> 1.0000 -1.9999 1.0000 1.0000 -1.8899 0.9250
>> G
>> 1.0000
>> 0.1041
>> 1.0000
>>
>> Simulations perform as expected.
>> Since the coefficients are between ]-2..2[ I transform the SOS matrix
>> as SOS_fix = SOS*2^14:
>>
>> SOS_fix
>> 16384 27614 16384 16384 -28175 14033
>> 16384 -32766 16384 16384 -30964 15155
>>
>> The question is: can I run this coefficients on iircas5 of the TI
>> dsplib? I know dsplib is Q.15 while my coefficients are Q.14, but I
>> suppose this is not a problem if the filter's input is small
>> enough not
>> to cause any overflow. Unfortunately this does not work, the
>> output is
>> completely wrong.
>>
>> The second think I tried was to multiply the numerator
>> coefficients of
>> the second section of the filter by 0.1041 (according to G), before
>> converting them to Q.14, getting this:
>>
>> SOS_fix_G
>> 16384 27614 16384 16384 -28175 14033
>> 1706 -3412 1706 16384 -30964 15155
>>
>> But this also does not work.
>>
>> Does anyone have any idea how I should convert my coefficients in
>> order
>> to work with iircas5?
>>
>> Thanks.
>>
>> Christian
>
> ---------------------------------
> New Yahoo! Messenger with Voice. Call regular phones from your PC and save
> big.

---------------------------------
New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.


(You need to be a member of c54x -- send a blank email to c54x-subscribe@yahoogroups.com )