Searching \ for 'Floating Point Math Routine (Pow) for PIC16' 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/math/index.htm?key=math
Search entire site for: 'Floating Point Math Routine (Pow) for PIC16'.

Truncated match.
PICList Thread
'Floating Point Math Routine (Pow) for PIC16'
2003\01\09@074226 by jmartin

flavicon
face
Hello,

Please, does anyone know where i can find a floating point
routine in assembly for PIC16 family ? I need the POW routine
with a precision of 32 bits.

Thanks.

[]4s
Jeferson Martin

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\09@075528 by Larry Bradley

flavicon
face
There are floating point routines on the Microchip web site.

At 09:52 AM 1/9/2003 +0000, you wrote:
>Hello,
>
>Please, does anyone know where i can find a floating point
>routine in assembly for PIC16 family ? I need the POW routine
>with a precision of 32 bits.
>
>Thanks.
>
>[]4s
>Jeferson Martin
>
>--
>http://www.piclist.com hint: The PICList is archived three different
>ways.  See http://www.piclist.com/#archives for details.

Larry Bradley
Orleans (Ottawa), Ontario, CANADA

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\09@081229 by jmartin

flavicon
face
Yeah, but not a POW floating point routine for PIC16, only
for PIC17. I really need for PIC16 family. I had not seen
any POW floating point routine on the Microchip web site
for PIC16...

Thanks....

[]4s
Jeferson Martin


Larry Bradley <spam_OUTlhbradleyTakeThisOuTspamIGS.NET> escreveu:

{Quote hidden}

--

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\09@085712 by Larry Bradley

flavicon
face
There are two  appnotes. One is the basic add, subtract stuff, the other
(AN660) is for the power, log, etc. It is a lot of code - the power
function requires some of the others, as I recall.

I needed a power function for the system I'm working on - The exponent in
my case is a constant (y=x^0.386), so I fit a 3rd degree polynomial to the
curve, and used that and the standard FP routines. If the exponent is a
variable, of course, you can't do that.

Larry

At 10:31 AM 1/9/2003 +0000, you wrote:
{Quote hidden}

Larry Bradley
Orleans (Ottawa), Ontario, CANADA

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\09@095448 by jmartin

flavicon
face
Hello Larry, it4s my case. I need to calculate the follow eq:
(p/p1)^0.190255, p and p1 are variables. Can you explain how i can
do it ? I need to use PIC16 due to PIC17 be very large. I have
already downloaded the stadard FP routines (+,-,...) from Microchip
site, but i don4t know how i can use it to calculate the pow function.

Thanks a lot!

[]4s
Jeferson Martin

Larry Bradley <lhbradleyspamKILLspamIGS.NET> escreveu:

{Quote hidden}

--

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\09@103204 by Scott Dattalo

face
flavicon
face
On Thu, 9 Jan 2003 EraseMEjmartinspam_OUTspamTakeThisOuTCOMP.UFSCAR.BR wrote:

> Hello Larry, it4s my case. I need to calculate the follow eq:
> (p/p1)^0.190255, p and p1 are variables. Can you explain how i can
> do it ? I need to use PIC16 due to PIC17 be very large. I have
> already downloaded the stadard FP routines (+,-,...) from Microchip
> site, but i don4t know how i can use it to calculate the pow function.

What's the dynamic range of p and p1? (i.e. are they 8-bit signed, 32-bit
unsigned?)

Scott

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\09@104612 by jmartin

flavicon
face
Scott, i4m trying to do an altimeter based on pressure altitude.

So, the eq is:

H = 44330,769[1 - (P/P1)^0,190255]
Where H is the altitude, P is the air pressure at altitude H at
a given and variable sea level pressure P1.

Thanks for your help !

[]4s
Jeferson Martin

Scott Dattalo <scottspamspam_OUTDATTALO.COM> escreveu:

{Quote hidden}

--

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\09@122257 by Scott Dattalo

face
flavicon
face
On Thu, 9 Jan 2003 KILLspamjmartinKILLspamspamCOMP.UFSCAR.BR wrote:

> Scott, i4m trying to do an altimeter based on pressure altitude.
>
> So, the eq is:
>
> H = 44330,769[1 - (P/P1)^0,190255]
> Where H is the altitude, P is the air pressure at altitude H at
> a given and variable sea level pressure P1.

That doesn't answer the question. Again, what are dynamic ranges of P and
P1? Do these come from an 8-bit A/D converter or what? You originally
asked for 32-bit precision, but I doubt you need it.

It'd probably make sense in a PIC to re-write this equation like:

H = A * ( 1 + P^B * (1/P1)^B)

Use a lookup table to compute f(x) = x^B and then perform the simple
arithmetic computation that follows. Of course, you'll need to scale the
1/P1 in a range suitable for the table. But I can't tell what the scale
factors should be without first knowing the dynamic range of your
variables.

Scott

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\09@124245 by jmartin

flavicon
face
Scott:

p1 and p ranges: 100.000 hPa to 1200.000 hPa

ok ??

Tanks!!

[]4s
Jeferson Martin

Scott Dattalo <RemoveMEscottTakeThisOuTspamDATTALO.COM> escreveu:

{Quote hidden}

--

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\09@154534 by Larry Bradley

flavicon
face
I doubt if the sea level pressure (P1?) varies that much - 800 to 1200,
perhaps. Even 800 suggests a hurricane!!!

What I did with my system was to use the equation (in my case y=x^0.386 or
whatever) to generate a set of values of y vs x over the expected range of
x (in my case, x was from 1 to 100). Then I used a program I have to fit a
polynomial to the data. I ended up having to break the data up into two
ranges, and fit a 3rd degree polynomial to each range (1<=x<=12, and x>12).
I got a fit to about 0.1% accuracy. I then used the floating point package
in my program to evaluate the polynomial as I read X from the A/D converter.

I'll use your equation and try to generate a polynomial or two for you.

Read the AN660 app note - you might be able to use it if you have a PIC
with enough program memory.

Larry

At 03:01 PM 1/9/2003 +0000, you wrote:
{Quote hidden}

Larry Bradley
Orleans (Ottawa), Ontario, CANADA

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\09@155332 by Jon M (Mike) Jones

picon face
I may be missing something but the Appendix (A&B) of Microchip AN660 claims
to have floating point code for both the 17C and the 16C both with the POW24
and POW32 routines. I can't comment on how good either of these routines are
but after much research they are the only ones I have found.

I plan on attempting to convert the 17C code  for use on the 18F452 soon. I
hope I'm not biting of more than I can chew.

(New to the list)
Mike Jones

{Original Message removed}

2003\01\09@163115 by jmartin

flavicon
face
Hello Mike,

Look at the top of page 7 of Microchip AN660: "Currently, this function (Pow)
is only supported on the PIC17CXXX".

[]4s
Jeferson Martin

"Jon M (Mike) Jones" <TakeThisOuTpmjones3EraseMEspamspam_OUTATTBI.COM> escreveu:

{Quote hidden}

> {Original Message removed}

2003\01\09@163335 by Larry Bradley

flavicon
face
OK, here are two 3rd degree polynomials to approximate y=x^0.190255, where
x is P/P1 in your case.

I have assumed that 100<= P<= 1200. P1 is always < P, thus the lowest value
for x will be 100/1200 = 0.0833.

I generated a table of y=x^.190255 for 0.08<=x<=1.0. As in my case, it was
necessary to split the data into two ranges to get a good fit.  Thus we get

For 0.08<=x<=0.3:

y=0.48093+2.12405x-5.51251x^2+6.42179x^3

and for 0.3<=x<=1:

y = .612857+.763474x-.569529x^2+.193612x^3

Thus select a poly based on the pressure ratio P/P1 and evaluate it, and
then evaluate the rest of the function to find the altitude.

Larry


At 12:13 PM 1/9/2003 +0000, you wrote:
{Quote hidden}

Larry Bradley
Orleans (Ottawa), Ontario, CANADA

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\09@163342 by Peter L. Peres

picon face
Depending on how fast you need there are polynomials you can use. And does
it have to be float ? Fixed point is easier, no ?

Peter

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\09@164115 by Scott Dattalo
face
flavicon
face
On Thu, 9 Jan 2003 EraseMEjmartinspamCOMP.UFSCAR.BR wrote:

> Scott:
>
> p1 and p ranges: 100.000 hPa to 1200.000 hPa

Let me try one more time:

http://www.its.bldrdoc.gov/fs-1037/dir-013/_1853.htm

When we say "dynamic range" in a system such as this we're typically
referring to the number of bits in the quantized signal. If you say that
the signal is quantized with an 8-bit A/D then I can infer the dynamic
range in dB as 20log(256) = 48dB. However, most people will just say the
dynamic range is "8-bits". (Assuming all 8-bits are used).

So in your system, you're probably obtaining p1 over some range of
pressures;  e.g. 0 to 100 hPa (this seems a little strange). Also, this
will be quantize:

 p1 = A*d1 + B

p1 is the pressure
d1 is the digitized number representing pressure
A and B are constants.

For example, if you're using an 8-bit A/D, and when the A/D gives you 42
that corresponds to p1=0 and when it gives you 168 when p1=100, then you
can write:

p1 - 0     d1 - 42
-------- = --------
100 - 0    168 - 42

p1 = 100/126*(d1 - 42)
   = 50/63*d1 - 100/3

This equation simply tells you how d1, numbers from the A/D, are converted
into pressure. In computing the altitude, you're probably going to want to
work with either d1 values directly or perhaps with a scaled version. The
answer depends on many factors such as how much time do you wish to spend
(e.g. you could convert everything to floating point and let the
computation take forever to compute) or how precise should the answer be
(it doesn't make sense computing altitude to the nearest nanometer!).

Scott

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\01\09@183334 by William Chops Westfield

face picon face
   > p1 and p ranges: 100.000 hPa to 1200.000 hPa

You get floating point pressure values out of your pressure sensor?  (I
guess it's possible, especially if you're reading it from something like
a GPS "thing"...)

The point is that usually a pressure sensor is connected to an integer A-D
converter, and that it may make a lot more sense (performance-wise) to stay
in that integer domain as long as possible while you're doing your math,
especially since your end result is probably an integer as well (feet or
meters of altitude, right?)  Why convert your integer pressure reading to a
floating point number, plug it into a complex floating point equation, and
finally convert back to an interger readout when the PIC would rather not
do floating point?

That means manipulting the formula quite a lot, but makes things a lot
easier for the PIC.

BillW

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

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