Displaying temperature using a -40 to 185F??


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    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....

  2. #2
    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

  3. #3
    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