Connect with us

Interfacing a NTC thermistor to a PIC

Discussion in 'Microcontrollers, Programming and IoT' started by Rajinder, Apr 17, 2018.

Scroll to continue with content
  1. Rajinder

    Rajinder

    539
    10
    Jan 30, 2016
    Hi
    I have a NTC thermistor.
    I want to connect to a PIC (PIC18F4520) A/D for temperature measurements.
    Is a simple voltage divider circuit good enough?
    The curve is non linear for the thermistor. Is there anyway of overcoming this in hardware? Or Software.
    Finally if i use a PTC thermistor are there any circuit changes to be made?
    Thanks in advance.
     
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    12,456
    2,985
    Nov 17, 2011
    What is "good enough" for you? Yes, it will work.

    Any way certainly, but rather complex and not economic.

    Yes, and this is the usual way. You can either approximate the non-linear characteristic by an equation or approximate the characteristic by a piecewise linear characteristic where you store a set of data points and interpolate in between.

    Depends on your PTC. You'll have to implement the new characteristic in software to accommodate the different type of sensor.

    Read this for more information.
     
    hevans1944 and (*steve*) like this.
  3. WHONOES

    WHONOES

    1,215
    330
    May 20, 2017
    You could use a Platinum Resistance Thermometer (PRT) instead. They are very linear and come in 100Ω or less commonly 1KΩ resistances. These quoted values are for when the element is at 0 deg C. They are a bit more expensive than your proposed NTC's or PTC's but, would not require any complex and time consuming linearization in either hardware or software saving a lot of time.
     
  4. timff

    timff

    19
    2
    Apr 13, 2018
    If you are unable to use a more linear sensing element, you might be able to translate your readings with a non-linear formula (if one is available for your device) or a look up table.

    One additional thought. You may wish to select a thermistor that can give you a wide resistance change over your target temperature so you get greater resolution. For example, if you select a part that has a 100 ohm change in series with a 10k resistor to form a voltage divider, you may not see as much of a voltage change as you would like for the microprocessor to measure.
     
  5. WHONOES

    WHONOES

    1,215
    330
    May 20, 2017
    What temperature range do you want to monitor?
     
  6. Rajinder

    Rajinder

    539
    10
    Jan 30, 2016
    HI all,
    Thanks for the advice and help.
    I am looking to measure from -10 to 70C
    The part that I have selected is NCP series from murata, it is 10K.
    I was thinking if I use this as a voltage divider with another 10K and feed into a PIC. How can I compensate for lead resistance?
    I am trying to achieve the same as using a 1n4148 diode which can be used as a temperature indicator i.e. 2mV change in voltage gives 1C degree change.

    Is there any easy way to make the output linear using hardware?
    Best regards,
    Raj
     
  7. Rajinder

    Rajinder

    539
    10
    Jan 30, 2016
    I have a further couple of questions :
    If R(25) = 10K at say beta of 4200 for example
    Then how do i calculate the R(25)/(100) from a typical graph? I know it is the difference between resistance at 25C and 100C but where does beta and constant K fit into all of this?
    thanks
     
  8. Harald Kapp

    Harald Kapp Moderator Moderator

    12,456
    2,985
    Nov 17, 2011
    How long are your leads? at 10 k resistance of the sensor the lead resistance is likely irrelevant - plus taking into account the tolerance of the sensor and the other resistor.

    You either use the graph or the equation, not both.

    You will have to trim the circuit and software anyway because each individual NTC will have a slightly different characteristic within its tolerances.
     
  9. Alec_t

    Alec_t

    3,144
    856
    Jul 7, 2015
    No. An analogue circuit to do that would be complex. Much easier to do linearisation in software.
     
  10. WHONOES

    WHONOES

    1,215
    330
    May 20, 2017
    Using a PRT, it would be very straight forward. As they are linear over the temp range you quote, it would just need a bit of straightforward scaling with an opamp to provide an output compatible with you chosen pic.
     
  11. OBW0549

    OBW0549

    157
    117
    Jul 5, 2016
    I agree; for the temperature range you're wanting to measure over, using a platinum RTD would be a much better choice, as it wouldn't require a lot of math to linearize it. The circuit doesn't have to be very complex; here's a very simple design I used on one project to interface a 1000Ω RTD to a PIC's ADC:

    temp.png
    VREF was +5V, which also powered the op amp. For your use, resistors R14 and R15 will need to be changed to get the offset & scaling you need.
     
  12. Rajinder

    Rajinder

    539
    10
    Jan 30, 2016
    Hi
    I will look at the platinum RTD. I think they are expensive than a thermistor. I was slso thinking of using a diode to measure temperature, which could be cheaper still.
    Am i correct in saying that R13 and R14 set a voltage at the inverting input. R12 and RTD set an adjustable voltage at non inverting input. The opamp will try to keep both inputs the same at its input and hence tge feefback resistor is used to set a gain / offset?
    Sorry about my lack of opamp knowledge.
    Raj
     
  13. OBW0549

    OBW0549

    157
    117
    Jul 5, 2016
    Yes, they're a bit more expensive-- but a lot less trouble to work with because they're much more linear.

    A diode (or a transistor with the base shorted to the collector) can be used, but the problem is the extremely large variation in forward voltage from unit to unit. Unlike RTDs and accurate thermistors, each unit has to be calibrated at a known temperature.

    The feedback resistor R15 is used to adjust the gain, and the R13/R14 ratio adjusts the offset. However, the two adjustments interact somewhat.
     
  14. WHONOES

    WHONOES

    1,215
    330
    May 20, 2017
    I like your follow up to my suggestion for using a PRT. It would be possible with a small mod to remove the influence of the offsetting on the gain.
     
  15. OBW0549

    OBW0549

    157
    117
    Jul 5, 2016
    True. It's also possible, by adding a large-ish resistor between the op amp output and its non-inverting input, to correct for the slight nonlinearity that results from feeding the RTD from a resistor instead of a constant-current source. With a small tweak, that same resistor can also cancel out the negative second-order term in the RTD's resistance vs temperature characteristic.

    But for the application of the circuit I posted above, perfect linearity was not important, and calibration was done in software so neither gain nor offset needed to be done by trimming resistor values. The most important design requirement was low component count, hence the circuit's lack of "nice" features.
     
  16. WHONOES

    WHONOES

    1,215
    330
    May 20, 2017
    Absolutely right, a constant current source would indeed improve linearity, it just depends on how accurate Rajinder needs it to be. Hopefully he will tell us.
     
  17. Rajinder

    Rajinder

    539
    10
    Jan 30, 2016
    The accuracy i require is thst it must perform as good as a diode. If you apply a constant current to a diode (1n4148) then the temperature can ve neasured by 1C/2mV
    1 degree for 2mV.
    So something like this or better.
    Thanks
     
  18. OBW0549

    OBW0549

    157
    117
    Jul 5, 2016
    No, it cannot. You can measure temperature deviations from some reference temperature, but you cannot directly measure temperature itself because at any particular forward current and temperature, the forward voltage drop will differ from one diode to the next.

    Moreover, that 2 mV/C is only approximate; it can vary from diode to diode and depends somewhat on forward current.

    So "as good as a diode" doesn't tell us much.

    The foregoing posts pretty much lay out the options available to you. In my opinion, your best course of action would be to use a simple thermistor/resistor voltage divider, feed the resulting voltage divider output into your PIC's ADC, and do the linearization in software.
     
  19. Rajinder

    Rajinder

    539
    10
    Jan 30, 2016
    Hi thanks for your reply.
    I was looking to at least measure a change on 1C.
    So think the thermistor and voltage divider will be the best option.
    Thanks
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-