Specifications
In other words, algorithms don’t actually read inputs at the time they reference
input channels and they don’t send values to outputs at the time they reference
output channels. Algorithms read channel values from an input buffer and write
(and can read) output values to/from an output buffer. Here are example algorithm
statements to describe operation:
inp_val = I108; /* inp_val is assigned a value from input buffer element 8 */
O137 = 22.3; /* output buffer element 37 assigned the value 22.3 */
O133 = O132; /* output buffer [32] is read and assigned to output buffer [33] */
A Common
Error to Avoid
Since the “buffered input - algorithm execution - buffered output” sequence is
probably not a method many are familiar with, a programming mistake associated
with it is easy to make. It is hoped that, once seen here, that it will not be
duplicated. The following algorithm statements will help explain:
O156.B0 = 1; /* digital output bit on VT1533A in SCP position 3 */
O156.B0 = 0;
Traditionally, the first of these two statements is expected to set output channel 56
bit 0 to a digital 1, then, after the time it takes to execute the second statement, the
bit would return to a digital 0. Because both of these statements are executed
BEFORE any values are sent to the output hardware, only the last statement has any
effect. Even if these two statements were in separate algorithms, the last one
executed would determine the output value. In this example the bit would never
change. The same applies to analog outputs.
Algorithm
Execution Order
The buffered I/O sequence explained previously can be used advantageously.
Multiple algorithms can access the very same buffered channel input value without
having to pass the value in a parameter. Any algorithm can read and use the value
that any other algorithm has sent to the output buffer as its input. In order for these
features to be of use, the order in which the algorithms are executed must be
known. When algorithms are defined, they are given one of 32 pre-defined
algorithm names. These range from ‘ALG1’ to ALG32’. The algorithms will
execute in order of its name. For instance, if ‘ALG5’ is defined, then ‘ALG2,’ then
‘ALG8’ and finally ‘ALG1,’ when they are run, they will execute in the order
‘ALG1,’ ‘ALG2,’ ‘ALG5,’ and ‘ALG8.’
Defining Algorithms (ALG:DEF)
This section discusses how to use the ALG:DEFINE command to define
algorithms. Later sections will discuss “what to define”.
ALG:DEFINE in the
Programming
Sequence
*RST erases all previously defined algorithms. All algorithms must be erased
before they re-defined (except in the special case described in “Changing an
Algorithm While it’s Running” later in this section).
The Algorithm Language and Environment
Defining Algorithms (ALG:DEF)
116 Chapter 4
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com










