PDA

View Full Version : pocketwatch code



global
11-12-2006, 03:53 AM
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,[$55,$00,$32,$3b,$d,$d,$A,$06]

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

SERIN 4,240, [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

Bruce Bates
11-12-2006, 04:28 AM
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 -->

global
11-14-2006, 12:36 AM
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.
11-14-2006, 01:05 AM
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 [with the appropriate commands for the LCD you choose] and you should be all set.

For example:



SEROUT LCD_PIN, LCD_BAUD, PACE ["?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

global
11-15-2006, 03:13 AM
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,[22,12]············· 'clear screen
SetTimeCommand:
SEROUT 5,84,[$55,$00,$00,$00,$08,$d,$b,$06]
ReadTimeCommand: 'see what time it is presently
SEROUT 5,84,[$55,$12]
SERIN 4,84, [ss,mm,hh,dd,mo,yl,yh]
SEROUT 5,84,[22,12]············· 'clear screen
SEROUT 12,84, [128,DEC2 hh,":",DEC2 mm, " ",136,DEC2 mo,"/",DEC2 dd,"/",DEC2 yl]
SEROUT 12,84,["1) Main Menu"]·················· 'displays main menu option
PAUSE 1000
GOTO ReadTimeCommand

Zoot
11-15-2006, 04:39 AM
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.
11-15-2006, 05:01 AM
I believe this is what you are looking for.