Reply by Jerry Avins August 21, 20032003-08-21
santosh nath wrote:
> > Jerry Avins <jya@ieee.org> wrote in message news:<3F43E184.9C8DD216@ieee.org>... > > santosh nath wrote: > > > > > > Jim Thomas <jthomas@bittware.com> wrote in message news:<3F4385C1.F6231ADE@bittware.com>... > > > > News wrote: > > > > > > > > > my question is why need to multiply by 32768, and what's the Q15 format? > > > > > > > > Ah... they are related. Q15 is a way of representing numbers between a > > > > little less than 1.0 and -1.0 with 16 bits. It is also called "1.15". > > > > The ms bit is the sign bit. The binary point (akin to the decimal > > > > point, but since the number is in binary rather than decimal, we can't > > > > call it a decimal point) follows the sign bit. The remaining bits are > > > > weighted by 2^(n-15), where n is the bit number (the ls bit being bit > > > > 0). > > > > > > > > The easiset way to convert a number to Q15 is by multiplying it by > > > > 32768. So to get 0.5 in Q15, we multiply it by 32768 (0x8000): 0.5 * > > > > 0x8000 = 0x4000. Note that the only bit equal to 1 here is bit14, and > > > > 2^(14-15) = 2^(-1) = 0.5 which is where we started. > > > > > > If the "number" is a fractional number (as you also show in an > > > example) then what you say is correct and represents Q15 format. It > > > would be nice if you > > > highlight how to convert a floating point number to a Q format. > > > > > > For example, 7.1345, 18.6789, 154.3565 are three floating point > > > numbers representing samples of a signal how to convert them in Q9 and > > > what is the percentage reduction in precision (relative error) for > > > each of them? > > > > > > Regards, > > > Santosh > > > > Multiply by 512.0 (2^9) and cast to int. To see the error, cast back to > > float, divide by 512.0, and compare. > > > > Your first sentence trancates decimal points of the product floating > numbers to zero. The second sentence gives the error between derived > number and actual number but it does not serve the inner meaning of my > question. Is Q format achieved by your operation? I guess - no. > Secondly I was hinting the problem > of Q format when a number is represented wrongly in Q format and even > if it represented correctly it looses precision. > Regards, > Santosh > > Jerry
If I goofed the numbers, then what I wrote is wrong in detail, but the idea remains. (I have no time to check right now.) Representing a number with many bits in a format that has a smaller number necessarily loses precision. Shoehorning the number into a particular format, such as Q9, may well give up more precision. There are too many ways for a number to be wrongly represented to make the general case worth thinking about. As far as I know, Q9 means that there are nine bits available for representing the fractional part of a number and (with 16-bits total), six bits for the integer part. That's what you have to work with. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Reply by santosh nath August 21, 20032003-08-21
Jerry Avins <jya@ieee.org> wrote in message news:<3F43E184.9C8DD216@ieee.org>...
> santosh nath wrote: > > > > Jim Thomas <jthomas@bittware.com> wrote in message news:<3F4385C1.F6231ADE@bittware.com>... > > > News wrote: > > > > > > > my question is why need to multiply by 32768, and what's the Q15 format? > > > > > > Ah... they are related. Q15 is a way of representing numbers between a > > > little less than 1.0 and -1.0 with 16 bits. It is also called "1.15". > > > The ms bit is the sign bit. The binary point (akin to the decimal > > > point, but since the number is in binary rather than decimal, we can't > > > call it a decimal point) follows the sign bit. The remaining bits are > > > weighted by 2^(n-15), where n is the bit number (the ls bit being bit > > > 0). > > > > > > The easiset way to convert a number to Q15 is by multiplying it by > > > 32768. So to get 0.5 in Q15, we multiply it by 32768 (0x8000): 0.5 * > > > 0x8000 = 0x4000. Note that the only bit equal to 1 here is bit14, and > > > 2^(14-15) = 2^(-1) = 0.5 which is where we started. > > > > If the "number" is a fractional number (as you also show in an > > example) then what you say is correct and represents Q15 format. It > > would be nice if you > > highlight how to convert a floating point number to a Q format. > > > > For example, 7.1345, 18.6789, 154.3565 are three floating point > > numbers representing samples of a signal how to convert them in Q9 and > > what is the percentage reduction in precision (relative error) for > > each of them? > > > > Regards, > > Santosh > > Multiply by 512.0 (2^9) and cast to int. To see the error, cast back to > float, divide by 512.0, and compare. >
Your first sentence trancates decimal points of the product floating numbers to zero. The second sentence gives the error between derived number and actual number but it does not serve the inner meaning of my question. Is Q format achieved by your operation? I guess - no. Secondly I was hinting the problem of Q format when a number is represented wrongly in Q format and even if it represented correctly it looses precision. Regards, Santosh
> Jerry
Reply by Jerry Avins August 20, 20032003-08-20
santosh nath wrote:
> > Jim Thomas <jthomas@bittware.com> wrote in message news:<3F4385C1.F6231ADE@bittware.com>... > > News wrote: > > > > > my question is why need to multiply by 32768, and what's the Q15 format? > > > > Ah... they are related. Q15 is a way of representing numbers between a > > little less than 1.0 and -1.0 with 16 bits. It is also called "1.15". > > The ms bit is the sign bit. The binary point (akin to the decimal > > point, but since the number is in binary rather than decimal, we can't > > call it a decimal point) follows the sign bit. The remaining bits are > > weighted by 2^(n-15), where n is the bit number (the ls bit being bit > > 0). > > > > The easiset way to convert a number to Q15 is by multiplying it by > > 32768. So to get 0.5 in Q15, we multiply it by 32768 (0x8000): 0.5 * > > 0x8000 = 0x4000. Note that the only bit equal to 1 here is bit14, and > > 2^(14-15) = 2^(-1) = 0.5 which is where we started. > > If the "number" is a fractional number (as you also show in an > example) then what you say is correct and represents Q15 format. It > would be nice if you > highlight how to convert a floating point number to a Q format. > > For example, 7.1345, 18.6789, 154.3565 are three floating point > numbers representing samples of a signal how to convert them in Q9 and > what is the percentage reduction in precision (relative error) for > each of them? > > Regards, > Santosh
Multiply by 512.0 (2^9) and cast to int. To see the error, cast back to float, divide by 512.0, and compare. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Reply by santosh nath August 20, 20032003-08-20
Jim Thomas <jthomas@bittware.com> wrote in message news:<3F4385C1.F6231ADE@bittware.com>...
> News wrote: > > > my question is why need to multiply by 32768, and what's the Q15 format? > > Ah... they are related. Q15 is a way of representing numbers between a > little less than 1.0 and -1.0 with 16 bits. It is also called "1.15". > The ms bit is the sign bit. The binary point (akin to the decimal > point, but since the number is in binary rather than decimal, we can't > call it a decimal point) follows the sign bit. The remaining bits are > weighted by 2^(n-15), where n is the bit number (the ls bit being bit > 0). > > The easiset way to convert a number to Q15 is by multiplying it by > 32768. So to get 0.5 in Q15, we multiply it by 32768 (0x8000): 0.5 * > 0x8000 = 0x4000. Note that the only bit equal to 1 here is bit14, and > 2^(14-15) = 2^(-1) = 0.5 which is where we started.
If the "number" is a fractional number (as you also show in an example) then what you say is correct and represents Q15 format. It would be nice if you highlight how to convert a floating point number to a Q format. For example, 7.1345, 18.6789, 154.3565 are three floating point numbers representing samples of a signal how to convert them in Q9 and what is the percentage reduction in precision (relative error) for each of them? Regards, Santosh
Reply by Jim Thomas August 20, 20032003-08-20
News wrote:

> my question is why need to multiply by 32768, and what's the Q15 format?
Ah... they are related. Q15 is a way of representing numbers between a little less than 1.0 and -1.0 with 16 bits. It is also called "1.15". The ms bit is the sign bit. The binary point (akin to the decimal point, but since the number is in binary rather than decimal, we can't call it a decimal point) follows the sign bit. The remaining bits are weighted by 2^(n-15), where n is the bit number (the ls bit being bit 0). The easiset way to convert a number to Q15 is by multiplying it by 32768. So to get 0.5 in Q15, we multiply it by 32768 (0x8000): 0.5 * 0x8000 = 0x4000. Note that the only bit equal to 1 here is bit14, and 2^(14-15) = 2^(-1) = 0.5 which is where we started. -- Jim Thomas Principal Applications Engineer Bittware, Inc jthomas@bittware.com http://www.bittware.com (703) 779-7770 Getting an inch of snow is like winning ten cents in the lottery - Calvin
Reply by News August 20, 20032003-08-20
Hi,

i am trying to implement DTMF detection by using goertzel algorithm

But i have meet some questions:

1. How can i  determine coefficient for filter frequency?

    I know that coefficient=  cos(2*pi*k/N)*32768, where k= (N*fi)/fs , fi=
filter frequency fs= sample frequency

for example, for 1209hz the correspond coefficient is
cos(2*pi*15.42/102)*32768=19073, assume that N=102

my question is why need to multiply by 32768, and what's the Q15 format?

Thnaks











-- 
Change your thought and you change the world.