Shop OBEX P1 Docs P2 Docs Learn Events
pocketwatch code — Parallax Forums

pocketwatch code

globalglobal Posts: 6
edited 2006-11-14 22:01 in BASIC Stamp
I'm using the following code to program the pocket watch and to check it i'm trying to display it with DEBUG.· Its not working though. Any suggestions??


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


'AN-151 BSII interface to Pocket Watch B
'by Solutions Cubed
'07/97

'Set I/O pin directions
INPUT·4 'communication FROM Pocket Watch B tm
OUTPUT·5 'communication TO Pocket Watch B fm

'Declare variables
ss VAR Byte 'seconds
mm VAR Byte 'minutes
hh VAR Byte 'hours
dd VAR Byte 'days
mo VAR Byte 'months
yl VAR Byte 'years low
yh VAR Byte 'years high

Begin:
HIGH·5 'ensure no spurious start bit
PAUSE 1000

SetTimeCommand:
SEROUT 5,240,[noparse][[/noparse]$55,$00,$32,$3b,$d,$d,$A,$06]

ReadTimeCommand: 'see what time it is presently
SEROUT 5,240,[noparse][[/noparse]$55,$12]

SERIN 4,240, [noparse][[/noparse]ss,mm,hh,dd,mo,yl,yh]
DEBUG $12,$16,$0c, "Time: ",DEC2 hh,":",DEC2 mm,":",DEC2 ss,13,"Date:",DEC2 mo,"/",DEC2 dd,"/20",DEC2 yl, CR
PAUSE 1000
GOTO ReadTimeCommand

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-11-11 21:28
    global -

    Change all of your BAUDMODE parameters to 84, and that should get you going. This presumes you are actually using a BS-2.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • globalglobal Posts: 6
    edited 2006-11-13 17:36
    thank you so much! I have another question.· This code displays the time through debug.· Can anyone help me as far as showing the time on an lcd instead of debug?· I'm kinda new at this and I'm having problems.·
  • Paul Sr.Paul Sr. Posts: 435
    edited 2006-11-13 18:05
    global said...
    thank you so much! I have another question. This code displays the time through debug. Can anyone help me as far as showing the time on an lcd instead of debug? I'm kinda new at this and I'm having problems.

    What do you have for an LCD? If none, consider a serial one - much easier to deal with. Then you can just take your DEBUG statement and make it a SEROUT [noparse][[/noparse]with the appropriate commands for the LCD you choose] and you should be all set.

    For example:
    SEROUT LCD_PIN, LCD_BAUD, PACE [noparse][[/noparse]"?y1?x00", "Time: ",DEC2 hh,":",DEC2 mm,":",DEC2 ss,13,"Date:",DEC2 mo,"/",DEC2 dd,"/20",DEC2 yl]
                                        ^
                                         This string is the LCD COMMAND for the SERIAL interface that I use - it places the start of text at ROW 1, COLUMN 00
    
    



    You need to keep track of the length of the data string you will be sending to the LCD - the above example, the string length would be 27 characters - obviously 7 characters too long for a 20 character wide LCD.... you get the idea

    Post Edited (Paul Sr.) : 11/13/2006 6:11:59 PM GMT
  • globalglobal Posts: 6
    edited 2006-11-14 20:13
    do you know if I used the bs2pe if the baud rate would also be 84? I'm sure it is but now my program wont run with the bs2pe.·· The pins are the same as the bs2 so I figured i could just switch them out.· I realized this was a better fit since we need it for datalogging.· this is what I have


    ' {$STAMP BS2pe}
    ' {$PBASIC 2.5}
    'AN-151 BSII interface to Pocket Watch B
    'by Solutions Cubed
    '07/97
    'Set I/O pin directions
    INPUT 4 'communication FROM Pocket Watch B
    OUTPUT 5 'communication TO Pocket Watch B

    'Declare variables
    ss VAR Byte 'seconds
    mm VAR Byte 'minutes
    hh VAR Byte 'hours
    dd VAR Byte 'days
    mo VAR Byte 'months
    yl VAR Byte 'years low
    yh VAR Byte 'years high
    Begin:
    HIGH 5 'ensure no spurious start bit
    PAUSE 1000
    SEROUT 5,84,[noparse][[/noparse]22,12]············· 'clear screen
    SetTimeCommand:
    SEROUT 5,84,[noparse][[/noparse]$55,$00,$00,$00,$08,$d,$b,$06]
    ReadTimeCommand: 'see what time it is presently
    SEROUT 5,84,[noparse][[/noparse]$55,$12]
    SERIN 4,84, [noparse][[/noparse]ss,mm,hh,dd,mo,yl,yh]
    SEROUT 5,84,[noparse][[/noparse]22,12]············· 'clear screen
    SEROUT 12,84, [noparse][[/noparse]128,DEC2 hh,":",DEC2 mm, " ",136,DEC2 mo,"/",DEC2 dd,"/",DEC2 yl]
    SEROUT 12,84,[noparse][[/noparse]"1) Main Menu"]·················· 'displays main menu option
    PAUSE 1000
    GOTO ReadTimeCommand
  • ZootZoot Posts: 2,227
    edited 2006-11-14 21:39
    For baud rates, I would recommend using conditional compilation so that you have common Baud rates available as CONstants in your program which will be accurate for any Stamp.

    Moderator(s) -- what happened to Jon Williams' sticky that had the conditional compilation template with FREQOUT, Baud, etc constants for all the Stamps?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • Paul Sr.Paul Sr. Posts: 435
    edited 2006-11-14 22:01
    I believe this is what you are looking for.
Sign In or Register to comment.