Thermistor Calibration

370 views
Skip to first unread message

Ian Johnson

unread,
Feb 24, 2012, 10:52:08 AM2/24/12
to MakerGear - Make Today, Change Tomorrow
I've finished putting together my new v3 hot end (from a Super Pack)
and I am not getting correct readings from the thermistor. My printer
is running Marlin on a Sanguinololu. I set the table to #1 (#define
THERMISTORHEATER_0 1 correct?) but by the time it gets to 185C and
above my thermometer shows the nozzle about 40C cooler than the
thermistor says it is. The ambient temperature before it heats up is
correct, and the readings begin to diverge at around 100C.

This is a different type of thermistor from what was on there before.
Do I need to change the beta value somewhere? I see a lot of
instructions that say to be sure and use the correct beta value, but
no mention of how to actually do it, especially with Marlin.

Michael Lenczewski

unread,
Feb 24, 2012, 4:07:13 PM2/24/12
to make...@googlegroups.com
I actually worked through a similar issue.  Sometimes it helps to slow down and ask yourself, what is really going on here...  First, you're essentially measuring temperature twice:  once with your reprap equipment and again with your external test equipment.  Who is right?  are they both wrong?  Who knows?

This is how the temperature stuff works on my set up; I use the same hot end as you do, so its a good guess that the thermistor is the same one.  Its a bit complicated so bear with me here:

The one lead of the thermistor connects to ground and a A/D pin.  That same A/D pin is tied high through a normal resistor.    Check out "voltage divider" on wikipedia to get the idea.

The microcontroller then essentially measures voltage on that A/D pin.  As the thermistor gets warmer, its resistance goes down in a not so linear, but predictable manner.  (That's why you need a lookup table, precomputing these saves the trouble of doing over and over again in code).  

The microcontroller measures the incoming voltage on that pin which is varied by the thermistor:  more voltage gets dumped to ground the hotter the thermistor gets.  The microcontroller reads a particular voltage actually gets a particular number based on how many "bits" your A/D is.  My A/D converter is 12 bits, so, I read out between 0 and 4096.  yours could be 10, so that's 2^10 or 1024.  But wait there's more:  its measures this with respect to a Voltage reference....  I noticed some wierdness with my Vref during prototyping, but if you have a proper board then you're probably OK here.  Basically you end up with a conversion factor, something like volts per A/D readings.  that being said, if your VREF is off, then this would definitely set your Temperature measurements off too.

Now the lookuptable is nice so you don't do needless repetitive arithmetic in your microcontroller.  The beta value is used in an equation to estimate the predicted resistance of the thermistor at a particular temperature.  So if you didn't generate your own table there's no place for the beta value.  I didn't bugger with the beta much here because the datasheet on mouser had a nice predicted ratios.

Now you know the Resistor value at a particular temperature, and you've got a voltage divider and an equasion for that.  One resistor stays the same while the other changes on temperature, so compute the resulting voltage using that equation on Wikipedia, for different values of temperature, say, every 10 degrees or so.  Then use your A/D info to convert that voltage into A/D readings.  now you should be able to go from temperature to A/D reading in one jump, no math in a look-up table.

Its even better to graph this out and you will see a nice stretch of temperatures that you'll be really accurate within, but not so accurate higher or lower, depending on the value you set for the OTHER resistor that ties the A/D pin high.  Google Docs worked quite well for this.

Its a few jumps, but my dev board is reading temperature with in a few degrees of my external temperature readings.  Enthusiastic because I learned several new things while figuring this out.

Ian Johnson

unread,
Feb 24, 2012, 4:53:39 PM2/24/12
to MakerGear - Make Today, Change Tomorrow

So the lookup table should be correct, it shows the theoretical
reationship between voltage and temperature for my thermistor. If
real world results are different, is it because the microprocessor's
calculation of the voltage coming from the thermistor is incorrect?
If my A/D is 10 bit, and the microprocessor calculates the voltage
based on a 12 bit number, then the difference would become more
pronounced as the temperature rises, correct?

Is this the order of operations- thermistor heats up, the voltage
changes and is read by the A/D converter which outputs a value from
0-1024 or 0-4096 depending on the bits. That value is read by the
microprocessor which determines what voltage it represents and
consults the lookup table to see what temperature corresponds to that
voltage.

If the voltage is getting calculated based on a 12 bit A\D rather than
10bit (if that is what I have), then where does that happen? Is it in
the firmware someplace where I can change it if it is incorrect? How
would I find out which kind of A/D the Sanguinololu has?

The other thing that could be wrong is the Vref, correct? How would I
troubleshoot that?




On Feb 24, 1:07 pm, Michael Lenczewski <michael.lenczew...@gmail.com>
wrote:

Triffid Hunter

unread,
Feb 24, 2012, 7:04:42 PM2/24/12
to make...@googlegroups.com
On Sat, Feb 25, 2012 at 8:07 AM, Michael Lenczewski <michael.l...@gmail.com> wrote:
Basically you end up with a conversion factor, something like volts per A/D readings.  that being said, if your VREF is off, then this would definitely set your Temperature measurements off too.

Actually this is quite irrelevant - We use vcc as vref, so it completely cancels out of the equation. the ADC senses the ratio between the two resistors, regardless of actual vcc voltage.

Michael Lenczewski

unread,
Feb 27, 2012, 10:30:58 AM2/27/12
to make...@googlegroups.com

Exactly.  It really depends on your board.  Been trying to dev my own board based on lpc1769...  i was noticing weirdness with my own setup.  Vcc for sang is prolly 5 volts.  Check the data sheets...  your a to d is probably 10 bits...  not sure, but ten bucks sez 10 bits.   Sorry for the crazy post.  Spent several hours figuring this out.

Shaun Saggers

unread,
Jun 17, 2013, 3:08:33 AM6/17/13
to make...@googlegroups.com
For anyone else who comes across this post while looking for info, This is what I did:
 
 
Gives three options for calibrating your thermistor based on 1.) manufacturer R/T tables, 2.) a set of measured calibration points, or 3.) Beta value for thermistor.
 
   And it's in excel, so you can see what the maths is doing (aside from the pre-solved polynomial equations for the Steinhart-Hart coefficients, which probably involved some maths I haven't done since university, so I stole the solutions from the referenced document)
 
Shaun
Reply all
Reply to author
Forward
0 new messages