Logarithm

More
08 Nov 2018 19:23 #120284 by yeepah
Logarithm was created by yeepah
Hy
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???
thanks

Please Log in or Create an account to join the conversation.

More
08 Nov 2018 23:01 #120297 by Grotius
Replied by Grotius on topic Logarithm
@Yann,

#include <rtapi_math.h>
log(10);

Will work.

You have to check your formula.

Please Log in or Create an account to join the conversation.

More
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

Please Log in or Create an account to join the conversation.

More
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

Please Log in or Create an account to join the conversation.

More
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.

Please Log in or Create an account to join the conversation.

More
09 Nov 2018 13:14 #120327 by Hakan
Replied by Hakan on topic Logarithm
You can test with
#include <math.h>

Please Log in or Create an account to join the conversation.

More
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....

Please Log in or Create an account to join the conversation.

More
09 Nov 2018 13:22 #120329 by andypugh
Replied by andypugh on topic Logarithm
github.com/LinuxCNC/linuxcnc/blob/master/src/rtapi/rtapi_math.h

I don't see a log function in rtapi_math.

There is a simple (recursive) log2() function here:
www.geeksforgeeks.org/program-to-compute-log-n/

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?

Please Log in or Create an account to join the conversation.

More
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.
www.anderswallin.net/2012/12/temperature-pid-control-part-deux/

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
thanks

Please Log in or Create an account to join the conversation.

More
09 Nov 2018 14:09 #120331 by andypugh
Replied by andypugh on topic Logarithm
LinuxCNC 2.8 (development version) includes this:
linuxcnc.org/docs/devel/html/man/man1/thermistor.1.html

And also this:
linuxcnc.org/docs/devel/html/man/man9/max31855.9.html

But for 2.7 it might be simplest to use this:
linuxcnc.org/docs/devel/html/man/man9/lincurve.9.html

Please Log in or Create an account to join the conversation.

Time to create page: 0.142 seconds
Powered by Kunena Forum