Forum - MCS Electronics

Author Message
Per Svensson

Joined: 03 Oct 2004
Posts: 185
Location: Gothenburg, Sweden

 Posted: Sat Aug 17, 2019 4:46 pm    Post subject: Use math for NTC temperature calculations Using tables for calculating temperature from thermistor readings is not very flexible when Alfa and Beta parameters varies A more general method is to use the formula Temp(Celcius) =Ro*EXP(Beta/(273.15+\$A32)-Beta/(273.15+25)) See attached Excel sheet where you can simulate all variants as long as Alfa and Beta are known. If there is an interest I can also upload a bascom implementation so you don't have to figure out the math coding /Per
Per Svensson

Joined: 03 Oct 2004
Posts: 185
Location: Gothenburg, Sweden

 Posted: Sat Aug 17, 2019 5:14 pm    Post subject: … And here is the code '************************************************************************************ ' A thermistor is connected from Vref (+5V) to GND via a resistor R1. ' The voltage to the ADC is a nonlinear representation of the temperature. ' NTC resistance is nominally Res25 ohm at 25degC and R1 is fixed and can be any value. But.. ' the best accuracy when R1 is selected to equal NTC's resistance at the temp where best accuracy is desired. ' See Excel spreadsheet "NTC beräkningar.xls" ' /---> To ADC ' | 'Vref o---NTC---o---R1-----| 'Farnell 732-138 Const Beta = 3620 'Thermistors Beta value Const Res25 = 10000 'Thermistors resistance at 25 deg C Const Res1 = 10000 'Fixed resistor to ground (Ususally close to Res25) Function Adc_to_temp(byval Adcval As Word) As Single '**************************************************************** ' Convert from ADC reading to temperature Celsius ' T = 1/Beta(ln(R1/R25((1024/ADCVAL)-1))+1/(273.15+25)) - 273.15 '**************************************************************** Local X As Single X = Adcval 'Avarage voltage expressed in ADC-units (0-1023) 'convert ADC-output to temperature using a logarithmic relation: X = 1024 / X 'Ratio of max value X = X - 1 X = X * Res1 'Resistor connector to ground 'X is now the resistance of the thermistor. Compute the temperature this represents X = X / Res25 'NTC resistance at 25 deg C X = Log(x) X = X / Beta X = X + 0.003354 X = 1 / X X = X - 273.15 'Kelvin -> Celsius 'T is now the true temperature in degrees Celsius Adc_to_temp = X + Temp_offset 'adjust sample with offset and Return result End Function
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT + 1 Hour Page 1 of 1

 Jump to: Select a forum BASCOM AVR/8051----------------BASCOM-AVRBASCOM-8051BASCOM-ARDUINOShare your working BASCOM-8051 code hereShare your working BASCOM-AVR code hereBASCOM BETA-SLA BASCOM Related----------------EASY TCP/IPAVR-DOSAR7212KokkeKat FAT-free SD card libBASCOM Project Blog Other Stuff----------------VariousPCB'sRoboticsNew WebSiteAnnouncementsAVR Archive----------------BASCOM-AVR ArchiveBASCOM-8051 ArchiveBASCOM-AVR Unsupported versionsEasy TCP/IP ArchiveBASCOM-EDB
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum