The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

WP-34s clock program
Message #1 Posted by Andrew Nikitin on 6 June 2013, 11:01 p.m.

I wrote this program to display internal clock.

LBL'CLK'
LocR 001
CLx
TIME
x=?.00
BACK 003
STO.00
CL[alpha]
[alpha]TIME
VIEW[alpha]
PSE 09
BACK 009
Exit interrupts program and leaves time on stack.

I take extra effort to avoid unnecessary screen updates (update screen only when time changes) and also I use PSE 09 to reduce amount of busy wait. Does it make sense from the power use point of view? Does PSE command saves power compared to busy wait? Or it has no advantage over simple

LBL'CLK'
CLx
TIME
CL[alpha]
[alpha]TIME
VIEW[alpha]
GTO'CLK'

Edited: 6 June 2013, 11:02 p.m.

      
Re: WP-34s clock program
Message #2 Posted by anetzer on 8 June 2013, 12:36 p.m.,
in response to message #1 by Andrew Nikitin

Did I get something wrong?

I only had Time showing on the Display after changing the VIEW[alpha] to VW[alpha]+.X

Before that the Display only showed "TIME" in the upper line and three hyphens in the numeric section.

            
Re: WP-34s clock program
Message #3 Posted by Andrew Nikitin on 8 June 2013, 4:38 p.m.,
in response to message #2 by anetzer

Quote:
Display only showed "TIME"
Like in T, I, M, E? 4 characters? Here is what it looks like on my calc:

I do not show rX contents because it is the same time, just formatted as decimal fraction.

            
Re: WP-34s clock program
Message #4 Posted by Andrew Nikitin on 8 June 2013, 10:39 p.m.,
in response to message #2 by anetzer

Here is what my entire time program look like. I tried to implement some functionality of HP-01, which allowed for convenient timestamp arithmetic.

Instruction:
[c] start clock, exit clock to grab current time
XEQ EEX ;; load current time into X
XEQ + ;; add timecode to timecode
XEQ - ;; add timecode to timecode
XEQ * ;; multiply timecode in Y by number in X
XEQ / ;; divide timecode in Y by number in X
XEQ 00 ;; (internal routine) convert both X and Y from timecode to number

Nothing fancy, really.

LBL C
LBL'CLK'
LocR 001
CLx
TIME
x=?.00
BACK 003
STO.00
CL[alpha]
[alpha]TIME
VIEW[alpha]
PSE 09
BACK 009

LBL 00 [->]HR x<> Y [->]HR x<> Y RTN

LBL 34 ;; XEQ EEX = load current time TIME RTN

LBL 75 ;; XEQ + = add timecode to timecode XEQ 00 + [->]H.MS RTN

LBL 65 ;; XEQ - = add timecode to timecode XEQ 00 - [->]H.MS RTN

LBL 55 ;; XEQ * = multiply timecode in Y by number in X x<> Y [->]HR * [->]H.MS RTN

LBL 45 ;; XEQ * = divide timecode in Y by number in X x<> Y [->]HR

            
Re: WP-34s clock program
Message #5 Posted by Marcus von Cube, Germany on 9 June 2013, 4:12 a.m.,
in response to message #2 by anetzer

anetzer, you must have entered the word TIME in alpha mode. There is a command in the alpha catalog the formats the X register as a time value and puts the result the alpha register. Use this instead.

                  
Re: WP-34s clock program
Message #6 Posted by anetzer on 9 June 2013, 9:51 a.m.,
in response to message #5 by Marcus von Cube, Germany

You're so right. I took "[alpha]TIME" as instruction to input an alpha string.

The following seems to work and leave the stack in order:

001 LBL C
002 LocR 001
003 LBL 00
004 DROP
005 TIME
006 CL[alpha]
007 [alpha]TIME
008 VIEW[alpha]
009 PSE 09
010 GTO 00
011 END

And if we drop the power-hungry loop?

001 LBL C
002 TIME
003 CL[alpha]
004 [alpha]TIME
005 VIEW[alpha]
006 PSE 09
007DROP
008 GTO C
009 END

                        
Re: WP-34s clock program
Message #7 Posted by Walter B on 9 June 2013, 10:51 a.m.,
in response to message #6 by anetzer

I can see no difference in power consumption between your two programs here - you just drop two dispensable steps IMHO.

d:-)

      
Re: WP-34s clock program
Message #8 Posted by Marcus von Cube, Germany on 9 June 2013, 4:16 a.m.,
in response to message #1 by Andrew Nikitin

Andrew,

always avoid using busy waits on the WP34s (and similar machines). A tight loop runs at the full processor speed quickly draining the batteries (at a rate of about 30 to 40 mA). A PSE command, on the other hand, puts the processor in a low power sleep mode consuming only a few micro A.

            
Re: WP-34s clock program
Message #9 Posted by Andrew Nikitin on 9 June 2013, 11:20 p.m.,
in response to message #8 by Marcus von Cube, Germany

Marcus, thank you for explanation. I will use it as a guidance.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall