Searching \ for '[PIC] Math, math, and more math...' 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: 'Math, math, and more math...'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Math, math, and more math...'
2006\05\04@155910 by PicDude

flavicon
face
I'm getting ready to modify an app with a bunch of math (+, -, *, / only), but
I want to calculate to 2 (or perhaps even 3) decimal places.  The app is
currently written in assembly using integer math, but I'm not looking forward
to doing all the math in assembly.

Is there a way to write the math parts in Basic or C, compile those parts to
assembly and integrate that into my code?  Alternatively, are there
assembly-language math libraries available anywhere that can make this
easier?  Performance/efficiency is not critical, since the chip (16F913) is
currently running at ~2Mhz, and I can step that up if necessary.

Cheers,
-Neil.

2006\05\04@161352 by Jan-Erik Soderholm

face picon face
PicDude wrote :

> I'm getting ready to modify an app with a bunch of math (+,
> -, *, / only), but I want to calculate to 2 (or perhaps even 3)
> decimal places.

The number of decimals is rather irrelevant,
what is the total dynamic range ?

0.010  - 0.001  ?? (only 10 distinct values...)

or

10000.000 - 0.001 (a little more work...)

or (probably) something else ?

Regards,
Jan-Erik.



2006\05\04@162751 by Charles Craft

picon face
Bolt this to the top of your 16F913:

http://www.micromegacorp.com/umfpu-v2.html

The uM-FPU V2 floating point coprocessor is easily interfaced with virtually any microcontroller to provide support for 32-bit IEEE 754 compatible floating point and 32-bit long integer calculations. It can be connected using either an I2C or SPI compatible interface. The uM-FPU uses an internal oscillator and requires no external components. It is available in an 8-pin DIP or SSOP-20 SMT package. Documentation and support software is available for a variety of microcontrollers (see list on the left).

{Original Message removed}

2006\05\04@163821 by PicDude

flavicon
face
On Thursday 04 May 2006 15:13, Jan-Erik Soderholm wrote:
> The number of decimals is rather irrelevant,
> what is the total dynamic range ?
>
> 0.010  - 0.001  ?? (only 10 distinct values...)
>
> or
>
> 10000.000 - 0.001 (a little more work...)
>
> or (probably) something else ?


The range of values is about -300.00 to 300.00.  With 2 decimal places, that's
60,000 possible values.  BUT, I have not yet determined how many extra places
I will need for the intermediate calcs.  I'll mostly be deriving the gradient
and constant for a straight-line equation ( y=mx+c ) then solving for it
given values of x.  Also, there is some IIR filtering in there.  I'm guessing
the m will have to be 3 decimal places else I'll lose accuracy.

The previous version is only solving the equation and the range of values is
0-100, with integer math.  Internally, I'm calculate to 4 *binary* places.

Cheers,
-Neil.

2006\05\04@164745 by Larry G. Nelson Sr.

picon face
I have had good luck with the math routines in the Microchip ap notes on several projects. I have had people tell me they are broken but they have passed all the tests I have run and they are in several commercial producrts working fine.
Larry

---- PicDude <spam_OUTpicdudeTakeThisOuTspamnarwani.net> wrote:
{Quote hidden}

> --

2006\05\04@164836 by James Newton, Host

face picon face
> Alternatively, are there assembly-language math libraries
> available anywhere that can make this easier?  

http://www.piclist.com/techref/microchip/math/basic.htm

---
James.


2006\05\04@164951 by PicDude

flavicon
face
This is actually pretty neat.  Unfortunately in this app, I'm converting an
existing design and space is ultra mega uber tight.  I have the option of
using any 28SSOP PIC that is pin-compatible with the 16F913, but can't add
any other chips.

Cheers,
-Neil.


On Thursday 04 May 2006 15:27, Charles Craft wrote:
{Quote hidden}

2006\05\04@170121 by olin piclist

face picon face
PicDude wrote:
> The range of values is about -300.00 to 300.00.  With 2 decimal
> places, that's 60,000 possible values.  BUT, I have not yet
> determined how many extra places I will need for the intermediate
> calcs.  I'll mostly be deriving the gradient and constant for a
> straight-line equation ( y=mx+c ) then solving for it given values of
> x.  Also, there is some IIR filtering in there.  I'm guessing the m
> will have to be 3 decimal places else I'll lose accuracy.

We've got 32 bit fixed point and 24 bit floating point routines for the PIC
16, although they expect our PIC development environment and would need some
modification to work outside them.


******************************************************************
Embed Inc, Littleton Massachusetts, (978) 742-9014.  #1 PIC
consultant in 2004 program year.  http://www.embedinc.com/products

2006\05\04@182245 by PicDude

flavicon
face
I've used some of those before, but I was thinking this would have to be
floating point.  But more and more I guess I'm going back to doing this as
integers, so I may end up there or with Microchip's routines.

Cheers,
-Neil.


On Thursday 04 May 2006 15:48, James Newton, Host wrote:
> > Alternatively, are there assembly-language math libraries
> > available anywhere that can make this easier?
>
> http://www.piclist.com/techref/microchip/math/basic.htm
>
> ---
> James.

2006\05\04@183426 by James Newtons Massmind

face picon face
www.piclist.com/techref/microchip/math/fp.htm

---
James.



{Quote hidden}

> -

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