Sunday, April 7, 2024

Swiss Micros SM32: Simulating a Choose Menu

Swiss Micros SM32: Simulating a Choose Menu


The following technique should work for the HP 33S and HP 35S, but most likely HP 32S/32SII due to the lack of memory (you could shorten or eliminate the messages, I suppose.).


What Is Needed


  • We will need at least two labels.
  • The user flags as needed. For the DM32, the user flags are from Flag 0 to Flag 4. This allows for up to five choices.
  • A choice variable. This variable holds the user’s choice from the menu. The algorithm presumes that the user will always enter a valid choice.
  • Clever calculation, as we start with the reference value in the X stack.
  • Flag 10, which allows us to display the choices and messages.



General Algorithm Format


LBL 1 (run the algorithm here)

CF 0 through CF 4 (as needed)

SF 10 ( [ |→ ] {FLAGS} {SF} [ . ] 0 )

“introduction message” (if desired)

PSE (follow each string with a pause)



LBL 2 (menu and main calculation)

“#a (description)”

PSE

“#b (description)”

PSE

INPUT CV (choice variable)


RCL CV

#a

x=y?

Value_a


RCL CV

#b

x=y?

INPUT α


STO α (store a reference value for future use)


(calculation)


CF 0, CF 1, CF 2, CF 3, CF 4 (clear all flags used)

CF 10

“RESULT =“ (if desired)

PSE (if desired)

VIEW (variable with result)

GTO (Lbl 1) or RTN


Notes: 

  • #a, #b, … corresponding flags, 0 – 4.
  • CV: choice variables (i.e. C, H, etc.)
  • α: reference value used
  • Choice #b demonstrates how we can allow the user to input their own value.


Entering Strings


Setting Flag 10 turns equation evaluation off. Now each typed “equation” now acts as a string. Enter strings by:


1. Pressing the right shift key [ |→ ], or the blue shift key on the DM32, then [ ST0 ] { EQN }.

2. Letters are entered by pressing [ RCL ] { letter }. Numbers can be entered as well. The equals key is entered by pressing [ |→ ]/[ blue shift ] [ ← ] { = }. The screen is 12 characters long before it scrolls. Note: We do not have the period or the question mark as available characters.

3. Press [ ENTER ] to go on to the next line.



Choice Variable


The choice variable is a pointer to the reference value. There is a one-on-one correspondence between the choice value and the reference value.


For example, say H is the choice variable and reference values are assigned as follows:


H = Choice Variable

Reference Value

1

13.5

2

14.7

3

16.1

If the user selects option 1, then 13.5 is placed on the X stack ready for calculation.

If the user selects option 2, then 14.7 is placed on the X stack ready for calculation.

If the user selects option 3, then 16.1 is placed on the X stack ready for calculation.



Example: Impedance of Transmission Lines


The characteristic impedance of transmission lines of a coaxial line is:


Z = K / √ε × log( D / L ) where:


K = √μ0 / (2 × π × √ε0 × log e) ≈ 138.059528959

D = inner diameter of outer conductor

L = outer diameter of inner conductor

ε = relative permittivity of dielectric medium (E)


The program give us three choices for the dielectric medium:


Material/Choice Variable ( C )

ε

1: Polythene (Flag 1)

2.3

2: Plexiglass (Flag 2)

3.2

3: Your Own (Flag 3)

Enter the ε of the material of your choice at the E? prompt


K is a constant that consists of the following scientific constants:


Vacuum Permeability

μ0 = 1.566370614 × 10^-6 H/m


Vacuum Permittivity

ε0 = 8.854187817 × 10^-12 F/m


Values are taken from the HP Prime, Software Version 2.1.14730 (2023 04 13).


SM32 Code

(Note: This should work on both the HP 33S and HP 35S; and the HP 35S can contain all the code in one label with the correct GTO commands)


// comment


// main program and initialization

T01 LBL T

T02 CF 1

T03 CF 2

T04 CF 3

T05 SF 10

T06 “TRANS-LINE IMP”

T07 PSE


// menu and calculation

M01 LBL M

M02 “REL PERMIT”

M03 PSE

M04 “1 POLYTHENE”

M05 PSE

M06 “2 PLEXIGLASS”

M07 PSE

M08 “3 YOUR OWN”

M09 PSE

M10 INPUT C


// set the flag based on the choice variable

M11 RCL C

M12 1

M13 x=y?

M14 SF 1


M15 RCL C

M16 2

M17 x=y?

M18 SF 2


M19 RCL C

M20 3

M21 x=y?

M22 SF 3


// enter reference value based on choice variable

M23 FS? 1

M24 2.3


M25 FS? 2

M26 3.2


M27 FS? 3

M28 INPUT E

M29 STO E


// calculation

M30 SQRT

M31 1/x

M32 138.059528959

M33 ×

M34 INNER DIAM

M35 PSE

M36 INPUT D

M37 OUTER DIAM

M38 PSE

M39 INPUT L

M40 ÷

M41 LOG

M42 ×

M43 STO Z


// clean up: clear all the flags for the next calculation

M44 CF 1

M45 CF 2

M46 CF 3

M47 CF 10

M48 VIEW Z

M49 STOP

// press R/S to do another problem

M50 GTO T




Examples

Let D = 0.68 in and L = 0.195 in.


Choice 1: Polythene. Resistance: 49.3835 Ω

Choice 2: Plexiglass. Resistance: 41.8669 Ω

Choice 3: ε = 1.95. Resistance: 53.6325 Ω



Source

Hewlett-Packard Company. HP-46 sample applications. Loveland, CO. February 1,1975. Part No. 00046-90018. pg. 26



Hope you find this useful,

Eddie


All original content copyright, © 2011-2024. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.