8.5
User-Defined Computation
In addition to the built-in computation files, users can define their own equations.
User-defined computations can be carried out similarly to built-in computations by
creating definition files using a text editor or the like on your PC and placing the files in
the MATH directory on the GS820ROM.
Notation Used in User-Defined Computation
Definition files are text files. They are written using statements that are similar to those
used in the programming language BASIC.
For example, to perform a computation that multiplies the measured value by 1.25 and
subtracts 0.75, we write the following statement in the file.
ML = ML * 1.25 − 0.75
ML is a built-in variable that represents the measured value. By substituting a value in
this variable, you can manipulate the measured value. In addition to built-in variables,
there are variables that can be used freely. These variables allow past measured values
in computations.
For example, statements that determine the average of the last two measured values
can be written in a file as follows:
Y = (X + ML)/2 // Substitute the result of summing the previous value (variable X)
and the present value and dividing by 2 into variable Y
X = ML // Substitute the measured value into variable X
ML = Y // Substitute variable Y into the measured value
X and Y are variables that users can use freely. Variables are held until the GS820 is
turned OFF. As shown above, statements written in multiple lines are evaluated in order
from the top. In the above example, the initial value of variable X is undefined causing
the first result to be a undefined value. To prevent this from happening, we will show an
example in which NAN (Not A Number) is substituted in the initial value of variable X.
if (J==0) then X = NAN
// If first time, substitute NAN into variable X
Y = (X + ML)/2
// Substitute the result of summing the previous value
(variable X) and the present value and dividing by 2
into variable Y
X = ML
// Substitute the measured value into variable X
ML = Y
// Substitute variable Y into the measured value
Here, J is a built-in variable that represents a counter whose initial value is zero when the
output is turned ON and incremented by 1 each time a measurement is completed. This
built-in variable J is used to evaluate if the computation is being performed for the first
time. The statement is written so that if it is the first time, NAN is substituted into variable X.
As can be seen from the above example, an if statement can be written in an statement.
An if statement evaluates true or false based on the following logic.
True: Not 0
False: 0
The equality operator (==) used in the statement returns 1 if the right side is equal to the
left side and 0 if not. In addition, there are two types of if statements.
if
conditional expression
then
a statement to be executed if true
if
conditional expression
then
a statement to be executed if true
else
a statement to
be executed if false
8-8
IM 765601-01E