Searching \ for '[PIC] Implementation of 8-bit arctangent 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: 'Implementation of 8-bit arctangent function'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Implementation of 8-bit arctangent function'
2006\12\23@105440 by Robert A LaBudde

flavicon
face
I found a neat approximation for an arctangent in radians of a value of X
in [-1,1]:

atan(X) = X / { 1 + 0.28 X*X }     error < 0.005, |X| < 1

If I use 8-bit fixed point, then the denominator will require 9 bits, which
creates an annoying problem with the division.

I see several solutions to the problem.

1. I can shift the denominator one bit to the right, creating a temporary 8
bit result, doing the division, and then shifting the quoteient one bit to
the right to compensate. Sort of a limited floating point.

2. Do a 32 bit by 16 bit division, and then convert to an 8-bit answer.

Does anyone have experience with the best way to deal with this type of
precision issue?

Thanks.
================================================================
Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: spam_OUTralTakeThisOuTspamlcfltd.com
Least Cost Formulations, Ltd.            URL: http://lcfltd.com/
824 Timberlake Drive                     Tel: 757-467-0954
Virginia Beach, VA 23464-3239            Fax: 757-467-2947

"Vere scire est per causas scire"
================================================================

2006\12\23@220800 by James Newtons Massmind

face picon face
I'm probably not understanding something, but...

www.piclist.com/cgi-bin/constdivmul.exe?Acc=ACC&Bits=8&endian=little&
Const=.28&ConstErr=0.005&Temp=TEMP&cpu=pic16

---
James.



> {Original Message removed}

2006\12\25@104629 by Scott Dattalo

face
flavicon
face
> I found a neat approximation for an arctangent in radians of a value of X
> in [-1,1]:
>
> atan(X) = X / { 1 + 0.28 X*X }     error < 0.005, |X| < 1
>
> If I use 8-bit fixed point, then the denominator will require 9 bits,
> which
> creates an annoying problem with the division.

Hi Robert,

If the implementation of the arctan is for a PIC, then you may wish to
consider:

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

This also has a similar error (~1/200) and doesn't involve any annoying
division. On the other hand, the returned result is in normalized radians
and thus may require an addition multiplication to convert to what ever
units you're using. (However, it should be pointed out that the lookup
table can be converted into other units).


Scott

2006\12\25@213625 by Robert A LaBudde

flavicon
face
At 10:45 AM 12/25/2006, Scott wrote:
>Hi Robert,
>
>If the implementation of the arctan is for a PIC, then you may wish to
>consider:
>
>http://www.dattalo.com/technical/software/pic/arctan.asm
>
>This also has a similar error (~1/200) and doesn't involve any annoying
>division. On the other hand, the returned result is in normalized radians
>and thus may require an addition multiplication to convert to what ever
>units you're using. (However, it should be pointed out that the lookup
>table can be converted into other units).

Thanks, Scott.

I'll implement my formula and compare to yours in terms of complexity and
space. I'll post the program when I'm done.


================================================================
Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: .....ralKILLspamspam@spam@lcfltd.com
Least Cost Formulations, Ltd.            URL: http://lcfltd.com/
824 Timberlake Drive                     Tel: 757-467-0954
Virginia Beach, VA 23464-3239            Fax: 757-467-2947

"Vere scire est per causas scire"
================================================================

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