Mathematical calculation


Closed Thread
Results 1 to 17 of 17
  1. #1
    Join Date
    Aug 2006
    Location
    Iran
    Posts
    94

    Default Mathematical calculation

    Hi, how can i calculate this formula with picbasic?

    RH(linear)= -2.0468+(0.0367*SORH)-(SORH*SORH*1.5955e-6)

    SORH is a 12 bit data that is given from sensor. i should put that data in above formula to calculate the humidity in %. how should i write the code?

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by amindzo View Post
    Hi, how can i calculate this formula with picbasic?
    RH(linear)= -2.0468+(0.0367*SORH)-(SORH*SORH*1.5955e-6)
    SORH is a 12 bit data that is given from sensor. i should put that data in above formula to calculate the humidity in %. how should i write the code?
    RH=(0-2046800+(36700*(SORH*1000000))-((SORH*1000000)*(SORH*1000000)*1595500/10000
    But you can't do that unless you're using a PIC18Fxxxx series PIC and PBP 2.50.
    What version of PBP are YOU using?

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by amindzo View Post
    Hi, how can i calculate this formula with picbasic?

    RH(linear)= -2.0468+(0.0367*SORH)-(SORH*SORH*1.5955e-6)
    I have no idea if it works or not, but this thread has a formula that doesn't require longs.

    Device Compatibility: Sensirion Parallax sensor
    http://www.picbasic.co.uk/forum/showthread.php?t=3652
    <br>
    DT

  4. #4
    Join Date
    Aug 2006
    Location
    Iran
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    I use picbasic pro 2.41(old version) and PIC16F877A.i wan to use SHT75(digital temperature and humidity sensor).

  5. #5
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Lightbulb

    Important questions here are how precise and how accurate does your result need to be? (There is a difference between precision and accuracy.)

    The formula you give compensates for the non-linearity of the sensor, and it is from the product data sheet, section 4.1:

    http://www.sensirion.com/en/pdf/prod...nsor-SHT7x.pdf

    Warning: Do not try to use anything like:

    RH=(0-2046800+(36700*(SORH*1000000))-((SORH*1000000)*(SORH*1000000)*1595500/10000
    ("Danger, Will Robinson!")

    Substitute 2353 (approximately 76% RH) for SOrh in the above formula and you will see why. (I get something like 883 quintillionths of a percent . . . very dry humor, indeed.)

    Suggestion:

    For the 12-bit data for which it is intended, the formula can be reduced, with some loss of precision, to:

    %RH = (SOrh/27) - [(SOrh)(SOrh)/627,000] - 2

    Again using 2353 (for 75.79% RH, according to the manufacturer), this gives 76.3; the manufacturer's formula gives 75.5.

    The 12-bit output from the sensor ranges from 0 (for 0%) to about 3400 (for 100%). I'm guessing the 8-bit output goes from 0 to about 212, so you may be a lot happier using the 8-bit output. (212 squared is 44,944; the square root of 65,536 is 256. But 2353--for about 76% RH--when squared is over 5.5 million!)

    By the way, that is only compensating for non-linearity of the sensor itself; compensation for temperature is given in 4.2. (A 10 degree difference from 25 Celsius amounts to an adjustment of 1.2 percent RH, an increase if more, a decrease if less.)

    The manufacturer provides an application note that gives three other ways to calculate the compensated value for non-linearity; the first two methods are much simpler and ideally suited to a microprocessor application. The formulas are given for both 8 and 12 bits:

    See section 2 of: http://www.sensirion.com/pdf/product..._Sensors_E.pdf

    If an accurate result, precise within a percent or two, plus or minus, is acceptable, you should have no problem. If you need help converting the factors in the tables of sections 2.1 or 2.2, just ask.

    Another suggestion: It is easier to divide by a whole number than to multiply by a decimal fraction.
    Last edited by RussMartin; - 19th October 2008 at 09:51.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

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


    Did you find this post helpful? Yes | No

    Talking Significant or not digits : a whole laughing matter.

    Hi, Amindzo

    Important questions here are how precise and how accurate does your result need to be? (There is a difference between precision and accuracy.)

    As the sensor is given for a basical 2% RH precision .... do you think all those intellectual self-indulgence calculation mean anything ???

    certainly not.

    just consider your result is "inside" those limits.

    Just for laughing : which reference and how many points will you use to calibrate your sensor ??? ( good question, no ??? )

    Alain ( Thermics and Thermodynamics Engineer ... BTW.)
    Attached Images Attached Images
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  7. #7
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi, Amindzo

    As the sensor is given for a basical 2% RH precision .... do you think all those intellectual self-indulgence calculation mean anything ???

    certainly not.

    just consider your result is "inside" those limits.

    Just for laughing : which reference and how many points will you use to calibrate your sensor ??? ( good question, no ??? )

    Alain ( Thermics and Thermodynamics Engineer ... BTW.)
    The document Alain refers to specifies accuracy, not precision. Accurate data may be precise or imprecise. Inaccurate data may also be precise or imprecise.

    I prefer imprecision of accurate data to precision of inaccurate data. Someone who has used both a slide rule and an electronic calculator feels this intuitively, in his gut.

    Of course, what we all want is both accuracy and precision. That's why God invented calibration and told engineers to do it.

    amindzo, I'm showing you ways to do the calculations; Alain is telling you you don't need them. He may be right . . . but you still have to convert the raw SOrh into %RH, and the formulas will help you do that.

    I'm also obliged to note that the document to which Alain refers is 6 years out of date.
    Last edited by RussMartin; - 19th October 2008 at 10:41.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

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


    Did you find this post helpful? Yes | No

    Talking

    Hi, Russ

    You're right; In French , Accuracy ... is told "precision" ... so, I sometmes mix the words !!!

    I see we have the same readings ... lol !

    BTW, I have found some nice sliding rules in the ex Communist part of the world ... I just love to use it : always reminds me what's necessary for life.


    one interesting tool for such work is this one :

    http://curveexpert.webhop.net


    Helps a lot for decent linearizations ...

    Alain
    Last edited by Acetronics2; - 19th October 2008 at 10:35.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  9. #9
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default

    My apologies, Alain. I have no French and do not know how different words and concepts translate. I help amindzo to find the calculations he needs, and to learn which ones he needs.

    In my youth, I learned Hebrew; Latin in high school; and Greek at university. Not much of that helps you or me or amindzo today!

    The very first slide rule I used, in 1963, was this one:

    http://foraker.research.att.com/~dav...tt/n1010es.jpg
    Last edited by RussMartin; - 19th October 2008 at 18:49.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

  10. #10
    Join Date
    Aug 2006
    Location
    Iran
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    thank you everybody,i think it's better to use the second method in application note,temperature is very important for me but humidity is not as important as temperature so i think i should use second method.

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


    Did you find this post helpful? Yes | No

    Wink Nostalgy ...

    Timeo Danaos et Dona Ferentes ...

    cheers

    Alain
    Attached Images Attached Images  
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  12. #12
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by amindzo View Post
    I use picbasic pro 2.41(old version)
    ?????????????????????????????????????????????????? ????????????????

  13. #13
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by amindzo View Post
    thank you everybody,i think it's better to use the second method in application note,temperature is very important for me but humidity is not as important as temperature so i think i should use second method.
    If you use 12-bit data for SOrh, the first method in the application note is a better choice. The second method is easily implemented for 8-bit SOrh.
    Last edited by RussMartin; - 19th October 2008 at 19:54.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

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


    Did you find this post helpful? Yes | No

    Thumbs up Re: Mathematical calculation

    Quote Originally Posted by techfighter View Post
    Hi amindzo,
    If you wants to calculated it for Electronic purpose i would recommend you to visit Online Calculator

    there have several Calculator for Electronic purpose, Generally its helpful for Electronic Mathmatics, Electronic Parts Calculation and Students.

    Thanks
    Hi, Tecfighter

    Pretty Nice digging out ... thread shows 2008 year and our friend Amindzo went haunting another ( better told otherS ) pic forums.

    Anyway, Thanks for the link ...

    Alain

  15. #15
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Mathematical calculation

    Hmm, who is techfighter?

    Ioannis

  16. #16
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: Mathematical calculation

    Techfighter and his multiple personality disorder has been dealt with a few days ago.

    Robert

  17. #17
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Mathematical calculation

    Oh, I see.He has been ... fought to death!

    Ioannis

Similar Threads

  1. Calculation Problem - value goes to zero after 65
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 12th March 2010, 05:10
  2. how to add the calculation of temperature in my source code
    By slimpeng in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 20th February 2008, 16:31
  3. Mathematical problem
    By iugmoh in forum General
    Replies: 2
    Last Post: - 25th January 2008, 18:24
  4. Need help with lookup table or direct calculation
    By nverma in forum mel PIC BASIC Pro
    Replies: 24
    Last Post: - 11th October 2006, 18:27
  5. Mathematical Precedence
    By keithdoxey in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 6th October 2006, 21:44

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