Float_to_fix conversion

General discussion on mikroC for dsPIC30/33 and PIC24.
Post Reply
Author
Message
elclerisi
Posts: 8
Joined: 28 Nov 2006 13:41
Location: BUENOS AIRES, ARGENTINA

Float_to_fix conversion

#1 Post by elclerisi » 28 Sep 2007 19:05

I´m experimenting with FFt functions, and need to build up a 1034 twiddle factors table in radix 1.15 format.
The code I have to generate this table is the folowing:

[ float real, imag;

void main(){

int i, nn;
float frec ,pi;

nn = 1034;//array lenght
nn = nn/2;

pi = 4.0* atan(1.0);


frec = 2.0*pi*0.5/(float)nn;

for ( i=0; i<=nn-1; i++){

real = cos((float)i*frec); //real coefficients
imag = sin((float)i*frec); //imag coefficients

}

}]

Since the results are in float format, I need an algorithm to convert this array to radix 1.15, as requires the dsPICMIkroC FFT functions.
If there is someone who knows the matter, I´ll be glad to get the solution.

thanks,
Ricardo.

[/code]

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

Re: Float_to_fix conversion

#2 Post by zristic » 01 Oct 2007 09:05

Image

elclerisi
Posts: 8
Joined: 28 Nov 2006 13:41
Location: BUENOS AIRES, ARGENTINA

#3 Post by elclerisi » 10 Oct 2007 11:49

Thanks for your answer. It works all right.
Best regards.

biglobe
Posts: 2
Joined: 15 Aug 2011 07:43

Re:

#4 Post by biglobe » 15 Aug 2011 10:18

elclerisi wrote:Thanks for your answer. It works all right.
Best regards.
Hi, can anyone repost the answer given by zristic?

I am new to FFT and I would like to understand how the twiddle factors are generated. I can understand the code from the thread starter however I cannot figure out how to represent the complex number in hex format, which I presume is in radix 1.15?

Please advise anyone. Thanks.

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

Re: Float_to_fix conversion

#5 Post by zristic » 16 Aug 2011 08:33

http://ww1.microchip.com/downloads/en/D ... 70049D.pdf

If you divide integer by 32768 you will get the value in radix point.
Attachments
Radix point
Radix point
Capture_498.jpg (76.01 KiB) Viewed 3775 times

Post Reply

Return to “mikroC for dsPIC30/33 and PIC24 General”