Count every other second instead of every second with a DS1302 Time Chip ....>>
Hi EveryOne
This is a project that I have been ·ask to do·by employer Updated
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
We have a process that we do that we need to keep track of how much product·is left in the ·silo
so we can call the vendor to order more product there is NO WAY to put a scale to weight the silo
The only way is to do this is time how much ·product is used in one minute and keep track of it that way
Here·is my new Problem
Because our Silo hold 50,000 pounds and seconds that I am using roll over before I get to 50,000 count
so· is there a way to count every other second instead of every second
This is what i am using right now
PD = PDSecs */102··············· ·' PD = P Basic Math· 0.4 Pound Per Seconds 256 X 0.4 = 102
SL = SLSecs */102··············· ·' SL = P Basic Math· 0.4 Pound Per Seconds 256 X 0.4 = 102
IF oldsecs <> secs THEN······ · ' This Routine Compars the oldsecs to secs
·· oldsecs = secs················· ·' This Routine is so that Counter Update once a Seconds
·· PDSecs = PDSecs + 1········ ·' These Couter is need so math can be done
·· SLSecs = SLSecs + 1
ENDIF
Is there an easy way to do this
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·that you may have and all of your time finding them ![smile.gif](http://forums.parallax.com/images/smilies/smile.gif)
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 6/21/2009 8:31:48 PM GMT
This is a project that I have been ·ask to do·by employer Updated
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
We have a process that we do that we need to keep track of how much product·is left in the ·silo
so we can call the vendor to order more product there is NO WAY to put a scale to weight the silo
The only way is to do this is time how much ·product is used in one minute and keep track of it that way
Here·is my new Problem
Because our Silo hold 50,000 pounds and seconds that I am using roll over before I get to 50,000 count
so· is there a way to count every other second instead of every second
This is what i am using right now
PD = PDSecs */102··············· ·' PD = P Basic Math· 0.4 Pound Per Seconds 256 X 0.4 = 102
SL = SLSecs */102··············· ·' SL = P Basic Math· 0.4 Pound Per Seconds 256 X 0.4 = 102
IF oldsecs <> secs THEN······ · ' This Routine Compars the oldsecs to secs
·· oldsecs = secs················· ·' This Routine is so that Counter Update once a Seconds
·· PDSecs = PDSecs + 1········ ·' These Couter is need so math can be done
·· SLSecs = SLSecs + 1
ENDIF
Is there an easy way to do this
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
![idea.gif](http://forums.parallax.com/images/smilies/idea.gif)
![smile.gif](http://forums.parallax.com/images/smilies/smile.gif)
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 6/21/2009 8:31:48 PM GMT
Comments
How do You know that the feed rate is .4 pounds per sec?
_________$WMc%______
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Truth is out there············································ BoogerWoods, FL. USA
We put 300 pound· in the hoper and time how long took to empty hoper which was 12 minutes and 40 seconds
took that 12 x 60 = 720 + 40 = 760
300 / 760 = .3947 which I used 0.4
When you·run the timer after 12 minutes and 41· it shows 300 pounds which is close enough
Now I could do this routine but is there another way to this, the part in RED
IF oldsecs <> secs THEN····· · ' This Routine Compars the oldsecs to secs
··· oldsecs = secs············ ·· ·' This Routine is so that Counter Update once a Seconds
··· b = b + 1
··· ELSEIF b = 2 THEN
··· b = 0
····SLsecs· =· SLsecs· + ·1
··· PDsecs· =· PDsecs· +· 1
·ENDIF
I know that would need this change to
·
PD = PDSecs */102··············· ·' PD = P Basic Math· 0.4 Pound Per Seconds 256 X 0.4 = 102
SL = SLSecs */102··············· ·' SL = P Basic Math· 0.4 Pound Per Seconds 256 X 0.4 = 102
PD = PDSecs */204·················' PD = P Basic Math· 0.8 Pound Per 2 ·Seconds 256 X 0.8 = 204
SL = SLSecs */204·················' SL = P Basic Math· 0.8 Pound Per 2 ·Seconds 256 X 0.8 = 204
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 6/19/2009 2:30:52 AM GMT
This will create a running total that keeps track of all the odd seconds (1,3, ..., 57, 59, 1, ...) that pass by. It assumes that current_seconds is in the range of 0 to 60.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·······
······· "What do you mean, it doesn't have any tubes?"
······· "No such thing as a dumb question" unless it's on the internet
········
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
Thank You for your reply
I can read the (0) and (1) but it advances the counter every second
Which help me a lot Thank You for your help in this project
DO
GOSUB Get_secs
·DEBUG HOME,HEX secs,CR,· DEC3 s························ ·' To Read The Seconds
LOOP
Get_secs:····················································· · ' DS1302 Reads the Read the Seconds Register
· HIGH CS1302··············································· · ' Select DS1302
· SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]RdSecs]
· SHIFTIN DataIO, Clock, LSBPRE, [noparse][[/noparse]secs.BIT0]
· LOW CS1302················································ · ' Deselect DS1302
· RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 6/21/2009 8:59:10 PM GMT
s = s + 2
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Truth is out there············································ BoogerWoods, FL. USA
I am using the DS1302 for two thing one is to save the data in ram
The other thing that I am using is the second register as a triggering point for the counters that I· am using
they are·seconds that have gone by but that is the only way you can do this
That is why I was hoping there was a way to this with the DS1302 Time Chip to not have a third counter·like I had posted earlyer
This with using every second
1·second =·.4 pound··· to··· 65535 seconds =··26214 pounds · which mean that my counter has roll over
Now if I could use every other second
1·seconds = .8 pounds· to··· 40000 seconds = 50000 pounds· which mean that counter would not roll over
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 6/20/2009 8:37:36 PM GMT
Thank You for your reply
I must not have done something right with what·I try ed because the seconds would update every seconds
ether that or I am not understanding how to write the code to do it that why I posted one of thing I try ed
Could you give an example of how to write it
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 6/21/2009 12:38:55 AM GMT
That would be the PBASIC version. Total is a running total of the number of odd seconds. current_seconds is the current second in the range of 0-59.
I will try tomorrow Thank You for your help
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Thank You for your reply and ALL the help that you have give in the past
It did not work for me......>>>>>..BUT..>>>>
You got me thinking about a Project that I·also was·working on for the company that I work for
and some help that I got from·......>>>>
I want to Thank Tracy Allen for sharing this code routine with me and all of his help in the the past
·Tracy Allen .....>>>> State Machine Logic For InPut Pin
····························· So I·thought about this, if this would work for me in this case·and· it works very well
This where Tracy help with this other ·Project
It update The PDSecs· and SLSecs every two seconds just what I was looking for
xbit··········· VAR···· Bit············ ' current state
x0············· VAR···· Bit············ ' previous state
xx············· VAR···· Bit············ ' change of state from·0 to 1
·
·
xbit = secs.BIT0
· xx = xbit ^ x0 & x0
· x0 = xbit
· PDSecs = PDSecs + xx······ ' These Counter's are need so math can be done
· SLSecs = SLSecs + xx
PD = PDSecs */204········ ' PD = P Basic Math· 0.4 Pound Per Seconds 256 X 0.4 = 102· or ·0.8 Pounds·Per ·every two seconds 256 X 0.8 =·204
SL = SLSecs */204········ ' SL = P Basic Math· 0.4 Pound Per Seconds 256 X 0.4 = 102· ·or ·0.8 Pounds·Per ·every two seconds 256 X 0.8 =·204
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 6/21/2009 8:56:46 PM GMT