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?
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:
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.
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.)
************************************************** ***********************
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 " !!!
*****************************************
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.
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.
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 " !!!
*****************************************
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:
Bookmarks