Post Reply 
Complex Lock mode for WP-34s
03-16-2015, 08:03 PM (This post was last modified: 05-03-2015 09:39 PM by Nigel (UK).)
Post: #1
Complex Lock mode for WP-34s
This post presents a "complex lock" mode for the WP-34s. At the end of the post are links to a firmware patch file (taken relative to build 3769), a zip file of the windows emulator that runs this firmware, a calc.bin file containing the firmware, and some documentation of the features of this new mode.

Complex lock mode has been developed jointly by Jeff O (motivation, lots of user interface suggestions and bug-spotting) and myself (coding).

The WP-34s already has wonderful support for complex numbers. However, doing a long series of such calculations is not as easy as it could be. Real and imaginary parts have to be entered in reverse order, a zero imaginary part is needed even when a number is purely real, and CPX must be pressed before each operation. This complex lock mode doesn't try to add any totally new features, but rather tries to make it easier to use the powerful features that the WP-34s already has.

Turning on complex lock mode for the first time is a two-step process. On a calculator or an emulator running the new firmware, execute CPXYES from the Mode menu. Then pressing (right-arrow) + CPX enters the new mode. (The small "=" sign lights up to show that the mode has been entered.) Pressing (right-arrow) + CPX again returns to normal mode; executing CPXNO from the Mode menu prevents the mode being reactivated until CPXYES is executed once more.

The reason for the two-step process is to stop a user from entering the mode accidentally. If this isn't a concern, one can execute CPXYES and forget about doing it again, at least until the calculator is reset.

To do the calculation (40+12i)*(3+5i), press:
Code:

40 CPX 12 ENTER 3 CPX 5 *
Here's the screen as the first "4" is pressed ...

[Image: Capture1.PNG?dl=1]

and after CPX is pressed ...

[Image: Capture2.PNG?dl=1]

and just before ENTER is pressed ...

[Image: Capture3.PNG?dl=1]

and after ENTER is pressed ...

[Image: Capture4.PNG?dl=1].

CPX separates the real and imaginary parts of a number. To multiply the result of this calculation by 3, simply press
Code:

3 *
The imaginary part is automatically set to zero. To multiply by 4i, press
Code:

CPX 4 *
and the real part is automatically entered as zero.

Number entry can be terminated with CPX instead of ENTER. Pressing
Code:

40 CPX 12 CPX
puts 40+12i "on the stack", leaving stack lift set. So the first calculation can equally well be done as
Code:

40 CPX 12 CPX 3 CPX 5 *
The difference is that this second method of doing the calculation doesn't push anything off the top of the stack until entry of the second number begins.

When entering complex lock mode the stack is automatically set to 8 levels (the prior setting is saved, and restored later). The real and imaginary parts of complex numbers are stored in pairs of registers just as they would be normally, so that there is always a four-level stack for complex number calculations.

Most functions on the keyboard do their normal "complex" thing - so to find the square root of 4+2i, press
Code:

4 CPX 2 D
Memory operations have been restricted to even register numbers, so that trying to store a number in register 01 will give an error. This stops complex numbers in memory from overlapping and corrupting each other.

There is also a polar entry mode available in which complex numbers are entered and displayed as (modulus, argument) pairs. In this mode the real and imaginary parts of complex numbers are still stored in the stack so that all of the WP-34s functions continue to work correctly. See the attached Word document for details of this and other features. Here's a picture:
[Image: Capture5.PNG?dl=1]

Finally - and this is the icing on the cake for all you electrical engineers out there - there are two more commands in the Mode menu, CPXI and CPXJ. CPXJ displays complex numbers with a "j" instead of an "i". Great!
[Image: Capture6.PNG?dl=1]
What's not to like? Several things.
  • Memory. The firmware is now significantly bigger and so there is less flash memory available for program storage. The firmware including the crystal and the printer is currently too big to fit in the available space, although it may be possible to fix this.
  • Flags. When coding this I needed flags; lots of them. I have taken them from the user flags. To stop user programs changing these flags and accidentally entering complex lock mode this firmware prevents users from setting or resetting flags 80-99 from the keyboard or from a program, both in and out of complex lock mode. (This firmware actually only uses flags 92-99; I put 80 as the limit to see the extent of flag deprival that people would be willing to tolerate!)
  • Registers. In complex lock mode, registers J and K are used for various purposes. Their contents will be overwritten when using the mode, but they remain perfectly accessible otherwise.
  • Existing programs corrupted. Jeff O has found that when loading the new firmware the programs stored in his calculator sometimes change and need to be edited or re-entered. This is probably due to op-code changes, although I did try to avoid these. Be aware of this if your calculator contains precious programs that are not yet backed up.
  • Complex numbers. This is a complex lock mode. If you don't use complex numbers, this mode won't be at all helpful! (Obviously.)

Here are some comments on the code for anyone who wants to look at it:
  • Errors. Complex lock mode adds two new error messages. The latter part of the code in errors.h seems to double in size each time a new error message is added. I've re-written it so that this doesn't happen; I'm not claiming that my solution is elegant, but it does seem to work. The original code is still there as a comment.
  • Flags. The flag restriction code can be separated out and used independently of the rest if anyone else wants to write a firmware extension that makes use of user flags. I haven't done this because I am sure that other people can do it better. To find the flag code, look for LIMIT_FLAGS in the source code.
  • Improvements. These are clearly possible; I'm not a programmer and I don't have an understanding of the finer aspects of the WP-34s firmware. Feel free to suggest or to make them, especially anything that makes the compiled code smaller!
We'd like to hear what you think - what do you want from a complex mode? How can this one be improved? Is the whole approach fundamentally wrong? We both like it and we hope that some of you will, too, but we don't imagine that the current system is the final word.

Nigel (UK) and Jeff O

Edit: slightly updated version (12/04/15, or 04/12/15 for the US!).
  • Entry of numbers in polar display mode is now slightly faster.
  • Entering a constant from the constant menu accessed via h + ENTER completes the entry of the number currently being entered before adding the constant to the stack.
  • If the constant menu is accessed via f + ENTER then numeric entry is not completed before the constant is entered. This allows complex numbers to be built up with constants in the real and/or imaginary parts.
  • The unpopular "Mod:" and "Arg:" have been replaced by "Length:" and "Angle:".

Edit: another small update (13/04/15) incorporating a suggestion from Pauli for improving entry speed in polar display mode.

Edit: another small update (19/04/15) incorporating another polar display mode speed-up, some bug fixes, and firmware that no longer uses user flags.

Edit: code tidying and a fix for a bug that prevented the QT emulator from compiling.

The downloads below have been updated.


Attached File(s)
.docx  COM Operation.docx (Size: 19.57 KB / Downloads: 38)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Complex Lock mode for WP-34s - Nigel (UK) - 03-16-2015 08:03 PM
RE: Complex Lock mode for WP-34s - Jeff O. - 03-16-2015, 08:22 PM
RE: Complex Lock mode for WP-34s - Jeff O. - 03-17-2015, 11:48 AM
RE: Complex Lock mode for WP-34s - Jeff O. - 03-17-2015, 11:50 PM
RE: Complex Lock mode for WP-34s - Bit - 03-18-2015, 02:50 AM
RE: Complex Lock mode for WP-34s - Jeff O. - 03-19-2015, 05:41 PM
RE: Complex Lock mode for WP-34s - Bit - 03-23-2015, 12:40 AM
RE: Complex Lock mode for WP-34s - Jeff O. - 03-23-2015, 12:03 PM
RE: Complex Lock mode for WP-34s - emece67 - 03-23-2015, 05:12 PM
RE: Complex Lock mode for WP-34s - emece67 - 04-22-2015, 12:17 AM
RE: Complex Lock mode for WP-34s - emece67 - 04-22-2015, 10:44 AM
RE: Complex Lock mode for WP-34s - Jeff O. - 04-24-2015, 05:44 PM
RE: Complex Lock mode for WP-34s - Jeff O. - 04-29-2015, 12:18 PM
RE: Complex Lock mode for WP-34s - Jeff O. - 04-13-2015, 01:55 PM
RE: Complex Lock mode for WP-34s - Jeff O. - 04-14-2015, 11:42 AM
RE: Complex Lock mode for WP-34s - emece67 - 04-29-2015, 02:02 PM
RE: Complex Lock mode for WP-34s - emece67 - 05-05-2015, 06:21 PM
RE: Complex Lock mode for WP-34s - emece67 - 05-06-2015, 07:13 AM
RE: Complex Lock mode for WP-34s - Jeff O. - 02-23-2019, 01:26 AM



User(s) browsing this thread: 1 Guest(s)