The Museum of HP Calculators

HP Forum Archive 20

[ Return to Index | Top of Index ]

Stopwatch function implemented on WP34s
Message #1 Posted by pascal_meheut on 28 Oct 2011, 2:36 a.m.

Hi,

Just for fun, I've implemented a Stopwatch function like the one on the HP-55 and the HP-41C TimeModule.

Of course, it would need a quartz to be precise but I'll see later if I can implement a calibration function.

It is a simple addon to the last firmware version and if someone is interested, I can give the calc.bin and/or the source code.

How it works:

- there is now a TIMER function in the P.FCNS menu, under TIME - Pressing F then H then EXIT quickly enters the TIMER mode too - once in TIMER mode, R/S starts & stops the stopwatch - EEX toggles the 10th secs display - ENTER stores the current value in memory. 0 to start and the increments - arrows increment/decrement the memory used - one can also enter the memory number directly - the memory used is displayed in the exponent zone and -> toggles it

I plan on implementing a delta mode later, like the TimeModule one but maybe simpler.

Here is what it looks like:

Cheers

      
Re: Stopwatch function implemented on WP34s
Message #2 Posted by Marcus von Cube, Germany on 28 Oct 2011, 3:42 a.m.,
in response to message #1 by pascal_meheut

Congrats, new master of convoluted C code! It took me a while before I was able to implement anything in WP 34S.

We'd like to see your sources and would also like to know the memory footprint of your additions. Maybe we can add you to the list of developers on SF. :-)

            
Re: Stopwatch function implemented on WP34s
Message #3 Posted by pascal_meheut on 28 Oct 2011, 5:14 a.m.,
in response to message #2 by Marcus von Cube, Germany

No luck sending you an email so I did it through silicium.

                  
Re: Stopwatch function implemented on WP34s
Message #4 Posted by pascal_meheut on 28 Oct 2011, 5:32 a.m.,
in response to message #3 by pascal_meheut

And received your email. Cannot respond still.

            
Re: Stopwatch function implemented on WP34s
Message #5 Posted by Andrés C. Rodríguez (Argentina) on 28 Oct 2011, 10:27 a.m.,
in response to message #2 by Marcus von Cube, Germany

Very nice, the TIMER function is very convenient indeed! Just a question: Given the current (pun intended) worries about CR 2032 batteries being not the best ones to cope with extended activity on these calculators, how feasible is to have the timer running for significant periods of time? Are you deliberately choosing a super-slow CPU clock mode to run the timer?

TIA

                  
Re: Stopwatch function implemented on WP34s
Message #6 Posted by pascal_meheut on 28 Oct 2011, 10:54 a.m.,
in response to message #5 by Andrés C. Rodríguez (Argentina)

This is a first implementation and I've not measured battery drain yet. I plan to do so. Right now, running the TIMER should be the same as running a program but I guess I can try to slow down the CPU clock.

Edited: 28 Oct 2011, 10:55 a.m.

                        
Re: Stopwatch function implemented on WP34s
Message #7 Posted by Marcus von Cube, Germany on 28 Oct 2011, 11:26 a.m.,
in response to message #6 by pascal_meheut

Pascal, you can wire the timer to the heartbeat interrupt. This will run at 2MHz and idle again after return. Just look into keys.c and search for K_HEARTBEAT. You will need a global variable which selects timer mode and disables all other functionality.

                              
Re: Stopwatch function implemented on WP34s
Message #8 Posted by pascal_meheut on 28 Oct 2011, 12:10 p.m.,
in response to message #7 by Marcus von Cube, Germany

This is exactly what I've done. In the main loop, there is a global variable containing a function pointer. If it is not null, it is called on every key pressed including HEARTBEAT instead of the normal processing.

The TIMER function simply sets this variable and exiting it resets its to NULL. This mechanism could be used for any other interactive function which needs full control of the keyboard if we had more space :-(

                                    
Re: Stopwatch function implemented on WP34s
Message #9 Posted by Marcus von Cube, Germany on 28 Oct 2011, 12:27 p.m.,
in response to message #8 by pascal_meheut

Well done! :-)

                  
Re: Stopwatch function implemented on WP34s
Message #10 Posted by pascal_meheut on 28 Oct 2011, 5:13 p.m.,
in response to message #5 by Andrés C. Rodríguez (Argentina)

BTW, I ran it for 2 hours straight on brand new batteries and the voltage went from 3.0V to 2.9V. The WP34s slows down at 2.5V and shutdowns at 2.2V. So timer's power consumption is not that bad.

            
Re: Stopwatch function implemented on WP34s
Message #11 Posted by Dominic Richens on 28 Oct 2011, 9:46 p.m.,
in response to message #2 by Marcus von Cube, Germany

I'd like to see your code as well (or diffs).

Too bad the hp20b/30b doesn't have a tone generator, I'd like to have a count down timer.

I wonder what the simplest circuit is to use one of the GPIO pins?

                  
Re: Stopwatch function implemented on WP34s
Message #12 Posted by pascal_meheut on 30 Oct 2011, 2:54 a.m.,
in response to message #11 by Dominic Richens

Code is in SVN.

      
Re: Stopwatch function implemented on WP34s
Message #13 Posted by robertoataulfo on 28 Oct 2011, 12:43 p.m.,
in response to message #1 by pascal_meheut

We can not take some factors of conversion?
I believe it is very easy to save some factor in a memory (STO) of him to leave the system fixed.
We could gain a few bytes for further improvements.
            
Re: Stopwatch function implemented on WP34s
Message #14 Posted by pascal_meheut on 28 Oct 2011, 3:31 p.m.,
in response to message #13 by robertoataulfo

Initialized constants are 272 bytes whilst executable code is 122 Kb according to the linker. So this not where room can be found I guess.

                  
Re: Stopwatch function implemented on WP34s
Message #15 Posted by robertoataulfo on 28 Oct 2011, 3:33 p.m.,
in response to message #14 by pascal_meheut

But these 272 bytes could not be used for something more important?
I think that any user can use some memories (STO and RCL) to save your constants.

Edited: 28 Oct 2011, 3:36 p.m.

                        
Re: Stopwatch function implemented on WP34s
Message #16 Posted by Marcus von Cube, Germany on 28 Oct 2011, 5:24 p.m.,
in response to message #15 by robertoataulfo

But then you need to know them. We have a few areas where we might save code such as the integer code which deserves a rewrite in ARM assembly.

                        
Re: Stopwatch function implemented on WP34s
Message #17 Posted by Walter B on 29 Oct 2011, 4:30 a.m.,
in response to message #15 by robertoataulfo

Using general purpose registers for constants would cost more *and* have the disadvantage of not knowing the names. We won't do that.

Walter

                  
Re: Stopwatch function implemented on WP34s
Message #18 Posted by Paul Dale on 28 Oct 2011, 9:58 p.m.,
in response to message #14 by pascal_meheut

I suspect the conversion constants aren't in the initialised data segment. They definitely take more than 272 bytes.

They are still incredibly compact as commands go. I'd guess eight to ten conversions or constants occupy the same space as the most trivial of commands (think the single bit setting mode commands) and this is including the catalogue overheads.

- Pauli

                        
Re: Stopwatch function implemented on WP34s
Message #19 Posted by Marcus von Cube, Germany on 29 Oct 2011, 6:37 a.m.,
in response to message #18 by Paul Dale

Quote:
I suspect the conversion constants aren't in the initialised data segment.
There is no such thing as an initialized data segment, just ROM data. All data in RAM is just zero. I got rid of the 'copy ROM to RAM' sequence all together.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall