Shop OBEX P1 Docs P2 Docs Learn Events
BS2...DS1302 demo code — Parallax Forums

BS2...DS1302 demo code

hmlittle59hmlittle59 Posts: 404
edited 2008-11-26 04:45 in BASIC Stamp
Hello all,

the code from Jeff Martin shows numbers being saved to DS1302 RAM, can Letters(char.) be saved also? "YES"..."NO"..."***".

thanks

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I HAVE LEARN SO MUCH...BUT STILL KNOW SO LITTLE!!!

hmlittle59

Comments

  • awesomeduckawesomeduck Posts: 87
    edited 2008-11-24 14:15
    Letters are numbers....everything in a computer is just a series of 1 and 0. Google for ASCII Character set and you will learn how it all works.
  • sylvie369sylvie369 Posts: 1,622
    edited 2008-11-24 15:14
    Awesomeduck is right. You can also read the Help file for the DEBUG command.

    Try this for a little demo:

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    X   VAR Byte
    Y   VAR Byte(6)
    
    X = 65
    Y(0) = "H"
    Y(1) = "e"
    Y(2) = "l"
    Y(3) = "l"
    Y(4) = "o"
    Y(5) = 0
    
    DEBUG X,CR
    DEBUG DEC X,CR
    DEBUG HEX X,CR
    DEBUG BIN X, CR
    DEBUG CR
    
    DEBUG Y,CR
    DEBUG DEC Y,CR
    DEBUG HEX Y,CR
    DEBUG BIN Y, CR
    DEBUG STR Y, CR
    



    The memory location holding variable X contains the binary number 01000001. That number can be used as the decimal number 65, the Hex number 41, or the ASCII character 'a'. You could add 3 to X, and you'd get 68, 44 (Hex), or 'd' (ASCII). The memory location doesn't care what you're planning to use the number for.

    Post Edited (sylvie369) : 11/24/2008 3:25:32 PM GMT
  • hmlittle59hmlittle59 Posts: 404
    edited 2008-11-26 00:12
    Thanks,

    I understand Hex,Ascii, and all, I guess I'm just making it harder then what it should be for myself when I look at and try to understand the DS1302 Demo and writing my own code to use the 31 Bytes. I'm just looking to store some (AUTO-CONFIG.) info in this RAM. "YES/NO", Number Values(22,00,03,*,##). My Pseudo Code is done and the Demo has Number Examples. I'll just save words "YES" or "NO" one letter at a time.



    thanks for the info

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I HAVE LEARN SO MUCH...BUT STILL KNOW SO LITTLE!!!

    hmlittle59
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-11-26 01:23
    I do the same thing in a DS1307. I'd store the YES and NO as single byte values 1 and 0.

    Don't know about the DS1302, but the DS1307 seems to retain stuff in its RAM even through a brief power-down that kills the time-of-day in the clock. Every time I jiggled the board, it would lose the time but keep the rest. Battery jiggling in its holder, I think. I put a capacitor across the battery, big enough to run the clock about 1/10 second -- 0.1 microfarad -- and stopped losing time, even when I directly beat on the battery in its holder.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i@arrl.net

    Post Edited (Carl Hayes) : 11/26/2008 5:50:23 AM GMT
  • hmlittle59hmlittle59 Posts: 404
    edited 2008-11-26 02:32
    Thanks,

    Yes, I use the (1 & 0) already so the Sub-routine is in place, but I just wanted to ensure the selection was exact and no false location settings(noise) or back up power glitches
    as this could by-pass some routines and setup some false values and (LOCK-OUT) times. Maybe I'll use 3 ones(111) = yes ... 3 zeros(000) = no (keep data field the same) to keep it close to full proof. My current board already has the 3.3v back up in place for the DS1302.

    I'll think on it some more thanks Carl

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I HAVE LEARN SO MUCH...BUT STILL KNOW SO LITTLE!!!

    hmlittle59

    Post Edited (hmlittle59) : 11/26/2008 2:57:26 AM GMT
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-11-26 04:45
    Maybe even an error-correcting code -- I've got a book on that around here somewhere --

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i@arrl.net
Sign In or Register to comment.