Searching \ for 'Sin and cos maths funtion on PIC(AN660 )' in subject line. ()
Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/math/index.htm?key=math
Search entire site for: 'Sin and cos maths funtion on PIC(AN660 )'.

Truncated match.
'Sin and cos maths funtion on PIC(AN660 )'
2002\11\26@074609 by

Hi every one

Do any one have any experience in use sine and cos maths function on PIC. like the one stated in the microchip AN660 document(using minimax approximations). Can any one kindly enlighten me what method they use cos I am current running short of memory and I need to replace their fixed point multiplication routine with my standard multiplication routine. I am not able to understand the flow of the program is there any material that I can read on?
--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservmitvma.mit.edu with SET PICList DIGEST in the body

At 08:49 PM 11/26/02 -0800, you wrote:
>Hi every one
>
>Do any one have any experience in use sine and cos maths function on PIC.
>like the one stated in the microchip AN660 document(using minimax
>approximations). Can any one kindly enlighten me what method they use cos
>I am current running short of memory and I need to replace their fixed
>point multiplication routine with my standard multiplication routine. I am
>not able to understand the flow of the program is there any material that

Microchip is just using a polynomial to approximate a segment of the
function, and very simple trig transformations to get the operand into the
domain where the polynomial is relatively accurate. Minmax just refers to the
criteria for finding the "optimal" polynomial coefficients. If you are
going to be using their coefficients, then you don't need to know how
to do that.

I didn't delve further into the AN (it looks pretty lucid, actually), but
polynomials are typically evaluated using Horner's method, which is
fast and yields minimum error.

P(x) = a*x^n + b*x^(n-1)... p*x + q

= (..((x * a) + b) * x) +... + q

So you need only n multiplications and n additions to get the answer.
When using fixed point multiplication, you have to be especially careful
of overflow and of letting the numbers get too small so accuracy suffers.
You might have to scale at each operation to keep the numbers in the
right range, and adjust the coefficients appropriately.

If you don't need much performance speed-wise, you might consider
re-writing the routine to use your pre-existing (?) FP multiplication
routine, which should save space.

Best regards,

Spehro Pefhany --"it's the network..."            "The Journey is the reward"
speffinterlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com

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

On Tue, 26 Nov 2002, Soon Lee wrote:

> Hi every one
>
> Do any one have any experience in use sine and cos maths function on
> PIC. like the one stated in the microchip AN660 document(using minimax
> approximations). Can any one kindly enlighten me what method they use
> cos I am current running short of memory and I need to replace their
> fixed point multiplication routine with my standard multiplication
> routine. I am not able to understand the flow of the program is there
> any material that I can read on?

For the theory:

http://www.dattalo.com/technical/theory/sinewave.html

For the practice:

http://www.brouhaha.com/~eric/pic/sine.html
www.dattalo.com/technical/software/pic/picsine.html
http://www.dattalo.com/technical/software/pic/sine18.asm

These three links cover the 12, 14, and 16-bit cores.

Scott

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

Hi thanks for the infor
sorry just to check the value for
sin(x)
the x is it in rad?

regards
----- Original Message -----
From: "Spehro Pefhany" <speffINTERLOG.COM>
To: <PICLISTMITVMA.MIT.EDU>
Sent: Tuesday, November 26, 2002 7:05 AM
Subject: Re: Sin and cos maths funtion on PIC(AN660 )

> At 08:49 PM 11/26/02 -0800, you wrote:
> >Hi every one
> >
> >Do any one have any experience in use sine and cos maths function on PIC.
> >like the one stated in the microchip AN660 document(using minimax
> >approximations). Can any one kindly enlighten me what method they use cos
> >I am current running short of memory and I need to replace their fixed
> >point multiplication routine with my standard multiplication routine. I
am
> >not able to understand the flow of the program is there any material that
>
> Microchip is just using a polynomial to approximate a segment of the
> function, and very simple trig transformations to get the operand into the
> domain where the polynomial is relatively accurate. Minmax just refers to
the
{Quote hidden}

reward"
> speffinterlog.com             Info for manufacturers:
http://www.trexon.com
> Embedded software/hardware/analog  Info for designers:
http://www.speff.com
>
> --
> http://www.piclist.com#nomail Going offline? Don't AutoReply us!
> email listservmitvma.mit.edu with SET PICList DIGEST in the body
>
>

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

At 12:08 AM 11/27/02 -0800, you wrote:
>Hi thanks for the infor
>sorry just to check the value for
>sin(x)
>the x is it in rad?

Best regards,

Spehro Pefhany --"it's the network..."            "The Journey is the reward"
speffinterlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com

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

Sorry as I am very new to this just to check if I use a calculator to check
will I get the correct value. Cos I have tested on calculator I don't seem
to get the result.
According to the AN I am doing the following

y        = |x| * 4 / pi
Z1     = |x| - y*P1
Z2     =Z1- y*P2
Z       =Z2- y*P3
result = Z*Z
maybe i follow the code wrongly
regards

{Original Message removed}

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