Searching \ for '[PIC]: CORDIC Arctan Function?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'CORDIC Arctan Function?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: CORDIC Arctan Function?'
2001\04\05@172401 by Mark Peterson

flavicon
face
I'm working on a compass project where I have two magneto resistive sensors
connected to a couple PIC analog inputs.  This effectively generates a sin
and cos value for the angle of the magnetic field.  What is the trig,
CORDIC, or whatever function that I need to use to turn the sin and cos
value into a single angle value?

Thanks.

Mark P

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2001\04\05@173026 by David VanHorn

flavicon
face
At 04:21 PM 4/5/01 -0500, Mark Peterson wrote:
>I'm working on a compass project where I have two magneto resistive sensors
>connected to a couple PIC analog inputs.  This effectively generates a sin
>and cos value for the angle of the magnetic field.  What is the trig,
>CORDIC, or whatever function that I need to use to turn the sin and cos
>value into a single angle value?

You're trying to convert rectangular to polar coordinates, I think.

--
Dave's Engineering Page: http://www.dvanhorn.org
Where's dave? http://www.findu.com/cgi-bin/find.cgi?kc6ete-9

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam@spam@mitvma.mit.edu with SET PICList DIGEST in the body


2001\04\05@175830 by Barry Gershenfeld

picon face
You want the arctangent.  That's tangent in, angle out.  And you
get the tangent from (sin/cos).  (Sine divided by cosine).

ArcTan is just the tangent table read backwards.

IANAM (I am not a mathematician) so count to 10 and look for
posted corrections before following my advice.

Barry



At 04:21 PM 4/5/01 -0500, you wrote:
{Quote hidden}

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam.....mitvma.mit.edu with SET PICList DIGEST in the body


2001\04\05@191152 by James R. Cunningham

flavicon
face
The tangent goes infinite at 90 & 270 degrees.  Hard on conversions.  You might
try a sin & cos comparison, which will also give you the quadrant information
you need.

Jim

Barry Gershenfeld wrote:

{Quote hidden}

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email @spam@listservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body


2001\04\05@200232 by Scott Dattalo

face
flavicon
face
On Thu, 5 Apr 2001, Mark Peterson wrote:

> I'm working on a compass project where I have two magneto resistive sensors
> connected to a couple PIC analog inputs.  This effectively generates a sin
> and cos value for the angle of the magnetic field.  What is the trig,
> CORDIC, or whatever function that I need to use to turn the sin and cos
> value into a single angle value?

http://www.dattalo.com/technical/software/pic/arctan.asm

For other trig/math functions:

http://www.dattalo.com/technical/software/software.html

Scott

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email KILLspamlistservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body


2001\04\05@210800 by Olin Lathrop

face picon face
> I'm working on a compass project where I have two magneto resistive
sensors
> connected to a couple PIC analog inputs.  This effectively generates a sin
> and cos value for the angle of the magnetic field.  What is the trig,
> CORDIC, or whatever function that I need to use to turn the sin and cos
> value into a single angle value?

Arctangent.


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, RemoveMEolinTakeThisOuTspamembedinc.com, http://www.embedinc.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spamBeGonelistservspamBeGonespammitvma.mit.edu with SET PICList DIGEST in the body


2001\04\06@081346 by Olin Lathrop

face picon face
> The tangent goes infinite at 90 & 270 degrees.  Hard on conversions.

Right, that's why you don't do SIN/COS and take the arctangent.  You use SIN
and COS separately in the arctangent process.  Most math libraries have a
routine for this, usually called something like ARCTAN2.


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, TakeThisOuTolinEraseMEspamspam_OUTembedinc.com, http://www.embedinc.com

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspamTakeThisOuTmitvma.mit.edu


2001\04\06@121310 by James R. Cunningham

flavicon
face
As I mentioned earlier, you might try a sin & cos comparison, which will also
give you the quadrant information
you need.  To elaborate on that, doing an arcsin will give you two possible
angles.  Doing an arccos will give you two possible angles, one of which will
be identical to the output from the arcsin, and is the angle you are looking
for.  You will then need to do some quadrant arithmetic.  I'm sure  you're
already aware that the usual azimuth convention sets 0 at north which is a 90
degree offset from the usual math convention, and that the azimuth angles
increase in the opposite direction from the usual math convention.  Don't you
need a third sensor to derive the dip of the field (tip angle)?

Jim

Barry Gershenfeld wrote:

> You want the arctangent.  That's tangent in, angle out.  And you

Mark Peterson wrote:

{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspammitvma.mit.edu


2001\04\06@122323 by Scott Dattalo

face
flavicon
face
On Fri, 6 Apr 2001, Olin Lathrop wrote:

> > The tangent goes infinite at 90 & 270 degrees.  Hard on conversions.
>
> Right, that's why you don't do SIN/COS and take the arctangent.  You use SIN
> and COS separately in the arctangent process.  Most math libraries have a
> routine for this, usually called something like ARCTAN2.

True. The link to the arctan routine I posted yesterday performs more like the
"arctan" function and not the "arctan2". However, in this particular case the
sine and cosine values are known and so the quadrant can be determined. In my
routine, you need to know the octant. But again, that's easily determined...

So to use my routine you'd have to jump through this psuedo hoop:


  s = sin value
  c = cos value


  angle = 0;
  if(s<0) {
     angle += 90;  // 90 degrees shift if sine is < 0
     s += 1;       // make positive. note, you can't
                   // just take the absolute value
  }

  if(c<0) {
     angle += 180;  // 180 degrees shift for cosine
     c += 1;
  }

  if(c == 0)
    return angle;

  if(s>c) {
    swap s and c
    angle += 45;
  }

  ratio = s/c;

  return angle + arctan(ratio);


The FRACDIC routine (within the arctan.asm link I posted earlier) does the
division and swapping.

Scott

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestEraseMEspamEraseMEmitvma.mit.edu


2001\04\10@042626 by Tom Handley

picon face
  Mark, I'm also working on a compass project using the Vector 2X module.
PNI has put the Vector 2X manual on their web site. It includes the math
to do calibration of the module in the raw mode. A great article on
using an electronic compass in robot navigation systems is in Circuit
Cellar, #81 April 1997. It goes into all the math and has a good
description of the CORDIC method.

     http://www.pnicorp.com/prec.html
     http://www.circellar.com/

  - Tom

At 04:21 PM 4/5/01 -0500, Mark Peterson wrote:
{Quote hidden}

------------------------------------------------------------------------
Tom Handley
New Age Communications
Since '75 before "New Age" and no one around here is waiting for UFOs ;-)

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservspam_OUTspamKILLspammitvma.mit.edu with SET PICList DIGEST in the body



'[PIC]: CORDIC Arctan Function?'
2001\05\01@165418 by Dmitry A. Kiryashov
flavicon
face
Hi Mark.

Yes it is CORDIC. You are pushing one value down to
zero and two others are becoming magnitude and angle.
It's easy to search altavista for details.

WBR Dmitry.



> I'm working on a compass project where I have two magneto resistive sensors
> connected to a couple PIC analog inputs.  This effectively generates a sin
> and cos value for the angle of the magnetic field.  What is the trig,
> CORDIC, or whatever function that I need to use to turn the sin and cos
> value into a single angle value?
>
> Thanks. Mark P

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspamspammitvma.mit.edu


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...