Offline
Full Member
Karma: 0
Posts: 107
|
 |
« on: February 04, 2013, 08:51:40 pm » |
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
Edison Member
Karma: 9
Posts: 1001
|
 |
« Reply #1 on: February 05, 2013, 09:23:29 am » |
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
God Member
Karma: 9
Posts: 836
|
 |
« Reply #2 on: February 22, 2013, 12:08:11 pm » |
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
|
|
|
|
|
Netherlands
Offline
Tesla Member
Karma: 87
Posts: 9392
In theory there is no difference between theory and practice, however in practice there are many...
|
 |
« Reply #3 on: February 22, 2013, 12:46:33 pm » |
google is your friend - http://sourceforge.net/projects/avrfix/ - never used btw
|
|
|
|
« Last Edit: February 22, 2013, 12:48:11 pm by robtillaart »
|
Logged
|
|
|
|
|
Offline
God Member
Karma: 9
Posts: 836
|
 |
« Reply #4 on: February 23, 2013, 03:30:18 am » |
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
|
|
|
|
|
Netherlands
Offline
Tesla Member
Karma: 87
Posts: 9392
In theory there is no difference between theory and practice, however in practice there are many...
|
 |
« Reply #5 on: February 23, 2013, 05:59:54 am » |
@michinyon Can you post the links you found? & your results?
TIA
|
|
|
|
|
Logged
|
|
|
|
|
Offline
God Member
Karma: 9
Posts: 836
|
 |
« Reply #6 on: February 24, 2013, 03:57:31 am » |
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
|
|
|
|
|
Netherlands
Offline
Tesla Member
Karma: 87
Posts: 9392
In theory there is no difference between theory and practice, however in practice there are many...
|
 |
« Reply #7 on: February 24, 2013, 06:45:48 am » |
@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
|
|
|
|
|
Offline
God Member
Karma: 9
Posts: 836
|
 |
« Reply #8 on: February 24, 2013, 08:12:12 am » |
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
|
|
|
|
|
Netherlands
Offline
Tesla Member
Karma: 87
Posts: 9392
In theory there is no difference between theory and practice, however in practice there are many...
|
 |
« Reply #9 on: February 24, 2013, 09:09:58 am » |
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
|
|
|
|
|
|