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.

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.
 
stevenlkz said:
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?

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 think you need to use PICBASIC PRO

its a very helpfull programme contaning a mathmathic operation

like : + - / * sqr & others

& it is very easy to use

u will find a demo version in this site :

https://www.melabs.com/products/pbp.htm

tell if it helped you :lol:
 
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.
 
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.

Latest threads

Back
Top