Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programmable Logic Controllers Third Edition Frank D. Petruzella McGraw-Hill.

Similar presentations


Presentation on theme: "Programmable Logic Controllers Third Edition Frank D. Petruzella McGraw-Hill."— Presentation transcript:

1 Programmable Logic Controllers Third Edition Frank D. Petruzella McGraw-Hill

2 Chapter 10 Data Manipulation Instructions

3 Data Manipulation Instructions Data manipulation instructions enable the programmable controller to manipulate data stored in memory. This extra characteristic gives the PLC capabilities that go far beyond the conventional relay equivalent instructions. Data manipulation involves transfer of data and operation on data with math functions, data conversion, data comparison, and logical operations.

4 Data Files, Words, And Bits Words of data memory in singular form my be referred to either as registers, elements or as words, depending on the manufacturer. The terms table or file are generally used when a consecutive group of related data memory words is referenced. A group of consecutive elements or words in SLC-500 are referred to as a file, in a ControlLogix controller they are referred to as an array. The data contained in files and words will be in the form of binary bits represented as series of 1's and 0's.

5 Data Files, Words, And Bits

6 Data Manipulation Instructions The use of data manipulation instructions in applications that require the generation and manipulation of large quantities of data generally reduces the complexity and quantity of the programming required. Data manipulation instructions allow the movement, manipulation, or storage of data in either single- or multiple-word groups from one data memory area of the PLC to another.

7 Data Manipulation Instructions Move / Logical COMMAND NAME DESCRIPTION MOV MOV Move Moves the source value to the destination MVM Masked Move Moves data from a source location to a selected portion of the destination MVM AND And Performs a bitwise AND operation AND OR Or Performs a bitwise OR operation OR XOR Exclusive Or Performs a bitwise XOR operation XOR NOT Not Performs a NOT operation NOT CLR Clear Sets all bits of a word to zero CLR

8 Data manipulation can be placed in two broad categories: data transfer and data comparison. Data Transfer Operations Data transfer instructions simply involve the transfer of the contents from one word or register to another. When new data replaces existing data, the process is referred to as writing over the existing data. Data transfer instructions can address almost any location in the memory. That location may be the preset register for a timer or counter or even an output register that controls a seven-segment display.

9 Data Transfer Concept

10 Get/Put Data Transfer Rung The older Allen-Bradley PLC-2 controller uses coil formatted data transfer instructions: GET and PUT. The PUT instruction is used with the GET instruction to form a data transfer rung. When input A is true, the GET/PUT instructions tell the processor to get the numeric value 005 stored in word 020 and put it into word 130.

11 MOVE (MOV) Instruction Allen-Bradley PLC-5 and SLC-500 controllers use a block formatted MOVE instruction to accomplish data moves. The MOVE instruction is used to copy the value in one word to another word. This instruction copies data from a source word to a destination word.

12 When the rung is true, the value stored at the source address, N7:30, is copied into the destination address, N7:20. MOVE (MOV) Instruction When the rung goes false, the destination address will retain the value, unless it is changed elsewhere in the program.

13 Move With Mask (MVM) Instruction The move with mask (MVM) instruction differs slightly from the MOVE instruction because a mask word is involved in the move. The data being moved must pass through the mask to get to their destination address. The MVM instruction is used to copy the desired part of a 16-bit word by masking the rest of the value.

14 Move With Mask (MVM) Instruction The mask may be entered as an address or in hexadecimal format, and its value will be displayed in hexadecimal. Where there is a 1 in the mask, data will pass from the source to the destination. Where there is a 0 in the mask, data in the destination will remain in their last state.

15 Move With Mask (MVM) Instruction

16 Bit Distribute (BTD) Instruction The bit distribute (BTD) instruction is used to move bits within a word or between words. Moving bits between words To move data within a word, enter the same address for the source and destination On each scan, when the rung that contains the BTD instruction is true, the processor moves the bit field from the source word to the destination word.

17 Program To Change The Preset Value Of A Timer Using The MOVE (MOV) Instruction  When the selector switch is 10-s position, rung 2 has logic continuity and rung 3 does not. As a result, the value 10 stored at the source address, N7:1, is copied into the destination address, T4:1 PRE.  Therefore, the preset value of the timer T4:1 will be 10. When PB1 is closed, there will be a 10-s delay period before the pilot light is energized.  To change the preset value of the timer to 5 s, the selector switch is turned to the 5-s position. This makes rung 3 true and rung 2 false. As a result, the preset value of the timer will change from 10 to 5. Closing PB1 will now result in a 5-s time-delay period before the pilot light is energized.

18 Changing The Preset Value Of A Timer Using The MOVE (MOV) Instruction

19 Program To Change The Preset Value Of A Counter Using The MOVE (MOV) Instruction  A limit switch provides count pulses for products coming off of a conveyor line onto a storage rack. The storage rack has room for only 300 boxes of product A or 175 boxes of product B or 50 boxes of product C.  Three switches are provided to select the desired preset counter value depending on the product line being manufactured.  A reset button is provided to reset the accumulated count to zero.  A pilot lamp is switched on when the storage rack is full.  If more than one of the preset counter switches is closed, the last value is selected.

20 Changing The Preset Value Of A Counter Using The MOVE (MOV) Instruction

21 Moving Data With File Instructions A file is a group of related consecutive words in the data table that have a definite start and end and are used to store information. A batch process program may contain several separate recipes in different files that can be selected by an operator.

22 Word to File File to File File to Word Moving Data With File Instructions Files allow large amounts of data to be scanned quickly and are useful in programs requiring the transfer, comparison, or conversion of data.

23 PLC-5 And SLC-500 Word And File Addresses

24 FAL (File, Arithmetic, and Logical) Instruction The file, arithmetic and logic (FAL) instruction is used to copy data from one file to another and to do file math and file logic.

25 FAL (File, Arithmetic, and Logical) Instruction Control is the address of the control structure in the control area (R) of processor memory. The processor uses this information to run the instruction.

26 FAL (File, Arithmetic, and Logical) Instruction Length represents the file length. Position represents the current location in the data block that the processor is accessing. It points to the word being operated on. Mode represents the number of file elements operated on per program scan: all mode, numeric mode, or incremental mode. Destination is the address where the processor stores the result of the operation. Expression contains addresses, program constraints, and operators that specify the source of data and the operations to be performed. The expression entered determines the function of the FAL instruction.

27 File-To-File Function Using The FAL Instruction When input A goes true, data from the expression file #N7:20 will be copied into the destination file #N7:50

28 File-To-Word Copy Function Using The FAL Instruction With each false- to-true transition of input A, the processor reads one element of integer file N29, starting at element 0, and writes the image into element 5 of integer file N29. The instruction writes over any data in the destination.

29 Word-To-File Copy Function Using The FAL Instruction If we start at position 0, the data from N7:100 will be copied to N7:101 on the first false-to-true transition of input A. On successive transitions the data will be copied into the next position in the file.

30 Copying Recipes And Storing Values For Timer Presets The exceptions to the rule that file addresses must take consecutive words in the data table are the timer, counter, and control data files for the FAL instruction. In these three data files, if you designate a file address, the FAL instruction will take every third word in that file and make a file of preset, accumulated, length, or position data within the corresponding file type.

31 File Copy (COP) And File Fill (FLL) Instructions The file copy (COP) instruction and the file fill (FLL) instruction are high-speed instructions that operate more quickly than the same operation with the FAL instruction. Unlike the FAL instruction, there is no control element to monitor or manipulate. Data conversion does not take place, so the source and destination should be the same file types.

32 File Copy (COP) Instruction Location in RSLogix software When input A goes true, the values in file N40 are copied to file N20.

33 Fill (FLL) Instruction Location in RSLogix software When input A goes true, the value in N15:5 is copied into N20:1 through N20:6 Since the instruction transfers to the end of the file, the file will be filled with the same data value in each word.

34 Using The FLL Instruction To Zero All Of The Data In A File Momentarily closing PB1 copies the contents of file #N10:0 into file #N12:0. Momentarily closing PB2 then clears file #N12:0. Note that zero is entered for the source value.

35 1. Data transfer instruction can not address timer or counter preset values. (True/False) 2. The terms table or file are generally used when a consecutive group of related memory words is referenced. (True/False) 3. PLCs can not handle manipulation of entire words. (True/False)

36 4. The ______ parameter of the FAL instruction is used to run the instruction. (a) Mode (b) Position (c) Control (d) Length 5. For the MVM instruction,where there is a _____ in the mask, data will pass from the source to the destination. (a) 0 (b) 1 (c) 5 (d) 10

37 6. In the example of the instruction shown, when the rung is true the value stored in N20:0 will be: (a) 30 (b) 100 (c) 20 (d) 120

38 7. For the example of the instruction shown, when the rung is true the value stored in the destination address is: a. 1010101010101010 c. 1111111111111111 b. 1010101011001010 d. 0000000000000000

39 8. The example of the instruction shown is one of a ______ copy function. a. word-to-file c. file-to-file b. file-to-word d. word-to-word

40 9. For the program shown, the preset value of the counter would be: (a) 0 (b) 50 (c) 175 (d) 300

41 10. For the program shown, closing PB2 changes all the data in #N10:0 to 0. (True/False)

42 Data compare instructions compare the data stored in two or more words (or registers) and make decisions based on the program instructions. Data Compare Instructions Data transfer operations are all output instructions, whereas data compare instructions are input instructions. Data Compare Instruction

43 RSLogix Data Compare Instructions LIM Limit Test Test whether one value is within the limit range of two other values LIMMEQ Masked Comparison For Equal Test portions of two values to see whether they are equal EQU Equal Test whether two values are equal NEQ Not Equal Test where one value is not equal to a second value LES Less Than Test whether one value is less than a second value GRT Greater Than Test whether one value is greater than a second value LEQ Less Than or Equal Test whether one value is less than or equal to a second value GEQ Greater Than or Equal Test whether one value is greater than or equal to a second value

44 Equal (EQU) Instruction The equal (EQU) instruction is an input instruction that compares source A to source B. When source A is equal to source B, the instruction is logically true; otherwise it is logically false.

45 EQUAL (EQU) Logic Rung 100 250 When the accumulated value of counter T4:0 stored in source A's address equals the value in source B's address, N7:40, the instruction is true and the output is energized.

46 The not equal (NEQ) instruction is an input instruction that compares source A to source B. When source A is not equal to source B, the instruction is logically true; otherwise it is logically false. NOT EQUAL (NEQ) Instruction

47 NOT EQUAL (NEQ) Logic Rung 25 When the value stored at source A's address, N7:5, is not equal to 25, the output will be true, otherwise the output will be false.

48 GREATER THAN (GRT) Instruction The greater than (GRT) instruction is an input instruction that compares source A to source B. When source A is greater than source B, the instruction is logically true; otherwise it is logically false.

49 GREATER THAN (GRT) Logic Rung 150 220 When the accumulated value of the timer T4:10, stored at the address of source A, is greater than the constant 200 of source B, the output will be on; otherwise, it will be off.

50 LESS THAN (LES) Instruction The less than (LES) instruction is an input instruction that compares source A to source B. When source A is less than source B, the instruction is logically true; otherwise it is logically false.

51 LESS THAN (LES) Logic Rung 10 360 When the accumulated value of counter C5:10, stored at the address of source A, is less than the constant 350 of source B, the output will be on; otherwise, it will be off.

52 GREATER THAN OR EQUAL (GEQ) Instruction The greater than or equal (GEQ) instruction is an input instruction that compares source A to source B. When source A is greater than or equal to source B, the instruction is logically true; otherwise it is logically false.

53 GREATER THAN OR EQUAL (GEQ) Logic Rung 150 If the value stored at the address of source A, N7:55, is greater than or equal to the value stored at the address of source B, N7:12, the output will be true; otherwise it will be false

54 LESS THAN OR EQUAL (LEQ) Instruction The less than or equal (LEQ) instruction is an input instruction that compares source A to source B. When source A is less than or equal to source B, the instruction is logically true; otherwise it is logically false.

55 LESS THAN OR EQUAL (LEQ) Logic Rung 1 458 If the accumulated count of counter C5:1 is less than or equal to 457, the pilot light will turn on.

56 LIMIT TEST (LIM) Instruction The limit test instruction (LIM) compares a test value to values in the low limit and the high limit. The limit test instruction is said to be circular because it can function in either of two ways. If the high limit has a greater value than the low limit, then the instruction is true if the value of the test is between or equal to the values of the high limit and the low limit. 25 50 If the value of the low limit is greater than the value of the high limit, the instruction is true if the value of the test is equal to or less than the low limit or equal to or greater than the high limit. 100 50

57 LIMIT TEST (LIM) Instruction Logic Rung 60 Since the high limit has a value of 50, and the low limit 25, the instruction will be true for test values 25 through 50.

58 LIMIT TEST (LIM) Instruction Logic Rung 25 Since the high limit has a value of 50, and the low limit 100, the instruction will be true for test values of 50 and less than 50, and for test values of 100 and greater than 100.

59 MASKED COMPARISON FOR EQUAL (MEQ) Instruction The masked comparison for equal instruction (MEQ) compares a value from a source address with data at a compare address and allows portions of the data to be masked. If the data at the source address match the data at the compare address bit-by-bit (less masked bits) the instruction is true. The instruction goes false as soon as it detects a mismatch.

60 MASKED COMPARISON FOR EQUAL (MEQ) Logic Rung

61 Relay Time Delay Circuit Three time-delay relays (1TD, 2TD, 3TD) are used to control the four solenoid valves. When the start button is pressed, solenoid A is energized immediately, solenoid B is energized 5 s later, solenoid C is energized 10 s later, and solenoid D is energized 15 s later.

62 Same Time Delay Circuit Using Only One Timer And The GREATER THAN OR EQUAL Instruction

63 Timer Program Using The EQUAL Instruction 5 5 5 15

64 Counter Program Using The LESS THAN Instruction

65 Numerical Data I/O Interfaces Numerical data interfaces can be divided into two groups: those that provide interface to multibit digital devices and those that provide interface to analog devices. Thumbwheel Switch (TWS) – multibit digital input device. The multibit digital devices are like discrete I/O because processed signals are discrete (on/off). The difference is that, with the discrete I/O, only a single bit is required to read an input or control an output. Multibit interfaces allow a group of bits to be input as a unit. They are used to accommodate devices that require BCD inputs or outputs. Thermocouple – analog input device. An analog I/O will allow monitoring and control of analog voltages and currents. Analog modules convert analog signals to 16-bit digital signals (input) or 16-bit digital signals to analog values (output).

66 Use Of Comparison Instructions In Filling Operations The receiving vessel has its weight monitored continuously by the PLC program. When the weight reaches a preset value the flow is cut-off by the solenoid valve. If the programmer uses the EQUAL instruction to de-energize the solenoid a problem may result. Should the supply system leak additional material into the vessel, the total weight could rise above the preset value, causing the instruction to go false and the vessel to overfill. The simplest solution is to program the comparison instruction as GREATER THAN OR EQUAL

67 BCD Input Interface Module The BCD-input module allows the processor to accept 4-bit digital codes. This interface inputs data into specific register or word locations in memory to be used by the control program. Data manipulation instructions are used to access the data from the module. This allows a person to change set points or presets externally without modifying the control program.

68 BCD Output Interface Module This type of module enables a PLC to operate devices, such as a seven-segment LED display board, that require BCD-coded signals.

69 BCD I/O Program Using MOVE and EQUAL Instructions 3 8 6 4 3 8 6 4 3864 The LED display board monitors the decimal setting of the thumbwheel switch. The setting of the thumbwheel switch is compared to the reference number 100 stored in Source B of the EQUAL instruction. 01000100 01000100 100 The pilot light output PL will be energized when the input switch is true and the value of the thumbwheel switch is equal to 100.

70 Analog Input Interface Module The analog input module contains circuitry that accepts analog voltage or current signals from field devices. These voltage or current inputs are converted from an analog to a digital value by an A/D converter circuit.

71 Analog Output Interface Module Data from a specific register or word location in memory is passed through the controller's data bus to a D/A converter The analog output from the converter is then used to control the analog output device.

72 Set-Point Control Set-point control in its simplest form compares an input value to a set-point value. A discrete output signal is provided if the input value is less than, equal to, or greater than the set-point value.

73 Set-Point Temperature Control Program The PLC is to provide simple off/on control of the electric heating elements of an oven. The oven is to maintain an average set-point temperature of 600 degrees F, with a variation of about 1% between the off and on cycles. Therefore, the electric heaters will be turned on when the temperature is 597 degrees F or less and stay on until the temperature rises to 603 degrees F or more. The electric heaters stay off until the temperature drops to 579 degrees F, at which time the cycle repeats itself.

74 Set-Point Temperature Control 125 1 2 0 5 0 6 0 0 600 0 6 0 3 603 When the LEQ instruction is true, a low temperature exists and the program switches on the heater. When the GEQ instruction is true, a high temperature exists and the program switches off the heater.

75 Set-Point Control Schemes Several common set-point control schemes can be preformed by different PLC models. These include on/off control, proportional (P) control, proportional- integral (PI) control, and proportional-integral- derivative (PID) control. Each involves the use of some form of closed-loop control to maintain a process characteristic such as temperature, pressure, flow, or level at a desired value.

76 Closed-Loop Control System A measurement is made of the variable to be controlled. This measurement is then compared to a reference point, or set-point. If a difference (error) exists between the actual and desired levels, the PLC control program will take the necessary corrective action.

77 ON/OFF Control With on/off control the output is either on or off – one for the occasion when the value of the measured variable is above the set-point, and the other for the occasion when the value is below the set-point. On/off control is inexpensive but not accurate enough for many process and machine control applications. On/off control almost always means overshoot and resultant system cycling. A deadband is usually required around the set-point to prevent relay chatter at set-point.

78 Proportional Control Process Proportional controls are designed to eliminate the hunting or cycling associated with on/off control. They allow the final control element to take intermediate positions between on and off. This permits analog control of the final control element to vary the amount of energy to the process, depending on how much the value of the measured and variable has shifted from the desired value.

79 The valve is initially opened 100% Level sensor Proportional Control Process The PLC analog output module controls the amount of fluid placed in the holding tank by adjusting the the percentage of valve opening. Valve Analog input Analog output As the fluid level in the tank approaches the preset point, the processor modifies the output to degrade closing the valve by different percentages, adjusting the valve to maintain a set-point.

80 PID Control Process Proportional-integral derivative (PID) is the most sophisticated and widely used type of process control. PID controllers produce outputs that depend on the magnitude, duration, and rate of change of the signal error. PID operations are more complex and mathematically based.

81 PID Control Loop Set-point Process variable Error Control output Sudden system disturbances are met with an aggressive attempt to correct the condition. A PID controller can reduce the system error to 0 faster than any other controller.

82 11. In the example of the instruction shown, assuming the number stored at source A was 100, the output would be: a. on c. 75 b. off d. 100

83 12. In the example of the instruction shown, the output will be true if the number stored in N7:1 is: a. 5 c. 25 b. 15 d. any of these

84 13. In the example of the instruction shown, the output will be true if the number stored in N7:5 is: a. 10 c. 50 b. 20 d. any of these

85 14. In the example of the instruction shown, the output will be true if the number stored in N12:10 is: a. 30 c. 20 b. 25 d. both a and b

86 15. Thumbwheel switches can be programmed to allow an operator to change set points or presets externally without modifying the program. True/False 16. Which of the following devices would be classified as an analog input field device? a. pushbutton c. thermocouple b. lamp d. motor

87 17. Multibit interfaces allow a group of bits to be input or output as one unit. (True/False) 18. In an analog input module, voltages and currents are sensed and converted into digital word equivalents by a(n): a. D/A converter c. rectifier b. A/D converter d. amplifier

88 20. Which of the following types of process control can reduce the system error to zero fastest? a. ON/OFF c. PROPORTIONAL b. DERIVATIVE d. PID 19. The LIM instruction compares a test value to values in the: (a) Source and Destination (b) low limit and the high limit. (c) input and output (d) LEQ and GEQ


Download ppt "Programmable Logic Controllers Third Edition Frank D. Petruzella McGraw-Hill."

Similar presentations


Ads by Google