Displaying temperature using a -40 to 185F??


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    May 2006
    Posts
    36

    Default Displaying temperature using a -40 to 185F??

    I am trying to display the temperature of a temp probe using an LCD and a PIC16F690. The probe can measure temps from -40F to 185F. The output from the temp probe is from 0.5 to 4.5V, respectively accross the temp span. I am trying to display the temp based on the analog input but I'm having some problems figuring out how to do this. I am using a 10-bit conversion with a 5V reference, so each bit is worth 0.004883 volts.

    The equation that I came up with was
    ((Analog_value - 0.5V)/ (0.004883V))-40 = temp (in F)

    The problem is that I can not multiply or divide decimal fractions in a PIC, atleast I don't know how to.

    One solution I thought of doing was disregarding the temps below 0 F. I can just display (temp below 0F). I could then take the voltage point where it is above 0 F and then add decimal fraction between 2 points (0.275) and display this number. So from my calculations, an analog value of 1.2109 V will create a digital value of 248. I can state that this is 0F and then add 0.275 * (new digital value X - digital value 248) to create the new values of temp.

    I am also allowing the user to have different things happen at different voltages and will need to convert 0 to 185 F into a value that will relate to A to D reading.

    I am also low on memory space.

    Do anyone have an ideas that might help? Thanks.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jblackann View Post
    ((Analog_value - 0.5V)/ (0.004883V))-40 = temp (in F)
    won't work...
    0-5v output, actually running from .5v to 4.5v, 10bit ADC, -40F to 185F range?

    4v total range, 10 bit ADC, lowest value readable from ADC = 102.4, highest value is 921.6, range of 819.2

    185+40 = 225 degrees total range thru 4v input offset by 40 degrees F

    ADC value - 102 = the .5v offset at the input
    ADC value * 225 / 819 = something like .275 degrees per bit

    But the result so far is offset by 40, so...
    IF result < 40 then
    result = 40 - result
    sign = negative
    else
    result = result - 40
    sign = positive
    endif
    DONE....

    So run a test case...
    Input value from ADC is 921, corresponding to a voltage of 4.5v
    921 - 102 = 819
    819 * 255 / 819 = 225
    The result is larger than 40, so sign is positive and subtract 40 from it,
    225 - 40 = 185
    sign positive 185
    BAM done...

    Another case at minimum...
    Input value from ADC is 102, corresponding to a voltage of .5v
    102 - 102 = 0
    0 * 255 / 819 = 0
    The result is smaller than 40, so set the sign negative and subtract it from 40.
    40 - 0 = 40
    sign negative 40
    BAM done...


    Not only that, but a search on temperature display here at this site would've most likely been a heck of a lot simpler and might actually net you some premade code just for this application....

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Something smells Fishy

    I understand the whole "Teaching a man to fish" thing.
    But at the end of the day, the guy's gotta be able to catch a fish.

    To help prevent starvation, I need to toss in a fish here. And maybe a loaf of bread to go with it.<hr>
    The Slope Intercept formula for the given data points would be ...

    Y = (0.2751 * X) - 68

    to do this in PBP with 1 decimal place @ 10-bit resolution ...
    Code:
    ADCIN 1, TempF
    TempF = TempF * 2751
    TempF = DIV32 1000
    TempF = TempF - 680
    GOSUB ShowTemp
    
    '...
    
    ' --- Display a Signed Word with 1 decimal place ---
    ShowTemp:
        if TempF.15 = 1 then LCDOUT "-"
        TempF = ABS(TempF)
        LCDOUT DEC (TempF/10),".",DEC1 (TempF//10)
    Return
    Bon Appetite,
    DT

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    I understand the whole "Teaching a man to fish" thing.
    Bon Appetite,
    Hey, you're right.
    I missed that 6th line in the 1st post about fractions...
    My bad...
    -40F to 185F... that temperature 'probe' sounds familiar... like something else I've seen before... might even have a greater range, just not documented... what is it... I can't put my finger on it...
    Oh...yes...it's a...(click)....mmmmmmmmmmmmmmmmsssssssssssssss

Similar Threads

  1. Replies: 10
    Last Post: - 17th February 2012, 07:19
  2. Write Onewire data toa I2C memory / read ASCI
    By Eugeniu in forum mel PIC BASIC Pro
    Replies: 67
    Last Post: - 16th November 2008, 19:19
  3. Displaying temperature Setpoints
    By Kalind in forum mel PIC BASIC Pro
    Replies: 58
    Last Post: - 27th October 2008, 14:52
  4. Conversion problem
    By eva in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 15th March 2007, 18:21
  5. Help for decimal conversion
    By eva in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th March 2007, 18:20

Members who have read this thread : 0

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