Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Ntc calibration error

Status
Not open for further replies.

johnny78

Full Member level 4
Joined
Jun 28, 2017
Messages
209
Helped
1
Reputation
2
Reaction score
4
Trophy points
18
Activity points
1,723
i was looking for a way to use my NTC with arduino & i found alot of easy projects & ways to do that

one of them
https://www.ametherm.com/blog/thermistor/arduino-and-thermistors

the code
Code:
#include <LiquidCrystal.h>

int ThermistorPin = A0;
int Vo;
float R1 = 3000;
float logR2, R2, T;
float A = 2.783297339, B = -0.4139621528, C = 17.57815707;  // Steinhart-Hart and Hart Coefficients

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
Serial.begin(9600);

}

void loop() {

Vo = analogRead(ThermistorPin);
R2 = R1* (1023.0 / (float)Vo - 1.0);
logR2 = log(R2);
T = (1.0 / (A + B*logR2 + C*logR2*logR2*logR2));  // Steinhart and Hart Equation. T  = 1 / {A + B[ln(R)] + C[ln(R)]^3}
T =  T - 273.15;

//lcd.print("TEMP = ");
//lcd.print(T);
//lcd.print(" C");

Serial.print(T);

delay(500);     // Time delay 10 Milliseconds
lcd.clear();

}

when i tried to test this i get 0 on serial monitor or Just -273.15 So the next line is useless

Code:
T = (1.0 / (A + B*logR2 + C*logR2*logR2*logR2));  // Steinhart and Hart Equation. T  = 1 / {A + B[ln(R)] + C[ln(R)]^3}
& i tried to read the vo & yes it works & the value varies when changing temp on the Ntc

would you check the code please?

best regards
Johnny
 
Last edited:

Hello!
I have checked the link above. Do you use that schematic?
If you read 0, what may happen is that your variable resistor is temporarily 0 ohm.
Check the resistance of your variable reistor, set it to around 2 kohm, and don't move
it until you get some value on A0.
You may also consider reading the value of A0 with a multimeter and check if it's a
reasonable value, in the 2 ~ 3V range.
By the way, are you really calculating a logarithm? Usually you don't have to. You should
use a lookup table.

Dora
 

Hello!
I have checked the link above. Do you use that schematic?
If you read 0, what may happen is that your variable resistor is temporarily 0 ohm.
Check the resistance of your variable reistor, set it to around 2 kohm, and don't move
it until you get some value on A0.
You may also consider reading the value of A0 with a multimeter and check if it's a
reasonable value, in the 2 ~ 3V range.
By the way, are you really calculating a logarithm? Usually you don't have to. You should
use a lookup table.

Dora
hi Dora
i've mentioned that i tried to read the Vo variable which reads the A0 & it works
(By the way, are you really calculating a logarithm? Usually you don't have to. You should
use a lookup table.)
this is the logarithm they use to read the NTC & i think WHY i should use Lookup table ?
its a solution i guess but not a professional one & that algorithm helps me because i want to read temp
from -25 to 25 which i cant get -25 easily

regards
Johnny
 
Last edited:

Hello!

this is the logarithm they

Who are "they"? The fact it's published somewhere on the net is not a guarantee of code
quality.

Usually in an embedded system, if you want to keep a small footprint, you don't use float
or double numbers, which is why you don't use logs. Especially on a small span like -25 ~ +25,
you would need an array of 50 values or even less if you use interpolation.

OK, anyway, if you can measure something with A0, it's good news. Now measure the raw
output of the ctn measurement point. If it changes when you hold the ctn, it works.
From there you will know if the problem is physical or software (i.e if you can see a variation
when you heat the ctn, then your software is wrong. Just debug it.

Dora.
 

Hello!



Who are "they"? The fact it's published somewhere on the net is not a guarantee of code
quality.

Usually in an embedded system, if you want to keep a small footprint, you don't use float
or double numbers, which is why you don't use logs. Especially on a small span like -25 ~ +25,
you would need an array of 50 values or even less if you use interpolation.

OK, anyway, if you can measure something with A0, it's good news. Now measure the raw
output of the ctn measurement point. If it changes when you hold the ctn, it works.
From there you will know if the problem is physical or software (i.e if you can see a variation
when you heat the ctn, then your software is wrong. Just debug it.

Dora.
thanks Dora
yes my problem is software
give me an idea to get the resistance of my NTC at -25c
i can start testing from 0c to 100c easilty
i got already 5c 25c 45c as the mentioned for steinhart equation

thanks
Johnny
--- Updated ---

i've found this method & it works great

https://learn.adafruit.com/thermistor?view=all
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top