Page 87

Petruzella_ProgrammableLogicControllers__5e

Ladder logic program DIV Divide Source A Source B Dest 5 3 Answer_Real 1.6666666 Calculate Tag Name Value Style Data Type Calculate Answer_Real 1 1.6666666 Decimal Float BOOL REAL The DIV instruction is used to divide two numbers. Figure 15-81 shows an example of a DIV instruction rung along with its Monitor Tags window. The operation of the rung can be summarized as follows: • A constant (5) is used for Source A and a constant  (3) for Source B. Note that tags could have been used for Source A or Source B. • When the Calculate tag is true the DIV instruction is executed. • Source A (5) is divided by Source B (3) and the result (1.6666666) is stored in the Dest tag Answer_ Real. Note that in this example a Real-type tag has been used for its destination. The program of Figure 15-82 is used as part of a parts tracking system with three conveyors. The number of parts in conveyor 1 and the number of parts in conveyor 2 are added to get the number of parts on conveyor 3. The operation of the program can be summarized as follows: • Each time Conveyor_1_Sensor is actuated the accumulated value of Counter_1_Parts is incremented by 1. • Each time Conveyor_2_Sensor is actuated the accumulated value of Counter_2_Parts is incremented by 1. • The addition in the ADD instruction places the sum of the accumulated values of the two counters in the Conveyor_3_Parts tag. • When the accumulated value for either counter is equal to 150 the reset (RES) instructions for both counters are enabled to automatically reset both counter ACC values to zero. 376 Part 5  Math, Comparison, and Move Instructions • Both counters can also be reset manually at any time by actuation of the Manual_Conveyor_Reset button. Comparison Instructions Compare instructions are used to compare two values. They can be used to see if two values are equal, if one value is greater or less than the other, and so on. In ControlLogix controllers, compare instructions are input instructions that do comparisons by either using an expression or doing the comparison indicated by the specific instruction. Figure 15-83 shows the Compare toolbar for the ControlLogix controller. The equal (EQU) instruction is used to test if two values are equal. Values compared can be actual values or tags that contain values. Figure 15-84 shows an example of an EQU instruction rung along with its Monitor Tags window. The operation of the rung can be summarized as follows: • The value stored at Source A is compared to the value stored at Source B. • If the values are equal, the instruction is logically true. • If the values are unequal, the instruction is logically false. • In this example Source A (25) is equal to Source B (25) so the instruction is true and output Equal_PL is on. • Source A and Source B may be SINT, INT, DINT, or REAL data types. The not equal (NEQ) instruction is used to test two values for inequality. Figure 15-85 shows an example of an NEQ instruction rung. When Source A is not equal to Source B, the instruction is logically true; otherwise, it is logically false. In this example the two values are not equal so the Not_Equal_PL is energized. The less than (LES) instruction is used to check if a value from one source is less than the value from a second source. Figure 15-86 shows an example of an LES instruction rung. When Source A is less than Source B, the instruction is logically true; otherwise, it is logically false. In this example Value_1 (100) is less than Value_2 (300) so the Less_Than_PL is energized. The greater than (GRT) instruction is used to check if a value from one source is greater than the value from a second source. Figure 15-87 shows an example of a GRT instruction rung. When Source A is greater than Source B, the instruction is logically true; otherwise, Figure 15-81  DIV instruction rung and its Monitor Tags window.


Petruzella_ProgrammableLogicControllers__5e
To see the actual publication please follow the link above