# HP Forums

Full Version: HP35s Calculator Max Rope Tension Program
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Hi,

This is my first post on the forum. I would like to introduce myself as an engineer that is still using a calculator instead of an iPhone application at work.

In 2007 I bought the HP35s as a replacement for another calculator and wrote a few programs to simplify several tasks. As a programming beginner I found the key stroke style much easier to use and get results. I stumbled on this site by accident searching for HP35s programming examples online. I also obtained the matrix program from stefan's website which helped a lot.

As my thanks to all the volunteers I am posting this simple program to calculate rope tension. Useful for riggers on the field who owns an HP35s calculator.

Schematic of problem ::

Keystrokes Display Description

```XEQ P ENTER 	                Run: program P pulley/sheaves
981 R/S 	        L? 	Enter the load L = 981N
0.02 R/S 	        F? 	For friction we will use m = 0.02
12 R/S 	                N? 	Enter 12 as the number of parts
3 R/S 	                D? 	3 for deflected pulley/sheaves
96.51 	Ans : 96.51N
The new code listing is as follows: ```
```P001 	LBL P
P002 	INPUT L 	Enter load L
P003 	INPUT F 	Enter friction coeficient e.g 0.02
P004 	INPUT N 	Enter the number of line parts
P005 	INPUT D 	This is the number of deflected sheaves
P006 	1
P007 	ENTER
P008 	RCL F
P009 	+
P010 	RCL N
P011 	ENTER
P012 	1
P013 	-
P014 	yx
P015 	STO A
P016 	ENTER
P017 	1
P018 	ENTER
P019 	RCL F
P020 	+
P021 	RCL D
P022 	yx
P023 	STO B
P024 	ENTER
P025 	0
P026 	ENTER
P027 	RCL N
P028 	1
P029 	-
P030 	RCL F
P031 	ENTER
P032 	1
P033 	+
P034 	x<>y
P035 	yx
P036 	+
P037 	DSE N
P038 	GTO P027
P039 	STO T
P040 	ENTER
P041 	RCL A
P042 	ENTER
P043 	RCL B
P044 	x
P045 	RCL T
P046 	÷
P047 	RCL L
P048 	x
P049 	STOP
LN=101 	Checksum=FD5A
```

` I tried to get the formatting as best I could`

Nice work, and welcome to the forum!

Hello,

Nice program. I don't think I will ever need to calculate rope tension for rigging, but I appreciate the use of the 35s. Since you state that you are a relatively new user to RPN, I'll risk pointing out a few improvements that might be made. Please don't take my suggestions as criticism, just trying to be helpful. With that said, your program could be shortened as follows:

The ENTER commands in lines 7, 11, 16, 18, 24, 26, 31, 40, and 42 are unnecessary due to automatic stack lift.

The RCL instructions in lines 8, 19, 43, 45, and 47 which are each followed by an arithmetic operation could be replaced with the corresponding combined instruction, e.g.,

RCL B

x

may be replaced with

RCLx B

With the above changes, your program is shortened to 35 steps:

```Line 	Instruction 	Comments
P001 	LBL P
P002 	INPUT L 	Enter load L
P003 	INPUT F 	Enter friction coeficient e.g 0.02
P004 	INPUT N 	Enter the number of line parts
P005 	INPUT D 	This is the number of deflected sheaves
P006 	1
P007	RCL+ F
P008	RCL N
P009	1
P010	-
P011	yx
P012	STO A
P013	1
P014	RCL+ F
P015	RCL D
P016	yx
P017	STO B
P018	0
P019	RCL N
P020	1
P021	-
P022	RCL F
P023	1
P024	+
P025	x<>y
P026	yx
P027	+
P028	DSE N
P029	GTO P019
P030	STO T
P031	RCL A
P032	RCLx B
P033	RCL÷ T
P034	RCLx L
P035	STOP
```

I believe my suggestions are valid, as I get the correct answer for your sample calculation.

FYI, unfortunately the LN and CK figures on the 35s do not have any useful meaning as different users will get different values on different machines. For example, your original program produces LN =153, CK=2B98 on my 35s. My revised version gives LN=111, CK=7DC5. (See the complete HP 35s "bug list".)

My apologies if you were well aware of the above suggested improvements and simply prefer your code to be structured as in your original.

Thank you for sharing the program.

For those riggers on the field with an iPad mini (and an HP-67 simulator running on it), I've taken the liberty to provide the program as an HP-67 card on my website www.cuveesoft.ch/rpn67/p11.html

I hope that's okay with you; otherwise, please contact me (link is on the website). It would also be nice to have a simple illustration of the problem your program solves.

When I understand your program correctly the following is calculated:

```A = (1 + F)^(N - 1)
B = (1 + F)^D
T = SUM (1 + F)^i for i in {0 ... N-1}
P = A*B*L/T
```

But for the geometric series we can use a closed form:

```T = ((1 + F)^N - 1)/(1 + F - 1) = ((1 + F)^N - 1)/F
```

Thus we end up with:

```P = (1 + F)^(N + D - 1)*L*F/((1 + F)^N - 1)
```

This can be reduced by (1 + F)^N:

```P = (1 + F)^(D - 1)*L*F/(1 - (1 + F)^-N)
```

Now you could enter that formula in algebraic mode.
But if I remember correctly this is a little slow.
And of course we prefer RPN:

```P001    LBL P
P002    INPUT L    Enter load L
P003    INPUT F    Enter friction coeficient e.g 0.02
P004    INPUT N    Enter the number of line parts
P005    INPUT D    This is the number of deflected sheaves
P006    1
P007    RCL+ F
P008    RCL D
P009    1
P010    -
P011    yx
P012    RCL* L
P013    RCL* F
P014    1
P015    ENTER
P016    RCL+ F
P017    RCL N
P018    +/-
P019    yx
P020    -
P021    /
P022    RTN
```

Kind regards

Thomas

Edited: 9 Dec 2013, 12:52 p.m.

The loop could still be improved a little:

Quote:
```P019	RCL N
P020	1
P021	-
P022	RCL F
P023	1
P024	+
P025	x<>y
P026	yx
P027	+
P028	DSE N
P029	GTO P019
```

```P019	1
P020	RCL+ F
P021	RCL N
P022	1
P023	-
P024	yx
P025	+
P026	DSE N
P027	GTO P019
```

Cheers

Thomas

Very nice, Thomas, your finding of a closed-form solution!

And thank you, Jean-Marc, for presenting an interesting program (even though not from my field of expertise). Don't worry about size, most import thing is to get the job done (my first RPN programs had a lot of needless ENTERs as well). I won't be surprise if someone shovels a step or two (you'll be surprised by the size-optimization some people here are capable of). Some fellow engineers might also like this:

Welcome to the club, Jean-Marc, and

Best regards,

Gerson.

Yes you understood the equation and improved it.

There is a link to a sketch for the problem on the first post its under:-

Quote:
Schematic of problem ::

HP35s Calculator Max Rope Tension Program

It shows in blue on my browser.

Edited: 12 Dec 2013, 12:10 a.m.

Thanks

I am always learning and improving and I don't mind listening to constructive suggestions.