14.2.1 Comparison of Values[an error occurred while processing this directive]
Comparison functions are shown in Figure 14.15 Comparison Functions. Previous function blocks were outputs, these replace input contacts. The example shows an EQU (equal) function that compares two floating point numbers. If the numbers are equal, the output bit light is true, otherwise it is false. Other types of equality functions are also listed.
The example in Figure 14.16 Comparison Function Examples shows the six basic comparison functions. To the right of the figure are examples of the comparison operations.
The ladder logic in Figure 14.16 Comparison Function Examples is recreated in Figure 14.17 Equivalent Statements Using CMP Statements with the CMP function that allows text expressions.
Expressions can also be used to do more complex comparisons, as shown in Figure 14.18 A More Complex Comparison Expression. The expression will determine if B is between A and C.
The LIM and MEQ functions are shown in Figure 14.19 Complex Comparison Functions. The first three functions will compare a test value to high and low limits. If the high limit is above the low limit and the test value is between or equal to one limit, then it will be true. If the low limit is above the high limit then the function is only true for test values outside the range. The masked equal will compare the bits of two numbers, but only those bits that are true in the mask.
Figure 14.20 A Number Line for the LIM Function shows a numberline that helps determine when the LIM function will be true.
File to file comparisons are also permitted using the FSC instruction shown in Figure 14.21 File Comparison Using Expressions. The instruction uses the control word c_0. It will interpret the expression 10 times, doing two comparisons per logic scan (the Mode is 2). The comparisons will be f<f, f<f then f<f, f<f then f<f, f<f then f<f, f<f then f<f, f<f. The function will continue until a false statement is found, or the comparison completes. If the comparison completes with no false statements the output A will then be true. The mode could have also been All to execute all the comparisons in one scan, or Increment to update when the input to the function is true - in this case the input is a plain wire, so it will always be true.
14.2.2 Boolean Functions[an error occurred while processing this directive]
Figure 14.22 Boolean Functions shows Boolean algebra functions. The function shown will obtain data words from bit memory, perform an and operation, and store the results in a new location in bit memory. These functions are all oriented to word level operations. The ability to perform Boolean operations allows logical operations on more than a single bit.
The use of the Boolean functions is shown in Figure 14.23 Boolean Function Example. The first three functions require two arguments, while the last function only requires one. The AND function will only turn on bits in the result that are true in both of the source words. The OR function will turn on a bit in the result word if either of the source word bits is on. The XOR function will only turn on a bit in the result word if the bit is on in only one of the source words. The NOT function reverses all of the bits in the source word.