Specifications

Data Types
The data type for variables is always static float. However, decimal constant values
without a decimal point or exponent character (“.”, “E” or “e”) as well as Hex and
Octal constants are treated as 32-bit integer values. This treatment of constants is
consistent with ANSI ‘C’. To understand what this can mean, it must be understood
that not all arithmetic statements in an algorithm are actually performed within the
VT1419A’s DSP chip at algorithm run-time. Where expressions can be simplified,
the VT1419A’s translator (a function of the driver invoked by ALG:DEF) performs
the arithmetic operations before downloading the executable code to the algorithm
memory in the VT1419A. For example, look at the following statement:
a=5+8;
When the VT1419A’s translator receives this statement, it simplifies it by adding
the two integer
constants (5 and 8) and storing the sum of these as the float constant
13. At algorithm run-time, the float constant 13 is assigned to the variable “a.” No
surprises so far. Now, analyze this statement:
a=(3/4)*12;
Again, the translator simplifies the expression by performing the integer divide for
3 / 4. This results in the integer value 0 being multiplied by 12 which results in the
float constant 0.0 being assigned to the variable “a” at run-time. This is obviously
not what was desired, but is exactly what the algorithm instructed.
These subtle problems can be avoided by specifically including a decimal point in
decimal constants where an integer operation is not desired. For example, either of
the constants in the division above were made into a float constant by including a
decimal point, the translator would have promoted the other constant toa float value
and performed a float divide operation resulting in the expected 0.75 * 12 or the
value 9.0. So, the statement:
a=(3./4)*12;
will result in the value float 9.0 being assigned to the variable “a.”
The Static Modifier
All VT11419A variables, local or global, must be declared as static. An example:
static float gain_var, integer_var, deriv_var; /* three vars declared */
In ‘C,’ local variables that are not declared as static lose their values once the
function completes. The value of a local static variable remains unchanged between
calls to an algorithm. Treating all variables this way allows an algorithm to
“remember” its previous state. The static variable is local in scope, but otherwise
behaves as a global variable. Also note, variables cannot
be declared within a
compound statement.
The Algorithm Language and Environment
Algorithm Language Reference
Chapter 4 125
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com