chapter 17

38
Chapter 17 Comparison and Data- handling Instructions

Upload: milla

Post on 19-Mar-2016

41 views

Category:

Documents


1 download

DESCRIPTION

Chapter 17. Comparison and Data-handling Instructions. Objectives. Describe the function of the common comparison instructions. Explain the difference between a move instruction and a copy instruction. Determine the data resulting after execution of a masked move instruction. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chapter 17

Chapter 17

Comparison and Data-handling Instructions

Page 2: Chapter 17

Objectives

• Describe the function of the common comparison instructions.

• Explain the difference between a move instruction and a copy instruction.

• Determine the data resulting after execution of a masked move instruction.

• Explain how a copy instruction can be used to copy recipe data from one source to another.

• Explain which instruction to use to have the PLC convert from an integer to a BCD value or from a BCD value to an integer.

Page 3: Chapter 17

Comparison Instructions

• Input instructions that test the relationship between two values, source A and source B– Source A is an address.– Source B can be an address or a constant

value.

Page 4: Chapter 17

Equal Instruction (EQU)

• Test when two values are equal.• Instruction is true when source A is equal to

source B.

Page 5: Chapter 17

An Equal Instruction Controlling OTE Instruction

Page 6: Chapter 17

Not Equal Instruction (NEQ)

• Test when two values for inequality.• Use this instruction to determine if two

specified sources are not equal.• Instruction is true when source A is not equal

to source B.

Page 7: Chapter 17

Not Equal Instruction

Page 8: Chapter 17

Less Than Instruction (LES) (1 of 2)

• Test when one value is less than another.• Instruction is true when the data stored in

source A is less than either the data stored in the address specified as source B or a constant entered in source B.

Page 9: Chapter 17

The Less Than Instruction (2 of 2)

Page 10: Chapter 17

Less Than or Equal (LEQ)

• Determine if one source of data is less than or equal to another.

• Instruction is true when the data stored in source A is less than or equal to either the data stored in the address specified as source B or a constant entered in source B.

Page 11: Chapter 17

Less Than or Equal Instruction

Page 12: Chapter 17

Greater Than Instruction (GEQ)

• Determine if one source of data is greater than another.

• Instruction is true when the data stored in source A is greater than either the data stored in the address specified as source B or a constant entered in source B.

Page 13: Chapter 17

The Greater Than Instruction

Page 14: Chapter 17

Greater Than or Equal (GEQ)

• Determine if one source of data is greater than or equal to another.

• Instruction is true when the data stored in source A is greater than or equal to either the data stored in the address specified as source B or a constant entered in source B.

Page 15: Chapter 17

Greater Than or Equal Instruction

Page 16: Chapter 17

Data-handling Instructions

• Used when data needs to be moved or copied from one data file source to another

• When data needs to be converted to a different radix

Page 17: Chapter 17

Move Instruction (MOV) (1 of 2)

• This is an output instruction that moves a copy of one data file element to a specified destination.

• The source can be an address or constant.• When instruction is true, a copy of the source

data will be moved to the specified destination address.

Page 18: Chapter 17

Move Instruction (2 of 2)

Page 19: Chapter 17

Masked Move Instruction (MVM) (1 of 2)

• This is an output instruction that moves a copy of one data file element through a mask to a specified destination.

• When true, a copy of the data specified in the source is moved through a hexadecimal mask to the specified destination.

Page 20: Chapter 17

Masked Move Instruction (2 of 2)

Page 21: Chapter 17

Hexadecimal Masking

• Source data is passed through the mask bit by bit.

• Mask bit in same position as source bit determines if data is to pass or not.

• To pass data through mask, set appropriate mask bit.

• To mask data from passing, reset the appropriate mask bit.

Page 22: Chapter 17

Source Data Moved through the Mask to the Destination

Page 23: Chapter 17

Mask Rules

• Mask is either a hexadecimal value or the address where the mask will be found.

• Data is evaluated on a bit by bit basis.• Mask 1 bits allow data to pass.• Mask 0 bits hold data from passing.• Destination bits that correspond to zeros in

the mask are not changed.

Page 24: Chapter 17

FRD Instruction Converting BCD Input Data to Integer

Page 25: Chapter 17

TOD Instruction ConvertingInteger Output Data to BCD

Page 26: Chapter 17

Copy File Instruction (COP)

• Output instruction that copies a user-defined group of 16-bit data file words

• Must copy consecutive dat file elements• Copy up to 128 one-word elements• Source and destination can be different file

types

Page 27: Chapter 17

Copy File Programming Parameters (1 of 2)

• Source is the address of the file to be copied. • The # symbol in front of the source address

specifies this address as the beginning of a user-defined source file.

• Destination is the starting address from which the number of source elements specified in the length parameter will be copied.

• # specifies copying a user-defined file.

Page 28: Chapter 17

Copy File Programming Parameters (2 of 2)

• Length parameter is the number of consecutive elements to be copied.

• Because different file types can be copied, the destination file type and length specify how many elements will be transferred.

Page 29: Chapter 17

Example of Copy File Instruction Operation

Page 30: Chapter 17

Ladder Containing Copy Instruction

Page 31: Chapter 17

AND Instruction

• The AND instruction performs a logical AND operation on two 16-bit words.

Page 32: Chapter 17

OR Instruction on a Ladder Rung

Page 33: Chapter 17

Exclusive-OR Instruction on a Ladder Rung

Page 34: Chapter 17

Not Logic As an Output Instruction on a PLC Ladder Rung

Page 35: Chapter 17

The Limit Test Instruction Testing for Values between 0 and 1750

Page 36: Chapter 17

The Limit Test Instruction Testing for Values outside the Range of 0 to 100

Page 37: Chapter 17

Data Flow from a VFD into the PLC

Page 38: Chapter 17

Scale with Parameters