You are on page 1of 319

Allen-Bradley

Logix5550 Controller
(Cat. No. 1756-L1)

Programming Manual

product icon

Preface

Using This Manual


Introduction
This document provides a programmer with details about each available instruction for a Logix5550 controller. You should already be familiar with how the Logix5550 controller stores and processes data. This manual provides this information for each instruction:
Category: Description Description: This section explains: Operands Operation the function of the instruction when to use the instruction any important interactions with other instructions

This section list and describes any operands you must specify when you enter the instruction. This section provides timing and memory information. This section also uses these symbols to indicate when the controller executes the instruction:
rung is true rung is false rung goes from false to true

Control status Example

This section lists and describes the control structure of the instruction, if any. Not all instructions use control structures. This section provides at least one programming example to demonstrate how to use the instruction.

The more complex instructions have multiple examples or more configuration information, as needed.

For More Information


Publication: Logix5550 Controller User Manual Publication Number: 1756-6.5.12

Logix5550 Controller Instruction Set Quick Reference 1756-6.5.11 Logix5550 Controller Quick Start Motion Control User Manual 1756-10.1 1756-x.xx

Publication 1756-6.4.1 review January 1998 - preliminary

ii

Using This Manual

Publication 1756-6.4.1 review January 1998 - preliminary

Table of Contents

Bit Instructions

Chapter 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1 I/O Tags in Data Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1 Rung Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1 Examine On (XIC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 Examine Off (XIO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4 Energize (OTE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6 Latch (OTL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8 Unlatch (OTU) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10 One Shot (ONS). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-12 One Shot Rising (OSR). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14 One Shot Falling (OSF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16

Timer and Counter Instructions

Chapter 2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1 Using Timers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1 Timer Accuracy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2 Timer On Delay (TON) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3 Pausing a TON instruction . . . . . . . . . . . . . . . . . . . . . . . . . 2-4 How controller mode can affect the TON instruction . . . . . 2-4 Timer Off Delay (TOF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-6 How controller mode can affect the TOF instruction. . . . . . 2-7 Retentive Timer On (RTO) . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9 How controller mode can affect the RTO instruction . . . . 2-10 Using Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12 Count Up (CTU) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-13 Count Down (CTD). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-16 Reset (RES). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-19

Publication 1756-6.4.1 review January 1998 - preliminary

tocii

Table of Contents

Input/Output Instructions

Chapter 3 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1 Message (MSG). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2 Selecting the Message Type . . . . . . . . . . . . . . . . . . . . . . . . . 3-8 Specifying CIP messages. . . . . . . . . . . . . . . . . . . . . . . . . 3-10 Specifying PLC-5 messages . . . . . . . . . . . . . . . . . . . . . . 3-10 Specifying SLC messages . . . . . . . . . . . . . . . . . . . . . . . . 3-11 Specifying block-transfer messages . . . . . . . . . . . . . . . . 3-11 Specifying PLC-3 messages . . . . . . . . . . . . . . . . . . . . . . 3-12 Specifying PLC-2 messages . . . . . . . . . . . . . . . . . . . . . . 3-12 Specifying the Communication Details. . . . . . . . . . . . . . . . . 3-13 Mapping addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13 MSG Programming Examples . . . . . . . . . . . . . . . . . . . . . . . 3-13 CIP communications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13 Ethernet communications . . . . . . . . . . . . . . . . . . . . . . . . 3-13 ControlNet communications. . . . . . . . . . . . . . . . . . . . . . . 3-13 Replacing PLC-5 block-transfer instructions . . . . . . . . . . 3-14 Get Status Value (GSV) and Set Status Value (SSV) . . . . . . . 3-15 Accessing the AXIS object . . . . . . . . . . . . . . . . . . . . . . . . 3-16 Accessing the CONTROLLER object . . . . . . . . . . . . . . . . . 3-16 Accessing the CONTROLLERDEVICE object . . . . . . . . . . . 3-17 Accessing the CST object . . . . . . . . . . . . . . . . . . . . . . . . 3-18 Accessing the DF1 object . . . . . . . . . . . . . . . . . . . . . . . . 3-18 Accessing the FAULTLOG object. . . . . . . . . . . . . . . . . . . . 3-20 Accessing the MESSAGE object . . . . . . . . . . . . . . . . . . . . 3-21 Accessing the MODULE object . . . . . . . . . . . . . . . . . . . . . 3-22 Accessing the MOTIONGROUP object . . . . . . . . . . . . . . . . 3-22 Accessing the PROGRAM object. . . . . . . . . . . . . . . . . . . . 3-22 Accessing the ROUTINE object. . . . . . . . . . . . . . . . . . . . . 3-23 Accessing the SERIALPORT object . . . . . . . . . . . . . . . . . . 3-24 Accessing the TASK object . . . . . . . . . . . . . . . . . . . . . . . 3-25 Accessing the WALLCLOCKTIME object . . . . . . . . . . . . . . 3-25 GSV/SSV Programming Example . . . . . . . . . . . . . . . . . . . . . 3-26 Getting fault information . . . . . . . . . . . . . . . . . . . . . . . . . 3-26 Setting enable and disable flags . . . . . . . . . . . . . . . . . . . 3-27

Publication 1756-6.4.1 review January 1998 - preliminary

Table of Contents

tociii

Compare Instructions

Chapter 4 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1 Using arithmetic status flags . . . . . . . . . . . . . . . . . . . . . . . 4-2 Compare (CMP). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3 Valid operations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3 Equal to (EQU) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-5 Greater than or Equal to (GEQ). . . . . . . . . . . . . . . . . . . . . . . . 4-6 Greater Than (GRT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7 Less Than or Equal to (LEQ). . . . . . . . . . . . . . . . . . . . . . . . . . 4-8 Less Than (LES) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9 Limit (LIM). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10 Mask Equal to (MEQ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12 Entering an immediate mask value . . . . . . . . . . . . . . . . . 4-13 Not Equal to (NEQ). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14

Compute/Math Instructions

Chapter 5 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-1 Using arithmetic status flags . . . . . . . . . . . . . . . . . . . . . . . 5-1 Compute (CPT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2 Valid operations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2 Determining the order of operation . . . . . . . . . . . . . . . . . . 5-2 Add (ADD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4 Subtract (SUB). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5 Multiply (MUL). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6 Divide (DIV) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7 Square Root (SQR). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-8 Negate (NEG). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-9

Arithmetic/Logic Instructions

Chapter 6 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1 Move (MOV) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2 Masked Move (MVM). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3 Bit Field Distribute (BTD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5 Clear (CLR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-7 Bitwise AND (AND) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-8 Bitwise OR (OR). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-10 Bitwise Exclusive OR (XOR) . . . . . . . . . . . . . . . . . . . . . . . . . 6-12 Bitwise NOT (NOT). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-14

Publication 1756-6.4.1 review January 1998 - preliminary

tociv

Table of Contents

File Concepts

Chapter 7 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-1 Manipulating Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2 Using the Control Structure . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4 Selecting Mode of Operation . . . . . . . . . . . . . . . . . . . . . . . . . 7-4 All mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-5 Numerical mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-6 Incremental mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7

File/Misc. Instructions

Chapter 8 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-1 Using the File/Misc. Instructions . . . . . . . . . . . . . . . . . . . . . . 8-2 Using arithmetic status flags . . . . . . . . . . . . . . . . . . . . . . . 8-2 Specifying dimensions within an array. . . . . . . . . . . . . . . . 8-3 File Arithmetic and Logic (FAL) . . . . . . . . . . . . . . . . . . . . . . . 8-4 Valid operations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4 File Search and Compare (FSC) . . . . . . . . . . . . . . . . . . . . . . . 8-7 File Copy (COP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-10 File Fill (FLL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-12 File Average (AVE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-13 File Sort (SRT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-15 File Standard Deviation (STD) . . . . . . . . . . . . . . . . . . . . . . . 8-17

File/Shift Instructions

Chapter 9 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-1 Using the File/Shift Instructions . . . . . . . . . . . . . . . . . . . . . . . 9-2 Bit Shift Left (BSL). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3 Bit Shift Right (BSR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-5 FIFO Load (FFL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-7 FIFO Unload (FFU) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-9 LIFO Load (LFL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-11 LIFO Unload (LFU) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-13

Sequencer Instructions

Chapter 10 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-1 Using the Sequencer Instructions . . . . . . . . . . . . . . . . . . . . 10-2 Sequencer Input (SQI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-3 Sequencer Output (SQO) . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-5 Sequencer Load (SQL). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-7

Publication 1756-6.4.1 review January 1998 - preliminary

Table of Contents

tocv

Program Control Instructions

Chapter 11 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-1 Jump to Label (JMP), Label (LBL) . . . . . . . . . . . . . . . . . . . . 11-2 Jump to Subroutine (JSR), Subroutine (SBR), Return (RET) . 11-4 Temporary End (TND) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-6 Master Reset Control (MCR) . . . . . . . . . . . . . . . . . . . . . . . . 11-7 User Interrupt Disable (UID) . . . . . . . . . . . . . . . . . . . . . . . . . 11-9 User Interrupt Enable (UIE). . . . . . . . . . . . . . . . . . . . . . . . . 11-10 Always False Instruction (AFI) . . . . . . . . . . . . . . . . . . . . . . 11-11 No Operation (NOP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-12

For/Next Instructions

Chapter 12 For/Break Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-1 For (FOR). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-2 Break (BRK). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-4

Special Instructions

Chapter 13 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-1 Using the Diagnostic Instructions. . . . . . . . . . . . . . . . . . . . . 13-2 File Bit Comparison (FBC) . . . . . . . . . . . . . . . . . . . . . . . . . . 13-3 Diagnostic Detect (DDT) . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-6 Data Transitional (DTR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-9 Using PID Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-11 Integral term implementation. . . . . . . . . . . . . . . . . . . . . 13-13 Derivative term . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-14 Setting the deadband . . . . . . . . . . . . . . . . . . . . . . . . . . 13-14 Using zero-crossing. . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-15 Setting output alarms . . . . . . . . . . . . . . . . . . . . . . . . . . 13-15 Using output limiting . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-15 Using manual mode (with bumpless transfer) . . . . . . . . 13-16 Feedforward or output biasing . . . . . . . . . . . . . . . . . . . . 13-16 Proportional Derivative Integral (PID) . . . . . . . . . . . . . . . . . 13-17 Configuring a PID Instruction . . . . . . . . . . . . . . . . . . . . . . . 13-20 PID Programming Examples . . . . . . . . . . . . . . . . . . . . . . . 13-22 Programming Considerations. . . . . . . . . . . . . . . . . . . . . 13-22 Placing the PID instruction in the main routine. . . . . . . . 13-23 Placing the PID instruction in an RTS routine . . . . . . . . . 13-24 Simulating a manual control station. . . . . . . . . . . . . . . . 13-24 Cascading loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-25 Controlling a ratio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13-26 Tracking the process variable . . . . . . . . . . . . . . . . . . . . 13-27

Publication 1756-6.4.1 review January 1998 - preliminary

tocvi

Table of Contents

Trigonometric Instructions

Chapter 14 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-1 Using arithmetic status flags . . . . . . . . . . . . . . . . . . . . . . 14-1 Sine (SIN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-2 Cosine (COS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-3 Tangent (TAN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-4 Arc Sine (ASN). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-5 Arc Cosine (ACS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-6 Arc Tangent (ATN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-7

Advanced Math Instructions

Chapter 15 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-1 Using arithmetic status flags . . . . . . . . . . . . . . . . . . . . . . 15-1 Natural Log (LN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-2 Log Base 10 (LOG) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15-3 X to the Power of Y (XPY). . . . . . . . . . . . . . . . . . . . . . . . . . . 15-4

Math Conversion Instructions

Chapter 16 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-1 Using arithmetic status flags . . . . . . . . . . . . . . . . . . . . . . 16-1 Degrees (DEG). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-2 Radians (RAD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-3 Convert to BCD (TOD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-4 Convert to Integer (FRD) . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-5

Motion Concepts

Chapter 17 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17-1 Identifying the Components of the ControlLogix Motion System17-2 The Logix5550 Controller (1756-L1) . . . . . . . . . . . . . . . . 17-2 The Analog/Encoder Servo Module (1756-MO2AE) . . . . . 17-2 RSLogix5000 Programming Software . . . . . . . . . . . . . . . 17-2 Developing a Motion Control Application Program . . . . . . . . 17-3 Adding a motion module . . . . . . . . . . . . . . . . . . . . . . . . . 17-3 Identifying and configuring each axis. . . . . . . . . . . . . . . . 17-3 Writing a motion application program . . . . . . . . . . . . . . . 17-4 Understanding Instruction Timing . . . . . . . . . . . . . . . . . . . . 17-5 Immediate type instructions . . . . . . . . . . . . . . . . . . . . . . 17-5 Delayed (message) type instructions . . . . . . . . . . . . . . . . 17-6 Process type instructions. . . . . . . . . . . . . . . . . . . . . . . . . 17-7 Using the Control Structure . . . . . . . . . . . . . . . . . . . . . . . . 17-10 Using Motion Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . 17-12

Publication 1756-6.4.1 review January 1998 - preliminary

Table of Contents

tocvii

Motion Conversion Instructions

Chapter 18 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-1 Motion Servo On (MSO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-3 Motion Servo Off (MSF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18-5 Motion Axis Shutdown (MASD) . . . . . . . . . . . . . . . . . . . . . . 18-7 Motion Axis Shutdown Reset (MASR). . . . . . . . . . . . . . . . . 18-10 Motion Direct Drive On (MDO) . . . . . . . . . . . . . . . . . . . . . . 18-12 Motion Direct Drive Off (MDF) . . . . . . . . . . . . . . . . . . . . . . 18-14 Motion Axis Fault Reset (MAFR). . . . . . . . . . . . . . . . . . . . . 18-16

Motion Move Instructions

Chapter 19 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19-1 Motion Axis Stop (MAS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19-2 Motion Axis Home (MAH). . . . . . . . . . . . . . . . . . . . . . . . . . . 19-5 Motion Axis Jog (MAJ). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19-8 Motion Axis Move (MAM). . . . . . . . . . . . . . . . . . . . . . . . . . 19-11 Motion Axis Gearing (MAG) . . . . . . . . . . . . . . . . . . . . . . . . 19-15 Motion Change Dynamics (MCD) . . . . . . . . . . . . . . . . . . . . 19-18 Motion Redefine Position (MRP). . . . . . . . . . . . . . . . . . . . . 19-21

Motion Group Instructions

Chapter 20 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20-1 Motion Group Stop (MGS) . . . . . . . . . . . . . . . . . . . . . . . . . . 20-2 Motion Group Program Stop (MGPS) . . . . . . . . . . . . . . . . . . 20-4 Motion Group Shutdown (MGSD) . . . . . . . . . . . . . . . . . . . . . 20-6 Motion Group Shutdown Reset (MGSR) . . . . . . . . . . . . . . . . 20-8 Motion Group Strobe Position (MGSP) . . . . . . . . . . . . . . . . 20-10

Motion Event Instructions

Chapter 21 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21-1 Motion Arm Watch (MAW) . . . . . . . . . . . . . . . . . . . . . . . . . . 21-2 Motion Disarm Watch (MDW). . . . . . . . . . . . . . . . . . . . . . . . 21-4 Motion Arm Registration (MAR) . . . . . . . . . . . . . . . . . . . . . . 21-6 Motion Disarm Registration (MDR). . . . . . . . . . . . . . . . . . . . 21-9 Chapter 22 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22-1 Motion Apply Axis Tuning (MAAT) . . . . . . . . . . . . . . . . . . . . 22-2 Motion Run Axis Tuning (MRAT). . . . . . . . . . . . . . . . . . . . . . 22-4 Motion Apply Hookup Diagnostics (MAHD). . . . . . . . . . . . . . 22-7 Motion Run Hookup Diagnostics (MRHD) . . . . . . . . . . . . . . . 22-9

Motion Configuration Instructions

Publication 1756-6.4.1 review January 1998 - preliminary

tocviii

Table of Contents

Notes:

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

Bit Instructions
(XIC, XIO, OTE, OTL, OTU, ONS, OSR, OSF)
Introduction
Use the bit (relay-type) instructions to monitor and control the status of bits, such as input bits or timer control-word bits.
If you want to: examine a bit for an ON condition examine a bit for an OFF condition hold a bit ON or OFF (non-retentive) latch a bit to ON (retentive) unlatch a bit to OFF (retentive) make a rung true for one program scan upon a false-to-true transition of the conditions preceding the ONS instruction on the rung trigger an event based on the change of state of the rung from true to false trigger an event based on the change of state of the rung from false to true Use this instruction: XIC XIO OTE OTL OTU ONS See page: 1-2 1-4 1-6 1-8 1-10 1-12

OSR OSF

1-14 1-16

I/O Tags in Data Storage

The input tags in the controller store the status of input sensors connected to input module terminals.
If the input sensor is: closed (on) open (off) then its corresponding input image bit is: on (1) off (0)

The output tags control the status of actuators wired to output module terminals.
If the output image bits is: on (1) off (0) then its corresponding output is: energized (on) de-energized (off)

Rung Logic

As each conditioning instruction is executed, the specified bit is examined to see if it matches a certain condition (on or off). If a complete path of true conditions examined for are found, the rung is set to true. The rung must contain a continuous path of true instructions from the start of the rung (far left) to the output instruction for the output to be enabled.

Publication 1756-6.4.1 review January 1998 - preliminary

1-2

Bit Instructions

Examine On (XIC)
Description: When a device closes its circuit, the module whose input terminal is wired to the device detects the closed circuit. This is the ON state. When the controller executes an XIC instruction with a tag that represents an input terminal, the controller determines whether the device is ON (closed). If the controller finds an ON state, the controller sets the XIC instruction to true. If the controller finds an OFF state, the controller sets the XIC instruction to false. If the XIC instruction is the only conditioning instruction on the rung, the controller enables the output instruction when the XIC instruction is true (input closed). The controller disables the output instruction when the XIC instruction is false. The XIC instruction is true or false depending on whether the controller finds an ON condition at the referenced bit.
If the rung is: true and the bit is: on off false on off the rung status changes to: false true false false

You can also use the XIC instruction to access the state of controller keywords. Enter the keyword in place of the tag.
Keyword: S:PRE S:POST S:FS S:N S:Z S:V S:C S:MINOR Description: The controller is pre-scanning rungs. The controller is post-scanning rungs. This is the first normal scan of the routines in this program. The result of an operation is negative. The result of an operation is zero. The result of an operation is an overflow. The result of an operation is a carry. At least one minor fault has been generated.

Publication 1756-6.4.1 review January 1998 - preliminary

Bit Instructions

1-3

Operands:
Operand: Source bit Valid Types: tag BOOL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true 0.13 na false 0.12 na

XIC Example:

If the controller finds an ON condition at the bit that corresponds to limit_switch_1, the instruction is true.

Publication 1756-6.4.1 review January 1998 - preliminary

1-4

Bit Instructions

Examine Off (XIO)


Description: When a device opens its circuit, the module whose input terminal is wired to the device detects an open circuit. This is the OFF state. When the controller finds an XIO instruction with a tag that represents an input terminal, the controller determines whether the device is OFF (open). If the controller finds an OFF state, the controller sets the XIO instruction to true. If the controller finds an ON state, the controller sets the XIO instruction to false. If the XIO instruction is the only conditioning instruction on the rung, the controller enables the output instruction when the XIO instruction is true (input open). The controller disables the output instructions when the XIO instruction is false. The XIO instruction is true or false depending on whether the controller finds an OFF or ON condition at the referenced bit.
If the rung is: true and the bit is: on off false on off the rung status changes to: true false false false

You can also use the XIO instruction to access the state of controller keywords. Enter the keyword in place of the tag.
Keyword: S:PRE S:POST S:FS S:N S:Z S:V S:C S:MINOR Description: The controller is pre-scanning rungs. The controller is post-scanning rungs. This is the first normal scan of the routines in this program. The result of an operation is negative. The result of an operation is zero. The result of an operation is an overflow. The result of an operation is a carry. At least one minor fault has been generated.

Publication 1756-6.4.1 review January 1998 - preliminary

Bit Instructions

1-5

Operands:
Operand: Source bit Valid Types: tag BOOL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 0.13 na na
executes does not execute executes

false 0.11 na

XIO Example:

If the controller finds an OFF condition at the bit that corresponds to limit_switch_2 , the instruction is true.

Publication 1756-6.4.1 review January 1998 - preliminary

1-6

Bit Instructions

Energize (OTE)
Description: Use the OTE instruction to control a bit. If the bit corresponds to an output module terminal, the device wired to this terminal is energized when the instruction is enabled. The device is de-energized when the instruction is disabled. If the output conditions that precede the OTE instruction are true, the controller enables the OTE instruction. If the output conditions that preceded the OTE instruction are false, the controller disables the OTE instructions. When rung conditions become false, the corresponding device de-energizes. An OTE instruction is similar to a relay coil. The OTE instruction is controlled by preceding input instructions; the relay coil is controlled by contacts in its hard-wired rung. The OTE instruction tells the controller how to control the referenced bit based on the rung condition.
If the rung is: true false the controller turns the bit: on (1) off (0)

Operands:
Operand: Destination bit Valid Types: tag BOOL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 0.19 na na
executes does not execute executes

false 0.19 na

Publication 1756-6.4.1 review January 1998 - preliminary

Bit Instructions

1-7

OTE Example:

If the rung is true (all preceding input instructions are true), the controllers turns ON the bit that corresponds to light_1. If the rung is not true (one or more of the preceding instructions is false), the controller turns OFF the bit.

Publication 1756-6.4.1 review January 1998 - preliminary

1-8

Bit Instructions

Latch (OTL)
Description: The OTL instruction is a retentive output instruction that can only turn on a bit (in cannot turn off a bit). This instruction is usually used with an OTU (unlatch) instruction, with both instructions referencing the same bit. When you assign a tag to an OTL instruction that corresponds to a terminal of an output module, the input device wired to this terminal is energized when the controller sets (enables) the bit. If the input conditions that precede the OTL instruction are true, the controller enables the OTL instruction. When rung conditions become false (after being true), the bit remains set and the corresponding output device remains energized. Use the OTU instruction to turn off the bit you latched on with the OTL instruction. When enabled, the OTL instruction tells the controller to turn on the referenced bit. Thereafter, the bit remains on, regardless of the rung condition, until the bit is turned off, typically by an unlatch (OTU) instruction in another rung.
If the rung is: true false the controller turns the bit: on (1) no change

Operands:
Operand: Destination bit Valid Types: tag BOOL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 0.20 na na
executes does not execute executes

false 0.13 na

Publication 1756-6.4.1 review January 1998 - preliminary

Bit Instructions

1-9

OTL Example:

If the rung is true (all preceding input instructions are true), the controllers turns ON the bit that corresponds to light_2. This bit remains ON until it is reset by an OTU instruction.

Publication 1756-6.4.1 review January 1998 - preliminary

1-10

Bit Instructions

Unlatch (OTU)
Description: The OTU instruction is a retentive output instruction that can only turn off a bit (it cannot turn on a bit). This instruction is usually used with an OTL (latch) instruction, with both instructions referencing the same bit. The OTU instruction turns off the bit, which was turned on (latched) by the OTL instruction. When the controller changes from Run to Program mode or when the controller loses power (and there is battery backup), the bit remains in the state set by the last rung of the latch/unlatch pair that was true. The OTU instruction tells the controller to turn off the referenced bit based on the rung condition. Thereafter, the bit remains off, regardless of the rung condition, until it is turned on, typically by an OTL instruction in another rung.
If the rung is: true false the controller turns the bit: off (0) no change

Operands:
Operand: Destination bit Valid Types: tag BOOL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 0.20 na na
executes does not execute executes

false 0.11 na

Publication 1756-6.4.1 review January 1998 - preliminary

Bit Instructions

1-11

OTU Example:

If the rung is true (all preceding input instructions are true), the controllers turns OFF the bit that corresponds to light_2.

Publication 1756-6.4.1 review January 1998 - preliminary

1-12

Bit Instructions

One Shot (ONS)


Description: The ONS instruction is an input instruction that makes the rung true for one program scan upon a false-to-true transition of the conditions preceding the ONS instruction on the rung. Use the ONS instruction to start events that are triggered by a pushbutton, such as pulling values from thumbwheel switches or freezing rapidly displayed LED values. You must enter a tag for the bit. Dedicate a unique bit to each ONS instruction. ATTENTION: You can program an output tag for the ONS instruction, but be aware that on-line programming with this instruction can be dangerous because the output might turn on immediately when the rung is scanned. Set the bit tag to 1 before entering the instruction. Then the rung must go from false to true before energizing the output.

During prescan, the bit tag is set to prevent false triggering when the program scan begins. Operands:
Operand: Source bit Valid Types: tag BOOL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true na na
does not execute does not execute executes

false na

Publication 1756-6.4.1 review January 1998 - preliminary

Bit Instructions

1-13

ONS Example:

The ONS instruction makes the rung true for one scan upon a false-to-true transition of any preceding instructions.

Publication 1756-6.4.1 review January 1998 - preliminary

1-14

Bit Instructions

One Shot Rising (OSR)


Description: The OSR instruction is an output instruction that triggers an event to occur one time.
This bit: output bit (.OB) Changes state as follows: Is set for one program scan when the rung goes from false to true. During prescan, this bit is cleared to prevent false triggering when the program scan begins. storage bit (.SB) Follows the rung status. During prescan, this bit is cleared to prevent false triggering when the programs can begins.

one program scan input rung

storage bit

output bit
40048

Use the OSR instruction whenever an event must start based on the change of state of the rung from false to true, not continuously when the rung is true. You must enter a bit tag for the output bit and the storage bit. Operands:
Operand: Storage bit the tag where you want to store the storage bit status tag BOOL Output bit the tag where you want to store the output bit status Valid Types: tag BOOL

Publication 1756-6.4.1 review January 1998 - preliminary

Bit Instructions

1-15

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true na na
does not execute does not execute executes

false na

OSR Example:

When the rung goes from false to true, the controller turns ON the bit that corresponds to output_bit_1 for one scan. The status of the bit that corresponds to storage_bit_1 reflects the current rung status.

Publication 1756-6.4.1 review January 1998 - preliminary

1-16

Bit Instructions

One Shot Falling (OSF)


Description: The OSF instruction is an output instruction that triggers an event to occur one time when the rung goes from true to false.
This bit: output bit (.OB) Changes state as follows: Is set for one program scan when the rung goes from false to true. During prescan, this bit is cleared to prevent false triggering when the program scan begins. storage bit (.SB) Follows the rung status. During prescan, this bit is cleared to prevent false triggering when the programs can begins.

one program scan input rung

storage bit

output bit
40048

Use the OSF instruction whenever an event must start based on the change of state of the rung from true to false, not on the resulting rung status. You must enter a bit tag for the output bit and the storage bit. Operands:
Operand: Storage bit the tag where you want to store the storage bit status Output bit the tag where you want to store the output bit status tag BOOL Valid Types: tag BOOL

Publication 1756-6.4.1 review January 1998 - preliminary

Bit Instructions

1-17

Operation:

\
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true na na
does not execute does not execute executes

false na

OSF Example:

When the rung goes from true to false, the controller turns ON the bit that corresponds to output_bit_2 for one scan. The status of the bit that corresponds to storage_bit_2 reflects the current rung status.

Publication 1756-6.4.1 review January 1998 - preliminary

1-18

Bit Instructions

Notes:

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

Timer and Counter Instructions


(TON, TOF, RTO, CTU, CTD, RES)
Introduction
Timers and counters control operations based on time or the number of events.
If you want to: delay turning on an output delay turning off an output time an event retentively count up count down reset a timer or counter Use this instruction: TON TOF RTO CTU CTD RES See page: 2-3 2-6 2-9 2-13 2-16 2-19

Using Timers

The controller stores timer status bits and the preset and accumulated values in a TIMER structure. Not all timer instruction use the entire TIMER structure. See each instruction for the portion it uses.
TIMER structure
bit number

31 30 29 28 27 26 25
EN TT DN FS LS OV ER

16 15

preset value (.PRE) accumulated value (.ACC)

Control bit or word: .EN bit .TT bit .DN bit .FS bit .LS bit .OV bit .ER bit .PRE word .ACC word

Description: The enable bit indicates the timer is enabled. The timing bit indicates that a timing operation is in process The done bit indicates that a timing operation is complete. not used not used not used not used The preset value specifies the value which the timer must reach before the controller sets the .DN bit. The accumulated value specifies the number of increments the instruction has counted. When enabled, the timer updates this value continually. Typically, enter zero. If you enter a value, the instruction starts counting time base intervals from that value. If the timer is reset, the .ACC value is zero.

Publication 1756-6.4.1 review January 1998 - preliminary

2-2

Timer and Counter Instructions

To access timer control bits, the preset value, or the accumulated value, use the tag mnemonic. For example, timer1.pre accesses the preset value for the tag timer1.

Timer Accuracy
The time base is 1 msec for all timers. Timer accuracy depends on the controller clock tolerance, which is + 0.02%. A timer could time out early or late by 1 msec. The displayed accumulated value of a timer shows the actual time, but it is dependent on the CRT update time. The accumulated value might appear to be less than the preset when the .DN bit is set.

Publication 1756-6.4.1 review January 1998 - preliminary

Timer and Counter Instructions

2-3

Timer On Delay (TON)


Description: Use the TON instruction to turn an output on or off after the timer has been on for a preset time interval. The TON instruction starts accumulating time when the rung goes true, and continues until one of the following happens: the rung goes false the accumulated value is equal to the preset value (.ACC=.PRE) a RES instruction resets the timer the controller resets the accumulated value when the rung conditions go false, regardless of whether the timer completed or not

rung condition

timer enable bit (.EN)

timer timing bit (.TT)

timer done bit (.DN) output device (controlled by .DN bit)


ON delay

timer accumulated value (.ACC) preset 0


16649

Operands:
Operand: Timer Preset Accum Valid Types: tag TIMER immediate (0-2147483647) immediate (0-2147483647)

Publication 1756-6.4.1 review January 1998 - preliminary

2-4

Timer and Counter Instructions

Control status:
Control bit or word: .EN bit Description: The enable bit is set when the rung goes true. It is reset when: .TT bit the rung goes false a RES instruction resets the timer

The timing bit is set when the rung goes true. It is reset when: the rung goes false the .DN bit is set (.ACC=.PRE) a RES instruction resets the timer

.DN bit

The done bit is set when the accumulated value is equal to the preset value (.ACC=.PRE). It is reset when: the rung goes false a RES instruction resets the timer

.PRE word .ACC word

The preset value specifies the value which the timer must reach before the controller sets the .DN bit. The accumulated value specifies the number of increments the instruction has counted. When enabled, the timer updates this value continually. Typically, enter zero. If you enter a value, the instruction starts counting time base intervals from that value. If the timer is reset, the .ACC value is zero.

Pausing a TON instruction


If you set the .DN bit using an OTE instruction you can pause the timer. The .EN and .TT bits remain set, but the .ACC value does not increment. Timing resumes when you clear the .DN bit. If the rung goes false while the timer is paused, the timer resets as normal.

How controller mode can affect the TON instruction


If you change to Program mode, or the controller loses power, before the timer reaches the .PRE value, the following occurs: .EN bit remains set .TT bit remains set .ACC value remains the same

Publication 1756-6.4.1 review January 1998 - preliminary

Timer and Counter Instructions

2-5

Then when you switch back to Run or Test mode, or power is restored, the following occurs:
Condition: If the rung is true Result: .EN bit remains set .TT bit remains set .DN bit remains reset .ACC value is reset and starts incrementing If the rung is false .EN bit is reset .TT bit is reset .DN bit is reset .ACC value is reset

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
does not execute does not execute executes

Description: true false

TON Example:

When limit_switch_1 is set, the controller starts timer_1. The accumulated value increments as long as the rung remains true. The bit that corresponds to timer_1.tt is set and light_2 is energized while the timer is timing. When the timer is finished (.ACC=.PRE), timer_1.tt is reset, light_2 is de-energized, and timer_1.dn is set. When .ACC=.PRE or when the rung conditions go false, the timer is reset.

Publication 1756-6.4.1 review January 1998 - preliminary

2-6

Timer and Counter Instructions

Timer Off Delay (TOF)


Description: Use the TOF instruction to turn an output on or off after its rung has been false for a preset time interval. The TOF instruction starts accumulating time when the rung goes false and continues timing until one of the following occurs: the rung goes true the accumulated value is equal to the preset value a RES instruction resets the timer
rung condition

timer enable bit (.EN)

timer timing bit (.TT) timer done bit (.DN)

output device (controlled by .DN bit)


OFF delay

preset

timer accumulated value (.ACC)

16650

Operands:
Operand: Timer Preset Accum Valid Types: tag TIMER immediate (0-2147483647) immediate (0-2147483647)

Publication 1756-6.4.1 review January 1998 - preliminary

Timer and Counter Instructions

2-7

Control status:
Control bit or word: .EN bit Description: The enable bit is set when the rung goes true. It is reset when: .TT bit the rung goes false a RES instruction resets the timer

The timing bit is set when the rung goes false and .ACC<.PRE. It is reset when: the rung goes true the .DN bit is set (.ACC=.PRE) a RES instruction resets the timer

.DN bit

The done bit is set when the rung goes true. It is reset when: .ACC=.PRE the rung goes false a RES instruction resets the timer

.PRE word .ACC word

The preset value specifies the value which the timer must reach before the controller sets the .DN bit. The accumulated value specifies the number of increments the instruction has counted. When enabled, the timer updates this value continually. Typically, enter zero. If you enter a value, the instruction starts counting time base intervals from that value. If the timer is reset, the .ACC value is zero.

How controller mode can affect the TOF instruction


If you change to Program mode, the controller loses power, or a fault interrupts the timer, before the timer reaches the .PRE value, the following occurs: .EN bit remains set .TT bit remains set .DN bit remains set .ACC value remains the same

Then when you switch back to Run or Test mode, or power is restored, the following occurs:
Condition: If the rung is true Result: .EN bit is set .TT bit is reset .DN bit remains reset .ACC value is reset If the rung is false .EN bit is reset .TT bit is reset .DN bit is reset .ACC=.PRE

Publication 1756-6.4.1 review January 1998 - preliminary

2-8

Timer and Counter Instructions

ATTENTION: Because the RES instruction resets the .ACC value, .DN bit, and .TT bit, do not use the RES instruction to reset a TOF timer.

During prescan: ATTENTION: Because the RES instruction resets the .ACC value, .DN bit, and .TT bit, do not use the RES instruction to reset a TOF timer.

!
Operation:
Characteristic: Timing (in s)

.TT bit is reset .ACC value is set equal to the .PRE value

Description: true DINT REAL false

Memory (words) Execution

DINT REAL
does not execute does not execute executes

TOF Example:

When limit_switch_2 is reset, the controller starts timer_2. The accumulated value increments as long as the rung remains false. The bit that corresponds to timer_2.tt is set and light_2 is energized while the timer is timing. When the timer is finished (.ACC=.PRE), timer_2.tt is reset, light_2 is de-energized, and timer_2.dn is set. When .ACC=.PRE or when the rung conditions go true, the timer is reset.

Publication 1756-6.4.1 review January 1998 - preliminary

Timer and Counter Instructions

2-9

Retentive Timer On (RTO)


Description: Use the RTO instruction to turn an output on or off after its timer has been on for a preset time interval. The RTO instruction lets the timer stop and start without resetting the accumulated value. The RTO instruction begins timing when its rung goes true. As long as the rung remains true, the timer updates the .ACC value each program scan, until it reaches the .PRE Value. The RTO instruction retains its .ACC value even if one of the following occurs: the rung goes false you change to Program mode the controller faults or loses power

rung condition

timer enable bit (.EN) reset pulse timer timing bit (.TT)

timer done bit (.DN) output device (controlled by .DN bit) preset

timer accumulated value (.ACC) 0


16651

When the controller resumes operation or the rung goes true, timing continues from the retained .ACC value. By retaining the .ACC value, retentive timers measure the cumulative period during which the rung is true. To reset the retentive timers .ACC value and status bits after the RTO rung goes false, use the RES instruction. Operands:
Operand: Timer Preset Accum Valid Types: tag TIMER immediate (0-2147483647) immediate (0-2147483647)

Publication 1756-6.4.1 review January 1998 - preliminary

2-10

Timer and Counter Instructions

Control status:
Control bit or word: .EN bit Description: The enable bit is set when the rung goes true. It is reset when: .DN bit the rung goes false a RES instruction resets the timer

The done bit is set when .ACC=.PRE. It is reset when: the rung goes false a RES instruction resets the timer

.PRE word .ACC word

The preset value specifies the value which the timer must reach before the controller sets the .DN bit. The accumulated value specifies the number of increments the instruction has counted. When enabled, the timer updates this value continually. Typically, enter zero. If you enter a value, the instruction starts counting time base intervals from that value. If the timer is reset, the .ACC value is zero.

How controller mode can affect the RTO instruction


If you change to Program mode, the controller loses power, or a fault interrupts the timer, before the timer reaches the .PRE value, the following occurs: .EN bit remains set .ACC value remains the same

Then when you switch back to Run or Test mode, or power is restored, the following occurs:
Condition: If the rung is true Result: .EN bit remains set .TT bit remains reset .ACC value continues incrementing If the rung is false .EN bit is reset .TT bit is reset .DN bit is reset .ACC value remains the same

Publication 1756-6.4.1 review January 1998 - preliminary

Timer and Counter Instructions

2-11

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
does not execute does not execute executes

Description: true false

RTO Example:

When limit_switch_1 is set, the controller starts incrementing the accumulated value of timer_3. The timer values remain when limit_switch_1 goes false.

Publication 1756-6.4.1 review January 1998 - preliminary

2-12

Timer and Counter Instructions

Using Counters

The controller stores controller status bits and the preset and accumulated values in a COUNTER structure. Not all counter instruction use the entire COUNTER structure. See each instruction for the portion it uses.
COUNTER structure
bit number 31 30 29 28 27 CU CD DN OV UN 16 15 0

preset value (.PRE) accumulated value (.ACC)

Control bit or word: .CU bit .CD bit .DN bit .OV bit

Description: The count up enable bit indicates that the instruction has increased its count. This status bit is only used by the CTU instruction. The count down enable bit indicates that the instruction has decreased its count. This status bit is only used by the CTD instruction. The done bit indicates that a counting operation is complete. The overflow bit indicates that the counter exceeded the upper limit of 2147483648 and began counting up again from -2147483648. This status bit is only used by the CTU instruction. The underflow bit indicates that the counter exceeded the lower limit of -2147483648 and began counting down again from 2147483648. This status bit is only used by the CTD instruction. The preset value specifies the value which the timer must reach before the controller sets the .DN bit. The accumulated value specifies the number of increments the instruction has counted. When enabled, the timer updates this value continually. Typically, enter zero. If you enter a value, the instruction increments or decrements from that value. If the timer is reset, the .ACC value is zero.

.UN bit

.PRE word .ACC word

To access counter control bits, the preset value, or the accumulated value, use the tag mnemonic. For example, counter1.pre accesses the preset value for the tag counter1.

Publication 1756-6.4.1 review January 1998 - preliminary

Timer and Counter Instructions

2-13

Count Up (CTU)
Description: The CTU instruction counts upward over a range of -214748368 to +214748367. Each time the rung goes from false to true, the CTU instruction increments the .ACC value by one count. When the .ACC value equals or exceeds the preset value, the CTU instruction sets the done .(DN) bit, which your program can use to initiate some action, such as controlling a storage bit or an output device. The .ACC value is retentive. The count is retained until it is reset by a RES instruction.
rung condition that controls CTU

count-up enable bit (.EN)

rung condition that controls RES

count-up done bit (.DN) output device (controlled by .DN bit) preset

counter accumulated value (.ACC) accumulated


16636

Operands:
Operand: Counter Preset Accum Valid Types: tag COUNTER immediate (-214748368 to +214748367) immediate (-214748368 to +214748367)

Publication 1756-6.4.1 review January 1998 - preliminary

2-14

Timer and Counter Instructions

Control status:
Control bit or word: .CU bit Description: The count up bit is set when the rung goes true. It is reset when the rung goes false a RES instruction resets the counter

During prescan, this bit is set to prevent a false count when the program scan begins. .DN bit The done bit is set when .ACC.PRE. It is reset when: .OV bit .ACC<.PRE a RES instruction resets the counter combining CTU and CTD instructions and counting back up past the .PRE value

The overflow bit is set when the counter exceeds the upper limit of 2147483647. It is reset when: a RES instruction resets the counter counting back down to 2147483647 with a CTD instruction that uses the same tag as the CTU instruction

.PRE word .ACC word

The preset value specifies the value which the counter must reach before the controller sets the .DN bit. The accumulated value specifies the number of increments the instruction has counted. When enabled, the counter updates this value continually. Typically, enter zero. If you enter a value, the instruction increments from that value. If the counter is reset, the .ACC value is zero.

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
does not execute does not execute executes

Description: true false

Publication 1756-6.4.1 review January 1998 - preliminary

Timer and Counter Instructions

2-15

CTU Example:

Each time limit_switch_1 goes from false to true, the controller increments the counter_1 by 1. When the accumulated value the preset value, the controller sets counter_1.dn. The controller sets counter_1.ov if the accumulated value exceeds 2147483647.

Publication 1756-6.4.1 review January 1998 - preliminary

2-16

Timer and Counter Instructions

Count Down (CTD)


Description: The CTD instruction counts downward over a range of 2147483647 to -2147483648. Each time the rung goes from false to true, the CTD instruction decrements the .ACC value by one count. The .DN bit is set as long as the .ACC value is greater than or equal to the .PRE value. When the .ACC value is less than the .PRE value, the .DN bit is reset, which your program can use to initiate some action, such as controlling a storage bit or an output device. The .ACC value is retentive. The count is retained until it is reset by a RES instruction.
rung condition that controls CTU

count-down enable bit (.EN)

rung condition that controls RES

count-down done bit (.DN)

output device (controlled by .DN bit)

counter accumulated value (.ACC) preset


16637

Operands:
Operand: Counter Preset Accum Valid Types: tag COUNTER immediate (-214748368 to +214748367) immediate (-214748368 to +214748367)

Publication 1756-6.4.1 review January 1998 - preliminary

Timer and Counter Instructions

2-17

Control status:
Control bit or word: .CD bit Description: The count down bit is set when the rung goes true. It is reset when the rung goes false a RES instruction resets the counter

During prescan, this bit is set to prevent a false count when the program scan begins. .DN bit The done bit is set when .ACC.PRE. It is reset when: .UN bit .ACC<.PRE a RES instruction resets the counter combining CTU and CTD instructions and counting back up past the .PRE value

The underflow bit is set when the counter exceeds the lower limit of -2147483648. It is reset when: a RES instruction resets the counter counting back up to -2147483648 with a CTU instruction that uses the same tag as the CTU instruction

.PRE word .ACC word

The preset value specifies the value which the counter must reach before the controller sets the .DN bit. The accumulated value specifies the number of increments the instruction has counted. When enabled, the counter updates this value continually. Typically, enter zero. If you enter a value, the instruction decrements from that value. If the counter is reset, the .ACC value is zero.

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
does not execute does not execute executes

Description: true false

Publication 1756-6.4.1 review January 1998 - preliminary

2-18

Timer and Counter Instructions

CTD Example:

Each time limit_switch_1 goes from false to true, the controller decrements the counter_2 by 1. When the accumulated value the preset value, the controller sets counter_2.dn. The controller sets counter_1.ov if the accumulated value underflows 2147483647.

Publication 1756-6.4.1 review January 1998 - preliminary

Timer and Counter Instructions

2-19

Reset (RES)
Description: The RES instruction is an output instruction that resets a TIMER, COUNTER, or CONTROL structure. The RES instruction executes when its rung is true.
When using a RES instruction for a: timer

The controller resets: .ACC value control status bits

counter

.ACC value control status bits

file instruction

.LEN value .POS value control status bits

You can use a negative .PRE value in a CTU or CTD instruction. When you use the RES instruction, is resets the .ACC value to zero, which might set the .DN bit and prevent the CTU or CTD instruction from operating. You can also use the RES instruction to reset the state of these controller keywords. Enter the keyword in place of the tag.
Keyword: S:FS S:N S:Z S:V S:C S:MINOR Description: This is the first normal scan of the routines in this program. The result of an operation is negative. The result of an operation is zero. The result of an operation is an overflow. The result of an operation is a carry. At least one minor fault has been generated.

Operands:
Operand: Structure Valid Types: tag TIMER, COUNTER, or CONTROL

Publication 1756-6.4.1 review January 1998 - preliminary

2-20

Timer and Counter Instructions

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

RES Example:
Example: Description: When the input conditions are true, reset timer_3.

When the input conditions are true, reset counter_1.

When the input conditions are true, reset control_1.pos.

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

Input/Output Instructions
(MSG, GSV, SSV)
Introduction
The input/output instructions read or write data to or from the controller or a block of data to or from another station on the network.
If you want to: send data to or from another device get controller status information set controller status information Use this instruction: MSG GSV SSV See page: 3-2 3-15 3-15

Publication 1756-6.4.1 review January 1998 - preliminary

3-2

Input/Output Instructions

Message (MSG)
Description: The MSG instruction reads or writes a block of data to another station on a network and to create unscheduled messages. The MSG instruction transfers as many as 1000 elements of data. The size of each element depends on the data types you specify and the type of message command you use. The MSG instruction transfers data in packets. If your message contains more data than what fits into one packet, the transfer requires more than one packet. The more packets of data to transfer, the longer the transfer takes.
On this network: ControlLogix ControlNet Ethernet DH+ remote I/O ? 709 words 120 words ? MSG packets are:

Operands:
Operand: Control block Valid Types: tag MESSAGE

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
does not execute does not execute executes

Description: true false

Publication 1756-6.4.1 review January 1998 - preliminary

Input/Output Instructions

3-3

Control status:

Each MSG instruction has a MESSAGE structure that contains status information about the instruction.
MESSAGE structure

bit number

31 30 29 28 27 26 25
EW ER DN ST EN TO EN.CC

16 15

flags (.FLAGS) error codes (.ERR) extended error codes (.EXERR) requested length (.REQ_LEN) done length (.DN_LEN)

Control bit or word: .EW bit

Description: The enable waiting bit is set when the controller detects that a message request entered the queue. The controller resets the .EW bit when the .ST bit is set.

.ER bit

The error bit is set when the controller detects that a transfer failed. The .ER bit is reset the next time the associated rung goes from false to true.

.DN bit

The done bit is set when the last packet of the instruction transferred. The .DN bit is reset the next time the associated rung goes from false to true. The .DN bit is only active in non-continuous mode.

.ST bit

The start bit is set when the controller begins executing the MSG instruction. The .ST bit is reset when the .DN bit or the .ER bit is set.

.EN bit

The enable bit is set when the rung goes true. This bit shows that the instruction is enabled and is being executed. In non-continuous mode, the .EN bit remains set until the message is completed and the rung goes false. In continuous mode, once the .EN bit is set, it remains set regardless of rung condition.

.EN_CC

The enable cache bit determines how to manage the messge connection when the message is complete. If you want the controller to maintain the connection (such as when you repeat the same MSG instruction many times), set the .EN_CC bit. If you rarely execute the MSG instruction and have other needs for controller conenction, clear the .EN_CC bit. The time out bit is set if a message automatically times out. If you manually set the .TO bit, the controller stops processing the messages and sets the .ER bit.

.TO bit

Publication 1756-6.4.1 review January 1998 - preliminary

3-4

Input/Output Instructions Control bit or word: .FLAGS word Description: The flags word stores the above status bits and other status information in one, 15-bit word. The error code word stores error codes for the MSG instruction.

.ERR word .EXERR word .REQ_LEN word

The requested length word specifies how many words the message instruction is supposed to transfer. The done length word identifies how many words actually transferred.

.DN_LEN word

ATTENTION: The controller processes the .ST and .EW bits asynchronously to the program scan. If you examine these bits in ladder logic, copy the bit status to a storage bit whose status is synchronized with the program scan. Otherwise, timing problems might invalidate your application with possible damage to equipment to injury to personnel.

Message flags
The message flags word stores operating status in word.
This bit: 02 04 05 06 07 08 10 12 13 14 Stores: .EW .ER .DN .ST .EN .TO .EN_CC MSG_OPENING MSG_ACTIVE MSG_CLOSED Description: the message has been triggered but processing of the request hasnt begun message processing resulted in an error; check the error code to determine the cause message processing was performed to completion successfully message processing has begun program logic triggered a message instruction message processing is terminated because the message timed out controller maintains connection for MSG instruction message processing is trying to open a connection for the requested connected message message processing is performing the requested operation message processing closed the connection that was used for a connected message

Publication 1756-6.4.1 review January 1998 - preliminary

Input/Output Instructions

3-5

MSG error codes (.ERR)


The error codes depend on the type of MSG instruction. ControlLogix error codes
Error Code: 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF 0x10 0x11 Description: connection failure insufficient resource invalid value IOI syntax error destination unknown; class unsupported, instance undefined, or structure element undefined insufficient packet space connection lost service unsupported error in data segment or invalid attribute value attribute list error state already exists object mode conflict object already exists attribute not settable permission denied device state conflict reply wont fit Error Code: 0x12 0x13 0x14 0x15 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F 0x21 0x25 0x26 0x27 0xFF 0xD0 0xD1 Description: fragment primitive insufficient command data attribute not supported too much data bridge request too large bridge response too large attribute list shortage invalid attribute list value embedded service error connection related failure already written key segment error invalid IOI size unexpected attribute in list general error map instance undefined module not in run state

Publication 1756-6.4.1 review January 1998 - preliminary

3-6

Input/Output Instructions

PLC and SLC error codes


Error Code: 0002 0003 0004 0005 0006 0007 0008 0010 0011 0012 0013 0014 0015 0016 0017 0018 0019 001A 0037 0083 0089 0092 00D3 00D5 0500 Description: link layer timed out or received a NAK duplicate token holder detected by link layer local port is disconnected application layer timed out waiting for a response duplicate node detected station is offline hardware fault no IP address configured for the network already at a maximum number of connections invalid internet address or host name no such host cannot communicate with the named server connection not completed before user-specified timeout connection timed out by the network connection refused by the destination host connection was broken reply not received before user-specified timeout no network buffer space available message timed out in local processor processor is disconnected processors message buffer is full no response control block is formatted incorrectly incorrect address for the local data table application layer timed out waiting for a response F00B F00C F00D F011 F012 F01A F01B F00A Error Code: 1000 2000 3000 4000 5000 6000 7000 8000 9000 B000 F001 F002 F003 F006 F007 Description: illegal command from local processor communication module not working remote node is missing, disconnected, or shut down processor connected but faulted (hardware) wrong station number requested function is not available processor is in program mode processors compatibility file does not exist remote node cannot buffer command processor is downloading so it is inaccessible processor incorrectly converted the address incomplete address incorrect address addressed file does not exist in target processor destination file is too small for number of words requested target processor cannot put requested information in packets privilege error, access denied requested function is not available request is redundant data type requested does not match data available incorrect command parameters file owner active - the file is being used program owner active - someone is downloading or online editing

Publication 1756-6.4.1 review January 1998 - preliminary

Input/Output Instructions

3-7

MSG extended error codes (.EXERR)


Error Code: 0x00 0x01 0xFB 0xFC 0xFD 0xFE 0x0100 0x0103 0x0106 0x0107 0x0108 0x0109 0x0110 0x0111 0x0114 0x0115 0x0116 0x0118 0x011A 0x0203 0x0204 0x0205 0x0206 0x0301 0x0302 0x0303 0x0305 0x0306 0x0311 0x0312 0x0315 0x0317 Description: extended status out of memory extended status out of instances message port not supported message unsupported data type message uninitialized message timeout connection in use transport not supported ownership conflict connection not found invalid connection type invalid connection size module not configured EPR not supported wrong module wrong device type wrong revision invalid configuration format application out of connections connection timeout unconnected message timeout unconnected send parameter error message too large no buffer memory bandwidth not available no screeners available signature mismatch CCM not available port not available link address not available invalid segment type connection not scheduled Error Code: 0x2000 0x2001 0x2002 0x2018 0x201B 0x201C 0x2100 0x2101 0x2102 0x2103 0x2104 0x2105 0x2106 0x2107 0x2108 0x2109 0x210A 0x210B 0x210E 0x210F 0x2110 0x2111 0x2112 0x2113 0x2114 0x3001 0x3002 0x3003 0x3004 0x3005 continued Description: insufficient IOI excessive IOI bad parameter value semaphore reject size too small invalid size privilege failure invalid keyswitch position password invalid no password issued address out of range address and how many out of range data in use type is invalid or not supported controller in uoload or download mode attempt to change number of array dimensions invalid symbol name symbol does not exist search failed task cannot start unable to write unable to read shared routine not editable controller in faulted mode run mode inhibitted in transfer state in error state in idle state boot or ID updated in reprogrammable mode

Publication 1756-6.4.1 review January 1998 - preliminary

3-8

Input/Output Instructions

Error Code: continued 0x4002 0x4003 0x4004 0x4005 0x4006 0x4007 0x5001 0x5002 0x5003 0x5004 0x5005 0x5006 0x5007 0xFD01 0xFD02

Description: motion group not inhibited motion K-constant not set motion axis not assigned to group motion update not configured maximum instances of motion axes created motion group inhibited maximum instances of motion groups created motion semaphore reject motion axes in group motion axes not inhibited duplicate axes in motion group list invalid axis in motion group motion axis not assignable to motion group bad backplane EEPROM no error code

Error Code: 0xFD03 0xFD04 0xFD05 0xFE01 0xFE02 0xFE04 0xFE05 0xFE08 0xFE09 0xFF00 0xFF01 0xFF04 0xFF08 0xFF0B 0x0FF0E

Description: missing requested connection no CST master axis or group not assigned invalid connection type invalid update rate invalidn input image pointer invalid input image size invalid output image pointer invalid output image size no connection route too long invalid state invalid route invalid configuration no connection allowed

Selecting the Message Type (configuration tab)

After you enter the MSG instruction and specify the MESSAGE structure, use the configuration tab in the programming software to specify the details of the message.

Click here to configure the MSG instruction

Publication 1756-6.4.1 review January 1998 - preliminary

Input/Output Instructions

3-9

The details you configure depend on the message type you select.
If the target device is a: ControlLogix device Select one of these message types: CIP data table read CIP data table write generic CIP PLC5 typed read PLC5 typed write PLC5 word range read PLC5 word range write SLC typed read SLC typed write See page: 3-10

PLC-5 processor

3-10

SLC controller

3-11 3-11 3-12

Block-transfer instruction from a block-transfer read previous PLC-5 program block-transfer write PLC-3 processor PLC3 typed read PLC3 typed write PLC3 word range read PLC3 word range write PLC2 unprotected read PLC2 unprotected write

PLC-2 processor

3-12

You must specify this configuration information:


In this field: Source Element/Tag Specify: If you select a read message type, the Source Element is the address of the data you want to read in the target device. Use the addressing syntax of the target device. If you select a write message type, the Source Tag is the tag of the data in the Logix5550 controller that you want to send to the target device. Number of Elements The number of elements you read/write depends on the type of data you are using. An element refers to one chunk of related data. For example, tag timer1 is one element that consists of one timer and its control structure. Also, timer1.acc is also one element that consists of one specific bit. If you select a read message type, the Destination Tag is the tag in the Logix5550 controller where you want to store the data you read from the target device. Use the tag name that maps to the target device address. If you select a write message type, the Desintation Element is the address of the location in the target device where you want to write the data.

Destination Element/Tag

Publication 1756-6.4.1 review January 1998 - preliminary

3-10

Input/Output Instructions

Specifying CIP messages


The CIP message types are designed for other ControlLogix devices, such as sending a message from one Logix5550 controller to another.
Select this command: CIP Data Table Read CIP Data Table Write Generic CIP If you want to: read data from another device write data to another device create your own message

Specifying PLC-5 messages


The PLC-5 message types are designed for PLC-5 processors.
Select this command: PLC5 Typed Read If you want to: read data identified by a type code. This command reads data structures without you specifying the actual word length. For example, if you chose a typed read of timer data with a requested data size of 5 elements, the MSG instruction read 5 timer structures. PLC5 Typed Write write data identified by a type code. This command writes data structures without you specifying the actual word length. PLC5 Word Range Read read a range of words, starting at the address specified as the external address and reading sequentially the number of words requested. The data from the internal address that is read is stored, starting at the address specified as the internal address. PLC5 Word Range Write write a range of words, starting at the address specified as the internal address and writing sequentially the number of words requested. The data from the internal address is written, starting at the address specified for the external address.

If you transfer floating point values, use a typed read or typed write to ensure accuracy.

Publication 1756-6.4.1 review January 1998 - preliminary

Input/Output Instructions

3-11

Specifying SLC messages


The SLC message types are designed for SLC controllers.
Select this command: SLC Typed Read If you want to: read data identified by a type code. This command reads data structures without specifying the actual word length. This command provides additional data verification for communication with SLC controllers. SLC Typed Write write data identified by a type code. This command writes data structures without specifying the actual word length. This command provides additional data verification for communication with SLC controllers.

The Logix5550 tag type must match the SLC data type. You can only transfer: 16-bit integer (INT), bit (BOOL), timer, counter, or control data.

Specifying block-transfer messages


The block-transfer message types interact with the block-transfer instructions in PLC-5 programs. Select one of the message types if you are converting PLC-5 logic to Logix5550 logic.
Select this command: Block-Transfer Read If you want to: re-use PLC code that uses a BTR instructions. This message type replaces the BTR instruction. Block-Transfer Write re-use PLC code that uses BTW instructions. This message type replaces the BTW instruction.

In addition to specifying the source and destination tags, you must also specify how many 16-bit integers to send or receive.

Publication 1756-6.4.1 review January 1998 - preliminary

3-12

Input/Output Instructions

Specifying PLC-3 messages


The PLC-3 message types are designed for PLC-3 processors.
Select this command: PLC3 Typed Read If you want to: read data identified by a type code. This command reads data structures without you specifying the actual word length. For example, if you chose a typed read of timer data with a requested data size of 5 elements, the MSG instruction read 5 timer structures. PLC3 Typed Write write data identified by a type code. This command writes data structures without you specifying the actual word length. PLC3 Word Range Read read a range of words, starting at the address specified as the external address and reading sequentially the number of words requested. The data from the internal address that is read is stored, starting at the address specified as the internal address. PLC3 Word Range Write write a range of words, starting at the address specified as the internal address and writing sequentially the number of words requested. The data from the internal address is written, starting at the address specified for the external address.

Specifying PLC-2 messages


The PLC-2 message types are designed for PLC-2 processors.
Select this command: PLC2 Unprotected Read PLC2 Unprotected Write If you want to: read 16-bit words from any area of the PLC-2 data table or PLC-2 compatibility file. write 16-bit words to any area of the PLC-2 data table of PLC-2 compatibility file.

The message transfer uses 16-bit words, so make sure the Logix5550 tag appropriately stores the transferred data. You must also specify a PLC-2 compatibility file.

Publication 1756-6.4.1 review January 1998 - preliminary

Input/Output Instructions

3-13

Specifying the Communication Details (communication tab)

When you configure a MSG instruction, you specify these details on the communication tab:
In this field: Path Specify: Enter the connection path to the target device. You can find the connection path through RSLinx software. Select CIP or DH+

Communication method

If you select CIP, the message is routed through the ControlLogix backplane. If you select DH+, the message is routed through a DH/RIO module. Specify: Source Link: Destination Link: Link ID of the local DH+ link Link ID of the remote DH+ link where the target device resides

Destination Node: Station address of the target device

Mapping addresses
For non-ControlLogix devices, you must map the target devices addressing to a local, Logix5550 tag. To map addresses, use the mapping tool in your programming software.
For: PLC-3 processors, PLC-5 processors SLC controllers Tag Name In this field: File Number Specify: Enter the file number of the address in the target device. For example, enter 7 for file 7, which is typically the N7 file. Enter the tag name the local controller uses to refer to the target devices address. For example, N7 in a PLC-5 processor could be referred to as PLC5_source in a Logix5550 controller. Enter the tag name to be the PLC-2 compatibility file.

PLC-2 processors

Tag Name

MSG Programming Examples


CIP communications

Ethernet communications

ControlNet communications

Publication 1756-6.4.1 review January 1998 - preliminary

3-14

Input/Output Instructions

Replacing PLC-5 block-transfer instructions

Publication 1756-6.4.1 review January 1998 - preliminary

Input/Output Instructions

3-15

Get Status Value (GSV) and Set Status Value (SSV)


Description: The Logix5550 controller stores status data in objects. (There is no status file, as in the PLC-5 processor. Use the GSV/SSV instructions to get and set controller status data within these objects. The GSV instruction retrieves the specified information and places it in the destination. The SSV instruction sets the specified attribute with data from the source. When you enter a GSV/SSV instruction, the programming software displays the valid objects, object names, and attribute names you can choose. The GSV/SSV instructions support the same objects, but the attributes differ, depending on whether you have read access (GSV) or write access (SSV) to the attribute.

!
Operands:
Operand: Object class Object name Attribute name Destination

ATTENTION: Use the GSV/SSV instructions carefully. Making changes to objects can cause unexpected controller operation or injury to personnel.

Valid Types: immediate any tag type object specific (see list of objects below) tag DINT This operand is only used with the GSV instruction.

Source

tag DINT This operand is only used with the SSV instruction.

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

Publication 1756-6.4.1 review January 1998 - preliminary

3-16

Input/Output Instructions

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. For example, there can be several tasks in your application. Each task has its own TASK object that you access by the task name. You can access these objects:
For information about this object: AXIS CONTROLLER CONTROLLERDEVICE CST DF1 FAULTLOG MODULE MOTIONGROUP PROGRAM ROUTINE SERIALPORT TASK WALLCLOCKTIME See page: 3-16 and chapter 17 3-16 3-17 3-18 3-18 3-20 3-22 3-22 and chapter 17 3-22 3-23 3-24 3-25 3-25

Accessing the AXIS object


The AXIS object provides status information about an axis for the servo module. Specify the object name to determine which AXIS object you want. For more information about the AXIS object, see chapter 17.

Accessing the CONTROLLER object


The CONTROLLER object provides status information about a controllers execution.
Attribute: TimeSlice Instruction: GSV SSV Description: Percentage of available CPU that is assigned to communications. Valid value is 10-90. This value is not changeable when the controller is in run mode.

Publication 1756-6.4.1 review January 1998 - preliminary

Input/Output Instructions

3-17

Accessing the CONTROLLERDEVICE object


The CONTROLLERDEVICE object identifies the physical hardware of the controller.
Attribute: DeviceName Instruction: GSV Description: ASCII string name of the controller. Logix5550 = ProductCode GSV Identifies the type of controller Logix5550 = 3 ProducRev GSV Identifies the current product revision. For a controller, this value starts at series A (1), revision A (1). SerialNumber GSV Serial number of the device. The serial number is assigned when the device is built. Status GSV Bits identify status: Value: 0100 0400 0xxx 1000 4000 8000 Type GSV Meaning: Controller detected a minor fault. Controller has a major fault and is in faulted mode. Controller is in run mode. Controller is in debug mode. Controller is in program mode. The controllers keyswitch is in the remote position.

Identifies the devices as a controller. Controller = 14

Vendor

GSV

Identifies the vendor of the device. Allen-Bradley = 0001

Publication 1756-6.4.1 review January 1998 - preliminary

3-18

Input/Output Instructions

Accessing the CST object


The CST (coordinated system time) object provides coordinated system time (CST) for the devices in the system.
Attribute: CurrentStatus Instruction: GSV Description: Current status of the coordinated system time. Bits identify: Bit: 0 1 2 3 4 5 6-7 8-9 Meaning: timer hardware faulted ramping enabled system time master synchronized local network master in relate mode unused time node type 00 = time dependent node 01 = time master node 10 = time relay node 11 = unused unused

10-15 CurrentValue GSV

Current value of the timer. The timer source is adjusted to match the value supplies in update services and from local communication network synchronization. The adjustment is either a ramping to the requested value or an immediate setting to the request value, as reported in the CurrentStatus attribute.

Accessing the DF1 object


The DF1 object provides an interface to the DF1 communication driver that you can configure for the serial port.
Attribute: ACKTimeout Instruction: GSV Description: The amount of time to wait for an acknowledgment to a message transmission. Delay in counts of 20 msec periods. DF1Mode GSV Specifies the DF1 driver mode. Value: 0 1 2 Meaning: point-to-point DF1 slave DF1 master

Publication 1756-6.4.1 review January 1998 - preliminary

Input/Output Instructions Attribute: DiagnosticCounters DF1 counters point-to-point modem bits packets sent packets receivedt undelivered packets ENQs sent NAKs recevied ENQs received bad packets NAKed no memory response sent duplicate packets received unused DCD recoveries count lost modem count DuplicateDetection GSV Instruction: GSV Description:

3-19

Array of diagnostic counters for the DF1 communication driver. DF1 counters slave modem bits packets sent packets receivedt undelivered packets messages retried NAKs recevied polls received bad packets NAKed no memory response sent duplicate packets received unused DCD recoveries count lost modem count

DF1 counters master modem bits packets sent packets receivedt undelivered packets messages retried NAKs recevied polls received bad packets NAKed no memory response sent duplicate packets received unused DCD recoveries count lost modem count

word 0 1 2 3 4 5 6 7 8 9 10 11 12

Enables duplicate message detection. Value: 0 1 Meaning: no duplicate message detection duplicate message detection

EmbeddedResponse

GSV

Enables embedded response functionality. Value: Meaning: 0 initiated only after one is received non-zero enabled unconditionally

ENQsSent

GSV

The number of inquiries (ENQs) to send after an ACK timeout. Valid value 0-255. Recommended setting is 3.

ErrorDetection

GSV

Specifies the error-detection scheme. Value: 0 1 Meaning: BCC CRC

GroupSize

GSV

Number of stations to poll. Valid value 0-255.

MasterMessage

GSV

Current value of the master message transmission. Value: 0 1 Meaning: between station polls (default) in poll sequence

MessageWaitTime

GSV

The time (acting as a master) to wait after receiving an ACK before polling the slave for a response. Delay in counts of 20 msec periods. The default is 3 periods (60 msec).

NAKsReceived

GSV

The number of NAKs received in response to a message before stopping transmission (point-to-point communication only). Valid value 0-255. Recommended setting is 3.

Publication 1756-6.4.1 review January 1998 - preliminary

3-20

Input/Output Instructions Attribute: PollMode Instruction: GSV Description: Current polling mode. Value: 0 1 2 3 Retries GSV Meaning: message-based, but dont allow slaves to initiate messages message-based, but allow slaves to initiate messages (default) standard, single-message transfer per node scan standard, multiple-message transfer per node scan

Number of times to resend a message to the master device without getting an acknowledgment. Valid value 0-255. Recommended setting is 3. The default is 3.

StationAddresss

GSV

Current station address of the serial port. Valid value 0-254.

PendingACKTimeout PendingDuplicateDetection PendingEmbeddedResponse PendingENQsSent PendingErrorDetection PendingGroupSize PendingMasterMessage PendingMessageWaitTime PendingNAKsReceived PendingPollMode PendingRetries PendingStationAddress

SSV SSV SSV SSV SSV SSV SSV SSV SSV SSV SSV SSV

Pending value for the ACKTimeout attribute. Pending value for the DuplicateDetection attribute. Pending value for the EmbeddedResponse attribute. Pending value for the ENQsSent attribute. Pending value for the ErrorDetection attribute. Pending value for the GroupSize attribute. Pending value for the MasterMessage attribute. Pending value for the MessageWaitTime attribute. Pending value for the NAKsReceived attribute. Pending value for the PollMode attribute. Pending value for the Retries attribute. Pending value for the StationAddress attribute.

Accessing the FAULTLOG object


The FAULTLOG object provides fault information about the controller.
Attribute: EighthMinorEvent FifthMinorEvent FirstMinorEvent Instruction: GSV GSV GSV Description: What was the eighth-most recent minor fault.

(same format as FirstMinorEvent) What was the fifth-most recent minor fault. (same format as FirstMinorEvent) What was the most recent minor fault.
timestamp type of fault fault code fault-specific

FourthMinorEvent

GSV

What was the fourth-most recent minor fault.

(same format as FirstMinorEvent)

Publication 1756-6.4.1 review January 1998 - preliminary

Input/Output Instructions Attribute: Last3MajorEvents Instruction: GSV Description: What were the last three major faults.

3-21

most recent timestamp type of fault fault code fault-specific MajorEvents GSV SSV MinorEvents GSV SSV MajorFaultBits GSV SSV MinorFaultBits GSV SSV SecondMinorEvent GSV

second most-recent timestamp type of fault fault code fault-specific

third most-recent timestamp type of fault fault code fault-specific

How many major faults have occurred since the last time this counter was reset. How many minor faults have occurred since the last time this counter was reset. Individual bits indicate the reason for the current major fault.

Individual bits indicate the reason for the current minor fault.

What was the second-most recent minor fault.

SeventhMinorEvent GSV SixthMinorEvent ThirdMinorEvent GSV GSV

(same format as FirstMinorEvent) What was the seventh-most recent minor fault. (same format as FirstMinorEvent) What was the sixth-most recent minor fault. (same format as FirstMinorEvent) What was the third-most recent minor fault. (same format as FirstMinorEvent)

Accessing the MESSAGE object


You can access the MESSAGE object through the GSV/SSV instructions. Specify the object name to determine which AXIS object you want. The MESSAGE object provides an interface to setup and trigger peer-to-peer communications. This object replaces the MG data type of the PLC-5 programmable controller.
Attribute: ConnectedFlag Instruction: GSV SSV Description: Specifies whether the message is connected or unconnected. Value: 1 2 Meaning: connected not connected

ConnectionPath

GSV SSV

Data to setup the connection path.

IOIString

GSV SSV

Specifies the string used for encoding the service and addressing for the message.

Publication 1756-6.4.1 review January 1998 - preliminary

3-22

Input/Output Instructions Attribute: MessageType Instruction: GSV SSV Port GSV SSV Priority GSV SSV UnconnectedTimeout GSV SSV Timeout period for all unconnected messages Priority of the message. Description: Specifies the type of message. Value: 0 Meaning: not initialized

Indicates which port the message should be sent on.

Accessing the MODULE object


tbd
Attribute: EntryStatus FaultCode FaultInfo ForceStatus Instance Mode Instruction: GSV GSV GSV GSV GSV GSV SSV Description:

Accessing the MOTIONGROUP object


The MOTIONGROUP object provides status information about an group of axes for the servo module. Specify the object name to determine which MOTIONGROUP object you want. For more information about the MOTIONGROUP object, see chapter 17.

Accessing the PROGRAM object


The PROGRAM object provides a way to start the execution of the application.
Attribute: DisableFlag Instruction: GSV SSV Description: Control this programs execution. Value: 0 1 Meaning: execution enabled execution disabled

Instance

GSV

The objects instance number. Valid values are 0-31.

Publication 1756-6.4.1 review January 1998 - preliminary

Input/Output Instructions Attribute: LastScanTime Instruction: GSV SSV MajorFaultRecord GSV SSV MaxScanTime GSV SSV MinorFaultRecord GSV SSV ProgramState GSV SSV Operating state of this program instance. Value: 0001 0002 0004 0008 0010 0020 0040 0100 0200 0400 1000 Meaning: execution of this program is disabled executing a non-edited version executing the edited version (online editing) an edit is pending for the end of execution first scan flag SFC force enable SFC restart (1=restart, 0=resume) prescan of executable in progress powerup fault recovery in progress powerup recovery in progress fault routine execution in progress Description: Time is took to execute this program the last time it was executed. Time is in microseconds. Records major faults for this program.

3-23

Maximum recorded execution time for this program. Time is in microseconds. Records minor faults for this program.

SFCRestart

GSV SSV

Selects a restart mode for the SFCs that are part of this program. Value: 0 1 Meaning: resume SFC after power loss restart SFC after power loss

Accessing the ROUTINE object


The ROUTINE object identifies the routines associated with a PROGRAM.
Attribute: Instance Instruction: GSV Description: The objects instance number. Valid values are 0-31.

Publication 1756-6.4.1 review January 1998 - preliminary

3-24

Input/Output Instructions

Accessing the SERIALPORT object


The SERIALPORT object provides an interface to the serial communication port.
Attribute: BaudRate Instruction: GSV Description: Specifies the baud rate. Valid values are 110, 300, 600, 1200, 2400, 4800, 9600, and 19200 (default). DataBits GSV Specifies the number of bits of data per character. Value: 7 8 Parity GSV Meaning: 7 data bits (ASCII only) 8 data bits

Specifies the parity. Value: 0 1 2 Meaning: no parity odd parity (ASCII only) even parity

RTSOffDelay

GSV

Amount of time to delay turning off the RTS line after the last character has been transmitted. Delay in counts of 20 msec periods. The default is 0 msec.

RTSSendDelay

GSV

Amount of time to delay transmitting the first character of a message after turning on the RTS line. Delay in counts of 20 msec periods. The default is 0 msec.

StopBits

GSV

Specifies the number of stop bits. Value: 1 2 Meaning: 1 stop bit (default) 2 stop bits (ASCII only)

PendingBaudRate PendingDataBits PendingParity PendingRTSOffDelay PendingRTSSendDelay PendingStopBits

SSV SSV SSV SSV SSV SSV

Pending value for the BaudRate attribute. Pending value for the DataBits attribute. Pending value for the Parity attribute. Pending value for the RTSOffDelay attribute. Pending value for the RTSSendDelay attribute. Pending value for the StopBits attribute.

Publication 1756-6.4.1 review January 1998 - preliminary

Input/Output Instructions

3-25

Accessing the TASK object


The TASK object provides a way to schedule the application. A task can be continuous or periodic.
Attribute: Instance Instruction: GSV Description: The objects instance number. Valid values are 0-31. LastScanTime GSV SSV MaxInterval GSV SSV MaxScanTime GSV SSV MinInterval GSV SSV Priority GSV SSV Rate GSV SSV StartTime GSV SSV Watchdog GSV SSV Value of WALLCLOCKTIME when the last execution of the task was started. Time limit for execution of all programs associated with this task. Time is in seconds. If you enter 0, these values are assigned: Time: 0.5 sec 5.0 sec Task Type: periodic continuous Time is took to execute this program the last time it was executed. Time is in microseconds. The maximum time interval between successive executions of the task. A value of 0 indicates 1 or less executions of the task. Maximum recorded execution time for this program. Time is in microseconds. The minimum time interval between successive executions of the task. A value of 0 indicates 1 or less executions of the task. Relative priority of this task as compared to the other tasks. Valid values 0-15.

Accessing the WALLCLOCKTIME object


The WALLCLOCKTIME object provides a timestamp the controller can use for scheduling.
Attribute: CSTOffset Instruction: GSV SSV CurrentValue GSV SSV Description: Positive offset from the coordinate system time value. Value in msecs. The default is 0. Current value of the wall clock time. The value is referenced from 0000 hrs. January 1, 1981.

Publication 1756-6.4.1 review January 1998 - preliminary

3-26

Input/Output Instructions

GSV/SSV Programming Example

Getting fault information


The following examples uses GSV instructions to get fault information.

Getting I/O fault information 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.

Getting program status information This example gets status information about program discrete and places the data in a user-defined structure discrete_info.

Gettings task status information This example gets status information about task IO_test and places the data in a user-defined structure io_test_info.

Publication 1756-6.4.1 review January 1998 - preliminary

Input/Output Instructions

3-27

Setting enable and disable flags


The following example uses input data to enable or disable a program. You could also use this method to enable or disable an I/O module, which is a program solution similar to using inhibit bits with a PLC-5 processor.

Based on the status of SW.1, place the appropriate value in the disableflag attribute of program discrete.

Publication 1756-6.4.1 review January 1998 - preliminary

3-28

Input/Output Instructions

Notes:

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

Compare Instructions
(CMP, EQU, GEQ, GRT, LEQ, LES, LIM, MEQ, NEQ)
Introduction
The compare instructions let you compare values by using an expression or a specific compare instruction.
If you want to: compare values based on an expression test whether two values are equal test whether one value is greater than or equal to a second value test whether one value is greater than a second value test whether one value is less than or equal to a second value test whether one value is less than a second value test whether one value is between two other values pass two values through a mask and test whether they are equal test whether one value is not equal to a second value Use this instruction: CMP EQU GEQ GRT LEQ LES LIM MEQ NEQ See page: 4-3 4-5 4-6 4-7 4-8 4-9 4-10 4-12 4-14

You can compare values of different data types, such as floating point and integer.
If the input rung is: true and the expression is: true false false true false the output status is: true false false false

Publication 1756-6.4.1 review January 1998 - preliminary

4-2

Compare Instructions

Using arithmetic status flags


To access arithmetic status flags, use an XIC or XIO instruction with one of the status keywords.
Use this keyword: For this status flag: S:C S:N S: V S:Z carry sign (result is negative) overflow zero With this access: read/write read/write read/write read/write

Use the RES instruction to clear the status flags.

Publication 1756-6.4.1 review January 1998 - preliminary

Compare Instructions

4-3

Compare (CMP)
Description: The CMP instruction is an input instruction that performs a comparison on arithmetic operations you specify in the expression. When the controller finds the expression is true, the rung goes true. Otherwise, the rung is false. The execution time of a CMP instruction is longer than the execution time of the other comparison instructions. A CMP instruction uses more words of memory than the other comparison instructions. The expression defines the operations you want to perform. Define the expression with operators, tags, and constants. Use brackets ( ) to define specific sections of more complex expressions. The expression must contain one comparison operation: =, <>, <, <=, >, or >=

Valid operations
Operator: + * / ** = <> < <= > Description: add subtract/negate multiply divide exponent (x to y) equal not equal less than less than or equal greater than Operator: >= ACS AND ASN ATN COS DEG FRD LN LOG Description: greater than or equal arc cosine logical AND arc sine arc tangent cosine degree BCD to binary natural log log base 10 Operator: MOD NOT OR RAD SIN SQR TAN TOD XOR Description: modulo divide logical complement logical OR degrees to radians sine square root tangent binary to decimal exclusive OR

Operands:
Operand: Expression Valid Types: an expression consisting of tags and/or immediate values separated by operators

Publication 1756-6.4.1 review January 1998 - preliminary

4-4

Compare Instructions

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

CMP Example:

If the controller finds the expression true, the instruction is true.

Publication 1756-6.4.1 review January 1998 - preliminary

Compare Instructions

4-5

Equal to (EQU)
Description: Use the EQU instruction to test whether two values are equal. Source A and Source B can either be values or tags. REAL values are rarely absolutely equal. If you need to determine the quality of two REAL values, use the LIM instruction.

Operands:
Operand: Source A Source B Valid Types: immediate or tag SINT, INT, DINT, or REAL immediate or tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true 0.44 0.44 false 0.16 0.17

EQU Example:

If value_1 is equal to value_2 , the instruction is true.

Publication 1756-6.4.1 review January 1998 - preliminary

4-6

Compare Instructions

Greater than or Equal to (GEQ)


Description: Use the GEQ instruction to test whether one value (Source A) is greater than or equal to a second value (Source B). Source A and Source B can be values or tags.

Operands:
Operand: Source A Source B Valid Types: immediate or tag SINT, INT, DINT, or REAL immediate or tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true 0.45 0.65 false 0.18 0.15

GEQ Example:

If value_1 is greater than or equal to value_2, the instruction is true.

Publication 1756-6.4.1 review January 1998 - preliminary

Compare Instructions

4-7

Greater Than (GRT)


Description: Use the GRT instruction to test whether one value (Source A) is greater than a second value (Source B). Source A and Source B can be values or tags.

Operands:
Operand: Source A Source B Valid Types: immediate or tag SINT, INT, DINT, or REAL immediate or tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true 0.44 0.65 false 0.17 0.18

GRT Example:

If value_1 is greater than value_2, the instruction is true.

Publication 1756-6.4.1 review January 1998 - preliminary

4-8

Compare Instructions

Less Than or Equal to (LEQ)


Description: Use the LEQ instruction to test whether one value (Source A) is less than or equal to a second value (Source B). Source A and Source B can be values or tags.

Operands:
Operand: Source A Source B Valid Types: immediate or tag SINT, INT, DINT, or REAL immediate or tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true 0.44 0.65 false 0.17 0.18

LEQ Example:

If value_1 is less than or equal to value_2 , the instruction is true.

Publication 1756-6.4.1 review January 1998 - preliminary

Compare Instructions

4-9

Less Than (LES)


Description: Use the LES instruction to test whether one value (Source A) is less than a second value (Source B). Source A and Source B can be values or tags.

Operands:
Operand: Source A Source B Valid Types: immediate or tag SINT, INT, DINT, or REAL immediate or tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true 0.43 0.65 false 0.18 0.17

LES Example:

If value_1 is less than value_2, the instruction is true.

Publication 1756-6.4.1 review January 1998 - preliminary

4-10

Compare Instructions

Limit (LIM)
Description: The LIM instruction is an input instruction that tests for values inside or outside of a specified range. The instruction is false until the controller detects that the Test value is within certain limits or outside of certain limits. Then the instruction goes true. When the instruction detects that the Test value is no longer within or outside of the limits, the instruction goes false. Low Limit <= High Limit: When the controller detects that the test value is equal to or between the limits, the instruction is true; if the test value is outside the limits, the instruction is false.
low limit test high limit

false

true

false

Low Limit >= High Limit: When the controller detects that the test value is equal to or outside the limits, the instruction is true; if the test value is inside the limits, but not equal to either limit, the instruction is false.
test low limit high limit test

true

false

true

Operands:
Operand: Low limit Test High limit Valid Types: immediate or tag SINT, INT, DINT, or REAL immediate or tag SINT, INT, DINT, or REAL immediate or tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) DINT REAL Description: true 0.87 3.60 false 0.16 0.18

Publication 1756-6.4.1 review January 1998 - preliminary

Compare Instructions Characteristic: Execution Description:


executes does not execute executes

4-11

LIM Example:

If test_value is greater than or equal to value_1 and less than or equal to value_2, the instruction is true.

Publication 1756-6.4.1 review January 1998 - preliminary

4-12

Compare Instructions

Mask Equal to (MEQ)


Description: The MEQ instruction is an input instruction that compares a Source value with a Compare value after passing portions of the Source through a Mask. If the Source value matches the Compare value bit by bit (less any masked bits), the instruction is true. The instruction goes false as soon as the controller detects a mismatch. The Mask passes data when the Mask bits are set (1); the Mask blocks data when the Mask bits are reset (0). The Mask must be the same element size as the Source and Compare. Use the MEQ instruction to extract for comparison data such as status or control bits. Operands:
Operand: Source Mask which bits to pass or block Compare Valid Types: immediate or tag SINT, INT, or DINT immediate or tag SINT, INT, or DINT (hexadecimal, octal, or binary value) immediate or tag SINT, INT, or DINT

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true 0.65 false 0.17

Publication 1756-6.4.1 review January 1998 - preliminary

Compare Instructions

4-13

MEQ Example:

The controller passes value_1 through the mask mask_1 and compares the result to value_2. A 0 in the mask restrains the instruction from comparing that bit. If value_1 and value_2 are the same, less the masked bits, the instruction is true.

MEQ operand: Source Mask Compare Result

Example values (using INTs): 01010101 01010101 11111111 11110000 01010101 0101xxxx

The instruction is true because the Source and Compare values are identical, minus the masked bits (which are not compared).

Entering an immediate mask value


If you want to enter an immediate mask value, you must precede the value with the correct prefix.
Prefix: 16# Description: hexadecimal for example; 16#0F0F 8# octal for example; 8#16 2# binary for example; 2#00110011

Publication 1756-6.4.1 review January 1998 - preliminary

4-14

Compare Instructions

Not Equal to (NEQ)


Description: Use the NEQ instruction to test whether two values are not equal. Source A and Source B can be values or tags.

Operands:
Operand: Source A Source B Valid Types: immediate or tag SINT, INT, DINT, or REAL immediate or tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true 0.45 0.43 false 0.18 0.16

NEQ Example:

If value_1 is not equal to value_2, the instruction is true.

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

Compute/Math Instructions
(CPT, ADD, SUB, MUL, DIV, SQR, NEG)
Introduction
The compute/math instructions evaluate arithmetic operations using an expression or a specific arithmetic instruction.
If you want to: evaluate an expression add two values subtract two values multiply two values divide two values take the square root of a value take the opposite sign of a value Use this instruction: CPT ADD SUB MUL DIV SQR NEG See page: 5-2 5-4 5-5 5-6 5-7 5-8 5-9

You can mix values of different data types, such as floating point and integer. If you use floating point as the source, use floating point as the destination. You can mix data types, but loss of accuracy and rounding error might occur. If the rung with the compute instruction goes true, the controller performs the computation.

Using arithmetic status flags


To access arithmetic status flags, use an XIC or XIO instruction with one of the status keywords.
Use this keyword: For this status flag: S:C S:N S: V S:Z carry sign (result is negative) overflow zero With this read/write access: read/write read/write read/write read/write

Use the RES instruction to clear the status flags.

Publication 1756-6.4.1 review January 1998 - preliminary

5-2

Compute/Math Instructions

Compute (CPT)
Description: The CPT instruction is an output instruction that performs the arithmetic operations you define in the expression. The CPT instruction can also copy data from one tag to another and automatically convert the data type at the source tag to the data type you specify for the Destination. The execution time of a CPT instruction is longer than the execution time of the other compute/math instructions. A CPT instruction uses more words of memory than the other compute/math instructions.

Valid operations
Operator: + * / = ** ACS AND Description: add subtract/negate multiply divide equal exponent (x to y) arc cosine logical AND Operator: ASN ATN COS DEG FRD LN LOG MOD Description: arc sine arc tangent cosine degree BCD to binary natural log log base 10 modulo divide Operator: NOT OR RAD SIN SQR TAN TOD XOR Description: logical complement logical OR degrees to radians sine square root tangent binary to decimal exclusive OR

Determining the order of operation


The operations you write into the expression are performed by the controller in a prescribed order, not necessarily the order you write them. You can override the order of operation by grouping terms within parenthesis, forcing the controller to perform an operation within the parenthesis ahead of other operations. Operations of equal order are performed from left to right.
Order: 1 2 3 Operation: ** * / 4 + Description: exponential negate multiply divide add subtract

Publication 1756-6.4.1 review January 1998 - preliminary

Compute/Math Instructions

5-3

Operands:
Operand: Destination Expression Valid Types: tag SINT, INT, DINT, or REAL an expression consisting of tags and/or immediate values separated by operators

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

CPT Example:

If the preceding instructions are true, the controller evaluates the expressions and places the result in result_1.

Publication 1756-6.4.1 review January 1998 - preliminary

5-4

Compute/Math Instructions

Add (ADD)
Description: Use the ADD instruction to add one value (Source A) to another value (Source B) and place the result in the Destination. Source A and Source B can be values or tags. The ADD instruction executes once each program scan as long as the rung is true. If you want the values added only once, use an ONS instruction.

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: sets if generates a carry; otherwise resets sets is an overflow is generated; otherwise resets sets is the result is zero; otherwise resets sets if the result is negative; otherwise resets

Operands:
Operand: Source A Source B Destination Valid Types: immediate or tag SINT, INT, DINT, or REAL immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

ADD Example:
If the preceding instructions are true, the controller adds float_value_1 to float_value_2 and places the result in compute_result.

Publication 1756-6.4.1 review January 1998 - preliminary

Compute/Math Instructions

5-5

Subtract (SUB)
Description: Use the SUB instruction to subtract one value (Source B) from another value (Source A) and place the result in the Destination. Source A and Source B can be values or tags. The SUB instruction executes once each program scan as long as the rung is true. If you want the values subtracted only once, use an ONS instruction.

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: sets if generates a borrow; otherwise resets sets is an underflow is generated; otherwise resets sets is the result is zero; otherwise resets sets if the result is negative; otherwise resets

Operands:
Operand: Source A Source B Destination Valid Types: immediate or tag SINT, INT, DINT, or REAL immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

SUB Example:
If the preceding instructions are true, the controller subtracts float_value_2 from float_value_1 and places the result in compute_result.

Publication 1756-6.4.1 review January 1998 - preliminary

5-6

Compute/Math Instructions

Multiply (MUL)
Description: Use the MUL instruction to multiply one value (Source A) with another value (Source B) and place the result in the Destination. Source A and Source B can be values or tags. The MUL instruction executes once each program scan as long as the rung is true. If you want the values multiplied only once, use an ONS instruction.

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets sets if an overflow is generated; otherwise resets sets is the result is zero; otherwise resets sets if the result is negative; otherwise resets

Operands:
Operand: Source A Source B Destination Valid Types: immediate or tag SINT, INT, DINT, or REAL immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

MUL Example:
If the preceding instructions are true, the controller multiples float_value_1 to float_value_2 and places the result in compute_result.

Publication 1756-6.4.1 review January 1998 - preliminary

Compute/Math Instructions

5-7

Divide (DIV)
Description: Use the DIV instruction to divide one value (Source A) by another value (Source B) and place the result in the Destination. Source A and Source B can be values or tags. The DIV instruction executes once each program scan as long as the rung is true. If you want the values divided only once, use an ONS instruction.

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets sets if division by zero or if an overflow is generated; otherwise resets sets is the result is zero; otherwise resets sets if the result is negative; otherwise resets

Operands:
Operand: Source A Source B Destination Valid Types: immediate or tag SINT, INT, DINT, or REAL immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

DIV Example:
If the preceding instructions are true, the controller divides float_value_1 by float_value_2 and places the result in compute_result.

Publication 1756-6.4.1 review January 1998 - preliminary

5-8

Compute/Math Instructions

Square Root (SQR)


Description: Use the SQR instruction to take the square root of a value (Source) and place the result in the Destination. If Source is negative, the controller takes the absolute value before performing the square root. The SQR instruction executes once each program scan as long as the rung is true. If you want the square root computed only once, use an ONS instruction.

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets sets if an overflow is generated; otherwise resets sets is the result is zero; otherwise resets always resets

Operands:
Operand: Source Destination Valid Types: immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

SQR Example:
If the preceding instructions are true, the controller takes the square root of value_1 and places the result in compute_result.

Publication 1756-6.4.1 review January 1998 - preliminary

Compute/Math Instructions

5-9

Negate (NEG)
Description: Use the NEG instruction to change the sign of a value. If you negate a negative value, the result is positive. If you negate a positive value, the result is negative. The NEG instruction executes once each program scan as long as the rung is true. If you want the values negated only once, use an ONS instruction.

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: sets if generates a carry; otherwise resets sets is an overflow is generated; otherwise resets sets is the result is zero; otherwise resets sets if the result is negative; otherwise resets

Operands:
Operand: Destination Expression Valid Types: tag SINT, INT, DINT, or REAL an expression consisting of tags and/or immediate values separated by operators

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

NEG Example:
If the preceding instructions are true, the controller takes the opposite sign of value_1 and places the result in compute_result.

Publication 1756-6.4.1 review January 1998 - preliminary

5-10

Compute/Math Instructions

Notes:

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

Move/Logic Instructions
(MOV, MVM, BTD, CLR, AND, OR, XOR, NOT,)
Introduction
The move instructions modify and move bits.
If you want to: copy the value in one word to another word copy a specific part of a 32-bit value by masking the rest of the value move bits within a word or between words set all the bits in a word to zero Use this instruction: MOV MVM BTD CLR See page: 6-2 6-3 6-5 6-7

If you move a REAL value to a SINT, INT, or DINT tag, the controller rounds the value to fit within the tag. The controller does not properly round numbers less than -1. The logical instructions perform logical operations on bits.
If you want to: perform a bitwise AND operation perform a bitwise OR operation perform a bitwise, exclusive OR operation perform a bitwise NOT operation Use this instruction: AND OR XOR NOT See page: 6-8 6-10 6-12 6-14

Publication 1756-6.4.1 review January 1998 - preliminary

6-2

Move/Logic Instructions

Move (MOV)
Description: The MOV instruction is an output instruction that copies the Source to a Destination. The Source remains unchanged. As long as the rung is true, the MOV instruction moves the data each program scan.

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets sets if overflow generated during REAL-to-integer conversions; otherwise resets sets if result is zero; otherwise resets sets if result is negative; otherwise resets

Operands:
Operand: Source Destination Valid Types: immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true 0.52 0.71 false 0.16 0.17

MOV Example:

If the preceding instructions are true, the controller copies the data in value_1 to value_2.

Publication 1756-6.4.1 review January 1998 - preliminary

Move/Logic Instructions

6-3

Masked Move (MVM)


Description: The MVM instruction is an output instruction that copies the Source to a Destination and allows portions of the data to be masked. The Source remains unchanged. As long as the rung is true, the MVM instruction moves data each program scan. The MVM instruction uses a Mask to either pass or block Source data bits. The Mask passes data when the Mask bits are set (1); the Mask blocks data when the Mask bits are reset (0). The Mask must be the same word size as the Source and Destination.

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets always resets sets if result is zero; otherwise resets sets if result is negative; otherwise resets

Operands:
Operand: Source Mask Destination Valid Types: immediate or tag SINT, INT, or DINT immediate or tag SINT, INT, or DINT tag SINT, INT, or DINT

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 2.22 na na
executes does not execute executes

false 0.17 na

Publication 1756-6.4.1 review January 1998 - preliminary

6-4

Move/Logic Instructions

MVM Example:

If the preceding instructions are true, the controller copies data in value_1 to value_2 while allowing data to be masked (a 0 masks the data in value_1).

value_3 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 before MVM instruction value_1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 mask_1 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 value_3 0 1 0 1 1 1 1 1 0 1 0 1 1 1 1 1 0 1 0 1 1 1 1 1 0 1 0 1 1 1 after MVM instruction

Publication 1756-6.4.1 review January 1998 - preliminary

Move/Logic Instructions

6-5

Bit Field Distribute (BTD)


Description: The BTD instruction is an output instruction that moves as many as 32 bits of data within a word or between words. The Source remains unchanged. The instruction writes over the Destination with the specified bits. If the length of the bit field extends beyond the Destination word, the controller does not save the overflow bits. These overflow bits are lost; they do not wrap up into the next word. On each program scan, when the rung that contains the BTD instruction is true, the controller moves the bit field from the Source to the Destination. To move data within a word, enter the same tag for the Source and Destination. Operands:
Operand: Source the tag of the bits to move Source bit the number of the bit (lowest bit number) from where to start the move Destination the tag of where to move the bits Destination bit the number of the bit (lowest bit number) where the controller starts copying the bits from the Source Length the number of bits to move immediate (1-32) immediate (0-31) tag DINT immediate (0-31) Valid Types: immediate or tag DINT

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 3.00 na na
executes does not execute executes

false 0.16 na

Publication 1756-6.4.1 review January 1998 - preliminary

6-6

Move/Logic Instructions

BTD Example:
example 1 If the preceding instructions are true, the controller moves bits within value_1.

destination bit

source bit

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

example 2

If the preceding instructions are true, the controller moves bits within value_1.

source bit

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

destination bit

value_2 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

Publication 1756-6.4.1 review January 1998 - preliminary

Move/Logic Instructions

6-7

Clear (CLR)
Description: Use the CLR instruction to set all the bits of an element to zero.

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets always resets always resets always resets

Operands:
Operand: Destination Valid Types: tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) DINT REAL
executes does not execute executes

Description: true 0.41 0.40 false 0.16 0.18

Execution

CLR Example:

If the preceding instructions are true, the controller sets all the bits of value_1 to 0.

Publication 1756-6.4.1 review January 1998 - preliminary

6-8

Move/Logic Instructions

Bitwise AND (AND)


Description: Use the AND instruction to perform a bitwise AND operation using the bits in two source tags. The controller evaluates the AND operation:
If Source A is: 0 1 0 1 And Source B is: 0 0 1 1 The Destination is: 0 0 0 1

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets always resets sets if the result is zero; otherwise resets sets if most-significant bit is set; otherwise resets

Operands:
Operand: Source A Source B Destination Valid Types: immediate or tag SINT, INT, DINT, or REAL immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

Publication 1756-6.4.1 review January 1998 - preliminary

Move/Logic Instructions

6-9

AND Example:

If the preceding instructions are true, the controller performs an AND operation on value_1 and value_2 and places the result in value_3.

value_1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 value_2 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 value_3 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0

Publication 1756-6.4.1 review January 1998 - preliminary

6-10

Move/Logic Instructions

Bitwise OR (OR)
Description: Use the OR instruction to perform a bitwise OR operation using the bits in two source tags. The controller evaluates the OR operation:
If Source A is: 0 1 0 1 And Source B is: 0 0 1 1 The Destination is: 0 1 1 1

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets always resets sets if the result is zero; otherwise resets sets if most-significant bit is set; otherwise resets

Operands:
Operand: Source A Source B Destination Valid Types: immediate or tag SINT, INT, DINT, or REAL immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

Publication 1756-6.4.1 review January 1998 - preliminary

Move/Logic Instructions

6-11

OR Example:

If the preceding instructions are true, the controller performs an OR operation on value_1 and value_2 and places the result in value_3.

value_1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 value_2 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 value_3 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Publication 1756-6.4.1 review January 1998 - preliminary

6-12

Move/Logic Instructions

Bitwise Exclusive OR (XOR)


Description: Use the XOR instruction to perform a bitwise XOR operation using the bits in two source tags. The controller evaluates the XOR operation:
If Source A is: 0 1 0 1 And Source B is: 0 0 1 1 The Destination is: 0 1 1 0

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets always resets sets if the result is zero; otherwise resets sets if most-significant bit is set; otherwise resets

Operands:
Operand: Source A Source B Destination Valid Types: immediate or tag SINT, INT, DINT, or REAL immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

Publication 1756-6.4.1 review January 1998 - preliminary

Move/Logic Instructions

6-13

XOR Example:

If the preceding instructions are true, the controller performs an XOR operation on value_1 and value_2 and places the result in value_3.

value_1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 value_2 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 value_3 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1

Publication 1756-6.4.1 review January 1998 - preliminary

6-14

Move/Logic Instructions

Bitwise NOT (NOT)


Description: Use the NOT instruction to perform a bitwise NOT operation using the bits in two source tags. The controller evaluates the NOT operation:
If Source is: 0 1 The Destination is: 1 0

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets always resets sets if the result is zero; otherwise resets sets if most-significant bit is set; otherwise resets

Operands:
Operand: Source Destination Valid Types: immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

Publication 1756-6.4.1 review January 1998 - preliminary

Move/Logic Instructions

6-15

NOT Example:

If the preceding instructions are true, the controller performs a NOT operation on value_1 and places the result in value_3.

value_1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 value_3 1 1 1 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0

Publication 1756-6.4.1 review January 1998 - preliminary

6-16

Move/Logic Instructions

Notes:

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

File Concepts
Introduction
This chapter presents the concepts of manipulating arrays (files) of data using the file instructions. The controller treats files as arrays of data. You can create arrays as large as three dimensions. For example, an application has an array of integers (SINT, INT, or DINT): first dimension elements 0-6 second dimension elements 0-4 third dimension elements 0-21

In this example, the array (file) has a total of 770 integers (22 x 5 x 7). If the data structure name is array1, any instruction referencing array1, has 770 integers. To access a specific element within the array, specify the coordinates as array_name[first_dim,second_dim, third_dim]. For example, enter array1[4,3,20]. The File/Misc instructions in the programming software manipulate arrays of data. These instructions are: average (AVE) copy (COP) file arithmetic and logic (FAL) file fill (FLL) file search (FSC) sort (SRT) standard deviation (STD)

Publication 1756-6.4.1 review January 1998 - preliminary

7-2

File Concepts

Manipulating Arrays

Typical array operations include: copying data from a: source word to a destination array source array to a destination array source array to a destination element operating on data from multiple sources, such as: source element source arrays storing the result in a: destination element destination array Use CONTROL.POS as the destination or expressions. It identifies the first element of the array for the operation.
FAL File Arith/logical Control control1 Length 4 Position 0 Mode ALL Destination array1[a, control1.pos, c] Expression integer_a

Element-to-Array Operation

FAL File Arith/logical Control control1 Length 4 Position 0 Mode ALL Destination integer_a Expression array1[a, control1.pos, c]

Array-to-Element Operation

FAL File Arith/logical Control control1 Length 4 Position 0 Mode ALL Destination array1[a, control1.pos, c] Expression array2[control1.pos, b, c]

Array-to-Array Operation

Publication 1756-6.4.1 review January 1998 - preliminary

File Concepts

7-3

element to array

array to array

array to word

(array * element) to array

(element * array) to element

(element * element) to array

(array * array) to element

(element * array) to array

(array * element) to element

(array * array) to array

16617

Publication 1756-6.4.1 review January 1998 - preliminary

7-4

File Concepts

Using the Control Structure

The control structure controls the operation of the file instruction. The control structure stores status bit, length (.LEN), and position (.POS) values.
CONTROL structure
bit number 31 30 29 28 27 26 25 24 EN EU DN EM ER UL IN FD 16 15 0

length value (.LEN) position value (.POS)

Control bit or word: .EN bit .EU bit

Description: The enable bit indicates that the instruction is enabled. The enable unload bit indicates unload instruction is enabled. Only used with the FFU and LFU instructions.

.DN bit .EM bit

The done bit indicates that the file operation is complete. The empty bit indicates that the stack is empty Only used with the FFL and LFL instructions.

.ER bit .UL bit

The error bit indicates when the file operation generates an overflow. The unload bit is the instructions output. The .UL bit stores the status of the bit removed from the array each time the instruction is enabled. Only used with the BSR and BSL instructions.

.IN bit

The inhibit bit indicates that the controller detected a true comparison using an FSC instruction. You must reset this bit to continue the search operation. This bit is only used by the FSC instruction. The found bit indicates that the controller detected a true comparison using an FSC instruction. This bit is only used by the FSC instruction. The length word specifies the number of elements in the array on which the file instruction operates. The position word identifies the current element that the controller is accessing. You generally enter a zero to start at the beginning of the current dimension of the array.

.FD bit .LEN word .POS word

You can use the RES instruction to reset the status bits and clear the .POS word.

Selecting Mode of Operation

The mode tells the controller how to distribute the block operation over one or more program scans. Select from:
If you want to: operate on the entire file before continuing on to the next rung distribute file operation over a number of program scans enter the number of words or operate on per scan (1-2147483647) manipulate one word of the file each time the rung goes from false to true Incremental Select this mode: All Numerical

Publication 1756-6.4.1 review January 1998 - preliminary

File Concepts

7-5

All mode
In All mode, the entire file is operated on before continuing on to the next rung of logic. The operation begins when the rung goes from false to true. The position (.POS) value in the control structure points to the word in the array that the instruction is currently using. Operation stops when the function completes or the controller detects an error.
Data file one scan

16639

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 and the .EN bit are reset and the .POS value is zeroed when the rung conditions are no longer true. Only then can another operation be triggered by a false-to-true transition of the rung.
one program scan condition of the rung that controls the instruction

.EN bit

.DN bit controller resets status bits and sets .POS value to zero scan of the instruction

operation complete

40010

Publication 1756-6.4.1 review January 1998 - preliminary

7-6

File Concepts

Numerical mode
Numerical mode distributes the array operation over a number of program scans. You enter the number of words per scan to operate on each program scan. Execution is triggered when the rung condition goes from false to true. Once triggered, the instruction is executed each time the rung is scanned for the number of program scans necessary to complete operation on the entire array. Once triggered, rung logic can change repeatedly without interrupting execution of the instruction.
one scan

second scan

next scan

16641

Important: Avoid using the results of a file instruction operating in numerical mode until the .DN bit is set because the data is incomplete.

Publication 1756-6.4.1 review January 1998 - preliminary

File Concepts

7-7

The following timing diagram shows the relationship between status bits and instruction operation. When the instruction execution is complete, the .DN it is set.
rung is true at completion multiple program scans condition of the rung that controls the instruction .EN bit .DN bit scan of the instruction operation complete controller resets status bits and sets .POS value to zero operation complete controller resets status bits and sets .POS value to zero
40013

rung is false at completion multiple program scans

If the rung is true at completion, the .EN and .DN bit are not reset until the rung is no longer true. When the rung goes false, these bits are reset and the .POS value is zeroed. If the rung is false at completion, the .EN bit is reset immediately. One scan after the .EN bit is reset, the .DN bit is reset and the .POS value is zeroed.

Incremental mode
Incremental mode manipulates one word of the array each time the rung goes from false to true.

1st rung enable 2nd rung enable 3rd rung enable

last rung enable

16643

Publication 1756-6.4.1 review January 1998 - preliminary

7-8

File Concepts

The following timing diagram shows the relationship between status bits and instruction operation. Execution occurs only in a program scan in which the rung goes from false to true. Each time this occurs, only one word of the array is manipulated. If the rung remains true for more than one program scan, the instruction is not executed in subsequent scans after the rung transition.
one or more program scan condition of the rung that controls the instruction .EN bit

.DN bit scan of the instruction

controller resets .EN bit operation complete controller resets status bits and sets .POS value to zero
40014

The .EN bit is set when rung logic is true. The .DN bit is set when the last word in the array has been manipulated. When the last word has been manipulated and the rung goes from false to true, the .EN and .DN bits are reset and the .POS value is zeroed. Incremental mode compared to numerical mode with 1word per scan The difference between incremental mode and numerical mode at a rate of one word per scan is: Numerical mode with any number of words per scan requires only one false-to-true rung transition to start execution. The instruction continues to execute the specified number of words each program scan until completion regardless of rung transition. Incremental mode required a false-to-true rung transition for each word in the array.

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

File/Misc. Instructions
(FAL, FSC, COP, FLL, AVE, SRT, STD)
Introduction
The file/miscellaneous instructions operate on arrays of data.
If you want to: perform arithmetic, logic, shift, and function operations on array data search for and compare array data copy the contents of one array into another array fill an array with specific data calculate the average of a set of values sort one dimension of array data into ascending order calculate the standard deviation of a set of values Use this instruction: FAL FSC COP FLL AVE SRT STD See page: 8-4 8-7 8-10 8-12 8-13 8-15 8-17

If you move a REAL value to a SINT, INT, or DINT tag, the controller rounds the value to fit within the tag. The controller does not properly round numbers less than -1.

Publication 1756-6.4.1 review January 1998 - preliminary

8-2

File/Misc. Instructions

Using the File/Misc. Instructions

The control structure controls the operation of the file instruction. The control structure stores status bit, length (.LEN), and position (.POS) values.
CONTROL structure

bit number

31 30 29 28 27 26 25 24 EN EU DN EM ER UL IN FD

16 15

length value (.LEN) position value (.POS)

Control bit or word: .EN bit .EU bit .DN bit .EM bit .ER bit .UL bit .IN bit .FD bit .LEN word .POS word

Description: The enable bit indicates that the instruction is enabled. not used The done bit indicates that the file operation is complete. not used The error bit indicates when the file operation generates an overflow. not used not used not used The length word specifies the number of elements in the array on which the file instruction operates. The position word identifies the current element that the controller is accessing. You generally enter a zero to start at the beginning of the current dimension of the array.

You can use the RES instruction to reset the status bits and clear the .POS word.

Using arithmetic status flags


Some of the file/miscellaneous instructions use arithmetic status flags. To access arithmetic status flags, use an XIC or XIO instruction with one of the status keywords.
Use this keyword: For this status flag: S:C S:N S: V S:Z carry sign (result is negative) overflow zero With this read/write access: read/write read/write read/write read/write

Use the RES instruction to clear the status flags.

Publication 1756-6.4.1 review January 1998 - preliminary

File/Misc. Instructions

8-3

Specifying dimensions within an array


The controller supports arrays of 1, 2, or 3 dimensions. Each time you enter an array tag for an instruction, you must also specify which dimension the instruction uses for its operations. You specify the active dimension of the array by using the .POS value of the CONTROL structure for the instruction.
Example array tag: array_1[control_1.pos] Description: This is a single dimension array tag. The tag control_1.pos identifies the current position within the array. This is a 2-dimensional array. The instruction would operate on the second dimension. You can enter an immediate value or tag to identify the first dimension. This is a 3-dimensional array. The instruction would operate on the third dimension. You can enter an immediate value or tag to identify the first and second dimensions.

array_2[0, control_2.pos]

array_3[0,1,control_3.pos]

The .POS value provides a sequential progression through the array. You could also use another tag or an immediate value to specify the position within the array. In this case, you would have to increment the position value. Some file instructions operate on the right-most dimension only. Be careful when using these instructions with multiple-dimensional arrays to make sure the instruction operates on the data you intend. See the following chapters of file instructions to make sure you understand how the instructions operate.

Publication 1756-6.4.1 review January 1998 - preliminary

8-4

File/Misc. Instructions

File Arithmetic and Logic (FAL)


Description: The FAL instruction performs copy, arithmetic, logic, and function operations on data stored in an array. The FAL instruction performs the same operations on arrays as the CPT instruction performs on elements. The FAL instruction is an output instruction that performs the operations defined by the source tags and operators in the Expression. The instruction stores the results in the Destination. Select the Mode to determine how the controller distributes the operations over program scans. You can use this instruction to perform operations such as: zero an array copy data from one array to another convert data from one data type to another (copy from one array to a second array of a different data type) perform computations on data stored in an array unload an array of error codes one at a time for display

Valid operations
Operator: + * / = ** ACS AND Description: add subtract/negate multiply divide equal exponent (x to y) arc cosine logical AND Operator: ASN ATN COS DEG FRD LN LOG MOD Description: arc sine arc tangent cosine degree BCD to binary natural log log base 10 modulo divide Operator: NOT OR RAD SIN SQR TAN TOD XOR Description: logical complement logical OR degrees to radians sine square root tangent binary to decimal exclusive OR

Operands:
Operand: Control Length number of elements in the array Position current element in the array Mode Destination INC, ALL, or 1-33554432 tag SINT, INT, DINT, or REAL immediate (1-33554432) Valid Types: tag CONTROL immediate (1-33554432)

Publication 1756-6.4.1 review January 1998 - preliminary

File/Misc. Instructions Operand: Expression Valid Types:

8-5

arithmetic expression consisting of tags and/or immediate values separated by operators CONTROL.POS identifies the dimension to vary (array1[A, CONTROL.POS, C]

Control status:
Control bit or word: .EN bit Description: The enable bit is set when the rung goes from false to true. It indicates that the instruction is enabled. In Incremental mode, the .EN bit follows the rung status. In Numerical and All mode, the .EN bit remains set until the instruction completes its operation, regardless of the rung status. The .EN bit is reset when the rung goes false, but only after the controller sets the .DN bit. .DN bit The done bit is set when the instruction has operated on the last element. In Numerical mode, if the Expression is false at completion, the controller resets the .DN bit one program scan after the operation is complete. If the Expression is true at complete, the controller reset the .DN bit when the rung goes false. .ER bit The error bit is set when the operation generates an overflow. The instruction stops executing until the program resets the .ER bit. When the controller detects an error, the .POS value stores the position of element that faulted. The length value specifies the number of elements in the array. The position value identifies the element that the controller is currently manipulating.

.LEN word .POS word

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
does not execute does not execute executes

Description: true false

Publication 1756-6.4.1 review January 1998 - preliminary

8-6

File/Misc. Instructions

FAL Example:

array-to-array copy

If the preceding instructions are true, the controller copies each element of array_1 into the same positions within array_2.

word-to-array copy

If the preceding instructions are true, the controller copies the value of element value_1 into the first 10 positions of array_2.

arithmetic array operation

If the preceding instructions are true, the controller divides the value in the current position of array_1 with the value in the current position of array_2.

Publication 1756-6.4.1 review January 1998 - preliminary

File/Misc. Instructions

8-7

File Search and Compare (FSC)


Description: The FSC instruction performs search and compare operations. The FSC instruction performs the same operations on arrays as the CMP instruction performs on elements. The FSC instruction is an output instruction that compares values in source arrays. element by element, for the operations you specify in the Expression. When the controller finds the specified comparison true, it sets the found (.FD) bit and records the position in the .POS word. The inhibit (.IN) bit is set to prevent further searching of arrays. Your logic must examine the .FD bit and the .POS value to take appropriate action. Reset the .IN bit after a true comparison is found so the instruction can continue. Select the Mode to determine how the controller distributes the operations over program scans. You can use this instruction to perform operations such as: set high and low process alarms for multiple analog inputs compare batch variables against a reference file before starting a batch operation

Valid Comparisons for Use in the Expression


Operator: none 0 + * | ** = <> < Description: copy clear add subtract/negate multiply divide exponent (x to y) equal not equal less than Operator: <= > >= ACS AND ASN ATN COS DEG FRD Description: less than or equal greater than greater than or equal arc cosine logical AND arc sine arc tangent cosine degree BCD to binary Operator: LN LOG MOD NOT OR RAD SIN SQR TAN TOD XOR Description: natural log log base 10 modulo divide logical complement logical OR degrees to radians sine square root tangent binary to decimal exclusive OR

The expression must contain at least one of these operations: =, <>, <, <=, >, or >=

Publication 1756-6.4.1 review January 1998 - preliminary

8-8

File/Misc. Instructions

Operands:
Operand: Control Length number of elements in the array Position current element in the array Mode Expression INC, ALL, or 1-33554432 arithmetic expression consisting of tags and/or immediate values separated by operators CONTROL.POS identifies the dimension to vary (array1[A, CONTROL.POS, C] immediate (1-33554432) Valid Types: tag CONTROL immediate (1-33554432)

Control status:
Control bit or word: .EN bit Description: The enable bit is set when the rung goes from false to true. It indicates that the instruction is enabled. In Incremental mode, the .EN bit follows the rung status. In Numerical and All mode, the .EN bit remains set until the instruction completes its operation, regardless of the rung status. The .EN bit is reset when the rung goes false, but only after the controller sets the .DN bit. .DN bit The done bit is set when the instruction has operated on the last element. In Numerical mode, if the Expression is false at completion, the controller resets the .DN bit one program scan after the operation is complete. If the Expression is true at complete, the controller reset the .DN bit when the rung goes false. .ER bit The error bit is set when the operation generates an overflow. The instruction stops executing until the program resets the .ER bit. When the controller detects an error, the .POS value stores the position of element that faulted. The length value specifies the number of elements in the array. The position value identifies the element that the controller is currently manipulating.

.LEN word .POS word

Publication 1756-6.4.1 review January 1998 - preliminary

File/Misc. Instructions

8-9

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
does not execute does not execute executes

Description: true false

FSC Example:

If the preceding instructions are true, the controller determines whether the first 10 elements in array_1 are not equal to the first 10 elements in array_2.

Publication 1756-6.4.1 review January 1998 - preliminary

8-10

File/Misc. Instructions

File Copy (COP)


Description: The COP instruction is an output instruction that copies the values in the Source to the Destination. Use this instruction to copy from one tag of any data type to another tag of the same or a different data type. The Source tag must specify the array element of the first data item to be copied; the Destination tag must specify the array element where the Source is to be copied. The Source remains unchanged. The Length determines how many elements to copy. The COP instruction does not use status bits. If you need an enable bit, program a parallel output that uses a storage tag. The COP instruction does not write over array boundaries. Any overflow data is lost. For best results, the Source and Destination should be the same type. Operands:
Operand: Source Destination Length number of elements in the Source Valid Types: tag array any type tag array any type immediate or tag SINT, INT, or DINT (1-33554432)

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

COP Example:

Publication 1756-6.4.1 review January 1998 - preliminary

File/Misc. Instructions

8-11

If the preceding instructions are true, the controller copies the first 10 elements of the second dimension of array_4 into the first 10 elements of the second dimension of array_5.

Publication 1756-6.4.1 review January 1998 - preliminary

8-12

File/Misc. Instructions

File Fill (FLL)


Description: The FLL instruction is an output instruction that fills the elements of an array with the Source value. Use this instruction to fill the elements of an array with the same value. The Destination tag must specify the first array element to receive the Source value. The Source remains unchanged. The Length determines the number of elements in the Destination array to fill with the Source value. The FLL instruction does not use status bits. If you need an enable bit, program a parallel output that uses a storage tag. The FLL instruction does not write over array boundaries. Any overflow data is lost. No data conversion occurs if the Source and the Destination are different data types. Operands:
Operand: Source Destination Length number of elements in the array Valid Types: immediate or tag SINT, INT, DINT, or REAL tag array any type immediate or tag SINT, INT, or DINT (1-33554432)

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

FLL Example:
If the preceding instructions are true, the controller copies the value of value_1 into the first 10 elements of the second dimension of array_4.

Publication 1756-6.4.1 review January 1998 - preliminary

File/Misc. Instructions

8-13

File Average (AVE)


Description: The AVE instruction calculates the average of a set of values. When the rung goes from false to true, the value at the current position is added to the next value, which is added to the next value, and so on. Each time another value is added, the .POS value is incremented. The final sum is divided by the number of values that were added and the result is stored in the Destination.

Arithmetic status flags


This flag: carry overflow zero sign The controller: always resets sets if overflow generated; otherwise resets sets if result is zero; otherwise resets sets if result is negative; otherwise resets

If an overflow occurs, the controller stops the calculation, sets the .ER bit, and the Destination remains unchanged. The .POS value identifies the element that caused the overflow. When you clear the .ER bit, the controller resets the .POS value to zero and the average is recalculated. Operands:
Operand: Array Dimension to vary Destination Control Length number of elements in the array Position current element in the array immediate (1-33554432) Valid Types: tag array SINT, INT, DINT, or REAL 0, 1, 2 tag SINT, INT, DINT, or REAL (must match array type) tag CONTROL immediate (1-33554432)

Publication 1756-6.4.1 review January 1998 - preliminary

8-14

File/Misc. Instructions

Control status:
Control bit or word: .EN bit .DN bit .ER bit .LEN word .POS word Description: The enable bit is set when the rung goes from false to true. It indicates that the instruction is enabled. The instruction follows the rung status. The done bit is set after the instruction finishes operations. After the rung goes false, the controller resets the .DN bit on the next false-to-true rung transition. The error bit is set when the operation generates an overflow. The instructions stops the calculation until the logic resets the .ER bit. The length value specifies the number of elements in the array. The position value identifies the element that the controller is currently manipulating.

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
does not execute does not execute executes

Description: true false

AVE Example:

If the preceding instructions are true, the controller averages the first 10 elements of array_2 and stores the result in float_value_1.

Publication 1756-6.4.1 review January 1998 - preliminary

File/Misc. Instructions

8-15

File Sort (SRT)


Description: The SRT instruction sorts a set of values in one dimension of the Array into ascending order. This instruction executes on a false-to-true rung transition. Make sure the Length you specify does not cause the tag to exceed array boundaries.

Operands:
Operand: Array Dimension to vary Control Length number of elements in the array Position current element in the array immediate (1-33554432) Valid Types: tag array SINT, INT, DINT, or REAL 0, 1, 2 tag CONTROL immediate (1-33554432)

Control status:
Control bit or word: .EN bit .DN bit .LEN word .POS word Description: The enable bit is set when the rung goes from false to true. It indicates that the instruction is enabled. The instruction follows the rung status. The done bit is set after the instruction finishes operations. After the rung goes false, the controller resets the .DN bit on the next false-to-true rung transition. The length value specifies the number of elements in the array. The position value identifies the element that the controller is currently manipulating.

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
does not execute does not execute executes

Description: true false

Publication 1756-6.4.1 review January 1998 - preliminary

8-16

File/Misc. Instructions

SRT Example:

If the preceding instructions are true, the controller sorts the first 10 elements of array_2 into ascending order.

Publication 1756-6.4.1 review January 1998 - preliminary

File/Misc. Instructions

8-17

File Standard Deviation (STD)


Description: The STD instruction calculates the standard deviation of a set of values in one dimension of the Array and stores the result in the Destination. This instruction executes on a false-to-true rung transition. The standard deviation is calculated according to this formula:
Standard Deviation =

SUM ( xi AVE ( xi ) ) ---------------------------------------------------(N 1)

Where: SUM( ) = summation of the enclosed variables AVE( ) = average of the enclosed variables xi = variable elements in the array N = number of elements in the array

Make sure the Length you specify does not cause the tag to exceed array boundaries.

Arithmetic status flags


This flag: carry overflow zero sign The controller: always resets sets if overflow is generated; otherwise resets sets if result is zero; otherwise resets always resets

If an overflow occurs, the controller stops the calculation, sets the .ER bit, and the Destination remains unchanged. The .POS value identifies the element that caused the overflow. When you clear the .ER bit, the controller resets the .POS value to zero and the average is recalculated. Operands:
Operand: Array Dimension to vary Destination Valid Types: tag array SINT, INT, DINT, or REAL 0, 1, 2 tag SINT, INT, DINT, or REAL (must match array type) Control Length number of elements in the array Position current element in the array immediate (1-33554432) tag CONTROL immediate (1-33554432)

Publication 1756-6.4.1 review January 1998 - preliminary

8-18

File/Misc. Instructions

Control status:
Control bit or word: .EN bit .DN bit .ER bit .LEN word .POS word Description: The enable bit is set when the rung goes from false to true. It indicates that the instruction is enabled. The instruction follows the rung status. The done bit is set after the instruction finishes operations. After the rung goes false, the controller resets the .DN bit on the next false-to-true rung transition. The error bit is set when the operation generates an overflow. The instructions stops the calculation until the logic resets the .ER bit. The length value specifies the number of elements in the array. The position value identifies the element that the controller is currently manipulating.

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
does not execute does not execute executes

Description: true false

STD Example:

If the preceding instructions are true, the controller finds the standard deviation of the first 10 elements of the second dimension of array_4 and stores the result in float_value_1.

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

File/Shift Instructions
(BSL, BSR, FFL, FFU, LFL, LFU)
Introduction
Use the file/shift instructions to track the flow of parts and information.
If you want to: Load bits into, shift bits through, and unload bits from a bit array one bit at a time, such as for tracking bottles through a line where each bit represents a bottle. Load and unload values in the same order, such as for tracking parts through an assembly line where parts are represented by values that have a part numbers and assembly code. Load and unload values in reverse order, such as tracking stacked inventory in a warehouse where goods are represented by a serial numbers and inventory codes. Use this instruction: BSL BSR See page: 9-3 9-5

FFL FFU

9-7 9-9

LFL LFU

9-11 9-13

Publication 1756-6.4.1 review January 1998 - preliminary

9-2

File/Shift Instructions

Using the File/Shift Instructions

The control structure controls the operation of the shift instruction.


CONTROL structure

bit number

31 30 29 28 27 26 25 24
EN EU DN EM ER UL IN FD

16 15

length value (.LEN) position value (.POS)

Control bit or word: .EN bit .EU bit

Description: The enable bit indicates that the instruction is enabled. The enable unload bit indicates unload instruction is enabled. Only used with the FFU and LFU instructions.

.DN bit .EM bit

The done bit indicates that the file operation is complete. The empty bit indicates that the stack is empty Only used with the FFL and LFL instructions.

.ER bit .UL bit

The error bit indicates when the file operation generates an overflow. The unload bit is the instructions output. The .UL bit stores the status of the bit removed from the array each time the instruction is enabled. Only used with the BSR and BSL instructions.

.IN bit

The inhibit bit indicates that the controller detected a true comparison using an FSC instruction. You must reset this bit to continue the search operation. This bit is only used by the FSC instruction. The found bit indicates that the controller detected a true comparison using an FSC instruction. This bit is only used by the FSC instruction. The length word specifies the number of elements in the array on which the file instruction operates. The position word identifies the current element that the controller is accessing. You generally enter a zero to start at the beginning of the current dimension of the array.

.FD bit .LEN word .POS word

Publication 1756-6.4.1 review January 1998 - preliminary

File/Shift Instructions

9-3

Bit Shift Left (BSL)


Description: Use the BSL instruction to shift all bits within the specified array one position left with each false-to-true rung transition. This instruction manipulates the right-most dimension only (for example, dimension 2 in array1[0,1,2]).

Operands:
Operand: Array Control Source bit Length number of bits in the array Valid Types: tag array DINT tag CONTROL tag BOOL immediate (1-2147483647)

Control status:
Control bit or word: .EN bit .DN bit .LEN word .POS word Description: The enable bit is set when the rung goes from false to true. It indicates that the instruction is enabled. The done bit is set to indicate that the array shifted one position. The length value specifies the number of bits in the array. The position value identifies the bit that the controller is currently manipulating.

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
does not execute does not execute executes

Description: true false

Publication 1756-6.4.1 review January 1998 - preliminary

9-4

File/Shift Instructions

BSL Example:

15 14 13 12 11 10 9 unload bit

5 4

input_1

If the preceding instructions are true, the controller starts the bit-shift-left operation on array_dint.
16658

Publication 1756-6.4.1 review January 1998 - preliminary

File/Shift Instructions

9-5

Bit Shift Right (BSR)


Description: Use the BSR instruction to shift all bits within the specified array one position right with each false-to-true rung transition. This instruction manipulates the right-most dimension only (for example, dimension 2 in array1[0,1,2]).

Operands:
Operand: Array Control Source bit Length number of bits in the array Valid Types: tag array DINT tag CONTROL tag BOOL immediate (1-2147483647)

Control status:
Control bit or word: .EN bit .DN bit .LEN word .POS word Description: The enable bit is set when the rung goes from false to true. It indicates that the instruction is enabled. The done bit is set to indicate that the array shifted one position. The length value specifies the number of bits in the array. The position value identifies the bit that the controller is currently manipulating.

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
does not execute does not execute executes

Description: true false

Publication 1756-6.4.1 review January 1998 - preliminary

9-6

File/Shift Instructions

BSR Example:

unload bit input_1 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

If the preceding instructions are true, the controller starts the bit-shift-right operation on array_dint.
16659

Publication 1756-6.4.1 review January 1998 - preliminary

File/Shift Instructions

9-7

FIFO Load (FFL)


Description: Use the FFL instruction with the FFU instruction to store and retrieve data in a first-in/first-out order. The FFL instruction retrieves the Source value and loads it into the next position in the stack. This instruction manipulates the right-most dimension only (for example, dimension 2 in array1[0,1,2]). Use the same Control, Length, and Position for the FFU/FFL pair of instructions. Operands:
Operand: Source tag that stores the next in value to the stack FIFO Control Length number of elements in the array Position current position in the array immediate (0-33554432) usually enter 0 tag array DINT or REAL tag CONTROL immediate (1-33554432) Valid Types: immediate or tag SINT, INT, or DINT

Control status:
Control bit or word: .EN bit Description: The enable load bit is set when the rung goes from false to true. It indicates that the instruction is enabled. The instruction follows the rung status. During prescan, this bit is set to prevent a false load when the program scan begins. .DN bit .EM bit .LEN word .POS word The done bit is set to indicate that the stack is full. The .DN bit inhibits loading the stack until there is room. The empty bit is set to indicate that the array is empty. Do not enable the FFU instruction if the .EM bit is set. The length value specifies the number of elements in the array. The position value identifies the element that the controller is currently manipulating.

Publication 1756-6.4.1 review January 1998 - preliminary

9-8

File/Shift Instructions

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
does not execute does not execute executes

Description: true false

FFL/FFU Example:

array_dint destination (value_2)

FFU removes data from the stack

source (value_1) FFL places data in the stack

16660

If the preceding instructions are true, the controller starts the FIFO operation on array_dint.

Publication 1756-6.4.1 review January 1998 - preliminary

File/Shift Instructions

9-9

FIFO Unload (FFU)


Description: Use the FFU instruction with the FFL instruction to store and retrieve data in a first-in/first-out order. The FFU instruction unloads the value from position 0 of the stack and stores that value in the Destination. This instruction manipulates the right-most dimension only (for example, dimension 2 in array1[0,1,2]). Use the same Control, Length, and Position for the FFU/FFL pair of instructions. Operands:
Operand: FIFO Destination tag that stores the value that exits from the stack Control Length number of elements in the array Position current position in the array immediate (0-33554432) usually enter 0 tag CONTROL immediate (1-33554432) Valid Types: tag array DINT or REAL tag DINT

Control status:
Control bit or word: .EU bit .DN bit .LEN word .POS word Description: The enable unload bit is set when the rung is true. This instruction indicates that the instruction is enabled. The done bit is set to indicate that the stack is full. The .DN bit inhibits loading the stack until there is room. The length value specifies the number of elements in the array. The position value identifies the element that the controller is currently manipulating.

Publication 1756-6.4.1 review January 1998 - preliminary

9-10

File/Shift Instructions

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
does not execute does not execute executes

Description: true false

FFL/FFU Example:

array_dint destination (value_2)

FFU removes data from the stack

source (value_1) FFL places data in the stack

16660

If the preceding instructions are true, the controller starts the FIFO operation on array_dint.

Publication 1756-6.4.1 review January 1998 - preliminary

File/Shift Instructions

9-11

LIFO Load (LFL)


Description: Use the LFL instruction with the LFU instruction to store and retrieve data in a last-in/first-out order. The LFL instruction retrieves the Source value and loads it into the next position in the stack. This instruction manipulates the right-most dimension only (for example, dimension 2 in array1[0,1,2]). Use the same Control, Length, and Position for the LFU/LFL pair of instructions. Operands:
Operand: Source tag that stores the next in value to the stack LIFO Control Length number of elements in the array Position current position in the array immediate (0-33554432) usually enter 0 tag array DINT or REAL tag CONTROL immediate (1-33554432) Valid Types: immediate or tag SINT, INT, or DINT

Control status:
Control bit or word: .EN bit Description: The enable load bit is set when the rung goes from false to true. It indicates that the instruction is enabled. The instruction follows the rung status. During prescan, this bit is set to prevent a false load when the program scan begins. .DN bit .EM bit .LEN word .POS word The done bit is set to indicate that the stack is full. The .DN bit inhibits loading the stack until there is room. The empty bit is set to indicate that the array is empty. Do not enable the FFU instruction if the .EM bit is set. The length value specifies the number of elements in the array. The position value identifies the element that the controller is currently manipulating.

Publication 1756-6.4.1 review January 1998 - preliminary

9-12

File/Shift Instructions

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
does not execute does not execute executes

Description: true false

LFL/LFU Example:

array_dint

source (value_1) LFL places data in the stack

destination (value_2)

LFU removes data from the stack

16621

If the preceding instructions are true, the controller starts the LIFO operation on array_dint.

Publication 1756-6.4.1 review January 1998 - preliminary

File/Shift Instructions

9-13

LIFO Unload (LFU)


Description: Use the LFU instruction with the LFL instruction to store and retrieve data in a last-in/first-out order. The LFU instruction unloads the last-entered value from the stack and stores that value in the Destination. This instruction manipulates the right-most dimension only (for example, dimension 2 in array1[0,1,2]). Use the same Control, Length, and Position for the LFU/LFL pair of instructions. Operands:
Operand: LIFO Destination tag that stores the value that exits from the stack Control Length number of elements in the array Position current position in the array immediate (0-33554432) usually enter 0 tag CONTROL immediate (1-33554432) Valid Types: tag array DINT or REAL tag DINT

Control status:
Control bit or word: .EU bit .DN bit .LEN word .POS word Description: The enable unload bit is set when the rung is true. This instruction indicates that the instruction is enabled. The done bit is set to indicate that the stack is full. The .DN bit inhibits loading the stack until there is room. The length value specifies the number of elements in the array. The position value identifies the element that the controller is currently manipulating.

Publication 1756-6.4.1 review January 1998 - preliminary

9-14

File/Shift Instructions

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
does not execute does not execute executes

Description: true false

LFL/LFU Example:

array_dint

source (value_1) LFL places data in the stack

destination (value_2)

LFU removes data from the stack

16621

If the preceding instructions are true, the controller starts the LIFO operation on array_dint.

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

10

Sequencer Instructions
(SQI, SQO, SQL)
Introduction
Sequencer instructions are typically used to control automatic assembly machines that have a consistent and repeatable operation. Use the SQI instruction to detect when a step is complete. Use the SQO instruction to set output conditions for the next step. Use the SQL instruction to load reference conditions into the sequencer input and output arrays.
If you want to: Monitor machine operating conditions for diagnostic purposes by comparing 32-bit data through a mask with reference data. Control sequential machine operations by transferring 32-bit data through a mask to output tags. Capture reference conditions by manually stepping the machine through its operating sequences and loading data into a destination array. Use this instruction: SQI See page: 10-3

SQO

10-5

SQL

10-7

Publication 1756-6.4.1 review January 1998 - preliminary

10-2

Sequencer Instructions

Using the Sequencer Instructions

The control structure controls the operation of the shift instruction.


CONTROL structure

bit number

31 30 29 28 27 26 25 24 EN EU DN EM ER UL IN FD

16 15

length value (.LEN) position value (.POS)

Control bit or word: .EN bit .EU bit .DN bit .EM bit .ER bit .UL bit .IN bit .FD bit .LEN word .POS word

Description: The enable bit indicates that the instruction is enabled. not used The done bit indicates that the file operation is complete. not used not used not used not used not used The length word specifies the number of elements in the array on which the file instruction operates. The position word identifies the current element that the controller is accessing. You generally enter a zero to start at the beginning of the current dimension of the array.

Publication 1756-6.4.1 review January 1998 - preliminary

Sequencer Instructions

10-3

Sequencer Input (SQI)


Description: Use the SQI instruction to detect when a step is complete in a sequence pair of SQO/SQI instructions. This instruction manipulates the right-most dimension only (for example, dimension 2 in array1[0,1,2]). Use the same Control, Length, and Position for the SQI, SQO, SQL combination of instructions.

Operands:
Operand: Array Mask Source Control Length number of steps Position current step immediate (0-33554432) usually enter 0 Valid Types: tag array SINT, INT, or DINT immediate or tag SINT, INT, or DINT tag SINT, INT, or DINT tag CONTROL immediate (1-33554432)

Control status:
Control bit or word: .LEN word .POS word Description: The length value specifies the number of elements in the array. The position value identifies the element that the controller is currently manipulating.

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
does not execute does not execute executes

Description: true false

Publication 1756-6.4.1 review January 1998 - preliminary

10-4

Sequencer Instructions

SQI Example:

If the preceding instructions are true, the controller starts the sequencer operation on array_dint.

SQO operand: Source Mask Destination

Example values (using INTs): 11110101 01001010 00001111 00001111 xxxx0101 xxxx1010

A 0 in the mask leaves the bit unchanged.

Entering an immediate mask value


If you want to enter an immediate mask value, you must precede the value with the correct prefix.
Prefix: 16# Description: hexadecimal for example; 16#0F0F 8# octal for example; 8#16 2# binary for example; 2#00110011

Publication 1756-6.4.1 review January 1998 - preliminary

Sequencer Instructions

10-5

Sequencer Output (SQO)


Description: Use the SQO instruction to set output conditions for the next step of a sequence pair of SQO/SQI instructions. This instruction manipulates the right-most dimension only (for example, dimension 2 in array1[0,1,2]). Use the same Control, Length, and Position for the SQI, SQO, SQL combination of instructions.

Operands:
Operand: Array Mask Destination Control Length number of steps Position current step immediate (0-33554432) usually enter 0 Valid Types: tag array SINT, INT, or DINT immediate or tag SINT, INT, or DINT tag SINT, INT, or DINT tag CONTROL immediate (1-33554432)

Control status:
Control bit or word: .EN bit Description: The enable bit is set when the rung goes from false to true. It indicates that the instruction is enabled. The instruction follows the rung status. During prescan, this bit is set to prevent a false increment when the program scan begins. .DN bit The done bit is set after the instruction finishes operating on the last element in the array. After the rung goes false, the controller resets the .DN bit on the next false-to-true transition. The length value specifies the number of elements in the array. The position value identifies the element that the controller is currently manipulating.

.LEN word .POS word

Publication 1756-6.4.1 review January 1998 - preliminary

10-6

Sequencer Instructions

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
does not execute does not execute executes

Description: true false

SQO Example:

If the preceding instructions are true, the controller starts the sequencer operation on array_dint.

SQO operand: Source Mask Destination

Example values (using INTs): 11110101 01001010 00001111 00001111 xxxx0101 xxxx1010

A 0 in the mask leaves the bit unchanged.

Entering an immediate mask value


If you want to enter an immediate mask value, you must precede the value with the correct prefix.
Prefix: 16# Description: hexadecimal for example; 16#0F0F 8# octal for example; 8#16 2# binary for example; 2#00110011

Publication 1756-6.4.1 review January 1998 - preliminary

Sequencer Instructions

10-7

Sequencer Load (SQL)


Description: Use the SQL instruction to load reference conditions into the sequencer input and output array. Use with SQO/SQI instructions. This instruction manipulates the right-most dimension only (for example, dimension 2 in array1[0,1,2]). Use the same Control, Length, and Position for the SQI, SQO, SQL combination of instructions. Operands:
Operand: Array Source Control Length number of steps Position current step immediate (0-33554432) usually enter 0 Valid Types: tag array SINT, INT, or DINT immediate or tag SINT, INT, or DINT tag CONTROL immediate (1-33554432)

Control status:
Control bit or word: .EN bit Description: The enable bit is set when the rung goes from false to true. It indicates that the instruction is enabled. The instruction follows the rung status. During prescan, this bit is set to prevent a false increment when the program scan begins. .DN bit The done bit is set after the instruction finishes operating on the last element in the array. After the rung goes false, the controller resets the .DN bit on the next false-to-true transition. The length value specifies the number of elements in the array. The position value identifies the element that the controller is currently manipulating.

.LEN word .POS word

Publication 1756-6.4.1 review January 1998 - preliminary

10-8

Sequencer Instructions

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
does not execute does not execute executes

Description: true false

SQL Example:

If the preceding instructions are true, the controller loads the value at value_2 into the current step of array_dint.

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

11

Program Control Instructions


(JMP, LBL, JSR, RET, SBR, TND, MCR, UID, UIE, AFI, NOP)
Introduction
Use the program control instructions to change the flow of logic.
If you want to: Jump over a section of logic that does not always need to be executed. Jump to a separate subroutine file, pass data to the subroutine, perform an operation, and return results. Mark a temporary end that halts program execution beyond that mark. Turn off all non-retentive outputs in a section of logic. Disable user tasks. Enable user tasks. Disable a rung. Insert a placeholder in the logic. Use this instruction: JMP LBL JSR SBR RET TND MCR UID UIE AFI NOP See page: 11-2 11-4

11-6 11-7 11-9 11-10 11-11 11-12

Publication 1756-6.4.1 review January 1998 - preliminary

11-2

Program Control Instructions

Jump to Label (JMP) Label (LBL)


Description: Use JMP and LBL instructions in pairs to skip portions of the ladder program. You can jump to the same label from one or more JMP instructions.
If the jump rung is: true The controller: skips from the JMP rung to the LBL rung and continues executing the logic. You can jump forward or backward. false ignores the JMP instruction.

Jumping forward to a label saves program scan time by omitting a logic segment until its needed. Jumping backward lets the controller repeat iterations of logic until its complete. Be careful not to jump backward an excessive number of times. The watchdog timer could time out because the controller never reaches the end of the logic, which would fault the controller. ATTENTION: Jumped logic is not scanned. Program critical logic outside the jumped zone.

The LBL instruction is the target of the JMP instruction that has the same label name. Make sure the LBL instruction is the first instruction on its rung. Operands:
Operand: Label number Valid Types: label name

Publication 1756-6.4.1 review January 1998 - preliminary

Program Control Instructions

11-3

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

JMP/LBL Example:

[other rungs of code]

If the preceding instructions are true, the controller jumps over successive rungs of logic until it reaches the rung that contains the LBL instruction with the same label as the JMP instruction.

Publication 1756-6.4.1 review January 1998 - preliminary

11-4

Program Control Instructions

Jump to Subroutine (JSR) Subroutine (SBR) Return (RET)


Description: The JSR, SBR, and RET instructions direct the controller to go to a separate routine within the program, scan that routine once, and return to the point of departure. The JSR instruction directs the controller to the specified routine, and if needed, defines the parameters passed to and received from the routine. The optional SBR instruction stores the incoming parameters. Use the SBR instruction only if you want to pass parameters. The RET instruction ends the subroutine, and if needed, stores parameters to return to the JSR instruction. The number and type of parameters in the JSR instruction should match those in the SBR and RET instructions. Unpredictable results can occur otherwise. There are no restrictions on the number of nested jumps you have or the number of parameters you pass or return.
level 1 subroutine action_1 level 2 subroutine action_2 level 3 subroutine action_3

main routine

action_1 JSR

SBR

SBR

SBR

action_2 JSR

action_3 JSR

RET

RET

RET

15294

The JSR, SBR, and RET instructions pass parameters into and out of a subroutine by value. This means that the controller uses additional execution time and memory to handle the values. You can reduce execution time by directly accessing program-scoped and controller-scoped data from within the subroutine, rather than passing values.

Publication 1756-6.4.1 review January 1998 - preliminary

Program Control Instructions

11-5

Operands:
Operand: Routine name Input parameter Return parameter Valid Types: tag ROUTINE immediate or tag any type tag any type

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

JSR/SBR/RET Example:

If the preceding instructions are true, the controller jumps to routine_1 within the same program.

[other rungs of code]

Publication 1756-6.4.1 review January 1998 - preliminary

11-6

Program Control Instructions

Temporary End (TND)


Description: Use the TND instruction as a boundary. The TND instruction lets your program run only up to this instruction. When the rung is true, the TND instruction is interpreted as the end of the routine. When the controller encounters the TND instruction, the controller moves to the end of the current routine. Control then returns to the calling routine. If the calling routine was the main routine, control returns to the next program within the current task. Use the TND instruction when debugging or troubleshooting your logic. The TND instructions limits logic execution only up to this instruction. Progressively move the TND instruction through the logic as you debug each new section. Operands: Operation:
Characteristic: Timing (in s) Memory (words) Execution Description: neglible DINT REAL
executes does not execute executes

none

TND Example:

If the preceding instructions are true, the controller stops scanning this routine.

Publication 1756-6.4.1 review January 1998 - preliminary

Program Control Instructions

11-7

Master Reset Control (MCR)


Description: Use the MCR instructions in pairs to create program zones that turn off all the non-retentive outputs in the zone. The controller still scans rungs within an MCR zone, but scan time is reduced because all the rungs in the zone are false. Non-retentive outputs are reset when the rung goes false.
If the MCR rung that starts the zone is: true false The controller: Executes the rungs in the MCR zone based on each rungs individual conditions (as if the MCR zone did not exist). Resets all non-retentive output instructions in the MCR zone, regardless of each rungs individual conditions.

MCR zones let you enable or inhibit segments of logic, such as for recipe applications. When you program an MCR zone, note that: You must end the zone with an unconditional MCR instruction. You cannot nest one MCR zone within another. Do not jump into an MCR zone. If the zone is false, jumping into the zone activates the zone. If an MCR zone continues to the end of the routine, you do not have to program an MCR instruction to end the zone.

Important: The MCR instruction is not a substitute for a hard-wired master control relay that provides emergency-stop capability. You should still install a hard-wired master control relay to provide emergency I/O power shutdown. ATTENTION: Do not overlap or nest MCR zones. Each MCR zone must be separate and complete. If they overlap or nest, unpredictable machine operation could occur with possible damage to equipment or injury to personnel. If you start instructions such as timers or counters in an MCR zone, instruction execution stops when the zone is disabled. Program critical operations outside the zone.

Operands:

none

Publication 1756-6.4.1 review January 1998 - preliminary

11-8

Program Control Instructions

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 0.06 na na
executes does not execute executes

false 0.05 na

MCR Example:

[other rungs of code]

When the first MCR instruction is true, the controller executes the rungs in the MCR zone (between the two MCR instructions). When the first MCR instruction is false, the controller resets all non-retentive outputs in the MCR zone (the rungs between the MCR instructions).

Publication 1756-6.4.1 review January 1998 - preliminary

Program Control Instructions

11-9

User Interrupt Disable (UID)


Description: Use the UID instruction to temporarily disable switching between user tasks. The current task continues to execute until either a UIE instruction is executed or the end of the program is reached. When the rung is true, the UID instruction increments an internal counter. As long as this counter value does not equal zero, the currently-executing task cannot be interrupted. The UID instruction does not disable a fault routine. Operands: Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

none

Description: true false

UID Example:

If the preceding instructions are true, the controller disables switching between user tasks.

Publication 1756-6.4.1 review January 1998 - preliminary

11-10

Program Control Instructions

User Interrupt Enable (UIE)


Description: Use the UIE instruction to re-enable switching between user tasks. When the rung is true and the internal counter is greater than zero, the counter is decremented. When the counter equals zero, the task currently executing can be interrupted again. Any pending interrupt programs are executed at this time. Operands: Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

none

Description: true false

UIE Example:

If the preceding instructions are true, the controller re-enables switching between user tasks.

Publication 1756-6.4.1 review January 1998 - preliminary

Program Control Instructions

11-11

Always False Instruction (AFI)


Description: Use the AFI instruction to make a rung always false. Use the AFI instruction to temporarily disable a rung while you are debugging a program.

Operands: Operation:

none

Characteristic: Timing (in s)

Description: true DINT REAL false

Memory (words) Execution

DINT REAL
executes does not execute executes

AFI Example:

If the preceding instructions are true, the controller makes the current rung false.

Publication 1756-6.4.1 review January 1998 - preliminary

11-12

Program Control Instructions

No Operation (NOP)
Description: The NOP instruction functions only as a placeholder; it performs no operation. You can use this instruction as a placeholder for future logic. When debugging your application, you can use this instruction when optimizing timing. none

Operands: Operation:

Characteristic: Timing (in s)

Description: true DINT REAL false

Memory (words) Execution

DINT REAL
executes does not execute executes

NOP Example:

You can use this instruction as a placeholder.

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

12

For/Break Instructions
(FOR, BRK)
Introduction
Use the FOR instruction to repeatedly call a subroutine. Use the BRK instruction to interrupt the execution of the subroutine.
If you want to: Repeatedly execute a routine. Terminate the repeated execution of a routine. Use this instruction: FOR BRK See page:

Publication 1756-6.4.1 review January 1998 - preliminary

12-2

For/Break Instructions

For (FOR)
Description: Use the FOR instruction to repeatedly execute a routine until the Index tag exceeds the Terminal value. This instruction does not pass parameters to the routine (see the JSR instruction). When the rung is true, the FOR instruction executes the rungs between the FOR and BRK instructions repeatedly in one program scan until the Index value exceeds the Terminal value or a BRK instruction ends the repetitions. The FOR instruction repeats this operation every program scan the FOR rung is true. When the rung is false, the controller skips to the rung that follows the rung with the BRK instruction. Be careful not to loop too many times in a single program scan. An excessive number of repetitions can cause the watchdog to timeout because the controller never reaches the end of the logic, which faults the controller. ATTENTION: For and BRK instructions might not execute properly in branches of ladder logic. Do not use FOR and BRK instructions in branches. Using FOR and BRK instructions within an output branch can cause unpredictable machine operation.

Operands:
Operand: Routine name Index Initial value Terminal value Step size Valid Types: ROUTINE name tag DINT immediate or tag SINT, INT, or DINT immediate or tag SINT, INT, or DINT immediate or tag SINT, INT, or DINT

Publication 1756-6.4.1 review January 1998 - preliminary

For/Break Instructions

12-3

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

FOR Example:

If the preceding instructions are true, the controller executes the routine until completion or until the controller reaches a BRK instructions.

Publication 1756-6.4.1 review January 1998 - preliminary

12-4

For/Break Instructions

Break (BRK)
Description: The BRK instruction interrupts the execution of a subroutine and its associated FOR instruction. When the rung goes true, the BRK instruction returns the controller to the next highest loop (if you have nested loops) or to the instruction that follows the BRK instruction.

Operands: Operation:

none

Characteristic: Timing (in s)

Description: true DINT REAL false

Memory (words) Execution

DINT REAL
executes does not execute executes

BRK Example:

If the preceding instructions are true, the controller stops executing the current routine and returns to the instruction following the FOR instruction.

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

13

Special Instructions
(FBC, DDT, DTR, PID)
Introduction
The special instructions perform application-specific operations.
If you want to: Compare I/O data against a known, good reference and record any mismatches. Compare I/O data against a known, good reference, record any mismatches, and update the reference to match the source. Pass the source data through a mask and compare the result to reference data. Then write the source into the reference for the next comparison. Control a PID loop with inputs from an analog input module and an output to an analog output module. Use this instruction: FBC See page: 13-3

DDT

13-6

DTR

13-9

PID

13-17

Publication 1756-6.4.1 review January 1998 - preliminary

13-2

Special Instructions

Using the Diagnostic Instructions

The FBC and DDT diagnostic instructions let you detect problems with data in your programs. The controller stores status bits and the length and position values in a 96-bit storage structure (three 32-bit words) in a CONTROL structures. There is one CONTROL structure to store status for the compare operation and one CONTROL structure to store status for the result.
CONTROL structure

bit number

31 30 29 28 27 26 25 24
EN EU DN EM ER UL IN FD

16 15

length value (.LEN) position value (.POS)

Control bit or word: .EN bit .EU bit .DN bit .EM bit .ER bit .UL bit .IN bit

Description: The enable bit indicates that the instruction is enabled. not used The done bit indicates that the file operation is complete. not used The error bit indicates when the file operation generates an overflow. not used The inhibit bit indicates that the controller detected a true comparison using an FSC instruction. You must reset this bit to continue the search operation. This bit is only used by the FSC instruction. The found bit indicates that the controller detected a true comparison using an FSC instruction. This bit is only used by the FSC instruction. The length word specifies the number of elementsin the array on which the file instruction operates. The position word identifies the current element that the controller is accessing. You generally enter a zero to start at the beginning of the current dimension of the array.

.FD bit .LEN word .POS word

Publication 1756-6.4.1 review January 1998 - preliminary

Special Instructions

13-3

File Bit Comparison (FBC)


Description: Use the FBC instruction to compare bits in a file of real-time machine or process values (Source) with bits in the Reference array. The FBC instruction records the position of each mismatch in the Result array. This instruction manipulates the right-most dimension only (for example, dimension 2 in a three-dimensional array array1[0,1,2]). The difference between the DDT and FBC instructions is that each time the DDT instruction finds a mismatch, the controller changes the reference bit to match the source bit. The FBC instruction does not change the reference bit.

Selecting the search mode


If you want to detect: One mismatch at a time Select this mode: Set the .IN bit (1) With each false-to-true transition, the instruction searches for the next mismatch between the Source and Reference arrays. Upon finding a mismatch, the instruction stops, sets the .FD bit, and records the position of the mismatch. All mismatches Reset the .IN bit (0) With a false-to-true transition, the instruction searches for all mismatches between the Source and Reference arrays.

Operands:
Operand: Source Reference Result Compare control Length number of bits to compare Position current bit in Source array Result control Length number of elements in Result array Position current position in Result array immediate (0-33554432) usually enter 0 immediate (0-2147483647) usually enter 0 tag CONTROL immediate (1-33554432) Valid Types: tag array DINT tag array DINT tag array DINT tag CONTROL immediate (1-2147483647)

Publication 1756-6.4.1 review January 1998 - preliminary

13-4

Special Instructions

Compare control status:


Control bit or word: .EN bit Description: The enable bit is set when the rung goes from false to true. It indicates that the instruction is enabled. If the .IN bit is set for one-at-a-time operation, your logic must toggle the .EN bit after the instruction detects each mismatch. .DN bit .IN bit The done bit is set when the controller reaches the end of the Source and Reference arrays. The inhibit bit determines the mode of operation. If the .IN bit is set, the controller detects one mismatch at a time (per program scan). The controller stops the search at each mismatch and waits for the logic to re-enable the instruction before continuing the search. If the .IN bit is reset, the controller detects all mismatches in one program scan. .FD bit .LEN word .POS word The found bit is set each time the controller records a mismatch (one-at-a-time operation) or after recording all mismatches (all-per-scan operation). The length value identifies the number of bits to compare. The position value identifies the current bit. Specify a position only if you want the instruction to start at as offset concurrent with a control offset for one scan.

Result control status:


Control bit or word: .DN bit .LEN word .POS word Description: The done bit is set when the Result array is full. The length value identifies the number of elements in the Result array. The position value identifies the current position in the Result array.

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
does not execute does not execute executes

Description: true false

Publication 1756-6.4.1 review January 1998 - preliminary

Special Instructions

13-5

FBC Example:

result source 15 14 13 12 11 10 9 1 8 7 1 6 0 5 4 0 0 3 2 1 1 0 1 3 9

array_dint_3

array_dint_1

1 1

0 1

reference

15 14 13 12 11 10 9 1

7 1

6 0

5 4 0 0

3 1

2 1

1 1

0 1

array_dint_2

0 1

If the preceding instructions are true, the controller compares the source array_dint_1 to the reference array_dint_2 and stores the locations of any mismatches in the result array_dint_3.
16657

Publication 1756-6.4.1 review January 1998 - preliminary

13-6

Special Instructions

Diagnostic Detect (DDT)


Description: Use the DDT instruction to compare bits in a Source file with bits in a Reference file to determine changes of state. The DDT instruction changes the status of the Reference bit to match the status of the corresponding Source bit. The DDT instruction records the position of each mismatch in the Result file. This instruction manipulates the right-most dimension only (for example, dimension 2 in a three-dimensional array array1[0,1,2]). The difference between the DDT and FBC instructions is that each time the DDT instruction finds a mismatch, the controller changes the reference bit to match the source bit. The FBC instruction does not change the reference bit.

Selecting the search mode


If you want to detect: One mismatch at a time Select this mode: Set the .IN bit (1) With each false-to-true transition, the instruction searches for the next mismatch between the Source and Reference arrays. Upon finding a mismatch, the instruction stops, sets the .FD bit, and records the position of the mismatch. All mismatches Reset the .IN bit (0) With a false-to-true transition, the instruction searches for all mismatches between the Source and Reference arrays.

Operands:
Operand: Source Reference Result Compare control Length number of bits to compare Position current bit in Source array Result control Length number of elements in Result array Position current position in Result array immediate (0-33554432) usually enter 0 immediate (0-2147483647) usually enter 0 tag CONTROL immediate (1-33554432) Valid Types: tag array DINT tag array DINT tag array DINT tag CONTROL immediate (1-2147483647)

Publication 1756-6.4.1 review January 1998 - preliminary

Special Instructions

13-7

Compare control status:


Control bit or word: .EN bit Description: The enable bit is set when the rung goes from false to true. It indicates that the instruction is enabled. If the .IN bit is set for one-at-a-time operation, your logic must toggle the .EN bit after the instruction detects each mismatch. .DN bit .IN bit The done bit is set when the controller reaches the end of the Source and Reference arrays. The inhibit bit determines the mode of operation. If the .IN bit is set, the controller detects one mismatch at a time (per program scan). The controller stops the search at each mismatch and waits for the logic to re-enable the instruction before continuing the search. If the .IN bit is reset, the controller detects all mismatches in one program scan. .FD bit .LEN word .POS word The found bit is set each time the controller records a mismatch (one-at-a-time operation) or after recording all mismatches (all-per-scan operation). The length value identifies the number of bits to compare. The position value identifies the current bit. Specify a position only if you want the instruction to start at as offset concurrent with a control offset for one scan.

Result control status:


Control bit or word: .DN bit .LEN word .POS word Description: The done bit is set when the Result array is full. The length value identifies the number of elements in the Result array. The position value identifies the current position in the Result array.

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
does not execute does not execute executes

Description: true false

Publication 1756-6.4.1 review January 1998 - preliminary

13-8

Special Instructions

DDT Example:

result source 15 14 13 12 11 10 9 1 8 7 1 6 0 5 4 0 0 3 2 1 1 0 1 3 9

array_dint_3

array_dint_1

1 1

0 1

reference

15 14 13 12 11 10 9 1

7 1

6 0

5 4 0 0

3 1

2 1

1 1

0 1

array_dint_2

0 1

If the preceding instructions are true, the controller compares the source array_dint_1 to the reference array_dint_2 and stores the locations of any mismatches in the result array_dint_3. The controller also changes the mismatched bits in the reference array_dint_2 to match the source array_dint_1.
16657

Publication 1756-6.4.1 review January 1998 - preliminary

Special Instructions

13-9

Data Transitional (DTR)


Description: The DTR instruction is an input instruction that you use to pass a Source value through a Mask and compare the result to a Reference value. Then the DTR instruction writes the Source element to the Reference element for the next comparison. If the masked Source differs from the Reference, the instruction goes true for one program scan.

Operands:
Operand: Source Mask Reference Valid Types: immediate or tag DINT immediate or tag DINT immediate or tag DINT

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

Publication 1756-6.4.1 review January 1998 - preliminary

13-10

Special Instructions

DTR Example:

If the preceding instructions are true, the controller passes the source value_1 through the mask_1 and compares the result to the reference value_2.

source 1 8 3

value_1

mask = 0FFF
0 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 previous scan 1 1 8 8 3 3

value_2

1 1

8 8

7 3

current scan previous scan

The rung remains false as long as the input value does not change.

The rung remains true for one scan when a change is detected.
13385

A 0 in the mask leaves the bit unchanged.

Entering an immediate mask value


If you want to enter an immediate mask value, you must precede the value with the correct prefix.
Prefix: 16# Description: hexadecimal for example; 16#0F0F 8# octal for example; 8#16 2# binary for example; 2#00110011

Publication 1756-6.4.1 review January 1998 - preliminary

Special Instructions

13-11

Using PID Instructions

PID closed-loop control holds a process variable at a desired set point. The following figure shows a flow-rate/fluid level example:
feedforward or bias setpoint error PID equation flow rate process variable control output

level detector

13385

In the above example, the PID equation controls the process by sending an output signal to the control valve. The greater the error between the setpoint and process variable input, the greater the output signal, and vice versa. An additional value (feedforward or bias) can be added to control output as an offset. The goal of PID calculations is to maintain the process variable you are controlling at the setpoint. The base PID equation is the standard parallel position PID algorithm, with the option of entering gains as independent or dependent.
Gains Option: Dependent gains (ISA standard) Derivative of: error
t

Equation:

1 dE CV = K C E + ---- Edt + T d ------ + BIAS Ti dt


0

process variable (PV)

E = SP - PV
t

1 dPV CV = K C E + ---- Edt T d ---------- + BIAS Ti dt


0

E = PV - SP
t

CV = K C

1 dE E + ---- Edt + T d ------ + BIAS Ti dt


0

Publication 1756-6.4.1 review January 1998 - preliminary

13-12

Special Instructions Gains Option: Independent gains Derivative of: error


t

Equation:

dE CV = K P E + K i Edt + K d ------ + BIAS dt


0

process variable (PV)

E = SP - PV
t

dPV CV = K P E + K i Edt K d ---------- + BIAS dt


0

E = PV - SP
t

dE CV = K P E + K i Edt + K d ------ + BIAS dt


0

Where:
Variable: KP Description: proportional gain (unitless) Kp = Kc unitless Ki integral gain (seconds -1)

KC K i = ---------60T i

Kd

derivative gain (seconds) Kd = Kc (Td) 60 seconds

KC 1 ---Ti Td SP PV E BIAS CV dt

controller gain (unitless) reset gain (repeats/minute)

rate gain (minutes) setpoint process variable error (SP-PV) or (PV-SP) feedforward or external control variable loop update time

Publication 1756-6.4.1 review January 1998 - preliminary

Special Instructions

13-13

Integral term implementation Perform integration by maintaining an accumulated sum:


Gains: independent gains Summation:

S k = K i ( E k )dt + S k 1

dependent gains

1 S k = ---- ( E k )dt + S k 1 Ti

If the integral (Ki) or reset (1/Ti) gain is zero, the accumulated sum continually sets to zero in auto mode. Avoid integral wind-up by preventing the running sum from accumulating whenever the CV output reaches its maximum or minimum values. These values are either 0% and 100% or the user-specified limits in output limiting. The accumulated sum remains frozen until the output drops below its maximum value or rises about its minimum value; then normal accumulation resumes. When executing the PID instruction in manual mode, you can achieve a bumpless transfer back to auto mode by using the accumulated sum to track the manual output:

dE S k = CV manual BIAS + K P E K d -----dt


When you switch to auto mode, the PID computation yields this manual output value and no jump in output occurs as a result of the mode change.

Publication 1756-6.4.1 review January 1998 - preliminary

13-14

Special Instructions

Derivative term The following approximation calculates the derivative term:

dQ Q k Q k 1 ------ ------------------------dt dt
Where Q represents wither Error or PV, depending on your settings. The calculation is further enhanced by using a derivative smoothing filter. This first order, low pass, digital filter eliminates large derivative term spikes caused by noise in the PV.

Qk Qk 1 D k = ( 1 a ) K d ------------------------- + aDk 1 dt

Where:
Variable: Kd Dk Dk-1 Qk a 1 --------------------dt 16 ----- + 1 Kd dt loop update time Description: derivative gain (seconds) current derivative term previous derivative term error or PV, depending on your settings

Setting the deadband


The adjustable deadband lets you select an error range above and below the setpoint where output does not change as long as the error remains within this range. This deadband lets you control how closely the process variable matches the setpoint without changing

Publication 1756-6.4.1 review January 1998 - preliminary

Special Instructions

13-15

the output.

high alarm + deadband setpoint - deadband low alarm time error within deadband range

Using zero-crossing 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 instruction considers the error value zero. Enter your deadband value in the control block. The deadband extends above and below the setpoint by the value you specify. Enter zero to inhibit the deadband. If scaled, the deadband has the same scaled units as the setpoint.

Setting output alarms


You can set an output alarm on the control variable output at a selected value above or below the setpoint. When the instruction detects that the output has reached either value, the controller sets an alarm bit in the control block. Alarm bits are reset by the instruction when the output comes back inside the limits. The instruction does not prevent the output from exceeding the alarm values unless you select output limiting. The controller handles alarm values as a percentage of the output. If you do not want alarms, enter 0% for the lower alarm and 100% for the upper alarm.

Using output limiting


You can set an output limit (percentage of output) on the control output. When the instruction detects that the output has reached a limit, it sets an alarm bit in the control block and prevents the output from exceeding either the lower or upper limit.

Publication 1756-6.4.1 review January 1998 - preliminary

13-16

Special Instructions

Using manual mode (with bumpless transfer)


Manual operation lets an output from a manual control station or from logic override the calculated output of the PID instruction. With a manual control station, you control the output device directly and override the PID instructions output. You must feed the output value into the tieback input. The PID instruction uses this value to calculate the integral term value required to achieve a bumpless transfer when you switch from manual to auto mode.
analog input module main control station output tracking (tieback input) second channel output PV input first channel

15297

Feedforward or output biasing


You can feedforward a disturbance from the system or bias output by feeding either of these values into the PID instructions feedforward/bias word of the control block. The feedforward value represents a disturbance fed in the PID instruction before the disturbance has a chance to change the process variable. Feedforward is often used to control processes with a transportation lag. For example, a feedforward value representing cold water poured into a warm mix could boost the output value faster than waiting for the process variable to change as a result of the mixing. A bias value can be used to compensate for steady-state loss of energy from the controlled process.

Publication 1756-6.4.1 review January 1998 - preliminary

Special Instructions

13-17

Proportional Derivative Integral (PID)


Description: The PID instruction is an output instruction that controls physical properties, such as temperature, pressure, liquid level, or flow rate of process loops. The PID instruction controls a PID loop with inputs from an analog input module and an output to an analog output module. For temperature control, you can convert the analog output to a time proportioning on/off output for driving a heater or cooling unit. Execute the PID instruction periodically at constant intervals using a timer or real-time sampling. The logic can interact with the PID algorithm by changing variables during operation, or you can change variables from a programming terminal. The PID instruction provides bumpless transfer when not using the integral term. It does this by generating a bias term to the difference between the proportional term and the manually-adjusted output as follows:
If you select: manual mode with tieback manual mode with setpoint The algorithm is: BIAS = TIEBACK - Pterm BIAS = SETPOINT - Pterm

The PID instruction has only a .EN bit to indicate execution status. The .EN bit indicates that its qualifying rung conditions are true, in which case the .EN bit is set (a false-to-true transition is not needed). The .EN bit is reset when the same qualifying rung conditions become false. The PID instruction does not use a .DN bit.

.EN bit

rung state execution of the PID instruction

Publication 1756-6.4.1 review January 1998 - preliminary

13-18

Special Instructions

Operands:
Operand: PID Process variable Tieback Control variable PID master loop Inhold bit Inhold value Setpoint Process variable Output % Valid Types: tag PID tag SINT, INT, DINT, or REAL immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL tag PID (optional) tag BOOL (optional) tag DINT (optional)

display only display only display only

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

Publication 1756-6.4.1 review January 1998 - preliminary

Special Instructions

13-19

Control status:
Word: CTL Contains: .EN .CT .CL .PVT .DOE .SWM .CA .MO .PE .NDF .NOBC .NOZC .INI .SPOR .OLL .OLH .EWD .DVNA .DVPA .PVLA .PVHA .MSTR setpoint ISA KI independent ISA KD independent ISA BIAS MAXS MINS DB SO MAXO MINO UPD PV ERR OUT PVH PVL DVP DVN PVDB DVDB MAXI

Specify a unique PID structure for each PID instruction.


Valid Range:

not applicable enabled cascade type (0=master; 1=slave) cascade loop (0=no; 1=yes) process variable tracking (0=no; 1=yes derivative of (0=PV; 1=error) software mode (0=no-auto); 1=yes- sw manual) control action (0=direct (SP-PV); 1=reverse (PV-SP)) station mode (0=automatic; 1=manual) PID equation (0=independent; 1=dependent) derivative smoothing (0=no; 1=yes) bias calculation (0=no; 1=yes) zero crossing (0=no; 1=for deadband) PID initialized (0=no; 1=yes) setpoint out of range (0=no; 1=yes) CV is below minimum output value (0=no; 1=yes) CV is above maximum output value (0=no; 1=yes) error is withinin deadband (0=no; 1=yes) error is alarmed low (0=no; 1=yes) error is alarmed high (0=no; 1=yes) PV is alarmed low (0=no; 1=yes) PV is alarmed high (0=no; 1=yes) slave with valid master address (0=no; 1=yes) -3.4 E+38 to 3.4 E+38 proportional gain (unitless) controller gain (unitless) integral gain (1/sec) reset term (minutes per repeat) derivative gain (seconds) rate term (minutes) 0 to 3.4 E+38 0 to 3.4 E+38 0 to 3.4 E+38 0 to 3.4 E+38 0 to 3.4 E+38 0 to 3.4 E+38 -100 to 100% -3.4 E+38 to 3.4 E+38 -3.4 E+38 to 3.4 E+38 0 to 3.4 E+38 0-100% 0-100% 0-100% >= 0.01 seconds -3.4 E+38 to 3.4 E+38 -3.4 E+38 to 3.4 E+38 0-100% -3.4 E+38 to 3.4 E+38 -3.4 E+38 to 3.4 E+38 -3.4 E+38 to 3.4 E+38 -3.4 E+38 to 3.4 E+38 0 to 3.4 E+38 0 to 3.4 E+38 -3.4 E+38 to 3.4 E+38

SP KP

independent

feedforward or bias maximum scaling minimum scaling deadband set output % maximum output limit (% of output) minimum output limit (% of output) loop update time (seconds) scaled PV value scaled error value output (% of 4095) process variable high alarm value process variable low alarm value positive deviation alarm negative deviation alarm process variable alarm deadband error alarm deadband maximum PV value

Publication 1756-6.4.1 review January 1998 - preliminary

13-20

Special Instructions Word: MINI TIE MAXCV MINCV MINTIE MAXTIE Contains: minimum PV value tieback value for manual control (0-4095) maximum CV value minimum CV value minimum tieback value maximum tieback value Valid Range: -3.4 E+38 to 3.4 E+38 0-100% -3.4 E+38 to 3.4 E+38 -3.4 E+38 to 3.4 E+38 -3.4 E+38 to 3.4 E+38 -3.4 E+38 to 3.4 E+38

Configuring a PID Instruction

After you enter the PID instruction and specify the PID structure, you use the configuration tabs to specify the details of the message.

Click here to configure the PID instruction

Specifying tuning
In this field: Setpoint (SP) Set output % Output bias Proportional gain (Kp) Specify: Enter a setpoint value (.SP) The valid range is:-3.4 E+38 to 3.4 E+38 Enter a set output percentage (.SO). The valid range is: 0-100% Enter an output bias percentage (.OUT). The valid range is: 0-100% Enter a proportional gain (.KP). For independent gains, its the proportional gain (unitless). The valid range is: 0 to 3.4 E+38 For dependent gains, its the controller gain (unitless). The valid range is: 0 Integral gain (Ki) to 3.4 E+38 Enter an integral gain (.KI). For independent gains, its the integral gain (1/sec). The valid range is: 0 to 3.4 E+38 For dependent gains, its the reset term (minutes per repeat). The valid range is: 0 to 3.4 E+38 Enter the derivative time (.KD). For independent gains, its the derivative gain (seconds). The valid range is: 0 to 3.4 E+38 For dependent gains, its the rate term minutes). The valid range is: Manual mode 0 to 3.4 E+38 Select either manual or software manual

Derivative time (Kd)

Publication 1756-6.4.1 review January 1998 - preliminary

Special Instructions

13-21

Specifying configuration
In this field: PID equation Specify: Select independent gains or dependent gains. Use independent when you want the three gains constants (P, I, and D) to operate independently. Select dependent when you want to use standard loop tuning methods. Select either E=PV-SP (direct acting) or E=SP-PV (reverse) Select PV or error. Use the PV derivative for more stable control when you do not change the setpoint often. Use the error derivative for fast responses to setpoint changes when the algorithm can tolerate overshoots. Enter an update time (greater than or equal 0.01 seconds) at 1/4 or 1.10 the natural period of the load time constant. The load time constant should be greater than: 3ms(algorithm) + block-transfer time(ms) ATTENTION: If you omit an update time or enter a negative update time, a major fault occurs the first time the controller runs the PID instruction. Enter a maximum control variable value (.MAXCV). The valid range is: -3.4 E+38 to 3.4 E+38 Enter a minimum control variable value (.MINCV). The valid range is: -3.4 E+38 to 3.4 E+38 Deadband value Derivative smoothing Bias calculation Zero crossing in deadband PV tracking Cascade loop Cascade type Enter a deadband value (.DB). The valid range is: 0 to 3.4 E+38 Enable or disable this selection. Enable or disable this selection. Enable or disable this selection. Enable or disable this selection. Enable or disable this selection. If cascade loop is enabled, select either slave or master.

Control action Derivative of

Loop update time

CV high limit CV low limit

Specifying alarms
In this field: PV high PV low PV deadband positive deviation negative deviation deviation deadband Specify: Enter a PV high alarm value (.PVH). The valid range is: -3.4 E+38 to 3.4 E+38 Enter a PV low alarm value (.PVL). The valid range is: -3.4 E+38 to 3.4 E+38 Enter a PV deadband value (.PVDB). The valid range is: 0 to 3.4 E+38 Enter a positive deviation value (.DVP). The valid range is: -3.4 E+38 to 3.4 E+38 Enter a negative deviation value (.DVN). The valid range is: -3.4 E+38 to 3.4 E+38 Enter a deviation deadband value (.DVDB). The valid range is: 0 to 3.4 E+3

Publication 1756-6.4.1 review January 1998 - preliminary

13-22

Special Instructions

Specifying scaling
In this field: PV unscaled maximum PV unscaled minimum Specify: Enter a maximum PV value (.MAXI). The valid range is: -3.4 E+38 to 3.4 E+38 Enter a maximum PV value (.MINI). The valid range is:

-3.4 E+38 to 3.4 E+38 PV engineering units maximum Enter the maximum engineering units. PV engineering units minimum Enter the minimum engineering units. CV maximum Enter a maximum CV value (.MAXCV). The valid range is: CV minimum Tieback maximum Tieback minimum -3.4 E+38 to 3.4 E+38 Enter a minimum CV value (.MINCV). The valid range is: -3.4 E+38 to 3.4 E+38 Enter a maximum tieback value (.MAXTIE). The valid range is: -3.4 E+38 to 3.4 E+38 Enter a minimum tieback value (.MINTIE). The valid range is: -3.4 E+38 to 3.4 E+38

PID Programming Examples


Consideration: run time errors

Programming Considerations
Description: If the controller encounters one of these conditions, the controller generates an run time error when it tries to execute the instruction: loop update time is zero or negative setpoint is out of range (SP < Smin or SP > Smax)

If you change SP, Smin, or Smax and this out-of-range condition occurs, the controller first tries to use the previously-valid SP, continues PID control, and sets the setpoint out-of-range error bit. If the controller cannot find a previously-valid SP, the controller generates the run time error. If you enter negative values for Kp, KI, KD, TI, or TD, the controller substitutes a zero for the negative number without generating a run time error. number of PID loops The number of PID loops that the controller can support depends on the update time required by the loops. The longer the update time and the less-sophisticated the loop control, the more loops the controller can support. The time required to receive analog inputs plus the time required for one scan should be less than the update time required by all the loops. loop update time The loop update time should be equal to the rate at which the PID rung changes between false and true. Deviation in toggle rate from the update time reduces the accuracy of the PID calculations.

Publication 1756-6.4.1 review January 1998 - preliminary

Special Instructions

13-23

Placing the PID instruction in the main routine


When you place the PID instruction in the main routine, control the sample time with a timer, where the PID loop update time equals the timer preset. Timer-based execution uses a free-running timer for event coordination. When the timers accumulated value reaches its preset value, it triggers the loop update sequence. The timer immediately resets and restarts to maintain a consistent update interval. Use timer-based execution in slower loop applications or in applications with relatively few loops.

Publication 1756-6.4.1 review January 1998 - preliminary

13-24

Special Instructions

Placing the PID instruction in an RTS routine


When you place the PID instruction in a real-time sample-based routine, the PID instructions execution is triggered by the availability of new analog data from an analog input source configured for real-time sampling. Configure the loop update time to equal the real-time sample interval.

Simulating a manual control station


When you program the simulation of a manual control station, make sure that a hardware manual control station is not connected when the logic is enabled. The following programming example uses these tags:
Tag: switch_1 switch_2 switch_3 output_value output_bit PID_output_value control_output Description: manual pushbutton switch automatic pushbutton switch enter pushbutton switch manual output value PID set output bit PID set output value current control output

Publication 1756-6.4.1 review January 1998 - preliminary

Special Instructions

13-25

Cascading loops
You can cascade two loops by assigning the control output of the outer loop to the setpoint of the inner loop. Do not scale the setpoint of the inner loop. Set the scaling bit to 1 to inhibit scaling.

Publication 1756-6.4.1 review January 1998 - preliminary

13-26

Special Instructions

Controlling a ratio
You can maintain two values in a ratio by using a MUL instruction with these parameters: uncontrolled value controlled value ratio between these two values

In the MUL instruction, enter:


For this MUL parameter: destination source A source B Enter this value: controlled value uncontrolled value ratio

Publication 1756-6.4.1 review January 1998 - preliminary

Special Instructions

13-27

Tracking the process variable


When in manual control, you can force the setpoint to be equal to the process variable (PV) by moving the PV into the setpoint element. to achieve a smooth manual-to-automatic transfer. If the setpoint is scaled, move the scaled PV from the PID control structure directly into the setpoint element. If the setpoint is not scaled, move the unscaled value from the PV address in the PID instruction to the setpoint.

Publication 1756-6.4.1 review January 1998 - preliminary

13-28

Special Instructions

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

14

Trigonometric Instructions
(SIN, COS, TAN, ASN, ACS, ATN)
Introduction
The trigonometric instructions evaluate arithmetic operations using trigonometric operations.
If you want to: Take the sine of a value. Take the cosine of a value. Take the tangent of a value. Take the arc sine of a value. Take the arc cosine of a value. Take the arc tangent of a value. Use this instruction: SIN COS TAN ASN ACS ATN See page: 14-2 14-3 14-4 14-5 14-6 14-7

You can mix values of different data types, such as floating point and integer. If you use floating point as the source, use floating point as the destination. You can mix data types, but loss of accuracy and rounding error might occur. If the rung with the compute instruction goes true, the controller performs the computation.

Using arithmetic status flags


To access arithmetic status flags, use an XIC or XIO instruction with one of the status keywords.
Use this keyword: For this status flag: S:C S:N S: V S:Z carry sign (result is negative) overflow zero With this read/write access: read/write read/write read/write read/write

Use the RES instruction to clear the status flags.

Publication 1756-6.4.1 review January 1998 - preliminary

14-2

Trigonometric Instructions

Sine (SIN)
Description: Use the SIN instruction to take the sine of a value (Source in radians) and store the result in the Destination. The Source must be greater than or equal to -205887.4 and less than or equal to 205887.4. The resulting value in the Destination is always greater than or equal to -1 and less than or equal to 1.

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets sets is an overflow is generated; otherwise resets sets is the result is zero; otherwise resets sets if the result is negative; otherwise resets

Operands:
Operand: Source Destination Valid Types: immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

SIN Example:

If the preceding instructions are true, the controller performs the sine operation.

Publication 1756-6.4.1 review January 1998 - preliminary

Trigonometric Instructions

14-3

Cosine (COS)
Description: Use the COS instruction to take the cosine of a value (Source in radians) and store the result in the Destination. The Source must be greater than or equal to -205887.4 and less than or equal to 205887.4. The resulting value in the Destination is always greater than or equal to -1 and less than or equal to 1.

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets sets is an overflow is generated; otherwise resets sets is the result is zero; otherwise resets sets if the result is negative; otherwise resets

Operands:
Operand: Source Destination Valid Types: immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

COS Example:

If the preceding instructions are true, the controller performs the cosine operation.

Publication 1756-6.4.1 review January 1998 - preliminary

14-4

Trigonometric Instructions

Tangent (TAN)
Description: Use the TAN instruction to take the tangent of a value (Source in radians) and store the result in the Destination. The Source must be greater than or equal to -102943.7 and less than or equal to 102943.7. The resulting value in the Destination is always a real number.

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets sets is an overflow is generated; otherwise resets sets is the result is zero; otherwise resets sets if the result is negative; otherwise resets

Operands:
Operand: Source Destination Valid Types: immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

TAN Example:

If the preceding instructions are true, the controller performs the tangent operation.

Publication 1756-6.4.1 review January 1998 - preliminary

Trigonometric Instructions

14-5

Arc Sine (ASN)


Description: Use the ASN instruction to take the arc sine of a value (Source in radians) and store the result in the Destination. The Source must be greater than or equal to -1 and less than or equal to 1. The resulting value in the Destination is always greater than or equal to -/2 and less than or equal to /2 (where = 3.141592).

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets sets is an overflow is generated; otherwise resets sets is the result is zero; otherwise resets sets if the result is negative; otherwise resets

Operands:
Operand: Source Destination Valid Types: immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

ASN Example:

If the preceding instructions are true, the controller performs the arc sine operation.

Publication 1756-6.4.1 review January 1998 - preliminary

14-6

Trigonometric Instructions

Arc Cosine (ACS)


Description: Use the ACS instruction to take the arc cosine of a value (Source in radians) and store the result in the Destination. The Source must be greater than or equal to -1 and less than or equal to 1. The resulting value in the Destination is always greater than or equal to 0 or less than or equal to (where = 3.141592).

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets sets is an overflow is generated; otherwise resets sets is the result is zero; otherwise resets sets if the result is negative; otherwise resets

Operands:
Operand: Source Destination Valid Types: immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

ACS Example:

If the preceding instructions are true, the controller performs the arc cosine operation.

Publication 1756-6.4.1 review January 1998 - preliminary

Trigonometric Instructions

14-7

Arc Tangent (ATN)


Description: Use the ATN instruction to take the arc tangent of a value (Source in radians) and store the result in the Destination. The resulting value in the Destination is always greater than or equal to -/2 and less than or equal to /2 (where = 3.141592).

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets sets is an overflow is generated; otherwise resets sets is the result is zero; otherwise resets sets if the result is negative; otherwise resets

Operands:
Operand: Source Destination Valid Types: immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false

ATN Example:

If the preceding instructions are true, the controller performs the arc tangent operation.

Publication 1756-6.4.1 review January 1998 - preliminary

14-8

Trigonometric Instructions

Notes:

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

15

Advanced Math Instructions


(LN, LOG, XPY)
Introduction
The advanced math instructions evaluate operations using an expression or a specific arithmetic instruction.
If you want to: Take the natural log of a value. Take the log base 10 of a value. Raise a value to the power of another value. Use this instruction: LN LOG XPY See page: 15-2 15-3 15-4

You can mix values of different data types, such as floating point and integer. If you use floating point as the source, use floating point as the destination. You can mix data types, but loss of accuracy and rounding error might occur. If the rung with the compute instruction goes true, the controller performs the computation.

Using arithmetic status flags


To access arithmetic status flags, use an XIC or XIO instruction with one of the status keywords.
Use this keyword: For this status flag: S:C S:N S: V S:Z carry sign (result is negative) overflow zero With this read/write access: read/write read/write read/write read/write

Use the RES instruction to clear the status flags.

Publication 1756-6.4.1 review January 1998 - preliminary

15-2

Advanced Math Instructions

Natural Log (LN)


Description: Use the LN instruction to take the natural log of the Source and store the result in the Destination. The Source must be greater than zero. The resulting Destination is greater than or equal to -87.33655 and less than or equal to 88.72284. The LN instruction executes once each program scan as long as the rung is true. If you only want the values added once, use an ONS instruction.

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets sets is an overflow is generated; otherwise resets sets is the result is zero; otherwise resets sets if the result is negative; otherwise resets

Operands:
Operand: Source Destination Valid Types: immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false 0.15 0.16

LN Example:

If the preceding instructions are true, the controller performs the natural log operation.

Publication 1756-6.4.1 review January 1998 - preliminary

Advanced Math Instructions

15-3

Log Base 10 (LOG)


Description: Use the LOG instruction to take the log base 10 of the Source and store the result in the Destination. The Source must be greater than zero. The resulting Destination is greater than or equal to -37.92978 and less than or equal to 38.53184. The LOG instruction executes once each program scan as long as the rung is true. If you only want the values added once, use an ONS instruction.

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets sets is an overflow is generated; otherwise resets sets is the result is zero; otherwise resets sets if the result is negative; otherwise resets

Operands:
Operand: Source Destination Valid Types: immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false 0.15 0.17

LOG Example:

If the preceding instructions are true, the controller performs the log operation.

Publication 1756-6.4.1 review January 1998 - preliminary

15-4

Advanced Math Instructions

X to the Power of Y (XPY)


Description: Use the XPY instruction to take the Source A (X) to the power of Source B (Y) and store the result in the Destination. If Source A is negative, Source B must be an integer value. The XPY instruction uses this algorithm: XPY = X**Y The controller evaluates x0=1 and 0x=0. The XPY instruction executes once each program scan as long as the rung is true. If you only want the values added once, use an ONS instruction.

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets sets is an overflow is generated; otherwise resets sets is the result is zero; otherwise resets sets if the result is negative; otherwise resets

Operands:
Operand: Source A Source B Destination Valid Types: immediate or tag SINT, INT, DINT, or REAL immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true false 0.17 0.18

Publication 1756-6.4.1 review January 1998 - preliminary

Advanced Math Instructions

15-5

XPY Example:

If the preceding instructions are true, the controller performs the exponential operation.

Publication 1756-6.4.1 review January 1998 - preliminary

15-6

Advanced Math Instructions

Notes:

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

16

Math Conversion Instructions


(DEG, RAD, TOD, FRD)
Introduction
The math conversion instructions convert values.
If you want to: Convert radians into degrees. Convert degrees into radians. Convert an integer value to a BCD value. Convert a BCD value to an integer value. Use this instruction: DEG RAD TOD FRD See page: 16-2 16-3 16-4 16-5

If the rung with the compute instruction goes true, the controller performs the computation.

Using arithmetic status flags


To access arithmetic status flags, use an XIC or XIO instruction with one of the status keywords.
Use this keyword: For this status flag: S:C S:N S: V S:Z carry sign (result is negative) overflow zero With this read/write access: read/write read/write read/write read/write

Use the RES instruction to clear the status flags.

Publication 1756-6.4.1 review January 1998 - preliminary

16-2

Math Conversion Instructions

Degrees (DEG)
Description: Use the DEG instruction to convert the Source (in radians) to degrees and store the result in the Destination.

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets sets is an overflow is generated; otherwise resets sets is the result is zero; otherwise resets sets if the result is negative; otherwise resets

Operands:
Operand: Source Destination Valid Types: immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true 35.03 33.67 false 0.15 0.17

DEG Example:

If the preceding instructions are true, the controller converts value_1 from radians to degrees.

Publication 1756-6.4.1 review January 1998 - preliminary

Math Conversion Instructions

16-3

Radians (RAD)
Description: Use the RAD instruction to convert the Source (in degrees) to radians and store the result in the Destination. The RAD instruction uses this algorithm: Source*/180

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets sets is an overflow is generated; otherwise resets sets is the result is zero; otherwise resets sets if the result is negative; otherwise resets

Operands:
Operand: Source Destination Valid Types: immediate or tag SINT, INT, DINT, or REAL tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL
executes does not execute executes

Description: true 36.20 34.20 false 0.17 0.17

RAD Example:

If the preceding instructions are true, the controller converts value_1 from degrees to radians.

Publication 1756-6.4.1 review January 1998 - preliminary

16-4

Math Conversion Instructions

Convert to BCD (TOD)


Description: Use the TOD instruction to convert an integer value (0 Source to a BCD value and store the result in the Destination.

99,999,999)

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets sets if the integer value is outside the range 0-99,999,999; otherwise resets sets is the result is negative or zero; otherwise resets always resets

Operands:
Operand: Source Destination Valid Types: immediate or tag SINT, INT, or DINT 0<=Source<=99,999,999 tag SINT, INT, or DINT

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 15.96 na na
executes does not execute executes

false 0.18 na

TOD Example:

If the preceding instructions are true, the controller converts value_1 from an integer value to a BCD value.

Publication 1756-6.4.1 review January 1998 - preliminary

Math Conversion Instructions

16-5

Convert to Integer (FRD)


Description: Use the FRD instruction to convert a BCD value (Source) to an integer value and store the result in the Destination.

Arithmetic status flags


This flag: carry (S:C) overflow (S:V) zero (S:Z) sign (S:N) The controller: always resets always resets sets is the result is zero; otherwise resets always resets

Operands:
Operand: Source Destination Valid Types: immediate or tag SINT, INT, or DINT tag SINT, INT, or DINT

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 9.20 na na
executes does not execute executes

false 0.16 na

FRD Example:

If the preceding instructions are true, the controller converts value_1 from a BCD value to an integer value.

Publication 1756-6.4.1 review January 1998 - preliminary

16-6

Math Conversion Instructions

Notes:

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

17

Motion Concepts
Introduction
The ControlLogix system takes a new approach to motion control. In the ControlLogix system, the motion application program execution and motion planner functions reside in the Logix5550 controller, creating highly-integrated motion and sequential control. A smart axis motion module receives coarse position commands from the ControlLogix controller and closes a high-speed (100s) fine planner, position loop, and velocity loop. The ControlLogix chassis allows high-speed synchronization of one or more ControlLogix processors and up to 16 motion control modules, which means one chassis can support up to 32 axes. RSLogix5000 programming software provides complete motion configuration and application programming, which eliminates the need to purchase and maintain multiple programming tools. An axis wizard guides you through assigning and configuring an axis. The axis wizard also initiates a powerful auto-tune utility which you can use to determine all axis gains and dynamics. The Logix5550 controller uses 27 high-level motion instructions, including instructions for homing, jogging, point-to-point positioning, complex gearing, and high-speed registration. You can insert these instructions directly into the ladder diagram application program.

Publication 1756-6.4.1 review January 1998 - preliminary

17-2

Motion Concepts

Identifying the Components of the ControlLogix Motion System

The Logix5550 Controller (1756-L1)


The Logix5550 controller is the main component in the ControlLogix system. It supports sequential and motion functions, and it performs all of the motion command execution and motion trajectory planner functions. You can use one or more Logix5550 controllers in each chassis, and each controller can control up to 16 motion modules. The Logix5550 controller supports the following motion features: An extensive command set including 27 motion instructions A high-speed motion task which executes motion commands and generates move profiles The ability to manage up to 16 Analog/Encoder Servo modules for a total of 32 axes

The Analog/Encoder Servo Module (1756-MO2AE)


The Analog/Encoder Servo module provides an analog/quadrature encoder servo drive interface. The servo module receives configuration and move information from the Logix5550 controller and manages motor position, velocity, and torque. The servo module supports: Connection capability for up to two drives Two 16-bit analog outputs Two quadrature encoder limits Two home limit switch inputs Two drive fault inputs Two drive enable outputs

100 s/200 s Position and Velocity loop

RSLogix5000 Programming Software


The RSLogix5000 programming software provides complete programming and commissioning support for the ControlLogix system. RSLogix5000 is the only programming software needed to fully configure and program the ControlLogix motion control systems. RSLogix5000 software includes the following features: Wizards for servo axis configuration including drive hookup diagnostics and auto-tuning Ladder-based application programming including support for 27 motion commands On-line editing and monitoring capability Multiple network support including ControlNet, Ethernet, DeviceNet, and DH+/RIO

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Concepts

17-3

Developing a Motion Control Application Program

To develop a motion control application program, you must complete several steps including: Adding a motion module to the I/O Configuration list Identifying and configuring each axis Writing an application program using the motion control instruction set

1 Select I/O Configuration 2 Click the right mouse button and select New Module 3 Select the 1756-MO2AE module

Adding a motion module


Use your programming software to add and configure the motion module. The software has a wizard for configuring motion module. To add a motion module to the I/O configuration list:
In this field: Name Enter: Enter a name for the motion module. The name can: have as many as 40 characters contain letters, numbers, and underscores (_) Slot Description Select the chassis slot number of the motion module. Enter a description of the module (optional). The description can: have as many as 128 characters contain letters, numbers, and underscores (_)

Identifying and configuring each axis


When you add the motion module, you identify and configure the axes for each channel on the module. 1. Select the channel you want to configure. 2. Click New Axis.
In this field: Name Enter: Enter a name for the axis. The name can: have as many as 40 characters contain letters, numbers, and underscores (_) Enter a description of the axis (optional). The description can: have as many as 128 characters contain letters, numbers, and underscores (_) Type Select AXIS.

Description

3. Click Configure... 4. Follow the axis wizard to configure the axis. For more information, see the Motion Control User Manual, publication 1756-x.xx.

Publication 1756-6.4.1 review January 1998 - preliminary

17-4

Motion Concepts

Writing a motion application program


To write a motion application program, you can insert motion instructions directly into the ladder diagram application program. The motion instruction set consists of five groups of motion instructions:
Group Motion state instructions Motion move instructions Motion group instructions Motion event instructions Motion configuration instructions For more information, refer to: Chapter 18 Chapter 19 Chapter 20 Chapter 21 Chapter 22

These instructions operate on one or more axes. You must identify and configure axes before you can use them. For more information about identifying and configuring axes, refer to the Motion Control User Manual, publication 1756-x.xx.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Concepts

17-5

Understanding Instruction Timing

Motion instructions use three types of timing sequences: Immediate timing, where the instruction completes in one scan. Delayed (message) timing, where the instruction completes over several scans because the instruction sends messages to the servo module. Process timing, where the instruction could take an indefinite amount of time to complete.

Immediate type instructions


Immediate type motion instructions execute to completion in one scan. If the processor detects an error during the execution of these instructions, the error status bit sets and the operation ends. Examples of immediate type instructions include the: Motion Change Dynamics (MCD) instruction Motion Group Strobe Position (MGSP) instruction

Immediate instructions work as follows: 1. When the rung that contains the motion instruction becomes true, the processor: Sets the enable (EN) bit. Clears the done (DN) bit. Clears the error (ER) bit.

2. The processor executes the instruction completely. 3.


If the processor: Does not detect an error when the instruction executes Detects an error when the instruction executes Then: The processor sets the .DN bit. The processor sets the .ER bit and stores an error code in the control structure.

4. The next time the rung becomes false, the processor clears the .EN bit.

Publication 1756-6.4.1 review January 1998 - preliminary

17-6

Motion Concepts

5. The processor can execute the instruction again when the rung becomes true.

EN

DN

ER Scan Scan Scan Scan rung true rung truerung false rung true

Delayed (message) type instructions


Delayed type motion instructions send one or more messages to the servo module. Examples of delayed type instructions include the: Motion Direct Drive On (MDO) instruction Motion Redefine Position (MRP) instruction

Delayed type instructions work as follows: 1. When the rung that contains the motion instruction becomes true, the processor: Sets the enable (EN) bit. Clears the done (DN) bit. Clears the error (ER) bit.

2. The processor begins to execute the instruction by setting up a message request to the servo module. Note: The remainder of the instruction executes in parallel to the program scan.

3. The processor checks if the servo module is ready to receive a new message. 4. The processor places the results of the check in the message status word of the control structure. 5. When the module is ready, the processor constructs and transmits the message to the module. Important: This process may repeat several times if the instruction requires multiple messages.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Concepts

17-7

6.
If the processor: Does not detect an error when the instruction executes Detects an error when the instruction executes Then: The processor sets the .DN bit. The processor sets the .ER bit and stores an error code in the control structure.

7. The next time the rung becomes false, the processor clears the .EN bit. 8. When the rung becomes true, the processor can execute the instruction again.

EN

DN

ER Scan Scan Execution Scan Scan rung truerung false completerung falserung true

Process type instructions


Process type motion instructions initiate motion processes that can take an indefinite amount of time to complete. Examples of process type instructions include the: Motion Arm Watch Position (MAW) instruction Motion Axis Move (MAM) instruction

Publication 1756-6.4.1 review January 1998 - preliminary

17-8

Motion Concepts

Process type instructions work as follows: 1. When the rung that contains the motion instruction becomes true, the processor: Sets the enable (.EN) bit. Clears the done (.DN) bit. Clears the error (.ER) bit. Clears the process complete (.PC) bit.

2. The controller initiates the motion process. 3.


If the processor: Does not detect an error when the instruction executes Detects an error when the instruction executes Then the controller: Sets the .DN bit. Sets the in process (.IP) bit. Sets the .ER bit. Stores an error code in the control structure. Does not change the .IP and .PC bits. Detects another instance of the motion instruction Clears the .IP bit for that instance.

4. When the motion process reaches the point where the instruction can be executed again, the controller sets the .DN bit. For some process type instructions, like MAM, this will occur on the first scan. For others, like MAH, the .DN bit will not be set until the entire homing process is complete. 5. Once the initiation of the motion process completes, the program scan can continue. Important: If one of the following events occurs during the motion process, the controller sets the .DN bit and the .PC bit and clears the .IP bit: The motion process completes. Another instance of the instruction executes. Another instruction stops the motion process. A motion fault stops the motion process.

Important: The remainder of the instruction and the control process continue in parallel with the program scan. 6. The next time the rung becomes false after the .DN bit sets, the controller clears the .EN bit.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Concepts

17-9

7. When the rung becomes true, the instruction can execute again.

EN

DN

ER

IP

PC Scan Scan Execution Scan Process rung truerung falsecompleterung falsecomplete

Publication 1756-6.4.1 review January 1998 - preliminary

17-10

Motion Concepts

Using the Control Structure

The controller uses the Motion_Instruction structure to store status information during the execution of motion instructions. Every motion instruction has a motion_control parameter which requires a motion_instruction tag for this purpose. For each motion instruction you use, define a separate motion_instruction tag. The motion control structure is shown below:
MOTION_INSTRUCTION structure
bit number 31 30 29 28 27 26 EN DN ER IP PC error code (.ERROR) (16 bits) message status (.STATUS) (8 bits) execution state (.STATE) (8 bits) 16 15 0

Control bit or word: .EN bit .DN bit .ER bit .IP bit .PC bit

Description: The enable bit indicates that the instruction is enabled. The done bit indicates that the operation is complete. The error bit indicates when the operation generates an overflow. The in process bit indicates that a process is being executed. The process complete bit indicates that the operation is complete. The .DN bit sets after an instruction has completed execution. The .PC bit sets when the initiated process has completed.

.ERR word .MSG word .EXE word

The error value contains the error code associated with a motion function. The message status value indicates the status condition of any message associated with the motion function. The execution status value keeps track of the execution state of a function. Many motion functions have several steps and this value tracks these steps.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Concepts

17-11

Error codes (.ERROR)


Error Code: 1 2 3 Description: The axis value is not an axis type. The group value is not a group type. The instruction tried to execute while another instance of this instruction was executing. This can occur when the controller executes a messaging instruction without checking the .DN bit of the preceding instruction. The instruction tried to execute on an axis whose servo loop is closed. The instruction tried to execute on an axis whose servo loop is not closed. The axis drive is enabled. The axis is in the shutdown state. The axis is not configured as a servo axis type. The instruction tried to execute in a direction that aggravates the current overtravel condition. The master axis reference is the same as the slave axis reference. The axis is not configured. Messaging to the servo module failed. The instruction tried to use a parameter that is outside the range limit.

4 5 6 7 8 9 10 11 12 13

Message status (.STATUS)


Message Status: 0x0 0x1 0x2 0x3 0x4 Description: The message was successful. The module is processing another message. The module is waiting for a response to a previous message. The response to a message failed. The module is not ready for messaging.

Execution status (.STATE)


The execution status is always set to 0 when the controller sets the .EN bit for a motion instruction. Other execution states depend on the motion instruction. See the specific instruction for details (not every motion instruction has additional execution states).

Publication 1756-6.4.1 review January 1998 - preliminary

17-12

Motion Concepts

Using Motion Variables

The Logix5550 controller stores motion status information in the AXIS and MOTION_GROUP objects. You can use the GSV and SSV instruction to set and read data within these objects. This section defines the motion class and motion instance variables which you can access using the GSV and SSV instructions. See chapter 3 for more information about the GSV and SSV instructions.

Motion instance variables


To use the motion instance variables, choose AXIS from the object list of the GSV and SSV instructions.
Variable: ACStopMode Description: The type of stop to perform on your axis. Value: 0 1 2 ActualPosition ActualVelocity AverageVelocity AverageVelocityTimebase AxisConfigurationState AxisInstance AxisType Meaning: fast stop fast shutdown hard shutdown

The actual position of your axis. The actual velocity of your axis. The average velocity of your axis. The timebase of the average velocity of your axis. The state of the axis configuration. The instance of the axis. The type of axis that you are using. Value: 0 1 2 Meaning: unused axis position only axis servo axis

Bandwidth CommandPosition CommandVelocity ConversionConstant DampingFactor DriveFaultAction

The unity gain bandwidth that the controller uses to calculate the gains for a Motion Apply Axis Tuning (MAAT) instruction. The command position of your axis. The command velocity of your axis. The conversion factor used to convert from your units to feedback counts. The value used in calculating the maximum position servo bandwidth during the execution of the Motion Run Axis Tuning (MRAT) instruction. The operation performed when a drive fault occurs. Value: 0 1 2 3 Meaning: shutdown the axis disable the drive stop the commanded motion change the status bit only

EffectiveInertia EncoderLossFaultAction

The inertia value for the axis as calculated from the measurements the controller made during the last Motion Run Axis Tuning (MRAT) instruction. The operation performed when an encoder loss fault occurs. Value: 0 1 2 3 Meaning: shutdown the axis disable the drive stop the commanded motion change the status bit only

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Concepts Variable: EncoderNoiseFaultAction Description: The operation performed when an encoder noise fault occurs. Value: 0 1 2 3 FrictionCompensation GroupInstance HomeMode Meaning: shutdown the axis disable the drive stop the commanded motion change the status bit only

17-13

The fixed output level used to compensate for static friction. The instance number of the motion group that contains your axis. The homing mode for your axis. Value: 0 1 2 Meaning: passive homing active homing (default) absolute homing

HomePosition HomeReturnSpeed HomeSequenceType

The homing position of your axis. The homing return speed of your axis. The homing sequence type for your axis. Value: 0 1 2 3 Meaning: immediate homing switch homing marker homing switch-marker homing (default)

HomeSpeed MapTableInstance MaximumAcceleration MaximumDeceleration MaximumNegativeTravel MaximumPositiveTravel MaximumSpeed ModuleChannel MotionConfigurationBits

The homing speed of your axis. The I/O map instance of the servo module. The maximum acceleration of your axis. The maximum deceleration of your axis. The maximum negative travel limit. The maximum positive travel limit. The maximum speed of your axis. The channel of your servo module. The motion configuration bits for your axis. Bit: 0 1 2 Meaning: home direction home switch normally-closed home marker edge negative Meaning: servo parameters are out of sync with the controller Bit Name: ACCEL_STS DECEL_STS MOV_STS JOG_STS GEAR_STS HOM_STS CLUTCH_STS Meaning: acceleration deceleration move jog gear homing clutch

MotionFaultBits

The motion fault bits for your axis. Bit: 0

MotionStatusBits

The motion status bits for your axis. Bit: 0 1 2 2 4 5 6

MotorEncoderTestIncrement OutputLimit

The amount of motion that is necessary to initiate the Motion Run Hookup Diagnostic (MRHD) test. The value of the maximum servo output voltage of your axis.

Publication 1756-6.4.1 review January 1998 - preliminary

17-14

Motion Concepts Variable: OutputOffset OutputScaling PositionAccelerationFFGain PositionError PositionErrorFaultAction Description: The value used to offset the effects of the cumulative offsets of the servo module DAC output and the servo drive input. The value used to convert the output of the servo loop into the equivalent voltage to the drive. The torque command output necessary to generate the commanded acceleration. The difference between the actual and command position of an axis. The operation performed when a position error fault occurs. Value: 0 1 2 3 PositionErrorTolerance PositionIError PositionIntegralGain PositionLockTolerance PositionProportionalGain PositionUnwind PositionVelocityFFGain RegistrationPosition ServoConfigurationBits Meaning: shutdown the axis disable the drive stop the commanded motion change the status bit only

The amount of position error that the servo tolerates before issuing a position error fault. The sum of the position error for an axis. The value used to achieve accurate axis positioning despite disturbances such as static friction and gravity. The amount of position error that the servo module tolerates when giving a true position locked status indication. The value the controller multiples with the position error to correct for the position error. The value used to perform the automatic unwind of the rotary axis. The velocity command output necessary to generate the commanded velocity. The registration position for your axis. The servo configuration bits for your servo loop. Bit: 0 1 2 3 4 5 6 7 8 9 Meaning: rotary axis external velocity servo drive encoder polarity negative servo polarity negative soft overtravel checking position error checking encoder loss fault checking encoder noise fault checking drive fault checking drive fault normally-closed Bit Name: WATCH_EV_ARM_STS WATCH_EX_STS REG_EV_ARM_STS REG_EX_STS HOM_EV_ARM_STS HOM_EV_STS Meaning: watch event armed watch event registration event armed registration event home event armed home event

ServoEventBits

The servo event bits for your servo loop. Bit: 0 1 2 3 4 5

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Concepts Variable: ServoFaultBits Description: The servo fault bits for your servo loop. Bit: 0 1 2 3 4 5 6 7 8 9 ServoOutputLevel ServoStatusBits Bit Name: P_OTRVL_FLT N_OTRVL_FLT POS_ERR_FLT ENC_CHA_LS_FLT ENC_CHB_LS_FLT1 ENC_CHZ_LS_FLT ENC_NS_FLT DRV_FLT SYNC_CONN_FLT HARD_FLT Meaning: positive overtravel fault negative overtravel fault position error fault encoder channel A loss fault encoder channel B loss fault encoder channel Z loss fault encoder noise fault drive fault synchronous connection fault servo hardware fault

17-15

The output voltage level for your axis servo loop. The status bits for your servo loop. Bit: 0 1 2 3 4 13 14 15 Bit Name: SRV_ACT_STS DRV_EN_STS OUT_LMT_STS POS)LCK_STS POS)SYNC_STS TUNE_STS TEST_STS SHUTDOWN_STS Meaning: position error update position ierror update velocity error update velocity ierror update velocity command update velocity command update velocity feedback update servo output level update Meaning: shutdown the axis disable the drive stop the commanded motion change the status bit only Meaning: servo action drive enable output limit position lock position sync tuning process test diagnostic axis shutdown

ServoStatusUpdateBits

The servo status update bits for your axis. Bit: 0 1 2 3 4 5 6 6

SoftOvertravelFaultAction

The operation performed when a soft overtravel fault occurs. Value: 0 1 2 3

StartActualPosition StartCommandPosition StrobeActualPosition StrobeCommandPosition TestDirectionForward

The actual position of your axis when new commanded motion starts for the axis. The command position of your axis when new commanded motion starts for the axis. The actual position of an axis when the Motion Group Strobe Position (MGSP) instruction executes. The command position of an axis when the Motion Group Strobe Position (MGSP) instruction executes. The direction of axis travel during the Motion Run Hookup Diagnostic (MRHD) instruction as seen by the servo module. Value: 0 1 Meaning: negative (reverse) direction positive (forward) direction

Publication 1756-6.4.1 review January 1998 - preliminary

17-16

Motion Concepts Variable: TestStatus Description: The status of the last Motion Run Hookup Diagnostic (MRHD) instruction. Value: 0 1 2 3 TuneAccel TuneAccelTime TuneDecel TuneDecelTime TuneRiseTime TuneStatus Meaning: test process successful test in progress test exceeded 2-second time-out test process stopped by the user

The acceleration value measured during the last Motion Run Axis Tuning (MRAT) instruction. The acceleration time in seconds measured during the last Motion Run Axis Tuning (MRAT) instruction. The deceleration value measured during the last Motion Run Axis Tuning (MRAT) instruction. The deceleration time in seconds measured during the last Motion Run Axis Tuning (MRAT) instruction. The axis rise time in seconds measured during the last Motion Run Axis Tuning (MRAT) instruction. The status of the last Motion Run Axis Tuning (MRAT) instruction. Value: 0 1 2 3 4 Meaning: test process successful tuning in progress axis reached tuning travel limit axis polarity set incorrectly tune process aborted by user

TuneVelocityBandwidth TuneVelocityScaling TuningConfigurationBits

The bandwidth of the drive as calculated from the measurements made during the last Motion Run Axis Tuning (MRAT) instruction. The axis drive scaling factor measured during the last Motion Run Axis Tuning (MRAT) instruction.

The tuning configuration bits for your axis.


Bit: 0 1 2 3 4 5 Meaning: tuning direction (0=forward, 1=reverse) tune position error integrator tune velocity error integrator tune velocity feedforward bit acceleration feedforward tune velocity low-pass filter

TuningTravelLimit TuningVelocity VelocityCommand VelocityError VelocityFeedback VelocityFilterBandwidth VelocityIError VelocityIntegralGain VelocityProportionalGain WatchPosition

The travel limit used by the Motion Run Axis Tuning (MRAT) instruction to limit the action of the action during tuning. The maximum speed initiated by the Motion Run Axis Tuning (MRAT) instruction. The current velocity reference to the velocity servo loop for an axis. The difference between the commanded and actual velocity of a servo axis. The actual velocity of your axis as estimated by the servo module. The bandwidth of the servo low-pass digital output filter. The sum of the velocity error for a specified axis. The value that the controller multiplies with the Velocity IError value to correct the velocity error. The value that the controller multiplies with the Velocity Error to correct the velocity error. The watch position of your axis.

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

18

Motion State Instructions


(MSO, MSF, MASD, MASR, MDO,MDF, MAFR)
Introduction
Motion state control instructions directly control or change the operating states of an axis. The motion conversion instructions are:
If you want to: Enable the servo drive and activate the axis servo loop. Disable the servo drive and deactivate the axis servo loop. Force an axis into the shutdown operating state. Once the axis is in the shutdown operating state, the controller blocks any instructions that initiate axis motion. Change an axis from an existing shutdown operating state to an axis ready operating state. If all of the axes of a servo module are removed from the shutdown state as a result of this instruction, the OK relay contacts for the module will close. Activate the servo drive and set the servo output voltage of an axis. Disable the servo drive and set the servo output voltage to the output offset voltage. Clear all motion faults for an axis. Use this instruction: MSO MSF MASD See page: 18-3 18-5 18-7

MASR

18-10

MDO MDF

18-12 18-14

MAFR

18-16

Publication 1756-6.4.1 review January 1998 - preliminary

18-2

Motion State Instructions

The five operating states of an axis are:


Operating State: Axis ready Description: This is the normal power-up state of the axis. In this state: Direct drive control the servo module drive enable output is inactive. servo action is disabled. no servo faults are present.

This operating state allows the servo module DAC to directly control an external drive. In this state: the servo module drive enable output is active. servo action is disabled. no servo faults are present.

Servo control

This operating state allows the servo module to perform closed loop motion. In this state: the servo module drive enable output is active. servo action is enabled. no servo faults are present. the axis is forced to maintain the commanded servo position.

Axis faulted

In this operating state, a servo fault is present, and the status of the drive enable output, the action of the servo, and the condition of the OK contact depend on the faults and fault actions that are present. This operating state allows the OK relay contacts to open a set of contacts in the E-stop string of the drive power supply. In this state: the servo module drive enable output is inactive. servo action is disabled. the OK contact is open.

Shutdown

To determine the operating state of the axis, you can look at the DRIVE and FDBK LEDs on the servo module.
If the DRIVE LED is: Flashing green Solid green Solid green Solid red Flashing red And the FDBK LED is: Flashing green Flashing green Solid green Flashing or solid red Flashing green Then the operating state of the axis is: Axis ready Direct drive control Servo control Axis faulted Shutdown

Publication 1756-6.4.1 review January 1998 - preliminary

Motion State Instructions

18-3

Motion Servo On (MSO)


Description: Use the MSO instruction to enable the servo drive and to activate the axis servo loop. A common use for this instruction is activating an axis servo loop in preparation for commanding motion. Important: This instruction causes an abrupt, uncontrolled stop. Do not use this instruction while the axis is moving. The MSO instruction uses delayed timing. To use the MSO instruction, configure the axis as a servo axis. Operands:
Operand: Axis Motion control Valid Types: tag AXIS tag MOTION_INSTRUCTION

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Control status:
Control bit or word: .EN bit .DN bit .ER bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction enables axis servo action. The error bit sets when the instruction detect an error, such as if the axis is not configured.

Publication 1756-6.4.1 review January 1998 - preliminary

18-4

Motion State Instructions

MSO error codes (.ERROR)


Error Code: 1 3 Description: The axis value is not an axis type. The instruction tried to execute while another instance of this instruction was executing. This can occur when the servo module executes a messaging instruction without checking the .DN bit of the preceding instruction. The axis is in the shutdown state. The axis is not configured as a servo axis. The axis is not configured. Messaging to the servo module failed.

7 8 11 12

MDO changes to the servo module LEDs


This LED FDBK DRIVE Will change to Flashing green Flashing green Meaning Servo action is enabled. The drive enable output is active.

MSO changes to the axis status bits


Bit Name SRV_ACT_STS State True Meaning DRV_EN_STS ACCEL_STS DECEL_STS CLUTCH_STS JOG_STS MOV_STS GEAR_STS HOM_STS True False False False False False False False Axis is in the servo on state. Servo loop is active.

The drive enable output is active. The axis is not accelerating. The axis is not decelerating. The axis is not clutching. The axis is not jogging. The axis is not moving. The axis is not gearing. The axis is not homing.

MSO Example:

When the input instructions are true, the controller enables the servo drive and activates the axis servo loop configured by axis_1.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion State Instructions

18-5

Motion Servo Off (MSF)


Description: Use the MSF instruction to disable the servo drive and to deactivate the axis servo loop. Important: When you need to turn the axis manually, use the MSF instruction to turn off servo action. Although servo action is off, the controller continues to track the axis position. When the servo action is turned on using the Motion Servo On (MSO) instruction, the servo maintains the new position. The MSF instruction uses delayed timing. To use the MSF instruction, configure the axis as a servo axis. Operands:
Operand: Axis Motion control Valid Types: tag AXIS tag MOTION_INSTRUCTION

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Control status:
Control bit or word: .EN bit .DN bit .ER bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction enables axis servo action. The error bit sets when the instruction detect an error, such as if the axis is not configured.

Publication 1756-6.4.1 review January 1998 - preliminary

18-6

Motion State Instructions

MSF error codes (.ERROR).


Error Code: 1 3 Description: The axis value is not an axis type. The instruction tried to execute while another instance of this instruction was executing. This can occur when the servo module executes a messaging instruction without checking the .DN bit of the preceding instruction. The axis is not configured as a servo axis. The axis is not configured. Messaging to the servo module failed.

8 11 12

MSF changes to the servo module LEDs


This LED FDBK DRIVE Will change to Flashing green Flashing green Meaning Servo action is disabled. The drive enable output is inactive.

MSF changes to the axis status bits


Bit Name SRV_ACT_STS State False Meaning DRV_EN_STS ACCEL_STS DECEL_STS CLUTCH_STS JOG_STS MOV_STS GEAR_STS HOM_STS False False False False False False False False Axis is in the axis ready state. Servo loop is inactive.

The drive enable output is inactive. The axis is not accelerating. The axis is not decelerating. The axis is not clutching. The axis is not jogging. The axis is not moving. The axis is not gearing. The axis is not homing.

MSF Example:

When the input instructions are true, the controller disables the servo drive and the axis servo loop configured by axis_1.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion State Instructions

18-7

Motion Axis Shutdown (MASD)


Description: Use the MASD instruction to force an axis into the shutdown operating state. Once the axis is in the shutdown operating state, the controller blocks any instructions that initiate axis motion. If an axis is in the shutdown operating state, it means: The axis servo action is off. The drive enable output is deactivated The servo output level is the output offset value. The servo module OK contacts are open.

Important: You can use the OK contacts to open the contacts that open the E-stop string (if wired) that controls the power to the drive system. The axis will remain in the shutdown state until either a Motion Axis Shutdown Reset (MASR) instruction or a Motion Group Shutdown Reset (MGSR) instruction executes. The MASD instruction uses delayed timing. To use the MASD instruction, configure the axis as either a servo axis or a position only axis. Operands:
Operand: Axis Motion control Valid Types: tag AXIS tag MOTION_INSTRUCTION

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Publication 1756-6.4.1 review January 1998 - preliminary

18-8

Motion State Instructions

Control status:
Control bit or word: .EN bit .DN bit .ER bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction sets the axis to the shutdown state. The error bit sets when the instruction detect an error, such as if the axis is not configured.

MASD error codes (.ERROR)


Error Code: 1 3 Description: The axis value is not an axis type. The instruction tried to execute while another instance of this instruction was executing. This can occur when the servo module executes a messaging instruction without checking the .DN bit of the preceding instruction. The axis is not configured. Messaging to the servo module failed.

11 12

MASD changes to the servo module LEDs


This LED FDBK DRIVE Will change to Flashing green Flashing red Meaning Servo action is inactive. The drive enable output is inactive. The OK contact is open.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion State Instructions

18-9

MASD changes to the axis status bits


Bit Name SRV_ACT_STS State False Meaning DRV_EN_STS SHUTDOWN_STS ACCEL_STS DECEL_STS CLUTCH_STS JOG_STS MOV_STS GEAR_STS HOM_STS False True False False False False False False False The axis is in the axis ready state. The servo loop is inactive.

The drive enable output is inactive. The axis is in the shutdown state. The axis is not accelerating. The axis is not decelerating. The axis is not clutching. The axis is not jogging. The axis is not moving. The axis is not gearing. The axis is not homing.

MASD Example:

When the input instructions are true, the controller forces axis_1 into the shutdown operating state.

Publication 1756-6.4.1 review January 1998 - preliminary

18-10

Motion State Instructions

Motion Axis Shutdown Reset (MASR)


Description: Use the MASR instruction to change an axis from an existing shutdown operating state to an axis ready operating state. If all of the axes of a servo module are removed from the shutdown state as a result of this instruction, the OK relay contacts for the module will close. Important: Because this instruction can close the OK contacts, you can use this instruction to close the contacts in the E-stop string that control the power to the drive system. Once you close the E-stop string, you can reapply power to the drive. The MASR instruction uses delayed timing. To use the MASR instruction, configure the axis as either a servo axis or a position-only axis. Operands:
Operand: Axis Motion control Valid Types: tag AXIS tag MOTION_INSTRUCTION

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Control status:
Control bit or word: .EN bit .DN bit .ER bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction clears the axis from the shutdown state. The error bit sets when the instruction detect an error, such as if the axis is not configured.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion State Instructions

18-11

MASR error codes (.ERROR)


Error Code: 1 3 Description: The axis value is not an axis type. The instruction tried to execute while another instance of this instruction was executing. This can occur when the servo module executes a messaging instruction without checking the .DN bit of the preceding instruction. The axis is not configured. Messaging to the servo module failed.

11 12

MASR changes to the servo module LEDs


This LED FDBK DRIVE Will change to Flashing green Flashing green Meaning Servo action is inactive. The drive enable output is inactive. The OK contact is closed.

MASR changes to the axis status bits


Bit Name SRV_ACT_STS State False Meaning DRV_EN_STS SHUTDOWN_STS False False Axis is in the axis ready state. Servo loop is inactive.

The drive enable output is inactive. The axis is not in the shutdown state.

MASR Example:

When the input instructions are true, the controller resets axis_1 from a previous shutdown operating state into an axis ready operating state.

Publication 1756-6.4.1 review January 1998 - preliminary

18-12

Motion State Instructions

Motion Direct Drive On (MDO)


Description: Use the MDO instruction to activate the servo drive and to set the servo output voltage of an axis. Common uses for this instruction include: Creating an independent programmable analog output as an open loop speed reference for a drive. Testing a servo drive for closed loop operation.

The MDO instruction uses delayed timing. To use the MDO instruction: Operands:
Operand: Axis Drive Output1 Drive Units Valid Types: tag AXIS immediate or tag SINT, INT, DINT, or REAL immediate 0=volts 1=% of maximum output limit Motion control tag MOTION_INSTRUCTION

Configure the axis as either a servo axis or a position-only axis. Ensure that the axis operating state is axis ready. Ensure that servo action is off.

1. The 16-bit digital-to-analog convertor on the servo module limits the effective resolution of the MDO instruction to 305 V or 0.003%.

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

Execution

does not execute does not execute executes

Important: The servo output voltage is not limited by the output limit configuration parameter and is not affected by the servo output polarity configuration bit.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion State Instructions

18-13

Control status:
Control bit or word: .EN bit .DN bit .ER bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction updates the axis servo output. The error bit sets when the instruction detect an error, such as if the drive output value was too large.

MDO error codes (.ERROR)


Error Code: 1 3 Description: The axis value is not an axis type. The instruction tried to execute while another instance of this instruction was executing. This can occur when the servo module executes a messaging instruction without checking the .DN bit of the preceding instruction. The axis servo loop is closed. The axis is in the shutdown state. The axis is not configured. Messaging to the servo module failed. An input parameter was out of range.

4 7 11 12 13

MDO changes to the servo module LEDs


This LED: FDBK DRIVE Will change to: Flashing green Solid green Meaning: Servo action is disabled. The drive enable output is active.

MDO changes to the axis status bits


Bit Name DRV_EN_STS State True Meaning The axis is in the drive control state. The drive enable output is active.

MDO Example:
When the input instructions are true, the controller activates the servo drive for axis_1 and sets the servo output voltage of axis_1.

Publication 1756-6.4.1 review January 1998 - preliminary

18-14

Motion State Instructions

Motion Direct Drive Off (MDF)


Description: Use the MDF instruction to disable the servo drive and to set the servo output voltage to the output offset voltage. The output offset voltage is the output voltage which generates zero or minimal drive motion. You can specify this value during axis configuration. Common uses for this instruction include: Stopping motion initiated by a preceding Motion Direct Drive On (MDO) instruction. Changing an axis from the direct drive control operating state to the axis ready operating state.

The MDF instruction uses delayed timing. To use the MDF instruction, configure the axis as either a servo axis or a position-only axis. Operands:
Operand: Axis Motion control Valid Types: tag AXIS tag MOTION_INSTRUCTION

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

executes does not execute executes

Publication 1756-6.4.1 review January 1998 - preliminary

Motion State Instructions

18-15

Control status:
Control bit or word: .EN bit .DN bit .ER bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction disables the axis drive signals. The error bit sets when the instruction detect an error, such as if the axis is not configured.

MDF error codes (.ERROR)


Error Code: 1 3 Description: The axis value is not an axis type. The instruction tried to execute while another instance of this instruction was executing. This can occur when the servo module executes a messaging instruction without checking the .DN bit of the preceding instruction. The axis servo loop is closed. The axis is not configured as a servo axis. The axis is not configured. Messaging to the servo module failed.

4 8 11 12

MDF changes to the servo module LEDs


This LED FDBK DRIVE Will change to Flashing green Flashing green Meaning Servo action is disabled. The drive enable output is inactive.

MDF changes to the axis status bits


Bit Name DRV_EN_STS State False Meaning The axis is in the axis ready state. The drive enable output is inactive.

MDF Example:

When the input instructions are true, the controller deactivates the servo drive for axis_1 and sets the servo output voltage of axis_1 to the output offset value.

Publication 1756-6.4.1 review January 1998 - preliminary

18-16

Motion State Instructions

Motion Axis Fault Reset (MAFR)


Description: Use the MAFR instruction to clear all motion faults for an axis. This is the only method for clearing axis motion faults. Important: The MAFR instruction removes the fault status, but does not perform any other recovery, such as enabling servo action. In addition, when the controller removes the fault status, the condition that generated the fault(s) may still exist. If the condition is not corrected before using the MAFR instruction, the axis will immediately fault again. The MAFR instruction is usually used as a part of a fault handling program. A fault-handling program provides specific action in response to possible faults. Once the fault condition is removed, the MAFR block clears all the active fault status bits. The MAFR instruction uses delayed timing. To use the MAFR instruction, configure the axis as either a servo axis or a position-only axis. Operands:
Operand: Axis Motion control Valid Types: tag AXIS tag MOTION_INSTRUCTION

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Publication 1756-6.4.1 review January 1998 - preliminary

Motion State Instructions

18-17

Control status:
Control bit or word: .EN bit .DN bit .ER bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction clears all the fault status bits. The error bit sets when the instruction detect an error, such as if the axis is not configured.

MAFR error codes (.ERROR)


Error Code: 1 3 Description: The axis value is not an axis type. The instruction tried to execute while another instance of this instruction was executing. This can occur when the servo module executes a messaging instruction without checking the .DN bit of the preceding instruction. The axis is not configured. Messaging to the servo module failed.

11 12

MAFR changes to the servo module LEDs


This LED FDBK DRIVE Will change to Flashing or solid green Not solid red Meaning There are no feedback faults. There are no drive faults.

MAFR changes to the axis status bits


Bit Name SRV_ACT_STS State False Meaning DRV_EN_STS ACCEL_STS DECEL_STS CLUTCH_STS JOG_STS MOV_STS GEAR_STS HOM_STS False False False False False False False False The axis is in the axis ready state. The servo loop is inactive.

The drive enable output is inactive. The axis is not accelerating. The axis is not decelerating. The axis is not clutching. The axis is not jogging. The axis is not moving. The axis is not gearing. The axis is not homing.

Publication 1756-6.4.1 review January 1998 - preliminary

18-18

Motion State Instructions

MAFR Example:

When the input instructions are true, the controller clears all motion faults for axis_1.

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

19

Motion Move Instructions


(MAS, MAH, MAJ, MAM, MAG, MCD, MRP)
Introduction
Motion move instructions control all aspects of axis position. The motion move instructions are:
If you want to: Initiate a controlled stop of any motion process on an axis. Home an axis. Initiate a jog motion profile for an axis. Initiate a move profile for an axis. Provide electronic gearing between any two axes Change the speed, acceleration rate, or deceleration rate of a move profile or a jog profile in progress. Change the command or actual position of an axis. Use this instruction: MAS MAH MAJ MAM MAG MCD See page: 19-2 19-5 19-8 19-11 19-15 19-18

MRP

19-21

Publication 1756-6.4.1 review January 1998 - preliminary

19-2

Motion Move Instructions

Motion Axis Stop (MAS)


Description: Use a MAS instruction to initiate a controlled stop of any motion process on an axis and to clear associated motion status flags. Important: If the axis is not moving when the MAS instruction executes, the MAS instruction has no effect on motion. The MAS instruction uses immediate and process type timing. To use the MAS instruction, configure the axis as a servo or position-only axis. Operands:
Operand: Axis Stop type motion type to stop Valid Types: tag AXIS immediate stop all motion stop jogging stop moving stop gearing stop tuning test immediate

Change decel

select whether or not to change the 0=no 1=yes deceleration Decel deceleration rate of the axis Decel units immediate 0=% of maximum deceleration 1=units/second2 Motion control tag MOTION_INSTRUCTION immediate or tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Move Instructions

19-3

Control status:
Control bit or word: .EN bit .DN bit .ER bit .IP bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction initiates an axis stop. The error bit sets when the instruction detect an error, such as if the axis is not configured. The in process bit sets when the rung goes true. It resets when one of the following events occurs: The MAS instruction completes A servo fault terminates the MAS instruction .PC bit The process complete bit sets after the stop operation completes.

MAS error codes (.ERR)


Error Code: 1 5 7 8 11 13 Description: The axis value is not an axis type. The instruction tried to execute on an axis whose servo loop is not closed. The axis is in the shutdown state. The axis is not configured as a servo axis. The axis is not configured. The instruction tried to use a parameter that is outside the range limit.

MAS changes to the axis status bits


Bit Name CLUTCH_STS JOG_STS MOV_STS GEAR_STS HOM_STS State True False False False False Meaning The axis is stopping. The axis is not jogging. The axis is not moving. The axis is not gearing. The axis is not homing.

Publication 1756-6.4.1 review January 1998 - preliminary

19-4

Motion Move Instructions

MAS Example:

When the input instructions are true, the controller stop motion on axis_1 and clears all associated, motion status flags.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Move Instructions

19-5

Motion Axis Home (MAH)


Description: Use the MAH instruction to home an axis. Two different homing modes are available: Activethe axis executes the configured home sequence type and establishes an absolute axis position. Passivethe axis waits for the next marker pulse to establish an accurate home position.

The MAH instruction uses delayed and process type timing. To use the MAH instruction:
If you want to use: Active homing Then: Passive homing Configure the axis as a servo axis. Ensure that the axis operating state is servo on.

Configure the axis as either a servo axis or a position-only axis.

Operands:
Operand: Axis Motion control Valid Types: tag AXIS tag MOTION_INSTRUCTION

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Publication 1756-6.4.1 review January 1998 - preliminary

19-6

Motion Move Instructions

Control status:
Control bit or word: .EN bit .DN bit .ER bit .IP bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction initiates an axis home operation. The error bit sets when the instruction detect an error, such as if the axis is not configured. The in process bit sets when the rung goes true. It resets when one of the following events occurs: The MAH instruction completes. A Motion Axis Stop (MAS) instruction terminates the MAH instruction. A servo fault occurs. .PC The process complete bit sets when the instruction completes an axis home operation.

MAH error codes (.ERR)


Error Code: 1 3 Description: The axis value is not an axis type. The instruction tried to execute while another instance of this instruction was executing. This can occur when the servo module executes a messaging instruction without checking the .DN bit of the preceding instruction. The axis is in the shutdown state. The axis is not configured as a servo axis. The axis is not configured. Messaging to the servo module failed.

7 8 11 12

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Move Instructions

19-7

MAH changes to the axis status bits


Bit Name CLUTCH_STS JOG_STS MOV_STS GEAR_STS HOM_STS State False False False False True Meaning The axis is not clutching. The axis is not jogging. The axis is not moving. The axis is not gearing. The axis is homing.

MAH Example:

When the input instructions are true, the controller homes axis_1.

Publication 1756-6.4.1 review January 1998 - preliminary

19-8

Motion Move Instructions

Motion Axis Jog (MAJ)


Description: Use the MAJ instruction to initiate a jog motion profile for an axis. Important: To stop an axis jog, use the Motion Axis Jog (MAJ) instruction with a speed of zero or the Motion Axis Stop (MAS) instruction. The MAJ instruction uses immediate and process type timing. To use the MAJ instruction: Configure the axis as a servo axis. Ensure that the axis operating state is servo on.

Operands:
Operand: Axis Direction direction of the jog Speed speed to move the axis Speed units immediate 0=% of maximum speed 1=units/second Accel acceleration rate of the axis Accel units immediate 0=% of maximum acceleration 1=units/second2 Decel deceleration rate of the axis Decel units immediate 0=% of maximum deceleration 1=units/second2 Profile velocity profile to run the jog immediate 0=trapezoidal 1=S-curve immediate or tag SINT, INT, DINT, or REAL immediate or tag SINT, INT, DINT, or REAL Valid Types: tag AXIS immediate or tag SINT, INT, or DINT 0=forward jog 1=reverse jog immediate or tag SINT, INT, DINT, or REAL

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Move Instructions Operand: Merge Valid Types: immediate

19-9

select whether or not to turn all axis 0=disable 1=enable movement into pure jog Merge speed immediate

if you selected the merge check box, 0=programmed value in the speed field 1=current axis speed this field determines the speed of the jog profile. Motion control tag MOTION_INSTRUCTION

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Control status:
Control bit or word: .EN bit .DN bit .ER bit .IP bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction initiates an axis jog. The error bit sets when the instruction detect an error, such as if the axis is not configured. The in process bit sets when the rung goes true. It resets when one of the following events occurs: Another MAJ instance supersedes the current instruction. A Motion Axis Stop (MAS) instruction, a merge operation, or a servo fault terminates the MAJ instruction. .PC bit The process complete bit sets when the instruction completes an axis jog.

Publication 1756-6.4.1 review January 1998 - preliminary

19-10

Motion Move Instructions

MAJ error codes (.ERR)


Error Code: 1 3 Description: The axis value is not an axis type. The instruction tried to execute while another instance of this instruction was executing. This can occur when the servo module executes a messaging instruction without checking the .DN bit of the preceding instruction. The axis is in the shutdown state. The axis is not configured as a servo axis. The axis is not configured. The instruction tried to execute with a parameter that is outside the range limit.

7 8 11 13

MAJ changes to the axis status bits


Bit Name JOG_STS MOV_STS GEAR_STS State True False False Meaning The axis is jogging. The axis is not moving. The axis is not gearing.

MAJ Example:

When the input instructions are true, the controller initiates a jog motion for axis_1.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Move Instructions

19-11

Motion Axis Move (MAM)


Description: Use the MAM instruction to initiate a move profile for an axis. The MAM instruction uses immediate and process type timing. To use the MAM instruction: Configure the axis as a servo axis. Ensure that the axis operating state is servo on.

Operands:
Operand: Axis Move type type of move operation Valid Types: tag AXIS immediate or tag SINT, INT, or DINT 0=absolute move 1=incremental move 2=rotary shortest path move 3=rotary positive move 4=rotary negative move immediate or tag SINT, INT, DINT, or REAL

Position/Distance value of the absolute command position to move to, or for incremental movement, the value of the distance to move from the current command position Speed speed to move the axis Speed units

immediate or tag SINT, INT, DINT, or REAL

immediate 0=% of maximum speed 1=units/second

Accel acceleration rate of the axis Accel units

immediate or tag SINT, INT, DINT, or REAL

immediate 0=% of maximum acceleration 1=units/second2

Publication 1756-6.4.1 review January 1998 - preliminary

19-12

Motion Move Instructions Operand: Decel deceleration rate of the axis Decel units immediate 0=% of maximum deceleration 1=units/second2 Profile velocity profile to run the jog Merge immediate 0=trapezoidal 1=S-curve immediate Valid Types: immediate or tag SINT, INT, DINT, or REAL

select whether or not to turn all axis 0=disable 1=enable movement into pure jog Merge speed immediate

if you selected the merge check box, 0=programmed value in the speed field 1=current axis speed this field determines the speed of the move profile. Motion control tag MOTION_INSTRUCTION

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Move Instructions

19-13

Control status:
Control bit or word: .EN bit .DN bit .ER bit .IP bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction initiates an axis move. The error bit sets when the instruction detect an error, such as if the axis is not configured. The in process bit sets when the rung goes true. It resets when one of the following events occurs: The MAM instruction completes. A Motion Stop Axis (MAS) instruction, a merge operation, or a servo fault terminates the MAM instruction. .PC bit The process complete bit sets when the instruction completes an axis move.

MAM error codes (.ERR)


Error Code: 1 5 7 8 9 11 13 Description: The axis value is not an axis type. The instruction tried to execute on an axis whose servo loop is not closed. The axis is in the shutdown state. The axis is not configured as a servo axis. The instruction tried to execute in a direction that aggravates the current overtravel condition. The axis is not configured. The instruction tried to use a parameter that is outside the legal range limit.

MAM changes to the axis status bits


Bit Name JOG_STS MOV_STS GEAR_STS State False True False Meaning The axis is not jogging. The axis is moving. The axis is not gearing.

Publication 1756-6.4.1 review January 1998 - preliminary

19-14

Motion Move Instructions

MAM Example:

When the input instructions are true, the controller initiates a move for axis_1.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Move Instructions

19-15

Motion Axis Gearing (MAG)


Description: Use the MAG instruction to provide electronic gearing between any two axes. The MAG instruction uses immediate and process type timing. To use the MAG instruction: Configure the axis as a servo axis. Ensure that the axis operating state is servo on.

Operands:
Operand: Slave axis axis to perform the operation on Master axis axis that the slave axis follows Direction immediate or tag SINT, INT, or DINT tag AXIS Valid Types: tag AXIS

direction of the slave axis relative to 0=slave axis moves in the same direction as the master axis the master axis 1=slave axis moves in the opposite direction of 2=slave axis moves in the reverse of its current direction 3=slave axis to continues its current direction Master reference master position source Ratio format format of the ratio between the slave and the master axis Ratio signed, real value of the gear ratio of slave units per master units Slave counts Master counts immediate or tag SINT, INT, or DINT immediate or tag SINT, INT, or DINT immediate 0=actual source 1=command source immediate 0=real gear ratio 1=integer fraction of slave encoder counts to master encoder counts immediate or tag SINT, INT, or DINT

Publication 1756-6.4.1 review January 1998 - preliminary

19-16

Motion Move Instructions Operand: Clutch select whether or not to ramp the slave axis to gearing speed using the acceleration value Accel acceleration of the slave axis Accel units immediate 0=% of maximum acceleration 1=units/second2 Motion control tag MOTION_INSTRUCTION Valid Types: immediate 0=disable 1=enable immediate or tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Control status:
Control bit or word: .EN bit .DN bit .ER bit .IP bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction initiates an axis gear. The error bit sets when the instruction detect an error, such as if the axis is not configured. The in process bit sets when the rung goes true. It resets if a Motion Stop Axis (MAS) instruction, a merge operation, or a servo fault terminates the MAG instruction. .PC bit The process complete bit sets after the slave axis ramps to match the slave speed.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Move Instructions

19-17

MAG error codes (.ERR)


Error Code: 1 5 7 8 10 11 12 Description: The axis value is not an axis type. The instruction tried to execute on an axis whose servo loop is not closed. The axis is in the shutdown state. The axis is not configured as a servo axis. The master axis reference is the same as the slave axis reference. The axis is not configured. Messaging to the servo module failed.

MAG changes to the axis status bits


Bit Name CLUTCH_STS GEAR_STS State True True Meaning The axis is clutching. The axis is gearing.

MAG Example:

When the input instructions are true, the controller provides electronic gearing between axis_slave and axis_1.

Publication 1756-6.4.1 review January 1998 - preliminary

19-18

Motion Move Instructions

Motion Change Dynamics (MCD)


Description: Use the MCD instruction to change the speed, acceleration rate, or deceleration rate of a move profile or a jog profile in progress. The MCD instruction uses immediate type timing. To use the MCD instruction: Configure the axis as a servo axis. Ensure the axis operating state is servo on. If the axis does not have a move or a jog in progress when the MCD instruction executes, the instruction will have no effect.

Note:

Operands:
Operand: Axis Motion type motion profile to change Change speed Valid Types: tag AXIS immediate 0=jog 1=move immediate

select whether or not to change the 0=no 1=yes speed Speed speed to move the axis Speed units immediate 0=% of maximum speed 1=units/second Change accel select this check box to change the acceleration Accel acceleration rate of the axis Accel units immediate 0=% of maximum acceleration 1=units/second2 Change decel select this check box to change the deceleration Decel deceleration rate of the axis immediate 0=no 1=yes immediate or tag SINT, INT, DINT, or REAL immediate 0=no 1=yes immediate or tag SINT, INT, DINT, or REAL immediate or tag SINT, INT, DINT, or REAL

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Move Instructions Operand: Decel units Valid Types: immediate 0=% of maximum deceleration 1=units/second2 Motion control tag MOTION_INSTRUCTION

19-19

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Control status:
Control bit or word: .EN bit .DN bit .ER bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction changes axis dynamics. The error bit sets when the instruction detect an error, such as if the axis is not configured.

MCD error codes (.ERR)


Error Code: 1 5 7 8 11 13 Description: The axis value is not an axis type. The instruction tried to execute on an axis whose servo loop is not closed. The axis is in the shutdown state. The axis is not configured as a servo axis. The axis is not configured. The instruction tried to use a parameter that is outside the range limit.

Publication 1756-6.4.1 review January 1998 - preliminary

19-20

Motion Move Instructions

MCD Example:

When the input instructions are true, the controller changes the speed, acceleration, or deceleration rate of a move profile of jog profile in progress for axis_1.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Move Instructions

19-21

Motion Redefine Position (MRP)


Description: Use the MRP instruction to change the command or actual position of an axis. Note: This instruction does not cause any motion; the axis position is only redefined.

The controller can calculate new axis positions in two ways: Absolute, where the controller assigns the position value as the current actual or command position. Relative, where the controller adds the position value to the current actual or command position.

The MRP instruction uses delayed type timing. To use the MRP instruction, configure the axis as either a servo axis or a position-only axis. Operands:
Operand: Axis Type type of redefinition operation Position select Valid Types: tag AXIS immediate 0=absolute 1=relative immediate

0=actual select whether to perform the redefinition operation on the current: 1=command actual position command position immediate or tag SINT, IN, DINT, or REAL

Position value to change the axis position Control

tag MOTION_INSTRUCTION

Publication 1756-6.4.1 review January 1998 - preliminary

19-22

Motion Move Instructions

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Control status:
Control bit or word: .EN bit .DN bit .ER bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction redefines the axis position commands. The error bit sets when the instruction detect an error, such as if the axis is not configured.

MRP error codes (.ERR)


Error Code: 1 3 Description: The axis value is not an axis type. The instruction tried to execute while another instance of this instruction was executing. This can occur when the servo module executes a messaging instruction without checking the .DN bit of the preceding instruction. The axis is not configured. Messaging to the servo module failed.

11 12

MRP Example:

When the input instructions are true, the controller changes the command or position of axis_1.

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

20

Motion Group Instructions


(MGS, MGPS, MGSD, MGSR, MGSP)
Introduction
Motion group instructions control a group of axes. The motion group instructions are:
If you want to: Initiate a stop on the motion on a group of axes. Initiate a stop of all motion on all the axes in a group, using the method that you set for each axis. Force all axes in a group into the shutdown operating state. Transition a group of axes from the shutdown operating state to the axis ready operating state. Latch the current command and actual position of all axes in a group. Use this instruction: MGS MGPS See page: 20-2 20-4

MGSD MGSR

20-6 20-8

MGSP

20-10

Publication 1756-6.4.1 review January 1998 - preliminary

20-2

Motion Group Instructions

Motion Group Stop (MGS)


Description: Use the MGS instruction to initiate a stop on the motion on a group of axes. The MGS instruction uses process type timing. To use the MGS instruction, the group must be configured.

Operands:
Operand: Axis Inhibit select whether or not the group of axes are inhibited after they stop Motion control Valid Types: tag AXIS immediate 0=disable 1=enable tag MOTION_INSTRUCTION

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Group Instructions

20-3

Control status:
Control bit or word: .EN bit .DN bit .ER bit .IP bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction initiates a group stop for all the axes in a group. The error bit sets when the instruction detect an error, such as if the group is not configured. The in process bit sets when the rung goes true. It resets when the MGS instruction completes. .PC bit The process complete bit sets after the instruction stops all the axes. If the Inhibit option is selected, the .PC bit sets after the instruction sets all the axes to the axis ready state.

MGS error codes (.ERR)


Error Code: 2 12 Description: The group value is not a group type. Messaging to the servo module failed.

MGS changes to the axis status bits


Bit Name CLUTCH_STS JOG_STS MOV_STS GEAR_STS HOM_STS State True False False False False Meaning The axis is stopping. The axis is not jogging. The axis is not moving. The axis is not gearing. The axis is not homing.

MGS Example:

When the input instructions are true, the controller stops motion on all axes in group_1 .

Publication 1756-6.4.1 review January 1998 - preliminary

20-4

Motion Group Instructions

Motion Group Program Stop (MGPS)


Description: Use the MGPS instruction to initiate a stop of all motion on all the axes in a group. The instruction stops each axis using a method that you set for each axis. The MGPS instruction uses delayed and process type timing. To use the MGPS instruction, the group must be configured. Operands:
Operand: Axis Motion control Valid Types: tag AXIS tag MOTION_INSTRUCTION

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Control status:
Control bit or word: .EN bit .DN bit .ER bit .IP bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction sets the group of axes to the shutdown operating state. The error bit sets when the instruction detect an error, such as if the group is not configured. The in process bit sets on a positive transition. It resets after the Motion Group Programmed Stop (MGPS) instruction completes. .PC bit The process complete bit sets after the instruction stops all the axes.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Group Instructions

20-5

MGPS error codes (.ERR)


Error Code: 2 12 Description: The group value is not a group type. Messaging to the servo module failed.

MGPS changes to the axis status bits


Bit Name SRV_ACT_STS State False Meaning DRV_EN_STS SHUTDOWN_STS False False The axis is in the axis ready state. The servo loop is inactive.

The drive enable output is inactive. The axis is not in the shutdown state.

MGPS Example:

When the input instructions are true, the controller stops motion on all axes in group_1, using a method that you set for each axis.

Publication 1756-6.4.1 review January 1998 - preliminary

20-6

Motion Group Instructions

Motion Group Shutdown (MGSD)


Description: Use the MGSD instruction to force all axes in a group into the shutdown operating state. The shutdown state of an axis means: The servo is off. The drive enable output is deactivated. The servo output level sets to the output offset value. The servo module OK relay contacts are open.

The MGSD instruction uses delayed type timing. To use the MGSD instruction, the group must be configured. Operands:
Operand: Axis Motion control Valid Types: tag AXIS tag MOTION_INSTRUCTION

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Control status:
Control bit or word: .EN bit .DN bit .ER bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction sets the group of axes to the shutdown operating state. The error bit sets when the instruction detect an error, such as if the group is not configured.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Group Instructions

20-7

MGSD error codes (.ERR)


Error Code: 2 12 Description: The group value is not a group type. Messaging to the servo module failed.

MGSD changes to the servo module LEDs


This LED FDBK DRIVE Will change to Flashing green Flashing red Meaning Servo action is disabled. The drive enable output is inactive. The OK contact is open.

MGSD changes to the axis status bits


Bit Name SRV_ACT_STS State False Meaning DRV_EN_STS SHUTDOWN_STS ACCEL_STS DECEL_STS CLUTCH_STS JOG_STS MOV_STS GEAR_STS HOM_STS False True False False False False False False False Axis is in the axis ready state. Servo loop is inactive.

The drive enable output is inactive. The axis is in the shutdown state. The axis is not accelerating. The axis is not decelerating. The axis is not clutching. The axis is not jogging. The axis is not moving. The axis is not gearing. The axis is not homing.

MGSD Example:

When the input instructions are true, the controller forces all axes in group_1 into a shutdown operating state.

Publication 1756-6.4.1 review January 1998 - preliminary

20-8

Motion Group Instructions

Motion Group Shutdown Reset (MGSR)


Description: Use the MGSR instruction to transition a group of axes from the shutdown operating state to the axis ready operating state. The MGS instruction uses delayed type timing. To use the MGSR instruction, the group must be configured. Operands:
Operand: Axis Motion control Valid Types: tag AXIS tag MOTION_INSTRUCTION

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Control status:
Control bit or word: .EN bit .DN bit .ER bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction resets the group of axes from the shutdown operating state. The error bit sets when the instruction detect an error, such as if the group is not configured.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Group Instructions

20-9

MGSR error codes (.ERR)


Error Code: 2 12 Description: The group value is not a group type. Messaging to the servo module failed.

MGSR changes to the servo module LEDs


This LED FDBK DRIVE Will change to Flashing green Flashing green Meaning Servo action is disabled. The drive enable output is inactive. The OK contact is closed.

MGSR changes to the axis status bits


Bit Name SRV_ACT_STS State False Meaning DRV_EN_STS SHUTDOWN_STS False False Axis is in the axis ready state. Servo loop is inactive.

The drive enable output is inactive. The axis is not in the shutdown state.

MGSR Example:

When the input instructions are true, the controller transitions all axes in group_1 from the shutdown operating state to the axis ready operating state.

Publication 1756-6.4.1 review January 1998 - preliminary

20-10

Motion Group Instructions

Motion Group Strobe Position (MGSP)


Description: Use the MGSP instruction to latch the current command and actual position of all axes in a group. The MGSP instruction uses immediate type timing. To use the MGSP instruction, the group must be configured. Operands:
Operand: Axis Motion control Valid Types: tag AXIS tag MOTION_INSTRUCTION

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Control status:
Control bit or word: .EN bit .DN bit .ER bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction sets a group of axes to the shutdown operating state. The error bit sets when the instruction detect an error, such as if the group is not configured.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Group Instructions

20-11

MGSP error codes (.ERR)


Error Code: 2 12 Description: The group value is not a group type. Messaging to the servo module failed.

MGSP Example:

When the input instructions are true, the controller latches the current command and the actual position of all axes in group_1 .

Publication 1756-6.4.1 review January 1998 - preliminary

20-12

Motion Group Instructions

Notes:

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

21

Motion Event Instructions


(MAW, MDW, MAR, MDR)
Introduction
Motion event instructions control the arming and disarming of special event checking functions, such as registration and watch position. The motion event instructions are:
If you want to: Arm watch-position event-checking for an axis. Disarm watch-position event-checking for an axis. Arm servo-module registration-event checking for an axis. Disarm servo-module registration-event checking for an axis. Use this instruction: MAW MDW MAR MDR See page: 21-2 21-4 21-6 21-9

Publication 1756-6.4.1 review January 1998 - preliminary

21-2

Motion Event Instructions

Motion Arm Watch (MAW)


Description: Use the MAW instruction to arm watch-position event-checking for an axis. The MAW instruction uses delayed and process type timing. To use the MAW instruction, configure the axis as either a servo axis or a position only axis. Operands:
Operand: Axis Trigger condition watch-event trigger condition Valid Types: tag AXIS immediate 0=forward The servo module looks for the actual position to change from less than the watch position to greater than the watch position. 1=reverse The servo module looks for the actual position to change from greater than the watch position to less than the watch position. Watch position new value for the watch position Motion control tag MOTION_INSTRUCTION immediate or tag SINT, INT, DINT, or REAL

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Event Instructions

21-3

Control status:
Control bit or word: .EN bit .DN bit .ER bit .IP bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction arms watch-event checking. The error bit sets when the instruction detect an error, such as if the axis is not configured. The in process bit sets when the rung goes true. It resets when one of the following events occurs: A watch event occurs. Another MAW instruction supersedes the current instruction. A Motion Disarm Watch (MDW) instruction terminates the MAW instruction. .PC bit The process complete bit is when a watch event occurs.

MAW error codes (.ERR)


Error Code: 1 3 Description: The axis value is not an axis type. The instruction tried to execute while another instance of this instruction was executing. This can occur when the servo module executes a messaging instruction without checking the .DN bit of the preceding instruction. The axis is not configured. Messaging to the servo module failed.

11 12

MAW changes to the axis status bits


Bit Name State Meaning The axis is looking for a watch position event. The previous watch event is cleared.

WATCH_EV_ARM_S True TS WATCH_EV_STS False

MAW Example:

When the input instructions are true, the controller arms watch-position event-checking for axis_1.

Publication 1756-6.4.1 review January 1998 - preliminary

21-4

Motion Event Instructions

Motion Disarm Watch (MDW)


Description: Use the MDW instruction to disarm watch-position event-checking for an axis. The MDW instruction uses delayed type timing. To use the MDW instruction, configure the axis as either a servo axis or a position-only axis. Operands:
Operand: Axis Motion control Valid Types: tag AXIS tag MOTION_INSTRUCTION

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Control status:
Control bit or word: .EN bit .DN bit .ER bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction disarms watch-event checking. The error bit sets when the instruction detect an error, such as if the axis is not configured.

Important: When you use this instruction, the controller clears the watch-event status bit and the watch-armed status bits. This instruction also clears the .IP bit in the control structure.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Event Instructions

21-5

MDW error codes (.ERR)


Error Code: 1 3 Description: The axis value is not an axis type. The instruction tried to execute while another instance of this instruction was executing. This can occur when the servo module executes a messaging instruction without checking the .DN bit of the preceding instruction. The axis is not configured. Messaging to the servo module failed.

11 12

MDW changes to the axis status bits


Bit Name WATCH_EV_ARM_STS WATCH_EV_STS State False False Meaning The axis is not looking for a watch position event. The previous watch event is cleared.

MDW Example:

When the input instructions are true, the controller disarms watch-position event-checking for axis_1.

Publication 1756-6.4.1 review January 1998 - preliminary

21-6

Motion Event Instructions

Motion Arm Registration (MAR)


Description: Use the MAR instruction to arm servo module registration event checking for an axis. The MAR instruction uses delayed and process type timing. To use the MAR instruction, configure the axis as either a servo axis or a position only axis.

Operands:
Operand: Axis Trigger condition input condition that defines the registration event Windowed registration select whether or not the registration position within the position window Min. position minimum position for windowed registration event checking. The registration position must be greater than this value before the controller accepts the registration event. Max. position maximum position for windowed registration event checking The registration position must be less than this value before the controller accepts the registration event. Motion control tag MOTION_INSTRUCTION immediate or tag SINT, INT, DINT, or REAL Valid Types: tag AXIS immediate 0=trigger on positive transitions 1=trigger on negative transitions immediate 0=disable 1=enable immediate or tag SINT, INT, DINT, or REAL

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Event Instructions

21-7

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Control status:
Control bit or word: .EN bit .DN bit .ER bit .IP bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction arms registration event checking. The error bit sets when the instruction detect an error, such as if the axis is not configured. The in process bit sets when the rung goes true. It resets when one of the following events occurs: A registration event occurs Another MAR instruction supersedes the current instruction A Motion Disarm Registration (MDR) instruction terminates the MAR instruction. .PC bit The process complete bit sets when a registration event occurs.

MAR error codes (.ERR)


Error Code: 1 3 Description: The axis value is not an axis type. The instruction tried to execute while another instance of this instruction was executing. This can occur when the servo module executes a messaging instruction without checking the .DN bit of the preceding instruction. The axis is not configured. Messaging to the servo module failed.

11 12

Publication 1756-6.4.1 review January 1998 - preliminary

21-8

Motion Event Instructions

MAR changes to the axis status bits


Bit Name REG_EV_ARM_STS REG_EV_STS State True False Meaning The axis is looking for a registration event. The previous registration event is cleared.

MAR Example:

When the input instructions are true, the controller arms servo-module registration-event checking for axis_1.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Event Instructions

21-9

Motion Disarm Registration (MDR)


Description: Use the MDR instruction to disarm servo module registration event checking for an axis. The MDR instruction uses delayed timing. To use the MDR instruction, configure the axis as either a servo axis or a position only axis. Operands:
Operand: Axis Motion control Valid Types: tag AXIS tag MOTION_INSTRUCTION

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Control status:
Control bit or word: .EN bit .DN bit .ER bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction disarms axis-registration event checking. The error bit sets when the instruction detect an error, such as if the axis is not configured.

Important: When you use this instruction, the controller resets the registration event status bit and the registration armed status bit.

Publication 1756-6.4.1 review January 1998 - preliminary

21-10

Motion Event Instructions

MDR error codes (.ERR)


Error Code: 1 3 Description: The axis value is not an axis type. The instruction tried to execute while another instance of this instruction was executing. This can occur when the servo module executes a messaging instruction without checking the .DN bit of the preceding instruction. The axis is not configured. Messaging to the servo module failed.

11 12

MDR changes to the axis status bits


Bit Name REG_EV_ARM_STS REG_EV_STS State False False Meaning The axis is not looking for a registration event. The previous registration event is cleared.

MDR Example:

When the input instructions are true, the controller disarms servo-module registration-event checking for axis_1 .

Publication 1756-6.4.1 review January 1998 - preliminary

Chapter

22

Motion Configuration Instructions


(MAAT, MRAT, MAHD, MRHD)
Introduction
Use the motion configuration instructions to tune an axis and to run diagnostic tests for the servo system. These tests include: A motor encoder hookup test. An encoder hookup test. A marker test

The motion configuration instructions are:


If you want to: Compute a complete set of servo gains and dynamic limits based on a previously executed MRAT instruction. The MAAT instruction also updates the servo module with the new gain parameters. Command the servo module to run a tuning motion profile for an axis. Apply the results of a previously executed MRHD instruction. The MAHD instruction generates a new set of encoder and servo polarities based on the observed direction of motion during the MRHD instruction. Command the servo module to run one of four diagnostic tests on an axis. MRHD 22-9 MRAT MAHD 22-4 22-7 Use this instruction: MAAT See page: 22-2

Publication 1756-6.4.1 review January 1998 - preliminary

22-2

Motion Configuration Instructions

Motion Apply Axis Tuning (MAAT)


Description: Use the MAAT instruction to compute a complete set of servo gains and dynamic limits based on a previously executed Motion Run Axis Tuning (MRAT) instruction. This instruction also updates the servo module with the new gain parameters. The MAAT instruction uses delayed type timing. To use the MAAT instruction: Configure the axis as a servo axis. Ensure the axis operating state is axis ready. Ensure servo action is off. Use a Motion Run Axis Tuning (MRAT) instruction before the MAAT instruction.

Operands:
Operand: Axis Motion control Valid Types: tag AXIS tag MOTION_INSTRUCTION

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Control status:
Control bit or word: .EN bit .DN bit .ER bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction completes an apply axis-tuning process. The error bit sets when the instruction detect an error, such as if the axis is not configured.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Configuration Instructions

22-3

MAAT error codes (.ERR)


Error Code: 1 3 Description: The axis value is not an axis type. The instruction tried to execute while another instance of this instruction was executing. This can occur when the servo module executes a messaging instruction without checking the .DN bit of the preceding instruction. The axis is in the shutdown state. The axis is not configured as a servo axis. The axis is not configured. Messaging to the servo module failed.

7 8 11 12

MAAT Example:

When the input instructions are true, the controller computes a complete set of servo gains and dynamic limits for axis_1.

Publication 1756-6.4.1 review January 1998 - preliminary

22-4

Motion Configuration Instructions

Motion Run Axis Tuning (MRAT)


Description: Use the MRAT to command the servo module to run a tuning motion profile for an axis. Note: This instruction does not close the servo loop at any time.

The MRAT instruction uses delayed and process type timing. To use the MRAT instruction: Operands:
Operand: Axis Motion control Valid Types: tag AXIS tag MOTION_INSTRUCTION

Configure the axis as a servo axis. Ensure the axis operating state is axis ready.

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Configuration Instructions

22-5

Control status:
Control bit or word: .EN bit .DN bit .ER bit In process (IP) Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction initiates a tuning process. The error bit sets when the instruction detect an error, such as if the axis is not configured. The in process bit sets when the rung goes true. It resets when one of the following events occurs: Process complete (PC) The MRAT instruction completes. A Motion Axis Stop (MAS) instruction or a servo fault terminates the MRAT instruction.

The process complete bit sets when the instruction completes a tuning process.

MRAT error codes (.ERR)


Error Code: 1 3 Description: The axis value is not an axis type. The instruction tried to execute while another instance of this instruction was executing. This can occur when the servo module executes a messaging instruction without checking the .DN bit of the preceding instruction. The axis servo loop is closed. The axis drive is enabled. The axis is in the shutdown state. The axis is not configured as a servo axis. The axis is not configured. Messaging to the servo module failed.

4 6 7 8 11 12

MRAT changes to the axis status bits


Bit Name DRV_EN_STS State True Meaning TUNE_STS True The axis is in the drive control state. The drive enable output is active while the tuning profile is running.

The axis is running a tuning process.

Publication 1756-6.4.1 review January 1998 - preliminary

22-6

Motion Configuration Instructions

MRAT Example:

When the input instructions are true, the controller commands the servo module to run a tuning motion profile for axis_1.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Configuration Instructions

22-7

Motion Apply Hookup Diagnostics (MAHD)


Description: Use the MAHD instruction to apply the results of a previously executed Motion Run Hookup Diagnostics (MRHD) instruction. The MAHD instruction generates a new set of encoder and servo polarities based on the observed direction of motion during the MRHD instruction. The MAHD instruction uses delayed type timing. To use the MAHD instruction: Configure the axis as either a servo axis or a position-only axis. Use a Motion Run Hookup Diagnostics (MRHD) instruction before the MAHD instruction.

Operands:
Operand: Axis Diagnostic test specify the test to apply Valid Types: tag AXIS immediate 0=motor/encoder hookup test 1=encoder hookup test 2=encoder marker test immediate 0=forward 1=reverse tag MOTION_INSTRUCTION

Observed direction direction of motion during the diagnostic tests Motion control

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Publication 1756-6.4.1 review January 1998 - preliminary

22-8

Motion Configuration Instructions

Control status:
Control bit or word: .EN bit .DN bit .ER bit Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction applies the results of a test process. The error bit sets when the instruction detect an error, such as if the axis is not configured.

MAHD error codes (.ERR)


Error Code: 1 3 Description: The axis value is not an axis type. The instruction tried to execute while another instance of this instruction was executing. This can occur when the servo module executes a messaging instruction without checking the .DN bit of the preceding instruction. The axis servo loop is closed. The axis drive is enabled. The axis is in the shutdown state. The axis is not configured as a servo axis. The axis is not configured. Messaging to the servo module failed.

4 6 7 8 11 12

MAHD Example:

When the input instructions are true, the controller applies the results of a previously executed Motion Run Hookup Diagnostics (MRHD) instruction to axis_1.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Configuration Instructions

22-9

Motion Run Hookup Diagnostics (MRHD)


Description: Use the MRHD instruction to command the servo module to run one of four diagnostic tests on an axis. The MRHD instruction uses delayed and process type timing. To use the MRHD instruction, specify the diagnostic test to run:
If you want to run the: Motor/encoder test Then: Encoder hookup test Encoder marker test Configure the axis as a servo axis. Ensure that the axis is in the axis ready operating state.

Configure the axis as either a servo axis or a position only axis. Configure the axis as either a servo axis or a position only axis.

Operands:
Operand: Axis Diagnostic test Valid Types: tag AXIS immediate

specify which diagnostic test to run 0=motor/encoder hookup test 1=encoder hookup test 2=encoder marker hookup test Motion control tag MOTION_INSTRUCTION

Operation:
Characteristic: Timing (in s) DINT REAL Memory (words) Execution DINT REAL Description: true 100.00 100.00 12 false 100.00 100.00

does not execute does not execute executes

Publication 1756-6.4.1 review January 1998 - preliminary

22-10

Motion Configuration Instructions

Control status:
Control bit or word: .EN bit .DN bit .ER bit In process (IP) Description: The enable bit sets when the rung goes from false to true. It remains set until servo messaging completes and the rung becomes false. The done bit sets when the instruction initiates a test process. The error bit sets when the instruction detect an error, such as if the axis is not configured. The in process bit sets when the rung goes true. It resets when one of the following events occurs: Process complete (PC) The MRHD instruction completes. A Motion Axis Stop (MAS) instruction or a servo fault terminates the MRHD instruction.

The process complete bit sets when the instruction completes the diagnostic test process.

MRHD error codes (.ERR)


Error Code: 1 3 Description: The axis value is not an axis type. The instruction tried to execute while another instance of this instruction was executing. This can occur when the servo module executes a messaging instruction without checking the .DN bit of the preceding instruction. The axis servo loop is closed. The axis drive is enabled. The axis is in the shutdown state. The axis is not configured as a servo axis. The axis is not configured. Messaging to the servo module failed.

4 6 7 8 11 12

MRHD changes to the axis status bits


Bit Name DRV_EN_STS State True Meaning The axis is in the drive control state. The drive enable output is active while the tuning profile is running.

TEST_STS

True

The axis is running a tuning process.

Publication 1756-6.4.1 review January 1998 - preliminary

Motion Configuration Instructions

22-11

Example:

When the input instructions are true, the controller runs the encoder diagnostic test on axis

Publication 1756-6.4.1 review January 1998 - preliminary

22-12

Motion Configuration Instructions

Notes:

Publication 1756-6.4.1 review January 1998 - preliminary

You might also like