Shop OBEX P1 Docs P2 Docs Learn Events
Can you crack this formula with a PIC ? — Parallax Forums

Can you crack this formula with a PIC ?

ArchiverArchiver Posts: 46,084
edited 2000-10-27 07:32 in General Discussion
It's a formula to calculate water vapour pressure given a temperature in Deg C

float calculateWaterWVP(float Temp)
{
float a,tempInK,c,d,e,wvp;

tempInK = Temp + 273.15;
a = -6096.9385 * (1/tempInK);
c = -2.711193 * 0.01 * tempInK;
d = 1.673952 * 0.00001 * (tempInK * tempInK);
e = 2.433502 * (log(tempInK)/log(10)/0.434294509);


wvp = exp(a + 21.2409642 + c + d + e);
return wvp;

} */

If you can do this, you get a medal !

Regards,
Darren

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-10-26 18:23
    I know this isn't what you had in mind, but have you looked at the PAK-II?
    The PAK-I doesn't do log and exp, but the PAK-II does.

    http://www.al-williams.com/awce/pak1.htm (has info on PAK-I and II).

    You can also read the manuals online and see some examples in the doclib.

    Regards,

    Al Williams
    AWC
    *8 channels of PWM: http://www.al-williams.com/awce/pak5.htm


    >
    Original Message
    > From: DAZLOGAN@a... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=s-LDgld1tqgGpqpLiuqfVDJo71zPYA6O3ekN0Q-K1VIoGi6t79lsaJTNw7sxwLrikR-64aqL]DAZLOGAN@a...[/url
    > Sent: Thursday, October 26, 2000 11:21 AM
    > To: picbasic-l@q...; PICLIST@m...;
    > basicstamps@egroups.com
    > Subject: [noparse][[/noparse]basicstamps] Can you crack this formula with a PIC ?
    >
    >
    > It's a formula to calculate water vapour pressure given a
    > temperature in Deg C
    >
    > float calculateWaterWVP(float Temp)
    > {
    > float a,tempInK,c,d,e,wvp;
    >
    > tempInK = Temp + 273.15;
    > a = -6096.9385 * (1/tempInK);
    > c = -2.711193 * 0.01 * tempInK;
    > d = 1.673952 * 0.00001 * (tempInK * tempInK);
    > e = 2.433502 * (log(tempInK)/log(10)/0.434294509);
    >
    >
    > wvp = exp(a + 21.2409642 + c + d + e);
    > return wvp;
    >
    > } */
    >
    > If you can do this, you get a medal !
    >
    > Regards,
    > Darren
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2000-10-27 00:52
    Hi Darren,

    I've tried to do this sort of math MANY times with my weather
    station, and have been mostly unsucessful. I'd highly recommend
    using Al Williams' PAK module to do it.

    It *is* possible to do with just the Stamp/PIC, but you'd
    likely end up with an inprecise answer.

    Matt Parnell
    Parnell Engineering, LLC http://www.weatherstamp.com
    37637 Five Mile Rd., #198 mail@w...
    Livonia, MI 48154-2634 Phone: (734) 464-0150
    Fax: (734) 432-9866 ICQ: 14074347
    Pager: (517) 251-7674

    Original Message
    From: DAZLOGAN@a... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=ctWTMVrpvJMy4MdaUAHnnSihr0z2RXn7f92y-oh1qLm3lM6dXTOhGK46h28D5DdZimPTDp-jXtnz1sE]DAZLOGAN@a...[/url
    Sent: Thursday, October 26, 2000 12:21 PM
    To: picbasic-l@q...; PICLIST@m...;
    basicstamps@egroups.com
    Subject: [noparse][[/noparse]basicstamps] Can you crack this formula with a PIC ?


    It's a formula to calculate water vapour pressure given a temperature in Deg
    C

    float calculateWaterWVP(float Temp)
    {
    float a,tempInK,c,d,e,wvp;

    tempInK = Temp + 273.15;
    a = -6096.9385 * (1/tempInK);
    c = -2.711193 * 0.01 * tempInK;
    d = 1.673952 * 0.00001 * (tempInK * tempInK);
    e = 2.433502 * (log(tempInK)/log(10)/0.434294509);


    wvp = exp(a + 21.2409642 + c + d + e);
    return wvp;

    } */
  • ArchiverArchiver Posts: 46,084
    edited 2000-10-27 05:52
    You might be able to use fixed point math instead of floating point. Fixed
    point math is easier to process. If you need an example of fixed point math
    let me know.

    MH

    Original Message
    From: "Matt Parnell" <tparnell@o...>
    To: <basicstamps@egroups.com>
    Sent: Thursday, October 26, 2000 4:52 PM
    Subject: RE: [noparse][[/noparse]basicstamps] Can you crack this formula with a PIC ?


    > Hi Darren,
    >
    > I've tried to do this sort of math MANY times with my weather
    > station, and have been mostly unsucessful. I'd highly recommend
    > using Al Williams' PAK module to do it.
    >
    > It *is* possible to do with just the Stamp/PIC, but you'd
    > likely end up with an inprecise answer.
    >
    > Matt Parnell
    > Parnell Engineering, LLC http://www.weatherstamp.com
    > 37637 Five Mile Rd., #198 mail@w...
    > Livonia, MI 48154-2634 Phone: (734) 464-0150
    > Fax: (734) 432-9866 ICQ: 14074347
    > Pager: (517) 251-7674
    >
    >
    Original Message
    > From: DAZLOGAN@a... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=dtXo9aibgKt-mp7iwONQ4u9U_-ylW13PX8WleSbqQIUujeexUBSu4qnd6uVPwNZ1DAGEz-g4Fg]DAZLOGAN@a...[/url
    > Sent: Thursday, October 26, 2000 12:21 PM
    > To: picbasic-l@q...; PICLIST@m...;
    > basicstamps@egroups.com
    > Subject: [noparse][[/noparse]basicstamps] Can you crack this formula with a PIC ?
    >
    >
    > It's a formula to calculate water vapour pressure given a temperature in
    Deg
    > C
    >
    > float calculateWaterWVP(float Temp)
    > {
    > float a,tempInK,c,d,e,wvp;
    >
    > tempInK = Temp + 273.15;
    > a = -6096.9385 * (1/tempInK);
    > c = -2.711193 * 0.01 * tempInK;
    > d = 1.673952 * 0.00001 * (tempInK * tempInK);
    > e = 2.433502 * (log(tempInK)/log(10)/0.434294509);
    >
    >
    > wvp = exp(a + 21.2409642 + c + d + e);
    > return wvp;
    >
    > } */
    >
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2000-10-27 07:32
    >It's a formula to calculate water vapour pressure given a temperature in
    Deg C
    > float calculateWaterWVP(float Temp)
    > {
    > float a,tempInK,c,d,e,wvp;
    > tempInK = Temp + 273.15;
    > a = -6096.9385 * (1/tempInK);
    > c = -2.711193 * 0.01 * tempInK;
    > d = 1.673952 * 0.00001 * (tempInK * tempInK);
    > e = 2.433502 * (log(tempInK)/log(10)/0.434294509);
    > wvp = exp(a + 21.2409642 + c + d + e);
    > return wvp;
    > } */
    >If you can do this, you get a medal !

    Hi Darren,

    The medal would have to be real geld to get cracking seriously on that one!


    Then, the first questions would be, over what temperature range, and to
    what accuracy? Is it pure water--there are big effects from salts. If you
    want it only near 25'C then, linearize around 3.169 kpa. Larger range--a
    table lookup with interpolation? Get out the big money to attempt to crack
    the formula!

    -- Tracy Allen
    electronically monitored ecosystems
    http://www.emesystems.com
Sign In or Register to comment.