Calculation of the tabular functions for microcontrollers

Calculation of the tabular functions for microcontrollers

When programming microcontrollers sometimes there is a problem of calculation of math functions. And despite the fact that the standard AVR GCC library includes support for float numbers and basic math calculations, in practice is not always possible to use these routines. Because AVR microcontrollers do not have a math coprocessor and instructions for operations with float numbers, the use of standard library routines leads to the generation of relatively cumbersome and slow code. Therefore, to calculate the "complex" mathematical functions often resort to the table method. In this case function pre-calculated and the values are written to the array, and then taken out of it. To reduce the size of the array, you can use linear interpolation.

This online-calculator allows generate source code for any functions. The code generated for the AVR GCC compiler. It automatically selects the type of the argument and the function return value based on the entered data.

The function is written in JavaScript. Possible to use the following constants and functions:

Further specifies the range of the argument and the step for the tabular function. The argument can only be a positive number of not more than two bytes. The "Generate" button will display the graph of and generate C-code. The graph solid blue line shows the original function, green - tabular points and a linear fit for them.

Enter the function expression for the argument x:

The range of of the argument x: from to with step

Function name:

Source code:

No votes yet