How do I find avr fixed point library?

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

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.

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 ?

google is your friend

never used btw

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.

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

TIA

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.

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

Or use lookup tables - Arduino Playground - 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

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.

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