Go Down

Topic: How do I find avr fixed point library? (Read 755 times) previous topic - next topic

memotick

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

Krodal

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.

michinyon

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 ?

robtillaart

#3
Feb 22, 2013, 06:46 pm Last Edit: Feb 22, 2013, 06:48 pm by robtillaart Reason: 1
google is your friend

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

never used btw
Rob Tillaart

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

michinyon

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.

robtillaart

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

TIA
Rob Tillaart

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

michinyon

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.

robtillaart

#7
Feb 24, 2013, 12:45 pm Last Edit: Feb 24, 2013, 03:01 pm by robtillaart Reason: 1
@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
Rob Tillaart

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

michinyon

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.

robtillaart

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
Rob Tillaart

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

Go Up