pocketwatch code
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
' {$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
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 -->
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:
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
' {$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
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