Helo everybody, i'm trying to convert a simulink model from float to fixed point variables to see if i can improve or not its velocity on arduino. i should decide a suitable data type to run on target for Arduino mega2560. simulink suggestion is: fixdt(Signed, WordLength, FractionLength). however,it's not clear (to me) if that data type becomes an int type on arduino or not and how it is treated in that case. i've tried a trivial model using that data type, it runs on arduino but doesn't seem to improve velocity.. what do you think about it?

i've tried a trivial model using that data type, it runs on arduino but doesn't seem to improve velocity..

A trivial example will not, but how about one where you do some arithmetic on the value. Post the code if you want specific help.

the simple model was still in simulink and i did it just to know if arduino can handle fixdt data type. i wouldn't even know how to write that data type on the ide. is there any easier way to represent a fixed point variable?

There is no "fixed point" type for Arduino, as far as I am aware.

What you can do, is represent your problem using integers. For example, if your GPS problem originally uses floating point numbers which represent metres, you can change it to use integers which represent millimetres.

What is the range of values that your fixed type requires? Are you most concerned with speed or accuracy?

The type needs to be chosen so that the variables can hold the full range of values that they need to hold. So you need to work out what the range of possible values is, and then choose the appropriate integer type to hold those values.

For example if you need to hold a percentage (0 … 100) to three decimal places then the range of possible values is 0 … 100000; a long is the most appropriate integer type for that range.

hi guys

i have a similar question how do you limit the amount of digits to the right of the decimal point

temp_f = sht1x.readTemperatureF(); lcd.print("Temperature: "); lcd.print(temp_f, DEC);

prints way to many digits i just want to print 2 digits to the right of decimal point

thanks

devobtch

```
lcd.print(temp_f);
```

Default, two decimal places.

lloyddean: What is the range of values that your fixed type requires? Are you most concerned with speed or accuracy?

i have variables with quite different ranges of value, but i did specify that on the model. the model is not so slow when using double type, so i'm interested in good accuracy

PeterH: and then choose the appropriate integer type to hold those values.

clear. when i choose to my question is just if you know something about how this fixdt data type works on arduino (in the signal notation of simulink, an example of this variable is called sfix16_en5 - 16 is the word lenght, 5 the fraction lenght - and it's a fixed point data type which uses int16 as "container") thank you

thanks AWOL

devobtch