From: jhmeyers@miu.edu (John H Meyers)
Subject: A User RPL stopwatch, yes! - was: stopwatch?
Date: 18 Jul 1996 00:00:00 GMT
Message-ID: <4slu0i$4n0@news.iastate.edu>
references: <31EC111E.41C67EA6@wombat.com>
organization: MIU Computer Services,  Fairfield, IA 52557.  Not Approved.
reply-to: jhmeyers@miu.edu
newsgroups: comp.sys.hp48


In article <31EC111E.41C67EA6@wombat.com>,
David A. Kuder <david@wombat.com> writes:

> Years ago I used an HP calculator with a stopwatch capability to measure
> experiments.  Now I'd like to do the same sort of thing, but I can't tell
> if the HP48 can do stopwatch style timing.  I can tell that it has a time
> of day clock, but I couldn't tell if it went below seconds in resolution
> or if I could capture the time and do arithmetic on it.

Was that the HP55?

Anyway, the quick answer is that there is a ready-made "stopwatch library"
for the HP48 (written by HP) which times things to 1/100 second, stores
as many "splits" as you want to allocate memory for, reviews, prints,
and can even be called from other programs.

One source is <ftp://hpcvbbs.cv.external.hp.com>
      in file "/dist/hp48g/goodies_disks/horn9.zip" (get horn8.zip also).
      The same library may also be posted in other locations,
      but with the "Goodies Disks" you also get more goodies!

GD#9 seems to be the latest version, but the instructions are in GD#8;
the library is about 2800 bytes, plus it will allocate a list variable
in your current directory for storing 25 (default) "splits".

However, in case you don't feel fulfilled by just using a canned library,
or don't have room for it, or don't have a cable to download it, and you
therefore feel the need to do your own programming, here are some
important considerations (some in manuals or FAQ, some not):

The HP48 can give you the time to the nearest 1/8192 second (well, sort of,
since it takes longer than that to do most any user instruction), either as
hh.mmss... or as binary "clock ticks" (G/GX User's Guide pp 16-3,4), so if
your HP48 is doing experiments all by itself, it can time them as well.

Time arithmetic is available via functions HMS+ , HMS- , and ordinary
addition/subtraction of binary TICKS values, or after HMS-> conversion.

If you want a "real stopwatch" with buttons to press, however, you'll run
into a snag, because while any key is down, the HP48 gets so distracted
that it hardly has any time to devote to your program (demonstration:
put the number 8 on the stack, press square root repeatedly,
alternating between quick taps vs. holding it down; notice the difference);
it is therefore difficult to precisely determine when you pressed any key.

There is also the matter of HP48 "garbage collection," which stalls the HP48
every time it runs out of temporary memory, as it keeps using new memory for
every new or changed object produced by any "user" or internal operation.

You need SysRPL functions to take over the keyboard and avoid these problems.
The STPWATCH library does this for you, so that it makes no difference how
quickly or slowly you press START/STOP.

However, if you want to time telephone conversations or VCR playback times,
you may not care about 1/100 second accuracy.  In that case, you might care
to experiment with a crude "user RPL stopwatch" such as the ghastly version
below; if you press the keys with a consistent "stroke," the time will turn
out to be pretty accurate, even though not for scientific research on SR/GR.

%%HP: T(3); @ for Kermit, uses ascii translation mode 3
@ HP48 [any model] crude Stopwatch/Timer
\<< { { Mark    \<< TIME 7 RND 'Time' \->TAG MEM DROP \>> } { }
      { @Delta@ \GDSec  \<< DUP2 SWAP HMS- HMS\-> 3600 * 3 RND
               '\GDSec' \->TAG SWAP MEM DROP \>> } { } { }
      { GC \<< MEM DROP \>> }
    } TMENU MEM DROP \>> @ 186 bytes (no name), #6118h checksum

Instructions:

  The "Mark" key places the current time on the stack; use as desired,
  at any point whose time you wish to record.

  The "Delta Seconds" key calculates the time difference between the
  time on level-2 and the time on level-1 (presumably the last 2 marks);
  use this whenever you want to know the elapsed time between two marks.
  Note that the result is placed *between* the stack levels containing
  the marks, leaving the most recent mark still on level-1.

  You are now ready to record another mark, compute the next delta,
  and so on indefinitely.  The history of marked times and intervals
  remains collected on the stack until you clear it.

  E.g.  [level-N] ... Time <-delta-> Time <-delta-> Time   [level-1]

  You need not perform a Delta between every pair of marks;
  compute only those intervals in which you are interested.

  If you want a Delta between two times which are not on the bottom
  two stack levels, first copy or move the times to those levels;
  e.g. to get the total elapsed time for a series of "laps" whose
  ending mark is on the bottom of the stack, you can copy [PICK]
  the earliest mark to level-1 and press "Delta" (the minus sign
  in the result helps you recognize this as the grand total!).

  The "GC" key forces an extra "garbage collection"; you need it only
  after you have been doing some other operations which may have used
  memory, because both the setup of the custom menu and the execution
  of each menu function force a garbage collection automatically,
  in preparation for the next event.

  Intervals which span across midnight will seem to "lose" 86400 seconds.

Now that all this has been said and done, wouldn't you rather just use
the stopwatch function of a Casio wristwatch?  Now, there's one thing
that Casio does pretty well, except of course that HP made the ultimate
time-computing and calculating watch long ago -- the last of the late
but great LED watches ever produced!  How about reviving it, with about
16MB RAM, IR, and radio links to satellites ... just call it a "wrist-top".

-----------------------------------------------------------
With best wishes from:  John H Meyers  ( jhmeyers@mum.edu )
