Showing posts with label thermistor. Show all posts
Showing posts with label thermistor. Show all posts

Tuesday, 26 February 2008

Thermal thoughts

I attached the wires of my new heater with some small crimps that I cut from connector pins like this:-



to just leave the crimp part :-



I also soldered them with lead free solder which melts at about 220°C rather than the tin lead solder that I used last time, which melts at 183°C. It could do with being higher still so I might see if I can buy some high temperature solder (301°C) for the next one I make.



Rather than insulate with the recommended heat shrink sleeving, which is only rated for 125°C, I used some high temperature woven sleeving. Even that seems to discolour at 240°C. PTFE sleeving might be better.



I pushed the wires from the thermistor into a two pin connector so that I can easily remove the nozzle.

I had to make a new mounting bracket because when I added the pipe around the PTFE insulator to stop it expanding it made it too big to go through the hole in my previous bracket, which also doubles as my spindle mount when milling.

The bit of aluminium box section I cut it from has been waiting for a new life since it appeared in a prototype electronic photo booth on Tomorrow's World in the early nineties.

I calibrated the thermistor by putting a thermocouple into a second hole in the nozzle with some silicon grease. I also put a second thermocouple inside the barrel. I then put a range of voltages across the heater and waited for it to reach thermal equilibrium before reading the temperatures and the resistance of the thermistor.



Notice how dark the J-B Weld has gone when briefly heated to 240°C.

I made the new heater resistance 7.1Ω compared to 8.6Ω last time because I guessed the acorn nut nozzle would have a larger surface area and hence greater heat loss. In fact it has a remarkably similar temperature power curve to my last nozzle.


Note that the difference between the internal and external temperatures is as much as 25°C. The PTFE tape I used to seal the nozzle may not be helping here. I also measured the outside temperature of the J-B Weld using an IR thermometer which read 242°C when the inside was 245°C and the nozzle was 220°C.

After calibrating the thermistor it seems to track the thermocouple within about 5°C.

Tuesday, 9 October 2007

Measuring temperature the easy way

I have been asked for more details on my temperature measurement scheme so I have consolidated some of my previous articles :-

The objective is to measure temperature from room temperature to about 250°C using a thermistor. The thermistor resistance is a extremely non linear. It is approximated by a negative exponential of the reciprocal of absolute temperature.

Ro is resistance at known temperature To, in this case 25°C, expressed in Kelvin. Beta is a second parameter of the thermistor which can be calculated if you know the resistance at two different temperatures or can be found on the data sheet.

The RepRap thermistor is an Epcos B57540G0103+, data sheet here. R25 is 10KΩ and beta is around 3500. Several values are given on the datasheet for different temperature ranges illustrating that the above equation is only an approximation. Here is a graph of its resistance against temperature :-


This can be made more linear by putting a fixed resistors in parallel. The magic value to use appears to be the value of the thermistor at the middle of the temperature range. In this case it is about 470Ω. Here is the resulting combined resistance, the formula for two resistors in parallel is :-

1/R = 1/R1 + 1/R2

I.e. the total conductance is the sum of the two conductances.


The resulting resistance is a lot more linear, however to measure temperature with an ADC we need a voltage rather than a resistance. This is easy, instead of wiring the resistor in parallel connect it in series to a voltage source equal to the full scale voltage of the ADC.



The voltage across the thermistor is then :-

V = Vref . Rth / (R + Rth)

Here is a graph of the the output voltage when Vref is 5V.



Note that the voltage decreases as the temperature rises. This could be inverted by swapping the resistor and thermistor but I prefer to keep one end of the thermistor at 0V so I can use single screened cable. It is also a good idea to put a capacitor across the ADC input to filter out any noise when using long leads like RepRap does. I used a 10uF tantalum bead.

Another consideration is how much power is dissipated in the thermistor as it will cause heating and alter the reading. The maximum dissipation will occur when its value equals the value of the resistor. At this point half the voltage is across the thermistor so the power dissipated in it is :-

P = (Vref / 2)2 / R

In the example above this works out at 13.3mW. The thermistor datasheet specifies a maximum of 18mW and a dissipation factor (in air) of 0.4 mW /K. I think this means that the temperature will rise by 33°C by self heating. The error would be less when not in air, but it is still perhaps a bit high. My system uses a Vref of 1.5 volts which, because it is a square law, only dissipates 1.2mW giving a 3°C rise at the mid range temperature in air.

For a 5V system is is probably worth sacrificing some of the ADC resolution to reduce the self heating error. This can be done by using two resistors :-



The full scale voltage is now :-

Vfsd = Vref * R1 / (R1 + R2)

We also want the source impedance of this voltage, which is R1 in parallel with R2, to be 470Ω.

1/R = 1/R1 + 1/R2

Solving these simultaneous equations gives :-

R1 = R / (1 - Vfsd / Vref)

R2 = R . R1 / (R1 - R)

So for Vfsd = 1.5V, Vref = 5V and R = 470:

R1 = 671Ω and R2 = 1569Ω, preferred values are 680 and 1K6.

And finally here is the Python code to work out the temperature :-
from math import *

class Thermistor:
"Class to do the thermistor maths"
def __init__(self, r0, t0, beta, r1, r2):
self.r0 = r0 # stated resistance, e.g. 10K
self.t0 = t0 + 273.15 # temperature at stated resistance, e.g. 25C
self.beta = beta # stated beta, e.g. 3500
self.vadc = 5.0 # ADC reference
self.vcc = 5.0 # supply voltage to potential divider
self.vs = r1 * self.vcc / (r1 + r2) # effective bias voltage
self.rs = r1 * r2 / (r1 + r2) # effective bias impedance
self.k = r0 * exp(-beta / self.t0) # constant part of calculation

def temp(self,adc):
"Convert ADC reading into a temperature in Celcius"
v = adc * self.vadc / 1024 # convert the 10 bit ADC value to a voltage
r = self.rs * v / (self.vs - v) # resistance of thermistor
return (self.beta / log(r / self.k)) - 273.15 # temperature

def setting(self, t):
"Convert a temperature into a ADC value"
r = self.r0 * exp(self.beta * (1 / (t + 273.15) - 1 / self.t0)) # resistance of the thermistor
v = self.vs * r / (self.rs + r) # the voltage at the potential divider
return round(v / self.vadc * 1024) # the ADC reading

Saturday, 22 September 2007

Temperature drop

My extruder controller is working much better after I cured the motor noise problem. The 10 bit SAR ADC also seems to work better than the 16 bit sigma-delta version did. With the 16 bit one there was a lot of noise on the readings, even when the motor wasn't running. I had to average over many samples to get a consistent reading which delayed the response. With the 10 bit ADC I just read it and compare it with the temperature set point value to decide if the heater should be on or off. That gives a temperature swing of about ± 3°C with the heater going on and off every four or five seconds.

The temperature is calculated from the ADC reading and vice versa by the PC with the following Python class :-
from math import *

class Thermistor:
"Class to do the thermistor maths"
def __init__(self, r0, t0, beta, r1, r2):
self.r0 = r0 # stated resistance
self.t0 = t0 + 273.15 # temperature at stated resistance, e.g. 25C
self.beta = beta # stated beta
self.vref = 1.5 * 1.357 / 1.345 # ADC reference, corrected
self.vcc = 3.3 # supply voltage to potential divider
self.vs = r1 * self.vcc / (r1 + r2) # effective bias voltage
self.rs = r1 * r2 / (r1 + r2) # effective bias impedance
self.k = r0 * exp(-beta / self.t0) # constant part of calculation

def temp(self,adc):
"Convert ADC reading into a temperature in Celsius"
v = adc * self.vref / 1024 # convert the ADC value to a voltage
r = self.rs * v / (self.vs - v) # resistance of thermistor
return (self.beta / log(r / self.k)) - 273.15 # temperature

def setting(self, t):
"Convert a temperature into a ADC value"
r = self.r0 * exp(self.beta * (1 / (t + 273.15) - 1 / self.t0)) # resistance of the thermistor
v = self.vs * r / (self.rs + r) # the voltage at the potential divider
return round(v / self.vref * 1024) # the ADC reading
It is instantiated as follows :-
thermistor = Thermistor(10380, 21, 3450, 1790, 2187)
10380 is the resistance of the thermistor measured by my multimeter at a room temperature of 21°C. 3450 is the beta of the thermistor taken from the data sheet. The last two values are the two resistors forming a potential divider with the thermistor wired across the second one, again the values are measured with a multimeter. The fudge factor of 1.357 / 1.345 corrects the MSP430 internal reference voltage so that it agrees with the multimeter.

The result seems to track the temperature measured by a thermocouple to within about 5°C, good enough for me. Just as I had finished checking it, I knocked the thermistor leads with my thermocouple and it fell off. It was stuck to the brass nozzle with JB Weld but I forgot to roughen the surface first. I am now waiting 16 hours for it to set again.

The extruder controller firmware is only about 400 lines of C. As well as temperature control it also controls the DC motor precisely using the shaft encoder and handles the I²C protocol.

I have now completed all the mechanical parts, the electronics and the firmware. I just need to get the RepRap host code to talk to my non standard hardware to complete the machine.

Friday, 14 September 2007

Toast

The first problem was easy enough to diagnose. Since I had rebuilt and rewired the circuit it had to be the thermistor itself. After removing it, I could see the underside was looking a bit toasted. I don't think it was designed for use up to 250°C. The insulation on the wire was not up to it and I suspect it was soldered to the actual device, and that the solder melted. There seems to be some solder on the brass nozzle now where it was mounted.



The remedy was easy: I just replaced it with the recommended glass bead thermistor which had arrived from back order in the meantime. It is rated to 300°C. Its characteristics are different so I had to change my resistor values, but I had anticipated that by mounting them on the connector rather than the board.

Saturday, 11 August 2007

Thermals

I need to knock up a controller for the extruder. This will take commands from the main controller via an I²C bus and control the motor speed and heater temperature. It may also need to control a fan to cool the workpiece and monitor a filament out detector.

I decided to drive the extruder with bench power supplies to see if it works first and get an idea of its parameters and hence the requirements for the controller. Here is my test setup :-



As you can see I have plenty of meters. I have been hoarding them for years but it is not often I get to use more than two at a time. Here I am measuring extruder voltage and current, temperature and thermistor resistance. I have another three or four about somewhere but I doubt I will ever need to measure 8 parameters!

The bench power supplies are ancient, I think the big one has valves in it and I built the small one when I was a child. I had a near perfect memory then so I never saw a need to label anything. I have several other items of equipment from that era, including an oscilloscope, with no labels on anything.

Here is the raw data I measured :-

PowerTemperatureResistance
0 W23 C2108 R
0.77 W48 C897 R
1.36 W64 C533 R
2.13 W87 C280 R
3.06 W114 C145 R
4.17 W145 C73 R
5.44 W173 C42 R
6.89 W207 C21.9 R
8.5 W243 C12.2 R

I plotted a graph of temperature against power. I expected it to be a straight line because the rate of heat loss is proportional to the temperature difference between the nozzle and its surroundings and at equilibrium that must equal the input power.


As you can see it is a bent line with a change of gradient at 150°C which I can't explain. I measured the temperature with a thermocouple inside the barrel. It is rated for use up to 250°C but the strange thing is that if I plot a graph of the temperature indicated by the thermistor then the graph is much straighter. I calculated the thermistor parameters from the thermocouple data ignoring the last three points.



So I am not sure what to make of it. I may have to repeat the experiment with my IR thermometer. As long as the thermistor measurements are repeatable I don't suppose absolute accuracy is necessary, other than to swap setting with other RepRappers.

The thermistor resistance is a extremely non linear. Its is approximated by a negative exponential of the reciprocal of absolute temperature.


Ro is resistance at known temperature To, in my case room temperature, expressed in Kelvin. Beta is a second parameter of the thermistor which can be calculated if you know the resistance at two different temperatures. I calculated it for each of the first six power levels and then took an average. It's probably not a very accurate value because the thermistor, being on the outside of the barrel, was probably at a significantly lower temperature than the thermocouple on the inside. However, it is the inside temperature I am interested in so I probably get a value of beta that sort of compensates for that.

Here is the graph of resistance against temperature :-



I plan to measure this with the analogue to digital converter in the MSP430 micros I am using. The problem is to cover such a large resistance range would end up with very little accuracy at the high temperature end where the machine will operate.

I had an idea that putting a fixed resistor in parallel would close up the bottom end without affecting the top much. Indeed it does, here is a graph of the combined resistance against temperature with a 100 Ohm resistor in parallel. You can see it is not far off being a straight line, much easier to digitise accurately.