08 Nov 2018 19:23 #120284 by yeepah
Logarithm was created by yeepah
I feel dumb
I try to install this code as compoment file .comp:

float thermistor2temperature(float R) {
float T;
if (R<=0)
R=0.001; // avoid log(0)
T = 1.0/ ( 1.0/T0 + (1.0/B) * log(R/R0) );
return T;

I do include #include <rtapi_math.h>

During compilation i get error : implicit declaration of function 'log'

What am I doing wrong???
08 Nov 2018 23:01 #120297 by Grotius
Replied by Grotius on topic Logarithm

#include <rtapi_math.h>

Will work.

You have to check your formula.
09 Nov 2018 09:12 #120317 by yeepah
Replied by yeepah on topic Logarithm
Thanks for your answer
But still don't want corporate. log( anything) always return implicit declaration of fonction 'log'
It's really weird and i don't know in which direction to look to find a solution
09 Nov 2018 11:20 #120324 by rodw
Replied by rodw on topic Logarithm
What happens if you use doubles?
double thermistor2temperature(double R) {
double T;

I suspect a type error
09 Nov 2018 12:07 #120325 by yeepah
Replied by yeepah on topic Logarithm
I thought that also. And I try it again.
I even try with with a log alone like
double R = log(133)
but it return alway the same error

I'm a bit lost
Do you have an idea were can i find a log code function. I could write it but my mathematique skill are a bit poor.
09 Nov 2018 13:14 #120327 by Hakan
Replied by Hakan on topic Logarithm
You can test with
#include <math.h>
09 Nov 2018 13:17 #120328 by rodw
Replied by rodw on topic Logarithm
Hmm, log() is not included in rtapi_math.h github.com/LinuxCNC/linuxcnc/blob/master/src/rtapi/rtapi_math.h

I would search for the C code in the GCC compiler for the log function and add it to my component.

Or try and add it to the header file....
09 Nov 2018 13:22 #120329 by andypugh
Replied by andypugh on topic Logarithm

I don't see a log function in rtapi_math.

There is a simple (recursive) log2() function here:

And log10(N) = log2(N)/log2(10)

I just noticed that the log2 above is calculated as an integer, so might not give the accuracy you need.

Why do you need a logarithm in HAL? Maybe there is another way?
09 Nov 2018 14:00 #120330 by yeepah
Replied by yeepah on topic Logarithm
thanks for your answers

I will work on that

I using linuxcnc to drive a reprap. I'm following and adapting the work of this guy.

Using hal encoder with NTC resistor and ne555 chip to control PID and pwmgen.
Thermistor change a frequency read by linuxcnc.....regulate extruder and hotbed temperature
To calcul the temperature with the frequency I need a log

I will work on the direction you give. And come back with the result
09 Nov 2018 14:09 #120331 by andypugh
Replied by andypugh on topic Logarithm
LinuxCNC 2.8 (development version) includes this:

And also this:

But for 2.7 it might be simplest to use this:
Time to create page: 0.108 seconds
Powered by Kunena Forum