Can P Basic Math be done on the fly with RC TIME command this is for Tracy All
sam_sam_sam
Posts: 2,286
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 this part resolved but there is a new problem
·
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
The problem now is that the flow rate changes depending on air flow setting
is there a way to adj the . value on the fly with RC TIME command
.xxxxxxxxxxxx * 65536 base on where RC TIME value is
x value range is from .1xx to .9xx would be nice if this can be done
x is value that want to adj how would I set this up IF this can be done
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 8/11/2009 3:15:10 AM GMT
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 this part resolved but there is a new problem
·
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
The problem now is that the flow rate changes depending on air flow setting
is there a way to adj the . value on the fly with RC TIME command
.xxxxxxxxxxxx * 65536 base on where RC TIME value is
x value range is from .1xx to .9xx would be nice if this can be done
x is value that want to adj how would I set this up IF this can be done
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 8/11/2009 3:15:10 AM GMT
Comments
The Stamp only has integer arithmetic. Depending on the
accuracy you need for the final answer, you may have to
use double precision arithmetic. Tracy Allen has some of
these extended math routines posted on his web site.
You may have to change the Stamp from a BS2 to a BS2P
in order to have enough room.
phil
But suppose you have a fraction N/D<1, and what you really want to compute is x*N/D. That is, the result is a certain proportion of x. N and D may be variables (dependent on air flow?) so you have to compute it at run time, not in advance as a constant. The Stamp can calculate a number, f, such that you can replace x*N/D with x ** f. That will be probably the most accurate way to do it on the Stamp. Here is the algorithm that computes f:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Thank You for your help in this Project
·I think This is just what I was look for
I change the value of N and F gave me a roughly the value that would except
If I use the out put from·the· RC TIME command· which the output from that would be =·N
D = 1% of 65536 which =·655
F =· value .1###########· to .9###########····· ·which is what I want to adj on the fly
I hope that you can understand what I want do
300 pound / 248 seconds = 1.209677411935...........
1 +· .209677411935·x 65536 = 13741..>· This is·what I want basicly dial this·
in so I do not have reprogram the Basic Stamp each time the Flow rate changes
500 pounds / 348 = 1.436781609195................
1 +· .436781609195x 65536 = 28625..> ·and so on
·Will this work Or am I completely wrong with·what I have here
' {$STAMP BS2}
' {$PBASIC 2.5}
J·· VAR··· Byte
N·· VAR··· Word
D·· VAR··· Word
F·· VAR··· Word
·'from http://www.emesys.com/BS2math2.htm#binary_long
' enter with N<32768, D<32768, N<D
'
binary division loop
N = 64000
D = 655
FOR J=15 TO 0·············· ' 16 bits
N=N//D<<1·················· ' remainder*2
F.BIT0(J)=N/D·············· ' next bit
NEXT
·DEBUG HOME,DEC5 ? N, CR, DEC5 ? D, CR, DEC5 ? F, CR
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 8/2/2009 9:20:21 PM GMT
It won't work as you have it. Note that the comment at the start of the code requires N<32768 and N<D, but you have N=64000 and D=655. Why those values? Also in your example you have 1.21 * 65536 = 13741 and 1.41 * 65536 = 28625, but neither of those is correct, even mod 65536. Huh?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
I want to take the result value and change ** ---- value on the fly if this can be done
the problem now is that when the flow rate changes I have reload the Basic stamp with the new value I want·to use·a pot to change
this value·
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
We know that pounds per second is a number around 1.2 or 1.4, but what is the full expected range?
(pounds) = (seconds) * (pounds per second)
But how do you figure this:
(pounds per second) = function_of (result)?
For example, if result=12345, what is (pounds per second)?
or if result = 54321, what is it?
Maybe there is a math formula, or maybe it is empirical, or maybe it needs a table of values to figure it out.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Does result have a maximum and a minimum value?· Yes
1.1 to 1.9 pound per seconds is the excepted value
·Does it need to be calibrated? Yes some what in that if the pound per second is way·off then the amount in the Silo will be way·off
So the result from RCTIME is somehow related to air flow and then to (pounds per second).
·Yes in·that I would like to adj the Flow rate value
I will still would have to figure this part·out manually
Pound / seconds = pounds per seconds then 1 + (. some value) ·x 655365 = P Basic math value
Then take this value and basically dial this in as the new value
·That would be ADJ by RCTIME value so I would not need to reload the Basic Stamp Again with this new pound per second value again
·
·
We still have to check the flow rate from the hopper to see if that value· is still right
I can not change that part
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 8/3/2009 12:27:12 AM GMT
I wrote this Demo to test the end value of 50,000 pound which is how much the Silo hold to see how far off the actual value versus the Basic Stamp
value is
I tried this Demo to see if I could use the RCTIME to do what I have in mind and it seem to work OK
Please give your thoughts on what·I have here if you see any problems with what I have in the Demo
Please feel free to let know what changes·need to make this work
Thank You for all of your help in this Project this has help me a lot I have learned a lot about programing
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 8/3/2009 1:35:13 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Here are the calibration steps.
1) Have PBASIC find the RCTIME value at maximum resistance, call it RTmax
2) ditto the RCTIME value at minimum resistance, call it RTmin
Those two values will be approximately 740 and 70.
3) Have PBASIC calculate the difference RTdiff = RTmax - RTmin, approximately 670.
4) Turn the dial to an intermediate setting, and have PBASIC measure the RCTIME, call it RCset
5) run the division algorithm:
Now, the Word value f contains the multiplier you need to use in
mass = seconds + (seconds ** f)
The overall result is something in the calculator range of 1.0 to 2.0 as the mass per second conversion.
You could calibrate the dial of the potentiometer in units from 1.0 to 2.0. If you want to translate the f factor into a decimal fraction to display on your LCD screen, use,
x = f ** 1000
DEBUG "1.", DEC3 x ' or the LCD equivalent.
Note that some of the variables are temporary and can be recycled.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
·
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
The problem now is that the flow rate changes depending on air flow setting
is there a way to adj the . value on the fly with RC TIME command
.xxxxxxxxxxxx * 65536 base on where RC TIME value is
x value range is from .1xx to .9xx would be nice if this can be done
x is value that want to adj how would I set this up IF this can be done
This· give me·the range that I want and it tell what the flow rate pounds per seconds
I want to thank Tracy Allen for all of his help in this project
and by this doing this project i have learned a lot about programing a Basic Stamp
I also want to Thank all of·you·that have replied and offer help in this project
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 8/5/2009 3:04:20 AM GMT
Because the·Air Flow Rate now is Controlled with a Ball Value right now
the Flow Rate is suppose to be 300 CFM @ 120 PSI· MAX·and the compressor that we are using put out 700 CFM @ 140 PSI
and the Flow Rate may below 1 pound per second What would I need to change to make this work with less than 1 pound per seconds
I would like to use· **· instead of */ if this can be done
Just so I know how to do it how would ·you do it if your Flow Rate is more than 2 pounds per second
The person that works with this Sand Blaster will have find the right flow rate for the best work to be done
Then I can take this New Flow Rate and go from there
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 8/11/2009 3:38:02 AM GMT