Shop OBEX P1 Docs P2 Docs Learn Events
How would I save the same label names with different Data In a DS1302 as a d — Parallax Forums

How would I save the same label names with different Data In a DS1302 as a d

sam_sam_samsam_sam_sam Posts: 2,286
edited 2010-01-28 00:39 in General Discussion
If this can be done
·Also would like to time stamp the data this is a maybe·( ?·)
reg = 0··· Is Product
reg = 1··· is Silo
reg = 2··· Is Product
reg = 3··· is Slio
reg.........>>>>>>>>>>>> and so on
reg..........>>>>>>>>>>>>and so on



··One· Until all reg are full· learn this first
and also be able to read all reg - 0 to last reg· one line at a time

··Two and then over ride the reg 0 and start over writing new· Data· in the same reg <<< meaning that to veiw the last how many data point that there are >>>>·then learn how to do·this


' {$STAMP BS2}
' {$PBASIC 2.5}

'
[noparse][[/noparse] I/O Definitions ]

DataIO········ · PIN···· 1························· · ' DS1302.6
Clock··········· ·PIN···· 0·························· ·' DS1302.7
CS1302········· PIN···· 2························· · ' DS1302.5

'
[noparse][[/noparse] Constants ]

WrRam·········· CON···· $FE························· ' Write RAM Data
RdRam·········· CON···· $FE························· ' Read RAM Data

'
[noparse][[/noparse] Variables ]

index·········· VAR···· Byte························· ' Loop Counter
reg············ ·VAR···· Byte························· ' Read/Write Address
ioByte········· VAR···· Byte························· ' Data To/From DS1302
Product········VAR···· Byte
Silo············ VAR···· Byte

reg = 0
ioByte = Product
GOSUB Write_Ram

reg = 1
ioByte = Silo
GOSUB Write_Ram

Write_Ram:
·HIGH CS1302····················································· ·' Select DS1302
· SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]reg, ioByte]
· LOW CS1302····················································· · ' Deselect DS1302
· RETURN

Read_Ram:
· HIGH CS1302···················································· · ' Select DS1302
· SHIFTOUT DataIO, Clock, LSBFIRST, [noparse][[/noparse]reg]
· SHIFTIN DataIO, Clock, LSBPRE, [noparse][[/noparse]ioByte]
· LOW CS1302···················································· · ' Deselect DS1302
· RETURN

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

·
·
·
·
Sam

Post Edited (sam_sam_sam) : 1/17/2010 2:04:26 AM GMT

Comments

  • kwinnkwinn Posts: 8,697
    edited 2010-01-17 14:43
    Sam, I am not familiar with the basic stamp so this is just an outline of the steps in generic basic using your variable names. I leave the translation to basic for the stamp to you.
    If you wanted to add a time stamp it could would take anywhere from 2 registers ( for HH:MM stored as packed BCD ) to 7 registers ( date and time as it appears in the 7 date time registers ). This would mean reducing the number of entries you could store as follows:
    Storing 2 bytes (product and silo) 15 entries
    Storing 4 bytes (product, silo, HH:MM) 7 entries
    Storing 9 bytes (product, silo, 7 date time registers) 3 entries

    ' This code will write the product and silo to registers 0 to 29 and then start over at 0
    loop:
    reg = 0
    for index = 0 to 14
    ioByte = Product
    GOSUB Write_Ram
    reg = reg + 1
    ioByte = Silo
    GOSUB Write_Ram
    reg = reg + 1
    ' Time stamp could be added here if the number of loops (for index = 0 to 14) is decreased
    end for
    goto loop
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2010-01-27 21:16
    I'm not sure I understand what you mean...are you just trying to overwrite previous samples stored on the datalogger? Where do the register names come into play?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Engineering
    Check out the new Savage Circuits TV!
    ·
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2010-01-28 00:39
    Chris

    Where do the register names come into play

    They are just name

    are you just trying to overwrite previous samples stored on the datalogger

    Yes want to use the DS1302· ram as a data looger of sorts

    A while back I ask how to save data on a DS1302 ram and you had a post where you put this as a example in the first post

    My question is how would save the value so you could read the 0-30 slots that the chip has

    I just want read what in ram at any given time the most updated Data


    Here is an example >>>> let say

    Using an ADC


    Reading1· 1.23
    Reading2··1.35
    Reading3··1.45

    and so on to

    Reading 30

    once it has reach 30
    it start back over to

    Reading1· with new data

    and so on
    ·

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

    ·
    ·
    ·
    ·
    Sam

    Post Edited (sam_sam_sam) : 1/28/2010 12:49:33 AM GMT
Sign In or Register to comment.