How do you take a value from a Scale doing P Basic Math and from a Flow Meter
Let say that you have a value from a scale and you take the value which has done with PBasic math
and you get a value................
product·········· VAR···· Word
Water············ VAR···· Word
Pulses··········· VAR···· Word
FMeter·········· VAR···· Word
Which would···· Water = Product */34·········· ·' This will tell you how many gallons of water
···
............You need so many Pulses for so many Gallons of water which has done with PBasic math
· Which would· ·Pulses = Water· */20070····· ' This will tell you how many Pulses you need for so many gallons
This is the part that is taken·from the data from the Scale and use to know how many gallons of water need
Now the Pulses from the Flow Meter are going to be counted with the Basic Stamp
·Would you count the Pulses from the Flow Meter· with the PULSIN Command
I want take the PULSIN value and compare this to the Pulses value and when they are the same then we are done
I am not sure how to write this part of the·routine
Can any one help me with problem
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 5/18/2009 1:12:42 AM GMT
and you get a value................
product·········· VAR···· Word
Water············ VAR···· Word
Pulses··········· VAR···· Word
FMeter·········· VAR···· Word
Which would···· Water = Product */34·········· ·' This will tell you how many gallons of water
···
............You need so many Pulses for so many Gallons of water which has done with PBasic math
· Which would· ·Pulses = Water· */20070····· ' This will tell you how many Pulses you need for so many gallons
This is the part that is taken·from the data from the Scale and use to know how many gallons of water need
Now the Pulses from the Flow Meter are going to be counted with the Basic Stamp
·Would you count the Pulses from the Flow Meter· with the PULSIN Command
I want take the PULSIN value and compare this to the Pulses value and when they are the same then we are done
I am not sure how to write this part of the·routine
Can any one help me with problem
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·

·
·
·
·
Sam
Post Edited (sam_sam_sam) : 5/18/2009 1:12:42 AM GMT
Comments
How long are the pulses and how quickly do they come in? Basically, you are going to have to count them yourself like:
Do you know how many pulses per second you'll be seeing? In my experience, if they get to 30 - 40 pulses per second, the Stamp won't be able to keep up, especially if the program has to do other things.
What you may have to do is have a dedicated Stamp to count pulses which the other Stamp can interrogate when it wants to check.
Cheers,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Tom
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
Thank You for sharing the routine
waitFor1:
···if·inputpin·=·0·then·goto·waitFor1·············· '·Wait·for·a·high
waitFor0:
···if·inputpin·=·1·then·goto·waitFor0············· ·'·Wait·for·a·low
···Pulses·=·Pulses·-·1
···if·Pulses·>·0·then·goto·waitFor1················· '·More·pulses·left·to·count
'·Here·the·pulse·count·has·become·zero.··We·can·probably·turn·off·the·water.
Tom Sisk, ·Stephen
Thank You for replys this will help alot
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 5/16/2009 8:53:32 PM GMT
In PM you told me there will be 78.4 pulses per gallon and you are looking at a flow rate of about 30 gallons per minute. That will be 2352 pulses per minute, or about 40 per second. That gives about 25 milliseconds from pulse to pulse for the Stamp to do processing. That is really quite a bit of time if the Stamp does not have much else to do while counting. Mike's code will work, or for variation here is another kind that uses state machine logic.
I figure that loop will execute in about 3 milliseconds, so that is plenty of time within the 25 ms allowed. It actually has to catch both the opening and the closing of the switch, within the 25 millisecond period.
Some new flowmeters use optical or hall effect sensors that have no bounce, however, some older flowmeters have long reed relays that are notorious for bounce. If bounce is an issue, additional tests have to be put in the loop to be sure that the switch is stable.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
http://www.koboldusa.com/datasheet/DRB-DPE_datasheet.pdf
Electrical Specifications
Frequency Output
Output Type: PNP open collector, 25 mA max.
Power Requirement: 14-28 VDC
Compact Electronics
Output Type: 4-20 mA, 3-wire & PNP switch or 2 PNP switches
Switch Rating: 300 mA Max. short circuit protected flow switch or frequency transmitter
6.6-65 DRB-1165 DRB-1265 N8=1-1/2” NPT
Part Number 807.037=Mating 4-pin Micro-DC plug with 6 ft. cable for output F300, L342, L343 & Z340
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 5/17/2009 3:41:19 PM GMT
Can you Please·explain one line to me so I can understand how this routine works the part in RED Code Wise
Could you Please give an example like they have in the two example below
Thank You all of your help in this project
'·· {$STAMP BS2}
'·· {$PBASIC 2.5}
xbit···· VAR··· Bit············································· ··· ·'·current·state·of·input·pin
x0····· ·VAR··· Bit·················································· '·previous·state
xx····· ·VAR·· ·Bit·················································· '·change·of·state·from·high·to·low
N······ ·VAR··· Word··············································· '·number·of·pulses
N=0
DO
··xbit·=·in0
' I understand what they have here as far as the truth table XOR
'============================================================================================
'························· ^ Bitwise XOR
' The Exclusive OR operator (|) returns the bitwise exclusive OR of two values.
'· Each Bit of the values is subject TO the following logic:
'
'··· 0 ^ 0 = 0
'··· 0 ^ 1 = 1
'··· 1 ^ 0 = 1
'··· 1 ^ 1 = 0
'
' The result returned by ^ will contain 1s in any Bit positions in which one OR the other
' (but NOT both) INPUT values contain 1s.
'
'Main:
'· value1 = %00001111
'· value2 = %10101001
' ·result = value1 ^ value2
'
·' DEBUG HOME, BIN8 ? value1,
·'··············· · · BIN8 ? value2,
·'·············· ··· ·BIN8 ? result······· ' Show OR result (%10100110)
·'
'============================================================================================
''& Bitwise AND
'The AND (&) operator returns the bitwise AND of two values.
' Each bit of the values is subject to the following logic:
'
'
'··· 0 & 0 = 0
'··· 0 & 1 = 0
'··· 1 & 0 = 0
'··· 1 & 1 = 1
'
'
'The result returned by & will contain 1s in only those bit
'positions in which both input values contain 1s.
value1 = %00001111································································· %00001111
· value2 = %10101101································································%10101101
· result = value1 & value2·························································· (%00001101
· DEBUG HOME, BIN8 ? value1,································ ' Show AND result (%00001101)
·················· · BIN8 ? Value2,
···················· BIN9 ? result
'
'=================================================================================================
··xx·=·xbit·^·x0·&·x0
··x0·=·xbit
··N·=·N·+·xx
·················
·· DEBUG HOME, DEC ? xbit,
···················· ·DEC ? xx,
···················· ·DEC ? x0,
···················· ·DEC ? N
LOOP·UNTIL·N·=· 30············································ ··'·pulses Needed
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 5/17/2009 6:38:15 PM GMT
Here Is a Demo From what you have in your Post
Which work very well
Thank You for the example
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Here is the Demo that I wrote to use what you have Posted
Thank You for sharing the code and your help in this Project
When we order the Flow Meter and come in
·I will try both Demo and see which one work the best·for the·Code Routine that·I still have to·write
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 5/17/2009 9:48:31 PM GMT
The value of xx will be either 1 or 0, depending on the current value of the input (xbit) and the prior value of the input (x0).
xx will be 1 only if there is a change from prior time to now (xbit ^ x0 = 1) AND the prior time it was high ( & x0). So xx will be 1 only when the input changes from 1 to 0. Note that the statement x0 = xbit subsequently updates the prior value. The DO:LOOP can execute many many times with xx=0. It is only during one time around that it becomes xx=1, when the input transitions from 1-->0.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Post Edited (Tracy Allen) : 5/18/2009 4:47:55 PM GMT
Thank you for taking the time to explain this to me and all of your help in this project
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
The company that I work for has put this Project on hold for now I will keep you posted if this changes
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam