Showing posts with label EC-4004. Show all posts
Showing posts with label EC-4004. Show all posts

Thursday, June 23, 2016

Programming with the Radio Shack EC-4004

Programming with the Radio Shack EC-4004

(Another milestone: this is blog #600! I can't thank you all enough!) 

To see my retro review of this calculator I did two years ago, click here:




The Radio Shack EC-4004 calculator’s programming mode is AOS (algebraic operating system).  Rarely you see a calculator with AOS any more (think the Casio fx-260 and Texas Instruments TI-30A), but it used to be prominent operating system with RPN.   In AOS, the uniary functions (trigonometric, logarithmic, factorial, for example) are entered after you enter the number.  Hence:  14 [ln] calculates ln(14) ≈ 2.639057329.

The storage of the EC-4004 is a mere 38 steps which can be distributed into two program slots.  That is not a lot.  Furthermore, if you enter numeric constants, each digit counts a step.  Remember, the display does NOT display the key, so be careful when entering programs.  There are a few program commands:

RTN ([INV] [ 9 ]):  Returns program control the first step (beginning). 

X ≤ M ([INV] [ 8 ]):  If the display is less than or equal to M, return to the first step.  Otherwise, go to the next step.

X > 0 ([INV] [ 7 ]): If the display is greater than 0, return to the first step.  Otherwise, go to the next step.

ENT ([RUN] in learn mode):  Prompt for a number.  The next step is to put a “placeholder” number as long as it will be valid in calculations.  Since each digit counts as a step, try to use placeholder numbers like 0, 1, or 2.  I’m not sure if the placeholder number is merged with ENT.  You can instead, use Kin or Min to store the entry in memory.

HLT ([INV] [RUN]): Halts the program to display immediate results.  Think of it as the PAUSE command.

X<>K ([INV] [Kout]): Exchange with a memory register.  The EC-4004 has six memory registers, plus one additional independent memory register (M).

[Kin] and [Kout] is your store and recall, respectively.

On to the list of sample programs!  Anything after double slashes (\\) is a comment. The hashtag (#) stands for placeholder number.

Area of a Regular Polygon

Formula:  (n*s^2)/(4*tan(180°/n)), n = number of sides, s = side length

MODE,  4 \\ sets Degree mode
ENT \\ prompt for n
#  \\ enter a placeholder number
Min \\ store in M
*
ENT \\ prompt for s
#  \\ placeholder number
X^2
÷
(
4
*
(
180
÷
MR \\ recall n
)
TAN
)
=

Test 1:  n = 6, s = 2.6,  result 17.56299519
Test 2:  n = 10, s = 3.87, result 115.2353964

 Sum of f(x)

In particular, Σ x^2 + 1 from x = 1 to M.  M is the upper limit.  You can adapt this to include any f(x), but remember you’ll only have 26 steps to work with for f(x).  Your variable for f(x) is register 1 (use [Kout], 1)

Before running, store the upper limit minus 1 in M, 0 in both registers 1 and 2.  (0, [ Kin ], 1; [ Kin ], 2).  Register 1 is your counter, register 2 is your sum.   In Summary:

M = upper limit – 1, Register 1 = 0, Register 2 = 0

Kout 1  \\ recall register 1 and add one
+
1
=
Kin 1
X^2 \\ f(x) starts here
+
1
=   \\ end f(x) with equals
+   \\ add result to register 2
Kout 2
=
Kin 2
Kout 1 \\ put register 1 in the display
X≤M   \\ is X≤M? If so, go to the beginning
Kout 2 \\ display sum

Test 1:  If the upper limit is 5, store 4 in M.  Result:  60
Test 2:  If the upper limit is 8, store 7 in M.  Result:  212

Payment of a Loan (with no balloon)

Formula:  PMT = PV / ((1 – (1 + r)^-n)/r)

Store the following amounts before running:
K1 = PV, present value or loan amount
K2 = n, number of payments.  Example: For 30 years for monthly payments, store 360 in K2.
K3 = r, periodic interest rate as a decimal.  Example: For 6% compounded monthly, enter 0.06/12 in K3.


Kout 1 \\ recall PV
÷
(
(   
1
-
(
1
+
Kout 3  \\ recall r
)
X^Y
Kout 2 \\ recall n
+/-
)
÷
Kout 3
)
=


Test 1:  K1 = 200,000, K2 = 360, K3 = 0.055/12.  Result:  1,135.58
Test 2:  K1 = 234,000, K2 = 360, K3 = 0.038/12.  Result:  1,090.34

Easy Traverse Calculation

Calculates the new point knowing the original coordinates, direction, and angle of travel.  The angle 0° comes from due east and rotates counterclockwise (see diagram below). 



Store before hand:
K1 = original coordinate easting (E, x)
K2 = original coordinate northing (N, y)

Distance is stored in K3 and angle is stored K4.  At the completion of the program, the new coordinates are stored in K1 and K2, respectively, to allow chain calculations.

MODE 4 \\ degrees mode
Kout 1
+
ENT \\ prompt for distance
# \\ placeholder number
Kin 3
*
ENT \\ prompt for angle
# \\ placeholder number
Kin 4
COS
=
Kin 1
HLT \\ display new easting coordinate
Kout 2
+
Kout 3
*
Kout 4
SIN
=
Kin 2 \\ display new northing coordinate


Test:  E0 = 10,000,  N0 = 10,000
Given distance = 110, angle = 126°,  E1 ≈ 9,935.343, N1 ≈ 10,088.992
Continuing,
Given distance = 150, angle = 30°, E2 ≈ 10,065.247, N2 ≈ 10,163.992

Measuring Dew Point (in degrees Celsuis)

W = 237.3 * V/(1 – V)
V = (ln H + (17.27*C)/(237.3+C))/17.27

Where:
H = relative humidity, store as a decimal (Example:  for 55.8% store 0.558 in K1)
C = temperature in degrees Celsius

Store before hand:  H in register 1 (K1), C in register 2 (K2). 

This program illustrates a perfect example of the effect of the limited programming space.  During the calculation, 17.27 and 237.3 are stored in K3 and K4, respectively to save program space.  And believe me, we’ll need every bit of it.

Kout 1 \\ H
LN
+
17.27
Kin 3
*
Kout 2 \\ C
÷
(
237.3
Kin 4
+
Kout 2
)
=
÷
Kout 3
Min // store V in M
*
Kout 4
÷
(
1
-
MR
)
=

Remember K1 = H, K2 = C
Test 1:  H = 51% (0.51), C = 27°C, Result ≈ 16.0003°C
Test 2:  H = 46% (0.46), C = 85°F = 29.44444444°C, Result ≈ 16.6110°C

Chebyshev Polynomial of the First Kind, for -1<x<1

Formula for -1<x<1:  T_n(x) = cos(n * acos x)   (source: Wolfram, http://mathworld.wolfram.com/ChebyshevPolynomialoftheFirstKind.html, see line 44)

ENT \\ prompt for x
#  \\ placeholder number
COSˉ¹
*
ENT \\ prompt for n
#  \\ placeholder number
=
COS

Test 1:  T_2(0.25) = -0.875  (x = 0.25, n = 2)
Test 2:  T_3(-0.68) = 0.782272  (x = -0.68, n = 3)

That is a small collection of programs for the EC-4004.  If you want me to do more, let me know.  Until then, have a great day everyone and stay safe!

Eddie

This blog is property of Edward Shore, 2016



Sunday, September 14, 2014

Retro: Radio Shack EC-4004

I recently purchased two calculators from https://www.devicegoround.com:

* Casio fx-115D SUPER-FX (talked about this in a previous post) and
* Radio Shack EC-4004

The EC-4004 is similar to the Casio fx-3600P, both manufactured beginning in 1981. The EC-4004 is battery powered taking two smaller-sized button batteries. (Currently it is running on LR-1130 and Radio Shack carries equivalent sized batteries.)


In addition to the independent memory (M), the EC-4004 has six additional memory registers. The Kin key stores the number into one of the six registers, which the Kout key is the recall key. In spite of its manual not mentioning this, the EC-4004 supports storage arithmetic.

Storage Arithmetic:

Let # represents registers 1 through 6:

Add x to #: x [ Kin ] [ + ] #
Subtract x from #: x [ Kin ] [ - ] #
Multiply x to #: x [ Kin ] [ × ] #
Divide #/x: x [ Kin ] [ ÷ ] #


Features:

* Single Variable Statistics and Linear Regression

* Programming including integrals

* Fractions. Kind of limited, you can enter fractions in operations and get answers in fractions (simplest form). Once a number in decimal form is entered, the result will be in decimal form. No converting from fractions to decimal feature is present, either.

* ENG and <-ENG key. These represent a number in different ways:

ENG: decreases the exponent part by 10^3, multiplies the mantissa by 1000
<-ENG: increases the exponent part by 10^3, divides the mantissa by 1000

Example: 23400 [ = ]
[ ENG ] (23.4 x 10^3)
[ ENG ] (23400 x 10^0)
[ ENG ] (23400000 x 10^-3)

23400 [ = ]
[ <-ENG ] (0.0234 x 10^6)
[ <-ENG ] (0.0000234 x 10^9)
[ <-ENG ] (0.0000000234 x 10^12)

Operating System

The operating system is AOS (Algebraic Operating System). I realize that AOS is a Texas Instruments term, however, it applies here. Simply put, any one-argument function (e^x, trig, log) are pressed after the number is entered. Example:

ln 2431.74 is calculated as 2431.74 [ ln ] (Result: 7.796362329)


Programming

Learn Mode: Mode 0, press [ P1 ] or [ INV ] [ P1 ] for P2.
Run Mode: Mode Decimal Point ( . ). Execute programs by pressing [ P1 ] or [ INV ] [ P1 ] for P2.

Memory: 38 steps, fully-merged
Number of Program Slots: 2

Not a lot of room, but it is handy for storing quick calculations. You have to be real precise in entering keystrokes because there are no editing features. We do have some tools in programming mode:

[ RUN ] (ENT): Acts as a stop, which will prompt the user to enter numbers. A program stopped midway has an ENT indicator. In run mode, the [ RUN ] continues program execution.

You can use [ RUN ] in programming mode prior to entering number (acts a placeholder). The number itself will not be stored as a step. This is important as programs may not run correctly without this step. Make sure that the placeholder numbers used make the calculations valid for each step!

x > 0 ( [ INV ] [ 7 ] ): Tests the number in the display. If the number is greater than zero, control goes back to the beginning. Execution stops.

x ≤ M ( [ INV ] [ 8 ] ): Tests whether the number in the display is equal to or less than what is stored in the independent Memory M. If the test is true, return to the beginning of the program. Execution stops.

RTN ( [ INV ] [ 9 ] ): Stops execution and returns to the beginning of the program.

[ INV ] [ MODE ]: is the clear program command. This is extremely important to do before starting any new problems.

Mode 1 is the Integral mode. Use P1 or P2 as the function. According to the manual, start going into Learn mode. Begin the program by pressing (number if needed) [ INV ] [ MR ] (Min). Use [ MR ] for the independent variable. End the function with [ = ]. Go into Mode 1, press P1 or P2, then lower limit, [ RUN ], upper limit, [ RUN ]. The EC-4004 stores the following in its registers:

1: lower limit
2: upper limit
3: subdivisions (store by INV RUN)
4: f(lower limit)
5: f(upper limit)
6: numeric integral

Sample Programs

Area of an Ellipse

A = π * a * b

Mode 0, P1: I am using 1 as placeholders.
ENT ( [ RUN ] key) 1
[ × ]
ENT 1
[ × ]
[EXP] key for π
[ = ]
RTN

Run P1: enter a, press [ RUN ], enter b, press [ RUN ], get the area.
Press [ AC ] to leave execution mode.

Examples:
a = 6, b = 3, Area = 56.54866776
a = 3, b = 8.1, Area = 76.340707148

Discriminant Tester

Here is a program where the placeholder numbers are important - all steps must count as valid.

Program: Calculate b^2 - 4ac. If positive, calculate its square root. If not, return to the beginning of the program and display 0.

Use the x ≤ M test.

I used P2 for this example:
0
[ INV ] [ MR ] (Min)
ENT 8
[ INV ] [ +/- ] x^2
[ - ]
4
[ × ]
ENT 3
[ × ]
ENT -2
[ = ]
[ INV ] [ RUN ] (HLT)
[ INV ] [ 8 ] x≤M (x ≤ 0?)
[ INV ] [ ( ] ( √ )


Note the order of entry: b, a, c

Examples:
b = 8, a = 3, c = -2. Results: 88, 9.38083152.
b = 1, a = 1, c = 7. Results: -27, 0. Press [ AC ]

Integral: an example

Calculate ∫ x * e^x dx from x =1 to x = 2. Use P1.

Keystrokes:

Enter the function:
[ MODE ] [ 0 ] (LRN)
[ P1 ]
[ INV ] [ MR ] (Min)
[ MR ]
[ × ]
[ MR ]
[ INV ] [ ln ] (e^x)
[ = ]

Enter integration mode:
[ MODE ] [ 1 ] ( ∫dx is displayed)
[ P1 ]
1 [ RUN ] 2 [ RUN ]

Approximate Result: 7.38906 x 10^0 (7.38906)

Source: "Programmable EC-4004 Scientific Calculator Owner's Manual" Radio Shack, 1981.




This may be my last blog entry before I head to Reno, NV, next weekend. I am going to the HHUC (HP Handhelds User Community) 2014 conference, http://hhuc.us/2014/index.htm . I plan to blog about some of the highlights of the conference in a future blog post. Until then, take care and thanks for your subscriptions, comments, and questions.

Eddie


This blog is property of Edward Shore. 2014

HP 20S: Acoustics Programs

HP 20S: Acoustics Programs Program A: Speed of Sound in Dry Air cs = 20.05 × √(273.15 + T°C) Code: 01: 61, 41, A: LBL A 02: ...