This Project is almost Done (Resloved Save Data to DS1302 Time Chip)Thank You f
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·Tis a another Post but this is a different question
http://forums.parallax.com/showthread.php?p=804156
What I want to do is each time the user stop using the Product it saves it to the DS1302 Chip until the user
Start again·to keep track of how much product is left in the SILO in case the power gose OFF
I try to a few time to get this to work but no luck so far
Dose any one have a routine that they can share with me··![smile.gif](http://forums.parallax.com/images/smilies/smile.gif)
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··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) : 7/4/2009 8:13:42 PM 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·Tis a another Post but this is a different question
http://forums.parallax.com/showthread.php?p=804156
What I want to do is each time the user stop using the Product it saves it to the DS1302 Chip until the user
Start again·to keep track of how much product is left in the SILO in case the power gose OFF
I try to a few time to get this to work but no luck so far
Dose any one have a routine that they can share with me··
![smile.gif](http://forums.parallax.com/images/smilies/smile.gif)
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··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) : 7/4/2009 8:13:42 PM GMT
Comments
Thank You for your reply
I want to save the Data from this routine to the DS1302· Time Chip
do it the same way that you put data to a serial LCD display in the[noparse][[/noparse] bracket ]
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 5/3/2009 10:34:32 PM GMT
Can someone help me with this
I must be having brain failure or something
I just can not·see·what wrong·with what·I am trying to do
Metered:
DEBUG CR,CR, DEC5 ? Silo
DEBUG CR, CR, DEC5 ? product , DEC5 ?· minutes
'Silo = Product (- 1)
product = minutes */435
·IF oldmins <> mins THEN
·oldmins = mins
minutes = minutes + 1
silo = silo + 1
ENDIF
WriteRam:······································································· ·'Write to DS1302 Ram
· reg = WrRam | (Reg << 1)················································ ' RAM Write Mode + Address
· HIGH CS1302Pin····························································· ·' Select DS1302
· SHIFTOUT Dta1302Pin, Clk1302Pin, LSBFIRST, [noparse][[/noparse]reg, ioByte]
LOW CS1302Pin······························································· ·' Deselect DS1302
ReadRam:···································································· ·'Read From DS1302 Ram
· reg = RdRam | (Reg << 1)············································ ·' RAM Read Mode + Address
· HIGH CS1302Pin························································· ·' Select DS1302
· SHIFTOUT Dta1302Pin, Clk1302Pin, LSBFIRST, [noparse][[/noparse]reg]
· SHIFTIN Dta1302Pin, Clk1302Pin, LSBPRE, [noparse][[/noparse]ioByte]
LOW CS1302Pin··························································· ·' Deselect DS1302
·WriteRam:········································································ ·'Write to DS1302 Ram
· reg = WrRam | (Reg << 1)················································ ' RAM Write Mode + Address
· HIGH CS1302···································································· ·' Select DS1302
· SHIFTOUT DataIO, Clock,LSBFIRST, [noparse][[/noparse]reg, ioByte]
· SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]WrBurst]
· SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]Product,Silo,temp,temp,temp,temp,temp, 0]
LOW CS1302········································································ ' Deselect DS1302
RETURN
ReadRam:······································································· ·'Read From DS1302 Ram
· reg = RdRam | (Reg << 1)············································· ' RAM Read Mode + Address
· HIGH CS1302································································ ·' Select DS1302
· SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]reg]
· SHIFTIN· DataIO, Clock, LSBPRE, [noparse][[/noparse]ioByte]
· SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]RdBurst]
· SHIFTIN DataIO, Clock, LSBPRE, [noparse][[/noparse]Product,Silo,temp,temp,temp,temp,temp]
LOW CS1302
· RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 5/3/2009 10:44:59 PM GMT
How about explaining what works and what doesn't work
I am not able to save the Product·or Silo data to the DS1302
The other Routines·works just the way I want them to work
You might also add more DEBUG statements to show what the program is doing.
How do I only read the Ram Data that is saved in the DS1302 Chip
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Jeff T.
Insert DEBUG after reg , you are missing bit 0 = 1 for read
·WriteRam:········································································ ·'Write to DS1302 Ram
· reg = WrRam | (Reg << 1)················································ ' RAM Write Mode + Address
· DEBUG HEX ? reg
· HIGH CS1302···································································· ·' Select DS1302
· SHIFTOUT DataIO, Clock,LSBFIRST, [noparse][[/noparse]reg, ioByte]
· SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]WrBurst]
· SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]Product,Silo,temp,temp,temp,temp,temp, 0]
LOW CS1302········································································ ' Deselect DS1302
RETURN
ReadRam:······································································· ·'Read From DS1302 Ram
· reg = RdRam | (Reg << 1)············································· ' RAM Read Mode + Address
· DEBUG HEX ? reg
· HIGH CS1302································································ ·' Select DS1302
· SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]reg]
· SHIFTIN· DataIO, Clock, LSBPRE, [noparse][[/noparse]ioByte]
· SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]RdBurst]
· SHIFTIN DataIO, Clock, LSBPRE, [noparse][[/noparse]Product,Silo,temp,temp,temp,temp,temp]
LOW CS1302
· RETURN
I was under the impression it always read and wrote from address zero upward to 30. If my thoughts are right then it also means that burst mode might not be the best method to record production records as each record would overwrite the previous.
So taking out the address specifier I would write the code as follows for burst.
·If the objective is to maintain several records in the DS1302 RAM then I would not use burst mode in this program.
Jeff T.
Thank You For reply s
But I can not get this to work
All·I get when power is removed is····· ·128
Then starts at 00000·· for all Data results
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 5/4/2009 4:10:06 AM GMT
These look like routines from some sample code I wrote.· Perhaps to make things simpler you could try something like:
reg = 0
ioByte = Product
GOSUB WriteRAM
reg = 1
ioByte = Silo
GOSUB WriteRAM
etc.· There are simpler ways to write this, but this might be easier to understand.· When you call WriteRAM reg needs to contain the target address and ioByte needs to contain the data to be written.· I hope this helps.· take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
Not completely sure how your doing all this but I did notice that "Product" and "Silo"·are word values , so you need to be writing Product.HighByte and Product.LowByte to RAM and the same with Silo
SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]Product.HighByte,Product.LowByte,Silo.HighByte,Silo.LowByte]
Jeff T
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
@Sam , just keep trying the suggested modifications Sam and post back with your observations .
Jeff T.
EDIT: Sam I am adding a small piece of code that writes two word values to RTC Ram and then reads them back , just make sure I have the pin assignment correct for your setup.
Post Edited (Unsoundcode) : 5/4/2009 6:47:52 PM GMT
Thank You for your help with this Project
I start to think that I was losing it last night trying to get this to work
I have try ed before to get this to work with no luck but it was·not importance enough to get it to work until now
Thanks again for your help
··Chris Savage
Thank You for your help as well
I will use this when I do not need to save it as a WORD
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
This routine work as you see it
But when I add Get_Time Routine It is wiped out
How do I fix this problem
·DS1302_Ram_Save_Demo .BS2
DataIO······ ··· PIN··· 4·············· ' DS1302.6
Clock·········· · PIN··· 3············· ' DS1302.7
CS1302········· PIN··· 5·············· ' DS1302.5
Product········ VAR·· ·Word
Silo·············· VAR··· Word
reg·············· VAR··· Byte
DO
GOSUB RdRam
product = product + 1
silo = silo + 1·······
GOSUB WrRam
PAUSE 200
LOOP
WrRam:
· reg = $FE
· HIGH CS1302
· SHIFTOUT DataIO, Clock,LSBFIRST, [noparse][[/noparse]reg]
· SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]Product.HIGHBYTE,Product.LOWBYTE,Silo.HIGHBYTE,Silo.LOWBYTE]
· LOW CS1302
RETURN
RdRam :
· reg = $FF
· HIGH CS1302
· SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]reg]
· SHIFTIN DataIO, Clock, LSBPRE, [noparse][[/noparse]Product.HIGHBYTE,Product.LOWBYTE,Silo.HIGHBYTE,Silo.LOWBYTE]
· LOW CS1302
· DEBUG HOME, "Product = ",DEC Product,"· Silo = ",DEC Silo, CR
RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 5/5/2009 2:21:49 AM GMT
There are two values for reading in burst mode and two values for writing in burst mode. Two of these apply to the clock and two to the RAM.
CLOCK:
Clk_Wr_Burst CON $BE
Clk_Rd_Burst CON $BF
RAM:
Ram_Wr_Burst CON $FE
Ram_Rd_Burst CON $FF
Jeff T.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 5/5/2009 9:10:25 PM GMT
Thank You for your routine of how to save to a DS1302 Time Chip
The problem·I was having·not being able to··save data was I was trying to save the wrong data
P = seconds */102········ I was trying to save "P"
································· What I need to save was seconds instead
' {$STAMP BS2}
' {$PBASIC 2.5}
DataIO········· PIN··· 4·············· ' DS1302.6
Clock·········· ·PIN··· 3············ · ' DS1302.7
CS1302·········PIN··· 5·············· ' DS1302.5
Product VAR Word
Silo VAR Word
reg VAR Byte
Silo=3456
Product=256
GOSUB WrRam
GOSUB RdRam
END
WrRam:
· reg = $FE
· HIGH CS1302
· SHIFTOUT DataIO, Clock,LSBFIRST, [noparse][[/noparse]reg]
· SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]Product.HIGHBYTE,Product.LOWBYTE,Silo.HIGHBYTE,Silo.LOWBYTE]
· LOW CS1302
RETURN
RdRam :
· reg = $FF
· HIGH CS1302
· SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]reg]
· SHIFTIN DataIO, Clock, LSBPRE, [noparse][[/noparse]Product.HIGHBYTE,Product.LOWBYTE,Silo.HIGHBYTE,Silo.LOWBYTE]
· LOW CS1302
· DEBUG "Product = ",DEC Product,"· Silo = ",DEC Silo
RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
When I·done with this project I will Post it
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam
Maybe some time this week if some people at work have time to mount the back plate so I can put up the controller
And I see that it alright it will take some photo of the controller and post them
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any·
·
·
·
·
Sam