Can PIC16F877 do floating point math?

Status
Not open for further replies.

stevenlkz

New Member
Hello everyone! Im doing my final project about intelligent traffic system with fuzzy logic that need to build into PIC16F877. But I face a problem that is there are no multiply, divide, square and square root instruction with MPlab. Another problem is I need to do the math in floating point. How can I solve it? Any advices and suggestions do u all can give me?
Thanks for spending your time.
 

As already suggested, try the PICList for details - but almost all processors don't have such instructions, you have to write them in software.

But the main point is do you REALLY! need floating point?, floating point is EXTREMELY slow, and also inaccurate (regardless of the processor, by definition floating point is inaccurate!). This is why spreadsheet programs like Excel don't use floating point for monatary calculations, they use integer maths instead - many times faster, and 100% accurate.

By careful scaling of inputs and result, you can usually use integer maths to do most calculations, if you check the EPE website they have 32 bit maths routines, which are more than enough for most purposes (I usually only use 16 bit ones).

So, why do you think you need floating point?.
 
I am no other choice. I must write with mplab and the floating point for my fuzzy logic. The fuzzy logic must work with floating point only can accurate.
 
When you say MPLAB, do you mean assembly or C18? MPLAB is a design environment pkg, not a language, compiler, or assembler itself.

C18 has a floating point lib already available. As noted, fp is extremely cycle-intensive and rarely necessary. If it's essential, fine, but it rarely is. Even the fuzzy logic task you mention would seem better served by understand the task well enough to fit the numbers into 32 bit integers. These will be hundreds of times faster than fp.

If you're doing assembly, making your own 64 bit integer data type is possible if you modify your math routines. That'll still be much faster.
 
i am using ccs compiler it has better implementation of fp.
comparison:
**broken link removed**
 
You'll probably get higher marks by deciding not to use floating point because thinking for yourself is normally rewarded.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…