Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 11 © 2011, The McGraw-Hill Companies, Inc.

Similar presentations


Presentation on theme: "Chapter 11 © 2011, The McGraw-Hill Companies, Inc."— Presentation transcript:

1 Chapter 11 © 2011, The McGraw-Hill Companies, Inc.

2 11.1 Math Instructions © 2011, The McGraw-Hill Companies, Inc.

3 The PLC’s math functions capability allows it to perform arithmetic functions on values.
Addition - The capability to add one piece of data to another. Subtraction - The capability to subtract one piece of data from another. Multiplication - The capability to multiply one piece of data by another. Division - The capability to divide one piece of data by another. © 2011, The McGraw-Hill Companies, Inc.

4 When the CPT (compute) instruction is executed, then copy, arithmetic, logical, or conversion operation residing in the expression field of this instruction is performed and the result is sent to the destination. © 2011, The McGraw-Hill Companies, Inc.

5 11.2 Addition Instruction © 2011, The McGraw-Hill Companies, Inc.

6 The ADD instruction performs the addition of two values stored in the referenced memory locations.
© 2011, The McGraw-Hill Companies, Inc.

7 Simulated ADD instruction rung.
© 2011, The McGraw-Hill Companies, Inc.

8 Counter program that uses the ADD instruction.
© 2011, The McGraw-Hill Companies, Inc.

9 Simulated counter program.
© 2011, The McGraw-Hill Companies, Inc.

10 Carry (C) - Address S2:0/0, is set to 1 when there is
The arithmetic status bits for the SLC 500 are found in word 0, bits 0 to 3 of the processor status file S2. Carry (C) - Address S2:0/0, is set to 1 when there is a carry in the ADD instruction or a borrow in the SUB instruction. Overflow (O) -Address S2:0/1, is set to 1 when the result is too large to fit in the destination register. Zero (Z) - Address S2:0/2, is set to 1 when the result of the subtract instruction is zero. Sign (S) - Address S2:0/3, is set to 1 when the result is a negative number. © 2011, The McGraw-Hill Companies, Inc.

11 Subtraction Instruction
11.3 Subtraction Instruction © 2011, The McGraw-Hill Companies, Inc.

12 The subtract instruction subtracts source B from source A and stores the result in the destination.
© 2011, The McGraw-Hill Companies, Inc.

13 Simulated SUB instruction rung.
© 2011, The McGraw-Hill Companies, Inc.

14 Vessel overfill alarm program.
© 2011, The McGraw-Hill Companies, Inc.

15 Simulated vessel overfill alarm program.
© 2011, The McGraw-Hill Companies, Inc.

16 Multiplication Instruction
11.4 Multiplication Instruction © 2011, The McGraw-Hill Companies, Inc.

17 The multiply instruction multiplies two values and stores the result in the destination address.
© 2011, The McGraw-Hill Companies, Inc.

18 Simulated MUL instruction rung.
© 2011, The McGraw-Hill Companies, Inc.

19 MUL instruction program used to calculate the product of two sources.
© 2011, The McGraw-Hill Companies, Inc.

20 Simulated MUL instruction program used to calculate the product of two sources.
© 2011, The McGraw-Hill Companies, Inc.

21 The MUL instruction used as part of a temperature control program.
© 2011, The McGraw-Hill Companies, Inc.

22 11.5 Division Instruction © 2011, The McGraw-Hill Companies, Inc.

23 The division instruction divides the value in source A by the value in source B and stores the result in the destination address. © 2011, The McGraw-Hill Companies, Inc.

24 Simulated DIV instruction rung.
© 2011, The McGraw-Hill Companies, Inc.

25 DIV instruction used to calculate the value that results from dividing source A by source B.
© 2011, The McGraw-Hill Companies, Inc.

26 Simulated DIV instruction program.
© 2011, The McGraw-Hill Companies, Inc.

27 Program for converting Celsius temperature to Fahrenheit.
© 2011, The McGraw-Hill Companies, Inc.

28 Other Word-Level Math Instructions 11.6
© 2011, The McGraw-Hill Companies, Inc.

29 Square root instruction.
© 2011, The McGraw-Hill Companies, Inc.

30 Simulated square root instruction rung.
© 2011, The McGraw-Hill Companies, Inc.

31 The negate (NEG) instruction changes the sign of the source value from positive to negative.
© 2011, The McGraw-Hill Companies, Inc.

32 Simulated negate instruction rung.
© 2011, The McGraw-Hill Companies, Inc.

33 The clear (CLR) instruction sets all bits of a word to zero.
© 2011, The McGraw-Hill Companies, Inc.

34 Simulated clear instruction rung.
© 2011, The McGraw-Hill Companies, Inc.

35 The convert to BCD (TOD) instruction is used to convert 16-bit integers into binary-coded decimal (BCD) values. © 2011, The McGraw-Hill Companies, Inc.

36 Simulated convert to BCD (TOD) instruction rung.
© 2011, The McGraw-Hill Companies, Inc.

37 The result, 377, is placed in the destination address, N7:1.
The scale data (SCL) instruction is used to allow very large or very small numbers to be enlarged or reduced by the rate value. The number 100 stored at the source address, N7:0, is multiplied by 25,000, divided by 10,000, and added to 127. The result, 377, is placed in the destination address, N7:1. © 2011, The McGraw-Hill Companies, Inc.

38 File Arithmetic Operations
11.7 File Arithmetic Operations © 2011, The McGraw-Hill Companies, Inc.

39 The file arithmetic and logic (FAL) instruction can combine an arithmetic operation with file transfer. The file add function of the FAL instruction is used to perform addition operations on multiple words. © 2011, The McGraw-Hill Companies, Inc.

40 The file subtract function of the FAL instruction is used to perform subtraction operations on multiple words. © 2011, The McGraw-Hill Companies, Inc.

41 The file multiplication function of the FAL instruction is used to perform multiplication operations on multiple words. © 2011, The McGraw-Hill Companies, Inc.

42 The file divide function of the FAL instruction is used to perform division operations on multiple words. © 2011, The McGraw-Hill Companies, Inc.


Download ppt "Chapter 11 © 2011, The McGraw-Hill Companies, Inc."

Similar presentations


Ads by Google