PDA

View Full Version : Mathematical calculation



amindzo
- 18th October 2008, 19:57
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?

skimask
- 18th October 2008, 22:54
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?

Darrel Taylor
- 19th October 2008, 01:08
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>

amindzo
- 19th October 2008, 05:56
I use picbasic pro 2.41(old version) and PIC16F877A.i wan to use SHT75(digital temperature and humidity sensor).

RussMartin
- 19th October 2008, 07:40
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/product_information/Datasheet-humidity-sensor-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_information/Non-Linearity_Compensation_Humidity_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.

Acetronics2
- 19th October 2008, 09:11
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.)

RussMartin
- 19th October 2008, 10:18
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. :D

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.

Acetronics2
- 19th October 2008, 10:32
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

RussMartin
- 19th October 2008, 11:11
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/~davek/slide/pickett/n1010es.jpg

amindzo
- 19th October 2008, 12:03
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.

Acetronics2
- 19th October 2008, 13:09
Timeo Danaos et Dona Ferentes ...

cheers

Alain

skimask
- 19th October 2008, 18:14
I use picbasic pro 2.41(old version)
?????????????????????????????????????????????????? ????????????????

RussMartin
- 19th October 2008, 19:51
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.

Acetronics2
- 19th October 2013, 20:09
Hi amindzo,
If you wants to calculated it for Electronic purpose i would recommend you to visit Online Calculator (http://actpcb.com/pcb-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. :D

Anyway, Thanks for the link ...

Alain

Ioannis
- 26th October 2013, 11:07
Hmm, who is techfighter?

Ioannis

Demon
- 26th October 2013, 17:33
Techfighter and his multiple personality disorder has been dealt with a few days ago.

Robert
:)

Ioannis
- 27th October 2013, 00:07
Oh, I see.He has been ... fought to death!

Ioannis