Download 82-0074-000--Manual, User`s
Transcript
Overall Sequence Here, the important things to note about this diagram are: · All algorithm referenced input channel values are stored in the Channel Input Buffer (Input Phase) BEFORE algorithms are executed during the Calculate Phase. · The execution of all defined algorithms (Calculate Phase) is complete BEFORE output values from algorithms, stored in the Channel Output Buffer, are used to update the output channel hardware during the Output Phase. 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; O116 = 22.3; O125 = O124; A Common Error to Avoid /* inp_val is assigned a value from input buffer element 8 */ /* output buffer element 16 assigned the value 22.3 */ /* output buffer [24] is read and assigned to output buffer [25] */ Since the "buffered input, algorithm execution, buffered output" sequence is probably unfamiliar to many, a programming mistake associated with it is easy to make. A common error is shown below and, it is hoped, that seeing this error will prevent its occurrence. O124.B0 = 1; /* digital output bit on VT1533A in SCP position 3 */ O124.B0 = 0; Traditionally, the first of these two statements is expected to set output channel 24, 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 Chapter 4 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 used as its input the value that any other algorithm has sent to the output buffer. In order for these features to be of use, the order in which the algorithms will be 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 run, they will execute in the order ‘ALG1,’ ‘ALG2,’ ‘ALG5,’ and ‘ALG8.’ For more on input and output value sharing, see “Algorithm to Algorithm Communication” on page 128. Creating and Running Custom Algorithms 121