**Using and programming the Psion 1**
**Introduction**
Using the Organiser 1
Programming the Organiser 1
The POPL language
Before actually using the Psion organiser 1, I thought it
would be just like the series 2 only less so. Its design is similar, so it ought to have
similar software features too, just less memory, a smaller screen and fewer built-in menu
items. However it turns out to be a completely different animal. It is hardly an organiser
at all never mind a computer. It is more of a calculator with a few extra added bits. What
surprised me most is that although there is a clock, there is no built-in diary or alarm.
With this page I aim to do two things. It should serve as a mini manual for the
organiser 1 and its programming language POPL on the science pack. Also, it should give
some insight into how limited it is, and therefore show what an amazing achievement the
series 2 is.
When it is switched on by pressing the On/Clear key, it always displays its clock not a
menu. The clock has a time and date, but no year. It can be set at this point by using the
cursor keys to select a part of the clock, and the A key to advance that part. The clock
will keep running while setting it but it can be temporarily stopped by pressing B. When
finished, press On to return the organiser to normal functioning.
By repeatedly pressing the Mode key the various menu options are displayed one by one,
and the item can be activated by pressing the Execute key. Normally the menu only has the
items ENTER, CALC and OFF.
OFF: This obviously just switches the organiser off.
CALC: This is the calculator. It is an extremely basic one in comparison to that of the
series 2, though it works in a similar way. The only has the operands it has available are
+, -, * and /. Brackets can be used, but they can only be nested two levels deep. The
organiser uses numbers with only 7 significant digits, and an exponent between -99 and 99.
After entering a calculation and pressing Execute, an equals sign and the answer is placed
at the end of the line. You can then edit either the answer or the original string by
using the cursor keys. When using the Utils or Science packs the calculator is much more
like that of the series 2, because the packs provide the ** operator as well as most of
the mathematical functions.
ENTER: This allows you to just type information into the organiser. This option is
fairly useless unless you have a DataPak, because the organiser 1 does not have a pack
A:, its Ram is not used for storing data.
There are two buttons labeled FIND and SAVE. When you press SAVE during Enter or Calc,
then the prompt changes to SAVE1 or SAVE2, depending on which pack you want to save the
text of calculation on. By pressing FIND, you can search each of the packs in much the
same way as the series 2. When data is stored on a pack, it is slightly compressed by
using only 6 bits per character, a 25% saving.
The organiser 1 can only be programmed with the help of the Science pack. The ROM
simply does not contain any built in programming language, and it is the Science pack
that provides POPL (the Psion Organiser Programming Language). It is very limited in
scope as you will see later.
After the Science pack has been inserted, the main menu of the organiser has a few more
options: COPY, CAT, RUN, and PROG.
COPY: Allows you to copy a whole pack. This is also available on the Utils pack.
CAT: Lists a catalogue of procedure, much like the DIR function on the series 2.
RUN: Runs a procedure obviously.
PROG: Edits a procedure. You must supply it with a procedure name for this option to
work. The prompt changes to EDIT, and the first line is shown. You can select a line, and
edit its content using the cursor keys in the usual way. The Execute key does nothing
however, and to insert a line you have to press Mode until the INSRT prompt appears.
Pressing Mode also gives the prompts SAVE1 or SAVE2 for saving to a pack, EXIT for ending
the edit mode but saving the procedure in Ram, QUIT to stop without saving and ERASE for
deleting a procedure from a pack. If you exit, the procedure is saved in Ram temporarily
so you can test it out before saving to DataPak (using the Save option). If the program is
not saved to a pack it will be lost when the organiser switches off.
It is a very simple language, designed mainly for extending the calculator's capabilities.
Here is a short overview of the main characteristics:
- Each procedure can only be 200 bytes long. Internally, each line is compressed by
replacing every recognised POPL word by a single byte, so that helps a little.
- Procedures can call others, so that more complicated programs can be made up from many
small procedures. Procedure names are never followed by a colon.
- Procedures can return a number, so that they work as functions in the calculator.
Instead of RETURN, it uses an equals sign.
- Each line of a procedure contains at most one instruction (possibly preceded by a label)
- All variables are local and they have a single letter name, so there can only be 26
local variables in a procedure. They are all floating point variables, there are no
integers, strings or arrays.
- Procedures can have up to 5 parameters, which are always called P1 to P5.
- Instead of global variables or arrays, there are twenty memories which can be read and
assigned to by the RECALL and STORE instructions.
- The IF command is only used in combination with GOTO.
Here is a list of recognised POPL operators, functions and commands. Most of these are
the same or similar to those on the series 2:
Operators: **, >, <, =, >=, <=, <>, OR, AND, NOT
Commands: IF, IN, OUT, GOTO
Functions: LN, PI, ABS, ATN, COS, DEG, ENG, EXP, FAC, FIX, INT, LOG, MAX, MIN, MOD, RAD,
RND, SGN, SIN, ALOG, RAND, SQRT, MEAN, ROUND, STDEV, STORE, GETKEY, RECALL.
As you can see there is a drastic lack of commands. There is no file handling, very few
display and keyboard instructions, no date and time functions, and no string capability.
The Science pack provides the editing facilities and the language interpreter needed
for programming. All the functions and operators are also available in the calculator
while the Science pack is present. The Utility pack also provides ** and all the functions
above except for STORE, RECALL and GETKEY, but does not allow programming. It only
provides these for use in the calculator.
The operators are exactly the same as those of the series 2 when acting on floating
point numbers, except that a true condition has value 1. I'll quickly list the commands
and functions below:
IF |
Conditional jump. Always used in combination with GOTO,
for example IF A=1 GOTO LABEL |
IN |
Shows a text and allows the value of a variable to be entered.
For example IN A or IN "VALUE" A. The string is optional. |
OUT |
Displays a text and/or variable, and then waits for a key.
For example OUT A, OUT"VALUE="A or OUT"THE END". |
GOTO |
Jumps to the given label. When a label is defined, it must
be at the start of a line and followed by one colon. The label after a GOTO has no colon. |
LN |
Natural logarithm. |
PI |
The mathematical constant pi. |
ABS |
Absolute value. |
ATN |
Arc tangent. |
COS |
Cosine. |
DEG |
Converts an angle from radians to degrees. |
ENG |
Sets the engineering format mode. After ENG(1) all numbers
are displayed with an exponent which is a multiple of 3, so 0.56 is shown as 560E-3.
ENG(0) returns the display format to normal. The function returns the previous engineering
mode status. |
EXP |
Raises e to power of the given value. |
FAC |
Factorial, for example FAC(5) is 5*4*3*2*1=120. |
FIX |
Sets the decimal format to the given number of decimal
places. For example, after FIX(2) the numbers 23 and 0.125 are shown as 23.00 and 0.13.
Using FIX with a negative number switches off the fixed decimal point. The function
returns the previous decimal setting. |
INT |
Rounds downwards to an integer. |
LOG |
Base 10 Logarithm. |
MAX |
The maximum of the given numbers (up to 42 numbers) |
MIN |
The minimum of the given numbers (up to 42 numbers) |
MOD |
Modulo, the remainder after division, for example
MOD(19,8) is 3. |
RAD |
Converts an angle from degrees to radians. |
RAND |
Seeds the pseudo random number generator with the given
number. It also returns that same number as the result. |
RND |
Random number in given range. RND(5,20) gives a number
from 6 to 20 inclusive. |
SGN |
The sign of a number. |
SIN |
Sine. |
ALOG |
Antilog, raises 10 to power of the given value. |
SQRT |
Square root. |
MEAN |
The mean of the given numbers (up to 42 numbers) |
ROUND |
Rounds the number to the nearest integer. |
STDEV |
The standard deviation of the given numbers (up to 42
numbers) |
STORE |
Places a value in one of the 20 memories. For example
STORE(20,2.3) puts value 2.3 in memory number 20. It also returns the new value as the
value of this function. |
GETKEY |
Waits for a key and returns its ASCII value (Find=1, Save=2, Mode=3, Execute=5, Left=6, Right=7, Delete=8,
Shift=9) |
RECALL |
Returns the contents of the given memory, for example
A=RECALL(1) will put the contents of memory cell 1 into variable A. |
All of the functions are also available from the calculator. The memories used in STORE
and RECALL are cleared at the start of each calculation so they can not be used to
remember values from one calculation to the next. They can be used to remember a value
inside a single calculation, for example
CALC:STORE(1,1+2)+RECALL(1)=6
The Science pack has several procedures already built in.
The easiest way to show how POPL works is simply to show you some of these.
The FAHR procedure consists simply of one line:
=(P1-32)/1.8
This converts a temperature in Fahrenheit given as a
parameter into Celsius and returns that value. Instead of the series 2 RETURN command, an
equals sign is used. From the calculator or the RUN prompt you could type FAHR(50) for
example and you get FAHR(50)=10. If you don't use a parameter then P1 is assumed to be 0,
so FAHR gives FAHR=-17.77778.
A slightly more complicated example is ASN, the arc sine:
IF ABS(P1)=1 GOTO A
=ATN(P1/SQRT(1-P1*P1))
A:=P1*PI/2
Here you see how labels and IF statements are used.
The third and final example consists of two procedures. QUAD will solve a quadratic
equation.
Procedure:QUAD
I:IN"A="A
IN"B="B
IN"C="C
IF A GOTO Q
IF B=0 GOTO I
=-C/B
Q:QR(A,B,C)
Procedure:QR
A=2*P1
B=P2
C=B*B-2*A*P3
D=SQRT(ABS(C))
IF C<0 GOTO I
OUT"ROOT"(-B+D)/A
OUT"ROOT"(-B-D)/A
=0
I:OUT"REAL PART"-B/A
OUT"IMAGINARY PART"D/A
This illustrates how a procedure is called, the use of
variables, and how IN and OUT work.
The Science pack also provides several other procedures: 46 which simply return useful
scientific constants, 13 which convert units like the FAHR procedure above, and 12 further
programs:
QUAD |
Calculates the roots of a quadratic equation (shown
above). |
POLY |
Calculates the roots of a polynomial equation by iteration
using the quotient difference method. |
LINE |
Does line fitting. |
INTEGR |
Integrates a function when given a set of up to twenty
equally spaced values of a function. |
IMAGE |
Calculates the position of an image from a simple lens,
when given the focal length and distance from the object. |
FOCAL |
Calculates the focal length of a compound lens, when given
the focal lengths of the two simple lenses. |
LC |
Calculates the period of the natural oscillations in an LC
circuit, when given the inductance and capacitance. |
BOHR |
Calculates the energy levels of an atom when given the
atomic number and any principal quantum number. |
SPECTRA |
Calculates the frequency of atomic line spectra when given
the effective atomic number and the principal quantum numbers of the upper/lower energy
levels. |
LARMOR |
Calculates the frequency of an electron in a magnetic
field of the given strength. |
PLASMA |
Calculates the plasma frequency of an ionised electron gas
of the given electron density. |
BRAGG |
Calculates the separation of the atoms or scattering
centres in a lattice for successive orders of diffraction, given the wavelength and the
angle of diffraction. |
| |