Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Microchip fixed point math library -16CXXX family

Status
Not open for further replies.

atferrari

Well-Known Member
Most Helpful Member
I've tried to compile fixed point routines from the math library in Microchip AN 617.

I found that divide or multiply, almost at the very end, use a flag (BSF FPFLAGS,NAN ) that is suposed to be employed in floating point routines.

Obviously, the compiler gives error because FPFLAGS and NAN do not need to be defined.

In the code zip file acompannying that app. note, there is an archive showing FPFLAGS and NAN , among other, as specific for floating point routines.

Curiously, the contents of that archive is not include in the .pdf version of the AN617.

Anyone knows what's actually going on? :(

Help appreciated.

Agustín Tomás
 
The MicroChip maths routines are well known for being bug ridden and pretty well useless, try looking on the PICList for maths routines.

You might also consider using integer maths routines, FAR faster, and more accurate - EPE magazine have 32 bit integer maths routines on their website.

By careful scaling of the values you can often avoid using decimal points (just adding them for display purposes).
 
What integer math? Fixed points?

Hi Nigel,

Thanks for replying. :)

My questions:

a) Long time I don't run across the expresion "integer" math and by now I am not sure about its actual meaning. Is it what I call "fixed point", right?

b) I found the routines in AN617 extremely long. I am naturally inquisitive, but this time I didn't want to involve myself in trying to understand them in full. (Less if they are so poorly commented or not commented at all!) :(

My own routine dividing 32/16 it's really short (and works OK) if compared with the equivalent there. I undesrtand that the routines proposed are not "unrolled" but yes, they are long!

What I was looking for was a set of routines using all the same arguments for input and output. Different origins do not assure that!

For the moment I need 16x16, 16/16 and 32/16.

Thanks again.

Agustín Tomás
 
Re: What integer math? Fixed points?

atferrari said:
Hi Nigel,

Thanks for replying. :)

My questions:

a) Long time I don't run across the expresion "integer" math and by now I am not sure about its actual meaning. Is it what I call "fixed point", right?

'Integer' is VERY common, and the most commonly used on microcontrollers, basically it means whole numbers only (no decimal points). Spreadsheets commonly use integer maths for doing money calculations, so it's done as pennies or cents, so no decimal points involved.

I would consider 'fixed point' to have a fixed number of decimal places, not none at all - but it's simply a matter of scaling.

b) I found the routines in AN617 extremely long. I am naturally inquisitive, but this time I didn't want to involve myself in trying to understand them in full. (Less if they are so poorly commented or not commented at all!) :(

My own routine dividing 32/16 it's really short (and works OK) if compared with the equivalent there. I undesrtand that the routines proposed are not "unrolled" but yes, they are long!

What I was looking for was a set of routines using all the same arguments for input and output. Different origins do not assure that!

For the moment I need 16x16, 16/16 and 32/16.

Try the EPE magazine website, they have full 32 bit integer maths routines, for 16 bit ones try Dontronics, they have an online 'book' which gives the 16 bit routines I normally use.

As you need 32/16 I would suggest you use the 32 bit routines from EPE, they are nice and simple to use.
 
Re: What integer math? Fixed points?

Nigel Goodwin said:
'Integer' is VERY common, and the most commonly used on microcontrollers, basically it means whole numbers only (no decimal points). Spreadsheets commonly use integer maths for doing money calculations, so it's done as pennies or cents, so no decimal points involved.

I would consider 'fixed point' to have a fixed number of decimal places, not none at all - but it's simply a matter of scaling.

Duly noted. Probably my confusion comes from the expresion "integer" as a name to quantities no bigger than 8-bits numbers. I run across that, first time in Turbo Basic if I recall properly...

From the beginning I used them (8 and 16-bit integers, dividing / multiplying by powers of 10 as necessary so as to maintain consistency up to final results. And yes, the decimal point in the display for the user.

Try the EPE magazine website, they have full 32 bit integer maths routines, for 16 bit ones try Dontronics, they have an online 'book' which gives the 16 bit routines I normally use.

As you need 32/16 I would suggest you use the 32 bit routines from EPE, they are nice and simple to use.

Your reccomendation is appreciated. Is good to have a word from an expert! :) I appreciate also, the time you spend in replying. :!:

Added one hour later:

Sorry Nigel,

a) in Dontronics' site the sole book online is about Basic, not assembler.

b) in EPE's site I couldn't find the place where to download those routines from.


Could you lead me to both places? Thanks

Agustín Tomás
 
Found them!

Thanks to you both! :)

Agustín Tomás
 
i wolud like to thank u but u have ???

hi how r u doin u have to know what`s the diferent between the flux and the charg desity so may u must to learn more ????
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top