I have been bouncing my head on this for a few days now. Everything seems coded how I would like it as far as the temperature control formulas. And the whole setup is accurate to 1% at the moment. Almost as soon as my actual temperature reaches 80degC + I get a "nan" value. Does anyone have any ideas why this could be happening? My appologies for the lack of comments, I was going to go back and put them in after I had the code where I wanted it.
What value pull up resistor did you use with the thermistor.
Should be about the same value as the thermistor at the temp of interrest.
So NOT 100k for a 100k thermistor if you use it for a hotbed.
Leo..
This is also a lot of code to look through not knowing where to look. So please write a minimal sketch that demonstrates the problem: in this case just read the probe, calculate the temperature, and print it to Serial monitor.
That at least tells you whether the probe works as expected.
I noticed references to a 4.096V reference voltage in your code - how is it all wired up? You use some external precision reference for this?
If that's also used as supply for the NTC (precision reference + buffer would do quite well) it should give a good job. Myself I'd still wire an NTC using Vcc as supply, and a regular analog input. Less components for the same result.
And another thing, looking back at the code: using the B-coefficient equation and "accurate to 1%" also doesn't normally go well together, except for a very small range around the nominal temperature/resistance (not necessarily the 25 degree values - you may measure the actual resistance of your NTC at whatever typical working temperature you have and use that for nominal values, will give much more accurate results).
Wawa:
What value pull up resistor did you use with the thermistor.
Should be about the same value as the thermistor at the temp of interrest.
So NOT 100k for a 100k thermistor if you use it for a hotbed.
Leo..
Currently I have a 100k(97k8 actual) resistor as the pull up resistor.
wvmarle:
This is also a lot of code to look through not knowing where to look. So please write a minimal sketch that demonstrates the problem: in this case just read the probe, calculate the temperature, and print it to Serial monitor.
That at least tells you whether the probe works as expected.
I noticed references to a 4.096V reference voltage in your code - how is it all wired up? You use some external precision reference for this?
Wawa:
Good catch.
4.096volt assumes an external A/D, and most of them can't be used with a (ratiometric) thermistor.
Need to see a device list and diagram.
Leo..
I am using an ADR444BRZ currently for AREF and to power the thermistor. I will draw up to show the thermistor sketch and post that when complete.
I am rather pleased with this set up right now it is more accurate than I expected <80degC. As soon as it hits 80 I get a "nan" value for my actual temp reading. The bed continues to heat after this point since there is no value to shut off the relay. I am shooting for ~100degC for ABS that I will probably run fairly often. It was at 95degC when I shut it off since I had no control to stop it once it got to that point. I am using an infrared thermometer to compare my readings to physical temp.
wvmarle:
If that's also used as supply for the NTC (precision reference + buffer would do quite well) it should give a good job. Myself I'd still wire an NTC using Vcc as supply, and a regular analog input. Less components for the same result.
And another thing, looking back at the code: using the B-coefficient equation and "accurate to 1%" also doesn't normally go well together, except for a very small range around the nominal temperature/resistance (not necessarily the 25 degree values - you may measure the actual resistance of your NTC at whatever typical working temperature you have and use that for nominal values, will give much more accurate results).
You have a point. When I originally wrote this program I did not have access to an accurate thermometer that could handle this. I may be able to use the A,B,C steinhart-hart equation once I get some resistance readings.
A 100k thermistor is about 10k@82C.
So use a 10k pull up resistor if you are interested in the temp of a hotbed.
That will increase resolution at high temp.
Probably won't fix 'nan' (not a number?), but it might move the error upwards.
As wvmarle said, write a simple sketch that demonstrates the problem.
Would have been easier to use the 3.3volt supply as reference instead of a separate chip.
(assuming an Uno, and nothing else connected to 3.3volt)
Absolute voltage is irrelevant with a ratiometric sensor.
Leo..
Indeed, wrong resistor value. Needs something much closer to the 100°C value of the NTC. Measure this, or check the data sheet.
Also I'm used to see a pull-up resistor rather than the pull-down you use, and using Vcc and not bothering with getting a separate reference voltage, as Vcc is the reference for the Arduino's ADC already. Saves quite a few components. See also this Adafruit tutorial about using a thermistor.
Indeed, wrong resistor value. Needs something much closer to the 100°C value of the NTC. Measure this, or check the data sheet.
Also I'm used to see a pull-up resistor rather than the pull-down you use, and using Vcc and not bothering with getting a separate reference voltage, as Vcc is the reference for the Arduino's ADC already. Saves quite a few components. See also this Adafruit tutorial about using a thermistor.
Sorry about the confusion. I will use that as a learning experience.
I tried both methods and I saw the best results with a pull down method. I will try again when I have time to mess with changing the resistor.
If I use a resistor closer to my target temperature of 100degC will I loose accuracy at lower temperatures?
Bunkest:
I tried both methods and I saw the best results with a pull down method. I will try again when I have time to mess with changing the resistor.
If I use a resistor closer to my target temperature of 100degC will I loose accuracy at lower temperatures?
There is NO difference. The thermistor between pin and ground is usually SAFER, because there is no 5volt going to the hotbed that can short out.
Yes.
Thermistors have the highest number of A/D steps per degreeC if fixed resistor is the same as thermistor value.
That's why we recommend the ~10k resistor with a 100k thermistor for hotbed use.
Should still have some steps per degreeC at room temp though (try to calculate it).
Leo..
Bunkest:
If I use a resistor closer to my target temperature of 100degC will I loose accuracy at lower temperatures?
Yes - thermistors have effectively a limited range.
Also the B-coefficient formula loses accuracy that far from the nominal temperature, but it's accurate enough to tell you whether it's safe to touch the filament.