473,749 Members | 2,660 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I handle atan() when calculating absolute phase? (Communication engineering)

I am calculating the phase of an IQ signal, which are polluted by AWGN
gaussian
noise. Thus, near pi/2, direct division of atan(Q/I) may yield outputs
either +pi/2 or
-pi/2. How do I handle this situation?

Thanks.
May 4 '06 #1
5 4172
BRG
Mr. Ken wrote:
I am calculating the phase of an IQ signal, which are polluted by AWGN
gaussian
noise. Thus, near pi/2, direct division of atan(Q/I) may yield outputs
either +pi/2 or
-pi/2. How do I handle this situation?


As well as having the function atan(x), your system is likely to have
atan2(y, x) which eliminates the ambiguity except when x and y are both
zero.

Brian Gladman
May 4 '06 #2
BRG wrote:
Mr. Ken wrote:
I am calculating the phase of an IQ signal, which are polluted by AWGN
gaussian noise.


As well as having the function atan(x), your system is likely to have
atan2(y, x) which eliminates the ambiguity except when x and y are both
zero.


atan2 avoids infinity, and I think gives a full +/-pi range, but there's
still a massive jump in the number that represents phase, so you can't
just average that number to remove noise. You can smooth x and y first,
or smooth a modified phase w/ 2pi added or subtracted to keep it near
the recent average, and jump the average when it goes out of range.
May 4 '06 #3
BRG
Robert Mabee wrote:
BRG wrote:
Mr. Ken wrote:
I am calculating the phase of an IQ signal, which are polluted by AWGN
gaussian noise.


As well as having the function atan(x), your system is likely to have
atan2(y, x) which eliminates the ambiguity except when x and y are both
zero.


atan2 avoids infinity, and I think gives a full +/-pi range, but there's
still a massive jump in the number that represents phase, so you can't
just average that number to remove noise.


[snip]
You can at +pi/2 and -pi/2, the points to which the original poster
specifically referred.

When two quadrature signals I and Q are available, atan2(Q, I) is better
than atan(Q/I) since it not only eliminates the division by zero problem
but also eliminates the artificial phase ambiguity _introduced_ by
atan(Q/I) at +pi/2 and -pi/2.

Noise will still be an issue at +pi and -pi but at least atan2(Q, I)
won't produce the incorrect results given by atan(Q/I) near +pi/2 and
-pi/2 caused by essentially ignoring a good sign on Q when I is small.

Brian Gladman
May 5 '06 #4

"BRG" <br*@nowhere.or g> wrote in message
news:44******** **************@ ptn-nntp-reader01.plus.n et...
Robert Mabee wrote:
BRG wrote:
Mr. Ken wrote:
I am calculating the phase of an IQ signal, which are polluted by AWGN
gaussian noise.

As well as having the function atan(x), your system is likely to have
atan2(y, x) which eliminates the ambiguity except when x and y are both
zero.


atan2 avoids infinity, and I think gives a full +/-pi range, but there's
still a massive jump in the number that represents phase, so you can't
just average that number to remove noise.


[snip]
You can at +pi/2 and -pi/2, the points to which the original poster
specifically referred.

When two quadrature signals I and Q are available, atan2(Q, I) is better
than atan(Q/I) since it not only eliminates the division by zero problem
but also eliminates the artificial phase ambiguity _introduced_ by
atan(Q/I) at +pi/2 and -pi/2.

Noise will still be an issue at +pi and -pi but at least atan2(Q, I)
won't produce the incorrect results given by atan(Q/I) near +pi/2 and
-pi/2 caused by essentially ignoring a good sign on Q when I is small.


Hmm... Let's see how much of this mess it cleans up:

float CalcTheta( const JVEC2 Point1, const JVEC2 Point2 )
{
float Theta;
if ( Point2.x - Point1.x == 0 )
if ( Point2.y > Point1.y )
Theta = 0;
else
Theta = static_cast<flo at>( PI );
else
{
Theta = std::atan( (Point2.y - Point1.y) / (Point2.x - Point1.x) );
if ( Point2.x > Point1.x )
Theta = static_cast<flo at>( PI ) / 2.0f - Theta;
else
Theta = static_cast<flo at>( PI ) * 1.5f - Theta;
};

return Theta;
}

would become...

float CalcTheta( const JVEC2 Point1, const JVEC2 Point2 )
{
float Theta;
Theta = std::atan2( (Point2.y - Point1.y) / (Point2.x - Point1.x) );
if ( Point2.x > Point1.x )
Theta = static_cast<flo at>( PI ) / 2.0f - Theta;
else
Theta = static_cast<flo at>( PI ) * 1.5f - Theta;
};

return Theta;
}

Is that all that can be simplified?


May 6 '06 #5
BRG
Jim Langston wrote:
"BRG" <br*@nowhere.or g> wrote in message
news:44******** **************@ ptn-nntp-reader01.plus.n et...
Robert Mabee wrote:
BRG wrote:
Mr. Ken wrote:
> I am calculating the phase of an IQ signal, which are polluted by AWGN
> gaussian noise.
As well as having the function atan(x), your system is likely to have
atan2(y, x) which eliminates the ambiguity except when x and y are both
zero.
atan2 avoids infinity, and I think gives a full +/-pi range, but there's
still a massive jump in the number that represents phase, so you can't
just average that number to remove noise.

[snip]
You can at +pi/2 and -pi/2, the points to which the original poster
specifically referred.

When two quadrature signals I and Q are available, atan2(Q, I) is better
than atan(Q/I) since it not only eliminates the division by zero problem
but also eliminates the artificial phase ambiguity _introduced_ by
atan(Q/I) at +pi/2 and -pi/2.

Noise will still be an issue at +pi and -pi but at least atan2(Q, I)
won't produce the incorrect results given by atan(Q/I) near +pi/2 and
-pi/2 caused by essentially ignoring a good sign on Q when I is small.


Hmm... Let's see how much of this mess it cleans up:

float CalcTheta( const JVEC2 Point1, const JVEC2 Point2 )
{
float Theta;
if ( Point2.x - Point1.x == 0 )
if ( Point2.y > Point1.y )
Theta = 0;
else
Theta = static_cast<flo at>( PI );
else
{
Theta = std::atan( (Point2.y - Point1.y) / (Point2.x - Point1.x) );
if ( Point2.x > Point1.x )
Theta = static_cast<flo at>( PI ) / 2.0f - Theta;
else
Theta = static_cast<flo at>( PI ) * 1.5f - Theta;
};

return Theta;
}

would become...

float CalcTheta( const JVEC2 Point1, const JVEC2 Point2 )
{
float Theta;
Theta = std::atan2( (Point2.y - Point1.y) / (Point2.x - Point1.x) );
if ( Point2.x > Point1.x )
Theta = static_cast<flo at>( PI ) / 2.0f - Theta;
else
Theta = static_cast<flo at>( PI ) * 1.5f - Theta;
};

return Theta;
}

Is that all that can be simplified?


float CalcTheta( const JVEC2 Point1, const JVEC2 Point2 )
{
return std::atan2( Point2.x - Point1.x, Point2.y - Point1.y );
}

is an even simpler solution.

Brian Gladman
May 6 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
9593
by: Michael Winter | last post by:
In an attempt to answer another question in this group, I've had to resort to calling the DOM method, Node.removeChild(), using a reference to it (long story...). That is, passing Node.removeChild. In Opera (7.23/Win), the call appears to do nothing - the node remains - but no errors are shown. In Netscape (7.0/Win), an exception results. On IE (6.0/Win), the node is removed. Strangly, if I pass another function reference, say...
21
8600
by: Protoman | last post by:
How do I calculate the log of a number? Don't tell me to use log in cmath; I'm trying to learn complex math in C++. Got any tips/ideas on how to do this? Thanks for the help!!!
6
2873
by: Leandro Berti via DotNetMonster.com | last post by:
Hi All, I wrote a code to do serial communication with an equipament. When i use the code outside of threaded class it seens work properly, but when i put inside a class and execute a thread in the first seconds the communication is ok, later i receive read/write error. I?ve been in MSDN site and there i discover that the read/write error is a INVALID_HANDLE problem. But why??? I just create the serial communication file and use it....
1
1593
by: Umut Tezduyar | last post by:
Because of the fact that, handling events method ( IPostBackEventHandler.RaisePorstBackEvent method) is prior to OnPreRender method, i cannot handle the events of the controls that i am adding on the OnPreRender method. Is there a way for that. Can i manually tell asp.net page to check again if there is control that is post backing to the server. ex: Load IPostBackEventHandler.RaisePostBackEvent ( in this phase parameter is
4
1521
by: Niels Jensen | last post by:
Hi, I'm a bit of a newbie to VB.NET so please forgive me if I get the terminology incorrect... I'm still learning :) I have a form with five numUpDown controls representing different ratios for 5 diferent things. Next to them are 5 checkboxes that can be used to lock it's relevant ratio. I'm trying to get them to automatically distribute a total of 100 amongst themselves. I've managed to get this working - almost...
39
7427
by: tydbowl | last post by:
I have a problem where the below code chunk causes handle leaks on some machines. The leak APPEARS to be handles to the registry key: HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap The below code runs on a timer running several times per second and after about 15-30 minutes or so, it runs out of handles and crashes IE. I found an article on msdn discussing how setting properties in this
4
4637
by: grayaii | last post by:
Hi, I have a simple form that handles all its paint functionality like so: this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); And the entry point to this program is like so: static void Main() {
6
2052
by: Liming | last post by:
Hi, In a typical 3 tier model (view layer, busines layer and data access layer) where do you handle your exceptions? do you let it buble up all the way to the .aspx pages or do you handle it in your business layer and/or data access layer? suppose in my data access layer, I provide try and catch, log the exception and re-throw it back to business layer, then in yoru business layer, what do you do? throw it back to the code behind or...
13
1618
by: Xah Lee | last post by:
Today, a motherfucker Christophe Rhodes (aka Xof in irc://chat.freenode.net/lisp ) kicked banned me. Here's the few relevant excerpt. (full, unedited excerpt will be published if there is a public interest) Begin excerpt: <xahleek, here is a simple problem but rather tedious to do it correctly. ....
0
8997
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8833
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9568
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6801
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6079
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4709
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3320
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2794
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.