Showing posts with label PCalc. Show all posts
Showing posts with label PCalc. Show all posts

Thursday, October 2, 2014

PCalc 3.3: Some of the new features

One of my favorite iOS calcualtor apps is PCalc by James Thompson. Recently, PCalc received an update to Version 3.3. Here are some of the new features:


If you Handoff, the PCalc will allow you to start calculations on one iOS device and transfer it to another. You will need Bluetooth and a cloud account.

Another new feature is the ability to turn operator precedence off. Do that and the PCalc operates like a basic four function calculator, with scientific functions. In this mode, be careful what order of keys you press as every operation affects the number in the display. The option of turning operator precedence is available when RPN mode is turned off.

And now for my favorite new feature: customizable keyboards. Each of the keyboards, one that shown when the iOS device is in portrait orientation and one that is shown in landscape orientation, can be individually customized. Each key can activate functions, user created programs, and access to option menus. The keyboard has two planes: one for "first" functions and one for functions that are acessed by press on the 2nd key. If you want keys to have two functions, then you will need to create a key for each plane. You can also change the size of each key, give the key a custom name, and change the font size of each key. Colors of the keys themselves are still determined by the theme you select in the app's options.

Additional new features include widget notification and an expanded list of Bluetooth keyboard shortcuts. PCalc is currently sold for $9.99 in the App Store.


Eddie

This blog is property of Edward Shore. 2014


Sunday, May 25, 2014

PCalc and HP 50g: Internal Pressure in a Vessel

PCalc and HP 50g: Internal Pressure in a Vessel

I = inner radius of the vessel
O = outer radius of the vessel
P = pressure of the water flow
σh = hoop stress

σh = P * (O^2 + I^2)/(O^2 - I^2)

Source: Goswami, Indramil Ph.D. P.E. "All In One Civil Engineering PE Breadth and Depth Exam Guide" 2nd Edition. McGraw Hill: 2012


PCalc: Pressure In A Vessel

Store the following:
I → M1
O → M2
P → M3

Decimal Mode
Set R1 To M1
R1 To Power of 2
Set R2 To M2
R2 To Power of 2
Set X To R1
Add R2 To X
Set R0 To R1
Subtract R2 From R0
Divide X By R0
Multiply X By M3



HP 50g: VESSEL

<< "Inner Radius" PROMPT
"Outer Radius" PROMPT
"Pressure" PROMPT
→ I O P
<< O SQ I SQ DUP2
+ UNROT - / P * →NUM
"σh" →TAG >> >>



Example:
O = 3/8 in = .375 in
I = 3/32 in = .09375 in
P = 10 lb/(s*in^2)

Result:
σh ≈ 11.3333 lb/(s*in^2)

- Eddie -


PCalc and HP 50g: Horizontal Pipe Discharge

PCalc and HP 50g: Horizontal Pipe Discharge

Variables:
X, Y, and D (diameter of the pipe) are in inches. Flow (Q) is calculated in GPM (gallons per minute).

Q ≈ .25974 * π * D^2/4 * X * √( g /(2 * Y))

Where
g = 9.80665 m/s^2 ≈ 386.08858 in/s^2
1 in^3/s ≈ .25974 gal/min

Source:

Gary P. Markey. Lecture 14: Flow Measurement in Pipes. BIE 5300/6300 Lectures
Utah State University - Open Courseware

http://ocw.usu.edu/Biological_and_Irrigation_Engineering/Irrigation___Conveyance_Control_Systems/L14_FlowMeasurementInPipes.pdf



PCalc: Horiz. Pipe Discharge (GPM)

Store the following values before proceeding:
D in M1
X in M2
Y in M3

Decimal Mode
Set X To M1
X To Power of 2
Multiply X By M2
Multiply X By Pi
Divide X By 4
Set R0 To 386.08858
Divide R0 By 2
Divide R0 By M3
R0 To Power of 0.5
Multiply X By R0
Multiply X By .25974



HP 50g: HPD

SQ: x^2

<< "Hose Diameter (in)" PROMPT
"X (in)" PROMPT
"Y (in)" PROMPT
→ D X Y
<< π D SQ * X * 4 / →NUM
386.08858 2 Y * / √ *
.25974 * "Flow (GPM)" →TAG >> >>



Example:
D = 2.5 in
X = 8 in
Y = 4 in

Result:
Flow ≈ 70.85936 Gallons per Minute

- Eddie -


PCalc and HP 50g: Mohr's Circle

PCalc and HP 50g: Mohr's Circle

Given shear stresses in the x and y directions (σx and σy) and normal stress (τ), find the radius, center, and viewing angle of Mohr's Circle.

I take τ to represent both τxy and τyx (both are assumed to be equal).

Radius:
R = √( (σx - σy)/2)^2 - τ^2 )

Center (S, 0):
S = (σx + σy)/2

Viewing Angle:
θ = atan( 2τ /(σx - σy)) / 2

Sources:

HP 35S Program by Jason Charalambides, Avant Garde Engineering. HP 35S program written in 2012.

http://www.avant-garde-engineering.com/HP35s_Programs/Mohr's%20Circle.pdf

Wikipedia Article on Mohr's Circle, retrieved 5/23/2014:

http://en.wikipedia.org/wiki/Mohr's_circle


PCalc:

Before running, store the following values:
σx into M1
σy into M2
τ into M3

Program: Mohr's Circle - Radius
Decimal Mode
Set X To M1
Subtract M2 From X
Divide X By 2
X To Power of 2
Set R0 To M3
R0 To Power of 2
Add R0 To X
X To Power of 0.5


Program: Mohr's Circle - Center (X,0)
Decimal Mode
Set X To M1
Add M2 To X
Divide X By 2


Program: Mohr's Circle - View Angle
Decimal Mode
Set X To M3
Multiply X By 2
Set R0 To M1
Subtract M2 From M0
Divide X By R0
Inverse Tangent X
Divide X By 2



HP 50g: MOHR

σ: ALPHA, Right-Shift, S
τ: ALPHA, Right-Shift, U
SQ: x^2

<< "Shear Stress σx" PROMPT
"Shear Stress σy" PROMPT
"Normal Stress τ" PROMPT
→ X Y T
<< X Y - 2 / SQ T SQ + √
"Radius" →TAG
X Y + 2 / (0,0) +
"Center" →TAG
T 2 * X Y - / ATAN 2 /
"View Angle" →TAG >> >>



Example:
σx = 100
σy = -220
τ = 80

Results:
R ≈ 178.88544
S = -60 (center (-60,0))
θ ≈ 13.28253° ≈ .23183 radians

- Eddie -

Friday, May 23, 2014

PCalc and HP 50g: Newton's Law of Gravity Solver



PCalc Program: Newton's Law of Gravity (U.S. units)
5/20/2014

F = (G * m1 * m2) / r^2

A solver program for PCalc. Turn Multiple Memories on. Use the Skip If Equal command to simulate a menu.

Pre-load the following values:
M0 = F (force: ft^3/(lb s^2))
M1 = m1 (mass of object 1 in pounds)
M2 = m2 (mass of object 2 in pounds)
M3 = r (distance between center of masses in feet)

Enter 0 (zero) for any variable you want to solve for.

Program:
Decimal Mode
Set X To 1.0690466104e-9
Skip 3 If M0 = 0
Skip 7 If M1 = 0
Skip 13 If M2 = 0
Skip 19 If M3 = 0
Multiply X By M1
Multiply X By M2
Power M3 To -2
Multiply X By M3
Stop
Invert X
Multiply X By M0
Invert M2
Multiply X By M2
Power M3 To 2
Multiply X By M3
Stop
Invert X
Multiply X By M0
Invert M1
Multiply X By M1
Power M3 To 2
Multiply X By M3
Stop
Multiply X By M1
Multiply X By M2
Invert M0
Multiply X By M0
Power X To 0.5
Stop

Example:
M0 = 0 (solve for F)
M1 = 4.384e30
M2 = 1.317e25
M3 = 49079712000 = 92954000 × 5280

Solve: X = 2.562411e25 (F)


HP 50g: Newton's Law of Gravity Solver

F = force (ft^3)/(lb s^2)
M1 = mass of object 1 (lb)
M2 = mass of object 2 (lb)
R = distance between objects (ft)

Program GRAVITY
<< {'F' 'M1' 'M2' 'R'} PURGE F M1 M2 1.0690466104E-9
* * R SQ / = STEQ 30 MENU >>


This blog is property of Edward Shore. 2014


PCalc and HP 50g: Period of Orbit Around the Sun

To determine the period of a satellite's orbit around the sun (mainly planet), Newton's version of Kepler's Third Law is used.

T = 2 π √(a^3 /(G * (MS + m)) )

Source: Astronomy 801: Planets, Stars, and the Universe - Penn State University
https://www.e-education.psu.edu/astro801/


PCalc Program: Period Around the Sun
5/19/2014

G = 1.0690441604e-9 ft^3/(s^2 lb)
Mass of the Sun = MS = 4.384e30 lbs

T = 2 π √(a^3 /(G * (MS + m)) )

Input:
Y: mass in pounds
X: distance in miles

Output:
X: period in years

Program:
Decimal Mode
Multiply X By 5280
X To Power of 3
Add 4.384e30 To Y
Multiply Y By 1.0690441604e-9
Divide X By Y
X of Power of 0.5
Multiply X By 2
Multiply X By Pi
Divide X By 31556925.9747

Example:
Input:
Y: 1.3170e25 pounds (Mass of the Eath)
X: 9295400 miles (average semi-major axis between Earth and Sun)

Output:
X: 1.0000102186
It takes about 1.00001 years for Earth to orbit the Sun


HP 50g: Period Around the Sun:

Input:
2: mass of orbiting object in pounds
1: distance from sun in miles

Output:
1: period of orbit in years

Program PERSUN
<< 5280 * 3 ^ SWAP 4.384E30 +
1.0690441604E-9 * / √ 2 * π *
→NUM 31556925.9747 / >>


This blog is property of Edward Shore. 2014



PCalc and HP50g: Distance of a Star by Parallax

Source: Astronomy 801: Planets, Stars, and the Universe - Penn State University
https://www.e-education.psu.edu/astro801/




PCalc Program: Distance of a Star by Parallax (Degrees Mode)
5/19/2014

D = approximate distance from Earth to the star
P = angle in arc seconds (1/3600 of the degree)

D = 1/ (tan(P/3600) * 63239.7263452)

1 light year = 63239.7263452 AU

(AU: distance from Earth to the Sun)

Input:
X: angle in arc seconds

Output:
X: distance in light year

Program:
Decimal Mode
Degrees Mode
Divide X By 3600
Tangent X
Multiply X By 63239.7263452
Invert X

Example:
Input:
X: 0.54 arc second

Output:
X: 6.0400619278 light years


HP 50g: Distance of a Star by Parallax

The commands PUSH and POP are used to preserve and recall settings. PUSH stores the settings while POP recalls stored settings. This allows the program to make necessary changes to program modes during execution with permanently affecting the settings for the user.

Input:
1: angle in arc seconds

Output:
1: distance to star in light years

Program PARALLAX
<< PUSH DEG 3600 / TAN
63239.7263452 * INV POP >>


This blog is property of Edward Shore. 2014





PCalc and HP 50G: Escape Velocity

The next four posts will have programs for the PCalc iOS app and the HP 50g calculator. English/U.S. Units (feet/miles, pounds, seconds) will be used instead of SI units (meters/kilometers, kilograms, seconds).

The Universal Gravitational Constant is:

SI Units:
G = 6.67384 x 10^-11 m^3/(s^2 kg)

English Units:
G = 1.06904661604 x 10^-9 ft^3/(s^2 lb)



PCalc Program: Escape Velocity (in mi/sec)
5/19/2014

G = 1.06904661604 x 10^-9 ft^3/(s^2 lb)

Input:
Y: mass (in pounds)
X: distance or radius (in miles)

Output:
Y: mass (in pounds)
X: escape velocity (mi/sec)

Program:
Decimal Mode
Multiply X By 5280
Invert X
Multiply X By Y
Multiply X By 2
Multiply X By 1.0690441604e-9
X To Power of 0.5
Divide X By 5280

Example:
Y: 1.3170e25 lbs (Mass of Earth)
X: 3,959 mi (radius of Earth)

Output:
Y: 1.3170e25
X: 6.9512

Escape Velocity: 6.9512 mi/sec


HP 50g: Escape Velocity:

Input:
2: mass in pounds
1: distance in miles

Output:
1: escape velocity in mi/sec

Program ESCVEL
<< 5280 * INV * 2 * 1.0690441604E-9 * √ 5280 / >>



This blog is property of Edward Shore. 2014

Sunday, May 4, 2014

PCalc: Programming Examples

For introduction to programming the PCalc iOS app, please click on this link:

http://edspi31415.blogspot.com/2014/05/pcalc-programming-introduction.html

PCalc:

Degrees Minutes Seconds to Decimal Degrees (DMS > D)

Converts DD.MMSSsssss to DD.dddddddddddd
D: Degrees
M: Minutes
S: Seconds

Example:
Input: 45.1535 (45° 15' 35")
Output: 45.2597222222 (≈ 45.25972°)

Program:
Decimal Mode
Set R0 To X
Truncate X
Set R1 To R0
Subtract X From R1
Multiply R1 By 100
Set R2 To R1
Truncate R1
Subtract R1 From R2
Divide R2 By 60
Multiply R2 By 100
Add R1 To R2
Divide R2 By 60
Add R2 To X


Decimal Degrees to Degrees Minutes Seconds (D > DMS)

Converts DD.ddddddd to DD.MMSSsssss where
D: Degrees
M: Minutes
S: Seconds

Example:
Input: 6.375 (6.375°)
Output: 6.2230 (6°22'30")

Decimal Mode
Set R0 To X
Truncate X
Set R1 To R0
Subtract X From R1
Multiply R1 By 60
Set R2 To R1
Truncate R1
Multiply R1 By 0.01
Add R1 To X
Set R3 To R2
Truncate R3
Subtract R3 From R2
Multiply R2 By 0.006
Add R2 To X


Stopping Sight Distance (in feet)

Input:
Y: design vehicle speed (miles per hour)
X: grade (in percentage)

Output:
X: Stopping sight distance in feet

Standard constants are used: deceleration of the car is assumed to be 11.2 ft/s^2.

Example:
Input:
Y: 45 mph
X: 2 (2% grade)

Output:
X: 249.8576858108 (feet)

Decimal Mode
Set R0 To 22/15
Multiply R0 By Y
Multiply X By 0.32
Add 11.2 To X
Invert X
Multiply X By 1.075
Y To Power of 2
Multiply X By Y
Add R0 To X


Perfect Trajectory (Projectile Motion without Air Resistance starting from point (0,0))

Input:
Y: Velocity in meters/second
X: Angle in Degrees

Output:
Y: Maximum Height in meters
X: Range of Projectile in meters

Example:
Input: Y: 30, X: 30
Output (to 4 decimal places): Y: 11.4718, X: 79.4790

Program:
Decimal Mode
Degrees Mode
Set R1 To 19.6133
Invert R1
Set R0 To X
Sine R0
R0 To The Power of 2
Multiply R1 By R0
Set R0 To Y
R0 To The Power of 2
Multiply R1 By R0
Set R2 To 9.80665
Invert R2
Set R0 To X
Multiply R0 By 2
Sine R0
Multiply R2 By R0
Set R0 To Y
R0 To The Power of 2
Multiply R2 By R0
Set X To R2
Set Y To R1


Eddie


This blog is property of Edward Shore. 2014

PCALC Programming: An Introduction

This blog entry is an introduction to programming the PCalc iOS App by James Thomson. My review of this app can be found here:

http://edspi31415.blogspot.com/2014/04/greetings-from-seattle-and-short-review.html

** Note, PCalc Lite app will not have this functionality. To get it, you have to purchase either the full PCalc iOS app (usually sold for $9.99), or make an in-app purchase of the appropriate add-on.

Creating or Edit Programs

Starting New Program or Edit a Program:

1. Press the f(x) button.
2. Select Edit (lower left corner of the dialogue box). This will cause a red circle to appear next to "User" and any other customized categories.
3. Select a category (User will work). To edit an existing program, just select it. To create a new program, select the Plus (+) symbol on the upper right hand corner of the screen. You can delete programs by pressing the red circle with a minus sign next to the program name. A red Delete box will appear as an indicator of confirmation.

Programs in PCalc work with registers. The X register is the primary display register. The Y register is the second display register. PCalc also has 10 permanent memory registers (labeled Memory 0 through Memory 9), 16 temporary registers (labeled Register 0 through Register 9, then Register A through Register F), and a tax register.

Everything is done in a sequential manner.

Types of Commands

There are several types of commands.

Mode Commands: they change the mode of PCalc. This includes angle setting (Degrees Mode, Radians Mode) and base setting (Decimal Mode, Octal Mode, Binary Mode, Hexadecimal Mode).

One Argument Commands: A command operates on a register and stores the result in that register. This includes trigonometric and logarithmic commands. This also includes several number operations:

Negate: Multiply the register by -1. This is like the change sign key. (+/-)

Invert: Takes the reciprocal of the value of the designated register. (1/x)

Truncate: Takes the integer part of the value of the register. (INTG/IP)

Exponent: The exponential function (e^x)

Factorial: The factorial function (x!). x must be positive, but does not have to be an integer.

Two Argument Commands: This is the arithmetic operations, power commands, and the Set command. The format is like this:

Command (operation)
Register (result is stored here)
Value (value of a designed register or specified value)

Let A and B be registers, B can also be a value.

Add B To A: A + B is stored in A

Subtract B From A: A - B is stored in A

Multiply A By B: A × B is stored in A

Divide A By B: A ÷ B is stored in A

A To Power of B: A^B is stored in A

(Inverse Power):
A To Power Of 1/B: Bth root of A stored in A (principal root)

Skipping Functions: PCalc allows for Boolean comparisons of values.

Command: Skip (what has to happen for the next commands to be skipped)
Register (register to be compared)
Value (register or value that is compared)
Skip (number of steps if the comparison is true)

For example:
Command: Skip If Greater Than
Register: X
Value: 42
Skip: 1

Skip 1 step if X>42.

There is a plain Skip command to arbitrarily skip a number of commands. This can turn out to be useful. It may take practice to get the Skip commands correct.

There are no loop commands in PCalc (as of this blog post).

You can stop, even invoke the error condition at any time by inserting a Stop or Error command, respectively.

Let's go over a couple of examples.

Volume of a Sphere

The volume of a sphere is V = 4/3 * π * r^3, where r is the radius.

This program takes the radius in the X register and calculate the volume of the radius. Please pay careful attention to the order of the program steps.

Volume of a Sphere
Decimal Mode
X To The Power of 3
Multiply X By 4/3
Multiply X By Pi (scroll down the possible list of values to select π).


Test example: The radius of Earth is approximately 3,963 miles. If we treat Earth as a sphere, it's volume would approximately be 260,711,882,973.332 cubic miles.

In more complex programs, I start by making copies of X, Y, and any other required registers into temporary registers. I use temporary registers to store and execute immediate calculations. When all the calculations are finished, I store the results into X, Y, and permanent memory registers (if necessary). The next program, Rect > Polar, will be an example of this.

Convert Rectangular Coordinates to Polar Coordinates

Enter the y coordinate then the x coordinate. The result will have r in the X register and the angle in the Y register. The angle is shown in degrees and ranges from -180° to 180°, similar to most scientific calculators with this function.

Comments are followed by a double backwards slash characters ( \\ ). These are for notes only and are not entered.

Rect > Polar
Decimal Mode
Degrees Mode \\ set PCALC to degrees
Set R0 to X \\ start calculating r = √(x^2 + y^2)
R0 To The Power of 2
Set R1 To Y
R1 To The Power of 2
Add R1 To R0
R0 To The Power of 1/2 \\ Inverse Power command, R0 = r
Set R1 To Y \\ start calculation for angle
Skip 5 If X!=0 \\ skip the next 5 steps if x≠0 - Goto (I)
Skip 2 If Y<0
Set R1 To 90
Skip 10 \\ skip the next 10 steps - Goto (II)
Set R1 To -90
Skip 8 \\ Goto (II)
Divide R1 By X \\ Label (I)
Inverse Tangent R1 \\ atan(R1)
Skip 2 If X>=0 \\ block if x<0 and y≥0
Skip 1 If Y<0
Add 180 To R1
Skip 2 If X>=0 \\ block if x<0 and y<0
Skip 1 If Y>=0
Subtract 180 From R1 \\ R1 = angle
Set X To R0 \\ Label (II) - r is now in register X
Set Y To R1 \\ angle is now in register Y, end of program


How to enter (x,y):
RPN Mode On: y, enter key, x, f(x) key, select Rect > Polar
RPN Mode Off: y, x~y key, x, f(x) key, select Rect > Polar

How to View Results:
RPN Mode On: r is displayed on the X stack, angle on the Y stack
RPN Mode Off: r is displayed, press the x~y key to get the angle

Example data (x,y):
y = 3, x = 3: r = 4.242640687, angle = 45
y = -4, x = 3: r = 5, angle = -53.13010235
y = 2, x = -2: r = 2.82842715, angle = 135
y = -3, x = -2: r = 3.60551275, angle = -123.6900675


My next blog entry will have several more example programs using PCalc.

Eddie


This blog is property of Edward Shore. 2014


Thursday, April 24, 2014

Greetings from Seattle - and a short review of the PCalc App. (Updated 4/28/2014)


I am in at the 1st Ave and Pike St Starbucks: the original Starbucks. Actually, the first one opened that first opened in 1971 moved to this location in 1976. The original Pike Place Brew is strong! Thankfully the coffee mellows after a while.

It is a dream of mine to blog from here. Thank you Starbucks! (Twitter: @starbucks)


Short Review of PCalc

This was recommend to me by bb010g. Thanks for the recommendation!

Prices:
PCalc Lite: Free (basic scientific calculator - Algebraic and RPN modes)
PCalc Full: $9.99 on iOS. (Includes Engineering functions, additional themes, conversions, programmer pack - base conversions and Boolean logic - each can be purchased separately)

Also available on Mac, but not available on Android devices.

Developer: James Thomson (Twitter: @jamesthomson)

I have the full version on both my iPad and iPod Touch. I like the intelligent layout of the keyboard, especially on the iPod Touch. The keys are big but you can still access all the major functions without much trouble. The choice of settings are plenty: everything from calculator settings to whether sound the keys make, if at all.

The features such as conversions, constants, and custom functions are accessed through the A>B, 42, and f(x) keys respectively. Each of the menus offers its options in a style consistent to standard iOS devices.

The calculator app has 10 memory registers and 16 other temporary registers that are used for programming. You can program custom functions. While the language does not contain loops, it does include relational testing (if true then skip n steps). Instead of working with the stack, you work with the memory and temporary registers, which takes a little getting used to. I hope to publish future posts explaining PCalc programming language in detail in the near future.

Here is a little sample of snippets I learned with the PCalc Programming:

The commands are constructed using proper English. (e.g. "Multiply M3 by M1", "Set R0 to 22/15")

Arithmetic Operators: Execute (add, subtract, multiply, divide) on a designated register with a certain value. The result is stored in the designated register.

Register X is the "display". Use this register to display your final answer. (Assuming your function has only one output).

To take the absolute value (on register X for example), execute the following steps:
Power X by 2
Power X by 0.5

PCalc is a great calculator app worth looking into. Website: http://www.pcalc.com

Update 4/28/2014:

Thanks to Terry for alerting me to this:  In Radians mode, cos(1.57079632) returned an answer of 6.7948967066 x 10^-9, which is not accurate.  Checking with Wolfram Alpha and with several calculators (HP 32Sii for example), cos(1.57079632) returns the correct answer of 6.7948966... x 10^-9.   Hopefully, this gets corrected in the next update.  

I checked cos(pi/2) and PCalc was accurate with answer of 0.

This ends my blog entry for now - off to see Seattle! Talk to you all soon! Thanks for the comments, recommendations, corrections, and compliments. As always, they are much appreciated.

Eddie


This blog is property of Edward Shore. 2014

RPN HP 12C: Fibonacci and Lucas Sequences

  RPN HP 12C: Fibonacci and Lucas Sequences Golden Ratio, Formulas, and Sequences Let φ be the Golden Ratio: φ = (1 + √5) ÷ 2...