Post Reply 
[34S] Ticks
03-24-2014, 03:57 PM (This post was last modified: 03-24-2014 04:01 PM by Tugdual.)
Post: #1
[34S] Ticks
Quick question, how do you achieve a 0.1s timer with 32768Hz cristal?
You cannot divide by 3276,8?

My next question would be: can we change the timer resolution? I guess not otherwise I'm sure the stopwatch would be more accurate and I this would probably drain more energy from the batteries.
Find all posts by this user
Quote this message in a reply
03-24-2014, 04:28 PM (This post was last modified: 03-24-2014 06:54 PM by Monte Dalrymple.)
Post: #2
RE: [34S] Ticks
(03-24-2014 03:57 PM)Tugdual Wrote:  Quick question, how do you achieve a 0.1s timer with 32768Hz cristal?
You cannot divide by 3276,8?

Take a look at the way it's done in the 41C Time Module. It multiplies by 175/1024 to get to 5600Hz and then divides by 56 to get 100Hz.
Visit this user's website Find all posts by this user
Quote this message in a reply
03-24-2014, 07:34 PM
Post: #3
RE: [34S] Ticks
(03-24-2014 03:57 PM)Tugdual Wrote:  Quick question, how do you achieve a 0.1s timer with 32768Hz cristal?
You cannot divide by 3276,8?

My next question would be: can we change the timer resolution? I guess not otherwise I'm sure the stopwatch would be more accurate and I this would probably drain more energy from the batteries.

Monte has given one possible explanation for the mystery.

Here is what I did in the 34S:

The Atmel chip has several oscillators, one of which is the 32KHz clock. The quartz crystal is just an option to increase its accuracy. The processor frequency is created by multiplying the 32KHz clock with help of a PLL which can be configured. In fact, most of the power saving is done by reprogramming the PLL to adapt the speed to the present needs. A running program obviously needs a higher processor speed than manual digit entry.

The ticks pose a problem here: you cannot count on regular timer interrupts if you change the input frequency randomly. That's why I use the LCD driver circuit (which is part of the Atmel chip) to create the tick interrupt. It's driven by the 32kHz oscillator. The interrupt is called every 640 cycles which results in roughly 51 interrupts per second. When a crystal is installed, an elaborate count down scheme is used to reach the 100ms interval:

Code:

        /*
         *  Count down to next 100ms user heart beat
         */
        if ( --UserHeartbeatCountDown == 0 ) {
                /*
                 *  Service the 100ms user heart beat
                 */
                user_heartbeat();

                if ( Xtal ) {
                        /*
                         *  Schedule the next one so that there are 50 calls in 5 seconds
                         *  We need to skip 3 ticks in 128 cycles
                         */
                        if ( Heartbeats ==  40 || Heartbeats ==  81 || Heartbeats == 122 ) {
                                UserHeartbeatCountDown = 6;
                        }
                        else {
                                UserHeartbeatCountDown = 5;
                        }
                }
                else {
                        /*
                         *  Without a crystal a less accurate timing is good enough
                         */
                        UserHeartbeatCountDown = Heartbeats & 1 ? 4 : 5;
                }
        }

Feel free to submit any optimizations. Wink

One reason for an inaccurate clock is the quartz oscillator. I've fitted some stock capacitors without thorough research if they are really suited for the crystal installed. If you have an oscilloscope you may verify it for yourself (I do have an oscilloscope but I didn't try to measure the frequency.)

Marcus von Cube
Wehrheim, Germany
http://www.mvcsys.de
http://wp34s.sf.net
http://mvcsys.de/doc/basic-compare.html
Find all posts by this user
Quote this message in a reply
03-24-2014, 10:09 PM
Post: #4
RE: [34S] Ticks
Hi Marcus, thanks for the detailed explanation and I do believe that your code is way good enough. When I said "'more accurate" clock, I really meant with more resolution, like 1ms instead of 0.1s. I am using the TICKS to measure time taken by various programs and usually computers would return a time information in ms. Not a big deal, the 34s is really good as it is :-).

Monte, thanks for the information about the fractional approach, I'm not very familiar with all those techniques but now I understand the principle.
Find all posts by this user
Quote this message in a reply
05-17-2014, 11:15 AM (This post was last modified: 05-17-2014 11:22 AM by jebem.)
Post: #5
RE: [34S] Ticks
Hi everybody,
Sorry to join this thread so late but I've got my WP-34S very recently.

First, two small remarks on the Owner's Guide:
1) I was checking the most recent "WP-34S Owner's Guide" at the SF repository, and can see that the "Edition 3.1" is the only one available for download - that's the "Manual_wp_34s_3_1.pdf".
I wonder if this is the most up to date version available as a download?
By the way, Walter is proposing a v3.3 in paper format (I've ordered one copy for myself).

2) Concerning the commands usage section, I see the Owner's Guide as a Reference Guide, more oriented to expert advanced users.
However I see an opportunity here to expose the WP-34S to a more broad population if examples of the commands were included as well, like HP and others are doing. This could be an offer in paper format only, to protect the creator's work.

Now, for the TICKS command:
1) Thanks Marcus for your explanation on the HP-20/30B timer interrupts used to generate a precise time tick.

2) As for the TICK command itself, it is very useful for benchmarking code execution as Tugdual has mentioned.

3) I see that the register used for TICKS is reset to Zero when the calculator is powered on, then it is incrementing forever (of course not...) as long as the calculator is powered on. Because the timeout inactivity will kick in in a few minutes and shutdown the calculator, the accumulated value is never to high anyway.

4) Is there a specific reason to have this 100mS time tick other than to support the PSE and printer.DLAY commands?
For sure the TIME and DATE functions are not dependent on this high level TICK value, right?

5) By the way, I have installed the 32768 KHz XTAL in my 34S (HP-30B based), and can only tell that the time is really accurate after 2 weeks of usage (I can't find any skew when comparing to my laptop time).

Jose Mesquita
RadioMuseum.org member

Find all posts by this user
Quote this message in a reply
05-17-2014, 11:42 AM
Post: #6
RE: [34S] Ticks
(05-17-2014 11:15 AM)jebem Wrote:  4) Is there a specific reason to have this 100mS time tick other than to support the PSE and printer.DLAY commands?

Ticks are used internally for some of the various timeouts. e.g. the time until a keypress shows the command and again when it goes nul. It is used in a few other places from memory.


- Pauli
Find all posts by this user
Quote this message in a reply
05-17-2014, 12:18 PM
Post: #7
RE: [34S] Ticks
(05-17-2014 11:15 AM)jebem Wrote:  First, two small remarks on the Owner's Guide:
1) I was checking the most recent "WP-34S Owner's Guide" at the SF repository, and can see that the "Edition 3.1" is the only one available for download - that's the "Manual_wp_34s_3_1.pdf".
I wonder if this is the most up to date version available as a download?
By the way, Walter is proposing a v3.3 in paper format (I've ordered one copy for myself).

Yes (3x). Smile

Quote:2) Concerning the commands usage section, I see the Owner's Guide as a Reference Guide, more oriented to expert advanced users.
However I see an opportunity here to expose the WP-34S to a more broad population if examples of the commands were included as well, like HP and others are doing. This could be an offer in paper format only, to protect the creator's work.

Thanks for thinking of copyright. One person at least. And yes, the manual assumes you know the traditional functions and also some mathematics (it's even stated therein). We had the Beginner's Guide but that wasn't updated anymore by its author AFAIK.

Quote:Now, for the TICKS command:
...
3) I see that the register used for TICKS is reset to Zero when the calculator is powered on, then it is incrementing forever (of course not...) as long as the calculator is powered on. Because the timeout inactivity will kick in in a few minutes ...

This isn't true anymore. With STOPW open, ticks will be incremented up to 2^16 to trigger timeout. And with the stopwatch timer running, TICKS may overflow more than once.

d:-)
Find all posts by this user
Quote this message in a reply
05-17-2014, 10:47 PM (This post was last modified: 05-17-2014 10:52 PM by jebem.)
Post: #8
RE: [34S] Ticks
(05-17-2014 12:18 PM)walter b Wrote:  
(05-17-2014 11:15 AM)jebem Wrote:  (...) Remarks on the Owner's Guide:
(...) Concerning the commands usage section, I see the Owner's Guide as a Reference Guide, more oriented to expert advanced users.
However I see an opportunity here to expose the WP-34S to a more broad population if examples of the commands were included as well, like HP and others are doing. This could be an offer in paper format only, to protect the creator's work.

Thanks for thinking of copyright. One person at least. And yes, the manual assumes you know the traditional functions and also some mathematics (it's even stated therein). We had the Beginner's Guide but that wasn't updated anymore by its author AFAIK.

Hi Walter,
Thanks for your time to reply.

Don't get me wrong, I see the Owner's Guide as a very good work. Surely it took long time to elaborate and validate. Thanks for that.

I spent more than a few hours reading all the contents and checking some of the features in the calculator. By the way, I use HP calculators since they came out, so RPN is not exactly new to me.
So let me be more specific in my remarks:

1) The WP-34S Owner's Guide covers the very basics on RPN and on the WP-34S calculator in great detail (so I do not miss the Beginners guide, really), giving a lot of good examples in the beginning of the book, and covering the basic commands and functions.

2) Then it takes deep explanation on some math features implementation, before going to the reference guide (Index of Operations), where we can also find a couple of good examples.
However the majority of the functions just have the general syntax and arguments, and referring to the HP-15C or to the HP-42S documentation for more details.

3) Then it goes into great detail on memory and registers architecture.
And then the Appendixes covers pretty much all the ins and outs on how to take a HP-20/30B to create and maintain a WP-34S.
I enjoy this section as I work with computers with electronics engineering and digital systems as my background.

4) As I see it - what am I missing in this book?
There are some fundamental math features that do not have concrete examples (like the ones in the beginning of the book) to get the users started on this calculator environment. So there is space for improvement here.

For instance, it was nice to have explicit simple examples explaining how to:
4.1) Create a matrix;
4.2) Take a couple of matrices and use them to solve simultaneous equations;
I know how to do it on a HP-42S, quite easy in fact, but I didn't find the time to decrypt the information supplied in this guide and develop/test how to do it in the WP-34S;
4.3) Use Complex numbers, if possible with matrices;
4.4) Use Differentiation;
4.5) Use Integration;
4.6) Use Derivatives;
4.7) Use the Solver (SLV);

Again, I'm not complaining, just pointing out what I see is missing in the book.
After all this is a free open project that was created by a small group of dedicated people to whom we should be grateful!

And from my part, I say again:
Thank You for the opportunity You are giving to other people to enjoy this great project for free! Smile

Jose Mesquita
RadioMuseum.org member

Find all posts by this user
Quote this message in a reply
05-18-2014, 10:24 AM
Post: #9
RE: [34S] Ticks
Bom dia, Jose,

muito obrigado for sharing your thoughts. BTW, posting at a typical Portuguese time when other people are sleeping deeply already Wink

(05-17-2014 10:47 PM)jebem Wrote:  4) As I see it - what am I missing in this book?
There are some fundamental math features that do not have concrete examples (like the ones in the beginning of the book) to get the users started on this calculator environment. So there is space for improvement here.

For instance, it was nice to have explicit simple examples explaining how to:
4.1) Create a matrix;
4.2) Take a couple of matrices and use them to solve simultaneous equations;
I know how to do it on a HP-42S, quite easy in fact, but I didn't find the time to decrypt the information supplied in this guide and develop/test how to do it in the WP-34S;
4.3) Use Complex numbers, if possible with matrices;
4.4) Use Differentiation;
4.5) Use Integration;
4.6) Use Derivatives;
4.7) Use the Solver (SLV);

Again, I'm not complaining, just pointing out what I see is missing in the book.
After all this is a free open project that was created by a small group of dedicated people to whom we should be grateful!

And from my part, I say again:
Thank You for the opportunity You are giving to other people to enjoy this great project for free! Smile

OK, let me start at the very end: Other than in Portuguese and German, you don't capitalize "you" in English unless you talk to gods. So it's not necessary here Wink
Beyond that, you are welcome. Smile

Seriously, about the manual:

It took me many (!!) hours to write it, including endless correction loops as the project developed. And more than once I reached the point where I was thinking "enough is enough". Writing and rewriting 244 pages just for nothing - without the slightest idea of any revenue - can be regarded as more than just a bit crazy even by very close people. So I avoided copying stuff I found in earlier manuals covered sufficiently IMHO to reduce my workload and since I assess that being just boring and adding no value. I entered pointers to those manuals instead.

Well, our friends from the USA repeatedly complained about that short form (although I declared it being a reference only), so I felt pressed to add some elementary RPN chapters for them. And the chapters and appendices about flashing, hardware, and advanced functions came as I had to write them down for me anyway to be able to operate my own WP 34S.

You should be able to follow the development of the manual at SourceForce quite well if you want to.

About your points in detail:

4.1 & 4.2: Matrices are the weak point of the WP 34S. We felt we had to include them for sake of completeness (the HP-42S featured them) but we could not support them on the same level as the HP-42S due to that ... #§&! ... display of the 20b/30b and lack of memory. Beyond testing the implementation, I didn't use matrices on the WP 34S. It shall be far nicer on the 43S ...

4.3: I thought I've explained complex numbers and calculations on pp. 36ff. What do you miss?

4.5 & 4.7: Those were points I felt explained elsewhere sufficiently. It's all in the manual of the HP-34C or HP-15C. No sense in copying & pasting IMHO.

4.4 & 4.6 (why two points for that?): I admit I didn't see a pressing need for f' and f" on our calculator. Frankly, I don't see any "killer application" justifying those two functions and I was too lazy to look for one.

Hope that explains a bit. There will be more about those topics in the manual of the 43S.

d:-)
Find all posts by this user
Quote this message in a reply
05-18-2014, 01:09 PM (This post was last modified: 05-18-2014 01:12 PM by jebem.)
Post: #10
RE: [34S] Ticks
(05-18-2014 10:24 AM)walter b Wrote:  OK, let me start at the very end: Other than in Portuguese and German, you don't capitalize "you" in English unless you talk to gods. So it's not necessary here Wink
Beyond that, you are welcome. Smile
Well, I though that by worshiping a little I could get free examples how on to do this math staff in this great WP-34S calculator Smile

Yesterday I couldn't sleep so I did some browsing around the net learning a bit more on on to use the HP-42S (I have just the emulator) to see if I can take advantage of my new WP-34S. So it was past midnight when I gave up and decided to write my previous post.

(05-18-2014 10:24 AM)walter b Wrote:  Seriously, about the manual:
(...) It took me many (!!) hours to write it, including endless correction loops as the project developed. And more than once I reached the point where I was thinking "enough is enough". Writing and rewriting 244 pages just for nothing - without the slightest idea of any revenue - can be regarded as more than just a bit crazy even by very close people. So I avoided copying stuff I found in earlier manuals covered sufficiently IMHO to reduce my workload and since I assess that being just boring and adding no value. I entered pointers to those manuals instead.

Well, our friends from the USA repeatedly complained about that short form (although I declared it being a reference only), so I felt pressed to add some elementary RPN chapters for them. And the chapters and appendices about flashing, hardware, and advanced functions came as I had to write them down for me anyway to be able to operate my own WP 34S.

(..) There will be more about those topics in the manual of the 43S.
Thank you so much Walter, for your dedication to this cause and to take time to reply here.
I understand perfectly your point and fully agree.
That's why I defend that the service should be paid, specially on open free projects like these. For that reason, I made a modest donation (I know, it was tiny, but I did just one calculator Smile ) and I'm willing to pay for the printed version for the WP-34S Owners Guide V3.3 or above.

And I can't wait for the next big thing: the WP-43S project!
(Although I have a slight WAF problem to deal with... even this morning my wife keep asking me "why do you need so many calculators? Are you planning to do big calculations on what???. She is a nurse, you see... extremely intelligent and practical - I guess more than me - so, sometimes she looks to me like I'm a little bit on the wild/nuts side... Smile )

Jose Mesquita
RadioMuseum.org member

Find all posts by this user
Quote this message in a reply
05-18-2014, 05:26 PM
Post: #11
RE: [34S] Ticks
(05-17-2014 10:47 PM)jebem Wrote:  For instance, it was nice to have explicit simple examples explaining how to:
4.3) Use Complex numbers, if possible with matrices;

cf. [WP-34S] Calculations With Complex Matrices

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
05-18-2014, 08:37 PM
Post: #12
RE: [34S] Ticks
(05-18-2014 05:26 PM)Thomas Klemm Wrote:  
(05-17-2014 10:47 PM)jebem Wrote:  For instance, it was nice to have explicit simple examples explaining how to:
4.3) Use Complex numbers, if possible with matrices;

cf. [WP-34S] Calculations With Complex Matrices

Cheers
Thomas

Thank you so much, Thomas! Very useful information!
I guess that I need to dig deeper in the archives...

Jose Mesquita
RadioMuseum.org member

Find all posts by this user
Quote this message in a reply
05-20-2014, 11:45 AM
Post: #13
RE: [34S] Ticks
Meanwhile I've posted two programs MPZ and MZP to convert between the \(Z^P\) and the \(\tilde{Z}\) representation of an m×n complex matrix: The Complex Transformations Between \(Z^P\) and \(\tilde{Z}\)
This should make calculations with complex matrices easier.

Kind regards
Thomas
Find all posts by this user
Quote this message in a reply
05-21-2014, 11:47 AM
Post: #14
RE: [34S] Ticks
Though it consists only of a transposition I've added two programs MPC and MCP to convert between the \(Z^P\) and the \(Z^C\) representation of an m×n complex matrix.

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
05-22-2014, 05:58 PM
Post: #15
RE: [34S] Ticks
(05-17-2014 10:47 PM)jebem Wrote:  For instance, it was nice to have explicit simple examples explaining how to:
4.1) Create a matrix;

Have a look at library program 'MED', the Matrix EDitor.

Marcus von Cube
Wehrheim, Germany
http://www.mvcsys.de
http://wp34s.sf.net
http://mvcsys.de/doc/basic-compare.html
Find all posts by this user
Quote this message in a reply
05-22-2014, 07:19 PM
Post: #16
RE: [34S] Ticks
(05-22-2014 05:58 PM)Marcus von Cube Wrote:  
(05-17-2014 10:47 PM)jebem Wrote:  For instance, it was nice to have explicit simple examples explaining how to:
4.1) Create a matrix;

Have a look at library program 'MED', the Matrix EDitor.

Thank you so much for that information, Marcus.
I will have to spend (much) more time reading and testing all these features in this excellent calculator.
The problem here is that my professional work consumes most of my time, and I end up by not being able to do deeper investigation on the other subjects like this one.

Jose Mesquita
RadioMuseum.org member

Find all posts by this user
Quote this message in a reply
05-22-2014, 11:01 PM
Post: #17
RE: [34S] Ticks
The library routines aren't overly well tested. Caveat emptor.


- Pauli
Find all posts by this user
Quote this message in a reply
05-23-2014, 04:51 AM
Post: #18
RE: [34S] Ticks
I'd emphasize what Pauli wrote in another fathom of this thread: the library routines are hardly tested at all unless the respective author did. This applies for their documentation as well.

d:-/
Find all posts by this user
Quote this message in a reply
05-24-2014, 07:56 PM
Post: #19
RE: [34S] Ticks
MED is my work. If you find any issues, you can blame me.

Marcus von Cube
Wehrheim, Germany
http://www.mvcsys.de
http://wp34s.sf.net
http://mvcsys.de/doc/basic-compare.html
Find all posts by this user
Quote this message in a reply
05-29-2014, 09:43 PM
Post: #20
RE: [34S] Ticks
(03-24-2014 07:34 PM)Marcus von Cube Wrote:  One reason for an inaccurate clock is the quartz oscillator. I've fitted some stock capacitors without thorough research if they are really suited for the crystal installed. If you have an oscilloscope you may verify it for yourself (I do have an oscilloscope but I didn't try to measure the frequency.)

See Jim Williams on crystal oscillators

Jorge.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: