double precision float on ESP8266

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
ThomasChr
Posts: 121
Joined: Sat Nov 25, 2017 7:50 am

Re: double precision float on ESP8266

Post by ThomasChr » Wed May 22, 2019 4:51 am

Phew, okay that sound resonable!

Just ask if you have any problems building the firmware!

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: double precision float on ESP8266

Post by pythoncoder » Wed May 22, 2019 8:24 am

The Pyboard D SF6W has hardware double precision FP. As far as I know the other ports which implement it do it in software.

Astronomical work definitely needs DP, especially if you get into things like predicting solar eclipses...
Peter Hinch
Index to my micropython libraries.

glubuluck
Posts: 12
Joined: Sun May 19, 2019 8:40 pm
Location: Brussels

Re: double precision float on ESP8266

Post by glubuluck » Wed May 22, 2019 8:29 am

pythoncoder wrote:
Wed May 22, 2019 8:24 am
The Pyboard D SF6W has hardware double precision FP. As far as I know the other ports which implement it do it in software.

Astronomical work definitely needs DP, especially if you get into things like predicting solar eclipses...
Thanks, good to know ! But not the same budget.. And actually i can manage with software implementation, since there is no time of computing issue.

pidou46
Posts: 101
Joined: Sat May 28, 2016 7:01 pm

Re: double precision float on ESP8266

Post by pidou46 » Fri May 24, 2019 6:31 am

Hi,

Sometime ago I made some thought, about this subject to build an heliostat.

The best option to me would be:
- port a fixed point precision library to microptyhon( the original one is python 3.1 so it should be quite easy)
- code the astronomic algorithm using this library.

Here is the thread for reference:
viewtopic.php?f=15&t=3405&p=19923#p19923

Finaly, I gived up because single precision was enough for me.
nodemcu V2 (amica)
micropython firmware Daily build 05/31/2016

pidou46
Posts: 101
Joined: Sat May 28, 2016 7:01 pm

Re: double precision float on ESP8266

Post by pidou46 » Fri May 24, 2019 3:30 pm

I have made some tests:

I got FixedPoint.py

To avoid an error I remove 'TypeError' from line 248 (I will check later thi point)

"class FXfamilyError(FXexception, TypeError): "

I upload it to my esp32.

import FixedPoint
x=FixedPoint.FXnum=(1)
y=FixedPoint.FXnum=(3)
print(x/y)
0.333333333333333333315

default family is 64bits

I try 128bit adn get an error
nodemcu V2 (amica)
micropython firmware Daily build 05/31/2016

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: double precision float on ESP8266

Post by jimmo » Fri May 24, 2019 3:59 pm

pidou46 wrote:
Fri May 24, 2019 3:30 pm
default family is 64bits

I try 128bit adn get an error
The FixedPoint library is quite large -- it's going to use up a significant amount of the RAM on your ESP8266.

This is probably why it fails at 128bit?

I generated an mpy module from FixedPoint.py and was able to do at least basic stuff in 128-bit.

Code: Select all

>>> a = FixedPoint.FXnum(1)
>>> b = FixedPoint.FXnum(3)
>>> print(a/b)
0.33333333333333333331
>>> f = FixedPoint.FXfamily(128)
>>> a = FixedPoint.FXnum(1, f)
>>> b = FixedPoint.FXnum(3, f)
>>> print(a/b)
0.333333333333333333333333333333333333332
To do that I checked out the repo at v1.10 (to match the firmware version on my ESP8266), and ran

Code: Select all

git checkout v1.10
cd mpy-cross
make -j 16
./mpy-cross -X emit=native -O3 ~/src/github.com/rwpenney/spfpm/FixedPoint.py
This gave me ~/src/github.com/rwpenney/spfpm/FixedPoint.mpy, which I put on the ESP8266 instead of the .py file.

A better approach would be to make a frozen module out of it, so the bytecode will be stored in ROM (Flash) instead. You'll have to build your own firmware, after placing FixedPoint.py in the ports/esp8266/modules directory.

pidou46
Posts: 101
Joined: Sat May 28, 2016 7:01 pm

Re: double precision float on ESP8266

Post by pidou46 » Fri May 24, 2019 5:56 pm

Thanks,

I hope it could help ThomasChr
nodemcu V2 (amica)
micropython firmware Daily build 05/31/2016

apollo2mond
Posts: 8
Joined: Wed May 29, 2019 6:17 pm

Re: double precision float on ESP8266

Post by apollo2mond » Sun Jun 02, 2019 6:45 pm

hi,, if i follow the described way i get this error:
TypeError: multiple bases have instance lay-out conflict

any further hints regarding?

many thanks

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: double precision float on ESP8266

Post by jimmo » Sun Jun 02, 2019 11:43 pm

apollo2mond wrote:
Sun Jun 02, 2019 6:45 pm
hi,, if i follow the described way i get this error:
TypeError: multiple bases have instance lay-out conflict
hi!
Sorry there have been lots of things described in this post - which part were you following?
It's possible though you might have run into to what @pidou46 said "To avoid an error I remove 'TypeError' from line 248 (I will check later thi point)"

glubuluck
Posts: 12
Joined: Sun May 19, 2019 8:40 pm
Location: Brussels

Re: double precision float on ESP8266

Post by glubuluck » Tue Jun 25, 2019 1:17 pm

Hello,
i just purchased an ESP32-WROOM-32, to try the Roberthh's solution : compile custom FW with double float on ESP32.
But actually, i need help for that...

What do i need ? (sources, compiler..)
How to get it work ?
sorry but my knowledge in micro-controller is just enough to flash regular FW
Thanks a lot

Matthieu

Post Reply