Pages: [1]   Go Down
Author Topic: How do I find avr fixed point library?  (Read 734 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 158
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry for the basic question... I read on hear that the Arduino IDE uses the avr library and may even contain the fixed point library.  However, I cannot find it.  Do I need to install something?

Thanks in advance
Logged

Offline Offline
Edison Member
*
Karma: 9
Posts: 1016
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Search the forum for fixed-point.

I don't know if the Arduino IDE is capable to set user defined compiler flags yet. But changing the avr libraries could get you into troubles with the default Arduino libraries.

Please tell us why you need it. Perhaps other possibilities exist for what you want to do.
Logged

Offline Offline
Faraday Member
**
Karma: 62
Posts: 3080
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was wanting to do the same thing.

Floating point calculations are too slow,   it is possible to encode the same problems using what is effectively
integer arithmetic as far as the cpu hardware is concerned.

Has anybody actually tried this,   or do I have to re-invent the wheel ?
Logged

Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 227
Posts: 14021
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

google is your friend

- http://sourceforge.net/projects/avrfix/ -

never used btw
« Last Edit: February 22, 2013, 12:48:11 pm by robtillaart » Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Faraday Member
**
Karma: 62
Posts: 3080
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I found about 5 different ones, and I am attempting to test them.   However, I am
not convinced it is very worthwhile on an 8 bit processor anyway.
Logged

Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 227
Posts: 14021
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@michinyon
Can you post the links you found? & your results?

TIA
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Faraday Member
**
Karma: 62
Posts: 3080
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As I said,   I found about 5 fixed point implementations on the net.  I downloaded and looked at them,  most
of them compiled OK  but I didn't go ahead and test them thoroughly

Most of them were based on 4 byte numbers and I came to the conclusion that on an 8-bit machine they
were going to be almost as bad as floats.

So I went ahead and implemented a fixed point scheme based on 2 byte numbers with 14 fractional bits.
This allows numbers between -2 and +1.999  only,  and 14 fractional bits,  which is fine for the application I have in mind,
I think.

I'm testing this to see if the accuracy is sufficient  and the speed improvement is worthwhile.  It might be
easier to just get a faster device.
Logged

Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 227
Posts: 14021
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@michinyon
Maybe your math can be simplified analytically. (sin/cos => tan etc)

Or use lookup tables - http://playground.arduino.cc/Main/MultiMap - saved my performance more than once with non linear functions.

Have you tried mapping the math on long integers
+ faster than float
+ more significant digits,
- not all functions work
- limited range
« Last Edit: February 24, 2013, 09:01:14 am by robtillaart » Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Faraday Member
**
Karma: 62
Posts: 3080
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well any "fixed point" scheme seems to work by using the long integers,  so yeah.  I'm implementing a simple one with
16 bit variables.

The other thing I have found,  is the very bad schemes used to calculate sine and cosine,  you would think they
would know better.
Logged

Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 227
Posts: 14021
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The other thing I have found,  is the very bad schemes used to calculate sine and cosine,  you would think they
would know better.

Did make a faster sine in the past [trading speed for accuracy] - http://arduino.cc/forum/index.php/topic,69723.0.html

Also interesting is CORDC - http://arduino.cc/forum/index.php/topic,75126.0.html - reply 33
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: