Post Reply 
Oops! hp42s Mohr's Cicle Program
06-02-2015, 08:41 AM
Post: #1
Oops! hp42s Mohr's Cicle Program
I could not find a program written about Mohr's Circle on the hp42s.
So I did this for kicks!
HP 42s Program Mohr's
This simple program runs and find the principal stress using Mohr's circle equations. The example below solves for principal stress & normal stress.

Line Instruction
01 LBL "MOHR"
02 INPUT "1OR0"
03 x=0?
04 GTO "XYT"
05 INPUT "TAUXY"
06 INPUT "SIGX"
07 INPUT "SIGY"
08 +
09 2
10 ÷
11 STO "S"
12 RCL "SIGX"
13 RCL- "SIGY"
14 2
15 ÷
16 x|2
17 RCL "TAUXY"
18 x|2
19 +
20 SQRT
21 STO "R"
22 CLST
23 RCL "R"
24 RCL+ "S"
25 STO "SIG1"
26 RCL "S"
27 RCL- "R"
28 STO "SIG2"
29 VIEW "SIG1"
30 PSE
31 VIEW "SIG2"
32 PSE
33 RCL "SIGX"
34 RCL- "SIGY"
35 1/x
36 2
37 x
38 RCLx "TAUXY"
39 ATAN
40 2
41 ÷
42 STO "Q"
43 VIEW "Q"
44 PSE
45 VIEW "R"
46 PSE
47 STOP
48 LBL "XYT"
49 CLST
50 INPUT "Q"
51 INPUT "SIG1"
52 INPUT "SIG2"
53 -
54 2
55 ÷
56 STO "R"
57 VIEW "R"
58 PSE
59 +/-
60 RCL+ "SIG1"
61 STO "S"
62 VIEW "S"
63 PSE
64 RCL "Q"
65 2
66 x
67 COS
68 RCLx "R"
69 RCL- "S"
70 +/-
71 STO "SIGY"
72 RCL "S"
73 2
74 x
75 -
76 +/-
77 STO "SIGX"
78 RCL "Q"
79 2
80 x
81 TAN
82 RCL "SIGX"
83 RCL- "SIGY"
84 x
85 2
86 ÷
87 STO "TAUXY"
88 VIEW "SIGX"
89 PSE
90 VIEW "SIGY"
91 PSE
92 VIEW "TAUXY"
93 STOP
94 RTN

Created by Jean-Marc Biram, Copyright © 2007 Free Software Foundation
Distributed under the version 3, GNU general public license


While writing the above I noticed a strange result which I narrowed down to codes.

Oops! this could be interesting, load this short program. I used the Free42 on my Palm T5. If you have the real thing give it a try.

01 LBL "OOPS"
02 CLST
03 STO "M"
04 STO "N"
05 INPUT "M"
06 INPUT "N"
07 -
08 x
09 2
10 ÷
11 STO "T"
12 VIEW "T"
10 RTN

Use the following values, M as 70,000 & N as -30,000
Strangely the Ans is T = 1,050,000,000 on the T5 version
Loaded the same program on the Android Free42 and the Ans is T = 30,002
Try it for yourself! Smile Smile

Regards, Jean-Marc
Visit this user's website Find all posts by this user
Quote this message in a reply
06-02-2015, 11:31 AM
Post: #2
RE: Oops! hp42s Mohr's Cicle Program
OOPS is giving me 1.05E9 on both versions I have on my iPhone. Check that you don't have some of the modernization options enabled on the Android version. I think there are some options that make the stack behave more like an RPL machine (at least in some builds/forks).
Visit this user's website Find all posts by this user
Quote this message in a reply
06-03-2015, 03:57 AM (This post was last modified: 06-03-2015 04:43 AM by Jean-Marc.)
Post: #3
RE: No Oops! hp35s Mohr's Circle Program
The same program on the HP 35s calculator gives me the correct answer T=0 Smile

01 LBL O
02 CLSTK
03 STO M
04 STO N
05 INPUT M
06 INPUT N
07 -
08 x
09 2
10 ÷
11 STO T
12 VIEW T
10 RTN

This must be a floating error in the Free42 app. I wonder if the actual HP 42s calculator gives T=0.

I had time to kill so I wrote one for the HP35s calculator too!

HP 35s Program Mohr's
This simple program runs and find the principal stress using Mohr's Circle. The examples below solves for principal stress & normal stress from angle.

Line Instruction
M001 LBL M
M002 SF 10
M003 MOHRS CIRC
M004 PSE
M005 0STRSS 1PRNC
M006 PSE
M007 INPUT M
M008 x=0?
M009 GTO M060
M010 SOLV PRINCIP
M011 PSE
M012 INPUT T
M013 INPUT X
M014 INPUT Y
M015 +
M016 2
M017 ÷
M018 STO S
M019 RCL X
M020 RCL- Y
M021 2
M022 ÷
M023 x2
M024 RCL T
M025 x2
M026 +
M027 √x
M028 STO R
M029 CLSTK
M030 RCL R
M031 RCL+ S
M032 STO M
M033 RCL S
M034 RCL- R
M035 STO N
M036 SIGMA MAX
M037 PSE
M038 VIEW M
M039 SIGMA MIN
M040 PSE
M041 VIEW N
M042 RCL X
M043 RCL- Y
M044 1/x
M045 2
M046 x
M047 RCLx T
M048 ATAN
M049 2
M050 ÷
M051 STO Q
M052 ANGLE
M053 PSE
M054 VIEW Q
M055 T MAX
M056 PSE
M057 VIEW R
M058 GTO M112
M059 SF 10
M060 SOLVE X,Y,T
M061 PSE
M062 CLSTK
M063 ANGLE Q
M064 PSE
M065 INPUT Q
M066 SIGMA MAX
M067 PSE
M068 INPUT M
M069 SIGMA MIN
M070 PSE
M071 INPUT N
M072 -
M073 2
M074 ÷
M075 STO R
M076 T MAX
M077 PSE
M078 VIEW R
M079 +/-
M080 RCL+ M
M081 STO S
M082 AVG STRSS
M083 PSE
M084 VIEW S
M085 RCL Q
M086 2
M087 x
M088 COS
M089 RCLx R
M090 RCL- S
M091 +/-
M092 STO Y
M093 RCL S
M094 2
M095 x
M096 -
M097 +/-
M098 STO X
M099 RCL Q
M100 2
M101 x
M102 TAN
M103 RCL X
M104 RCL- Y
M105 x
M106 2
M107 ÷
M108 STO T
M109 VIEW X
M110 VIEW Y
M111 VIEW T
M112 STOP
M113 RTN

Modified by Jean-Marc Biram, Copyright © 2007 Free Software Foundation
Distributed under the version 3, GNU general public license

shorter version of J. E. Charalambides HP 35s Mohr's Program.

Regards, Jean-Marc
Visit this user's website Find all posts by this user
Quote this message in a reply
06-03-2015, 05:37 AM
Post: #4
RE: Oops! hp42s Mohr's Cicle Program
Real physical 42S returns 1050000000, versions A & C.
Find all posts by this user
Quote this message in a reply
06-03-2015, 05:43 AM
Post: #5
RE: Oops! hp42s Mohr's Cicle Program
INPUT on the 42S (and Free42) puts a 0 in the stack, so after the two INPUT statements your stack looks like:

Code:
T: 0
Z: 70000
Y: 0
X: -30000

Result is 1'050'000'000
So the Android version is wrong.
Find all posts by this user
Quote this message in a reply
06-03-2015, 06:27 AM
Post: #6
RE: Oops! hp42s Mohr's Cicle Program
My Samsung S3 returns 1050000000.
Find all posts by this user
Quote this message in a reply
06-03-2015, 08:05 AM
Post: #7
RE: Oops! hp42s Mohr's Circle Program
Aha! that's what's happening, thank for the clarification. Correct me if I am wrong:-

CLST resets stack T Y X to zero
STO M stores 0 from stack
STO N stores 0
INPUT M brings back the M stored 0 before entering 70,000
INPUT N brings back the N stored 0 before entering -30,000

HP 35s calculator behaves differently the stored number will need a recall command first for this to happen. INPUT places the number on the stack, that's probably why T=0 in this case.

PS: Checked my android version again and got the same answer as the T5. Difference is only between 35s & 42s apparently. Maybe you can try other models Hp32sii 33s etc... Smile

Regards, Jean-Marc
Visit this user's website Find all posts by this user
Quote this message in a reply
06-03-2015, 12:20 PM
Post: #8
RE: Oops! hp42s Mohr's Cicle Program
My Samsung Galaxy S4 running Free 42 1.5.5 returns
1,050,000,000

I also get the same result in Free42 Binary and Decimal 1.5.5 on windows.
Find all posts by this user
Quote this message in a reply
06-03-2015, 12:47 PM
Post: #9
RE: Oops! hp42s Mohr's Cicle Program
The 41C doesn't have an INPUT command, so you don't have this problem there. Big Grin

But you could do this:

Code:
LBL "OOPS"
"M?"
PROMPT
STO 00
"N?"
PROMPT
STO 01
-
x
2
÷
STO 02
VIEW 02
RTN

...Which returns 0 if X is 0 when you run the program.
Visit this user's website Find all posts by this user
Quote this message in a reply
06-03-2015, 03:09 PM
Post: #10
RE: Oops! hp42s Mohr's Cicle Program
(06-02-2015 08:41 AM)Jean-Marc Wrote:  Use the following values, M as 70,000 & N as -30,000
Strangely the Ans is T = 1,050,000,000 on the T5 version
Loaded the same program on the Android Free42 and the Ans is T = 30,002
Try it for yourself! Smile Smile

What Version number is the Android Free42 you're using?

I just tried it on Android Free42 Version 1.5.5 and get the 1,050,000,000 answer. That's on both my Nexus 7 and Moto X Phone.

Maybe your Android version is and older version?

Bill
Smithville, NJ
Find all posts by this user
Quote this message in a reply
Post Reply 




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