Strona 1 z 1
Odczt NTC
: 09 maja 2022, 18:43
autor: grzeniu 73
Witam.
Nie znalazłem takiego tematu. Ma ktos jakiś przykład przekształcania napięcia z NTC na temperaturę. Dowolny ntc ,bo nie mam konkretnego.
Podłączone mam w ten sposób ,ze rezystor podciągnięty do 5v, ntc do masy i na środku mierze napięcie. Potrzebuje wzór do tego przekształcenia.
Pozdrawiam!
Re: Odczt NTC
: 09 maja 2022, 18:47
autor: niveasoft
One są nieliniowe i dlatego tam do obliczeń potrzebny jest logarytm. Jak się w programie nie spieszy to liczy się na bieżąco a jak program wymagający czasowo to tworzy się gotową tablicę stałych i sięga po gotowe dane na podstawie odczytów z ADC.
Jak nie znajdziesz to musiałbym odkopać mój kod do laminatora
Tu link do rozwiązania z tablicą ->
https://www.mcselec.com/index.php?optio ... &Itemid=57
A poniżej kod do sposobu z obliczeniami z tego tematu ->
https://www.mcselec.com/index2.php?opti ... hlight=ntc
'************************************************************************************
' 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
Ogólnie to wpisujesz w wyszukiwarkę MCS NTC i jest sporo gotowych tematów.
Re: Odczt NTC
: 09 maja 2022, 20:34
autor: grzeniu 73
Dzieki. Sprawdzę sobie. Właśnie teraz mam tablice. Włożyłem termometr do wody i zapisałem odczyty.