Friday, December 23, 2016

Fun with HP 71B IV

Fun with HP 71B IV

For the previous entries:

Links to other HP 71B Programs:
Fun with the 71B:
http://edspi31415.blogspot.com/2012/06/fun-with-hp-71b.html
Fun with the 71B III:


Rake Wall

The program RAKEWALL calculates:

*  The positions and lengths of studs on a rake wall
*  Angle of the incline




Program RAKEWALL
192 Bytes, 12/22/2016

10 DESTROY B,R,L,N,A
15 DESTROY I,T,O
50 INPUT “BASE:”; B
52 INPUT “RISE:”; R
54 INPUT “RUN:”; L
56 INPUT “O.C. :”; S
74 N = INT(L/S)
76 DEGREES
78 T = ATAN(R/L)
80 DISP “ANGLE =”; T; “°”  @ PAUSE
90 FOR I=L TO 0 STEP –S
92 A = I*TAN(T)+B
94 DISP I; “, “; A  @ PAUSE
96 NEXT I
98 DISP 0; “, “; B

Notes:
Degree symbol (°):  [ g ], [RUN] (CTRL), [ A ]

Example: (amounts are in feet)
BASE:  4
RISE:  3
RUN:  6
O.C.:  16/12  (1 foot, 4 inches)

Output: 
ANGLE = 26.5650511771 °
(Position from where the incline meets the base, length of studs)
6, 7
4.66666666667, 6.33333333334
3.33333333334, 5.66666666667
2.00000000001, 5
0.66666666668, 4.33333333334
0,  4


Automotive Cylinders:  Calculating Displacement and Piston Speed

The program supplies default values which can be accepted or changed.



Program AUTOCYN
217 Bytes, 12/22/2016

10 DESTROY N,B,S,R,E,P
15 INPUT “# CYLINDERS:”,  “6”; N
20 INPUT “BORE (IN):”, “4”; B
25 INPUT “STROKE (IN):”, “4”; S
30 E = PI/4 * B^2 * S * N
35 INPUT “RPM:”; R
40 P = S * R / 6
45 DISP “ENGINE DISPLACEMENT =” @ WAIT 1
50 DISP E; “ IN^3” @ PAUSE
55 DISP “PISTON SPEED =” @ WAIT 1
60 DIPS P; “FPM”

Example 1:
N = 6 cylinders, B = 4 in, S = 4 in, RPM = 3500
Output:  E ≈ 301.59290 in^3, P ≈ 2333.33333 FPM

Example 2:
N = 6 cylinders, B = 4 in, S = 3 in, RPM = 4500
Output:  E ≈ 226.19467 in^3, P = 2250 FPM

Right Triangle Solver

The program RIGHTTRI is a solver for the sides A, B, and C.  To solve for the third side, the desired side needs to have a 0 value, while the other two sides have non-zero values.  Each time a solution is found, the values of A, B, and C are reset (set to 0).



Program RIGHTTRI
502 Bytes, 12/22/2016

10 DESTROY A,B,C,Z$
11 ! LOOP
12 DISP “A, B, C, Solve, Exit”
14 DELAY 0, 0
16 Z$ = KEY$
18 IF Z$ = “A” THEN 30
20 IF Z$ = “B” THEN 40
22 IF Z$ = “C” THEN 50
24 IF Z$ = “S” THEN 60
26 IF Z$ = “E” THEN 96
28 GOTO 12
30 INPUT “A = “; A
32 GOTO 12
40 INPUT “B = “; B
42 GOTO 12
50 INPUT “C = “; C
52 GOTO 12
60 IF A=0 AND B AND C THEN 62 ELSE 70
62 S=SQR(C^2-B^2) @ Z$ = “A”
64 GOTO 90
70 IF A AND B=0 AND C THEN 72 ELSE 80
72 S=SQR(C^2-A^2) @ Z$ = “B”
74 GOTO 90
80 IF A AND B AND C=0 THEN 82 ELSE 86
82 S=SQR(A^2+B^2) @ Z$ = “C”
84 GOTO 90
86 DISP “MUST HAVE ONE 0” @ BEEP @ WAIT .5
88 GOTO 10
90 DISP Z$; “ = “; S @ PAUSE
92 GOTO 10
94 DISP “DONE”

Notes:

The line of IF A=0 AND B AND C… tests whether A is zero, B and C are non-zero.  You can test whether a variable is non-zero by just typing the variable in an IF condition.

The function SQR is the square root function of the HP 71B.

Anything following an exclamation point (!) is a comment.


Basic Bridged-T Notch Filter

The program NOTCH calculates the required capacitor and resistor to null out an undesired frequency.

Inputs:  inductance (H), frequency to nullified (Hz), resistance of the required coil (Ω)



Source:  Rosenstein, Morton.  Computing With the Scientific Calculator Casio: Tokyo, Japan.  1986.  ISBN-10: 1124161430

Program NOTCH
244 Bytes, 12/22/2016

10 DESTROY L,F,I,C,R
20 DISP “INDUCTANCE” @ WAIT 1
22 INPUT “in H: “; L
24 DISP “FREQUENCY” @ WAIT 1
26 INPUT “in Hz: “; F
28 DISP “COIL’S RESISTENCE” @ WAIT 1
30 INPUT “in Ω: “; I
40 C = 1/(2 * PI^2 * F^2 * L)
42 R = (PI * F * L)^2 / I
44 DISP “NOTCH CAPACITOR” @ WAIT 1
46 DISP C; “ F” @ PAUSE
48 DISP “NOTCH RESISTENCE” @ WAIT 1
50 DISP R; “ Ω”

Notes:
Capital Omega Character (Ω):  [ g ], [RUN] (CTRL), [ Q ]

Example:   L = 0.12 H, F = 1170 Hz, Coil Resistance = 30 Ω
Output: 
NOTCH CAPACITOR ≈ 3.08402 * 10^-7 F
NOTCH RESISTENCE ≈ 6485.04070 Ω


Differential Equations and Half-Increment Solution, Numerical Methods

The program HALFDIFF solves the numerical differential equation

d^2y/dt^2 = f(dy/dt, y, t)  given the initial conditions y(t0) = y0 and dy/dt (t0) = dy0

In this notation, y is the independent variable and t is the dependent variable.

The Method

Let C = f(dy/dt, y, t).  Give the change of t as Δt.

First Step:

With t = t0:
h_1/2 = dy0 + C * Δt/2
y1 = y0 + dy0 * Δt

Loop:

t = t0 + Δt
h_I+1/2 = h_I-1/2 + C * Δt
y_I+1 = y_I +h_I+1/2 * Δt

Repeat as many steps as desired.


Source:  Eiseberg, Robert M.  Applied Mathematical Physics with Programmable Pocket Calculators  McGraw-Hill, Inc:  New York.  1976.  ISBN 0-07-019109-3

Program HALFDIFF
250+ bytes, 12/22/2016

Edit f(A,Y,T) at line 5 where
A = y’(t), Y = y(t),  T = t

5 DEF FNF(A,Y,T) = insert function y’(t), y(t), and t here
10 DESTROY A,Y,D,N,H,T
12 RADIANS
20 INPUT “dY/dX (0) = “, “0”; A
22 INPUT “Y(0) = “, “0”; Y
24 INPUT “DELTA T = “,”1”; D
26 INPUT “TMAX = “,”5”; N
28 T = D
44 H = A + FNF(A,Y,T) * D/2
48 Y = Y + H * D
50 DISP D; “, “;  Y @ PAUSE
70 FOR I = 2 * D TO N STEP D
72 T = I @ A = H
76 H = H + FNF(A,Y,T) * D
78 Y = Y + H * D
80 DISP I; “, “; Y @ PAUSE
82 NEXT I

Example:  y’’(t) = y’(t) + 2 *  t with y’(0) = 0, y(0) = 1, Delta t = 1, Max t = 6
FNF(A,Y,T) = A + 2 * T

Results:

T
Y
1
2
2
8
3
26
4
70
5
168
6
376


  
This blog is property of Edward Shore, 2016.





No comments:

Post a Comment

HP Prime: Area by Quadratic Splines

HP Prime:  Area by Quadratic Splines Introduction The program QUADSUM calculates the area under the curve described by the set o...