Is there a more efficient way?


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2005
    Posts
    53

    Question Is there a more efficient way?

    I know this is a brute force way to linearize a thermistor connected to an analog input. Is there a more efficient way? I only need about 30F range.

    Thanks!

    if AD0 >= 446 then RA = 67
    if AD0 >= 450 then RA = 68
    if AD0 >= 456 then RA = 69
    if AD0 >= 461 then RA = 70
    if AD0 >= 477 then RA = 71
    if AD0 >= 473 then RA = 72
    if AD0 >= 479 then RA = 73
    if AD0 >= 486 then RA = 74
    if AD0 >= 492 then RA = 75
    if AD0 >= 499 then RA = 76
    if AD0 >= 506 then RA = 77
    if AD0 >= 513 then RA = 78
    if AD0 >= 519 then RA = 79
    if AD0 >= 526 then RA = 80
    if AD0 >= 529 then RA = 81
    if AD0 >= 535 then RA = 82
    if AD0 >= 544 then RA = 83
    if AD0 >= 548 then RA = 84
    if AD0 >= 552 then RA = 85
    if AD0 <= 438 then RA = 65

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    the use of LOOKUP, READ will be easier and faster... some home work to do but ... just an idea
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Wink

    Hi, Mark edwards

    Considering the thermistor's value tolerance ( generally +/- 20%, 10% in the best cases ) , plus it's precision, linearity, and repeatability ...

    on that a small range , a simple y = ax + b linéarisation will give a widely credible result !!!

    Alain
    Last edited by Acetronics2; - 23rd July 2005 at 10:13.

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    I disagree. Banks of IF statements are real ugly and there are more elegant ways of doing the same thing, but those heaps of IF statements invariably outperform the more elegant solutions.

    There is room for improvement, not in performance as in speed per se, but in resolution. You could almost interpolate steps of about a quarter of a degree (or better)... look...

    if AD0 >= 446 then RA = 67
    if AD0 >= 450 then RA = 68

    You've got about four clicks or more...

    if AD0 >= 535 then RA = 82
    if AD0 >= 544 then RA = 83

    between adjacent degrees... you have enough data to increase your resolution to beyond 1F. No, not with banks of IF statements this time, you need to be a little more creative with the math. If you can't figure it, come back and I'll show you how.

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Wink

    Hi, Mel

    I Agree for the ( basic ...) maths.

    As no sensor calibration is evoked ... the result could be, i.e.

    70°F +/- 10°F ... ( remember the thermistor nominal value tolerance !!! )

    what is the sense of the 1/4°F here ...

    Ah, Yesssss, I see ... a smart looking gadget !!!

    Not so easy, the precise measurements .... don't you think???

    Alain

  6. #6
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    As long as it looks good and appears to function...

    More than half the stuff you see for sale is total rubbish... however the secret of success is being fastest to market with your particular piece of land-fill...

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    And now i agree

    Many people think that because it's electronic it's more accurate ... well sometime !!!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    ...Many people think that because it's electronic it's more accurate ...
    ...and the more decimals there are on the display the better it is...
    Last edited by NavMicroSystems; - 25th July 2005 at 23:48.
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



Similar Threads

  1. large & efficient electro magnet
    By therian in forum Off Topic
    Replies: 13
    Last Post: - 19th October 2012, 06:53
  2. Transformerless Power Suppply
    By ERIK in forum Schematics
    Replies: 75
    Last Post: - 3rd September 2012, 15:08
  3. Efficient comparison on data (iButton)
    By enigma in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 27th August 2010, 13:37
  4. Efficient Fixed-Point Trigonometry For PIC16F
    By ScaleRobotics in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 9th September 2009, 01:50

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