CalcEd - a Complex Calculating Editor

last updated in September 2006 (new functions, 8 plotter channels)

Main site: http://freenet-homepage.de/dl4yhf/calc_ed.html

Backup site, very slow sometimes: www.qsl.net/dl4yhf/calc_ed

What is "CalcEd" ?

On the first glance, CalcEd looks like a simple text editor. It handles large files (>64k) and rich text files (*.RTF). But its main purpose is: CALCULATING ! You can use it for step-by-step calculations, and save all steps in a simple textfile.

This information is copied from CalcEd's manual, it may be quite outdated (you will find a more up-to-date manual in the zipped archive, along with the executable).

You can download CalcEd from this site (see end of this document).


Basic operation as calculator

To calculate a formula, simply enter it in a new text line like this:

1+2

Then, with the cursor still in the line of the formula, press F7 (or use the "Calculate" menu, or shift-ENTER to produce the next line). When a (normal) formula is be calculated, the result is "printed" into the same text line like this:

1+2 =: 3

The "= :" token (without the space) is a keyword, which shows CalcEd that a line is a "formula" which must be re-calculated when you press F9 (to update all results). Be careful not to use this token in "normal" text which shall not be affected by F9 = "Re-Calculate All".

This is all you have to know to use CalcEd for simple calculations !


Examples: Resonant frequency of an L/C tank circuit (inductor and capacitor)

1/(2*pi*sqrt(1.36mH*1nF)) =: 136474
1/((2*pi*136.5kHz)^2*1nF) =: 0.00135949

Notes

  • CalcEd accepts "technical" exponents (powers of ten like p="pico", n="Nano", m="Milli", ... M="Mega" .
  • There must not be a space character between the number and the exponent, no matter if mathematical ("1.23E-6") or technical ("1.23uF", see below) .
  • Americans beware: "m" is NOT MEGA, it's milli ! 14 mHz is a strange frequency for a ham radio transmitter ;-)

A physical dimension may be appended directly after a "technical" exponent, like pF="picofarad", kOhm="kilo-ohm" etc. The physical dimensions are skipped, you can use them for clarity. CalcEd will happily add apples and pears if you want it to.

You can use the result from one calculation in the next calculation. The underscore character (_) is the token for a variable which holds the last result.


1+1 =: 2
_*_ =: 4
_*_ =: 16
_*_ =: 256
_*_ =: 65536

The underscore as placeholder for the "last result is the easiest way to do step-by-step calculations.

Numeric Variables and Functions

For better clarity, variables can be used. Variables always begin with a capital letter (to tell them from built-in functions):

R1 := 1+2+3 =: 6
L1 := 1.36mH =: 0.00136
C1 := 1.0nF =: 1e-09

Note: Unlike many programming languages, you don't have to declare a variable. You just use it and it begins to exist !

To assign a new value to a variable, use the operator symbol ":=" in the formula, and calculate it with F7 (or shift-return).

If you don't want to see the result in that line, enter the "at"-sign in the first colum. The editor will see that this line contains some kind of command, and that it's neither normal text nor a normal formula.

@X1 := 10
@X2 := 20
X1+X2 =: 30

Complex Numbers

Important about CalcEd (at least for its author) is, it calculates with complex values. This helps a lot to calculate electric AC networks, where its sometimes tricky to calculate the phase shift from inductors and capacitors. Even the frequency response of a complex networks can be calculated this way, without the necessity to solve linear equations (see the "bandpass"-example in the CalcEd archive).

Complex values are noted as a sum of real and imaginary part.

Here we simply add two complex numbers (parenthesis just for clarity):

(1 + j*2) + (2+3*j) =: 3 + j* 5

Many (but not all) of CalcEd's internal functions support complex values:

sqrt(-2) =: 8.66311e-17 + j*1.41421
_*_ =: -2 + j*2.4503e-16

(Note the rounding problem!)

sqrt(1+j) =: 1.09868 + j*0.45509
_*_ =: 1 + j* 1

exp(1) =: 2.71828
exp(j) =: 0.540302 + j*0.841471
exp(1+j) =: Nur imaginaerer Exponent zur Basis e.

Notes:
e is the "natural number" 2.718... , and exp(x) is "e power x" .
The error messages may have been translated into English by the time you read this.

Parallel resistors (or impedances) in electric circuits

Because connecting two resistors in parallel is a common task in the electronic business, there is a special "parallel" operator in CalcEd (the two parallel "pipes").

Note:
"C" programmers please take care, || is not the "boolean or" !

Examples:

R1 || R2 =: 40
30 || 30 || 30 =: 10

This also works for complex values:

(1+2*j)||(3+4*j) =: 0.769231 + j*1.34615
(3+3j)||(3+3j)||(3+3j) =: 1 + j* 1


Built-in functions and other syntax elements

A list of all supported operators and functions is in the manual, which is part of the downloadable archive. A short reference of the built-in functions can be displayed through CalcEd's 'Help'-menu.

Outside the body of a self-defined function, commands must be preceeded with the ampersand character ("at"-sign, @), so CalcEd can see that a line contains a command, function call, or similar.

You can type 'normal' text between the calculations for documentation (or remarks). This may change in a future version(*) of CalcEd: Within sections of classic program code (with loops, branches, etc) it will be necessary to put remarks into comment sections like the following:

/* This is, and will ever be, a comment */
// This is also a comment, C++ style
REM This is a comment too, stoneage BASIC style

(*) In fact, there is a CalcEd-variant with a tiny programming language built inside. But it's too early to be spread around..


Function plotter

There is a simple function plotter in CalcEd which can be invoked with this command:

@plot(<feeder>:=<start_value>..<end_value>,<function1>[,<function2>] [,...] )

where
<feeder> is the name of a variable for the X-axis (often "X"),
<start_value> is the first value (for the start of the X-axis),
<end_value> is the last value (for the end of the X-axis)
<function1> is the name or the definition of the first function to be plotted (or a 'calculated' variable like "Y"),
<function2>..<function8> are optional functions which can be plotted into the same diagram window.

Examples:
@plot(X:=-pi..pi,sin(X),cos(X))
@plot(X:=0..400,sin(X)/(X+10))

Note: During the execution of the "plot" command, the whole document is calculated over and over, so it takes some time. Assignments to <feeder> (here: X) are suppressed during the calculation.

A more sophisticated example for the plotter can be found in the file "coupled_bandpass.txt" . It calculates and plots the amplitude- and phase response as function of frequency for a bandpass made of loosely coupled tank circuits: The command...

@plot(F:=135kHz..138kHz,20*log(A2),ang(U2)*180/pi)

... opened this plot window with the amplitude- and phase response of a simulated bandpass filter:




Disclaimer and Download

I hate this legal stuff, but here it comes again:

The author provides this software "AS IS" without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose.

The entire risk as to the quality and performance is with you. In no event unless required by applicable law will the author and/or any other party who may modify and/or redistribute this software be liable to you for damages, including any lost profits, lost monies, or other special, incidental or consequential damages arising out of the use or inability to use this package, or for any claim by any other party.

This program is still "under construction", and there are certainly a number of bugs lurking in the code. The entire risk is with you. You may find udates at the DL4YHF website (search for DL4YHF CalcEd) . User feedback is welcome !

If you have a good reason why you need the ugly sourcecodes, please ask (for non-profit use only!). CalcEd is written in "pure C" without using a toolbox (neither MFC,VCL,CLX or whatever).

Download CalcEd (executable and manual) from here:

calc_ed.zip

To install, just unpack the executable and the manual from the zipped archive into a directory of your choice. No extra DLL's are required in the current version of CalcEd. At the moment, CalcEd runs under Win95-98-XP. A Linux compilation may be available one fine day ;-)

Author: Wolfgang Buescher. Mail: On my main website.

Back to the main site