DSPRelated.com
Forums

Magnitude by summing |I| & |Q|

Started by Thomas Magma September 3, 2008
Hello,

I'm trying to write a very efficient and fast detection algorithm for a 
dsPIC. I've already been down the path of the Goertzel and have dismissed it 
because of it's use of floating point numbers. I am now using a modified DFT 
and would like to get rid of the square root algorithm that calculates the 
magnitude of  I & Q. It seems to me that simply summing (the accumulated) I 
& Q channels it will give you a cheap and dirty indication of gain. Summing 
their absolute values, that is. Does anyone see anything wrong with this? 
Are there any draw backs of doing this?

Thomas 


On Sep 3, 1:50&#4294967295;pm, "Thomas Magma" <somewh...@overtherainbow.com>
wrote:
> Hello, > > I'm trying to write a very efficient and fast detection algorithm for a > dsPIC. I've already been down the path of the Goertzel and have dismissed it > because of it's use of floating point numbers. I am now using a modified DFT > and would like to get rid of the square root algorithm that calculates the > magnitude of &#4294967295;I & Q. It seems to me that simply summing (the accumulated) I > & Q channels it will give you a cheap and dirty indication of gain. Summing > their absolute values, that is. Does anyone see anything wrong with this? > Are there any draw backs of doing this? > > Thomas
Make a surface plot (output on Z, and actual values of I and Q on the X and Y axes) and compare the two approaches. Where are they most similar? Where are they most dissimilar? Julius
On Sep 3, 2:50&#4294967295;pm, "Thomas Magma" <somewh...@overtherainbow.com>
wrote:
> Hello, > > I'm trying to write a very efficient and fast detection algorithm for a > dsPIC. I've already been down the path of the Goertzel and have dismissed it > because of it's use of floating point numbers. I am now using a modified DFT > and would like to get rid of the square root algorithm that calculates the > magnitude of &#4294967295;I & Q. It seems to me that simply summing (the accumulated) I > & Q channels it will give you a cheap and dirty indication of gain. Summing > their absolute values, that is. Does anyone see anything wrong with this? > Are there any draw backs of doing this? > > Thomas
Thomas, Search this topic in this group. It's been discusssed. Dirk

Thomas Magma wrote:

> Hello, > > I'm trying to write a very efficient and fast detection algorithm for a > dsPIC.
To detect what?
> I've already been down the path of the Goertzel and have dismissed it > because of it's use of floating point numbers.
Goertzel can be done in the integer math.
> I am now using a modified DFT
There is no point. With dsPIC, Goertzel is more efficient then I/Q accumulation.
> and would like to get rid of the square root algorithm that calculates the > magnitude of I & Q.
sqrt(I^2 + Q^2) ~ max(|I|,|Q|) + (min(|I|,|Q|) >> 2) The error is less then 10% BTW, in R. Lyons book, there is a chapter about sqrt(I^2 + Q^2) approximation.
> It seems to me that simply summing (the accumulated) I > & Q channels it will give you a cheap and dirty indication of gain. Summing > their absolute values, that is. Does anyone see anything wrong with this?
Max. error ~ 40% Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
> > There is no point. With dsPIC, Goertzel is more efficient then I/Q > accumulation. >
Actually, the Goertzel is terribly inefficient with the dsPIC, at least when using floating point and the C30 compiler. Floating point addition, subtraction and multiplication take hundreds of cycles to complete on the dsPIC. I couldn't find any good examples of the Goertzel done with integers. Using the floating point Goertzel I was something like 1000 times the required processing time, now with an integer DFT using a look-up sin/cos table I am less than 10 percent over the required processing time. I am very close to my target, hence my original question.
>Max. error ~ 40%
Where do you get 40% from. All I'm doing is tone detection where the gain triggers a preset value. Are you saying that there is 40% noise on the magnitude output? This might be acceptable depending where my noise floor is and where I set my trigger value. Thomas

Thomas Magma wrote:

>>There is no point. With dsPIC, Goertzel is more efficient then I/Q >>accumulation. >> > > Actually, the Goertzel is terribly inefficient with the dsPIC, at least when > using floating point and the C30 compiler.
There is no need for the floating point to do Goertzel.
> Floating point addition, > subtraction and multiplication take hundreds of cycles to complete on the > dsPIC. I couldn't find any good examples of the Goertzel done with integers.
Example of Goertzel, eh? As you already noticed, the things are not going to work that way. You have to start learning from the very basics.
> Using the floating point Goertzel I was something like 1000 times the > required processing time, now with an integer DFT using a look-up sin/cos > table I am less than 10 percent over the required processing time. I am > very close to my target, hence my original question.
How did you manage to get such a poor result?
> >>Max. error ~ 40% > > > Where do you get 40% from.
Elementary school.
> All I'm doing is tone detection where the gain > triggers a preset value. Are you saying that there is 40% noise on the > magnitude output?
No. What I said is the amplitude can be 40% different from the true value.
> This might be acceptable depending where my noise floor is > and where I set my trigger value. > > Thomas >
VLV
> Floating point addition, >> subtraction and multiplication take hundreds of cycles to complete on the >> dsPIC. I couldn't find any good examples of the Goertzel done with >> integers. > > Example of Goertzel, eh? As you already noticed, the things are not going > to work that way. You have to start learning from the very basics. >
How many people do you know that have re-written the Goertzel for integers, or people that even really understand the algorithm? I pitty the person that has to pay for you to re-invent the wheel.
>> Using the floating point Goertzel I was something like 1000 times the >> required processing time, now with an integer DFT using a look-up sin/cos >> table I am less than 10 percent over the required processing time. I am >> very close to my target, hence my original question. > > How did you manage to get such a poor result? >
Sorry that should be 1000 percent not 1000 times.
>> >>>Max. error ~ 40% >> >> >> Where do you get 40% from. > > Elementary school. >
OK point well taken, I did the math. But if everyone went ahead and figured out the answers on their own, there would be no more newsgroups and you would have too much time on your hands. Thomas
> > OK point well taken, I did the math. But if everyone went ahead and figured > out the answers on their own, there would be no more newsgroups and you > would have too much time on your hands. > > Thomas
And that would be bad because .......? Dirk
On 3 Sep., 20:50, "Thomas Magma" <somewh...@overtherainbow.com> wrote:
> Hello, > > I'm trying to write a very efficient and fast detection algorithm for a > dsPIC. I've already been down the path of the Goertzel and have dismissed it > because of it's use of floating point numbers. I am now using a modified DFT > and would like to get rid of the square root algorithm that calculates the > magnitude of I & Q. It seems to me that simply summing (the accumulated) I > & Q channels it will give you a cheap and dirty indication of gain. Summing > their absolute values, that is. Does anyone see anything wrong with this? > Are there any draw backs of doing this? > > Thomas
read these:? http://www.analog.com/static/imported-files/processor_manuals/2127342adsp2100vol1.zip (chapter14) http://www.analog.com/static/imported-files/processor_manuals/60899921adsp2100vol2.zip (chapter8) -Lasse
Thomas Magma wrote:
> Hello, > > I'm trying to write a very efficient and fast detection algorithm for a > dsPIC. I've already been down the path of the Goertzel and have dismissed it > because of it's use of floating point numbers.
Goertzel can be fixed point. Over four years ago, someone at Rice U published code to handle DTMF on an 8-bit integer microprocessor. Maybe you can find it. 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;