Page 89

Petruzella_ProgrammableLogicControllers__5e

Ladder logic program Value_1 25 Value_2 25 Output Equal_PL Equal_PL <Local:2:O.Data.2> L2 EQU Equal Source A Source B Tag Name Value Style Data Type Equal_PL 1 25 25 Decimal Decimal Decimal BOOL DINT DINT -Value_1 -Value_2 Ladder logic program Value_1 10 Value_2 25 Not_Equal_PL <Local:2:O.Data.3> Ladder logic program Value_1 100 Value_2 300 Less_Than_PL <Local:2:O.Data.4> CMP Ladder logic program Compare Expression Value_1 = Value_2 378 Part 5  Math, Comparison, and Move Instructions Ladder logic program Value_1 1420 Value_2 1200 Greater_Than_PL <Local:2:O.Data.5> is slightly slower and uses more memory than the execution of the other comparison instructions. The advantage of the CMP instruction is that it allows you to enter complex expressions in one instruction. Figure 15-88 shows an example of a CMP instruction rung. In this example the comparison operator found in the expression is the equivalent of an EQU instruction. The comparison instruction is true because Value_1 (300) is equal to Value_2 (300). The program of Figure 15-89 is an example of the use of comparison instructions used to test the accumulated value of a counter. The operation of the program can be summarized as follows: • When the accumulated count is between 5 and 10 the GRT and LES instructions will both be logically true so the PL_1 pilot light will be on. • When the accumulated count is equal to 15, the EQU instruction will be logically true so the PL_2 pilot light will be on. • The PL_3 pilot light will be on at all times except when the accumulated count is 20 at which time the NEQ instruction is logically false. • The counter is reset automatically when the accumulated count reaches 25 or manually anytime the Reset_PB is actuated. Figure 15-84  EQU instruction rung and its Monitor Tags window. Figure 15-85  NEQ instruction rung. L2 Output NEQ Not Equal Source A Source B Not_Equal_PL Figure 15-86  LES instruction rung. L2 Output LES Less than (A<B) Source A Source B Less_Than_PL Figure 15-87  GRT instruction rung. L2 Output GRT Greater than (A>B) Source A Source B Greater_Than_PL Figure 15-88  CMP instruction rung. Equal_PL Equal_PL <Local:2:O.Data.2> L2 Output Tag Name Value Style Data Type Equal_PL 1 300 300 Decimal Decimal Decimal BOOL DINT DINT -Value_1 -Value_2


Petruzella_ProgrammableLogicControllers__5e
To see the actual publication please follow the link above