Shop OBEX P1 Docs P2 Docs Learn Events
PBasic Math ( Resolved) — Parallax Forums

PBasic Math ( Resolved)

sam_sam_samsam_sam_sam Posts: 2,286
edited 2009-07-22 00:47 in General Discussion
Hi EveryOne

This is a project that I have been ·ask to do·by employer

As of right now I can not give all of the details.......................
................·but when the Project is done I will share with all of you on the Forum


I know that I have·This a another Post but this is a different question
http://forums.parallax.com/showthread.php?p=804156

http://forums.parallax.com/showthread.php?p=804554


Here is the problem that I now have

Silo Hold 50,000 Pounds need to keep track of usage need smallest error possible

I was using the Seconds */309 to get the Flow Rate··

300 Pounds of Sand
248 Seconds to run the·Sand out of hopper
Which give you 1.21 pound per sec or 72.6 per minute

So I took 256 x 1.21 = 309.76 rounded to 310

When you look at the total 5 hour and 24 from now you get an error and this is at 22838 pound I still need to go to 50,000 pounds

S = 22782· error of· - 46
P = 22856· error of··+ 18

Actual results are suppose to be 22838

B = P - s */ 128
A = P - B

Now if I use this I can narrow the error to

A = 22819 error of· - 19

How can I· narrow the error down can any one help



▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·idea.gif·that you may have and all of your time finding them smile.gif

·
·
·
·
Sam

Post Edited (sam_sam_sam) : 7/22/2009 1:24:40 PM GMT

Comments

  • Tracy AllenTracy Allen Posts: 6,666
    edited 2009-07-21 16:56
    Sam,

    When I calculate 5 hours, 24 minutes into seconds I get 19440 seconds, and that times 1.209677419355 pounds per second is 23516 pounds. Where did you get 22838? And shouldn't it be 72.6 #/minute, not 272.6 #/minute?

    Anyway, for better precision in PBASIC math use ** instead of */.

    1.209677419355 = 1 + .209677419355
    .209677419355 * 65536 = 13741

    Then in PBASIC:
    pounds = seconds + (seconds ** 13741)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Mike GreenMike Green Posts: 23,101
    edited 2009-07-21 17:06
    You are making some simplifying assumptions and those accumulate over time to cause errors.

    In particular, 300 / 248 = 1.2096771935+ pounds per second. That's a 0.03% error (roughly).
    With a 22838 pound load, that's an error of 9 pounds. You've got other errors from your other
    rounding, roughly the same amount (309.76 rounded to 310).

    If you want more accurate results, you'll need to use higher precision arithmetic.
    Tracy Allen (www.emesystems.com) has quite a bit of information on multiple precision arithmetic for Stamps.
    Follow the "math" link at the bottom of the page.
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2009-07-22 00:47
    Tracy Allen

    Thank You for all of your help in this Project

    That did the trick· It now work great

    Now I understand how to use the ** and */ in P Basic Math with a number· like (·1.21)

    Mike Green

    Thank You for your help as well



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them smile.gif

    ·
    ·
    ·
    ·
    Sam
Sign In or Register to comment.