cancel
Showing results for 
Search instead for 
Did you mean: 

Is stm32 micro-controls are capable to calculate Natural Logarithm ?

LACTIC
Associate II

I am using Thermistor (NTC Type ) as temperature sensor .

So to calculate the temperature from adc value of STM32 I am using this formula(taken from this site :- https://www.jameco.com/jameco/workshop/techtip/temperature-measurement-ntc-thermistors.html)

1/T = 1/T0 + 1/B * ln( ( adcMax / adcVal ) – 1 )

where :-

T0= 298.15 K

B=3345.80 K

I am using Board 6-Bit adc .

So I want ask that can I use above formula in my program, because I am confuse that controller can calculate "ln (Natural Logarithm) ".

5 REPLIES 5
saiteja
Associate II

Interface temperature sensor with any of the adc pin in controller, from pin read the value

sysTemperature = HAL_ADC_GetValue(&hadc1); 

sysTemp_inmV = ((float)sysTemperature/4096.0) * 3300; //ref = 3.3

sysTemp_inCel = sysTemp_inmV/10

Thanks.

Here 12bit adc enable ?

Because 4096 is value 2^12.

Following functions calculate the natural logarithm (base e):

#include <math.h>

double log(double x);

float logf(float x);

long double logl(long double x);

You may also try to avoid the log calculation by tabulating the function at a suitable step and linearly interpolate between the steps; or by fittingthe function by polynomial.

JW

OK

Does this mean that you got the answer you look for? If yes, please click on "Select as Best" for the good answer.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.