NTC thermistor temperature monitering


Closed Thread
Results 1 to 4 of 4
  1. #1
    Divinci's Avatar
    Divinci Guest

    Default NTC thermistor temperature monitering

    Hello I am very green when it comes to programming and need some help. I am trying to write a program so that a voltage divider is created by a thermistor and a resistor and that value is sent into my PIC16F690. I wanted to just calculate the value but the equation requires using ln. so my plan now is to make a lookup table but I'm lost. Then after I want to convert the number to BCD and output it to 7 segment decoders and displayed it on 2 7 segment displays. Then I want take in from two input on a count up and one a count down, then compare the measured value to the counter value and output on one of three outputs more than 2 less than, equal to and more than 2 greater than (which I haven't even gotten to yet). I might be doing most or all of this completely wrong any help would be greatly appreciated. Also i only need it to work for values 0-39 in BCD to save outputs on the chip. As you will notice a lot is cut and paste.
    Thank you Anthony
    '************************************************* ***************
    '* Name : UNTITLED.BAS *
    '* Author : [select VIEW...EDITOR OPTIONS] *
    '* Notice : Copyright (c) 2012 [select VIEW...EDITOR OPTIONS] *
    '* : All Rights Reserved *
    '* Date : 11/25/2012 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************
    p16F690.Inc
    TRISA = 011111 'set most to input but leave three bits for output
    TRISB = 000000
    TRISC = 000000
    ADCON1 = 000010


    define OSC 20
    DEFINE ADC_BITS 8 ' Set number of bits in result
    DEFINE ADC_CLOCK 3 ' Set clock source (rc = 3)
    DEFINE ADC_SAMPLEUS 10 ' Set sampling time in microseconds


    adcVar VAR WORD
    adcVoltage VAR WORD
    temp VAR WORD
    tempa var word
    ba var word
    k1 var word
    ya var word
    yb var word
    yc var word
    yd var word
    ye var byte
    yf var byte
    Myvar var word




    main:


    ADCIN 1,adcVar


    ADCVoltage=(adcVar/1024)*5
    ba = (100000/((5/ADCVoltage)-1))
    k = ln(ba/100000)
    ya = 0.003354016
    yb = 0.000256985
    yc = 0.00000262213
    yd = 0.0000000638309
    tempa = (ya+yb*(k*k)+yc*(k*k*k)+yd*(k*k*k*k)
    temp = 1/tempa


    if temp=< 0 then
    temp=0
    endif


    if temp => 39 then
    temp=39
    endif


    if temp > 9 then 'Convert to bcd
    temp = temp +6
    endif


    For MyVar = 8 to 15 'highest 8 to go to one 7 segment
    yf = temp.0(MyVar)
    Next MyVar


    ye = portb 'lowest 8 to go to other 7 segment
    yf = portc


    GoTo main



  2. #2
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: NTC thermistor temperature monitering

    first i notice "TRISA = 011111" you should use all 8 so "TRISA = 00011111"

    also your using 8 bit processors that dont use floating point math, so all those ya = 0.0000203123 numbers, your going to have to convert to whole numbers and the max is going to be somewhere near 65353 as a max number, all math cannot excede this numberso you cant do a 35000 + 35000, wont work
    go ahead and set your adbits to 10, when you get to the read/store use something like this
    ADCIN 0, Res1 ' Read Channel 0 data
    res1 = res1 / 64 ' 0-1024 (/256 = 0-255) etc...
    Ive got to do this too, i need to use a NTC for a temp guage, I'm sure i can do it with about 5 lines of code, so you should be able to clean this up a bit.
    try to get your math down, it looks way to complicated.

  3. #3
    Join Date
    Oct 2004
    Posts
    440


    Did you find this post helpful? Yes | No

    Default Re: NTC thermistor temperature monitering

    A bit easier is the MCP9700A.
    It's linear and runs about 34 cents.

    Norm

  4. #4
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: NTC thermistor temperature monitering

    great idea, I didnt know about that chip, just order a bunch.

Similar Threads

  1. NTC thermistor temperature sensing
    By pxidr84 in forum mel PIC BASIC Pro
    Replies: 36
    Last Post: - 16th January 2011, 08:56
  2. NTC Thermistor with PWM
    By shredder in forum Schematics
    Replies: 2
    Last Post: - 13th March 2007, 23:27
  3. resistor in parallel with a thermistor
    By Pic_User in forum General
    Replies: 0
    Last Post: - 13th March 2007, 01:42
  4. Help with Thermistor Circuit
    By CocaColaKid in forum General
    Replies: 2
    Last Post: - 12th May 2005, 06:08
  5. Best Way To Use A Thermistor
    By CocaColaKid in forum Schematics
    Replies: 1
    Last Post: - 1st May 2004, 10:00

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts