PDA

View Full Version : Floating point math



Alexey
- 15th September 2014, 04:00
Would be very nice to have floating point math

Currently I use MikroC from Mikroelektronika for that. What I do not like too much in MikroC is lack of convenient and simple serial input/output functions and formatted output - if you want to output a phrase, you have to output letter by letter which is a pain. Also output of a value as text is not as simple as in PBP. But their signed word and long variables and floating point math are a definite plus (works even on 8 pin PIC12). I use 8 pin PICs in current project and it looks like compilers from Microchip do not have math library for such micros, they also do not have graphic library for PIC18 etc. so MikroC was my choice for this project. I like MikroC because their libraries (includung graphic) can work on any small PICs as long as hardware (pin count, etc) is sufficient for the project.

I guess 90% of my projects are done on PBP and I like it very much. Are there any future plans for PBP compiler or it is now matured and no more development is planned?

mackrackit
- 15th September 2014, 12:43
http://melabs.com/resources/fp.htm
http://support.melabs.com/threads/1012-Floating-point-rutines-in-PBP?

Art
- 14th April 2015, 05:19
Though this is fairly old, right now I’m writing C code for dspic33FJ64GP just to do floating point math
where I’m still more proficient with the rest of the program to use a 16F628A in the same circuit.
Two chips have to talk some serial with each other. Quite crazy since then the board requires
two regulators for two supply voltages and level conversion for connections between the 3.3 Volt dspic and any 5 Volt pic or peripherals.

The dspic is really only for some numbers go in, it does it’s sin, cos, tan, and some different numbers come out.

pedja089
- 14th April 2015, 08:01
Why you need FP for trig function?
You can use lookup table and linear interpolation to get 3-4 decimal places resolution.
Melanie already done that
http://www.picbasic.co.uk/forum/showthread.php?t=718&p=2873#post2873
And just found this
http://www.picbasic.co.uk/forum/content.php?r=202-Cordic-Trig-Functions-with-PicBasic-Pro
So I think that you can do all that in one pic.
And you can use N bith math, or FP rutines, is long isn't enough... And it must be faster to do that in one PIC, than to sent and receive data thru UART.

Dave
- 14th April 2015, 12:03
Hey Art, Being you like to work with the 16F628's you might have a look at using one of the 16F1847's to replace it. 8K of flash, 1K of ram, 256 bytes of eeprom and 32Mhz. I have replaced a few 16F628's from old projects and they work a treet...

Art
- 14th April 2015, 15:18
I did give a a lot of thought of getting it into one chip, and it would definitely be the dspic
since I already have implemented the functions I want into another program for the same chip.
This is just the first time I’ve had to do the hardware. The last one was a kit web server.

Since I want the LCD to be continually driven, and am more apt with fancy graphics with an 8 bit pic,
that’s the reason to consider the second chip.
If I was happy with a fairly static LCD display, it would be easy with the dspic alone.
The algorithms are Sunrise/set, Moonrise/Set, and Moon Illumination for a clock.