Upload
john-todora
View
425
Download
0
Tags:
Embed Size (px)
Citation preview
1Northampton Community College
Comparison, Forcing I/O and Subroutines
Chapter 07 Sections 7-4 through 7-6
Chapter 08 Sections 8-1, 8-2, 8-3-3 through 8-3-5
2Northampton Community College
Comparison Instructions
Chapter 07 Sections 7-4 through 7-6
3Northampton Community College
Data Compare Instructions
Data compare instructions are input instructions. Data compare instructions compare the data, or value,
stored in two words (or registers) and makes a decision based upon those values and the type of comparison being performed.
The SLC-500 series processors have eight and the ControlLogix has nine comparison instructions. We will cover seven of them. Equal (EQU) Not Equal (NEQ) Less Than (LES) Less Than or Equal To (LEQ) Greater Than (GRT) Greater Than or Equal To (GEQ) Limit Test (LIM)
4Northampton Community College
Comparison Instruction Parameters
Comparison instructions in the SLC500 are word level instructions and in the ControlLogix a tag of data type SINT, INT, DINT REAL or STRING. The instructions have two parameters: Source A Source B
Source A
Source B
5Northampton Community College
Instruction Comparison Rules
Comparison instruction parameters have several rules: In the SLC500, Source A and Source B can be WORD level addresses. In
the ControlLogix Source A and Source B can be a tag of data type SINT, INT, DINT, REAL or STRING.
Source A can be a WORD level address in the SLC500 or a tag in the ControlLogix and Source B can be a program constant.
Source A and Source B can not both be program constants.
Two WORD leveladdresses
A WORD leveladdress and a
Constant
Two ConstantsIllegal
6Northampton Community College
Equal (EQU) Instruction
The EQU instruction is an input instruction that compares the value referenced in Source A to the value referenced in source B. When the value of Source A is equal to the value of Source B the instruction is true, otherwise it is false.
When the accumulator value of counter C5:0 (C5:0.ACC) referenced in Source A is equal to the accumulator value of counter C5:1 (C5:1.ACC) referenced in Source B, the instruction is true and output O:2/5 is energized, otherwise the instruction is false and the output is de-energized.
When the program is running, the value of the WORD level address will be displayed in this field.
True when Source A = Source B
7Northampton Community College
Not Equal (NEQ) Instruction
The NEQ instruction is an input instruction that compares the value referenced in Source A to the value referenced in source B. When the value of Source A is not equal to the value of Source B the instruction is true, otherwise it is false.
When the accumulator value of timer T4:0 (T4:0.ACC) referenced in Source A is not equal to the program constant of 36 referenced in Source B, the instruction is true and output O:2/5 is energized, otherwise the instruction is false and the output is de-energized.
When the program is running, the value of the WORD level address will be displayed in this field.
True when Source A ≠ Source B
8Northampton Community College
Greater Than (GRT) Instruction The GRT instruction is an input instruction that compares the value
referenced in Source A to the value referenced in source B. When the value of Source A is greater than the value of Source B the instruction is true, otherwise it is false.
When the value stored in tag name SetPoint referenced in Source A is greater than the value stored in tag name Furnace_Temp referenced in Source B, the instruction is true and the output with tag name Heater is energized, otherwise the instruction is false and the output is de-energized.
True when Source A > Source B
2 Greater Than (A>B)Source A SetPoint 0Source B Furnace_Temp 0
GRTHeater
<Local:3:O.Data.5>
When the program is running, the value of the WORD level address will be displayed in this field.
9Northampton Community College
Less Than (LES) Instruction The LES instruction is an input instruction that compares the value
referenced in Source A to the value referenced in source B. When the value of Source A is less than the value of Source B the instruction is true, otherwise it is false.
When the value stored in the preset of timer T4:0 (T4:0.PRE) referenced in Source A is less than the accumulator value of counter C5:2 (C5:2.ACC) referenced in Source B, the instruction is true and output O:2/5 is energized, otherwise the instruction is false and the output is de-energized.
True when Source A < Source B
When the program is running, the value of the WORD level address will be displayed in this field.
10Northampton Community College
Greater Than or Equal To (GEQ) Instruction
The GEQ instruction is an input instruction that compares the value referenced in Source A to the value referenced in source B. When the value of Source A is greater than or equal to the value of Source B the instruction is true, otherwise it is false.
When the value stored in word B3:1 referenced in Source A is greater than or equal to the program constant of 568 referenced in Source B, the instruction is true and output O:2/5 is energized, otherwise the instruction is false and the output is de-energized.
When the program is running, the value of the WORD level address will be displayed in this field.
True when Source A ≥ Source B
11Northampton Community College
Less Than or Equal To (LEQ) Instruction The LEQ instruction is an input instruction that compares the value
referenced in Source A to the value referenced in source B. When the value of Source A is less than or equal to the value of Source B the instruction is true, otherwise it is false.
When the value of the tag name Refrg_Temp referenced in Source A is less than or equal to the value of the tag named SetPoint referenced in Source B, the instruction is true and the output with tag name Refrg_at_Temp is energized, otherwise the instruction is false and the output is de-energized.
True when Source A ≤ Source B
3 Less Than or Eql (A<=B)Source A Refrg_Temp 0Source B SetPoint 0
LEQRefrg_at_Temp
<Local:3:O.Data.13>
When the program is running, the value of the WORD level address will be displayed in this field.
12Northampton Community College
Limit Test (LIM) Instruction
The Limit Test instruction is an input instruction that tests for values that are inside of, or outside of, a specified range. The output of the instruction is dependent upon how the limits are set.
The LIM instruction has three instruction parameters: Low Limit (Low Lim) Test High Limit (High Lim)
Low Limit (Low Lim)
Test
High Limit (High Lim)
13Northampton Community College
LIM Parameter Rules
There are several rules associated with entering parameters into the LIM instruction:The parameter values in the SLC 500 can be WORD
level addresses or program constants and in the ControlLogix they can be tags of data type SINT, INT, DINT, REAL or program constants, with the following restrictions:If the Test parameter is a program constant, than the High Lim
and Low Lim parameters must be WORD level addresses or tags.
If the test parameter is a WORD level address or tag, than the Low Lim and High Lim parameters can be a program constant, a WORD level address or tag or a combination thereof.
14Northampton Community College
LIM Instruction Operation
If the value referenced in the Low Lim is less than or equal to the value referenced in the High Lim, the instruction will be true when the value referenced in the Test parameter is between or equal to either of the limits.
O:2/7 will be true (ON) when T4:1.ACC is:
≥78 and ≤156
78 156
T4:1.ACC
O:2/7 ONO:2/7 OFF O:2/7 OFF
15Northampton Community College
LIM Instruction Operation
If the value referenced in the Low Lim is greater than the value referenced in the High Lim, the instruction will be true when the value referenced in the Test parameter is equal to or outside of the limits.
SetPoint
78 156Heater OFFHeater ON Heater ON
4 Limit Test (CIRC)Low Limit LO_Temp_Lmt 156Test SetPoint 36High Limit HI_Temp_Lmt 78
LIMHeater
<Local:3:O.Data.5>
Heater will be true (ON) when the value stored in SetPoint is:
≤78 OR ≥156
16Northampton Community College
Performing Comparison Windows
Assume an output is being controlled based upon the value of a counter accumulator, C5:0.ACC. Following is the output operation criteria: Output is OFF when C5:0.ACC is 0 to and including 3. Output is ON when C5:0.ACC is 4 to and including 7. Output is OFF when C5:0.ACC is 8 to and including 10. Output is ON when C5:0.ACC is 11 to and including 25. Output is OFF when C5:0.ACC is >25.
Comparison instructions can be used in combinations to achieve the desired results.
17Northampton Community College
Performing Comparison Windows
18Northampton Community College
Subroutines
Chapter 08
Sections 8-3-3 to 8-3-5
Supplement Document
19Northampton Community College
Subroutines
Subroutine(s) is a group of program code that performs a specific task. The subroutine(s) are part of a program (in our case the MainProgram) and are not part of the MainRoutine.
A subroutine can be invoked, (called), from anyplace in the MainRoutine or from another subroutine. When a subroutine is called from within another subroutine it is referred to as nesting subroutines.
Most, if not all, computer programs and PLC/PAC programs contain subroutines.
Subroutines are used to make what would be an enormous program more manageable by breaking up the code into smaller tasks. Specific functions within a task should be placed in subroutines.
Organizing a program by using subroutines makes the code easier to read, understand and maintain.
Subroutines can also be reused in other programs that require the same task be performed.
20Northampton Community College
Subroutines
SLC500 The SLC500 uses separate
ladder files to store and execute subroutines. There are a total of 253 subroutine ladder files; #3 through #255.
Ladder file #2 (LAD2) is the main ladder file and is the one we have been using in all labs to this date.
Scan starts at rung 0 LAD2 and ends at the End statement in LAD2.
ControlLogix The ControlLogix uses
separate routines to store and execute subroutines. The number of routines is limited to 32 per program.
The MainRoutine is the main ladder routine and is the one we have been using in all labs to this date.
Scan starts at rung 0 in the MainRoutine and ends at the End statement in the MainRoutine
21Northampton Community College
Creating a ControlLogix Subroutine
1. To create a new subroutine right click on MainProgram and select New Routine… from the pop-up menu
2. New Routine dialog box will open. Type in the name of the subroutine and from the Type: dropdown, select the type of program code.
3. The new subroutine will appear listed under the program that it was created in. Double click the subroutine to open the ladder editor.
22Northampton Community College
Program Control Instructions There are many program control instructions. Below is a list of them and the
platforms they are available on:Instruction CL 500 Sim Instruction CL 500 Sim
JMP – Jump to Label ● ● ●UID – User Interrupt Disable
●
LBL – Label ● ● ●UIE – User Interrupt Enable
●
JXR – Jump to External Routine ●SFR – Reset Sequential Chart
●
JSR – Jump to Subroutine ● ● ●SFP – Pause Sequential Chart
●
RET – Return from Subroutine ● ● ●EVENT – Trigger Event Task
●
SBR – Subroutine Label ● ● ● EOT – End of Transition ●
TND – Temporary End ● ● ● AFI – Always False ●
MCR – Master Control Reset ● ● ● NOP – No Operation ●
SUS - Suspend
This course will only cover the instructions shown in Red. The instruction in Green can be used, but they will not be discussed in class.
23Northampton Community College
ControlLogix Program Control Instructions
JSR – Jump to Subroutine The JSR is an output instruction that is used to “call” a
subroutine. The instruction rung can be conditional or unconditional. JSR instructions can have several parameters. The one
shown here has 3-parameters. Subroutine name to be “called” (required)
Parameter to pass to the subroutine (optional)
Parameter to accept a value returning from the subroutine (optional)
24Northampton Community College
ControlLogix Program Control Instructions
Entering JSR parameters: Routine Name (Required) –
Double-click this parameter field, click the dropdown arrow and select the subroutine name from the dropdown list. The subroutine name will only be in the list if the subroutine has been created.
Input Par and Return Par (Optional) – These parameters will not be used in this course. When a parameter is not used it must be removed. Right click on the parameter field and select Remove Instruction Parameter from the pop-up menu. Do this for each parameter that is not required. The picture on this slide illustrates removing a parameter field.
25Northampton Community College
ControlLogix Program Control Instructions
JSR operation When the rung containing a JSR instruction is true, the
processor scan jumps to the subroutine referenced in the Routine Name parameter and begins program execution at the first rung in that subroutine
A jump cannot be made into the middle of a subroutine. Execution will always start at the first instruction on the first rung in that ladder routine.
This rung will unconditionally jump to the subroutine named Routine04
26Northampton Community College
ControlLogix Program Control Instructions
SBR – Subroutine Label The SBR in an input instruction that is always true and
marks the beginning of a subroutine. It must be the first instruction on the first rung of the subroutine.
The input parameter field(s) is used to reference tags whose data is to be used (passed) to the subroutine. (This course will not be using these parameters).
SBR instructions can have several parameters. The one shown here has one parameters.
Parameter that passes data to the subroutine (optional)
27Northampton Community College
ControlLogix Program Control Instructions
For this course the Input Par parameter will need to be removed from the SBR instruction. To remove the parameter right-click on the parameter and select Remove Instruction Parameter from the pop-up menu.
28Northampton Community College
ControlLogix Program Control Instructions
RET – Return from Subroutine The RET instruction is an output instruction that is used to
stop executing the subroutine and return to the ladder file that originally “called” the subroutine.
The instruction can be conditional or unconditional and can contain several parameters. The RET instruction shown here has one parameter. (This course will not use these parameters).
Parameter that passes data back to the ladder file that originally “called” the subroutine. (optional)
29Northampton Community College
ControlLogix Program Control Instructions
For this course the Input Par parameter will need to be removed from the RET instruction. To remove the parameter right-click on the parameter and select Remove Instruction Parameter from the pop-up menu.
30Northampton Community College
ControlLogix Program Control Instructions
Several conditional RET instructions can be present in a subroutine. As an example: If an RET instruction becomes true that is on rung 0006 in a
subroutine containing 45-rungs, the program scan will return to the ladder file that originally called the subroutine and rungs 0007 through 0045 will not execute.
If the RET instruction on rung 0006 becomes false another RET instruction becomes true that is on rung 0010 in the same subroutine, the program scan will return to the ladder file that originally called the subroutine and rungs 0011 through 0045 will not executed.
If the entire subroutine ladder file is to be always scanned, placing a RET instruction on the last rung of the program is optional. If an RET instruction is not found in the subroutine ladder file, the END statement performs the return.
31Northampton Community College
Program Execution using Subroutines
32Northampton Community College
Forcing I/O
33Northampton Community College
Using the Force I/O Function
The force function will only work on field I/O devices, therefore the input and output data files in the SLC500 and the Controller tags in the ControlLogix.
Before applying a force to any input or any output device, an understanding of the potential effect that force(s) will have on the machine or process operation and to the safety of personal is essential.
DO NOT INSTALL FORCES WITHOUT FIRST UNDERSTANDING WHAT AFFECT IT WILL HAVE ON THE
OPERATION OF THE MACHINE OR PROCESS Most programming software provide some visible means of
alerting the user that a force is in affect or installed. Most processor modules have an LED indicator that will be
lit if there are any forces installed.
34Northampton Community College
Installing and Enabling Forces
This is an instructor led, interactive lab. If there is no program running in the PLC at your
workstation, open a program that uses I/O field devices, download the program to the PLC, then place the PLC in RUN mode.
Your instructor will also switch to RSLogix and attach to someone’s workstation to lead you through and demonstrate the force functions.