Allen-Bradley Logix5000 Reference Manual
Allen-Bradley Logix5000 Reference Manual

Allen-Bradley Logix5000 Reference Manual

1756 controllogix, 1768 compactlogix, 1769 compactlogix, 1789 softlogix, 1794 flexlogix, powerflex 700s with drivelogix
Hide thumbs Also See for Logix5000:
Table of Contents
Reference Manual
Logix5000 Controllers General Instructions
Reference Manual
Catalog Numbers 1756 ControlLogix, 1768 CompactLogix, 1769 CompactLogix, 1789 SoftLogi x , 1794 FlexLogix,
PowerFlex 700S with DriveLogix
Table of Contents
loading

Summary of Contents for Allen-Bradley Logix5000

  • Page 1 Reference Manual Logix5000 Controllers General Instructions Reference Manual Catalog Numbers 1756 ControlLogix, 1768 CompactLogix, 1769 CompactLogix, 1789 SoftLogi x , 1794 FlexLogix, PowerFlex 700S with DriveLogix...
  • Page 2 Identifies information that is critical for successful application and understanding of the product. Allen-Bradley, Rockwell Software, Rockwell Automation, RSLogix5000, ControlLogix, CompactLogix, SoftLogix, FlexLogix, DriveLogix, PowerFlex 700S, FactoryTalk, FactoryTalk Alarms and Events, Logix5000, SLC, MicroLogix, PLC-2, PLC-3, PLC-5, PhaseManager, FactoryTalk View SE, RSLinx Enterprise, RSView, RSLogix Emulate 5000, SoftLogix 5800, and TechConnect are trademarks of Rockwell Automation, Inc.
  • Page 3 Summary of Changes Summary of Changes This manual contains new and updated information. Changes throughout this revision are marked by change bars, as shown to the right of this paragraph. Topic Page Added MDAC and MDCC motion instructions to Locator Bit addressing Configure MSG instructions Get Audit Value, controller events and set controller events instructions...
  • Page 4 Notes: Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 5: Table Of Contents

    Table of Contents Instruction Locator Where to Find an Instruction ........29 Preface Introduction.
  • Page 6 Table of Contents Buffer Alarms ........... . 78 Programmatically Access Alarm Information .
  • Page 7 Table of Contents One Shot Falling (OSF) ......... 107 Relay Ladder Operands .
  • Page 8 Specify the Configuration Details ....... . . 172 Specify this Data for a Logix5000 Controller as a Target Device . 173 Specify CIP Data Table Read and Write Messages .
  • Page 9 Table of Contents Relay Ladder ..........194 Structured Text .
  • Page 10 Table of Contents Equal To (EQU) ..........226 Relay Ladder .
  • Page 11 Table of Contents Function Block..........244 Relay Ladder .
  • Page 12 Table of Contents Chapter 6 Compute/Math Instructions Compute (CPT) ..........262 (CPT, ADD, SUB, MUL, DIV, Relay Ladder .
  • Page 13 Table of Contents Function Block..........278 Relay Ladder .
  • Page 14 Table of Contents Chapter 7 Move/Logical Instructions Move (MOV) ........... 295 (MOV, MVM, BTD, MVMT, Relay Ladder .
  • Page 15 Table of Contents Structured Text ..........318 Function Block.
  • Page 16 Table of Contents Boolean Exclusive OR (BXOR)........337 Structured Text.
  • Page 17 Table of Contents Relay Ladder ..........374 Structured Text .
  • Page 18 Table of Contents Chapter 9 Array (File)/Shift Instructions Bit Shift Left (BSL) ..........402 (BSL, BSR, FFL, FFU, LFL, LFU) Relay Ladder .
  • Page 19 Table of Contents Structured Text ..........454 Function Block.
  • Page 20 Table of Contents Relay Ladder ..........481 Structured Text.
  • Page 21 Table of Contents Structured Text ..........522 Relay Ladder .
  • Page 22 Table of Contents FBD_MATH_ADVANCED Structure ..... . . 536 Relay Ladder ..........537 Function Block .
  • Page 23 Table of Contents Relay Ladder Example ........548 Structured Text .
  • Page 24 Table of Contents Convert to BCD (TOD)......... 564 Relay Ladder .
  • Page 25 Table of Contents Structured Text ..........583 Relay Ladder .
  • Page 26 Table of Contents String Delete (DELETE)......... 612 Relay Ladder .
  • Page 27 Table of Contents Structured Text ..........631 Relay Ladder .
  • Page 28 Table of Contents Common Instruction Parameters for Timing Modes... . 662 Overview of Timing Modes........665 Program/Operator Control .
  • Page 29: Where To Find An Instruction

    Motion Logix5000 Controllers Motion Instructions Reference Manual, publication MOTION-RM002 PhaseManager PhaseManager User Manual, publication LOGIX-UM001 Process control Logix5000 Controllers Process Control and Drives Instructions Reference Manual, publication 1756-RM006 Instruction Location Languages Relay ladder ASCII Test For Buffer Line Structured text...
  • Page 30 Instruction Locator Instruction Location Languages Instruction Location Languages Relay ladder Relay ladder ASCII Read Structured text Compare Relay ladder CONCAT Relay ladder ASCII Read Line Structured text String Concatenate Structured text Relay ladder Relay ladder Arc Sine Structured text Copy File Structured text Function block Relay ladder...
  • Page 31 Instruction Locator Instruction Location Languages Instruction Location Languages Relay ladder INTG Process control Structured text Equal to Structured text Integrator Function block Function block Relay ladder ESEL Process control Structured text Immediate Output Structured text Enhanced Select Function block IREF Function block EVENT Relay ladder...
  • Page 32 Instruction Locator Instruction Location Languages Instruction Location Languages MAFR Motion Relay ladder MCLM Coordinate Relay ladder Motion Axis Fault Reset Structured text Motion Coordinated Linear Structured text Move Motion Relay ladder Motion Axis Gear Structured text Relay ladder Master Control Reset MAHD Motion Relay ladder...
  • Page 33 Instruction Locator Instruction Location Languages Instruction Location Languages MGSR Motion Relay ladder Relay ladder Motion Group Shutdown Structured text No Operation Reset Relay ladder Relay ladder Bitwise NOT Structured text Middle String Structured text Function block MINC Process control Structured text NTCH Process control Structured text...
  • Page 34 Instruction Locator Instruction Location Languages Instruction Location Languages Relay ladder Process control Structured text Proportional Integral Structured text Scale Function block Derivative SCRV Process control Structured text Process control Structured text S-Curve Function block Proportional + Integral Function block Process control Function block PMUL Process control...
  • Page 35 Instruction Locator Instruction Location Languages Instruction Location Languages STOR Relay ladder Relay ladder String To REAL Structured text X to the Power of Y Structured text Function block Relay ladder Subtract Structured text Function block SWPB Relay ladder Swap Byte Structured text Relay ladder Tangent...
  • Page 36 Instruction Locator Notes: Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 37: Introduction

    Logix5000 controllers. For a complete list of common procedures manuals, see the Logix5000 Controllers Common Procedures Programming Manual, publication 1756-PM001. The term Logix5000 controller refers to any controller that is based on the Logix5000 operating system, such as: · CompactLogix controllers ·...
  • Page 38: Common Information For All Instructions

    The following icons help identify language-specific information. Icon Programming Language Relay ladder Structured text Function block Common Information for The Logix5000 instruction set has some common attributes. All Instructions Information Appendix Common attributes Common Attributes defines: • Arithmetic status flags •...
  • Page 39: Relay Ladder Rung Condition

    Preface If an operand or parameter supports more than one data type, the bold data types indicate optimal data types. An instruction executes faster and requires less memory if all the operands of the instruction use the same optimal data type, typically DINT or REAL.
  • Page 40: Function Block States

    Preface Function Block States When programming in function block, restrict the range of IMPORTANT +/-15 engineering units to +/-10 because internal floating point calculations are done by using single precision floating point. Engineering units outside of this range may result in a loss of accuracy if results approach the limitations of single precision +/-38 floating point (+/-10...
  • Page 41: Additional Resources

    Preface Additional Resources See these manuals and documents for more information about using motion modules in a Logix5000 control system. Publication Publication Number Logix5000 Controllers Common Procedures 1756-PM001 Programming Manual Motion Coordinate System User Manual MOTION-UM002 Logix5000 Controllers Motion Instructions...
  • Page 42 Preface Notes: Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 43 Chapter FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Topic Page Digital Alarm (ALMD) Analog Alarm (ALMA) Configure an Alarm Instruction Enter Alarm Message Text Monitor Alarm Status Buffer Alarms Programmatically Access Alarm Information Suppress or Disable Alarms Controller-based Alarm Execution These Logix-based alarm instructions are available in relay ladder, structured text, and function block diagram.
  • Page 44: Digital Alarm (Almd)

    Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Digital Alarm (ALMD) The ALMD instruction detects alarms based on Boolean (true/false) conditions. Program (Prog) and operator (Oper) control parameters provide an interface for alarm commands. Operands: Relay Ladder In relay ladder, the alarm condition input (In) is obtained from the rung condition.
  • Page 45: Structured Text

    FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Chapter 1 Structured Text ALMD(ALMD, In, ProgAck, The operands are the same as those for the relay ladder ALMD instruction, with a ProgReset, ProgDisable, ProgEnable); few exceptions as indicated above. Function Block Operand Type Format...
  • Page 46 Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Input Parameter Data Type Description ProgAck BOOL Set by the user program to acknowledge the alarm. Requires a cleared-to-set transition while the alarm is unacknowledged. Default is cleared. Relay Ladder Copied from the instruction operand.
  • Page 47 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Chapter 1 Input Parameter Data Type Description AlarmCountReset BOOL Set by the user program to reset the alarm count. A cleared-to-set transition resets the alarm count to zero. Default is cleared. UseProgTime BOOL Specifies whether to use the controller’s clock or the ProgTime value to timestamp alarm state change events.
  • Page 48 Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Output Parameter Data Type Description DeliveryEN BOOL Delivery status of the alarm notification message. Set when delivery is in progress. Cleared when delivery is not in progress. NoSubscriber BOOL Alarm had no subscribers when attempting to deliver the most recent message. Set when there are no subscribers.
  • Page 49: State Diagrams When Acknowledgement Required

    FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Chapter 1 Description: The ALMD instruction detects alarms based on Boolean (true/false) conditions. The ALMD instruction provides additional functionality when used with RSLinx Enterprise and FactoryTalk View SE software. You can display alarms in the Alarm Summary, Alarm Banner, Alarm Status Explorer, and Alarm Log Viewer displays in FactoryTalk View SE software.
  • Page 50: State Diagrams When Acknowledgment Not Required

    Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) State Diagrams when Acknowledgment Not Required Latched = False In = Condition, MinDurationACC >= MinDurationPRE InAlarm = False InAlarm = True Acked = True In != Condition Latched = True In = Condition, MinDurationACC >= MinDurationPRE InAlarm = False InAlarm = True...
  • Page 51: Almd Alarm Acknowledge Required And Latched

    FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Chapter 1 Condition Function Block Action Structured Text Action Prescan All operator requests, timestamps, and delivery flags are All operator requests, timestamps, and delivery flags are cleared. cleared. InAlarm is cleared and Acked is set. InAlarm is cleared and Acked is set.
  • Page 52: Almd Alarm Acknowledge Required And Not Latched

    Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) ALMD Alarm Acknowledge Required and Not Latched ALMD Alarm Acknowledge Not Required and Latched Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 53: Almd Alarm Acknowledge Not Required And Not Latched

    FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Chapter 1 ALMD Alarm Acknowledge Not Required and Not Latched Example: Two motor failure signals are combined such that if either one occurs, a motor fault alarm is activated. Programmatically acknowledge the alarm with a cleared- to-set transition of the Motor101Ack tag value.
  • Page 54: Structured Text

    Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Structured Text Motor101FaultConditions := Motor101Overtemp OR Motor101FailToStart; ALMD(Motor101Fault,Motor101FaultConditions, Motor101Ack,0,0,0 ); Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 55: Analog Alarm (Alma)

    FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Chapter 1 Analog Alarm (ALMA) The ALMA instruction detects alarms based on the level or rate of change of an analog value. Program (Prog) and operator (Oper) control parameters provide an interface for alarm commands. Operands: Relay Ladder Operand...
  • Page 56: Structured Text

    Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Structured Text ALMA(ALMA, In, ProgAckAll, The operands are the same as those for the relay ladder ALMD instruction, with a ProgDisable, ProgEnable); few exceptions as indicated above. Function Block Operand Type Format Description...
  • Page 57 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Chapter 1 Input Parameter Data Type Description HEnabled BOOL High alarm condition detection. Set to enable detection of the High alarm condition. Clear to disable detection of the High alarm condition. Default is set. LEnabled BOOL Low alarm condition detection.
  • Page 58 Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Input Parameter Data Type Description ROCPosProgAck BOOL Positive rate of change program acknowledge. Set by the user program to acknowledge a positive rate-of- change condition. Requires a cleared-to-set transition while the alarm condition is unacknowledged. Default is cleared.
  • Page 59 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Chapter 1 Input Parameter Data Type Description HHSeverity DINT Severity of the High High alarm condition. This does not affect processing of alarms by the controller, but can be used for sorting and filtering functions at the alarm subscriber. Valid = 1...1000 (1000 = most severe;...
  • Page 60 Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Input Parameter Data Type Description ROCPosSeverity DINT Severity of the increasing rate-of-change condition. This does not affect processing of alarms by the controller, but can be used for sorting and filtering functions at the alarm subscriber. Valid = 1...1000 (1000 = most severe;...
  • Page 61 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Chapter 1 Output Parameter Data Type Description ROCPosAcked BOOL Positive rate-of-change condition acknowledged status. Set when a positive rate-of-change condition is acknowledged. Always set when AckRequired is cleared. Cleared when a positive rate-of-change condition is not acknowledged.
  • Page 62 Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Output Parameter Data Type Description ROCPosInAlarmCount DINT The number of times the positive rate-of-change condition has been activated. If the maximum value is reached, the counter leaves the value at the maximum count value. ROCNegInAlarmTime LINT Timestamp when the ALMA instruction detected that the In value exceeded the negative rate-of-...
  • Page 63 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Chapter 1 Output Parameter Data Type Description SeverityInv (Status.2) BOOL Alarm severity configuration is invalid. If severity <1, the instruction uses Severity = 1. If severity >1000, the instruction uses Severity = 1000. AlarmLimitsInv (Status.3) BOOL Alarm Limit configuration is invalid (for example, LLimit <...
  • Page 64: State Diagrams When Acknowledgement Required

    Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Description The ALMA instruction detects alarms based on the level or rate of change of a value. The ALMA instruction provides additional functionality when used with RSLinx Enterprise and FactoryTalk View SE software. You can display alarms in the Alarm Summary, Alarm Banner, Alarm Status Explorer, and Alarm Log Viewer displays in FactoryTalk View SE software.
  • Page 65: State Diagrams When Acknowledgement Not Required

    FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Chapter 1 State Diagrams when Acknowledgement Not Required In >= HLimit, MinDurationACC >= MinDurationPRE HInAlarm = False HInAlarm = True HAcked = True In < (HLimit - Deadband) In <= LLimit, MinDurationACC >= MinDurationPRE LInAlarm = False LInAlarm = True LAcked = True...
  • Page 66 Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Execution: Condition Relay Ladder Action Prescan The rung-condition-out is set to false. All the xInAlarm parameters are cleared and all alarm conditions are acknowledged. All operator requests, timestamps, and delivery flags are cleared. Rung-condition-in is false The instruction does not execute.
  • Page 67: Alma Level Condition Acknowledge Required

    FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Chapter 1 ALMA Level Condition Acknowledge Required Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 68: Alma Level Condition Acknowledge Not Required

    Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) ALMA Level Condition Acknowledge Not Required Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 69: Alma Rate Of Change Acknowledge Required

    FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Chapter 1 ALMA Rate of Change Acknowledge Required Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 70: Alma Rate Of Change Acknowledge Not Required

    Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) ALMA Rate of Change Acknowledge Not Required Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 71: Relay Ladder

    FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Chapter 1 Example: A tank alarm is activated if the tank level surpasses a High or High High limit. Programmatically acknowledge all the alarm conditions with a cleared-to-set transition of the Tank32LevelAck tag value. The application logic must clear Tank32LevelAck.
  • Page 72: Configure An Alarm Instruction

    Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Configure an Alarm After you enter an ALMD or ALMA instruction and specify the alarm tag name, Instruction use the Alarm Configuration dialog to specify the details of the message. The Properties dialog for the alarm instruction includes a Configuration tab.
  • Page 73 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Chapter 1 Option Description Severity Select a severity range from 1…1000 to rank the importance of an alarm condition. A severity of 1 is for low priority alarms; a severity of 1000 is for an emergency condition. By default, in the FactoryTalk Alarms and Events system, severity ranges are mapped to priorities as follows: ·...
  • Page 74: Enter Alarm Message Text

    Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Enter Alarm Message Text Enter appropriate message text to display when an alarm condition is active (InAlarm). For an ALMD instruction, you enter the message information on the Configuration tab. For an ALMA instruction, you enter the message information on the Message tab.
  • Page 75: Message String Variables

    FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Chapter 1 Message String Variables Variable Embeds in the message string Default code added to message string Alarm name The name of the alarm, which consists of the controller /*S:0 %AlarmName*/ name, program name, and tag name. For example, [Zone1Controller]Program:Main.MyAlarmTagName.
  • Page 76: Multiple Language Versions Of Alarm Messages

    Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) All of this variable information is included with the alarm data, viewable by the operator, and entered in the history log, regardless of whether you embed the information in the message text. Multiple Language Versions of Alarm Messages You can maintain alarm messages in multiple languages.
  • Page 77: Monitor Alarm Status

    FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Chapter 1 Monitor Alarm Status On the Status tab of the alarm dialog, monitor the alarm condition, acknowledge an alarm, disable an alarm, suppress an alarm, or reset an alarm. Use the dialog selections to see how an alarm behaves, without needing an operational HMI.
  • Page 78: Buffer Alarms

    Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Buffer Alarms In order to receive controller-based alarm messages, alarm clients (such as an RSLinx Enterprise server) must establish a subscription to the alarms in the Logix controller. The controller maintains a connection to each subscriber and monitors the status of that connection.
  • Page 79: Programmatically Access Alarm Information

    FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Chapter 1 Programmatically Access Each alarm instruction has an alarm structure that stores alarm configuration and Alarm Information execution information. The alarm structure includes both Program and Operator control elements and operator elements. The alarm instructions do not use mode settings to determine whether program access or operator access is active, so these elements are always active.
  • Page 80 Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) When you create an alarm instruction, you must create and assign a tag of the correct alarm data type for that alarm. For example, create MyDigitalAlarm of data type ALARM_DIGITAL. In relay ladder, these instruction parameters must be entered on the instruction: ·...
  • Page 81: Suppress Or Disable Alarms

    FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Chapter 1 Suppress or Disable Alarms Suppress alarms to remove alarms you know exist from the HMI but still keep the alarms alive. This lets you clear the alarm summary while you are resolving a known alarm without continuing to view alarm information.
  • Page 82: Controller-Based Alarm Execution

    Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Controller-based Alarm Controller-based alarms process inputs from two sources. Execution Source Description Alarm tag members Alarm tag members are, for the most part, processed when the user application scans the alarm instruction.
  • Page 83: Controller Memory Use

    FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Chapter 1 Use care when determining where to place alarm instructions in the application. The accuracy of the timestamps are affected by how quickly the instruction is scanned after the alarm condition changes state. MinDuration time accumulation and Rate of Change calculations require repeated scanning, within time intervals determined by the user application.
  • Page 84 Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) · Typically 2.2 KB per analog alarm with no associated tags Analog Alarm Example Approximate Size Analog alarm with no associated tags and this configuration: 2228 bytes · HH Alarm message: Level Alarm ·...
  • Page 85: Scan Time

    FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Chapter 1 Longer message strings, as well as message strings for multiple languages, consume additional memory from your controller. Actual memory usage will depend on how the alarm is configured, message length, and any associated tags passed with the alarm. Scan Time These execution times show how ALMD instructions and ALMA instructions affect total scan time.
  • Page 86 Chapter 1 FactoryTalk Alarms and Events Logix-based Instructions (ALMD, ALMA) Notes: Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 87 Chapter Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Topic Page Bit Addressing Examine If Closed (XIC) Examine If Open (XIO) Output Energize (OTE) Output Latch (OTL) Output Unlatch (OTU) One Shot (ONS) One Shot Rising (OSR) One Shot Falling (OSF) One Shot Rising with Input (OSRI) One Shot Falling with Input (OSFI)
  • Page 88: Bit Addressing

    Chapter 2 Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Bit Addressing Bits in a Logix controller exist in one of several forms: • BOOL tag • BOOL array • Bits within an integer (SINT, INT, or DINT) tag •...
  • Page 89 Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Chapter 2 Example: Indirect Serial Bit Reference in a DINT array MyBits : DINT[10] BitRef : DINT EndTag MOV(34,BitRef ) XIC(MyBits[(BitRef AND NOT 31)/32].[BitRef AND 31]) Explanation (BitRef AND NOT 31)/32=Calculates the element in the DINT .[BitRef AND 31]=Calculates the bit within the element If the tag MyBits is defined as an INT or SINT, the mask value would be 15 or 7, respectively.
  • Page 90: Examine If Closed (Xic)

    Chapter 2 Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Examine If Closed (XIC) The XIC instruction examines the data bit to see if it is set. Operands: Relay Ladder Operand Type Format Description Data bit BOOL Bit to be tested Structured Text...
  • Page 91 Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Chapter 2 Execution: Condition Relay Ladder Action Prescan The rung-condition-out is set to false. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true Data Bit = 0 Rung-condition-out Examine data bit.
  • Page 92: Relay Ladder

    Chapter 2 Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Example 1: If limit_switch_1 is set, this enables the next instruction (the rung-condition-out is true). Relay Ladder Structured Text IF limit_switch THEN ; END_IF; Example 2: If S:V is set (indicates that an overflow has occurred), this enables the next instruction (the rung-condition-out is true).
  • Page 93: Examine If Open (Xio)

    Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Chapter 2 Examine If Open (XIO) The XIO instruction examines the data bit to see if it is cleared. Operands: Relay Ladder Operand Type Format Description Data bit BOOL Bit to be tested Structured Text...
  • Page 94 Chapter 2 Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Execution: Condition Relay Ladder Action Prescan The rung-condition-out is set to false. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true Data Bit = 0 Rung-condition-out Examine data bit.
  • Page 95: Relay Ladder

    Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Chapter 2 Example 1: If limit_switch_2 is cleared, this enables the next instruction (the rung-condition- out is true). Relay Ladder Structured Text IF NOT limit_switch_2 THEN ; END_IF; Example 2: If S:V is cleared (indicates that no overflow has occurred), this enables the next instruction (the rung-condition-out is true).
  • Page 96: Output Energize (Ote)

    Chapter 2 Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Output Energize (OTE) The OTE instruction sets or clears the data bit. Operands: Relay Ladder Operand Type Format Description Data bit BOOL Bit to be set or cleared Structured Text Structured text does not have an OTE instruction, but you can achieve the same results by using a non-retentive assignment.
  • Page 97: Relay Ladder

    Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Chapter 2 Example: When switch is set, the OTE instruction sets (turns on) light_1. When switch is cleared, the OTE instruction clears (turns off ) light_1. Relay Ladder Structured Text light_1 [:=] switch;...
  • Page 98: Output Latch (Otl)

    Chapter 2 Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Output Latch (OTL) The OTL instruction sets (latches) the data bit. Operands: Relay Ladder Operand Type Format Description Data bit BOOL Bit to be set Structured Text Structured text does not have an OTL instruction, but you can achieve the same results by using an IF...THEN construct and an assignment.
  • Page 99: Relay Ladder

    Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Chapter 2 Example: When enabled, the OTL instruction sets light_2. This bit remains set until it is cleared, typically by an OTU instruction. Relay Ladder Structured Text IF BOOL_expression THEN light_2 := 1;...
  • Page 100: Output Unlatch (Otu)

    Chapter 2 Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Output Unlatch (OTU) The OTU instruction clears (unlatches) the data bit. Operands: Relay Ladder Operand Type Format Description Data bit BOOL Bit to be cleared Structured Text Structured text does not have an OTU instruction, but you can achieve the same results by using an IF...THEN construct and an assignment.
  • Page 101: Relay Ladder

    Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Chapter 2 Example: When enabled, the OTU instruction clears light_2. Relay Ladder Structured Text IF BOOL_expression THEN light_2 := 0; END_IF; Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 102: One Shot (Ons)

    Chapter 2 Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) One Shot (ONS) The ONS instruction enables or disables the remainder of the rung, depending on the status of the storage bit. Operands: Relay Ladder Operand Type Format Description...
  • Page 103 Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Chapter 2 Execution: Condition Relay Ladder Action Prescan The storage bit is set to prevent an invalid trigger during the first scan. The rung-condition-out is set to false. Rung-condition-in is false The storage bit is cleared.
  • Page 104: Relay Ladder

    Chapter 2 Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Example: You typically precede the ONS instruction with an input instruction because you scan the ONS instruction when it is enabled and when it is disabled for it to operate correctly.
  • Page 105: One Shot Rising (Osr)

    Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Chapter 2 One Shot Rising (OSR) The OSR instruction sets or clears the output bit, depending on the status of the storage bit. This instruction is available in structured text and function block as OSRI, page 109.
  • Page 106: Rockwell Automation Publication 1756-Rm003N-En-P - October

    Chapter 2 Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Execution: Condition Relay Ladder Action Prescan. The storage bit is set to prevent an invalid trigger during the first scan. The output bit is cleared. The rung-condition-out is set to false. Rung-condition-in is false.
  • Page 107: One Shot Falling (Osf)

    Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Chapter 2 One Shot Falling (OSF) The OSF instruction sets or clears the output bit depending on the status of the storage bit. This instruction is available in structured text and function block as OSFI, see page 112.
  • Page 108 Chapter 2 Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Execution: Condition Relay Ladder Action Prescan. The storage bit is cleared to prevent an invalid trigger during the first scan. The output bit is cleared. The rung-condition-out is set to false. Rung-condition-in is false.
  • Page 109: One Shot Rising With Input (Osri)

    Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Chapter 2 One Shot Rising with Input The OSRI instruction sets the output bit for one execution cycle when the input (OSRI) bit toggles from cleared to set. This instruction is available in relay ladder as OSR, see page 105.
  • Page 110 Chapter 2 Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Description: When InputBit is set and InputBit is cleared, the OSRI instruction sets OutputBit. When InputBit is set or when InputBit is cleared, the OSRI instruction clears OutputBit. InputBit InputBit OutputBit...
  • Page 111: Structured Text

    Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Chapter 2 Example: When limit_switch1 goes from cleared to set, the OSRI instruction sets OutputBit for one scan. Structured Text OSRI_01.InputBit := limit_switch1; OSRI(OSRI_01); State := OSRI_01.OutputBit; Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 112: One Shot Falling With Input (Osfi)

    Chapter 2 Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) One Shot Falling with Input The OSFI instruction sets the OutputBit for one execution cycle when the (OSFI) InputBit toggles from set to cleared. This instruction is available in relay ladder as OSF, see page 107.
  • Page 113 Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Chapter 2 Description: When the InputBit is cleared and the InputBit is set, the OSFI instruction sets the OutputBit. When InputBit is cleared or when InputBit is set, the OSFI instruction clears the OutputBit.
  • Page 114: Structured Text

    Chapter 2 Bit Instructions (XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF, OSRI, OSFI) Example: When limit_switch1 goes from set to cleared, the OSFI instruction sets OutputBit for one scan. Structured Text OSFI_01.InputBit := limit_switch1; OSFI(OSFI_01); Output_state := OSFI_01.OutputBit; Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 115: Timer And Counter Instructions

    Chapter Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Topic Page Timer On Delay (TON) Timer Off Delay (TOF) Retentive Timer On (RTO) Timer On Delay with Reset (TONR) Timer Off Delay with Reset (TOFR) Retentive Timer On with Reset (RTOR) Count Up (CTU) Count Down (CTD)
  • Page 116: Timer On Delay (Ton)

    Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Timer On Delay (TON) The TON instruction is a non-retentive timer that accumulates time when the instruction is enabled (rung-condition-in is true). This instruction is available in structured text and function block as TONR. Operands: Relay Ladder Operand...
  • Page 117 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Chapter 3 When the TON instruction is disabled, the .ACC value is cleared. Rung-condition-in Timer Enable Bit (.EN) Timer Timing Bit (.TT) Timer Done Bit (.DN) Dela Preset Timer did not...
  • Page 118 Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Execution: Condition Relay Ladder Action Prescan The .EN, .TT, and .DN bits are cleared. The .ACC value is cleared. The rung-condition-out is set to false. Rung-condition-in is false The .EN, .TT, and .DN bits are cleared.
  • Page 119 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Chapter 3 Example: When limit_switch_1 is set, light_2 is on for 180 ms (timer_1 is timing). When timer_1.acc reaches 180, light_2 goes off and light_3 goes on. Light_3 remains on until the TOF instruction is disabled.
  • Page 120: Timer Off Delay (Tof)

    Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Timer Off Delay (TOF) The TOF instruction is a non-retentive timer that accumulates time when the instruction is enabled (rung-condition-in is false). This instruction is available in structured text and function block as TOFR.
  • Page 121 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Chapter 3 When the TOF instruction is disabled, the .ACC value is cleared. Rung-condition-in Timer Enable Bit (.EN) Timer Timing Bit (.TT) Timer Done Bit (.DN) OFF Delay Preset Timer Accumulated Value (.ACC)
  • Page 122 Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Execution: Condition Relay Ladder Action Prescan The .EN, .TT, and .DN bits are cleared. The .ACC value is set to equal the .PRE value. The rung-condition-out is set to false.
  • Page 123 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Chapter 3 Example: When limit_switch_2 is cleared, light_2 is on for 180 ms (timer_2 is timing). When timer_2.acc reaches 180, light_2 goes off and light_3 goes on. Light_3 remains on until the TOF instruction is enabled.
  • Page 124: Retentive Timer On (Rto)

    Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Retentive Timer On (RTO) The RTO instruction is a retentive timer that accumulates time when the instruction is enabled. This instruction is available in structured text and function block as RTOR.
  • Page 125 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Chapter 3 Description: The RTO instruction accumulates time until it is disabled. When the RTO instruction is disabled, it retains its .ACC value. You must clear the .ACC value, typically with a RES instruction referencing the same TIMER structure.
  • Page 126 Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Arithmetic Status Flags: Not affected Fault Conditions: A major fault will occur if Fault type Fault code .PRE < 0 .ACC < 0 Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 127 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Chapter 3 Execution: Condition Relay Ladder Action Prescan The .EN, .TT, and .DN bits are cleared. The .ACC value is not modified. The rung-condition-out is set to false. Rung-condition-in is false The .EN and .TT bits are cleared.
  • Page 128 Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Example: When limit_switch_1 is set, light_1 is on for 180 ms (timer_2 is timing). When timer_3.acc reaches 180, light_1 goes off and light_2 goes on. Light_2 remains until timer_3 is reset.
  • Page 129: Timer On Delay With Reset (Tonr)

    Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Chapter 3 Timer On Delay with Reset The TONR instruction is a non-retentive timer that accumulates time when (TONR) TimerEnable is set. This instruction is available in relay ladder as two separate instructions: ·...
  • Page 130 Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Description: The TONR instruction accumulates time until the following occurs: · TONR instruction is disabled · ACC ≥ PRE The time base is always 1 ms. For example, for a two-second timer, enter 2000 for the PRE value.
  • Page 131 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Chapter 3 Arithmetic Status Flags: Not affected Fault Conditions: None Execution: Condition Function Block Action Structured Text Action Prescan No action taken. No action taken. Instruction first scan EN, TT and DN are cleared.
  • Page 132: Structured Text

    Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Example: Each scan that limit_switch1 is set, the TONR instruction increments the ACC value by elapsed time until the ACC value reaches the PRE value. When ACC ≥...
  • Page 133: Timer Off Delay With Reset (Tofr)

    Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Chapter 3 Timer Off Delay with Reset The TOFR instruction is a non-retentive timer that accumulates time when (TOFR) TimerEnable is cleared. This instruction is available in relay ladder as two separate instructions: ·...
  • Page 134 Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Input Parameter Data Type Description Status DINT Status of the function block. InstructFault (Status.0) BOOL The instruction detected one of the following execution errors. This is not a minor or major controller error.
  • Page 135 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Chapter 3 After it updates the ACC, the timer sets last_time_scanned = current_time. This gets the timer ready for the next scan. Make sure to scan the timer at least every 69 minutes while it runs. Otherwise, the ACC IMPORTANT value won’t be correct.
  • Page 136: Structured Text

    Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Example: Each scan after limit_switch1 is cleared, the TOFR instruction increments the ACC value by elapsed time until the ACC value reaches the PRE value. When ACC ≥...
  • Page 137: Retentive Timer On With Reset (Rtor)

    Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Chapter 3 Retentive Timer On with The RTOR instruction is a retentive timer that accumulates time when Reset (RTOR) TimerEnable is set. This instruction is available in relay ladder as two separate instructions: ·...
  • Page 138 Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Description: The RTOR instruction accumulates time until it is disabled. When the RTOR instruction is disabled, it retains its ACC value. You must clear the .ACC value by using the Reset input.
  • Page 139 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Chapter 3 Arithmetic Status Flags: Not affected Fault Conditions: None Execution: Condition Function Block Action Structured Text Action Prescan No action taken. No action taken. Instruction first scan EN, TT and DN are cleared.
  • Page 140: Structured Text

    Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Example: Each scan that limit_switch1 is set, the RTOR instruction increments the ACC value by elapsed time until the ACC value reaches the PRE value. When ACC ≥...
  • Page 141: Count Up (Ctu)

    Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Chapter 3 Count Up (CTU) The CTU instruction counts upward. This instruction is available in structured text and function block as CTUD. Operands: Relay Ladder Operand Type Format Description...
  • Page 142 Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) The accumulated value continues incrementing, even after the .DN bit is set. To clear the accumulated value, use a RES instruction that references the counter structure or write 0 to the accumulated value.
  • Page 143 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Chapter 3 Execution: Condition Relay Ladder Action Prescan The .CU bit is set to prevent invalid increments during the first program scan. The rung-condition-out is set to false. Rung-condition-in is false The .CU bit is cleared.
  • Page 144 Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Example: After limit_switch_1 goes from disabled to enabled 10 times, the .DN bit is set and light_1 turns on. If limit_switch_1 continues to go from disabled to enabled, counter_1 continues to increment its count and the .DN bit remains set.
  • Page 145: Count Down (Ctd)

    Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Chapter 3 Count Down (CTD) The CTD instruction counts downward. This instruction is available in structured text and function block as CTUD. Operands: Relay Ladder Operand Type Format Description...
  • Page 146 Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Description: The CTD instruction is typically used with a CTU instruction that references the same counter structure. When enabled and the .CD bit is cleared, the CTD instruction decrements the counter by one.
  • Page 147 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Chapter 3 Execution: Condition Relay Ladder Action Prescan The .CD bit is set to prevent invalid decrements during the first program scan. The rung-condition-out is set to false. Rung-condition-in is false The .CD bit is cleared.
  • Page 148 Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Example: A conveyor brings parts into a buffer zone. Each time a part enters, limit_switch_1 is enabled and counter_1 increments by one. Each time a part leaves, limit_switch_2 is enabled and counter_1 decrements by one.
  • Page 149: Count Up/Down (Ctud)

    Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Chapter 3 Count Up/Down (CTUD) The CTUD instruction counts up by one when CUEnable transitions from clear to set. The instruction counts down by one when CDEnable transitions from clear to set.
  • Page 150 Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Output Parameter Data Type Description EnableOut BOOL The instruction produced a valid result. DINT Accumulated value. BOOL Count up enabled. BOOL Count down enabled. BOOL Counting done.
  • Page 151 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Chapter 3 Figure 2 - Counting Down CDEnable Count-down Enable Bit (CD) Count-down Done Bit (DN) Counter Accumulated Value (ACC) Preset 16637 When disabled, the CTUD instruction retains its accumulated value. Set the Reset input parameter of the FBD_COUNTER structure to reset the instruction.
  • Page 152: Structured Text

    Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Example: When limit_switch1 goes from cleared to set, CUEnable is set for one scan and the CTUD instruction increments the ACC value by 1. When ACC ≥...
  • Page 153: Reset (Res)

    Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Chapter 3 Reset (RES) The RES instruction resets a TIMER, COUNTER, or CONTROL structure. Operands: Relay Ladder Operand Type Format Description Structure TIMER Structure to reset CONTROL COUNTER Description:...
  • Page 154 Chapter 3 Timer and Counter Instructions (TON, TOF, RTO, TONR, TOFR, RTOR, CTU, CTD, CTUD, RES) Notes: Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 155: Input/Output Instructions

    Chapter Input/Output Instructions (MSG, GSV, SSV, IOT) Topic Page Message (MSG) MSG Error Codes Specify the Configuration Details MSG Configuration Examples Specify the Communication Details Get System Value (GSV) and Set System Value (SSV) GSV/SSV Objects GSV/SSV Programming Example Immediate Output (IOT) The input/output instructions read or write data to, or from, a controller or module.
  • Page 156: Message (Msg)

    Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) Message (MSG) The MSG instruction asynchronously reads or writes a block of data to another module on a network. Operands: Relay Ladder Operand Type Format Description Message MESSAGE Message structure control Structured Text MSG(MessageControl);...
  • Page 157 Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 Mnemonic Data Description Type .FLAGS The FLAGS member provides access to the status members (bits) in one 16-bit word. This bit Is this member .EN_CC Important: Do not change or manipulate the EN, EW, ER, DN, or ST bits of the FLAGS member. For example, do not clear the entire FLAGS word.
  • Page 158 Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) Mnemonic Data Description Type .Class To change the Class parameter of a CIP Generic message, set this member to the required value. .Attribute To change the Attribute parameter of a CIP Generic message, set this member to the required value. .Instance DINT To change the Instance parameter of a CIP Generic message, set this member to the required value.
  • Page 159 Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 Mnemonic Data Description Type .UnconnnectedTimeout DINT Time out for an unconnected message or for making a connection. The default value is 30 seconds. If the message is Then Unconnected The ER bit turns on if the controller doesn’t get a response within the UnconnectedTimeout time.
  • Page 160 Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) Connection with .EN_CC = 1 Rung-condition-in .EN bit .EW bit Connection with .EN_CC = 0 .ST bit .DN bit or .ER bit 41382 Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 161 Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 Where Description Where Description Rung-condition-in is true. Message is sent. .EN is set. .ST is set. .EW is set. .EW is cleared. Connection is opened*. Message is sent. Message is done or errored. .ST is set.
  • Page 162 Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) Condition Relay Ladder Action Structured Text Action Rung-condition-in is false. .EN bit = 1 (does not apply to structured text) Examine .EN Bit .EN Bit = 0 .EW bit = 1 Examine .EW Bit .EW Bit = 0 .ST bit = 1 Examine .ST Bit...
  • Page 163 Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 Condition Relay Ladder Action Structured Text Action EnableIn is set. EnableIn is always set. The instruction executes. Instruction execution .EN Bit = 1 .EN Bit = 0 Examine .EN Bit .EW Bit = 1 .EW bit = 1 Examine .EW Bit Examine .EW Bit...
  • Page 164 Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) Condition Relay Ladder Action Structured Text Action Postscan The rung-condition-out is set to false. No action taken. Arithmetic Status Flags: Not affected Fault Conditions: None Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 165: Msg Error Codes

    Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 MSG Error Codes The error codes depend on the type of MSG instruction. Error Codes The RSLogix 5000 programming software does not always display the full description. Error Code (Hex) Description Display In Software 0001 Connection failure (see extended error codes) Same as description...
  • Page 166 Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) Error Code (Hex) Description Display In Software 001D Invalid attribute list Same as description 001E Embedded service error 001F Connection related failure (see extended error codes) 0022 Invalid reply received 0025 Key segment error 0026 Invalid IOI error 0027...
  • Page 167: Extended Error Codes

    Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 Extended Error Codes The RSLogix 5000 programming software does not display any text for the extended error codes. These are the extended error codes for error code 0001. Extended Description Extended Description Error Code Error Code (Hex)
  • Page 168 Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) These are the extended error codes for error code 001F. Extended Error Code Description (Hex) 0203 Connection timeout These are the extended error codes for error code 0004 and 0005. Extended Error Code Description (Hex) 0000...
  • Page 169: Plc And Slc Error Codes (.Err)

    Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 PLC and SLC Error Codes (.ERR) Logix firmware revision 10.x and later provides new error codes for errors that are associated with PLC and SLC message types (PCCC messages). ·This change lets RSLogix 5000 software display a more meaningful description for many of the errors.
  • Page 170 Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) Table 2 - PLC and SLC Error Codes (hex) (Continued) R9.x And Earlier R10.x And Later Description .ERR .EXERR .ERR .EXERR 00F0 000D F00D Request is redundant 00F0 000E F00E Command cannot be executed 00F0 000F F00F...
  • Page 171: Block-Transfer Error Codes

    Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 Block-Transfer Error Codes These are the Logix5000 block-transfer specific error codes. Error Code (Hex) Description Display In Software 00D0 The scanner did not receive a block-transfer response from the block-transfer module within 3.5...
  • Page 172: Specify The Configuration Details

    Figure 3 - Message Configuration Tab 45634 If the target device is Select one of these message types Page Logix5000 controller CIP Data Table Read CIP Data Table Write I/O module that you configure by using RSLogix Module Reconfigure 5000 software...
  • Page 173: Specify This Data For A Logix5000 Controller As A Target Device

    · If you select a read message type, the Destination Element is the first element of the tag in the Logix5000 controller where you want to store the data you read from the target device. · If you select a write message type, the Destination Element is the address of the location in the target device where you want to write the data.
  • Page 174: Reconfigure An I/O Module

    Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) Reconfigure an I/O Module Use the Module Reconfigure message to send new configuration information to an I/O module. During the reconfiguration, the following occurs: • Input modules continue to send input data to the controller. •...
  • Page 175: Relay Ladder

    Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 Example: Follow these steps to reconfigure an I/O module. 1. Set the required member of the configuration tag of the module to the new value. 2. Send a Module Reconfigure message to the module. When reconfigure[5] is set, set the high alarm to 60 for the local module in slot 4.
  • Page 176: Specify Cip Generic Messages

    Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) Specify CIP Generic Messages If you want to In this property Type or select Perform a pulse test on a digital output Message Type CIP Generic module Service Type Pulse Test Source tag_name of type INT [5] This array contains Description...
  • Page 177 Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 If you want to In this property Type or select Reset electronic fuses on a digital output Message Type CIP Generic module Service Type Reset Electronic Fuse Source tag name of type DINT This tag represents a bit mask of the points to reset fuses on.
  • Page 178 Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) Table 3 - Get/Set Controller Events Monitored for Changes Bit Definitions Tag Names Data Type Bit Definition Get Controller Events Monitored for Changes DINT[0] Meaning Set Controller Events Monitored for Changes Store to removable media through RSLogix 5000 programming software Online edits were accepted, tested, or assembled Partial import online transaction completed SFC Forces were enabled...
  • Page 179: Specify Plc-5 Messages

    The data from the Source Element is stored, starting at the address specified as the Destination Tag. PLC5 Word Range Write Write a contiguous range of 16-bit words from Logix5000 memory regardless of data type to PLC- 5 memory. This command starts at the address specified as the Source Tag and reads sequentially the number of 16-bit words requested.
  • Page 180 (OS303 and above), SLC 5/04 processors (OS402 and above), and SLC 5/05 processors. The following diagrams show how the typed and word-range commands differ. The example uses read commands from a PLC-5 processor to a Logix5000 controller. Typed Read Command...
  • Page 181: Specify Slc Messages

    Use the SLC message types to communicate with SLC and MicroLogix controllers. The following table shows which data types that the instruction lets you access. The table also shows the corresponding Logix5000 data type. For this SLC or MicroLogix data type...
  • Page 182: Specify Plc-3 Messages

    The data from the Source Element is stored, starting at the address specified as the Destination Tag. PLC3 Word Range Write Write a contiguous range of 16-bit words from Logix5000 memory regardless of data type to PLC- 3 memory. This command starts at the address specified as the Source Tag and reads sequentially the number of 16-bit words requested.
  • Page 183: Specify Plc-2 Messages

    Logix5000 Source tag array_1[0] Destination tag array_2[0] You can use an alias tag for the source tag (in originating Logix5000 controller). You cannot use an alias for the destination tag. The destination must be a base tag. → Logix5000 PLC-5...
  • Page 184: Specify The Communication Details

    Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) Specify the You typically set up a broadcast in ladder logic or structured text programs. In Communication Details ladder logic, you can add a rung and click on the MSG property to access the Message Configuration dialog box to set up a new message.
  • Page 185 Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 Example The I/O configuration of the controller has the module that gets the message. Click Browse and select the module. The I/O configuration of the controller has only the local communication module. Go to the local communication module.
  • Page 186: Broadcast Button

    Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) To type a path, use this format: port, next_address, port, next_address, … Where For this network Type Backplane Port DF1 (serial, serial channel 0) 2 ControlNet EtherNet/IP DH+ channel A DH+ channel B DF1 channel 1 (serial channel 1) Backplane...
  • Page 187 Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 By default, the Path radio button on the Communication tab is active (dot in radio button). Do these steps to enable the Broadcast button and select a channel to default a path for the message. 1.
  • Page 188: System Protocol Tab Configuration

    Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) System Protocol Tab Configuration To run broadcast in ControlLogix in the RSLogix 5000 programming software, you must configure the System Protocol tab in the Controller Properties dialog box. The protocol must be compatible with the message type of ‘write’ on the Message Configuration dialog box.
  • Page 189 Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 4. Choose a protocol from the Protocol box. The Message Type box on the Message Configuration Tab IMPORTANT dialog box must be write-typed to be compatible with the system protocol. Otherwise, the Broadcast button is disabled.
  • Page 190: For Block Transfers

    Use the following table to select a communication method or module address for the message. If the destination device is Then select And specify Logix5000 controller No other specifications required. PLC-5 controller over an EtherNet/IP network PLC-5 controller over a ControlNet...
  • Page 191: Choose A Cache Option

    Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 If the destination device is Then select And specify Block transfer module over a Channel Channel A or B of the 1756-DHRIO module that is universal remote I/O network connected to the RIO network. Rack Rack number (octal) of the module.
  • Page 192 Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) If a MSG instruction uses a connection, you have the option to leave the connection open (cache) or close the connection when the message is done transmitting. If you Then Cache the connection The connection stays open after the MSG instruction is done.
  • Page 193: Guidelines

    This increases the efficiency of your project because Logix controllers execute more efficiently and use less memory when working with 32-bit integers (DINTs). To convert between INTs and DINTs, see the Logix5000 Controllers Common Procedures Programming Manual, publication 1756-PM001. 4. Cache the connected MSGs that execute most Cache the connection for those MSG instructions that execute most frequently, up to the frequently.
  • Page 194: Get System Value (Gsv) And Set System Value (Ssv)

    Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) Get System Value (GSV) and The GSV/SSV instructions get and set controller system data that is stored Set System Value (SSV) in objects. Operands: Relay Ladder Operand Type Format Description Class name Name Name of object.
  • Page 195: Structured Text

    Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 Structured Text GSV(ClassName,InstanceName,AttributeName,Dest); SSV(ClassName,InstanceName,AttributeName,Source); The operands for are the same as those for the relay ladder GSV and SSV instructions. Description: The GSV/SSV instructions get and set controller system data that is stored in objects.
  • Page 196 Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) ATTENTION: Use the GSV and SSV instructions carefully. Making changes to objects may cause unexpected controller operation or injury to personnel. You must test and confirm that the instructions don’t change data that you don’t want them to change.
  • Page 197 Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 The GSV/SSV Objects section shows each object’s attributes and their associated data types. For example, the MajorFaultRecord attribute of the Program object needs a DINT[11] data type. Arithmetic Status Flags: Not affected Fault Conditions: A minor fault will occur if Fault type...
  • Page 198: Gsv/Ssv Objects

    Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) GSV/SSV Objects When you enter a GSV/SSV instruction, you specify the object and its attribute that you want to access. In some cases, there will be more than one instance of the same type of object, so you might also have to specify the object name.
  • Page 199: Addoninstructiondefintion Attributes

    AddOnInstructionDefintion Attributes The AddOnInstructionDefinition object lets you customize instructions for sets of commonly-used logic, provides a common interface to this logic, and provides documentation for the instruction. For details, see the Logix5000 Controllers Add-On Instructions Programming Manual, publication 1756-PM010. Attribute...
  • Page 200 Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) Attribute Data Type Instruction Description CanUseRPIFrom DINT Identifies whether to use the RPI specified by the producer. Producer Value Meaning Do not use the RPI specified by the producer Use the RPI specified by the producer ControllerLog DINT Number of controller log entries that originated from a program/task properties change, an online...
  • Page 201: Controllerdevice Attributes

    Recoverable minor fault 0010 Unrecoverable minor fault 0100 Recoverable major fault 1000 Unrecoverable major fault Type Identifies the device as a controller. Controller = 14. Vendor Identifies the vendor of the device. Allen-Bradley = 0001. Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 202: Cst Attributes

    Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) CST Attributes The coordinated system time (CST) object provides coordinated system time for the devices in one chassis. Attribute Data Type Instruction Description CurrentStatus Current status of the coordinated system time. Meaning Timer hardware faulted: the device’s internal timer hardware is in a faulted state Ramping enabled: the current value of the timer’s lower 16+ bits ramp up to...
  • Page 203: Df1 Attributes

    Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 DF1 Attributes The DF1 object provides an interface to the DF1 communication driver that you can configure for the serial port. Attribute Data Type Instruction Description ACKTimeout DINT The amount of time to wait for an acknowledgment to a message transmission (point-to-point and master only).
  • Page 204 Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) Attribute Data Type Instruction Description NAKReceiveLimit SINT The number of NAKs received in response to a message before stopping transmission (point-to- point communication only). Valid value 0...127. Default is 3. NormalPollGroupSi Number of stations to poll in the normal poll node array after polling all the stations in the priority poll node array (master only).
  • Page 205: Faultlog Attributes

    Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 Attribute Data Type Instruction Description PendingReply DINT Pending value for the ReplyMessageWait attribute. MessageWait PendingSlavePollTi DINT Pending value for the SlavePollTimeout attribute. meout PendingStation Pending value for the StationAddress attribute. Address PendingToken SINT Pending value for the TokenHoldFactor attribute.
  • Page 206: Module Attributes

    Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) Attribute Data Type Instruction Description MessageType SINT Specifies the type of message. Value Meaning Not initialized Port SINT Indicates which port the message should be sent on. Value Meaning Backplane Serial port Timeout SINT Determines when a connection should be considered timed out and closed.
  • Page 207: Program Attributes

    Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 Attribute Data Type Instruction Description Instance DINT Provides the instance number of this module object. LEDStatus Specifies the current state of the I/O status indicator on the front of the controller. Value Meaning Status indicator off: No Module objects are configured for the controller.
  • Page 208: Routine Attributes

    Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) Attribute Data Type Instruction Instruction Description within within Standard Safety Task Task MinorFault DINT[11] Records minor faults for this program Record We recommend that you create a user-defined structure to simplify access to the MinorFaultRecord attribute: Name Data TypeStyleDescription...
  • Page 209: Safety Attributes

    Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 Safety Attributes The Safety Controller object provides safety status and safety signature information. The SafetyTask and SafetyFaultRecord attributes can capture information about non-recoverable faults. See the GuardLogix Controllers User Manual, publication 1756-UM020. Attribute Data Type Instruction...
  • Page 210: Task Attributes

    Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) Attribute Data Type Instruction Description RTSSendDelay Amount of time to delay transmitting the first character of a message after turning on the RTS line. Valid value 0...32,767. Delay in counts of 20 msec periods. The default is 0 msec. StopBits SINT Specifies the number of stop bits.
  • Page 211: Wallclocktime Attributes

    Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 Attribute Data Type Instruction Instruction Description within within Standard Safety Task Task MinimumInterval DINT[2] None The minimum time interval between successive executions of the task. DINT[0] contains the lower 32 bits of the value; DINT[1] contains the upper 32 bits of the value.
  • Page 212 Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) Attribute Data Type Instruction Description DateTime DINT[7] The date and time. Value Meaning DINT[0] Year DINT[1] Month (1...12) DINT[2] Day (1...31) DINT[3] Hour (0...23) DINT[4] Minute (0...59) DINT[5] Seconds (0...59) DINT[6] Microseconds (0...999,999) DSTAdjustment The number of minutes to adjust for daylight saving time.
  • Page 213: Gsv/Ssv Programming Example

    Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 GSV/SSV Programming Get Fault Information Example The following examples use GSV instructions to get fault information. Example 1: This example gets fault information from the I/O module disc_in_2 and places the data in a user-defined structure disc_in_2_info. Relay Ladder Structured Text GSV(MODULE,disc_in_2,FaultCode,disc_in_2_info.FaultCode);...
  • Page 214: Structured Text

    Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) Structured Text GSV(PROGRAM,DISCRETE,LASTSCANTIME, discrete_info.LastScanTime); GSV(PROGRAM,DISCRETE,MAXSCANTIME,discrete_info.MaxScanTim Example 3: This example gets status information about task IO_test and places the data in a user-defined structure io_test_info. Relay Ladder Structured Text GSV(TASK,IO_TEST,LASTSCANTIME,io_test_info.LastScanTime); GSV(TASK,IO_TEST,MAXSCANTIME,io_test_info.MaxScanTime); GSV(TASK,IO_TEST, W ATCHDOG,io_test_info.WatchDog); Set Enable And Disable Flags The following example uses the SSV instruction to enable or disable a program.
  • Page 215: Relay Ladder

    Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 Example: Based on the status of SW.1, place the appropriate value in the disableflag attribute of program discrete. Relay Ladder Structured Text IF SW.1 THEN discrete_prog_flag := enable_prog; ELSE discrete_prog_flag := disable_prog; END_IF;...
  • Page 216: Immediate Output (Iot)

    Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) Immediate Output (IOT) The IOT instruction immediately updates the specified output data (output tag or produced tag). Operands: Relay Ladder Operand Type Format Description Update Tag Tag that you want to update, either: ·...
  • Page 217 Input/Output Instructions (MSG, GSV, SSV, IOT) Chapter 4 The type of network between the controllers determines when the consuming controller receives the new data and event trigger via the IOT instruction. With this controller Over this network The consuming device receives the data and event trigger ControlLogix Backplane...
  • Page 218: Relay Ladder

    Chapter 4 Input/Output Instructions (MSG, GSV, SSV, IOT) Example 1: When the IOT instruction executes, it immediately sends the values of the Local:5:0 tag to the output module. Relay Ladder Structured Text IOT (Local:5:O); Example 2: This controller controls station 24 and produces data for the next station (station 25).
  • Page 219: Compare Instructions

    Chapter Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Topic Page Compare (CMP) Equal To (EQU) Greater Than or Equal To (GEQ) Greater Than (GRT) Less Than or Equal To (LEQ) Less Than (LES) Limit (LIM) Mask Equal To (MEQ) Not Equal To (NEQ) The compare instructions let you compare values by using an expression or a specific compare instruction.
  • Page 220 Chapter 5 Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) If you want to Use this instruction Available in these languages Page Test whether one value is less than or equal to Relay ladder a second value Structured text Function block Test whether one value is less than a...
  • Page 221: Compare (Cmp)

    Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5 Compare (CMP) The CMP instruction performs a comparison on the arithmetic operations you specify in the expression. Operands: Relay Ladder Operand Type Format Description Expression SINT Immediate Tag An expression consisting of tags and/or immediate values separated by operators.
  • Page 222 Chapter 5 Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Execution: Condition Relay Ladder Action Prescan The rung-condition-out is set to false. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true Expression is true. Rung-condition-out is set Evaluate Expression to true.
  • Page 223: Cmp Expressions

    Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5 CMP Expressions You program expressions in CMP instructions the same as expressions in FSC instructions. Use the following sections for information on valid operators, format, and order of operation, which are common to both instructions. Valid Operators Operator: Description...
  • Page 224: Determine The Order Of Operation

    Chapter 5 Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Determine the Order of Operation The operations you write into the expression are performed by the instruction in a prescribed order, not necessarily the order you write them. You can override the order of operation by grouping terms within parentheses, forcing the instruction to perform an operation within the parentheses ahead of other operations.
  • Page 225: Use Strings In An Expression

    Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5 Use Strings in an Expression Use a relay ladder or structured text expression to compare string data types. To use strings in an expression, follow these guidelines: ·...
  • Page 226: Equal To (Equ)

    Chapter 5 Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Equal To (EQU) The EQU instruction tests whether Source A is equal to Source B. Operands: Relay Ladder Operand Type Format Description Source A SINT Immediate Tag Value to test against Source B DINT...
  • Page 227: Function Block

    Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5 Function Block Operand Type Format Description EQU tag FBD_COMPARE Structure EQU structure FBD_COMPARE Structure Input Parameter Data Type Description EnableIn BOOL Enable input. If cleared, the instruction does not execute and outputs are not updated. Default is set.
  • Page 228: Relay Ladder

    Chapter 5 Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Relay Ladder Condition Action Prescan The rung-condition-out is set to false. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true Rung-condition-out is set Source A = Source B to true.
  • Page 229: Relay Ladder

    Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5 Example: If value_1 is equal to value_2, set light_a. If value_1 is not equal to value_2, clear light_a. Relay Ladder Structured Text light_a := (value_1 = value_2); Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 230: Greater Than Or Equal To (Geq)

    Chapter 5 Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Greater Than or Equal To The GEQ instruction tests whether Source A is greater than or equal to Source B. (GEQ) Operands: Relay Ladder Operand Type Format Description Source A SINT...
  • Page 231: Function Block

    Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5 Function Block Operand Type Format Description GEQ tag FBD_COMPARE Structure GEQ structure FBD_COMPARE Structure Input Parameter Data Type Description EnableIn BOOL Enable input. If cleared, the instruction does not execute and outputs are not updated. Default is set.
  • Page 232: Relay Ladder

    Chapter 5 Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Arithmetic Status Flags: Not affected Fault Conditions: None Execution: Relay Ladder Condition Action Prescan The rung-condition-out is set to false. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true Rung-condition-out is set Source A ≥...
  • Page 233: Relay Ladder

    Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5 Example: If value_1 is greater than or equal to value_2, set light_b. If value_1 is less than value_2, clear light_b. Relay Ladder Structured Text light_b := (value_1 >= value_2); Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 234: Greater Than (Grt)

    Chapter 5 Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Greater Than (GRT) The GRT instruction tests whether Source A is greater than Source B. Operands: Relay Ladder Operand Type Format Description Source A SINT Immediate Tag Value to test against Source B DINT REAL...
  • Page 235: Function Block

    Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5 Function Block Operand Type Format Description GRT tag FBD_COMPARE Structure GRT structure FBD_COMPARE Structure Input Parameter Data Type Description EnableIn BOOL Enable input. If cleared, the instruction does not execute and outputs are not updated. Default is set.
  • Page 236: Relay Ladder

    Chapter 5 Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Fault Conditions: None Execution: Relay Ladder Condition Action Prescan The rung-condition-out is set to false. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true Rung-condition-out is set Source A >...
  • Page 237: Relay Ladder

    Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5 Example: If value_1 is greater than value_2, set light_1. If value_1 is less than or equal to value_2, clear light_1. Relay Ladder Structured Text light_1 := (value_1 > value_2); Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 238: Less Than Or Equal To (Leq)

    Chapter 5 Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Less Than or Equal To (LEQ) The LEQ instruction tests whether Source A is less than or equal to Source B. Operands: Relay Ladder Operand Type Format Description Source A SINT...
  • Page 239: Function Block

    Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5 Function Block Operand Type Format Description LEQ tag FBD_COMPARE Structure LEQ structure FBD_COMPARE Structure Input Parameter Data Type Description EnableIn BOOL Enable input. If cleared, the instruction does not execute and outputs are not updated. Default is set.
  • Page 240: Relay Ladder

    Chapter 5 Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Fault Conditions: None Execution: Relay Ladder Condition Action Prescan The rung-condition-out is set to false. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true Rung-condition-out is set Source A ≤...
  • Page 241: Relay Ladder

    Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5 Example: If value_1 is less than or equal to value_2, set light_2. If value_1 is greater than value_2, clear light_2. Relay Ladder Structured Text light_2 := (value_1 <= value_2); Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 242: Less Than (Les)

    Chapter 5 Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Less Than (LES) The LES instruction tests whether Source A is less than Source B. Operands: Relay Ladder Operand Type Format Description Source A SINT Immediate Tag Value to test against Source B DINT REAL...
  • Page 243: Function Block

    Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5 Function Block Operand Type Format Description LES tag FBD_COMPARE Structure LES structure FBD_COMPARE Structure Input Parameter Data Type Description EnableIn BOOL Enable input. If cleared, the instruction does not execute and outputs are not updated. Default is set.
  • Page 244: Relay Ladder

    Chapter 5 Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Fault Conditions: None Execution: Relay Ladder Condition Action Prescan The rung-condition-out is set to false. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true Rung-condition-out is set Source A <...
  • Page 245: Relay Ladder

    Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5 Example: If value_1 is less than value_2, set light_3. If value_1 is greater than or equal to value_2, clear light_3. Relay Ladder Structured Text light_3 := (value_1 < value_2); Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 246: Limit (Lim)

    Chapter 5 Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Limit (LIM) The LIM instruction tests whether the Test value is within the range of the Low Limit to the High Limit. Operands: Relay Ladder Operand Type Format Description Low limit...
  • Page 247: Function Block

    Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5 Function Block Operand Type Format Description LIM tag FBD_LIMIT Structure LIM structure FBD_LIMIT Structure Input Parameter Data Type Description EnableIn BOOL If cleared, the instruction does not execute and outputs are not updated. If set, the instruction executes as described under Execution.
  • Page 248 Chapter 5 Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Description: The LIM instruction tests whether the Test value is within the range of the Low Limit to the High Limit. If Low Limit And Test Value Is The Rung-condition-out Is ≤...
  • Page 249: Relay Ladder

    Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5 Execution: Relay Ladder Condition Action Prescan The rung-condition-out is set to false. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true Comparison is true. Rung-condition-out is set Evaluate Limit to true.
  • Page 250: Relay Ladder

    Chapter 5 Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Example 1: Low Limit ≤ High Limit: When 0 ≤ value ≥ 100, set light_1. If value < 0 or value >100, clear light_1. Relay Ladder Structured Text IF (value <= 100 AND(value >= 0 AND value <= 100)) OR value >= 100 AND value <= 0 OR value >= 100)) THEN light_1 := 1;...
  • Page 251: Relay Ladder

    Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5 Example 2: Low Limit ≥ High Limit: When value ≥ 0 or value ≤ −100, set light_1. If value < 0 or value >−100, clear light_1. Relay Ladder Structured Text IF (0 <= -100 AND value >= 0 AND value <= -100)) OR (0 >= -100 AND(value <= 0 OR value >= -100)) THEN...
  • Page 252: Mask Equal To (Meq)

    Chapter 5 Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Mask Equal To (MEQ) The MEQ instruction passes the Source and Compare values through a Mask and compares the results. Operands: Relay Ladder Operand Type Format Description Source SINT Immediate Tag...
  • Page 253: Fbd_Mask_Equal Structure

    Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5 FBD_MASK_EQUAL Structure Input Parameter Data Type Description EnableIn BOOL If cleared, the instruction does not execute and outputs are not updated. If set, the instruction executes as described under Execution. Default is set.
  • Page 254: Relay Ladder

    Chapter 5 Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Arithmetic Status Flags: Not affected Fault Conditions: None Execution: Relay Ladder Condition Action Prescan The rung-condition-out is set to false. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true Masked Source = Rung-condition-out is set...
  • Page 255: Relay Ladder

    Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5 Example 1: If the masked value_1 is equal to the masked value_2, set light_1. If the masked value_1 is not equal to the masked value_2, clear light_1. This example shows that the masked values are equal.
  • Page 256: Relay Ladder

    Chapter 5 Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Example 2: If the masked value_1 is equal to the masked value_2, set light_1. If the masked value_1 is not equal to the masked value_2, clear light_1. This example shows that the masked values are not equal.
  • Page 257: Not Equal To (Neq)

    Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5 Not Equal To (NEQ) The NEQ instruction tests whether Source A is not equal to Source B. Operands: Relay Ladder Operand Type Format Description Source A SINT Immediate Tag Value to test against Source B DINT...
  • Page 258: Function Block

    Chapter 5 Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Function Block Operand Type Format Description NEQ tag FBD_COMPARE Structure NEQ structure FBD_COMPARE Structure Input Parameter Data Type Description EnableIn BOOL Enable input. If cleared, the instruction does not execute and outputs are not updated. Default is set.
  • Page 259: Relay Ladder

    Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Chapter 5 Execution: Relay Ladder Condition Action Prescan The rung-condition-out is set to false. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true Rung-condition-out is set Source A = Source B to true.
  • Page 260: Relay Ladder

    Chapter 5 Compare Instructions (CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ) Example: If value_1 is not equal to value_2, set light_4. If value_1 is equal to value_2, clear light_4. Relay Ladder Structured Text light_4 := (value_1 <> value_2); Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 261 Chapter Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Topic Page Compute (CPT) Add (ADD) Subtract (SUB) Multiply (MUL) Divide (DIV) Modulo (MOD) Square Root (SQR) Negate (NEG) Absolute Value (ABS) The compute/math instructions evaluate arithmetic operations by using an expression or a specific arithmetic instruction.
  • Page 262: Compute (Cpt)

    Chapter 6 Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) If you want to Use this instruction Available in these languages Page Calculate the square root of a value Relay ladder SQRT Structured text Function block Take the opposite sign of a value Relay ladder Structured text...
  • Page 263 Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Chapter 6 Description: The CPT instruction performs the arithmetic operations you define in the expression. When enabled, the CPT instruction evaluates the expression and places the result in the Destination. The execution of a CPT instruction is slightly slower and uses more memory than the execution of the other compute/math instructions.
  • Page 264: Valid Operators

    Chapter 6 Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Valid Operators Operator Description Optimal Operator Description Optimal DINT, REAL modulo-divide DINT, REAL subtract/negate DINT, REAL bitwise complement DINT multiply DINT, REAL bitwise OR DINT divide DINT, REAL degrees to radians DINT, REAL...
  • Page 265: Determine The Order Of Operation

    Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Chapter 6 Determine the Order of Operation The operations you write into the expression are performed by the instruction in a prescribed order, not necessarily the order you write them. You can override the order of operation by grouping terms within parentheses, forcing the instruction to perform an operation within the parentheses ahead of other operations.
  • Page 266: Add (Add)

    Chapter 6 Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Add (ADD) The ADD instruction adds Source A to Source B and places the result in the Destination. Operands: Relay Ladder Operand Type Format Description Source A SINT Immediate Tag Value to add to Source B...
  • Page 267: Fbd_Math Structure

    Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Chapter 6 FBD_MATH Structure Input Parameter Data Type Description EnableIn BOOL Enable input. If cleared, the instruction does not execute and outputs are not updated. Default is set. SourceA REAL Value to add to SourceB.
  • Page 268: Relay Ladder

    Chapter 6 Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Example: Add float_value_1 to float_value_2 and place the result in add_result. Relay Ladder Structured Text add_result := float_value_1 + float_value_2; Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 269: Subtract (Sub)

    Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Chapter 6 Subtract (SUB) The SUB instruction subtracts Source B from Source A and places the result in the Destination. Operands: Relay Ladder Operand Type Format Description Source A SINT Immediate Tag Value from which to subtract Source B...
  • Page 270: Fbd_Math Structure

    Chapter 6 Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) FBD_MATH Structure Input Parameter Data Type Description EnableIn BOOL Enable input. If cleared, the instruction does not execute and outputs are not updated. Default is set. SourceA REAL Value from which to subtract SourceB.
  • Page 271: Relay Ladder

    Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Chapter 6 Example: Subtract float_value_2 from float_value_1 and place the result in subtract_result. Relay Ladder Structured Text subtract_result := float_value_1 - float_value_2; Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 272: Multiply (Mul)

    Chapter 6 Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Multiply (MUL) The MUL instruction multiplies Source A with Source B and places the result in the Destination. Operands: Relay Ladder Operand Type Format Description Source A SINT Immediate Tag Value of the multiplicand...
  • Page 273: Fbd_Math Structure

    Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Chapter 6 FBD_MATH Structure Input Parameter Data Type Description EnableIn BOOL Enable input. If cleared, the instruction does not execute and outputs are not updated. Default is set. Source A REAL Value of the multiplicand.
  • Page 274: Relay Ladder

    Chapter 6 Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Example: Multiply float_value_1 by float_value_2 and place the result in multiply_result. Relay Ladder Structured Text multiply_result := float_value_1 ∗ float_value_2; Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 275: Divide (Div)

    Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Chapter 6 Divide (DIV) The DIV instruction divides Source A by Source B and places the result in the Destination. Operands: Relay Ladder Operand Type Format Description Source A SINT Immediate Tag Value of the dividend...
  • Page 276: Fbd_Math Structure

    Chapter 6 Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) FBD_MATH Structure Input Parameter Data Type Description EnableIn BOOL Enable input. If cleared, the instruction does not execute and outputs are not updated. Default is set. Source A REAL Value of the dividend.
  • Page 277: Relay Ladder

    Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Chapter 6 To detect a possible divide-by-zero, examine the minor fault bit (S:MINOR). See Logix5000 Controllers Common Procedures Programming Manual, publication 1756-PM001. Arithmetic Status Flags: Arithmetic status flags are affected.
  • Page 278: Structured Text

    Chapter 6 Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Structured Text divide_result := float_value_1 / float_value_2; Function Block Example 2: The DIV and MOV instructions work together to divide two integers, round the result, and place the result in an integer tag: •...
  • Page 279: Modulo (Mod)

    Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Chapter 6 Modulo (MOD) The MOD instruction divides Source A by Source B and places the remainder in the Destination. Operands: Relay Ladder Operand Type Format Description Source A SINT Immediate Tag Value of the dividend...
  • Page 280: Fbd_Math Structure

    Chapter 6 Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) FBD_MATH Structure Input Parameter Data Type Description EnableIn BOOL Enable input. If cleared, the instruction does not execute and outputs are not updated. Default is set. Source A REAL Value of the dividend.
  • Page 281: Relay Ladder

    Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Chapter 6 To detect a possible divide-by-zero, examine the minor fault bit (S:MINOR). See Logix5000 Controllers Common Procedures Programming Manual, publication 1756-PM001. Arithmetic Status Flags: Arithmetic status flags are affected.
  • Page 282: Relay Ladder

    Chapter 6 Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Example: Divide dividend by divisor and place the remainder in remainder. In this example, three goes into 10 three times, with a remainder of one. Relay Ladder Structured Text remainder := dividend MOD divisor;...
  • Page 283: Square Root (Sqr)

    Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Chapter 6 Square Root (SQR) The SQR instruction computes the square root of the Source and places the result in the Destination. Operands: Relay Ladder Operand Type Format Description Source SINT...
  • Page 284: Relay Ladder

    Chapter 6 Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Description: If the Destination is not a REAL, the instruction handles the fractional portion of the result as follows: If the source is Then the fractional Example portion of the result Not a REAL...
  • Page 285: Relay Ladder

    Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Chapter 6 Example: Calculate the square root of value_1 and place the result in sqr_result. Relay Ladder Structured Text sqr_result := SQRT(value_1); Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 286: Negate (Neg)

    Chapter 6 Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Negate (NEG) The NEG instruction changes the sign of the Source and places the result in the Destination. Operands: Relay Ladder Operand Type Format Description Source SINT Immediate Tag Value to negate...
  • Page 287: Relay Ladder

    Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Chapter 6 Description: If you negate a negative value, the result is positive. If you negate a positive value, the result is negative. Arithmetic Status Flags: Arithmetic status flags are affected. Fault Conditions: None Execution:...
  • Page 288: Relay Ladder

    Chapter 6 Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Example: Change the sign of value_1 and place the result in negate_result. Relay Ladder Structured Text negate_result := -value_1; Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 289: Absolute Value (Abs)

    Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Chapter 6 Absolute Value (ABS) The ABS instruction takes the absolute value of the Source and places the result in the Destination. Operands: Relay Ladder Operand Type Format Description Source SINT...
  • Page 290: Relay Ladder

    Chapter 6 Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Description: The ABS instruction takes the absolute value of the Source and places the result in the Destination. Arithmetic Status Flags: Arithmetic status flags are affected. Fault Conditions: None Execution:...
  • Page 291: Relay Ladder

    Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Chapter 6 Example: Place the absolute value of value_1 into value_1_absolute. In this example, the absolute value of negative four is positive four. Relay Ladder Structured Text value_1_absolute := ABS(value_1); Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 292 Chapter 6 Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS) Notes: Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 293 Chapter Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Topic Page Move (MOV) Masked Move (MVM) Masked Move with Target (MVMT) Bit Field Distribute (BTD) Bit Field Distribute with Target (BTDT) Clear (CLR) Swap Byte (SWPB) Bitwise AND (AND)
  • Page 294 Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) If you want to Use this instruction Available in these languages Page Copy a value Relay ladder Structured text Copy a specific part of an integer Relay ladder Copy a specific part of an integer in function block MVMT...
  • Page 295: Move (Mov)

    Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Move (MOV) The MOV instruction copies the Source to the Destination. The Source remains unchanged. Operands: Relay Ladder Operand Type Format Description Source SINT...
  • Page 296: Relay Ladder

    Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Example: Move the data in value_1 to value_2. Relay Ladder Structured Text value_2 := value _1; Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 297: Masked Move (Mvm)

    Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Masked Move (MVM) The MVM instruction copies the Source to a Destination and allows portions of the data to be masked. This instruction is available in structured text and function block as MVMT, see page 300.
  • Page 298: Enter An Immediate Mask Value

    Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Enter an Immediate Mask Value When you enter a mask, the programming software defaults to decimal values. If you want to enter a mask by using another format, precede the value with the correct prefix. Prefix Description Hexadecimal...
  • Page 299: Relay Ladder

    Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Relay Ladder Structured Text value_b := (value_b AND NOT (mask_2)) OR (value_a AND mask_2); Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 300: Masked Move With Target (Mvmt)

    Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Masked Move with Target The MVMT instruction first copies the Target to the Destination. Then the instruction compares the masked Source to the Destination and makes any required changes to the (MVMT) Destination.
  • Page 301: Enter An Immediate Mask Value By Using An Input Reference

    Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Description: When enabled, the MVMT instruction uses a Mask to either pass or block Source data bits. A ‘1’ in the mask means the data bit is passed. A ‘0’ in the mask means the data bit is blocked.
  • Page 302: Structured Text

    Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) 2. Mask Source and compare it to Dest. Any required changes are made in Dest. Source and Target remain unchanged. A 0 in the mask restrains the instruction from comparing that bit (shown by x in the example).
  • Page 303: Bit Field Distribute (Btd)

    Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Bit Field Distribute (BTD) The BTD instruction copies the specified bits from the Source, shifts the bits to the appropriate position, and writes the bits into the Destination. This instruction is available in structured text and function block as BTDT, page 306.
  • Page 304 Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Execution: Condition Relay Ladder Action Prescan The rung-condition-out is set to false. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true The instruction copies and shifts the Source bits to the Destination.
  • Page 305 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 source value_1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 destination bit value_2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
  • Page 306: Bit Field Distribute With Target (Btdt)

    Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Bit Field Distribute with The BTDT instruction first copies the Target to the Destination. Then the instruction copies the specified bits from the Source, shifts the bits to the appropriate position, and Target (BTDT) writes the bits into the Destination.
  • Page 307 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Description: When enabled, the BTD instruction copies a group of bits from the Source to the Destination. The group of bits is identified by the Source bit (lowest bit number of the group) and the Length (number of bits to copy).
  • Page 308: Structured Text

    Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Structured Text BTDT_01.Source := source; BTDT_01.SourceBit := source_bit; BTDT_01.Length := length; BTDT_01.DestBit := dest_bit; BTDT_01.Target := target; BTDT(BTDT_01); distributed_value := BTDT_01.Dest; Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 309: Clear (Clr)

    Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Clear (CLR) The CLR instruction clears all the bits of the Destination. Operands: Relay Ladder Operand Type Format Description Destination SINT Tag to clear DINT REAL...
  • Page 310: Relay Ladder

    Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Example: Clear all the bits of value to 0. Relay Ladder Structured Text value := 0; Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 311: Swap Byte (Swpb)

    Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Swap Byte (SWPB) The SWPB instruction rearranges the bytes of a value. Operands: Relay Ladder Operand Type Format Enter Source Tag that contains the bytes that you want to rearrange DINT REAL Order Mode...
  • Page 312: Structured Text

    Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Structured Text SWPB(Source,OrderMode,Dest); The operands are the same as those for the relay ladder SWPB instruction. If you select the HIGH/LOW order mode, enter it as HIGHLOW or HIGH_LOW (without the slash).
  • Page 313: Relay Ladder

    Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Example 1: The three SWPB instructions each reorder the bytes of DINT_1 according to a different order mode. The display style is ASCII, and each character represents one byte. Each instruction places the bytes, in the new order, in a different Destination.
  • Page 314: Relay Ladder

    Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Relay Ladder Initialize the tags. Reverse the bytes. Determine whether the SWPB instruction has acted on all the elements in the array. Structured Text index := 0;...
  • Page 315: Bitwise And (And)

    Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Bitwise AND (AND) The AND instruction performs a bitwise AND operation by using the bits in Source A and Source B and places the result in the Destination. To perform a logical AND, see page 331.
  • Page 316: Fbd_Logical Structure

    Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) FBD_LOGICAL Structure Input Parameter Data Type Description EnableIn BOOL Enable input. If cleared, the instruction does not execute and outputs are not updated. Default is set.
  • Page 317: Function Block

    Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Function Block Condition Action Prescan No action taken. Instruction first scan No action taken. Instruction first run No action taken. EnableIn is cleared EnableOut is cleared.
  • Page 318: Relay Ladder

    Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Relay Ladder Structured Text value_result_and := value_1 AND value_2; Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 319: Bitwise Or (Or)

    Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Bitwise OR (OR) The OR instruction performs a bitwise OR operation by using the bits in Source A and Source B and places the result in the Destination. Operands: Relay Ladder Operand...
  • Page 320: Fbd_Logical Structure

    Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) FBD_LOGICAL Structure Input Parameter Data Type Description EnableIn BOOL Enable input. If cleared, the instruction does not execute and outputs are not updated. Default is set.
  • Page 321: Function Block

    Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Function Block Condition Action Prescan No action taken. Instruction first scan No action taken. Instruction first run No action taken. EnableIn is cleared EnableOut is cleared.
  • Page 322: Relay Ladder

    Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Relay Ladder Structured Text value_result_or := value_1 OR value_2; Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 323: Bitwise Exclusive Or (Xor)

    Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Bitwise Exclusive OR (XOR) The XOR instruction performs a bitwise XOR operation by using the bits in Source A and Source B and places the result in the Destination. To perform a logical XOR, see page 337.
  • Page 324: Fbd_Logical Structure

    Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) FBD_LOGICAL Structure Input Parameter Data Type Description EnableIn BOOL Enable input. If cleared, the instruction does not execute and outputs are not updated. Default is set.
  • Page 325: Function Block

    Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Function Block Condition Action Prescan No action taken. Instruction first scan No action taken. Instruction first run No action taken. EnableIn is cleared EnableOut is cleared.
  • Page 326: Relay Ladder

    Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Relay Ladder Structured Text value_result_xor := value_1 XOR value_2; Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 327: Bitwise Not (Not)

    Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Bitwise NOT (NOT) The NOT instruction performs a bitwise NOT operation by using the bits in the Source and places the result in the Destination. To perform a logical NOT, see page 340.
  • Page 328: Fbd_Logical Structure

    Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) FBD_LOGICAL Structure Input Parameter Data Type Description EnableIn BOOL Enable input. If cleared, the instruction does not execute and outputs are not updated. default is set Source DINT...
  • Page 329: Function Block

    Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Function Block Condition Action Prescan No action taken. Instruction first scan No action taken. Instruction first run No action taken. EnableIn is cleared EnableOut is cleared.
  • Page 330: Relay Ladder

    Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Relay Ladder Structured Text value_result_not := NOT value_1; Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 331: Boolean And (Band)

    Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Boolean AND (BAND) The BAND instruction logically AND as many as eight boolean inputs. To perform a bitwise AND, see page 315.
  • Page 332 Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Description: The BAND instruction ANDs as many as eight boolean inputs. If an input is not used, it defaults to set (1). Out = In1 AND In2 AND In3 AND In4 AND In5 AND In6 AND In7 AND In8 Arithmetic Status Flags: Not affected...
  • Page 333: Structured Text

    Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Example 1: This example ANDs bool_in1 and bool_in2 and places the result in value_result_and. If BOOL_IN1 is If BOOL_IN2 is Then VALUE_RESULT_AND is Structured Text value_result_and := bool_in1 AND bool_in2;...
  • Page 334: Boolean Or (Bor)

    Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Boolean OR (BOR) The BOR instruction logically OR as many as eight boolean inputs. To perform a bitwise OR, see page 319.
  • Page 335 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Description: The BOR instruction ORs as many as eight boolean inputs. If an input is not used, it defaults to cleared (0). Out = In1 OR In2 OR In3 OR In4 OR In5 OR In6 OR In7 OR In8 Arithmetic Status Flags: Not affected...
  • Page 336: Structured Text

    Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Example 1: This example ORs bool_in1 and bool_in2 and places the result in value_result_or. If BOOL_IN1 is If BOOL_IN2 is Then VALUE_RESULT_OR is Structured Text value_result_or := bool_in1 OR bool_in2;...
  • Page 337: Boolean Exclusive Or (Bxor)

    Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Boolean Exclusive OR The BXOR performs an exclusive OR on two boolean inputs. (BXOR) To perform a bitwise XOR, see page 323.
  • Page 338 Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Description: The BXOR instruction performs an exclusive OR on two boolean inputs. Out = In1 XOR In2 Arithmetic Status Flags: Not affected Fault Conditions: None Execution:...
  • Page 339: Structured Text

    Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Example 1: This example performs an exclusive OR on bool_in1 and bool_in2 and places the result in value_result_xor. If BOOL_IN1 is If BOOL_IN2 is Then VALUE_RESULT_XOR is Structured Text...
  • Page 340: Boolean Not (Bnot)

    Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Boolean NOT (BNOT) The BNOT instruction complements a boolean input. To perform a bitwise NOT, see page 327. Operands: Structured Text IF NOT operand THEN Use NOT as an operator within an expression.
  • Page 341 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Chapter 7 Description: The BNOT instruction complements a boolean input. Out = NOT In Arithmetic Status Flags: Not affected Fault Conditions: None Execution: Condition Function Block Action Prescan...
  • Page 342: Structured Text

    Chapter 7 Move/Logical Instructions (MOV, MVM, BTD, MVMT, BTDT, CLR, SWPB, AND, OR, XOR, NOT, BAND, BOR, BXOR, BNOT) Example 1: This example complements bool_in1 and places the result in value_result_not. If BOOL_IN1 is Then VALUE_RESULT_NOT is Structured Text value_result_not := NOT bool_in1; Function Block Example 2: If bool_in1 is cleared, light1 is cleared (off ).
  • Page 343: Array (File)/Misc. Instructions

    Chapter Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Topic Page Selecting Mode of Operation File Arithmetic and Logic (FAL) File Search and Compare (FSC) Copy File (COP) Synchronous Copy File (CPS) File Fill (FLL) File Average (AVE) File Sort (SRT) File Standard Deviation (STD) Size In Elements (SIZE)
  • Page 344: Selecting Mode Of Operation

    Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) You can mix data types, but loss of accuracy and rounding error might occur and the instruction takes more time to execute. Check the S:V bit to see whether the result was truncated.
  • Page 345 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 The following timing diagram shows the relationship between status bits and instruction operation. When the instruction execution is complete, the .DN bit is set. The .DN bit, the .EN bit, and the .POS value are cleared when the rung- condition-in is false.
  • Page 346: Numerical Mode

    Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Numerical Mode Numerical mode distributes the array operation over a number of scans. This mode is useful when working with non-time-critical data or large amounts of data.
  • Page 347: Incremental Mode

    Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 The following timing diagram shows the relationship between status bits and instruction operation. When the instruction execution is complete, the .DN bit is set. Rung is False at Completion Rung is True at Completion Multiple Scans Multiple Scans...
  • Page 348 Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) The following timing diagram shows the relationship between status bits and instruction operation. Execution occurs only in a scan in which the rung- condition-in goes from false to true. Each time this occurs, only one element of the array is manipulated.
  • Page 349: File Arithmetic And Logic (Fal)

    Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 File Arithmetic and Logic The FAL instruction performs copy, arithmetic, logic, and function operations (FAL) on data stored in an array. Operands: Relay Ladder Operand Type Format Description Control...
  • Page 350: Control Structure

    Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) CONTROL Structure Mnemonic Data Type Description BOOL The enable bit indicates that the FAL instruction is enabled. BOOL The done bit is set when the instruction has operated on the last element (.POS = .LEN). BOOL The error bit is set if the expression generates an overflow (S:V is set).
  • Page 351 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 Execution: Condition Relay Ladder Action Prescan The rung-condition-out is set to false. Rung-condition-in is false. .DN Bit = 0 Internal bit is cleared Examine .DN Bit INC Mode .DN Bit = 1 .LEN <...
  • Page 352 Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Condition Relay Ladder Action Rung-condition-in is true. page 355 .LEN < 0 or Major Fault .POS < 0 Numeric .ER Bit = 0 Examine .ER Bit Mode .DN Bit = 0 .ER Bit = 1...
  • Page 353 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 Condition Relay Ladder Action Mode .EN Bit = 1 Examine .EN Bit .EN Bit = 0 Bit = 1 Examine .POS = .POS + 1 internal bit. Bit = 0 Internal bit is set.
  • Page 354 Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Condition Relay Ladder Action Mode Bit = 1 .EN Bit = 0 Examine Examine .EN bit. internal bit. Bit = 0 .EN Bit = 1 .POS = .POS + 1 .EN bit is set.
  • Page 355 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 Condition Relay Ladder Action Numeric Mode .EN Bit = 1 Examine .EN bit. .EN Bit = 0 .POS = .POS + 1 Bit = 1 Examine internal bit.
  • Page 356 Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Example 1: When enabled, the FAL instruction copies each element of array_2 into the same position within array_1. Array-to-Array Copy Expression: Destination: array_2[control_2.pos] array_1[control_2.pos] Example 2: When enabled, the FAL instruction copies value_1 into the first 10 positions of the second dimension of array_2.
  • Page 357 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 Example 4: When enabled, the FAL instruction adds value_1 and value_2 and stores the result in the current position of array_1. Arithmetic Operation: (Element + Element) to Array Expression: Destination: value_1 + value_2...
  • Page 358 Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Example 7: Each time the FAL instruction is enabled, it adds value_1 to the current value of array_1 and stores the result in value_2. The FAL instruction uses incremental mode, so only one array value is added to value_1 each time the instruction is enabled.
  • Page 359: Fal Expressions

    Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 FAL Expressions You program expressions in FAL instructions the same as expressions in CPT instructions. Use the following sections for information on valid operators, format, and order of operation, which are common to both instructions. Valid Operators Operator Description...
  • Page 360: Determine The Order Of Operation

    Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Determine the Order of Operation The operations you write into the expression are performed by the instruction in a prescribed order, not necessarily the order you write them. You can override the order of operation by grouping terms within parentheses, forcing the instruction to perform an operation within the parentheses ahead of other operations.
  • Page 361: File Search And Compare (Fsc)

    Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 File Search and Compare The FSC instruction compares values in an array, element by element. (FSC) Operands: Relay Ladder Operand Type Format Description Control CONTROL Control structure for the operation Length DINT Immediate...
  • Page 362 Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Execution: Condition Relay Ladder Action Prescan The rung-condition-out is set to false. Rung-condition-in is false. .DN Bit = 0 Examine .DN bit. Internal bit is cleared. INC Mode .DN Bit = 1 .LEN <...
  • Page 363 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 Condition Relay Ladder Action Rung-condition-in is true. page 355 .LEN < 0 or Major Fault .POS < 0 Numeric .ER Bit = 0 Examine .ER bit. Mode .DN Bit = 0 .ER Bit = 1...
  • Page 364 Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Example 1: Search for a match between two arrays. When enabled, the FSC instruction compares each of the first 10 elements in array_1 to the corresponding elements in array_2.
  • Page 365 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 Example 2: Search for a match in an array. When enabled, the FSC instruction compares the MySearchKey to 10 elements in array_1. Control_3.pos MySearchKey Reference 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000 00000000000000000000000000000000...
  • Page 366 Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Code_table_search.POS Code Code_table The FSC instruction finds that this array element equals code. The instruction sets the .FD and .IN bits. The .POS (4) value indicates the position of the equal element.
  • Page 367: Fsc Expressions

    Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 FSC Expressions You program expressions in FSC instructions the same as expressions in CMP instructions. Use the following sections for information on valid operators, format, and order of operation, which are common to both instructions. Valid Operators Operator Description...
  • Page 368: Determine The Order Of Operation

    Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Determine the Order of Operation The operations you write into the expression are performed by the instruction in a prescribed order, not necessarily the order you write them. You can override the order of operation by grouping terms within parentheses, forcing the instruction to perform an operation within the parentheses ahead of other operations.
  • Page 369: Use Strings In An Expression

    Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 Use Strings in an Expression To use strings of ASCII characters in an expression, follow these guidelines: · An expression lets you compare two string tags. ·...
  • Page 370: Copy File (Cop) Synchronous Copy File (Cps)

    Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Copy File (COP) The COP and CPS instructions copy the value(s) in the Source to the Synchronous Copy File Destination. The Source remains unchanged. (CPS) Operands: Relay Ladder Operand Type...
  • Page 371 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 The number of bytes copied is: Byte Count = Length ∗ (number of bytes in the Destination data type) ATTENTION: If the byte count is greater than the length of the Source, unpredictable data is copied for the remaining elements.
  • Page 372 Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Execution: Condition Relay Ladder Action Structured Text Action Prescan The rung-condition-out is set to false. No action taken. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true The instruction executes.
  • Page 373: Relay Ladder

    Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 Example 1: Both array_4 and array_5 are the same data type. When enabled, the COP instruction copies the first 10 elements of array_4 into the first 10 elements of array_5.
  • Page 374: Relay Ladder

    Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Example 3: The project_data array (100 elements) stores a variety of values that change at different times in the application. To send a complete image of project_data at one instance in time to another controller, the CPS instruction copies project_data to produced_array.
  • Page 375: Relay Ladder

    Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 When enabled, the COP instruction copies a contiguous block of bytes, starting at array_timer[0]. The length is nine timer structures. Array_timer[0] First the instruction copies timer[0] values to timer[1].
  • Page 376: File Fill (Fll)

    Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) File Fill (FLL) The FLL instruction fills elements of an array with the Source value. The Source remains unchanged. Operands: Relay Ladder Operand Type Format: Description Source SINT Immediate...
  • Page 377 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 Description: The number of bytes filled is: Byte count = Length ∗ (number of bytes in the Destination data type) You must test and confirm that the instruction doesn’t change data that you don’t IMPORTANT want it to change.
  • Page 378 Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Execution: Condition Relay Ladder Action Prescan The rung-condition-out is set to false. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true. End_address = start_address + (Length ∗ number of bytes in a destination element) End_address >...
  • Page 379: Relay Ladder

    Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 Example: The FLL instruction copies the value in value_1 into dest_1 Relay Ladder Source (value_1) Source (value_1) Destination (dest_1) Destination (dest_1) Data Type Value Data Type Value After FLL SINT 16#80 (-128)
  • Page 380: File Average (Ave)

    Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) File Average (AVE) The AVE instruction calculates the average of a set of values. Operands: Relay Ladder Operand Type Format Description Array SINT Array tag Find the average of the values in this array Specify the first element of the group of elements to average DINT...
  • Page 381: Control Structure

    Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 CONTROL Structure Mnemonic Data Type Description BOOL The enable bit indicates that the AVE instruction is enabled. BOOL The done bit is set when the instruction has operated on the last element in the array (.POS = .LEN). BOOL The error bit is set if the instruction generates an overflow.
  • Page 382 Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Execution: Condition Relay Ladder Action Prescan The .EN bit is cleared. The .DN bit is cleared. The .ER bit is cleared. The rung-condition-out is set to false. Rung-condition-in is false.
  • Page 383: Relay Ladder

    Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 Example 1: Average array_dint, which is DINT[4,5]. Dimension 1 ------------------------------------ - ----- - 11.5 Dimension 0 dint_ave = 12 Relay Ladder Structured Text SIZE(array_dint,0,length); sum := 0; FOR position = 0 TO (length-1) DO sum := sum + array_dint[position];...
  • Page 384: Relay Ladder

    Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Example 2: Average array_dint, which is DINT[4,5]. Dimension 1 + + + + --------------------------------------- - ----- - Dimension 0 dint_ave = 3 Relay Ladder Structured Text SIZE(array_dint,1,length);...
  • Page 385: File Sort (Srt)

    Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 File Sort (SRT) The SRT instruction sorts a set of values in one dimension (Dim to vary) of the Array into ascending order. Operands: Relay Ladder Operand Type Format...
  • Page 386 Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Description: The SRT instruction sorts a set of values in one dimension (Dim to vary) of the Array into ascending order. You must test and confirm that the instruction doesn’t IMPORTANT change data that you don’t want it to change.
  • Page 387 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 Execution: Condition Relay Ladder Action Structured Text Action Prescan The .EN bit is cleared. The .EN bit is cleared. The .DN bit is cleared. The .DN bit is cleared. The .ER bit is cleared.
  • Page 388: Relay Ladder

    Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Example 1: Sort int _array, which is DINT[4,5]. After Before Dimension 1 Dimension 1 Dimension 0 Dimension 0 Relay Ladder Structured Text control_1.LEN := 4; control_1.POS := 0; SRT(int_array[0,2],0,control_1);...
  • Page 389: Relay Ladder

    Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 Relay Ladder Structured Text control_1.LEN := 5; control_1.POS := 0; SRT(int_array[2,0],1,control_1); Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 390: File Standard Deviation (Std)

    Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) File Standard Deviation The STD instruction calculates the standard deviation of a set of values in one (STD) dimension of the Array and stores the result in the Destination. Operands: Relay Ladder Operand...
  • Page 391: Structured Text

    Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 Structured Text Structured text does not have an STD instruction, but you can achieve the same results by using a SIZE instruction and a FOR...DO or other loop construct. SIZE(array,0,length);...
  • Page 392 Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Description: The standard deviation is calculated according to this formula:        –   start   Standard Deviation = ------------------------------------------------------------------- - –...
  • Page 393 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 Arithmetic Status Flags: Arithmetic status flags are affected. Fault Conditions: A major fault will occur if Fault type Fault code .POS < 0 or .LEN < 0 Dimension to vary does not exist for the specified array Execution:...
  • Page 394: Relay Ladder

    Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Example 1: Calculate the standard deviation of dint_array, which is DINT[4,5]. Dimension 1 Dimension 0 ------------------------------------ - ----- -        ...
  • Page 395: Relay Ladder

    Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 Example 2: Calculate the standard deviation of dint_array, which is DINT[4,5]. Dimension 1 Dimension 0 ------------------------------------------------------ - ----- -        ...
  • Page 396: Structured Text

    Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Structured Text SIZE(dint_array,1,length); sum := 0; FOR position = 0 TO (length-1) DO sum := sum + dint_array[position]; END_FOR; average := sum / length; sum := 0; FOR position = 0 TO (length-1) DO sum := sum + ((dint_array[position] - average)**2);...
  • Page 397: Size In Elements (Size)

    Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 Size In Elements (SIZE) The SIZE instruction finds the size of a dimension of an array. Operands: Relay Ladder Operand Type Format Description Source SINT Array tag Array on which the instruction is to operate DINT REAL...
  • Page 398: Relay Ladder

    Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Execution: Condition Relay Ladder Action Structured Text Action Prescan The rung-condition-out is set to false. No action taken. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true The instruction executes.
  • Page 399: Relay Ladder

    Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Chapter 8 Example 3: Strings_a is an array of string structures. The SIZE instruction finds the number of elements in the DATA member of the string structure and stores the size in data_size_a.
  • Page 400 Chapter 8 Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE) Notes: Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 401 Chapter Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Topic Page Bit Shift Left (BSL) Bit Shift Right (BSR) FIFO Load (FFL) FIFO Unload (FFU) LIFO Load (LFL) LIFO Unload (LFU) Use the array (file)/shift instructions to modify the location of data within arrays. If you want to Use this instruction Available in these languages...
  • Page 402: Bit Shift Left (Bsl)

    Chapter 9 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Bit Shift Left (BSL) The BSL instruction shifts the specified bits within the Array one position left. Operands: Relay Ladder Operand Type Format Description Array DINT Array tag Array to modify Specify the element where to begin the shift Do not use CONTROL.POS in the subscript Control...
  • Page 403 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Chapter 9 Description: When enabled, the instruction unloads the uppermost bit of the specified bits to the .UL bit, shifts the remaining bits one position left, and loads Source bit into bit 0 of Array.
  • Page 404 Chapter 9 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Condition Relay Ladder Action Rung-condition-in is true. .EN Bit = 1 Examine .EN Bit .EN Bit = 0 .EN bit is set. .LEN = 0 .DN bit is set. .Source Bit = 1 Examine Source Bit .UL bit remains set.
  • Page 405 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Chapter 9 Example 1: When enabled, the BSL instruction starts at bit 0 in array_dint[0]. The instruction unloads array_dint[0].9 into the .UL bit, shifts the remaining bits, and loads input_1 into array_dint[0].0. The values in the remaining bits (10…31) are invalid. 9 8 7 6 5 4 3 2 1 0 array_dint[0] 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0...
  • Page 406: Bit Shift Right (Bsr)

    Chapter 9 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Bit Shift Right (BSR) The BSR instruction shifts the specified bits within the Array one position right. Operands: Relay Ladder Operand Type Format Description Array DINT Array tag Array to modify Specify the element where to begin the shift Do not use CONTROL.POS in the subscript Control...
  • Page 407 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Chapter 9 Description: When enabled, the instruction unloads the value at bit 0 of Array to the .UL bit, shifts the remaining bits one position right, and loads Source bit into the uppermost bit of the specified bits.
  • Page 408 Chapter 9 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Condition Relay Ladder Action Rung-condition-in is true. .EN Bit = 1 Examine .EN bit. .EN Bit = 0 .EN Bit is set. .LEN = 0 .DN bit is set. .Source Bit = 1 Examine source bit.
  • Page 409 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Chapter 9 Example 1: When enabled, the BSR instruction starts at bit 9 in array_dint[0]. The instruction unloads array_dint[0].0 into the .UL bit, shifts the remaining bits right, and loads input_1 into array_dint[0].9. The values in the remaining bits (10…31) are invalid.
  • Page 410: Fifo Load (Ffl)

    Chapter 9 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) FIFO Load (FFL) The FFL instruction copies the Source value to the FIFO. Operands: Relay Ladder Operand Type Format Description Source SINT Immediate Data to be stored in the FIFO DINT REAL string...
  • Page 411: Control Structure

    Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Chapter 9 CONTROL Structure Mnemonic Data Type Description BOOL The enable bit indicates that the FFL instruction is enabled. BOOL The done bit is set to indicate that the FIFO is full (.POS = .LEN). The .DN bit inhibits loading the FIFO until .POS <...
  • Page 412 Chapter 9 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Execution: Condition Relay Ladder Action Prescan .EN bit is set to prevent a false load when scan begins. .LEN < 0 .POS < 0 .EM is cleared. .EM is set. .DN is cleared.
  • Page 413 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Chapter 9 Condition Relay Ladder Action Rung-condition-in is false. .EN bit is cleared. .LEN < 0 .POS < 0 .EM is cleared. .EM is set. .DN is cleared. .DN is set. .POS = 0 .EM is set.
  • Page 414 Chapter 9 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Condition Relay Ladder Action Rung-condition-in is true. .EN = 0 .EN bit is set. Examine .EN bit. .LEN < 0 .EN = 1 .POS < 0 .LEN < 0 .EM bit is set.
  • Page 415 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Chapter 9 Example: When enabled, the FFL instruction loads value_1 into the next position in the FIFO, which is array_dint[5] in this example. Before FIFO load After FIFO load array_dint[0] 00000 00000 11111 11111...
  • Page 416: Fifo Unload (Ffu)

    Chapter 9 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) FIFO Unload (FFU) The FFU instruction unloads the value from position 0 (first position) of the FIFO and stores that value in the Destination. The remaining data in the FIFO shifts down one position.
  • Page 417: Control Structure

    Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Chapter 9 CONTROL Structure Mnemonic Data Type Description BOOL The enable unload bit indicates that the FFU instruction is enabled. The .EU bit is set to preset a false unload when the program scan begins. BOOL The done bit is set to indicate that the FIFO is full (.POS = .LEN).
  • Page 418 Chapter 9 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Execution: Condition Relay Ladder Action Prescan .EU bit is set to prevent a false unload when scan begins. .LEN < 0 .POS < 0 .EM is cleared. .EM is set. .DN is cleared.
  • Page 419 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Chapter 9 Condition Relay Ladder Action Rung-condition-in is false. .EU bit is cleared. .LEN < 0 .POS < 0 .EM is cleared. .EM is set. .DN is cleared. .DN is set. .POS = 0 .EM is set.
  • Page 420 Chapter 9 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Condition Relay Ladder Action Rung-condition-in is true. .EU = 0 .EU bit is set. .LEN < 0 Examine .EU bit. .EU = 1 .LEN < 0 .POS < 0 .EM bit is set.
  • Page 421 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Chapter 9 Example: When enabled, the FFU instruction unloads array_dint[0] into value_2 and shifts the remaining elements in array_dint. Before FIFO unload After FIFO unload array_dint[0] 00000 11111 11111 22222 22222 33333 33333 44444...
  • Page 422: Lifo Load (Lfl)

    Chapter 9 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) LIFO Load (LFL) The LFL instruction copies the Source value to the LIFO. Operands: Relay Ladder Operand Type Format Description Source SINT Immediate Data to be stored in the LIFO DINT REAL string...
  • Page 423: Control Structure

    Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Chapter 9 CONTROL Structure Mnemonic Data Type Description: BOOL The enable bit indicates that the LFL instruction is enabled. BOOL The done bit is set to indicate that the LIFO is full (.POS = .LEN). The .DN bit inhibits loading the LIFO until .POS <...
  • Page 424 Chapter 9 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Execution: Condition: Relay Ladder Action Prescan .EN bit is set to prevent a false load when scan begins. .LEN < 0 .POS < 0 .EM is cleared. .EM is set. .DN is cleared.
  • Page 425 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Chapter 9 Condition: Relay Ladder Action Rung-condition-in is false. .EN bit is cleared. .LEN < 0 .POS < 0 .EM is set. .EM is cleared. .DN is cleared. .DN is set. .EM is set.
  • Page 426 Chapter 9 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Condition: Relay Ladder Action Rung-condition-in is true. .EN = 0 .EN bit is set. .LEN < 0 Examine .EN bit. .EN = 1 .POS < 0 .LEN < 0 .EM bit is set.
  • Page 427 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Chapter 9 Example: When enabled, the LFL instruction loads value_1 into the next position in the LIFO, which is array_dint[5] in this example. Before LIFO load After LIFO load array_dint[0] 00000 00000 11111 11111...
  • Page 428: Lifo Unload (Lfu)

    Chapter 9 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) LIFO Unload (LFU) The LFU instruction unloads the value at .POS of the LIFO and stores 0 in that location. Operands: Relay Ladder Operand Type Format Description LIFO SINT Array tag LIFO to modify Specify the first element of the LIFO...
  • Page 429: Control Structure

    Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Chapter 9 CONTROL Structure Mnemonic Data Type: Description BOOL The enable unload bit indicates that the LFU instruction is enabled. The .EU bit is set to preset a false unload when the program scan begins. BOOL The done bit is set to indicate that the LIFO is full (.POS = .LEN).
  • Page 430 Chapter 9 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Execution: Condition Relay Ladder Action Prescan .EU bit is set to prevent a false unload when scan begins. .LEN < 0 .POS < 0 .EM is cleared. .EM is set .DN is cleared .DN is set .POS = 0...
  • Page 431 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Chapter 9 Condition Relay Ladder Action Rung-condition-in is false. .EU bit is cleared. .LEN < 0 .POS < 0 .EM is cleared. .EM is set. .DN is cleared. .DN is set. .POS = 0 .EM is set.
  • Page 432 Chapter 9 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Condition Relay Ladder Action Rung-condition-in is true. .EU = 0 .EU bit is set. Examine .EU bit. .LEN < 0 .EU = 1 .POS < 0 .LEN < 0 .EM bit is set.
  • Page 433 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Chapter 9 Example: When enabled, the LFU instruction unloads array_dint[5] into value_2. Before LIFO unload After LIFO unload array_dint[0] 00000 00000 11111 11111 22222 22222 33333 33333 44444 44444 array_dint[5] 55555 00000 control_1.pos = 5 00000...
  • Page 434 Chapter 9 Array (File)/Shift Instructions (BSL, BSR, FFL, FFU, LFL, LFU) Notes: Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 435 Chapter Sequencer Instructions (SQI, SQO, SQL) Topic Page Sequencer Input (SQI) Sequencer Output (SQO) Sequencer Load (SQL) No action taken. Sequencer instructions monitor consistent and repeatable operations. If you want to Use this instruction Available in these languages Page Detect when a step is complete Relay ladder Set output conditions for the next step Relay ladder...
  • Page 436: Sequencer Input (Sqi)

    Chapter 10 Sequencer Instructions (SQI, SQO, SQL) Sequencer Input (SQI) The SQI instruction detects when a step is complete in a sequence pair of SQO/ SQI instructions. Operands: Relay Ladder Operand Type Format Description Array DINT Array tag Sequencer array Specify the first element of the sequencer array Do not use CONTROL.POS in the subscript Mask...
  • Page 437: Enter An Immediate Mask Value

    Sequencer Instructions (SQI, SQO, SQL) Chapter 10 Description: When enabled, the SQI instruction compares a Source element through a Mask to an Array element for equality. Typically use the same CONTROL structure as the SQO and SQL instructions. The SQI instruction operates on contiguous memory. Enter an Immediate Mask Value When you enter a mask, the programming software defaults to decimal values.
  • Page 438 Chapter 10 Sequencer Instructions (SQI, SQO, SQL) Condition: Relay Ladder Action Prescan The rung-condition-out is set to false. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true. .LEN ≤ 0 .POS < 0 .ER bit is cleared. .POS >...
  • Page 439: Use Sqi Without Sqo

    Sequencer Instructions (SQI, SQO, SQL) Chapter 10 Example: When enabled, the SQI instruction passes value_2 through the mask to determine whether the result is equal to the current element in array_dint. The masked comparison is true, so the rung-condition-out goes true. SQI Operand Example Values (DINTs Displayed In Binary) Source...
  • Page 440: Sequencer Output (Sqo)

    Chapter 10 Sequencer Instructions (SQI, SQO, SQL) Sequencer Output (SQO) The SQO instruction sets output conditions for the next step of a sequence pair of SQO/SQI instructions. Operands: Relay Ladder Operand Type Format Description Array DINT Array tag Sequencer array Specify the first element of the sequencer array Do not use CONTROL.POS in the subscript Mask...
  • Page 441: Enter An Immediate Mask Value

    Sequencer Instructions (SQI, SQO, SQL) Chapter 10 Description: When enabled, the SQO instruction increments the position, moves the data at the position through the Mask, and stores the result in the Destination. If .POS > .LEN, the instruction wraps around to the beginning of the sequencer array and continues with .POS = 1.
  • Page 442 Chapter 10 Sequencer Instructions (SQI, SQO, SQL) Execution: Condition Relay Ladder Action Prescan The .EN bit is set to prevent a false load when the program scan begins. The rung-condition-out is set to false. Rung-condition-in is false The .EN bit is cleared. The rung-condition-out is set to false.
  • Page 443: Using Sqi With Sqo

    Sequencer Instructions (SQI, SQO, SQL) Chapter 10 Example: When enabled, the SQO instruction increments the position, passes the data at that position in array_dint through the mask, and stores the result in value_1. SQO Operand Example Values (Using INTS Displayed In Binary) Array xxxxxxxx xxxxxxxx xxxx0101 xxxx1010 Mask...
  • Page 444: Sequencer Load (Sql)

    Chapter 10 Sequencer Instructions (SQI, SQO, SQL) Sequencer Load (SQL) The SQL instruction loads reference conditions into a sequencer array. Operands: Relay Ladder Operand Type Format Description Array DINT Array tag Sequencer array Specify the first element of the sequencer array Do not use CONTROL.POS in the subscript Source SINT...
  • Page 445 Sequencer Instructions (SQI, SQO, SQL) Chapter 10 Description: When enabled, the SQL instruction increments to the next position in the sequencer array and loads the Source value into that position. If the .DN bit is set or if .POS ≥ .LEN, the instruction sets .POS=1. Typically use the same CONTROL structure as the SQI and SQO instructions.
  • Page 446 Chapter 10 Sequencer Instructions (SQI, SQO, SQL) Condition Relay Ladder Action Rung-condition-in is true. .EN bit is set. .EN = 0 .LEN ≤ 0 or .ER bit is cleared. examine .EN bit .POS < 0 .DN bit is set. .EN = 1 .POS ≥...
  • Page 447 Sequencer Instructions (SQI, SQO, SQL) Chapter 10 Example: When enabled, the SQL instruction loads value_3 into the next position in the sequencer array, which is array_dint[5] in this example. Before load After load array_dint[0] 00000 00000 11111 11111 22222 22222 33333 control_1.pos = 5 33333...
  • Page 448 Chapter 10 Sequencer Instructions (SQI, SQO, SQL) Notes: Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 449 Chapter Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Topic Page Jump to Label (JMP) Label (LBL) Jump to Subroutine (JSR) Subroutine (SBR) Return (RET) Jump to External Routine (JXR) Temporary End (TND) Master Control Reset (MCR) User Interrupt Disable (UID) User Interrupt...
  • Page 450 Chapter 11 Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) If you want to Use this instruction Available in these languages Page Jump over a section of logic that does not always Relay ladder need to be executed Jump to a separate routine, pass data to the routine,...
  • Page 451: Jump To Label (Jmp)

    Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Chapter 11 Jump to Label (JMP) The JMP and LBL instructions skip portions of ladder logic. Label (LBL) Operands: Relay Ladder Operand Type Format...
  • Page 452 Chapter 11 Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Execution: Condition: Relay Ladder Action Prescan The rung-condition-out is set to false. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true The rung-condition-out is set to true.
  • Page 453: Jump To Subroutine (Jsr)

    Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Chapter 11 Jump to Subroutine (JSR) The JSR instruction jumps execution to a different routine. The SBR and RET Subroutine (SBR) Return instructions are optional instructions that exchange data with the JSR instruction.
  • Page 454: Function Block

    Chapter 11 Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Function Block Input Parameters Return Parameters The operands are the same as those for the relay ladder JSR instruction. ATTENTION: For each parameter in a SBR or RET instruction, use the same data type (including any array dimensions) as the corresponding parameter in the JSR instruction.
  • Page 455: Relay Ladder

    Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Chapter 11 The operands are the same as those for the relay ladder SBR instruction. RET Operands: Relay Ladder Operand Type Format Description Return...
  • Page 456 Chapter 11 Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Use these guidelines to program a jump to a subroutine. Do not use a JSR instruction to call (execute) the main routine. IMPORTANT ·...
  • Page 457: Relay Ladder And Structured Text

    Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Chapter 11 There are no restrictions, other than controller memory, on the number of nested routines you can have or the number of parameters you pass or return. Level 1 Level 2 Level 3...
  • Page 458: Function Block

    Chapter 11 Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Condition Relay Ladder Action Structured Text Action Instruction execution. JSR copies input parameters to Input Parameters appropriate SBR tags. Logic execution begins in routine identified by JSR.
  • Page 459: Relay Ladder

    Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Chapter 11 Example 1: The JSR instruction passes value_1 and value_2 to routine_1. The SBR instruction receives value_1 and value_2 from the JSR instruction and copies those values to value_a and value_b, respectively.
  • Page 460: Relay Ladder

    Chapter 11 Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Example 2: Relay Ladder MainRoutine When abc is on, subroutine_1 executes, calculates the number of cookies, and places a value in cookies_1. Adds the value in cookies_1 to cookies_2 and stores the result in total_cookies.
  • Page 461: Function Block

    Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Chapter 11 Example 3: Function Block JSR instruction in Routine_A 42972 1.The val ues in Add_Input_1, 3.The va lue of Sum_A_B_C is co pied t o Add_Input_2, an d Add_Input_3 Add_Three_Result.
  • Page 462: Jump To External Routine (Jxr)

    Chapter 11 Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Jump to External Routine The JXR instruction executes an external routine. This instruction is only (JXR) supported by the SoftLogix5800 controllers. Operands: Relay Ladder Operand...
  • Page 463: Ext_Routine_Control Structure

    Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Chapter 11 EXT_ROUTINE_CONTROL Structure Mnemonic Data Type Description Implementation ErrorCode SINT If an error occurs, this value identifies the error. Valid There are no predefined error codes.
  • Page 464 Chapter 11 Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Description: Use the Jump to External Routine ( JXR) instruction to call the external routine from a ladder routine in your project. The JXR instruction supports multiple parameters so you can pass values between the ladder routine and the external routine.
  • Page 465: Temporary End (Tnd)

    Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Chapter 11 Temporary End (TND) The TND instruction acts as a boundary. Operands: Relay Ladder Operands None Structured Text TND(); None You must enter the parentheses () after the instruction mnemonic, even though there are no operands.
  • Page 466: Relay Ladder

    Chapter 11 Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Example: You can use the TND instruction when debugging or troubleshooting to execute logic up to a certain point. Progressively move the TND instruction through the logic as you debug each new section.
  • Page 467: Master Control Reset (Mcr)

    Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Chapter 11 Master Control Reset (MCR) The MCR instruction, used in pairs, creates a program zone that can disable all rungs within the MCR instructions. Operands: Relay Ladder None...
  • Page 468 Chapter 11 Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Description: When the MCR zone is enabled, the rungs in the MCR zone are scanned for normal true or false conditions. When disabled, the controller still scans rungs within an MCR zone, but scan time is reduced because non-retentive outputs in the zone are disabled.
  • Page 469 Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Chapter 11 Example: When the first MCR instruction is enabled (input_1, input_2, and input_3 are set), the controller executes the rungs in the MCR zone (between the two MCR instructions) and sets or clears outputs, depending on input conditions.
  • Page 470: User Interrupt Disable (Uid) User Interrupt Enable (Uie)

    Chapter 11 Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) User Interrupt Disable (UID) The UID instruction and the UIE instruction work together to prevent a small User Interrupt Enable (UIE) number of critical rungs from being interrupted by other tasks.
  • Page 471: Relay Ladder

    Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Chapter 11 Arithmetic Status Flags: Not affected Fault Conditions: None Execution: Condition Relay Ladder Action Structured Text Action Prescan The rung-condition-out is set to false. No action taken.
  • Page 472: Always False Instruction (Afi)

    Chapter 11 Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Always False Instruction The AFI instruction sets its rung-condition-out to false. (AFI) Operands: Relay Ladder None Description: The AFI instruction sets its rung-condition-out to false. Arithmetic Status Flags: Not affected Fault Conditions:...
  • Page 473: No Operation (Nop)

    Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Chapter 11 No Operation (NOP) The NOP instruction functions as a placeholder. Operands: Relay Ladder None Description: You can place the NOP instruction anywhere on a rung. When enabled the NOP instruction performs no operation.
  • Page 474: End Of Transition (Eot)

    Chapter 11 Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) End of Transition (EOT) The EOT instruction returns a boolean state to an SFC transition. Operands: Relay Ladder Operand Type Format Description...
  • Page 475: Relay Ladder

    Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Chapter 11 Example: When both limit_switch1 and interlock_1 are set, set state. After timer_1 completes, EOT returns the value of state to the calling routine. Relay Ladder Structured Text state := limit_switch1 AND interlock_1;...
  • Page 476: Sfc Pause (Sfp)

    Chapter 11 Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) SFC Pause (SFP) The SFP instruction pauses an SFC routine. Operands: Relay Ladder Operand Type Format Description SFCRoutine ROUTINE Name SFC routine to pause Name...
  • Page 477: Relay Ladder

    Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Chapter 11 Example: If sfc_en_p is set, pause the SFC routine named normal. Restart the SFC when sfc_en_e is set. Relay Ladder Pause the SFC routine.
  • Page 478: Structured Text

    Chapter 11 Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Structured Text Pause the SFC routine: IF (sfp_en_p) THEN SFP(normal,paused); sfp_en_p := 0; END_IF; Resume executing the SFC IF (sfp_en_e) THEN routine: SFP(normal,executing);...
  • Page 479: Relay Ladder

    Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Chapter 11 Description: When the SFR instruction is enabled: · In the specified SFC routine, all stored actions stop executing (reset). ·...
  • Page 480: Structured Text

    Chapter 11 Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Structured Text IF shutdown THEN SFR(mySFC,initialize); END_IF; Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 481: Trigger Event Task (Event)

    Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Chapter 11 Trigger Event Task (EVENT) The EVENT instruction triggers one execution of an event task. Operands: Relay Ladder Operand Type Format Description Task...
  • Page 482: Relay Ladder

    Chapter 11 Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) The controller does not clear the bits of the Status attribute once they are set. · To use a bit for new status information, you must manually clear the bit. ·...
  • Page 483: Structured Text

    Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Chapter 11 Structured Text Program A IF Shut_Down_Line AND NOT Shut_Down_Line_One_Shot THEN EVENT (Shut_Down); END_IF; Shut_Down_Line_One_Shot := Shut_Down_Line; Program B IF Shut_Down_Line AND NOT Shut_Down_Line_One_Shot THEN EVENT (Shut_Down);...
  • Page 484 Chapter 11 Program Control Instructions (JMP, LBL, JSR, RET, SBR, JXR, TND, MCR, UID, UIE, AFI, NOP, EOT, SFP, SFR, EVENT) Example 2: The following example uses an EVENT instruction to initialize an event task. (Another type of event normally triggers the event task.) Continuous task If Initialize_Task_1 = 1 then The ONS instruction limits the execution of the EVENT instruction to one scan.
  • Page 485 Chapter For/Break Instructions (FOR, FOR...DO, BRK, EXIT, RET) Topic Page For (FOR) Break (BRK) Return (RET) Use the FOR instruction to repeatedly call a subroutine. Use the BRK instruction to interrupt the execution of a subroutine. If you want to Use this instruction Available in these languages Page...
  • Page 486: For (For)

    Chapter 12 For/Break Instructions (FOR, FOR...DO, BRK, EXIT, RET) For (FOR) The FOR instruction executes a routine repeatedly. Operands: Relay Ladder Operand Type Format Description Routine name ROUTINE Routine Name Routine to execute Index DINT Counts how many times the routine has been executed Initial value SINT...
  • Page 487 For/Break Instructions (FOR, FOR...DO, BRK, EXIT, RET) Chapter 12 Arithmetic Status Flags: Not affected Fault Conditions: A major fault will occur if Fault Type Fault Code Main routine contains a RET instruction Execution: Condition Relay Ladder Action Prescan The rung-condition-out is set to false. The controller executes the subroutine once.
  • Page 488 Chapter 12 For/Break Instructions (FOR, FOR...DO, BRK, EXIT, RET) Example: When enabled, the FOR instruction repeatedly executes routine_2 and increments value_2 by 1 each time. When value_2 is > 10 or a BRK instruction is enabled, the FOR instruction no longer executes routine_2. Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 489: Break (Brk)

    For/Break Instructions (FOR, FOR...DO, BRK, EXIT, RET) Chapter 12 Break (BRK) The BRK instruction interrupts the execution of a routine that was called by a FOR instruction. Operands: Relay Ladder None Structured Text EXIT; Use the EXIT statement in a loop construct. See Appendix B for information on structured text constructs.
  • Page 490: Return (Ret)

    Chapter 12 For/Break Instructions (FOR, FOR...DO, BRK, EXIT, RET) Return (RET) The RET instruction returns to the calling FOR instruction. Operands: Relay Ladder None Description: Do not place a RET instruction in the main routine. If you place a RET IMPORTANT instruction in the main routine, a major fault occurs (type 4, code 31).
  • Page 491 For/Break Instructions (FOR, FOR...DO, BRK, EXIT, RET) Chapter 12 Example: The FOR instruction repeatedly executes routine_2 and increments value_2 by 1 each time. When value_2 is > 10 or a BRK instruction is enabled, the FOR instruction no longer executes routine_2. The RET instruction returns to the calling FOR instruction.
  • Page 492 Chapter 12 For/Break Instructions (FOR, FOR...DO, BRK, EXIT, RET) Notes: Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 493 Chapter Special Instructions (FBC, DDT, DTR, PID) Topic Page File Bit Comparison (FBC) Diagnostic Detect (DDT) Data Transitional (DTR) Proportional Integral Derivative (PID) Configure a PID Instruction Use PID Instructions PID Theory The special instructions perform application-specific operations. If you want to Use this instruction Available in these languages Page...
  • Page 494: File Bit Comparison (Fbc)

    Chapter 13 Special Instructions (FBC, DDT, DTR, PID) File Bit Comparison (FBC) The FBC instruction compares bits in a Source array with bits in a Reference array. Operands: Relay Ladder Operand Type Format Description: Source DINT Array tag Array to compare to the reference Do not use CONTROL.POS in the subscript Reference DINT...
  • Page 495: Result Structure

    Special Instructions (FBC, DDT, DTR, PID) Chapter 13 RESULT Structure Mnemonic Data Type Description BOOL The done bit is set when the Result array is full. .LEN DINT The length value identifies the number of storage locations in the Result array. .POS DINT The position value identifies the current position in the Result array.
  • Page 496 Chapter 13 Special Instructions (FBC, DDT, DTR, PID) Execution: Condition Relay Ladder Action Prescan. Compare.EN bit is cleared. Compare.FD bit is cleared. Compare.DN = 0 Examine compare.DN bit. compare.DN = 1 Compare.DN bit is cleared. Compare.POS value is cleared. Result.DN bit is cleared. Result.POS value is cleared.
  • Page 497 Special Instructions (FBC, DDT, DTR, PID) Chapter 13 Condition Relay Ladder Action Rung-condition-in is false. Compare.EN bit is cleared. Compare.FD bit is cleared. Compare.DN = 0 Examine compare.DN bit. Compare.DN = 1 Compare DN bit is cleared. Compare.POS value is cleared. Result.DN bit is cleared.
  • Page 498 Chapter 13 Special Instructions (FBC, DDT, DTR, PID) Condition Relay Ladder Action Rung-condition-in is true. Examine Compare.EN = 1 Goto compare.EN bit. Exit Compare.EN = 0 Compare.DN = 1 Goto Examine Compare EN bit is set. Exit compare.DN bit. Compare.DN = 0 Compare.ER bit is cleared.
  • Page 499 Special Instructions (FBC, DDT, DTR, PID) Chapter 13 Condition Relay Ladder Action Compare Compare.POS = compare.LEN Compare.POS ≥ Goto Compare.LEN Compare.DN bit is set. Exit page 498 Result.DN = 1 Result.DN bit is cleared. Source[compare.POS] = Compare.FD bit is set. Examine result.DN Result.POS value is Reference[compare.POS]...
  • Page 500 Chapter 13 Special Instructions (FBC, DDT, DTR, PID) Example: When enabled, the FBC instruction compares the source array_dint1 to the reference array_dint2 and stores the locations of any mismatches in the result array_dint3. Source a rray_dint1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Reference 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 array_dint2...
  • Page 501: Diagnostic Detect (Ddt)

    Special Instructions (FBC, DDT, DTR, PID) Chapter 13 Diagnostic Detect (DDT) The DDT instruction compares bits in a Source array with bits in a Reference array to determine changes of state. Operands: Relay Ladder Operand Type Format Description Source DINT Array tag Array to compare to the reference Do not use CONTROL.POS in the subscript...
  • Page 502: Result Structure

    Chapter 13 Special Instructions (FBC, DDT, DTR, PID) RESULT Structure Mnemonic Data Type Description BOOL The done bit is set when the Result array is full. .LEN DINT The length value identifies the number of storage locations in the Result array. .POS DINT The position value identifies the current position in the Result array.
  • Page 503 Special Instructions (FBC, DDT, DTR, PID) Chapter 13 Execution: Condition: Relay Ladder Action Prescan Compare.EN bit is cleared. Compare.FD bit is cleared. Compare.DN = 0 Examine Compare.DN bit. Compare.DN = 1 Compare.DN bit is cleared. Compare.POS value is cleared. Result.DN bit is cleared. Result.POS value is cleared.
  • Page 504 Chapter 13 Special Instructions (FBC, DDT, DTR, PID) Condition: Relay Ladder Action Rung-condition-in is false. Compare.EN bit is cleared. Compare.FD bit is cleared. Compare.DN = 0 Examine Compare.DN bit. Compare.DN = 1 Compare DN bit is cleared. Compare.POS value is cleared. Result.DN bit is cleared.
  • Page 505 Special Instructions (FBC, DDT, DTR, PID) Chapter 13 Condition: Relay Ladder Action Rung-condition-in is true. Compare.EN = 1 Examine Goto Compare.EN bit. Exit Compare.EN = 0 Compare.DN bit = 1 Examine Goto Compare EN bit is set. Compare.DN bit. Exit compare.DN bit = 0 Compare.ER bit is cleared.
  • Page 506 Chapter 13 Special Instructions (FBC, DDT, DTR, PID) Condition: Relay Ladder Action Compare Compare.POS = compare.LEN Compare.POS ≥ Goto Exit Compare.DN bit is set. Compare.LEN page 505 Result.DN = 1 Compare.FD bit is set. Result.DN bit is cleared. Reference[compare.POS] Source[compare.POS] = Examine result.DN Result.POS value is = Source[compare.POS]...
  • Page 507 Special Instructions (FBC, DDT, DTR, PID) Chapter 13 Example: When enabled, the DDT instruction compares the source array_dint1 to the reference array_dint2 and stores the locations of any mismatches in the result array_dint3. The controller also changes the mismatched bits in the reference array_dint2 to match the source array_dint1.
  • Page 508: Data Transitional (Dtr)

    Chapter 13 Special Instructions (FBC, DDT, DTR, PID) Data Transitional (DTR) The DTR instruction passes the Source value through a Mask and compares the result with the Reference value. Operands: Relay Ladder Operand Type Format Description Source DINT Immediate Array to compare to the reference Mask DINT Immediate...
  • Page 509 Special Instructions (FBC, DDT, DTR, PID) Chapter 13 Fault Conditions: None Execution: Condition Relay Ladder Action Prescan The Reference = Source AND Mask. The rung-condition-out is set to false. Rung-condition-in is false The Reference = Source AND Mask. The rung-condition-out is set to false. Rung-condition-in is true reference is set equal to masked source masked source =...
  • Page 510 Chapter 13 Special Instructions (FBC, DDT, DTR, PID) Example: When enabled, the DTR instruction masks value_1. If there is a difference in the two values, the rung-condition-out is set to true. Example 1 Example 2 Source Mask = 0FFF 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 Reference Current Scan...
  • Page 511: Proportional Integral Derivative (Pid)

    Special Instructions (FBC, DDT, DTR, PID) Chapter 13 Proportional Integral The PID instruction controls a process variable such as flow, pressure, Derivative (PID) temperature, or level. Operands: Relay Ladder Operand Type Format Description Structure PID structure Process SINT Value you want to control variable DINT REAL...
  • Page 512: Structured Text

    Chapter 13 Special Instructions (FBC, DDT, DTR, PID) Structured Text The operands are the same as those for the relay ladder PID instruction. PID(PID,ProcessVariable, However, you specify the Setpoint, Process Variable, and Output percent by Tieback,ControlVariable, accessing the .SP, .PV.and .OUT members of the PID structure, rather than by PIDMasterLoop,InholdBit, including values in the operand list.
  • Page 513 Special Instructions (FBC, DDT, DTR, PID) Chapter 13 Mnemonic: Data Type Description .BIAS REAL Feedforward or bias % .MAXS REAL Maximum engineering unit scaling value .MINS REAL Minimum engineering unit scaling value REAL Deadband engineering units REAL Set output % .MAXO REAL Maximum output limit (% of output)
  • Page 514 Chapter 13 Special Instructions (FBC, DDT, DTR, PID) Mnemonic: Data Type Description .DATA REAL[17] The .DATA member stores: Element Description .DATA[0] Integral accumulation .DATA[1] Derivative smoothing temporary value .DATA[2] Previous .PV value .DATA[3] Previous .ERR value .DATA[4] Previous valid .SP value .DATA[5] Percent scaling constant .DATA[6]...
  • Page 515 Special Instructions (FBC, DDT, DTR, PID) Chapter 13 Mnemonic: Data Type Description .DVPA BOOL Deviation is alarmed high (0=no; 1=yes) .PVLA BOOL PV is alarmed low (0=no; 1=yes) .PVHA BOOL PV is alarmed high (0=no; 1=yes) Description: The PID instruction typically receives the process variable (PV) from an analog input module and modulates a control variable output (CV) on an analog output module in order to maintain the process variable at the desired setpoint.
  • Page 516: Configure A Pid Instruction

    Chapter 13 Special Instructions (FBC, DDT, DTR, PID) Configure a PID Instruction After you enter the PID instruction and specify the PID structure, you use the configuration tabs to specify how the PID instruction should function. Click here to configure the PID instruction Specify Tuning Select the Tuning tab.
  • Page 517: Specify Configuration

    Special Instructions (FBC, DDT, DTR, PID) Chapter 13 Specify Configuration Select the Configuration tab. You must click OK or Apply for any changes to take effect. In this field Specify PID equation Select independent gains or dependent gains (.PE). Use independent when you want the three gains (P, I, and D) to operate independently. Use dependent when you want an overall controller gain that affects all three terms (P, I, and D).
  • Page 518: Specify Scaling

    Chapter 13 Special Instructions (FBC, DDT, DTR, PID) Specify Scaling Select the Scaling tab. You must click OK or Apply for any changes to take effect. In this field Specify PV unscaled maximum Enter a maximum PV value (.MAXI) that equals the maximum unscaled value received from the analog input channel for the PV value.
  • Page 519 Special Instructions (FBC, DDT, DTR, PID) Chapter 13 When using dependent gains, the proportional gain is replaced with a controller gain that affects all three terms. You can use either form of equation to perform the same type of control. The two equation types are merely provided to let you use the equation type with which you are most familiar.
  • Page 520: To Auto

    Chapter 13 Special Instructions (FBC, DDT, DTR, PID) Where: Variable Description Proportional gain (unitless) unitless Integral gain (seconds To convert between K (integral gain) and T (reset time), use: ---------- - Derivative gain (seconds) To convert between K (derivative gain) and T (rate time), use: ) 60 Controller gain (unitless)
  • Page 521: Pid Instruction Timing

    Special Instructions (FBC, DDT, DTR, PID) Chapter 13 The PID instruction also automatically provides bumpless transfers from software manual mode to auto mode or from manual to auto mode. The PID instruction back-calculates the value of the integral accumulation term required to make the CV output track either the set output (.SO) value in software manual mode or the tieback input in manual mode.
  • Page 522: Relay Ladder

    Chapter 13 Special Instructions (FBC, DDT, DTR, PID) Relay Ladder Structured Text PID(TIC101,Local:0:I.Ch0Data,Local:0:I.Ch1Data, Local:1:O.Ch4Data,0,Local:1:I.Ch4InHold, Local:1:I.Ch4Data); When using a periodic task, make sure that the analog input used for the process variable is updated to the processor at a rate that is significantly faster than the rate of the periodic task.
  • Page 523: Relay Ladder

    Special Instructions (FBC, DDT, DTR, PID) Chapter 13 Relay Ladder Structured Text PID_timer.pre := 1000 TONR(PID_timer); IF PID_timer.DN THEN PID(TIC101,Local:0:I.Ch0Data,Local:0:I.Ch1Data, Local:1:O.Ch0Data,0,Local:1:I.Ch0InHold, Local:1:I.Ch0Data); END_IF; In this method, the loop update time of the PID instruction should be set equal to the timer preset. As in the case of using a periodic task, you should set the analog input module to produce the process variable at a significantly faster rate than the loop update time.
  • Page 524: Relay Ladder

    Chapter 13 Special Instructions (FBC, DDT, DTR, PID) The timestamp ranges from 0…32,767 ms. Monitor the timestamp. When it changes, a new process variable sample has been received. Every time a timestamp changes, execute the PID instruction once. Because the process variable sample is driven by the analog input module, the input sample time is very accurate, and the loop update time used by the PID instruction should be set equal to the RTS time of the analog input module.
  • Page 525: Structured Text

    Special Instructions (FBC, DDT, DTR, PID) Chapter 13 Structured Text IF (Local:0:I.Ch0Fault) THEN TIC101.SWM [:=] 1; ELSE TIC101.SWM := 0; END_IF; IF (Local:0:I.RollingTimestamp<>PreviousTimestamp) OR (Local:0:I.Ch0Fault) THEN PreviousTimestamp := Local:0:I.RollingTimestamp; PID(TIC101,Local:0:I.Ch0Data,Local:0:I.Ch1Data, Local:1:O.Ch0Data,0,Local:1:I.Ch0InHold, Local:1:I.Ch0Data); END_IF; Bumpless Restart The PID instruction can interact with the 1756 analog output modules to support a bumpless restart when the controller changes from Program to Run mode or when the controller powers up.
  • Page 526: Derivative Smoothing

    Chapter 13 Special Instructions (FBC, DDT, DTR, PID) Instructions for setting a bumpless restart. Do this Details Configure the 1756 analog output module’s channel that Select the “hold for initialization” checkbox on the properties page for the specific channel of receives the control variable from the PID instruction the module.
  • Page 527: Use Output Limiting

    Special Instructions (FBC, DDT, DTR, PID) Chapter 13 Zero-crossing is deadband control that lets the instruction use the error for computational purposes as the process variable crosses into the deadband until the process variable crosses the setpoint. Once the process variable crosses the setpoint (error crosses zero and changes sign) and as long as the process variable remains in the deadband, the output will not change.
  • Page 528: Relay Ladder

    Chapter 13 Special Instructions (FBC, DDT, DTR, PID) Relay Ladder Structured Text PID(master,pv_master,0,cv_master,0,0,0); PID (slave,pv_slave,0,cv_slave,master,0,0); Control a Ratio You can maintain two values in a ratio by using these parameters: · Uncontrolled value · Controlled value (the resultant setpoint to be used by the PID instruction) ·...
  • Page 529: Structured Text

    Special Instructions (FBC, DDT, DTR, PID) Chapter 13 Structured Text pid_2.sp := uncontrolled_flow * ratio PID(pid_2,pv_2,tieback_2,cv_2,0,0,0); For this multiplication parameter Enter this value Destination Controlled value Source A Uncontrolled value Source B Ratio Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 530: Pid Theory

    Chapter 13 Special Instructions (FBC, DDT, DTR, PID) PID Theory The following figures show the process flow for PID instructions. PID Process Error Displayed Displayed as EUs as EUs Software A/M Output A/M Station Mode Control Bias % Action Software A/M Mode Output % SP-PV...
  • Page 531: Trigonometric Instructions

    Chapter Trigonometric Instructions (SIN, COS, TAN, ASN, ASIN, ACS, ACOS, ATN, ATAN) Topic Page Sine (SIN) Cosine (COS) Tangent (TAN) Arc Sine (ASN) Arc Cosine (ACS) Arc Tangent (ATN) The trigonometric instructions evaluate arithmetic operations by using trigonometric operations. If you want to Use this instruction Available in these languages Page...
  • Page 532: Sine (Sin)

    Chapter 14 Trigonometric Instructions (SIN, COS, TAN, ASN, ASIN, ACS, ACOS, ATN, ATAN) Sine (SIN) The SIN instruction takes the sine of the Source value (in radians) and stores the result in the Destination. Operands: Relay Ladder Operand Type Format Description Source SINT...
  • Page 533: Relay Ladder

    Trigonometric Instructions (SIN, COS, TAN, ASN, ASIN, ACS, ACOS, ATN, ATAN) Chapter 14 Fault Conditions: None Execution: Relay Ladder Condition Action Prescan The rung-condition-out is set to false. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true The controller calculates the sine of the Source and places the result in the Destination.
  • Page 534: Cosine (Cos)

    Chapter 14 Trigonometric Instructions (SIN, COS, TAN, ASN, ASIN, ACS, ACOS, ATN, ATAN) Cosine (COS) The COS instruction takes the cosine of the Source value (in radians) and stores the result in the Destination. Operands: Relay Ladder Operand Type Format Description Source SINT...
  • Page 535: Relay Ladder

    Trigonometric Instructions (SIN, COS, TAN, ASN, ASIN, ACS, ACOS, ATN, ATAN) Chapter 14 Fault Conditions: None Execution: Relay Ladder Condition Action Prescan The rung-condition-out is set to false. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true The controller calculates the cosine of the Source and places the result in the Destination.
  • Page 536: Tangent (Tan)

    Chapter 14 Trigonometric Instructions (SIN, COS, TAN, ASN, ASIN, ACS, ACOS, ATN, ATAN) Tangent (TAN) The TAN instruction takes the tangent of the Source value (in radians) and stores the result in the Destination. Operands: Relay Ladder Operand Type Format Description Source SINT...
  • Page 537: Relay Ladder

    Trigonometric Instructions (SIN, COS, TAN, ASN, ASIN, ACS, ACOS, ATN, ATAN) Chapter 14 Execution: Relay Ladder Condition Action Prescan The rung-condition-out is set to false. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true The controller calculates the tangent of the Source and places the result in the Destination. The rung-condition-out is set to true.
  • Page 538: Arc Sine (Asn)

    Chapter 14 Trigonometric Instructions (SIN, COS, TAN, ASN, ASIN, ACS, ACOS, ATN, ATAN) Arc Sine (ASN) The ASN instruction takes the arc sine of the Source value and stores the result in the Destination (in radians). Operands: Relay Ladder Operand Type Format Description...
  • Page 539: Relay Ladder

    Trigonometric Instructions (SIN, COS, TAN, ASN, ASIN, ACS, ACOS, ATN, ATAN) Chapter 14 Fault Conditions: None Execution: Relay Ladder Condition Action Prescan The rung-condition-out is set to false. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true The controller calculates the arc sine of the Source and places the result in the Destination.
  • Page 540: Arc Cosine (Acs)

    Chapter 14 Trigonometric Instructions (SIN, COS, TAN, ASN, ASIN, ACS, ACOS, ATN, ATAN) Arc Cosine (ACS) The ACS instruction takes the arc cosine of the Source value and stores the result in the Destination (in radians). Operands: Relay Ladder Operand Type Format Description...
  • Page 541: Relay Ladder

    Trigonometric Instructions (SIN, COS, TAN, ASN, ASIN, ACS, ACOS, ATN, ATAN) Chapter 14 Fault Conditions: None Execution: Relay Ladder Condition Action Prescan The rung-condition-out is set to false. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true The controller calculates the arc cosine of the Source and places the result in the Destination.
  • Page 542: Arc Tangent (Atn)

    Chapter 14 Trigonometric Instructions (SIN, COS, TAN, ASN, ASIN, ACS, ACOS, ATN, ATAN) Arc Tangent (ATN) The ATN instruction takes the arc tangent of the Source value and stores the result in the Destination (in radians). Operands: Relay Ladder Operand: Type Format Description...
  • Page 543: Fbd_Math_Advanced Structure

    Trigonometric Instructions (SIN, COS, TAN, ASN, ASIN, ACS, ACOS, ATN, ATAN) Chapter 14 FBD_MATH_ADVANCED Structure Input Parameter Data Type Description EnableIn BOOL Enable input. If cleared, the instruction does not execute and outputs are not updated. Default is set. Source REAL Input to the math instruction.
  • Page 544: Relay Ladder

    Chapter 14 Trigonometric Instructions (SIN, COS, TAN, ASN, ASIN, ACS, ACOS, ATN, ATAN) Example: Calculate the arc tangent of value and place the result in result. Relay Ladder Structured Text result := ATAN(value); Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 545: Advanced Math Instructions

    Chapter Advanced Math Instructions (LN, LOG, XPY) Topic Page Natural Log (LN) Log Base 10 (LOG) X to the Power of Y (XPY) The advanced math instructions include these instructions. If you want to Use this instruction Available in these languages Page Take the natural log of a value Relay ladder...
  • Page 546: Natural Log (Ln)

    Chapter 15 Advanced Math Instructions (LN, LOG, XPY) Natural Log (LN) The LN instruction takes the natural log of the Source and stores the result in the Destination. Operands: Relay Ladder Operand Type Format Description Source SINT Immediate Find the natural log of this value DINT REAL Destination...
  • Page 547: Relay Ladder

    Advanced Math Instructions (LN, LOG, XPY) Chapter 15 Description: The Source must be greater than zero, otherwise the overflow status bit (S:V) is set. The resulting Destination is greater than or equal to -87.33655 and less than or equal to 88.72284. Arithmetic Status Flags: Arithmetic status flags are affected.
  • Page 548: Relay Ladder Example

    Chapter 15 Advanced Math Instructions (LN, LOG, XPY) Example: Calculate the natural log of value and place the result in result. Relay Ladder Example Structured Text result := LN(value); Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 549: Log Base 10 (Log)

    Advanced Math Instructions (LN, LOG, XPY) Chapter 15 Log Base 10 (LOG) The LOG instruction takes the log base 10 of the Source and stores the result in the Destination. Operands: Relay Ladder Operand Type Format Description Source SINT Immediate Find the log of this value DINT REAL...
  • Page 550: Relay Ladder

    Chapter 15 Advanced Math Instructions (LN, LOG, XPY) Description: The Source must be greater than zero, otherwise the overflow status bit (S:V) is set. The resulting Destination is greater than or equal to -37.92978 and less than or equal to 38.53184. Arithmetic Status Flags: Arithmetic status flags are affected.
  • Page 551: Relay Ladder

    Advanced Math Instructions (LN, LOG, XPY) Chapter 15 Example: Calculate the log of value and place the result in result. Relay Ladder Structured Text result := LOG(value); Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 552: To The Power Of Y (Xpy)

    Chapter 15 Advanced Math Instructions (LN, LOG, XPY) X to the Power of Y (XPY) The XPY instruction takes Source A (X) to the power of Source B (Y) and stores the result in the Destination. Operands: Relay Ladder Operand Type Format Description...
  • Page 553: Fbd_Math Structure

    Advanced Math Instructions (LN, LOG, XPY) Chapter 15 FBD_MATH Structure Input Parameter Data Type Description EnableIn BOOL Enable input. If cleared, the instruction does not execute and outputs are not updated. Default is set. Source X REAL Base value. Valid = any float Source Y REAL Exponent.
  • Page 554: Relay Ladder

    Chapter 15 Advanced Math Instructions (LN, LOG, XPY) Execution: Relay Ladder Condition Action Prescan The rung-condition-out is set to false. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true The controller takes Source X to the power of Source Y and places the result in the Destination. The rung-condition-out is set to true.
  • Page 555: Relay Ladder

    Advanced Math Instructions (LN, LOG, XPY) Chapter 15 Example: The XPY instruction takes value_1 to the power of value_2 and places the result in result. Relay Ladder Structured Text result := (value_1 ∗∗ value_2); Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 556 Chapter 15 Advanced Math Instructions (LN, LOG, XPY) Notes: Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 557 Chapter Math Conversion Instructions (DEG, RAD, TOD, FRD, TRN, TRUNC) Topic Page Degrees (DEG) Radians (RAD) Convert to BCD (TOD) Convert to Integer (FRD) Truncate (TRN) The math conversion instructions convert values. If you want to Use this instruction Available in these languages Page Convert radians to degrees Relay ladder...
  • Page 558: Degrees (Deg)

    Chapter 16 Math Conversion Instructions (DEG, RAD, TOD, FRD, TRN, TRUNC) Degrees (DEG) The DEG instruction converts the Source (in radians) to degrees and stores the result in the Destination. Operands: Relay Ladder Operand Type Format Description Source SINT Immediate Value to convert to degrees DINT REAL...
  • Page 559: Fbd_Math_Advanced Structure

    Math Conversion Instructions (DEG, RAD, TOD, FRD, TRN, TRUNC) Chapter 16 FBD_MATH_ADVANCED Structure Input Parameter Data Type Description EnableIn BOOL Enable input. If cleared, the instruction does not execute and outputs are not updated. Default is set. Source REAL Input to the conversion instruction. Valid = any float Output Parameter Data Type...
  • Page 560: Relay Ladder

    Chapter 16 Math Conversion Instructions (DEG, RAD, TOD, FRD, TRN, TRUNC) Example: Convert value to degrees and place the result in result. Relay Ladder Structured Text result := DEG(value); Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 561: Radians (Rad)

    Math Conversion Instructions (DEG, RAD, TOD, FRD, TRN, TRUNC) Chapter 16 Radians (RAD) The RAD instruction converts the Source (in degrees) to radians and stores the result in the Destination. Operands: Relay Ladder Operand Type Format Description Source SINT Immediate Value to convert to radians DINT REAL...
  • Page 562: Fbd_Math_Advanced Structure

    Chapter 16 Math Conversion Instructions (DEG, RAD, TOD, FRD, TRN, TRUNC) FBD_MATH_ADVANCED Structure Input Parameter Data Type Description EnableIn BOOL Enable input. If cleared, the instruction does not execute and outputs are not updated. Default is set. Source REAL Input to the conversion instruction. Valid = any float Output Parameter Data Type...
  • Page 563: Relay Ladder

    Math Conversion Instructions (DEG, RAD, TOD, FRD, TRN, TRUNC) Chapter 16 Example Convert value to radians and place the result in result. Relay Ladder Structured Text result := RAD(value); Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 564: Convert To Bcd (Tod)

    Chapter 16 Math Conversion Instructions (DEG, RAD, TOD, FRD, TRN, TRUNC) Convert to BCD (TOD) (0 ≤ Source ≤ 99,999,999) The TOD instruction converts a decimal value to a BCD value and stores the result in the Destination. Operands: Relay Ladder Operand Type Format...
  • Page 565: Relay Ladder

    Math Conversion Instructions (DEG, RAD, TOD, FRD, TRN, TRUNC) Chapter 16 Description: BCD is the Binary Coded Decimal number system that expresses individual decimal digits (0…9) in a 4-bit binary notation. If you enter a negative Source, the instruction generates a minor fault and clears the Destination.
  • Page 566: Function Block

    Chapter 16 Math Conversion Instructions (DEG, RAD, TOD, FRD, TRN, TRUNC) Function Block Condition Action Prescan No action taken. Instruction first scan No action taken. Instruction first run No action taken. EnableIn is cleared EnableOut is cleared. EnableIn is set The instruction executes.
  • Page 567: Convert To Integer (Frd)

    Math Conversion Instructions (DEG, RAD, TOD, FRD, TRN, TRUNC) Chapter 16 Convert to Integer (FRD) The FRD instruction converts a BCD value (Source) to a decimal value and stores the result in the Destination. Operands: Relay Ladder Operand Type Format Description Source SINT...
  • Page 568: Relay Ladder

    Chapter 16 Math Conversion Instructions (DEG, RAD, TOD, FRD, TRN, TRUNC) Description: The FRD instruction converts a BCD value (Source) to a decimal value and stores the result in the Destination. Arithmetic Status Flags: Arithmetic status flags are affected. Fault Conditions: None Execution: Relay Ladder...
  • Page 569: Relay Ladder

    Math Conversion Instructions (DEG, RAD, TOD, FRD, TRN, TRUNC) Chapter 16 Example: The FRD instruction converts value_a to a decimal value and places the result in result_1. Relay Ladder Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 570: Truncate (Trn)

    Chapter 16 Math Conversion Instructions (DEG, RAD, TOD, FRD, TRN, TRUNC) Truncate (TRN) The TRN instruction removes (truncates) the fractional part of the Source and stores the result in the Destination. Operands: Relay Ladder Operand Type Format Description Source REAL Immediate Value to truncate Destination...
  • Page 571: Relay Ladder

    Math Conversion Instructions (DEG, RAD, TOD, FRD, TRN, TRUNC) Chapter 16 Description: Truncating does not round the value; rather, the non-fractional part remains the same regardless of the value of the fractional part. Arithmetic Status Flags: Arithmetic status flags are affected. Fault Conditions: None Execution:...
  • Page 572: Relay Ladder

    Chapter 16 Math Conversion Instructions (DEG, RAD, TOD, FRD, TRN, TRUNC) Example: Remove the fractional part of float_value_1, leaving the non-fractional part the same, and place the result in float_value_1_truncated. Relay Ladder Structured Text float_value_1_truncated := TRUNC(float_value_1); Function Block Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 573: 1756-L7X Controllers

    Use the ASCII serial port instructions to read and write ASCII characters To use the ASCII serial port instructions, you must configure the IMPORTANT serial port of the controller. For procedures, see the Logix5000 Controllers Common Procedures Programming Manual, publication 1756-PM001.
  • Page 574 Chapter 17 ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) If you want to For example Use this Available in these Page instruction languages Determine when the buffer contains Check for data that contains termination Relay ladder termination characters characters Structured text...
  • Page 575: Instruction Execution

    ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) Chapter 17 Instruction Execution ASCII serial port instructions execute asynchronous to the scan of the logic. Logic ASCII Queue ASCII Task Rung-condition-in of Instruction 1 Instruction at the top instruction transitions of the queue executes.
  • Page 576 Chapter 17 ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) Scan Scan Scan Scan Rung-condition-in false true false true false .DN or .ER Enters Queue Resets status bits. When scanned and .DN Executes or .ER are set, sets the .EM bit.
  • Page 577: Ascii Error Codes

    · You can use the default STRING data type. It stores up to 82 characters. · You can create a new string data type that stores less or more characters. To create a new string data type, see the Logix5000 Controllers Common Procedures Programming Manual, publication 1756-PM001.
  • Page 578: Ascii Test For Buffer Line (Abl)

    Chapter 17 ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) ASCII Test For Buffer Line The ABL instruction counts the characters in the buffer up to and including the (ABL) first termination character. Operands: Relay Ladder Operand Type Format...
  • Page 579 ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) Chapter 17 Description The ABL instruction searches the buffer for the first set of termination characters. If the instruction finds the termination characters, it does the following: · Sets the .FD bit. ·...
  • Page 580: Relay Ladder

    Chapter 17 ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) Example: Continuously test the buffer for the termination characters. Relay Ladder MV_line.EN ASCII Test For Buffer Line Channel SerialPort Control MV_line Character Count Structured Text ABL(0,MV_line); Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 581: Ascii Chars In Buffer (Acb)

    ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) Chapter 17 ASCII Chars in Buffer (ACB) The ACB instruction counts the characters in the buffer. Operands: Relay Ladder Operand Type Format Enter Channel DINT Immediate ASCII Chars in Buffer Channel SerialPort Control Character Count...
  • Page 582: Relay Ladder

    Chapter 17 ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) Description: The ACB instruction counts the characters in the buffer. Follow these guidelines to program the ACB instruction. 1. Configure the serial port of the controller for user mode. 2.
  • Page 583: Ascii Clear Buffer (Acl)

    ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) Chapter 17 ASCII Clear Buffer (ACL) The ACL instruction immediately clears the buffer and ASCII queue. Operands: Relay Ladder Operand Type Format Enter ASCII Clear Buffer Channel DINT Immediate Channel Clear Serial Port Read...
  • Page 584: Relay Ladder

    Chapter 17 ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) Arithmetic Status Flags: Not affected Fault Conditions: None Execution: Condition Relay Ladder Action Structured Text Action Prescan The rung-condition-out is set to false. No action taken. Rung-condition-in is false The rung-condition-out is set to false.
  • Page 585: Ascii Handshake Lines (Ahl)

    ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) Chapter 17 ASCII Handshake Lines The AHL instruction obtains the status of control lines and turns on or off the (AHL) DTR and RTS signals. Operands: Relay Ladder ASCII Handshake Lines Channel AND Mask...
  • Page 586: Structured Text

    Chapter 17 ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) Structured Text AHL(Channel,ANDMask,ORMask, The operands are the same as those for the relay ladder AHL instruction. SerialPortControl); However, you specify the Channel Status value by accessing the .POS member of the SERIAL_PORT_CONTROL structure, rather than by including the value in the operand list.
  • Page 587 ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) Chapter 17 Description: The AHL instruction can do the following: · Obtain the status of the control lines of the serial port · Turn on or off the data terminal ready (DTR) signal ·...
  • Page 588: Relay Ladder

    Chapter 17 ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) 3. This is a transitional instruction. · In relay ladder, toggle the rung-condition-in from cleared to set each time the instruction should execute. · In structured text, condition the instruction so that it executes only on a transition.
  • Page 589: Structured Text

    ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) Chapter 17 Structured Text osri_1.InputBit := get_control_line_status; OSRI(osri_1); IF (osri_1.OutputBit) THEN AHL(0,0,0,serial_port); END_IF; Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 590: Ascii Read (Ard)

    Chapter 17 ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) ASCII Read (ARD) The ARD instruction removes characters from the buffer and stores them in the Destination. Operands: Relay Ladder ASCII Read Channel Destination SerialPort Control SerialPort Control Length Characters Read Operand...
  • Page 591: Structured Text

    ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) Chapter 17 Structured Text ARD(Channel,Destination, The operands are the same as those for the relay ladder ARD instruction. SerialPortControl); However, you specify the Serial Port Control Length and the Characters Read values by accessing the .LEN and .POS members of the SERIAL_PORT_CONTROL structure, rather than by including the values in the operand list.
  • Page 592: Relay Ladder

    Chapter 17 ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) 4. To trigger a subsequent action when the instruction is done, examine the EM bit. Arithmetic Status Flags: Not affected Fault Conditions: None Execution: Condition Relay Ladder Action Structured Text Action Prescan The rung-condition-out is set to false.
  • Page 593: Structured Text

    ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) Chapter 17 Structured Text ACB(0,bar_code_count); IF bar_code_count.POS >= 24 THEN bar_code_read.LEN := 24; ARD(0,bag_bar_code,bar_code_read); END_IF; Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 594: Ascii Read Line (Arl)

    Chapter 17 ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) ASCII Read Line (ARL) The ARL instruction removes specified characters from the buffer and stores them in the Destination. Operands: Relay Ladder ASCII Read Line Channel Destination SerialPort Control SerialPort Control Length...
  • Page 595: Structured Text

    ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) Chapter 17 Structured Text ARL(Channel,Destination, The operands are the same as those for the relay ladder ARL instruction. SerialPortControl); However, you specify the Serial Port Control Length and the Characters Read values by accessing the .LEN and .POS members of the SERIAL_PORT_CONTROL structure, rather than by including the values in the operand list.
  • Page 596: Relay Ladder

    Chapter 17 ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) · In structured text, condition the instruction so that it executes only on a transition. 4. To trigger a subsequent action when the instruction is done, examine the EM bit.
  • Page 597: Structured Text

    ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) Chapter 17 MV_line.FD ASCII Read Line Channel Destination MV_msg SerialPort Control MV_read SerialPort Control Length Characters Read Structured Text ABL(0,MV_line); osri_1.InputBit := MVLine.FD; OSRI(osri_1); IF (osri_1.OutputBit) THEN mv_read.LEN := 12; ARL(0,MV_msg,MV_read);...
  • Page 598: Ascii Write Append (Awa)

    Chapter 17 ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) ASCII Write Append (AWA) The AWA instruction sends a specified number of characters of the Source tag to a serial device and appends either one or two predefined characters. Operands: Relay Ladder ASCII Write Append...
  • Page 599: Structured Text

    ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) Chapter 17 Structured Text AWA(Channel,Source, The operands are the same as those for the relay ladder AWA instruction. SerialPortControl); However, you specify the Serial Port Control Length and the Characters Sent values by accessing the .LEN and .POS members of the SERIAL_PORT_CONTROL structure, rather than by including the values in the operand list.
  • Page 600: Relay Ladder

    Chapter 17 ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) · In structured text, condition the instruction so that it executes only on a transition. 3. Each time the instruction executes, do you always send the same number of characters? Then In the Serial Port Control Length, enter the number of characters to send.
  • Page 601: Structured Text

    ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) Chapter 17 Structured Text IF temp_high THEN temp_high_write.LEN := 5; AWA(0,string[1],temp_high_write); temp_high := 0; END_IF; Example 2: When alarm is set, the AWA instruction sends the specified number of characters in alarm_msg and appends a termination character (s).
  • Page 602: Ascii Write (Awt)

    Chapter 17 ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) ASCII Write (AWT) The AWT instruction sends a specified number of characters of the Source tag to a serial device. Operands: Relay Ladder ASCII Write Channel Source SerialPort Control SerialPort Control Length...
  • Page 603: Structured Text

    ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) Chapter 17 Structured Text AWT(Channel,Source, The operands are the same as those for the relay ladder AWT instruction. SerialPortControl); However, you specify the Serial Port Control Length and the Characters Sent values by accessing the .LEN and .POS members of the SERIAL_PORT_CONTROL structure, rather than by including the values in the operand list.
  • Page 604: Relay Ladder

    Chapter 17 ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) 3. Each time the instruction executes, do you always send the same number of characters? Then In the Serial Port Control Length, enter the number of characters to send. Before the instruction executes, move the LEN member of the Source tag to the LEN member of the Serial Port Control tag.
  • Page 605: Structured Text

    ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) Chapter 17 Structured Text osri_1.InputBit := temp_low; OSRI(osri_1); IF (osri_1.OutputBit) THEN temp_low_write.LEN := 9; AWT(0,string[2],temp_low_write); END_IF; Example 2: When MV_update is set, the AWT instruction sends the characters in MV_msg. Because the number of characters in MV_msg varies, the rung first moves the length of the string (MV_msg.LEN) to the Serial Port Control Length of the AWT instruction (MV_write.LEN).
  • Page 606 Chapter 17 ASCII Serial Port Instructions (ABL, ACB, ACL, AHL, ARD, ARL, AWA, AWT) Notes: Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 607: Ascii String Instructions

    Chapter ASCII String Instructions (CONCAT, DELETE, FIND, INSERT, MID) Topic Page String Concatenate (CONCAT) String Delete (DELETE) Find String (FIND) Insert String (INSERT) Middle String (MID) Use the ASCII string instructions to modify and create strings of ASCII characters. If you want to For example Use this Available in these...
  • Page 608 Chapter 18 ASCII String Instructions (CONCAT, DELETE, FIND, INSERT, MID) You can also use the following instructions to compare or convert ASCII characters. If you want to Use this instruction Page Compare a string to another string See if the characters are equal to specific characters See if the characters are not equal to specific characters See if the characters are equal to or greater than specific characters See if the characters are greater than specific characters...
  • Page 609: String Data Types

    ·You can use the default STRING data type. It stores up to 82 characters. ·You can create a new string data type that stores less or more characters. To create a new string data type, see the Logix5000 Controllers Common Procedures Programming Manual, publication 1756-PM001.
  • Page 610: String Concatenate (Concat)

    Chapter 18 ASCII String Instructions (CONCAT, DELETE, FIND, INSERT, MID) String Concatenate The CONCAT instruction adds ASCII characters to the end of a string. (CONCAT) Operands: Relay Ladder CONCAT String Concatenate Source A Source B Dest Operand Type Format Enter Notes Source A String...
  • Page 611: Relay Ladder

    ASCII String Instructions (CONCAT, DELETE, FIND, INSERT, MID) Chapter 18 Execution: Condition Relay Ladder Action Structured Text Action Prescan The rung-condition-out is set to false. No action taken. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true The instruction executes.
  • Page 612: String Delete (Delete)

    Chapter 18 ASCII String Instructions (CONCAT, DELETE, FIND, INSERT, MID) String Delete (DELETE) The DELETE instruction does not automatically remove all ASCII characters from a string. An algorithm determines which characters in the string are removed depending on the starting position, quantity, and size of the Source. Operands: Relay Ladder DELETE...
  • Page 613: Relay Ladder

    ASCII String Instructions (CONCAT, DELETE, FIND, INSERT, MID) Chapter 18 Execution: Condition Relay Ladder Action Structured Text Action Prescan The rung-condition-out is set to false. No action taken Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true The instruction executes.
  • Page 614: Find String (Find)

    Chapter 18 ASCII String Instructions (CONCAT, DELETE, FIND, INSERT, MID) Find String (FIND) The FIND instruction locates the starting position of a specified string within another string. Operands: Relay Ladder FIND Find String Source Search Start Result Operand Type Format Enter Notes Source...
  • Page 615: Relay Ladder

    ASCII String Instructions (CONCAT, DELETE, FIND, INSERT, MID) Chapter 18 Execution: Condition Relay Ladder Action Structured Text Action Prescan The rung-condition-out is set to false. No action taken. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true The instruction executes.
  • Page 616: Insert String (Insert)

    Chapter 18 ASCII String Instructions (CONCAT, DELETE, FIND, INSERT, MID) Insert String (INSERT) The INSERT instruction adds ASCII characters to a specified location within a string. Operands: Relay Ladder INSERT Insert String Source A Source B Start Dest Operand Type Format Enter Notes...
  • Page 617: Relay Ladder

    ASCII String Instructions (CONCAT, DELETE, FIND, INSERT, MID) Chapter 18 Execution: Condition Relay Ladder Action Structured Text Action Prescan The rung-condition-out is set to false. No action taken. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true The instruction executes.
  • Page 618: Middle String (Mid)

    Chapter 18 ASCII String Instructions (CONCAT, DELETE, FIND, INSERT, MID) Middle String (MID) The MID instruction copies a specified number of ASCII characters from a string and stores them in another string. Operands: Relay Ladder Middle String Source Start Dest Operand Type Format...
  • Page 619: Relay Ladder

    ASCII String Instructions (CONCAT, DELETE, FIND, INSERT, MID) Chapter 18 Execution: Condition Relay Ladder Action Structured Text Action Prescan The rung-condition-out is set to false. No action taken. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true The instruction executes.
  • Page 620 Chapter 18 ASCII String Instructions (CONCAT, DELETE, FIND, INSERT, MID) Notes: Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 621 Chapter ASCII Conversion Instructions (STOD, STOR, DTOS, RTOS, UPPER, LOWER) Topic Page String To DINT (STOD) String To REAL (STOR) DINT to String (DTOS) REAL to String (RTOS) Upper Case (UPPER) Lower Case (LOWER) Use the ASCII conversion instructions to alter the format of data. If you want to For example Use this...
  • Page 622: String Data Types

    · You can use the default STRING data type. It stores up to 82 characters. · You can create a new string data type that stores less or more characters. To create a new string data type, see the Logix5000 Controllers Common Procedures Programming Manual, publication 1756-PM001.
  • Page 623: String To Dint (Stod)

    ASCII Conversion Instructions (STOD, STOR, DTOS, RTOS, UPPER, LOWER) Chapter 19 String To DINT (STOD) The STOD instruction converts the ASCII representation of an integer to an integer or REAL value. Operands: Relay Ladder STOD String To DINT Source Dest Operand Type Format...
  • Page 624: Relay Ladder

    Chapter 19 ASCII Conversion Instructions (STOD, STOR, DTOS, RTOS, UPPER, LOWER) Execution: Condition Relay Ladder Action Structured Text Action Prescan The rung-condition-out is set to false. No action taken. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true The instruction executes.
  • Page 625: String To Real (Stor)

    ASCII Conversion Instructions (STOD, STOR, DTOS, RTOS, UPPER, LOWER) Chapter 19 String To REAL (STOR) The STOR instruction converts the ASCII representation of a floating-point value to a REAL value. Operands: Relay Ladder Operands STOR String to Real Source Dest Operand Type Format...
  • Page 626: Relay Ladder

    Chapter 19 ASCII Conversion Instructions (STOD, STOR, DTOS, RTOS, UPPER, LOWER) Execution: Condition Relay Ladder Action Structured Text Action Prescan The rung-condition-out is set to false. No action taken. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true The instruction executes.
  • Page 627: Dint To String (Dtos)

    ASCII Conversion Instructions (STOD, STOR, DTOS, RTOS, UPPER, LOWER) Chapter 19 DINT to String (DTOS) The DTOS instruction produces the ASCII representation of a value. Operands: Relay Ladder DTOS DINT to String Source Dest Operand Type Format Enter Notes Source SINT Tag that contains the value If the Source is a REAL, the instruction converts it to...
  • Page 628: Relay Ladder

    Chapter 19 ASCII Conversion Instructions (STOD, STOR, DTOS, RTOS, UPPER, LOWER) Execution: Condition Relay Ladder Action Structured Text Action Prescan The rung-condition-out is set to false. No action taken. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true The instruction executes.
  • Page 629: Real To String (Rtos)

    ASCII Conversion Instructions (STOD, STOR, DTOS, RTOS, UPPER, LOWER) Chapter 19 REAL to String (RTOS) The RTOS instruction produces the ASCII representation of a REAL value. Operands: Relay Ladder RTOS Real to String Source Dest Operand Type Format Enter Notes Source REAL Tag that contains the REAL...
  • Page 630: Relay Ladder

    Chapter 19 ASCII Conversion Instructions (STOD, STOR, DTOS, RTOS, UPPER, LOWER) Execution: Condition Relay Ladder Action Structured Text Action Prescan The rung-condition-out is set to false. No action taken. Rung-condition-in is false The rung-condition-out is set to false. Rung-condition-in is true The instruction executes.
  • Page 631: Upper Case (Upper)

    ASCII Conversion Instructions (STOD, STOR, DTOS, RTOS, UPPER, LOWER) Chapter 19 Upper Case (UPPER) The UPPER instruction converts the alphabetical characters in a string to upper case characters. Operands: Relay Ladder Operand Type Format Description Source String Tag that contains the characters that you want to convert to upper case Destination String...
  • Page 632: Relay Ladder

    Chapter 19 ASCII Conversion Instructions (STOD, STOR, DTOS, RTOS, UPPER, LOWER) Example: To find information about a specific item, an operator enters the catalog number of the item into an ASCII terminal. After the controller reads the input from a terminal (terminal_read.EM is set), the UPPER instruction converts the characters in catalog_number to all upper case characters and stores the result in catalog_number_upper_case.
  • Page 633: Lower Case (Lower)

    ASCII Conversion Instructions (STOD, STOR, DTOS, RTOS, UPPER, LOWER) Chapter 19 Lower Case (LOWER) The LOWER instruction converts the alphabetical characters in a string to lower case characters. Operands: Relay Ladder Operand Type Format Description Source String Tag that contains the characters that you want to convert to lower case Destination String...
  • Page 634: Relay Ladder

    Chapter 19 ASCII Conversion Instructions (STOD, STOR, DTOS, RTOS, UPPER, LOWER) Example: To find information about a specific item, an operator enters the item number into an ASCII terminal. After the controller reads the input from a terminal (terminal_read.EM is set), the LOWER instruction converts the characters in item_number to all lower case characters and stores the result in item_number_lower_case.
  • Page 635: Breakpoints (Bpt)

    Use the debug instructions to monitor the state of your logic when it is in conditions that you determine. These instructions are compatible only with RSLogix Emulate 5000 software, with which you can emulate a Logix5000 controller on your personal computer. If you want to Use this instruction...
  • Page 636: String Format

    Chapter 20 Debug Instructions (BPT, TPT) Description: Breakpoints are programmed with the Breakpoint output instruction (BPT). When the inputs on a rung containing a BPT instruction are true, the BPT instruction stops program execution. The software displays a window indicating that the breakpoint triggered and the values that triggered it. When a breakpoint triggers, the emulator displays a window informing you that a breakpoint occurred.
  • Page 637 Debug Instructions (BPT, TPT) Chapter 20 In this case, you would have a tracepoint instruction that has two Trace This operands (one for a REAL and one for an INT, although the value of any tag can be formatted with any flag). The resulting tracepoint window that would appear when the tracepoint is triggered would look like the example.
  • Page 638 Chapter 20 Debug Instructions (BPT, TPT) Example: You can display many tag values with the BPT instruction. However, the formatting string can contain only 82 characters. Because the formatting string requires two characters for each tag you want in the breakpoint, you cannot trace more than 41 tags with a single BPT instruction.
  • Page 639: Tracepoints (Tpt)

    Debug Instructions (BPT, TPT) Chapter 20 Tracepoints (TPT) Trace points log data you select when a rung is true. Operands: Relay Ladder Operand Type Format Description Format String A string that sets the formatting for the trace reports (both on-screen and logged to disk).
  • Page 640 Chapter 20 Debug Instructions (BPT, TPT) In this case, you would have a tracepoint instruction that has two Trace This operands (one for a REAL and one for an INT, although the value of any tag can be formatted with any flag). The resulting tracepoint window that would appear when the tracepoint is triggered would look like the example.
  • Page 641 Debug Instructions (BPT, TPT) Chapter 20 Example: This rung triggers a trace of three analog values when any one of them exceeds a given value (30.01). You want to display the tracepoint information in the Format string (myformat). In this case, the format string contains this text: Analog inputs trace:Analog inputs = %f, %f, and %f When the tracepoint triggers, the characters before the colon (‘Analog inputs trace’) appear in the title bar of the trace window.
  • Page 642 Chapter 20 Debug Instructions (BPT, TPT) When this trace is logged to disk, the characters before the colon appear in the traces. This indicates which tracepoint caused which trace entry. This is an example of a trace entry. ‘Analog inputs trace:’ is the heading text from the tracepoint's format string.
  • Page 643: Introduction

    Appendix Common Attributes Introduction This appendix describes attributes that are common to the Logix instructions. For Information About See Page Immediate Values Floating Point Values Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 644: Status Flags

    Appendix A Common Attributes Status Flags To access controller configuration and status in your logic, use the Get System Value (GSV) and Set System Value (SSV) instructions. There is also a set of status flags that you can access directly with relay and structured text instructions. These flags are not tags and you cannot create aliases for them.
  • Page 645 Common Attributes Appendix A Status Flag Description Overflow flag The controller sets the overflow flag when the result of an arithmetic operation resulted in an overflow. This flag can be used with only the XIC, XIO, OTE, OTL and OTU relay instructions or in structured text like a Boolean variable.
  • Page 646: Expressions In Array Subscripts

    Appendix A Common Attributes Expressions in Array Subscripts Expressions set status flags based on the results of arithmetic operations. If you have an array subscript as an expression, both the expression and the instruction could generate minor faults. Under certain circumstances, the S:Z status flag may be set if the expression of an array element evaluates to zero.
  • Page 647: Floating Point Values

    As a result, there is no way to control the number of digits to the right of the decimal point in logic in a Logix5000 controller. For example, in most cases, if you subtract 10 from 10.1, you expect the result to be 0.1.
  • Page 648: Totalizer Examples

    Appendix A Common Attributes Totalizer Examples The IEEE 754 standard affects totalization applications such that errors occur when adding very small numbers to very large numbers. The standard requires exponents in the two operands to be the same. Since the fractional component is only 23 bits, as the exponent gets larger, the fractional component approaches zero.
  • Page 649: Data Conversions

    Common Attributes Appendix A Data Conversions Data conversions occur when you mix data types in your programming. When programming Conversions can occur when you Relay Ladder Logic Mix data types for the parameters within one instruction Function Block Wire two parameters that have different data types Instructions execute faster and require less memory if all the operands of the instruction use: •...
  • Page 650: Data Types

    Appendix A Common Attributes Data Types LINT Data Type Considerations When using LINT data types, many limitations apply. A LINT data type cannot be used in most instructions. Limitations are as follows: • The LINT data type is not supported in Machine Edition. The LINT data type is a 64-bit word;...
  • Page 651 Common Attributes Appendix A Because immediate values are always zero-filled, the conversion of a SINT or INT value may produce unexpected results. In the following example, the comparison is false because Source A, an INT, converts by sign-extension; while Source B, an immediate value, is zero-filled. adder Logic Listing - Total number of rungs: 3 Equal Source A...
  • Page 652: Integer To Real

    Appendix A Common Attributes EXAMPLE Mixing an INT tag with an immediate value Since remote_rack_1:I.Data[0] is an INT tag, the value to check it against first moves into int_0, also an INT tag. The EQU instruction then compares both tags. 2#1111_1111_1111_1111 Move Equal...
  • Page 653: Real To An Integer

    Common Attributes Appendix A REAL to an Integer To convert a REAL value to an integer value, the controller rounds the fractional part and truncates the upper portion of the non-fractional part. If data is lost, the controller sets the overflow status flag. Numbers round as in the following examples.
  • Page 654 Appendix A Common Attributes Notes: Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 655: Introduction

    Appendix Function Block Attributes Introduction This appendix describes issues that are unique with function block instructions. Review the information in this appendix to make sure you understand how your function block routines will operate. When programming in function block, restrict the range of IMPORTANT +/-15 engineering units to +/-10...
  • Page 656: Latching Data

    Appendix B Function Block Attributes Use the table to choose your function block elements. If you want to Use a Supply a value from an input device or tag Input reference (IREF) Send a value to an output device or tag Output reference (OREF) Perform an operation on an input value or values and Function block...
  • Page 657 Function Block Attributes Appendix B This example is the same as the one above. The value of tagA is stored only once at the beginning of the routine’s execution. The routine uses this stored value throughout the routine. Block_01 tagA Block_02 tagA Starting with RSLogix 5000 software, version 11, you can use the same tag in...
  • Page 658: Order Of Execution

    Appendix B Function Block Attributes Order of Execution The RSLogix 5000 programming software automatically determines the order of execution for the function blocks in a routine when you do the following: · Verify a function block routine. · Verify a project that contains a function block routine. ·...
  • Page 659 Function Block Attributes Appendix B This input pin uses an output that the block produced on the previous scan. If a group of blocks are in a loop, the controller cannot determine which block to execute first. In other words, it cannot resolve the loop. To identify which block to execute first, mark the input wire that creates the loop (the feedback wire) with the Assume Data Available indicator.
  • Page 660: Resolve Data Flow Between Two Blocks

    Appendix B Function Block Attributes Resolve Data Flow Between Two Blocks If you use two or more wires to connect two blocks, use the same data flow indicators for all of the wires between the two blocks. This is okay This is not okay One wire uses the Assume Data Available indicator while the other wire Neither wire uses the Assume Data Available indicator.
  • Page 661: Function Block Responses To Overflow Conditions

    Function Block Attributes Appendix B Function Block Responses In general, the function block instructions that maintain history do not update to Overflow Conditions history with ±NAN, or ±INF values when an overflow occurs. Each instruction has one of these responses to an overflow condition. Response 1 Response 2 Response 3...
  • Page 662: Common Instruction Parameters For Timing Modes

    Appendix B Function Block Attributes Timing Mode Description Oversample In oversample mode, the delta time (DeltaT) used by the instruction is the value written into the OversampleDT parameter of the instruction. If the process input has a time stamp value, use the real time sampling mode instead. Add logic to your program to control when the instruction executes.
  • Page 663 Function Block Attributes Appendix B Input Parameters Input Parameter Data Type Description TimingMode DINT Selects timing execution mode. Value: Description: Periodic mode Oversample mode Real time sampling mode Valid = 0…2 Default = 0 When TimingMode = 0 and task is periodic, periodic timing is enabled and DeltaT is set to the task scan rate.
  • Page 664 Appendix B Function Block Attributes Output Parameters Output Parameter Data Type Description DeltaT REAL Elapsed time between updates. This is the elapsed time in seconds used by the control algorithm to calculate the process output. Periodic: DeltaT = task scan rate if task is Periodic task, DeltaT = elapsed time since previous instruction execution if task is Event or Continuous task Oversample: DeltaT = OversampleDT Real Time Sampling: DeltaT = (RTSTimeStamp...
  • Page 665: Overview Of Timing Modes

    Function Block Attributes Appendix B Overview of Timing Modes The following diagram shows how an instruction determines the appropriate timing mode. Determine Time-base Mode TimingMode = 0 TimingMode = 1 TimingMode = 2 Periodic Timing Oversample Timing Real Time Timing DeltaT = OversampleDT DeltaT = RTSTimeStamp - RTSTimeStamp...
  • Page 666: Program/Operator Control

    Appendix B Function Block Attributes Program/Operator Control Several instructions support the concept of Program/Operator control. These instructions include the following: · Enhanced Select (ESEL) · Totalizer (TOT) · Enhanced PID (PIDE) · Ramp/Soak (RMPS) · Discrete 2-State Device (D2SD) · Discrete 3-State Device (D3SD) Program/Operator control lets you control these instructions simultaneously from both your user program and from an operator interface device.
  • Page 667 Function Block Attributes Appendix B For example, let’s assume that a Totalizer instruction will always be used in Operator control, and your user program will never control the running or stopping of the Totalizer. In this case, you could wire a literal value of 1 into the ProgOperReq.
  • Page 668 Appendix B Function Block Attributes Operator request inputs to an instruction are always cleared by the instruction when it executes. This allows operator interfaces to work with these instructions by merely setting the desired mode request bit. You don’t have to program the operator interface to reset the request bits.
  • Page 669: Introduction

    Appendix Structured Text Programming Introduction This appendix describes issues that are unique with structured text programming. Review the information in this appendix to make sure you understand how your structured text programming executes. Topic Page Structured Text Syntax Assignments Expressions Instructions Constructs Comments...
  • Page 670: Assignments

    Appendix C Structured Text Programming Term Definition Examples Instruction An instruction is a standalone statement. instruction(); (see page 679) An instruction uses parenthesis to contain its operands. Depending on the instruction, there can be zero, one, or multiple operands. instruction(operand); When executed, an instruction yields one or more values that are part of a data structure.
  • Page 671: Specify A Non-Retentive Assignment

    Structured Text Programming Appendix C Specify a Non-retentive Assignment The non-retentive assignment is different from the regular assignment described above in that the tag in a non-retentive assignment is reset to zero each time the controller does the following: • Enters the RUN mode. •...
  • Page 672: Assign An Ascii Character To A String

    Appendix C Structured Text Programming Assign an ASCII Character to a String Use the assignment operator to assign an ASCII character to an element of the DATA member of a string tag. To assign a character, specify the value of the character or specify the tag name, DATA member, and element of the character.
  • Page 673: Expressions

    Structured Text Programming Appendix C Expressions An expression is a tag name, equation, or comparison. To write an expression, use any of the following: • Tag name that stores the value (variable) • Number that you enter directly into the expression (immediate value) •...
  • Page 674: Use Arithmetic Operators And Functions

    Appendix C Structured Text Programming Use Arithmetic Operators and Functions You can combine multiple operators and functions in arithmetic expressions. Arithmetic operators calculate new values. Use this operator Optimal data type DINT, REAL Subtract/negate DINT, REAL Multiply DINT, REAL Exponent (x to the power of y) DINT, REAL Divide DINT, REAL...
  • Page 675: Use Relational Operators

    Structured Text Programming Appendix C The table shows some examples. Use this format Example For this situation Write value1 operator value2 If gain_4 and gain_4_adj are DINT tags and your gain_4_adj := gain_4+15; specification says: ‘Add 15 to gain_4 and store the result in gain_4_adj’"...
  • Page 676 Appendix C Structured Text Programming The table shows some examples. Use this format Example For this situation Write value1 operator value2 If temp is a DINT tag and your specification says: ‘If IF temp<100 THEN... temp is less than 100⋅ then…’ stringtag1 operator stringtag2 If bar_code and dest are string tags and your IF bar_code=dest THEN...
  • Page 677: Use Logical Operators

    Structured Text Programming Appendix C Use Logical Operators Logical operators let you check if multiple conditions are true or false. The result of a logical operation is a BOOL value. If the comparison is The result is True False Use these logical operators. Use this operator Data type Logical AND...
  • Page 678: Use Bitwise Operators

    Appendix C Structured Text Programming Use Bitwise Operators Bitwise operators manipulate the bits within a value based on two values. Use this operator Optimal data type Bitwise AND &, AND DINT Bitwise OR DINT Bitwise exclusive OR DINT Bitwise complement DINT This is an example.
  • Page 679: Instructions

    Structured Text Programming Appendix C Instructions Structured text statements can also be instructions. See the Locator Table page 29 for a list of the instructions available in structured text. A structured text instruction executes each time it is scanned. A structured text instruction within a construct executes every time the conditions of the construct are true.
  • Page 680: Constructs

    Appendix C Structured Text Programming Constructs Constructs can be programmed alone or nested within other constructs. If you want to Use this construct Available in these languages Page Do something if or when specific conditions occur IF...THEN Structured text Select what to do based on a numerical value CASE...OF Structured text Do something a specific number of times before...
  • Page 681: Structured Text

    Structured Text Programming Appendix C IF...THEN Use IF…THEN to do something if or when specific conditions occur. Operands: Structured Text IF bool_expression THEN Operand Type Format Enter ; Bool_ BOOL BOOL tag or expression that evaluates to a expression BOOL value (BOOL expression) expression END_IF;...
  • Page 682 Appendix C Structured Text Programming The table summarizes different combinations of IF, THEN, ELSIF, and ELSE. If you want to Use this construct Do something if or when conditions are Do nothing if conditions are false IF…THEN true Do something else if conditions are false IF…THEN…ELSE Choose from alternative statements (or Do nothing if conditions are false...
  • Page 683 Structured Text Programming Appendix C The [:=] tells the controller to clear light whenever the controller does the following: • Enters the RUN mode. • Leaves the step of an SFC if you configure the SFC for Automatic reset. (This applies only if you embed the assignment in the action of the step or use the action to call a structured text routine via a JSR instruction.) Example 3: IF…THEN…ELSIF...
  • Page 684: Case

    Appendix C Structured Text Programming CASE...OF Use CASE to select what to do based on a numerical value. Operands: Structured Text CASE numeric_expression OF Operand Type Format Enter selector1: statement; SINT Tag or expression that evaluates to a number Numeric_ (numeric expression) expression selectorN: statement;...
  • Page 685 Structured Text Programming Appendix C These are the syntax for entering the selector values. When selector is Enter One value value: statement Multiple, distinct values value1, value2, valueN : Use a comma (,) to separate each value. A range of values value1..valueN : ...
  • Page 686 Appendix C Structured Text Programming Example If you want this Enter this structured text If recipe number = 1 then CASE recipe_number OF Ingredient A outlet 1 = open (1) Ingredient B outlet 4 = open (1) Ingredient_A.Outlet_1 :=1; Ingredient_B.Outlet_4 :=1; If recipe number = 2 or 3 then 2,3: Ingredient_A.Outlet_4 :=1;...
  • Page 687: For

    Structured Text Programming Appendix C FOR…DO Use the FOR…DO loop to do something a specific number of times before doing anything else. Operands: Structured Text FOR count:= initial_value TO Operand Type Format Description final_value BY increment DO count SINT Tag to store count position as the FOR…DO ;...
  • Page 688 Appendix C Structured Text Programming Description: The syntax is described in the table. FOR count := initial_value TO final_value Optional BY increment If you don’t specify an increment, the loop increments by 1. ; Optional IF bool_expression THEN EXIT; If there are conditions when you want to exit the loop early, use other statements, such as an END_IF;...
  • Page 689 Structured Text Programming Appendix C Example 2: If you want this Enter this structured text A user-defined data type (structure) stores the following information SIZE(Inventory,0,Inventory_Items); about an item in your inventory: For position:=0 to Inventory_Items - 1 do ·Barcode ID of the item (string data type) ·Quantity in stock of the item (DINT data type) If Barcode = Inventory[position].ID then An array of the above structure contains an element for each...
  • Page 690: While

    Appendix C Structured Text Programming WHILE…DO Use the WHILE…DO loop to keep doing something as long as certain conditions are true. Operands: Structured Text WHILE bool_expression DO Operand Type Format Enter ; Bool_ BOOL BOOL tag or expression that evaluates to a expression BOOL value expression...
  • Page 691 Structured Text Programming Appendix C The following diagrams show how a WHILE...DO loop executes and how an EXIT statement leaves the loop early. False False BOOL expression BOOL expression True True Statement 1 Statement 1 Statement 2 Statement 2 Statement 3 Statement 3 Statement 4 Statement 4...
  • Page 692 Appendix C Structured Text Programming Example 2: If you want this Enter this structured text Move ASCII characters from a SINT array into a string tag. (In a SINT element_number := 0; array, each element holds one character.) Stop when you reach the SIZE(SINT_array, 0, SINT_array_size);...
  • Page 693: Repeat

    Structured Text Programming Appendix C REPEAT…UNTIL Use the REPEAT…UNTIL loop to keep doing something until conditions are true. Operands: Structured Text REPEAT Operand Type Format Enter ; bool_ BOOL BOOL tag or expression that evaluates to a expression BOOL value (BOOL expression) expression UNTIL bool_expression Make sure that you do not iterate within the loop too...
  • Page 694 Appendix C Structured Text Programming The following diagrams show how a REPEAT...UNTIL loop executes and how an EXIT statement leaves the loop early. Statement 1 Statement 1 Statement 2 Statement 2 Statement 3 Statement 3 Statement 4 statement 4 … …...
  • Page 695 Structured Text Programming Appendix C Example 2: If you want this Enter this structured text Move ASCII characters from a SINT array into a string tag. (In a SINT element_number := 0; array, each element holds one character.) Stop when you reach the SIZE(SINT_array, 0, SINT_array_size);...
  • Page 696: Comments

    Appendix C Structured Text Programming Comments To make your structured text easier to interpret, add comments to it. • Comments let you use plain language to describe how your structured text works. • Comments do not affect the execution of the structured text. The table describes how to add comments to your structured text.
  • Page 697: Rockwell Automation Publication 1756-Rm003N-En-P - October

    Structured Text Programming Appendix C Notes: Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 698 Appendix C Structured Text Programming Notes: Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 699 Index array subscript expressions 646 ABL instruction 578 ASCII ABS instruction 289 chars in buffer 581 absolute value 289 handshake lines 585 ACB instruction 581 instructions ABL 578 ACL instruction 583 ACS instruction 540 CONCAT 610 ADD instruction 266 delete 612 addition 266 DTOS 627 addressing...
  • Page 700 Index Boolean connection AND 331 cache 191 connector Exclusive OR 337 NOT 340 function block diagram 655 OR 334 construct BOR 334 structured text 680 break 489 control structure 350 BRK instruction 489 BSL instruction 402 BSR instruction 406 conversion instructions BTD instruction 303 DEG 558 BTDT instruction 306...
  • Page 701 Index document FBD_COUNTER structure 149 structured text 696 FBD_LIMIT structure 247 DTOS instruction 627 FBD_LOGICAL structure 316 DTR instruction 508 FBD_MASK_EQUAL structure 253 FBD_MASKED_MOVE structure 300 FBD_MATH structure 267 elements FBD_MATH_ADVANCED structure 283 size instruction 397 end of transition instruction 474 EOT instruction 474 FBD_ONESHOT structure 109 EQU instruction 226...
  • Page 702 Index LIFO unload 428 LIM instruction 246 icon 655 limit 246 if...then 681 LINT immediate data type 650 output instruction 216 LN instruction 546 immediate values 646 incremental mode 347 base 10 549 input instruction 549 reference 655 natural 546 wire connector 655 logical input/output instructions...
  • Page 703 Index instruction 172 pause SFC instruction 476 cache connection 191 error codes 165 instruction operands 156 alarms 517 programming guidelines 193 configuring 516 structure 156 deadband 526 MUL instruction 272 feedforward 527 multiplication 272 operands 511 MVM instruction 297 scaling 518 MVMT instruction 300 tuning 516 structure 512...
  • Page 704 Index scan delay introduction 621 lower case 633 function block diagram 660 RTOS 629 search STOD 623 mode 495 upper case 631 string 614 data type 576 sequencer evaluation in structured text 676 input 436 manipulation instructions SQI 436 CONCAT 610 load 444 delete 612 nstructions...
  • Page 705 Index task tuning 516 trigger event task 481 temporary end 465 timer instructions UID instruction 470 introduction 115 UIE instruction 470 RES 153 unresolved loop TOF 120 function block diagram 658 off delay 120 update output 216 structure 116 upper case 631 timing modes 661 instruction 631 TND instruction 465...
  • Page 706 Index Notes: Rockwell Automation Publication 1756-RM003N-EN-P - October 2011...
  • Page 708 Rockwell Automation Support Rockwell Automation provides technical information on the Web to assist you in using its products. At http://www.rockwellautomation.com/support/, you can find technical manuals, a knowledge base of FAQs, technical and application notes, sample code and links to software service packs, and a MySupport feature that you can customize to make the best use of these tools.

Table of Contents