Shop OBEX P1 Docs P2 Docs Learn Events
NTC thermistor with AD converter — Parallax Forums

NTC thermistor with AD converter

Hey everyone merry Christmas and happy new year.

I am trying to use a thermistor as a way to read temperature yet rctime only get the value of discharge and even though i have tried a lot of calibration, it is not linear and i never get the same value.
I want to ask how do you read temperature. I have read about the lm35 sensor which requires an ad converter. Has anyone used it with a propeller in C language?
could s/he post a wiring picture plus a simple code?

thank you very much.
«1

Comments

  • jmgjmg Posts: 15,175
    edited 2016-01-04 02:28
    johnproko wrote: »
    .., it is not linear

    NTC thermistors are inherently non-linear, but you should get similar readings at a fixed temperature.

    A disti like Digikey shows 3,440 items under Temperature Sensors, Transducers
    - cheapest are Linear ratio metric ones sub 20c/k, and there is a NXP LM75BD,112 which is i2c interface, 26c/1k

    Temperature Sensors choice often comes down to package, and final use.
  • I'd be happy to help you write some C or C++ code. I'm not familiar with the Prop's sigma-delta though (there's probably something in the Simple library for it) and you don't specify an external ADC for reading the voltage. If you plan to use an LM35 or any other analog sensor, you'll need to choose either sigma-delta or an external ADC. The MCP3xxx series ADC from Microchip are very common (lots of objects for the Propeller in Spin, C, C++, and probably others too).
  • You could use the (very accurate) MCP9808 which you can get as a breakout board from Adafruit. It has I2C interface which provides the temperature in a digital form, so no additional adc is needed.

    Erlend
  • Has anyone used a thermistor with rctime and made a graph and a equation?
    I am trying to get some values yet it never gets the same number.
    I have an arduino to guide me and a classic thermometer.

    For the ad converter what must be done? connections and some basic principles.

  • jmgjmg Posts: 15,175
    johnproko wrote: »
    Has anyone used a thermistor with rctime and made a graph and a equation?

    Google find this :

    http://www.sensorsmag.com/temperature/thermistors-accurate-temperature-sensors-part-2-application-11278

    Seems you can use LTSpice to model thermistors.
    johnproko wrote: »
    I am trying to get some values yet it never gets the same number.
    That sounds a more fundamental problem.
    You need to get stable readings, before you worry about curve fitting.
    Exactly how much do the numbers vary, and if you swap the thermistor for the same value resistor, is it more stable ?


  • Well they do vary a lot. rctime 70 might correspond from 22-24 C
    How someones uses thermistors without an adc?
    There must be a way
  • kwinnkwinn Posts: 8,697
    johnproko wrote: »
    Well they do vary a lot. rctime 70 might correspond from 22-24 C
    How someones uses thermistors without an adc?
    There must be a way

    I know that it can be done since the spectrometers I work on use thermistors in an rc circuit to control the temperature. One requirement is to couple the thermistor with a capacitance value that has a charge/discharge time that can be measured with some precision. What is the resistance range of your thermistor, and what is the capacitance value you are using with it?
  • jmgjmg Posts: 15,175
    johnproko wrote: »
    Well they do vary a lot. rctime 70 might correspond from 22-24 C
    I'm not following, are you saying there is a variation between thermistors & systems ?

    I thought you meant a fixed thermistor at a fixed temperature, in a single test system, gave unstable readings ?

    Unit to unit variation, is a different problem.

    johnproko wrote: »
    How someones uses thermistors without an adc?
    There must be a way
    rctime is a ADC, just a very simple one.
  • rctime is fine but what kind of capacitor are you using? Be aware though that capacitors have hysteresis which depends upon the dielectric. Use polystyrene or polypropylene caps, or even teflon as these kind of caps are better for sample/hold in A/D work. But I can only guess since I have not seen a circuit or the code you are using.
  • johnproko

    I have working "C" code for NTC thermistors, used with the ADS1015 12-bit ADC 4 channel with programmable gain amplifier in full working order, if you are interested. Adafruit has a breakout board for this ADC, which can be found here: https://www.adafruit.com/product/1083

    The working code should be found here, but if it doesn't work for you, then I have a version locally that may have some changes:

    SUCCESS: Converting mbed C++ to C to Propeller GCC.... BUG-B-GONE
    http://forums.parallax.com/discussion/160271/success-converting-mbed-c-to-c-to-propeller-gcc-bug-b-gone/p1

    Then in addition to that, here is a discussion pertaining to getting a simulation of an NTC thermistor working with the ADS1015:

    Configuring A Programmable Gain Amplifier On An ADC
    http://forums.parallax.com/discussion/160328/configuring-a-programmable-gain-amplifier-on-an-adc/p1

    This all applies to code written in C for SimpleIDE.
  • The schematic is simple... Pin 8--\resistor 220\-- thermistorand a capacitor in parallel--- GND.
    the thermistor is 10kohm and the capacitor is the brown one 0.1μF (https://www.parallax.com/product/751-00012)
    The code is simple as well:

    high(8);
    pause(1);
    int x = rctime(8, 1);
    print("%f ", x);

  • johnproko wrote: »
    Hey everyone merry Christmas and happy new year.

    I am trying to use a thermistor as a way to read temperature yet rctime only get the value of discharge and even though i have tried a lot of calibration, it is not linear and i never get the same value.
    I want to ask how do you read temperature. I have read about the lm35 sensor which requires an ad converter. Has anyone used it with a propeller in C language?
    could s/he post a wiring picture plus a simple code?

    thank you very much.

    Howdy, here you go, use an LM34 for Fahrenheit or an LM35 for Celsius, C code below.


    /*Relay/LM34 thermostat*/
    #include "simpletools.h"                      // Include simpletools
    #include "adcDCpropab.h"                      // Include adcDCpropab
    int main()                                    // main function
    {
      adc_init(21, 20, 19, 18);                   // CS=21, SCL=20, DO=19, DI=18
      float v3;                                   // Voltage variables
      float temp=0.85;
      int ps=45; 
         
      while(1)                                    // Loop repeats indefinitely
      {               
        v3 = adc_volts(3);                        // Check A/D 3    
        putChar(HOME);                            // Cursor -> top-left "home"   
        print("Temperature = %f V%c\n", v3, CLREOL);     // Display volts
        if(v3>temp) 
        {
          low(0); 
          high(1);
        }          
        if(v3<temp-0.03) 
        {
          high(0); 
          low(1);
        }            
        pause(1000);                               // Wait 1 s
      }  
    }
    
  • Thank you for your video and code.
    yet I have the propeller that has no build in a/d.
    Thus my question is how to connect an external, and the code needed from there onwards.
  • kwinnkwinn Posts: 8,697
    There are several ADC's that already have drivers in the OBEX. MCP320x, MCP4922, ADC0831, and several others show up when searching for "adc".
  • OBEX is nice if one is looking for spin examples.
    I need a C language program and the schematic of what goes where...
    Up to now I have an arduino checking the thermistor and sending a message to the propeller if the temperature is in certain range.
    Yet this is not efficient as I have to program 2 different MCUs and still cannot see what the temperature is.
    Any ideas on how to connect the A/D and what to write to read the thermistor?
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2016-01-10 01:22
    I don't understand why you can't get a reliable reading with RC? Did you try a poly cap instead of a ceramic? If you use an object it's best to either link or post the code to that so we can see exactly what you are using and also to confirm you are using a Prop.

    Either that or just use a cheap 1-wire or I2C sensor, no A/D required and the code is simple. I have also used the DHT22 humidity and temperature sensors, you only need a single wire.
  • jmgjmg Posts: 15,175
    edited 2016-01-10 01:31
    johnproko wrote: »
    yet I have the propeller that has no build in a/d...

    OBEX is nice if one is looking for spin examples.
    I need a C language program and the schematic of what goes where...
    ...
    Any ideas on how to connect the A/D and what to write to read the thermistor?
    The Prop can run Counters as ADC in Sigma Delta mode, so check if you can find C code for that.

    Mostly, that is config of the Counters, and then reading at some update rate.
    Counter-ADC runs continually in the background, and the Prop reads the change in counts/time elapsed.

    One you have Sigma-Delta ADC, you can simply skew with your thermister.
    A benefit of this is the CAP tolerance / drift/ hysteresis is removed from the mix, and you measure purely the ratio of two resistors.

    eg a Feedback resistor of half the thermister will have a balance point of 75% counting.
  • True Jim, but the caps need to be almost on the chip itself for best results. I've just been through this whole exercise for a new design and finally settled on using 1-wire TO92 devices as they have a wide temperature range and I can glue or clamp the sensor onto the target just like a thermistor. As long as you don't rely on Spin you won't need to dedicate a cog to this as Tachyon handles the 1us start pulse easily and I think C will use the same cog too.
  • jmgjmg Posts: 15,175
    I've just been through this whole exercise for a new design and finally settled on using 1-wire TO92 devices as they have a wide temperature range and I can glue or clamp the sensor onto the target just like a thermistor.

    The OP has not said why the preference for thermister over Digital sensor, but there are some special packages, or extremes in temperature, that come only in NTC. Might be one of those applications.

  • kwinnkwinn Posts: 8,697
    jmg wrote: »
    I've just been through this whole exercise for a new design and finally settled on using 1-wire TO92 devices as they have a wide temperature range and I can glue or clamp the sensor onto the target just like a thermistor.

    The OP has not said why the preference for thermister over Digital sensor, but there are some special packages, or extremes in temperature, that come only in NTC. Might be one of those applications.

    Lots of alternatives to a thermistor, and most of them lower in cost and complexity than adding an adc (and probably op amp) to the circuit. I know darn well that an rc circuit works with a polystyrene/polypropylene capacitor.

    If it needs to be mounted away from the propeller a 555 timer will produce nice pulses that can be measured, but again, accuracy requires using poly or similar quality capacitors.
  • Peter I have uploaded in previous comments how my wiring is and the code im using.
    the rctime measures the resistance in a resistor. Thus the change might represent some change before it actually change the value. For example at rctime = 90 arduino is showing a range from 23.05 to 23.30 C. might not sound much yet as temperature rises the range widens and the variation increases.
    I have tried different caps, changed the thermistor etc. yet the fact remains that i need some accuracy, not deviating 2 degrees at 35C.
    I Have the propeller without A/D convertion, the first propeller that came out. I need a way to read the value using analog, probably, or if someone else has some equation from a previous project.
    My last solution is to make the arduino the temp master and propeller the slave yet I lose all the point in multitasking.
  • Now I know how to suck eggs! :)
    Seriously though, I had checked the thread and there is no circuit and just an equation but the rctime function itself is not shown. I did see mention of a "brown capacitor" and a link which seems to indicate that this is a decoupling capacitor, the exact type you want to avoid. However you say the Arduino works with the same circuit? Back to the rctime function then, do you know what it is or is it a built-in function that you are using from....? There have been so many opportunities for you to provide actual real details and get some real answers, hopefully this may be realized this time.

    BTW, I have no trouble getting reliable readings with an RC network on the Prop.
  • I am not saying that the rctime readings are not reliable. All im saying is that one rctime reading equals to 2-4 different values based on the reading I get from the arduino. The latter has analog pins build in so reading a thermistor is just a walk in the park. What I need is the prop to read that thermistor and translate that into temperature. I dont know how to connect a A/D converter which should I buy. As for the code I will start by printing both prop and ard readings. If those match, since im using identical thermistors I hope that by coping the arduino equation will solve my problems. Will the ADC 0831 work? I am trying to figure out how SPI works.
  • Adc0831? Uggh! This chip just uses clock and one way data, barely spi at all.
    I will try some rc stuff with different caps and post the results. I am guessing you are using some kind of C etc but will await clarification.
  • jmgjmg Posts: 15,175
    johnproko wrote: »
    What I need is the prop to read that thermistor and translate that into temperature.

    Can you give the
    * Thermistor Values at expected temperature span ?
    * Required LSB of reading in bits or Degrees ?
    * How often is an update required ?
    * What is claimed tolerance of these thermistors ?
    * what are the cable lengths involved ?
    * how many sensors do you need to read ?
    * will these be individually calibrated ?

    Simplest circuits of NTC + CAP, will include CAP tolerance and drift in the error sources.
    A slightly more complex bridge design of Rref+NTC+CAP is ratiometric, and will have the CAP tolerance removed.
    If the cable lengths are significant, you may need to buffer the NTC and add mains filtering, as the signal is still analog.

  • I write a program in C yes.

    dont care about the length, once calibrated i will just add the difference. Nevertheless the cable is 45cm long.
    It is a 10k thermistor, will post the datasheet below.
    I want to read 3 thermistors, 2 using 45cm wire one with a 15cm. an update every 30sec is ok more than that is problematic since im building an egg incubator the size of a box 100cmX100cmX60cm.
    Another solution is to monitor with an arduino the range i need 36.1C to 38.8C, yet since im building a temperature sensor I would like to have a code ready to other to come projects.

    http://cdn.sparkfun.com/datasheets/Sensors/Temp/ntcle100.pdf
  • Have you tried the same circuit with a reference resistor of say around 6800 for 33'C? close to the Prop? If the reading isn't stable then it seems that this rctime function or the capacitor has a problem otherwise there is no reason why the Prop can't handle it. But I am still wondering why you can't just use a nice simple 1-wire temperature sensor chip as it only requires the same two wires you are running now and the code is very simple and there is no need for any conversion etc.

    Actually I came across a LMT01LPGM which is even easier with a -50 to 150'C range in a 2-pin TO92 pack that outputs nice easy pulses that can be simply counted, around 1400 pulses at 88kHz for around 33'C. They are around $1.50, I think I might even use these in my new design.
  • jmgjmg Posts: 15,175
    Actually I came across a LMT01LPGM which is even easier with a -50 to 150'C range in a 2-pin TO92 pack that outputs nice easy pulses that can be simply counted, around 1400 pulses at 88kHz for around 33'C. They are around $1.50, I think I might even use these in my new design.

    That is a nice looking device, not super-cheap, but very easy to use and quite good calibrate specs.

  • johnprokojohnproko Posts: 121
    edited 2016-01-12 10:12
    I am open to any advise for the sensor.
    Could you post the 1 wire sensor and how to connect?
  • jmgjmg Posts: 15,175
    johnproko wrote: »
    Could you post the 1 wire sensor and how to connect?

    That's all in the data sheet Peter linked to.

    In the Prop case, a NPN transistor and 2 bias resistors is a minimal circuit, but I would add a series R (~1k) to each wire leaving the board for ESD and slip protection.
    In TI's circuit, a briefly shorted sensor would likely take out the transistor.

    Code to count is just a counter config setup, but you will need to sense the gaps in the bursts, to know when the count is stable.
    Maybe polling counter somewhere between 25us to 10ms until two-the-same are found.
Sign In or Register to comment.