You are on page 1of 339

GE Fanuc Automation Programmable Control Products

VersaMax PLC
User's Manual, GFK-1503D
January 2006

GFL-002

Warnings, Cautions, and Notes as Used in this Publication


Warning
Warning notices are used in this publication to emphasize that hazardous voltages, currents, temperatures, or other conditions that could cause personal injury exist in this equipment or may be associated with its use. In situations where inattention could cause either personal injury or damage to equipment, a Warning notice is used.

Caution
Caution notices are used where equipment might be damaged if care is not taken.

Note
Notes merely call attention to information that is especially significant to understanding and operating the equipment. This document is based on information available at the time of its publication. While efforts have been made to be accurate, the information contained herein does not purport to cover all details or variations in hardware or software, nor to provide for every possible contingency in connection with installation, operation, or maintenance. Features may be described herein which are not present in all hardware and software systems. GE Fanuc Automation assumes no obligation of notice to holders of this document with respect to changes subsequently made. GE Fanuc Automation makes no representation or warranty, expressed, implied, or statutory with respect to, and assumes no responsibility for the accuracy, completeness, sufficiency, or usefulness of the information contained herein. No warranties of merchantability or fitness for purpose shall apply. The following are trademarks of GE Fanuc Automation North America, Inc. Alarm Master CIMPLICITY CIMPLICITY 90ADS CIMSTAR Field Control GEnet Genius Helpmate Logicmaster Modelmaster Motion Mate PACSystems Proficy ProLoop PROMACRO PowerMotion PowerTRAC Series 90 Series Five Series One Series Six Series Three VersaMax VersaPoint VersaPro VuMaster Workmaster

Copyright 2006 GE Fanuc Automation North America, Inc. All Rights Reserved

Contents
Chapter 1
Introduction................................................................................... 1-1
The VersaMax Family of Products ............................................................ 1-3 CPU Modules for VersaMax PLCs ............................................................... 1-4 Power Supplies ............................................................................................ 1-6 I/O Modules .................................................................................................. 1-7 Carriers....................................................................................................... 1-10 Expansion Modules .................................................................................... 1-12 Communications Modules .......................................................................... 1-14

Chapter 2 Chapter 3 Chapter 4

CPU Module Datasheets: CPU001, CPU002, CPU005................. 2-1 CPU Module Datasheet: CPUE05................................................ 3-1 Installation..................................................................................... 4-1
Mounting Instructions ................................................................................... 4-2 Installing an Expansion Transmitter Module ................................................ 4-4 Installing an Expansion Receiver Module .................................................... 4-5 Installing Power Supply Modules ................................................................. 4-9 Installing Additional Modules...................................................................... 4-10 Activating or Replacing the Backup Battery ............................................... 4-11 Serial Port Connections.............................................................................. 4-12 Ethernet Connection for CPUE05 .............................................................. 4-19 CE Mark Installation Requirements............................................................ 4-20

Chapter 5

Configuration ................................................................................ 5-1


Using Autoconfiguration or Programmer Configuration ............................... 5-2 Configuring Racks and Slots ................................................................... 5-3 Software Configuration................................................................................. 5-6 Autoconfiguration ....................................................................................... 5-12

Chapter 6

Ethernet Configuration................................................................. 6-1


Ethernet Configuration Overview ................................................................. 6-2 Configuring the Ethernet Interface ............................................................... 6-3 Configuring Ethernet Global Data ................................................................ 6-4 Configuring a Global Data Exchange for a Producer ................................... 6-5 Configuring a Global Data Exchange for a Consumer................................. 6-6 Configuring Advanced User Parameters...................................................... 6-9

GFK-1503D

iii

Contents

Chapter 7

CPU Operation .............................................................................. 7-1


Parts of the CPU Sweep .............................................................................. 7-2 Standard CPU Sweep Operation ................................................................. 7-4 CPU Stop Modes.......................................................................................... 7-6 Flash Memory............................................................................................... 7-6 Controlling the Execution of a Program ....................................................... 7-7 Run/Stop Mode Switch Operation ................................................................ 7-8 Privilege Levels and Passwords................................................................... 7-9

Chapter 8

Elements of an Application Program .......................................... 8-1


Structure of an Application Program ............................................................ 8-2 Subroutines .................................................................................................. 8-3 Program Languages..................................................................................... 8-6 The Instruction Set ....................................................................................... 8-8

Chapter 9

Program Data ................................................................................ 9-1


Data Memory References ............................................................................ 9-2 Retentiveness of Data .................................................................................. 9-4 System Status References........................................................................... 9-5 How Program Functions Handle Numerical Data ........................................ 9-9 Time-Tick Contacts .................................................................................... 9-11

Chapter 10 Instruction Set Reference .......................................................... 10-1


Bit Operation Functions.............................................................................. 10-2 Control Functions ..................................................................................... 10-18 Data Move Functions .............................................................................. 10-32 Data Type Conversion Functions ............................................................. 10-41 Math and Numerical Functions................................................................. 10-48 Relational Functions ................................................................................. 10-58 Relay Functions........................................................................................ 10-62 Table Functions ........................................................................................ 10-68 Timer and Counter Functions................................................................... 10-73

iv

VersaMax PLC

User's Manual January 2006

GFK-1503D

Contents
Chapter 11 The Service Request Function................................................... 11-1
SVCREQ Function Numbers...................................................................... 11-2 Format of the SVCREQ Function ............................................................... 11-3 SVCREQ 1: Change/Read Constant Sweep Timer .................................. 11-4 SVCREQ 2: Read Window Times............................................................. 11-6 SVCREQ 3: Change Programmer Communications Window Mode......... 11-7 SVCREQ 4: Change System Communications Window Mode................. 11-8 SVCREQ 6: Change/Read Number of Words to Checksum .................... 11-9 SVCREQ 7: Read or Change the Time-of-Day Clock............................. 11-11 SVCREQ 8: Reset Watchdog Timer ....................................................... 11-15 SVCREQ 9: Read Sweep Time from Beginning of Sweep ..................... 11-16 SVCREQ 10: Read Folder Name............................................................ 11-17 SVCREQ 11: Read PLC ID ..................................................................... 11-18 SVCREQ 13: Shut Down (Stop) PLC..................................................... 11-19 SVCREQ 14: Clear Fault......................................................................... 11-20 SVCREQ 15: Read Last-Logged Fault Table Entry ................................ 11-21 SVCREQ 16: Read Elapsed Time Clock ................................................ 11-23 SVCREQ 18: Read I/O Override Status.................................................. 11-24 SVCREQ 23: Read Master Checksum ................................................... 11-25 SVCREQ 26/30: Interrogate I/O .............................................................. 11-26 SVCREQ 29: Read Elapsed Power Down Time ..................................... 11-27

Chapter 12 Serial I/O / SNP / RTU Protocols ................................................ 12-1


Format of the Communication Request Function....................................... 12-2 Configuring Serial Ports Using the COMMREQ Function.......................... 12-4 Calling Serial I/O COMMREQs from the PLC Sweep .............................. 12-11 Serial I/O COMMREQ Commands........................................................... 12-13

GFK-1503D

Contents

Contents

Chapter 13 Ethernet Communications ......................................................... 13-1


Overview of the Ethernet Interface............................................................. 13-2 IP Addressing ............................................................................................. 13-4 Routers ....................................................................................................... 13-5 Ethernet Global Data.................................................................................. 13-6 Diagnostic Tools ....................................................................................... 13-14 Troubleshooting Common Ethernet Difficulties........................................ 13-25

Chapter 14 PID Built-in Function Block........................................................ 14-1


Operands of the PID Function.................................................................... 14-2 Reference Array for the PID Function ........................................................ 14-3 Operation of the PID Function.................................................................. 14-11 PID Algorithm Selection (PIDISA or PIDIND) and Gain Calculations ...... 14-13 Determining the Process Characteristics ................................................. 14-18 Setting Tuning Loop Gains....................................................................... 14-19 Example.................................................................................................... 14-21

Chapter 15 The EZ Program Store Device.................................................... 15-1


Read/Write/Verify Data with a Programmer Present.................................. 15-3 Update a PLC CPU without a Programmer Present .................................. 15-7

Appendix A Performance Data ......................................................................... A-1


Function Block Timing ..................................................................................A-2 I/O Module Scan Times................................................................................A-8 Ethernet Global Data Sweep Impact..........................................................A-13 Support for Large Ethernet Global Data Configurations ............................A-14

vi

VersaMax PLC

User's Manual January 2006

GFK-1503D

Chapter

Introduction

Guide to the VersaMax Document Set


This manual contains general information about CPU operation and program content. It also provides detailed descriptions of specific programming requirements. Chapter 1 is a general introduction to the VersaMax family of products. CPU Modules are described in detail in chapters 2 and 3. Installation procedures are described in Chapter 4. PLC Configuration is described in chapter 5. Configuration determines certain characteristics of module operation and also establishes the program references used by each module in the system. Ethernet Configuration for CPU model IC200CPUE05 is described in chapter 6. CPU Operation is described in chapter 7. Serial Communications are described in chapter 12. Ethernet Communications for CPU model IC200CPUE05 is described in chapter 13. The rest of the manual describes many programming features.

Elements of an Application Program: chapter 8 Program Data: chapter 9 Instruction Set Reference: chapter 10 The Service Request Function: chapter 11 The PID Function: chapter 14 Instruction Timing: appendix A

GFK-1503D

1-1

1
Other VersaMax Manuals
VersaMax Modules, Power Supplies, and Carriers Users Manual (catalog number GFK-1504) Describes the many VersaMax I/O and option modules, power supplies, and carriers. This manual also provides detailed system installation instructions. Describes the diagnostic interface to the Ethernet functions of CPU module IC200CPUE05. Describes the installation and operation of the Ethernet Network Interface Unit module.

VersaMax PLC Ethernet Station Managers Manual (catalog number GFK-1876) VersaMax Ethernet Network Interface Unit Users Manual (catalog number GFK-1860) VersaMax Genius NIU Users Manual (catalog number GFK-1535) VersaMax DeviceNet Communications Modules Users Manual (catalog number GFK-1533) VersaMax Profibus Communications Modules Users Manual (catalog number GFK-1534)

Describes the installation and operation of the Genius NIU. Describes the installation and operation of the DeviceNet Network Interface Unit module and the DeviceNet Network Slave Module. Describes the installation and operation of the Profibus Network Interface Unit module and the Profibus Network Communications Module.

1-2

VersaMax PLC Users Manual January 2006

GFK-1503D

1 The VersaMax Family of Products


The VersaMax family of products provides universally-distributed I/O that spans PLC and PC-based architectures. Designed for industrial and commercial automation, VersaMax I/O provides a common, flexible I/O structure for local and remote control applications. The VersaMax PLC provides big-PLC power with a full range of I/O and option modules. VersaMax I/O Stations with Network Interface Modules make it possible to add the flexibility of VersaMax I/O to other types of networks. VersaMax meets UL, CUL, CE, Class1 Zone 2 and Class I Division 2 requirements. As a scaleable automation solution, VersaMax I/O combines compactness and modularity for greater ease of use. The 70-mm depth and small footprint of VersaMax I/O enables easy, convenient mounting as well as spacesaving benefits. Modules can accommodate up to 32 points of I/O each. The compact, modular VersaMax products feature DIN-rail mounting with up to eight I/O and option modules per rack and up to 8 racks per VersaMax PLC or VersaMax I/O Station system. Expansion racks can be located up to 750 meters from the main VersaMax PLC or VersaMax I/O Station rack. Expansion racks can include any VersaMax I/O, option, or communications module. VersaMax provides automatic addressing that can eliminate traditional configuration and the need for hand-held devices. Multiple field wiring termination options provide support for two, three, and four-wire devices. For faster equipment repair and shorter Mean-Time-To-Repair, the hot insertion feature enables addition and replacement of I/O modules while a machine or process is running and without affecting field wiring. VersaMax I/O may be remotely located. Remote I/O interfaces for Genius, DeviceNet, Profibus, and Ethernet are available.

GFK-1503D

Chapter 1 Introduction

1-3

1 CPU Modules for VersaMax PLCs


A VersaMax PLC consists of a group of VersaMax modules with a VersaMax CPU and attached power supply in the first position.
VersaMax PLC CPU power supply VersaMax Modules

All VersaMax CPUs provide powerful PLC functionality. They are designed to serve as the system controller for up to 64 modules with up to 2048 I/O points. Two serial ports provide RS-232 and RS-485 interfaces for SNP slave and RTU slave communications. CPU model IC200CPUE05 provides a built-in Ethernet port.

Basic CPU Features


Programming in Ladder Diagram, Sequential Function Chart, and Instruction List Floating point (real) data functions Non-volatile flash memory for program storage Run/Stop switch Embedded RS-232 and RS-485 communications Compatible with EZ Program Store device

Available VersaMax CPUs


CPU with Two Serial Ports, 34kB of Configurable Memory CPU with Two Serial Ports, 42kB of Configurable Memory CPU with Two Serial Ports, 128kB of Configurable Memory CPU with Two Serial Ports and Embedded Ethernet Interface, 128kB of Configurable Memory IC200CPU001 IC200CPU002 IC200CPU005 IC200CPUE05

1-4

VersaMax PLC Users Manual January 2006

GFK-1503D

CPU001 CPU002
CPU001
PWR OK RUN

CPU005
CPU005
PWR OK RUN FAULT FORCE PORT 1 PORT 2

Status LEDs

FAULT FORCE PORT 1 PORT 2

PORT 1

PORT 1

RS232

RS232 PORT 2

Serial Ports

PORT 2

RS485

RS485

CPUE05
CPUE05
PWR OK RUN FAULT FORCE PORT 1 PORT 2

PORT 1

RS232 PORT 2 ETHERNET RESTART

ETHERNET 10 BASE T / 100 BASE TX RS485

LAN STAT PORT 1

Ethernet Interface

EZ Program Store
The EZ Program Store device (IC200ACC003) can be used to store and update the configuration, application program, and reference table data of a VersaMax PLC. A programmer and PLC CPU are used to initially write data to the device.

PLC

GFK-1503D

Chapter 1 Introduction

1-5

1 Power Supplies
An AC or DC Power Supply provides +5V and +3.3V power to the modules in the rack. Additional power supplies can be installed on special booster carriers if needed for systems where the number of modules creates the need for a booster. The AC or DC Power Supply on the CPU or NIU and the Power Supply that resides on the Booster Carrier must share the same external power source. CPU models IC200CPU005 and IC200CPUE05 require the use of an expanded 3.3V power supply. See the table below.

24 VDC POWER SUPPLY

IC200PWR001 + INPUT

NOT USED

VDC

Available Power Supplies and Carrier


The following VersaMax power supplies and carrier are available:
24VDC Power Supply 24VDC Expanded 3.3V Power Supply 120/240VAC Power Supply 120/240VAC Expanded 3.3V Power Supply 12VDC Power Supply 12VDC Expanded 3.3V Power Supply Power Supply Booster Carrier IC200PWR001 IC200PWR002 IC200PWR101 IC200PWR102 IC200PWR201 IC200PWR202 IC200PWB001

Power supplies are described in the VersaMax Modules, Power Supplies, and Carriers Users Manual (GFK-1504).
1-6 VersaMax PLC Users Manual January 2006 GFK-1503D

1 I/O Modules
VersaMax IO and option modules are approximately 110mm (4.33in) by 66.8mm (2.63in) in size. Modules can be mounted either horizontally or vertically on several types of available I/O Carriers. Modules are 50mm (1.956 in) in depth, not including the height of the carrier or the mating connectors.
110mm (4.33in)

FLD PWR

OK

66.8mm (2.63in)

10 11 12 13 14 15 16 OUTPUT POS GRP

IC200MDL750
12/24VDC 32PT

Color code: Red: AC Blue: DC Gold: Mixed Gray: Analog/other

.5A

17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

1234567

831

Module Description

FLD PWR

OK

OK LED indicates presence of power from VersaMax power supply

Individual Point LEDS on Discrete Modules

Latch

Field Power LED indicates presence of power from external supply

VersaMax I/O modules are described in the VersaMax Modules, Power Supplies, and Carriers Users Manual (GFK-1504).

GFK-1503D

Chapter 1 Introduction

1-7

1
Available I/O Modules
The following types of VersaMax I/O Modules are available:
Discrete Input Modules Input 120VAC 8 Point Grouped Module Input 240VAC 8 Point Grouped Module Input 120VAC 8 Point Isolated Module Input 240VAC 4 Point Isolated Module Input 120VAC (2 Groups of 8) 16 Point Module Input 240VAC (2 Groups of 8) 16 Point Module Input 120VAC 16 Point Isolated Module Input 240VAC 8 Point Isolated Module Input 125VDC Positive/Negative Logic Grouped 8 Point Module Input 125VDC Positive/Negative Logic Grouped 16 Point Module Input 48VDC Positive/Negative Logic Grouped 16 Point Module Input 48VDC Positive/Negative Logic Grouped 32 Point Module Input 24VDC Positive/Negative Logic (2 Groups of 8) 16 Point Module Input 5/12VDC (TTL) Positive/Negative Logic 16 Point Module Input 5/12VDC (TTL) Positive/Negative Logic Grouped 32 Point Module Input 24VDC Positive/Negative Logic (4 Groups of 8) 32 Point Module Discrete Output Modules Output 120VAC 0.5A per Point Isolated 8 Point Module Output 120VAC 0.5A per Point Isolated 16 Point Module Output 120VAC 2.0A per Point Isolated 8 Point Module Output 24VDC Positive Logic 2.0A per Point (1 Group of 8) w/ESCP 8 Point Module, Output 12/24VDC Positive Logic 0.5A per Point (1 Group of 16) 16 Point Module Output 24VDC Positive Logic 0.5A per Point (1 Group of 16) w/ESCP 16 Point Module Output 24VDC Positive Logic 0.5A per Point (2 Groups of 16) w/ESCP 32 Point Module Output 5/12/24VDC Negative Logic 0.5A per Point (1 Group of 16) 16 Point Module Output 5/12/24VDC Negative Logic 0.5A per Point (2 Groups of 16) 32 Point Module Output 12/24VDC Positive Logic 0.5A per Point (2 Groups of 16) 32 Point Module Output Relay 2.0A per Point Isolated Form A 8 Point Module Output Relay 2.0A per Point Isolated Form A 16 Point Module IC200MDL329 IC200MDL330 IC200MDL331 IC200MDL730 IC200MDL740 IC200MDL741 IC200MDL742 IC200MDL743 IC200MDL744 IC200MDL750 IC200MDL930 IC200MDL940 IC200MDL140 IC200MDL141 IC200MDL143 IC200MDL144 IC200MDL240 IC200MDL241 IC200MDL243 IC200MDL244 IC200MDL631 IC200MDL632 IC200MDL635 IC200MDL636 IC200MDL640 IC200MDL643 IC200MDL644 IC200MDL650

1-8

VersaMax PLC Users Manual January 2006

GFK-1503D

1
Discrete Mixed I/O Modules Mixed 24VDC Positive Logic Input Grouped 20 Point / Output Relay 2.0A per Point Grouped 12 Point Module Mixed 24VDC Positive Logic Input 20 Point / Output 12 Point / (4) High Speed Counter, PWM, or Pulse Train Configurable Points Mixed 16 Point Grouped Input 24VDC Pos/Neg Logic / 16 Pt Grouped Output 24VDC Pos. Logic 0.5A w/ESCP Mixed 24VDC Positive Logic Input Grouped 10 Point / Output Relay 2.0A per Point 6 Point Module Mixed 24 VDC Pos/Neg Logic Input Grouped 16 Point / Output 12/24VDC Pos. Logic 0.5A 16 Point Module Mixed 16 Point Grouped Input 24VDC Pos/Neg Logic / 8 Pt Relay Output 2.0A per Pt Isolated Form A Mixed 120VAC Input 8 Point / Output Relay 2.0A per Point 8 Point Module Mixed 240VAC Input 8 Point / Output Relay 2.0A per Point 8 Point Module Mixed 120VAC Input 8 Point / Output 120VAC 0.5A per Point Isolated 8 Point Module Mixed 120VAC In Isolated 8 Point / Output Relay 2.0A Isolated 8 Point Module Mixed 240VAC In Isolated 4 Point / Output Relay 2.0A Isolated 8 Point Module Analog Input Modules Analog Input Module, 12 Bit Voltage/Current 4 Channels Analog Input Module, 16 Bit Voltage/Current, 1500VAC Isolation, 8 Channels Analog Input Module, 12 Bit Voltage/Current 8 Channels Analog Input Module, 15 Bit Differential Voltage 8 Channels Analog Input Module, 16 Bit Differential Current 8 Channels Analog Input Module, 15 Bit Voltage 15 Channels Analog Input Module, 15 Bit Current 15 Channels Analog Input Module, 16 Bit RTD, 4 Channels Analog Input Module, 16 Bit Thermocouple, 7 Channels Analog Output Modules Analog Output Module, 12 Bit Current, 4 Channels Analog Output Module, 12 Bit Voltage 4 Channels. 0 to +10VDC Range Analog Output Module, 12 Bit Voltage 4 Channels. -10 to +10VDC Range Analog Output Module, 13 Bit Voltage 8 Channels Analog Output Module, 12 Bit Current 8 Channels Analog Output Module, 13 Bit Voltage 12 Channels Analog Output Module, 12 Bit Current 12 Channels Analog Output Module, 16 Bit Voltage/Current, 1500VAC Isolation, 4 Channels Analog Mixed I/O Modules Analog Mixed Module, Input Current 4 Channels, Output Current 2 Channels Analog Mixed Module, 0 to +10VDC Input 4 Channels, Output 0 to +10VDC 2 Channels Analog Mixed Module, 12 Bit -10 to +10VDC, Input 4 Channels / Output -10 to +10VDC 2 Channels

IC200MDD840 IC200MDD841 IC200MDD842 IC200MDD843 IC200MDD844 IC200MDD845 IC200MDD846 IC200MDD847 IC200MDD848 IC200MDD849 IC200MDD850 IC200ALG230 IC200ALG240 IC200ALG260 IC200ALG261 IC200ALG262 IC200ALG263 IC200ALG264 IC200ALG620 IC200ALG630 IC200ALG320 IC200ALG321 IC200ALG322 IC200ALG325 IC200ALG326 IC200ALG327 IC200ALG328 IC200ALG331 IC200ALG430 IC200ALG431 IC200ALG432

GFK-1503D

Chapter 1 Introduction

1-9

1 Carriers
Carriers provide mounting, backplane communications, and field wiring connections for all types of VersaMax modules. I/O modules can be installed on carriers or removed without disturbing field wiring. There are three basic I/O Carrier types:

Terminal-style I/O carriers. Modules mount parallel to the DIN rail. Compact Terminal-style I/O Carriers. Modules mount perpendicular to the DIN rail. Connector-style I/O Carriers. Modules mount perpendicular to the DIN rail. These carriers are normally used with Interposing I/O Terminals as illustrated below.

See the VersaMax Modules, Power Supplies, and Carriers Users Manual (GFK-1504) for information about VersaMax I/O Carriers. Terminal-style I/O carriers have 36 individual terminals for direct connection of field wiring. Auxiliary I/O Terminal Strips are available for applications requiring additional wiring terminals.
Terminal-style I/O Carrier Compact Terminal-style I/O Carrier Connector-style I/O Carrier and Interposing Terminals

Auxiliary I/O Terminal Strip

MADE IN USA

1-10

VersaMax PLC Users Manual January 2006

GFK-1503D

1
Available Carriers and Terminal Strips
The following types of Carriers, terminals, and cables are available:
Terminal-Style I/O Carriers Barrier-Style Terminal I/O Carrier Box-Style Terminal I/O Carrier Spring-Style Terminal I/O Carrier Compact Terminal-Style I/O Carriers Compact Box-Style I/O Carrier Compact Spring-Style I/O Carrier Connector-Style I/O Carrier Connector-Style I/O Carrier Interposing Terminals for use with Connector-Style Carrier Barrier-Style Interposing I/O Terminals Box-Style Interposing I/O Terminals Thermocouple-Style Interposing I/O Terminals Spring-Style Interposing I/O Terminals Disconnect-Style Interposing I/O Terminals, Main Base Disconnect-Style Interposing I/O Terminals, Expansion Base Relay-Style Interposing I/O Terminals, Main Base Relay-Style Interposing I/O Terminals, Expansion Base Fuse-Style Interposing I/O Terminals, Main Base Fuse-Style Interposing I/O Terminals, Expansion Base Cables for use with Connector-Style I/O Carriers 2 connectors, 0.5m, no shield 2 connectors, 1.0m, no shield 2 connectors, 2.0m, no shield 1 connector, 3.0m, no shield IC200CBL105 IC200CBL110 IC200CBL120 IC200CBL230 IC200CHS011 IC200CHS012 IC200CHS014 IC200CHS015 IC200CHS101 IC200CHS102 IC200CHS111 IC200CHS112 IC200CHS121 IC200CHS122 IC200CHS003 IC200CHS022 IC200CHS025 IC200CHS001 IC200CHS002 IC200CHS005

Auxiliary I/O Terminal Strips for use with Terminal-style I/O Carriers and Interposing Terminals Barrier-Style Auxiliary I/O Terminal Strip Box-Style Auxiliary I/O Terminal Strip Spring-Style Auxiliary I/O Terminal Strip Other Carriers Communications Carrier Power Supply Booster Carrier
GFK-1503D Chapter 1 Introduction

IC200TBM001 IC200TBM002 IC200TBM005 IC200CHS006 IC200PWB001


1-11

1 Expansion Modules
There are two basic types of VersaMax I/O expansion systems, Multi-Rack and Single-ended:

Multi-Rack: A VersaMax PLC or NIU I/O Station with an Expansion Transmitter Module (IC200ETM001) and one to seven expansion racks, each with an Expansion Receiver Module (IC200ERM001 or IC200ERM002). If all the Expansion Receivers are the Isolated type (IC200ERM001), the maximum overall cable length is 750 meters. If the expansion bus includes any non-isolated Expansion Receivers (IC200ERM002), the maximum overall cable length is 15 meters.
VersaMax PLC or I/O Station Main Rack (0) ETM PS

CPU/NIU VersaMax ExpansionRack 1 15M with any IC200ERM002 ERMs 750M with all IC200ERM001 ERMs IC200CBL601, 602, 615 PS

ERM VersaMax ExpansionRack 7 PS

Terminator Plug

ERM

Single-ended: A CPU or NIU I/O Station connected directly to one expansion rack with non-isolated Expansion Receiver Module (IC200ERM002). Maximum cable length is 1 meter.
VersaMax PLC or NIU I/O Station Main Rack
PS

1M

CPU/NIU

VersaMax Expansion Rack


IC200CBL600

PS

ERM

1-12

VersaMax PLC Users Manual January 2006

GFK-1503D

1
VersaMax Modules for Expansion Racks
All types of VersaMax I/O and communications modules can be used in expansion racks. Some VersaMax analog modules require specific module revisions as listed below:
Module IC200ALG320 IC200ALG321 IC200ALG322 IC200ALG430 IC200ALG431 IC200ALG432 Module Revision B or later B or later B or later C or later C or later B or later

Available Expansion Modules


The following Expansion Modules and related products are available:
Expansion Modules Expansion Transmitter Module Expansion Receiver Module, Isolated Expansion Receiver Module, Non-isolated Cables Expansion Cable, Shielded, 1 meter Expansion Cable, Shielded, 2 meters Expansion Cable, Shielded, 15 meters Firmware Update Cable Terminator Plug (included with ETM) Connector Kit IC200CBL601 IC200CBL602 IC200CBL615 IC200CBL002 IC200ACC201 IC200ACC302 IC200ETM001 IC200ERM001 IC200ERM002

See the VersaMax Modules, Power Supplies, and Carriers Users Manual (GFK-1504) for information about VersaMax Expansion modules.

GFK-1503D

Chapter 1 Introduction

1-13

1 Communications Modules
Communications modules provide additional flexibility for VersaMax systems. These communications modules install on a VersaMax Communications Carrier. Power for the communications module comes from the main system power supply or from a booster supply as shown below.
VersaMax PLC CPU power supply Optional booster power supply Profibus Network Slave Module

Available VersaMax PLC Communications Modules


The following VersaMax PLC communications modules are available:
Communications Modules Profibus-DP Network Slave Module DeviceNet Network Control Module Asi Network Master Module Serial Communications Module Communications Carrier IC200BEM002 IC200BEM103 IC200BEM104 IC200CMM020 IC200CHS006

For information about the Communications Carrier, please see the VersaMax Modules, Power Supplies, and Carriers Users Manual (GFK1504).

1-14

VersaMax PLC Users Manual January 2006

GFK-1503D

1
Profibus-DP Network Slave Module
The Profibus-DP Network Slave Module (IC200BEM002) is a communications module that exchanges PLC reference table data on the Profibus network. The VersaMax PLC CPU can read and write this data as though it were conventional bit- and word-type I/O data. Multiple Profibus-DP Network Slave Modules may be used in the same VersaMax PLC. Each one can read up to 244 bytes of data from the network, and send up to 244 bytes of output data. The total amount of combined inputs and outputs is 384 bytes. For information about the Profibus-DP Network Slave Module, refer to the VersaMax System Profibus Network Modules Users Manual (GFK-1534, revision A or later).

DeviceNet Network Control Module


The DeviceNet Network Control Module (IC200BEM103) is a communications module that can be configured to operate as a master, as a slave, or as both simultaneously. It can exchange up to 512 bytes of input data and 512 bytes of output data with other devices on the DeviceNet network. The VersaMax PLC CPU can read and write this data as though it were conventional bit- and word-type I/O data. The Network Control Module operates as a Group 2 Only Client (master) and can communicate only with Group 2 Slave devices. It can also operate as a Group 2 Only or a UCMM-capable Server (slave), or as a master and slave simultaneously. For information about the DeviceNet Network Control Module, refer to the VersaMax System DeviceNet Network Communications Users Manual (GFK-1533).

GFK-1503D

Chapter 1 Introduction

1-15

1
Asi Network Master Module
The VersaMax AS-Interface Network Master (IC200BEM104) conforms to the AS-Interface Specification for the master AS-Interface protocol. It can be used to connect a VersaMax PLC or I/O station NIU to an Actuator-Sensor network. The AS-Interface module supports communications with up to 31 slave devices, exchanging to exchange up to 4 bits of input data and 4 bits of output data per slave address on the Actuator-Sensor network. For information about the AS-Interface Network Master Module, refer to the VersaMax System ASI Network Communications Users Manual (GFK1697).

Serial Communications Module


The VersaMax Serial Communications Module, IC200CMM020, operates as a Modbus RTU Master in a VersaMax I/O Station. The Serial Communications module receives commands from a remote host such as an RX7i PLC.

1-16

VersaMax PLC Users Manual January 2006

GFK-1503D

Chapter

CPU Module Datasheets: CPU001, CPU002, CPU005

This chapter describes the appearance, features, and functionality of the following VersaMax PLC CPU modules:

IC200CPU001 CPU with 34kB Configurable Memory IC200CPU002 CPU with 42kB Configurable Memory IC200CPU005 CPU with 128kB Configurable Memory

GFK-1503D

2-1

2
IC200CPU001: CPU with 34kB Configurable Memory IC200CPU002: CPU with 42kB Configurable Memory IC200CPU005: CPU with 128kB Configurable Memory
VersaMax PLC CPUs IC200CPU001, CPU002, and CPU005 provide powerful PLC functionality in a small, versatile system. They are designed to serve as the system controller for up to 64 modules with up to 2048 I/O points. Two serial ports provide RS-232 and RS-485 interfaces for SNP slave and RTU slave communications.
CPU001, CPU002
CPU001
PWR OK RUN FAULT FORCE PORT 1 PORT 2

CPU005
CPU005
PWR OK RUN FAULT FORCE PORT 1 PORT 2

IC200CPU001

IC200CPU005

PORT 1

PORT 1

RS232 PORT 2

RS232 PORT 2

RS485

RS485

Features


2-2

Non-volatile flash memory for program storage Programming in Ladder Diagram, Sequential Function Chart, and Instruction List Battery backup for program, data, and time of day clock Run/Stop switch Floating point (real) data functions Embedded RS-232 and RS-485 communications 70mm height when mounted on DIN rail with power supply Compatible with EZ Program Store device
GFK-1503D

VersaMax PLC Users Manual January 2006

2
CPU with 34kB Configurable Memory: IC200CPU001 CPU with 42kB Configurable Memory: IC200CPU002 CPU with 128kB Configurable Memory: IC200CPU005 Module Specifications
Size Program storage Battery Backup for program, data, and time-of-day clock CPU001/002: 2.63 (66.8mm) x 5.04 (128mm) CPU005: 4.20 (106.7mm) x 5.04 (128mm) System flash, battery-backed RAM Super capacitor provides power to memory for 1 hour Over 1 hour, backup battery protects memory contents up to 6 months. Backup battery has shelf life of 5 years when not in use. Backplane current consumption: IC200CPU001, IC200CPU002 Backplane current consumption: IC200CPU005 no serial port converter or EZ Program Store device with serial port converter or EZ Program Store device no serial port converter or EZ Program Store device with serial port converter or EZ Program Store device Floating point Embedded communications Boolean execution speed Realtime clock accuracy (for timer functions) Time of day clock accuracy yes RS-232, RS-485 CPU001, CPU002: 1.8ms/K (typical) CPU005: 0.5ms/K (typical) 100ppm (0.01%) or +/- 9sec/day 23ppm (0.0023%) or +/- 2sec/day @ 30C. 100 ppm (0.01%) or +/- 9sec/day @ full temperature range 5V output: 40mA 5V output: 140mA 5V output: 35mA 5V output: 135mA 3.3V output: 300mA* 3.3V output: 100mA

* CPU005 requires a power supply with expanded 3.3V.

GFK-1503D

Chapter 2 CPU Module Datasheets: CPU001, CPU002, CPU005

2-3

2
CPU with 34kB Configurable Memory: IC200CPU001 CPU with 42kB Configurable Memory: IC200CPU002 CPU with 128kB Configurable Memory: IC200CPU005 VersaMax General Product Specifications
VersaMax products should be installed and used in conformance with product-specific guidelines as well as the following specifications:
Environmental Vibration Shock Operating Temp. Storage Temp. Humidity Enclosure Protection EMC Emission Radiated, Conducted IEC68-2-6 IEC68-2-27 1G @57-150Hz, 0.012in p--p @10-57Hz 15G, 11ms 0 deg C to +60 deg C ambient -40 deg C to +85 deg C 5% to 95%, noncondensing Steel cabinet per IP54: protection from dust & splashing water Industrial Scientific & Medical Equipment (Group 1, Class A) Information Technology Equipment (Class A) referred to as FCC part 15, Radio Devices (Class A) 8KV Air, 4KV Contact 10Vrms /m, 80Mhz to 1000Mhz, 80% AM 10Vrms/m, 900MHz +/-5MHZ 100%AM with 200Hz square wave 2KV: power supplies, 1KV: I/O, communication Damped Oscillatory Wave: 2.5KV power supplies, I/O [12V-240V]; 1KV communication Damped Oscillatory Wave: Class II, power supplies, I/O [12V-240V] 2 kV cm(P/S); 1 kV cm (I/O and communication modules) 10Vrms, 0.15 to 80Mhz, 80%AM 1.5KV During Operation: Dips to 30% and 100%, Variation for AC +/-10%, Variation for DC +/-20%

IEC529

CISPR 11/EN 55011 CISPR 22/EN 55022 FCC 47 CFR 15

EMC Immunity Electrostatic Discharge RF Susceptibility

EN 61000-4-2 EN 61000-4-3 ENV 50140/ENV 50204

Fast Transient Burst Surge Withstand

EN 61000-4-4 ANSI/IEEE C37.90a IEC255-4 EN 61000-4-5

Conducted RF Isolation Dielectric Withstand Power Supply Input Dips, Variations

EN 61000-4-6 UL508, UL840, IEC664 EN 61000-4-11

2-4

VersaMax PLC Users Manual January 2006

GFK-1503D

2
IC200CPU001: CPU with 34kB Configurable Memory IC200CPU002: CPU with 42kB Configurable Memory IC200CPU005: CPU with 128kB Configurable Memory Serial Ports
The two serial ports are software-configurable for SNP slave or RTU master or slave operation. 4-wire and 2-wire RTU are supported. If a port is being used for RTU, it automatically switches to SNP slave mode if necessary. Both ports default to SNP slave and both automatically revert to SNP slave when the CPU is in Stop mode, if configured for Serial I/O. Either port can be software-configured to set up communications between the CPU and various serial devices. An external device can obtain power from Port 2 if it requires 100mA or less at 5VDC.
PORT 1

Port 1: is an RS-232 port with a 9-pin female D-sub


connector. The pinout of Port 1 allows a simple straightthrough cable to connect with a standard AT-style RS-232 port. Maximum cable lengths from the CPU to the last device attached to the cable are:
Baud Rate Maximum Cable Length 15 meters (50 ft.) 7.5 meters (25 ft.) 5 meters (16 ft.) 2.5 meters (8 ft.)

RS232 PORT 2

19.2 K and below 38.4K 57.6K 115.2K

Port 2: is an RS-485 port with a 15-pin female D-sub


RS485

connector. This can be attached directly to an RS-485 to RS-232 adapter (IC690ACC901). Maximum cable lengthsfrom the CPU to the last device attached to the cable is Port 2 1200 meters (4000 ft.)
Port 1 Defaults to SNP slave PLC in Stop/No I/O mode. PLC in Stop/No I/O mode Port 2 Defaults to SNP slave no PLC in Stop/No IO mode.

The following table compares the functions of Port 1 and Port 2.


CPU Protocols (SNP slave, RTU master/slave, Serial I/O) Firmware Upgrade Smart module firmware upgrade

GFK-1503D

Chapter 2 CPU Module Datasheets: CPU001, CPU002, CPU005

2-5

2
CPU with 34kB Configurable Memory: IC200CPU001 CPU with 42kB Configurable Memory: IC200CPU002 CPU with 128kB Configurable Memory: IC200CPU005 Serial Port Baud Rates
RTU protocol Serial I/O protocol SNP protocol Firmware Upgrade via WinLoader CPU001, CPU002 1200, 2400, 4800, 9600, 19.2K 1200, 2400, 4800, 9600, 19.2K 4800, 9600, 19.2K, 38.4K* 1200, 2400, 4800, 9600, 19.2K, 38.4K CPU005** 1200, 2400, 4800, 9600, 19.2K, 38.4K*, 57.6K* 1200, 2400, 4800, 9600, 19.2K, 38.4K*, 57.6K* 4800, 9600, 19.2K, 38.4K* 1200, 2400, 4800, 9600, 19.2K, 38.4K, 57.6K, 115.2K

* Only on one port at a time, not available on older CPU001 and CPU002 hardware revisions. ** Some versions of VersaPro software allow configuration of RTU and Serial I/O at 115.2K baud for CPU005. However, this baud rate is not supported by the CPU. If a configuration using this baud rate is stored to the PLC: 1. For RTU, an Unsupported Feature in Configuration fault is logged and the PLC transitions to Stop Faulted mode. 2. For Serial I/O, the same fault is logged when the transition to Run mode occurs. The PLC will immediately transition to Stop Faulted mode.

Mode Switch
The CPU module has a convenient switch that can be used to place the PLC in Stop or Run mode. The same switch can also be used to block accidental writing to CPU memory and forcing or overriding discrete data. Use of this feature is configurable. The default configuration enables Run/Stop mode selection and disables memory protection.

RUN/ON

STOP/OFF

2-6

VersaMax PLC Users Manual January 2006

GFK-1503D

2
IC200CPU001: CPU with 34kB Configurable Memory IC200CPU002: CPU with 42kB Configurable Memory IC200CPU005: CPU with 128kB Configurable Memory CPU LEDs
The seven CPU LEDs, visible through the module door, indicate the presence of power and show the operating mode and diagnostic status of the CPU. They also indicate the presence of faults, forces, and communications on the CPUs two ports.
CPU001
PWR OK RUN FAULT FORCE PORT 1 PORT 2

POWER OK

ON when the CPU is receiving 5V power from the power supply. Does not indicate the status of the 3.3V power output. ON indicates the CPU has passed its powerup diagnostics and is functioning properly. OFF indicates a CPU problem. Fast blinking indicates that the CPU is running its powerup diagnostics. Slow blinking indicates the CPU is configuring I/O modules. Simultaneous blinking of this LED and the green Run LED indicates that the CPU is in boot mode and is waiting for a firmware update through port 1. Green when the CPU is in Run mode. Amber when the CPU is in Stop/IO Scan mode. If this LED is OFF but OK is ON, the CPU is in Stop/No IO Scan mode. If this LED is flashing green and the Fault LED is ON, the module switch was moved from Stop to Run mode while a fatal fault existed. Toggling the switch will continue to Run mode.

RUN

FAULT

ON if the CPU is in Stop/Faulted mode because a fatal fault has occurred. To turn off the Fault LED, clear both the I/O Fault Table and the PLC Fault Table. If this LED is blinking and the OK LED is OFF, a fatal fault was detected during PLC powerup diagnostics. Contact PLC Field Service. ON if an override is active on a bit reference. Blinking indicates activity on that port.

FORCE PORT 1 PORT 2

GFK-1503D

Chapter 2 CPU Module Datasheets: CPU001, CPU002, CPU005

2-7

2
CPU with 34kB Configurable Memory: IC200CPU001 CPU with 42kB Configurable Memory: IC200CPU002 CPU with 128kB Configurable Memory: IC200CPU005 Configurable Memory
CPU001 and CPU002 (release 2.0 or later) and CPU005 have configurable user memory. The configurable memory is the amount of memory required for the application program, hardware configuration, registers (%R), analog inputs (%AI), and analog outputs (%AQ). The amount of memory allocated to the application program and hardware configuration are automatically determined by the actual program and configuration entered from the programmer. The rest of the configurable memory can be easily allocated to suit the application.
Configurable memory CPU001: 34K bytes maximum CPU002: 42K bytes maximum CPU005: 128K bytes maximum 128 bytes minimum 12K bytes 20K bytes 400 bytes minimum 256 bytes minimum 4,096 bytes 256 bytes minimum 256 bytes minimum

Application program size (not configurable) CPU001, for rel. 1.50 compatibility CPU002, for rel. 1.50 compatibility Hardware configuration size (not configurable) Registers (%R) CPU001/002, for rel. 1.50 compatibility Analog Inputs (%AI) Analog Outputs (%AQ)

2-8

VersaMax PLC Users Manual January 2006

GFK-1503D

Chapter

CPU Module Datasheet: CPUE05

This chapter describes the appearance, features, and functionality of the following VersaMax PLC CPU module:

IC200CPUE05: CPU with Two Serial Ports, Embedded Ethernet Interface, and 128K Configurable Memory

GFK-1503D

3-1

3
IC200CPUE05: CPU with Two Serial Ports, Embedded Ethernet Interface, and 128K Configurable Memory
CPU IC200CPUE05 shares the basic features of the other VersaMax PLC CPUs. It provides powerful PLC functionality in a small, versatile system. CPUE05 can serve as the system controller for up to 64 modules with up to 2048 I/O points. Two serial ports provide RS-232 and RS-485 interfaces for serial communications. CPUE05 also provides a built-in Ethernet Interface. The RS-232 serial port can be configured for Local Station manager operation to provide access to diagnostic information about the Ethernet interface. CPUE05 has 128kB of configurable memory. In addition, CPUE05 is compatible with the EZ Program Store device, which can be used to write, read, update, and verify programs, configuration, and reference tables data without a programmer or programming software.
CPUE05
PWR OK RUN FAULT FORCE PORT 1 PORT 2

MAC XXXXXXXXXX

IC200CPUE05
CPU 40K BYTES USER MEM

PORT 1

IP ADDRESS

RS232 PORT 2 ETHERNET RESTART

ETHERNET 10 MBPS BASE T

LAN STAT PORT 1

RS485

Features


3-2

128kB of configurable memory Programming in Ladder Diagram, Sequential Function Chart, and Instruction List Non-volatile flash memory for program storage Battery backup for program, data, and time of day clock Run/Stop switch Floating point (real) data functions Embedded RS-232 and RS-485 communications Embedded Ethernet interface 70mm height when mounted on DIN rail with power supply
VersaMax PLC Users Manual January 2006 GFK-1503D

3
CPU with Two Serial Ports, Embedded Ethernet Interface, and 128K Configurable Memory: IC200CPUE05 Module Specifications
Size Program storage Battery backup for program, data, and time-of-day clockl 4.95 (126mm) x 5.04 (128mm) System flash, battery-backed RAM Super capacitor provides power to memory for 1 hour Over 1 hour, backup battery protects memory contents up to 6 months. Backup battery has shelf life of 5 years when not in use. no serial port converter or EZ Program Store device with serial port converter or EZ Program Store device Floating point Boolean execution speed Realtime clock accuracy (for timer functions) Time of day clock accuracy Embedded communications Configurable memory Ethernet Interface Specifications Number of SRTP server connections Ethernet data rate Physical interface WinLoader support Number of Ethernet Global Data configuration-based exchanges EGD Exchange limits Time Synchronization Selective Consumption of EGD Load EGD configuration from PLC to programmer Remote Station Manager over UDP Local Station Manager (RS-232) Configurable Advanced User Parameters yes 0.5ms/K (typical) 100ppm (0.01%) or +/- 9sec/day 23ppm (0.0023%) or +/- 2sec/day @ 30C. 100 ppm (0.01%) or +/- 9sec/day @ full temperature range RS-232, RS-485, Ethernet interface 128K bytes maximum 8 10Mbps 10BaseT RJ45 via CPU port 32 100 data ranges and 1400 bytes of data per exchange; 1200 total data ranges across all exchanges. NTP - client only yes yes yes via CPU port yes 5V output: 220mA 5V output: 320mA 3.3V output: 570mA*

Backplane current consumption: IC200CPUE05

*
GFK-1503D

CPUE05 requires a power supply with expanded 3.3V.


Chapter 3 CPU Module Datasheet: CPUE05 3-3

3
IC200CPUE05: CPU with Two Serial Ports, Embedded Ethernet Interface, and 128K Configurable Memory VersaMax General Product Specifications
VersaMax products should be installed and used in conformance with product-specific guidelines as well as the following specifications:
Environmental Vibration Shock Operating Temp. Storage Temp. Humidity Enclosure Protection EMC Emission Radiated, Conducted IEC68-2-6 IEC68-2-27 1G @57-150Hz, 0.012in p--p @10-57Hz 15G, 11ms 0 deg C to +60 deg C ambient -40 deg C to +85 deg C 5% to 95%, noncondensing Steel cabinet per IP54: protection from dust & splashing water Industrial Scientific & Medical Equipment (Group 1, Class A) Information Technology Equipment (Class A) referred to as FCC part 15, Radio Devices (Class A) 8KV Air, 4KV Contact 10Vrms /m, 80Mhz to 1000Mhz, 80% AM 10Vrms/m, 900MHz +/-5MHZ 100%AM with 200Hz square wave 2KV: power supplies, 1KV: I/O, communication Damped Oscillatory Wave: 2.5KV power supplies, I/O [12V-240V]; 1KV communication Damped Oscillatory Wave: Class II, power supplies, I/O [12V-240V] 2 kV cm(P/S); 1 kV cm (I/O and communication modules) 10Vrms, 0.15 to 80Mhz, 80%AM 1.5KV During Operation: Dips to 30% and 100%, Variation for AC +/-10%, Variation for DC +/-20%

IEC529

CISPR 11/EN 55011 CISPR 22/EN 55022 FCC 47 CFR 15

EMC Immunity Electrostatic Discharge RF Susceptibility

EN 61000-4-2 EN 61000-4-3 ENV 50140/ENV 50204

Fast Transient Burst Surge Withstand

EN 61000-4-4 ANSI/IEEE C37.90a IEC255-4 EN 61000-4-5

Conducted RF Isolation Dielectric Withstand Power Supply Input Dips, Variations

EN 61000-4-6 UL508, UL840, IEC664 EN 61000-4-11

3-4

VersaMax PLC Users Manual January 2006

GFK-1503D

3
IC200CPUE05: CPU with Two Serial Ports, Embedded Ethernet Interface, and 128K Configurable Memory Serial Ports
The two serial ports are software-configurable for SNP slave or RTU master or slave operation. 4-wire and 2-wire RTU are supported. If a port is being used for RTU, it automatically switches to SNP slave mode if necessary. Port 1 can also be configured for Local Station Manager operation to provide access to diagnostic information about the Ethernet interface. Both ports default to SNP slave and both automatically revert to SNP slave when the CPU is in Stop mode, if configured for Serial I/O. Either port can be software-configured to set up communications between the CPU and various serial devices. An external device can obtain power from Port 2 if it requires 100mA or less at 5VDC.
PORT 1

Port 1: is an RS-232 port with a 9-pin female D-sub connector. The


pinout of Port 1 allows a simple straight-through cable to connect with a standard AT-style RS-232 port. Port 1 can be configured for either CPU serial communications (SNP, RTU, Serial I/O), or local Station Manager use. If Port 1 has been configured for CPU use, it can be forced to local Station Manager operation using the Restart pushbutton. Once forced, Port 1 remains available for station manager use until the PLC is power cycled, or the Restart pushbutton is pressed. If Port 1 is configured as a local Station Manager, it cannot be used for CPU serial communications or for firmware upgrades using Winloader. The Restart pushbutton will NOT toggle it to the CPU serial protocols.

RS232 PORT 2

Port 2: is an RS-485 port with a 15-pin female D-sub connector. This can
RS485

be attached directly to an RS-485 to RS-232 adapter (IC690ACC901). Port 2 can be used for program, configuration, and table updates with the EZ Program Store module. The following table compares the functions of Port 1 and Port 2.
CPU Protocols (SNP slave, RTU master/ slave, Serial I/O) Local Station Manager Firmware Upgrade Smart module firmware upgrade EZ Program Store device Port 1 Defaults to SNP slave Yes (see above) PLC in Stop/No I/O mode, Port 1 not disabled or in Local Station Manager mode. PLC in Stop/No I/O mode, Port 1 configured for CPU protocol No Port 2 Defaults to SNP slave no no PLC must be in Stop/No IO mode. Read, Write, Verify, and Update. PLC must be in Stop/No IO mode.
3-5

GFK-1503D

Chapter 3 CPU Module Datasheet: CPUE05

3
CPU with Two Serial Ports, Embedded Ethernet Interface, and 128K Configurable Memory: IC200CPUE05 Cable Lengths
Maximum cable lengths from the CPU to the last device attached to the cable are: Port 1 (RS-232):
Baud Rate 19.2 K and below 38.4K 57.6K 115.2K Maximum Cable Length 15 meters (50 ft.) 7.5 meters (25 ft.) 5 meters (16 ft.) 2.5 meters (8 ft.)

Port 2 (RS-485): 1200 meters (4000 ft.)

Serial Port Baud Rates


RTU protocol Serial I/O protocol SNP protocol Local Station Manager (this is independent of serial protocol baud rate) Firmware Upgrade via WinLoader Port 1 1200, 2400, 4800, 9600, 19.2K, 38.4K*, 57.6K* 1200, 2400, 4800, 9600, 19.2K, 38.4K*, 57.6K* 4800, 9600, 19.2K, 38.4K* 1200, 2400, 4800, 9600, 19.2K, 38.4K, 57.6K, 115.2K 2400, 4800, 9600, 19.2K, 38.4K, 57.6K, 115.2K Port 2 1200, 2400, 4800, 9600, 19.2K, 38.4K*, 57.6K* 1200, 2400, 4800, 9600, 19.2K, 38.4K*, 57.6K* 4800, 9600, 19.2K, 38.4K* na

na

Only on one port at a time.

Some versions of VersaPro software allow configuration of RTU and Serial I/O at 115.2K baud. However, this baud rate is not supported by the CPU. If a configuration using this baud rate is stored to the PLC: 1. For RTU, an Unsupported Feature in Configuration fault is logged and the PLC transitions to Stop Faulted mode. 2. For Serial I/O, the same fault is logged when the transition to Run mode occurs. The PLC will immediately transition to Stop Faulted mode.

3-6

VersaMax PLC Users Manual January 2006

GFK-1503D

3
CPU with Two Serial Ports, Embedded Ethernet Interface, and 128K Configurable Memory: IC200CPUE05 Ethernet LAN Port
The Ethernet LAN port supports SRTP Server and Ethernet Global Data. This port connects directly to a 10BaseT (twisted pair) network without an external transceiver. The 10BaseT twisted pair cables must meet applicable IEEE 802 standards. CPUE05 automatically selects either half-duplex of fullduplex operation, as sensed from the network connection. A space is provided on the front of the CPUE05 module where the configured IP Address can be written.
IP Address Writable Area
IP ADDRESS

Ethernet LAN Port

ETHERNET RESTART

ETHERNET 10 BASE T

LAN STAT PORT 1 RJ 45

GFK-1503D

Chapter 3 CPU Module Datasheet: CPUE05

3-7

3
IC200CPUE05: CPU with Two Serial Ports, Embedded Ethernet Interface, and 128K Configurable Memory Mode Switch
The Mode switch is located behind the module door. It can be used to place the PLC in Stop or Run mode. It can also be used to block accidental writing to CPU memory and forcing or overriding discrete data. Use of this feature is configurable. The default configuration enables Run/Stop mode selection and disables memory protection.
RUN/ON

STOP/OFF

CPU LEDs
The seven CPU LEDs, visible through the module door, indicate the presence of power and show the operating mode and diagnostic status of the CPU. They also indicate the presence of faults, forces, and communications on the CPUs two ports
CPUE05
PWR OK RUN FAULT FORCE PORT 1 PORT 2

POWER OK

ON when the CPU is receiving 5V power from the power supply. Does not indicate the status of the 3.3V power output. ON indicates the CPU has passed its powerup diagnostics and is functioning properly. OFF indicates a CPU problem. Fast blinking indicates that the CPU is running its powerup diagnostics. Slow blinking indicates the CPU is configuring I/O modules. Simultaneous blinking of this LED and the green Run LED indicates that the CPU is in boot mode and is waiting for a firmware update through port 1. Green when the CPU is in Run mode. Amber when the CPU is in Stop/IO Scan mode. If this LED is OFF but OK is ON, the CPU is in Stop/No IO Scan mode. If this LED is flashing green and the Fault LED is ON, the module switch was moved from Stop to Run mode while a fatal fault existed. Toggling the switch will continue to Run mode.

RUN

FAULT

ON if the CPU is in Stop/Faulted mode because a fatal fault has occurred. To turn off the Fault LED, clear both the I/O Fault Table and the PLC Fault Table. If this LED is blinking and the OK LED is OFF a fatal fault was detected during PLC powerup diagnostics. Contact PLC Field Service. ON if an override is active on a bit reference. Blinking indicates activity on that port when controlled by the CPU.

FORCE PORT 1 PORT 2


3-8

VersaMax PLC Users Manual January 2006

GFK-1503D

3
CPU with Two Serial Ports, Embedded Ethernet Interface, and 128K Configurable Memory: IC200CPUE05 Ethernet Restart Pushbutton
The Ethernet Restart pushbutton is located on the right side of the module.
IP Address Writable Area
IP ADDRESS

ETHERNET RESTART

Ethernet Restart Pushbutton

ETHERNET 10 BASE T

LAN STAT PORT 1

Ethernet LEDs

The Ethernet Restart pushbutton has two functions:

When pressed for less than 5 seconds, it resets the Ethernet hardware, tests the Ethernet LEDs, and restarts the Ethernet firmware. This disrupts any Ethernet communications that are presently underway. When pressed for at least 5 seconds, it toggles the function of Port 1 between its configured operation and forced local Station Manager operation. Note that if Port 1 is available for Local Station Manager operation, Winloader cannot be used for a firmware upgrade.

Ethernet LEDs
Three LEDs indicate the status and activity of the Ethernet interface.
LAN STAT
indicates the status and activity of the Ethernet network connection. ON/flickering green indicates Ethernet interface is online. ON amber indicates Ethernet interface is offline indicates the general status of the Ethernet interface. ON green indicates no exception detected. ON amber indicates an exception. Blinking amber indicates error code. Blinking green indicates waiting for configuration or waiting for IP address. indicates when the Ethernet interface is controlling the RS-232 serial port. It also indicates when the Ethernet Restart pushbutton has been used to override configured RS-232 port usage for Local Station Manager operation. ON amber indicates Port 1 is available for Local Station Manager use (either by configuration or forced). OFF indicates PLC CPU is controlling Port 1. (Does not blink to indicate traffic).

PORT1

The Ethernet LEDs turn ON briefly, first amber then green, when a restart is performed in the Operational state by pressing and releasing the Restart pushbutton. This verifies that the Ethernet LEDs are operational. All three LEDs blink green in unison when a software load is in progress.
GFK-1503D Chapter 3 CPU Module Datasheet: CPUE05 3-9

3
IC200CPUE05: CPU with Two Serial Ports, Embedded Ethernet Interface, and 128K Configurable Memory Configurable Memory
CPUE05 provides a total of 128K bytes of configurable user memory. This 64K of memory is use for the application program, hardware configuration, registers (%R), analog inputs (%AI), and analog outputs (%AQ). The amount of memory allocated to the application program and hardware configuration are automatically determined by the actual program and configuration entered from the programmer. The rest of the 64K bytes can be easily configured to suit the application.
Configurable memory Application program size (not configurable) Hardware configuration size (not configurable) Registers (%R) Analog Inputs (%AI) Analog Outputs (%AQ) 128K bytes maximum 128 bytes minimum 528 bytes minimum 256 bytes minimum 256 bytes minimum 256 bytes minimum

3-10

VersaMax PLC Users Manual January 2006

GFK-1503D

3
CPU with Two Serial Ports, Embedded Ethernet Interface, and 128K Configurable Memory: IC200CPUE05 Ethernet Interface Overview
CPUE05 has a built-in Ethernet interface that makes it possible to communicate on a 10BaseT network. Both half-duplex and full-duplex operation are supported. Using 10/100 hubs allows CPUE05 to communicate on a network containing 100Mb devices.-

SRTP Server
CPUE05 supports up to eight simultaneous SRTP Server connections for use by other devices on the Ethernet network, such as the PLC programmer, CIMPLICITY HMI, SRTP channels for Series 90 PLCs, and Host Communications Toolkit applications. No PLC programming is required for server operation.

Ethernet Global Data


CPUE05 supports up to 32 simultaneous Ethernet Global Data exchanges. Global Data exchanges are configured using the PLC programming software, then stored to the PLC. Both Produced and Consumed exchanges may be configured. CPUE05 supports up to 1200 variables across all Ethernet Global Data exchanges, and supports selective consumption of Ethernet Global Data exchanges. See chapter 13 for information about Ethernet Global Data.

Station Manager Functionality


CPUE05 has built-in Station Manager functionality. This permits on-line diagnostic and supervisory access through either the Station Manager port or via the Ethernet network. Station Manager services include:

An interactive set of commands for interrogating and controlling the station. Unrestricted access to observe internal statistics, an exception log, and configuration parameters. Password security for commands that change station parameters or operation.

Use of the Station Manager function requires a separate computer terminal or terminal emulator. See GFK-1876 for information about Station Manager operation.
GFK-1503D Chapter 3 CPU Module Datasheet: CPUE05 3-11

3-12

VersaMax PLC Users Manual January 2006

GFK-1503D

Chapter

Installation

This chapter describes:

Installing the CPU Installing the power supply Installing additional modules Activating or replacing the backup battery Serial port connections Installing expansion modules Ethernet connection for CPUE05 CE Mark installation requirements

System installation instructions, which give guidelines for carrier, power supply, and module installation, as well as information about field wiring and grounding, are located in the VersaMax Modules, Power Supplies, and Carriers Manual, GFK-1504.

GFK-1503D

4-1

4 Mounting Instructions
All VersaMax modules and carriers in the same PLC rack must be installed on a single section of 7.5mm X 35mm DIN rail, 1mm thick. Steel DIN rail is recommended. The DIN rail must be electrically grounded to provide EMC protection. The rail must have a conductive (unpainted) corrosion-resistant finish. DIN rails compliant with DIN EN50022 are preferred. For vibration resistance, the DIN rail should be installed on a panel using screws spaced approximately 15.24cm (6 inches) apart. The base snaps easily onto the DIN rail. No tools are required for mounting or grounding to the rail.

Removing the CPU from the DIN Rail


1. Turn off power to the power supply. 2. (If the CPU is attached to the panel with a screw) remove the power supply module. Remove the panel-mount screw. 3. Slide the CPU along the DIN rail away from the other modules until the connector disengages. 4. With a small flathead screwdriver, pull down on the DIN rail latch tab(s) on the bottom of the module and lift the module off the DIN rail.

4-2

VersaMax PLC Users Manual January 2006

GFK-1503D

4
Panel-Mounting
For maximum resistance to mechanical vibration and shock, the equipment must also be installed on a panel. Using the module as a template, mark the location of the modules panel-mount hole on the panel. Drill the hole in the panel. Install the module using an M3.5 (#6) screw in the panel-mount hole.

Note 1. Tolerances on all dimensions are +/- 0.13mm +/-0.005in) noncumulative. Note 2. 1.1 to 1.4Nm (10 to 12 in/lbs) of torque should be applied to M3.5 (#6-32) steel screw threaded into material containing internal threads and having a minimum thickness of 2.4mm (0.093in).
SEE NOTE 2.

4.3mm 0.170in

M3.5 (#6) SCREW SPLIT LOCK W ASHER FLAT W ASHER

4.3mm 0.170in 5.1mm 0.200in

15.9mm 0.62in REF

TAPPED HOLE IN PANEL

CPU

GFK-1503D

Chapter 4 Installation

4-3

4 Installing an Expansion Transmitter Module


If the VersaMax PLC will have more than one expansion rack or one expansion rack that uses an Isolated Expansion Receiver Module (IC200ERM001) as its interface to the expansion bus, an Expansion Transmitter Module must be installed to the left of the CPU. The Expansion Transmitter Module must be installed on the same section of DIN rail as the rest of the modules in the main rack (rack 0).
Expansion Transmitter Module CPU and Power Supply

ETM

PS

CPU VersaMax PLC Main Rack (0)

1. Make sure rack power is off. 2. Attach the Expansion Transmitter to DIN rail to the left of the CPU position. 3. Install the CPU. Connect the modules and press them together until the connectors are mated. 4. After completing any additional system installation steps, apply power and observe the module LEDs.
On indicates presence of 5VDC power. Off indicates no 5VDC power.
PWR EXP TX

Blinking or On indicates active communications on expansion bus. Off indicates no communications.

Removing an Expansion Transmitter Module


1. Make sure rack power is off. 2. Slide module on DIN rail away from the CPU in the main rack. 3. Using a small screwdriver, pull down on the tab on the bottom of the module and lift the module off the DIN rail.

4-4

VersaMax PLC Users Manual January 2006

GFK-1503D

4 Installing an Expansion Receiver Module


An Expansion Receiver Module (IC200ERM001 or 002) must be installed in the leftmost slot of each VersaMax expansion rack. 1. Insert the label inside the small access door at the upper left corner of the module. 2. Attach the module to the DIN rail at the left end of the expansion rack. 3. Select the expansion rack ID (1 to 7) using the rotary switch under the access door at upper left corner of the module. Each rack must be set to a different rack ID. With a single-ended cable (one expansion rack only), set the Rack ID to 1.
1 7 6 5 2 3 4

4. Install a VersaMax Power Supply module on top of the Expansion Receiver. See Installing a Power Supply in this chapter for details. 5. Attach the cables. If the system includes an Expansion Transmitter Module, attach the terminator plug to the EXP2 port on the last Expansion Receiver Module. 6. After completing any additional system installation steps, apply power and observe the module LEDs.
On indicates presence of 5VDC power. Off indicates no 5VDC power. Green indicates CPU/NIU is scanning I/O in expansion racks. Amber indicates not scanning. Blinking or On indicates module is communicating on expansion bus Off indicates module not communicating

PWR SCAN EXP RX

GFK-1503D

Chapter 4 Installation

4-5

4
Removing an Expansion Receiver Module
1. Make sure rack power is off. 2. Uninstall the Power Supply module from the Expansion Receiver Module. 3. Slide the Expansion Receiver Module on DIN rail away from the other modules. 4. Using a small screwdriver, pull down on the tab on the bottom of the module and lift the module off the DIN rail.

Expansion Rack Power Sources


Power for module operation comes from the Power Supply installed on the Expansion Receiver Module. If the expansion rack includes any Power Supply Booster Carrier and additional rack Power Supply, it must be tied to the same source as the Power Supply on the Expansion Receiver Module.

Connecting the Expansion Cable: RS-485 Differential


For a multiple-rack expansion system, connect the cable from the expansion port on the Expansion Transmitter to the Expansion Receivers as shown below. If all the Expansion Receivers are the Isolated type (IC200ERM001), the maximum overall cable length is 750 meters. If the expansion bus includes any non-isolated Expansion Receivers (IC200ERM002), the maximum overall cable length is 15 meters.
VersaMax PLC or I/O Station Main Rack (0) ETM PS

CPU/NIU VersaMax ExpansionRack 1 15M with any IC200ERM002 ERMs 750M with all IC200ERM001 ERMs PS

ERM VersaMax ExpansionRack 7 PS

Terminator Plug ERM

4-6

VersaMax PLC Users Manual January 2006

GFK-1503D

4
Install the Terminator Plug (supplied with the Expansion Transmitter module) into the lower port on the last Expansion Receiver. Spare Terminator Plugs can be purchased separately as part number IC200ACC201 (Qty 2).

RS-485 Differential Inter-Rack Connection (IC200CBL601, 602, 615)


PIN 2 3 5 6 8 9 12 13 16 17 20 21 24 25 7 23 1 FRAME+ FRAMERIRQ/+ RIRQ/RUN+ RUNRERR+ RERRIODT+ IODTRSEL+ RSELIOCLK+ IOCLK0V 0V SHIELD 26-PIN MALE VARIABLE (SEE TEXT) PIN 2 3 5 6 8 9 12 13 16 17 20 21 24 25 7 23 1 FRAME+ FRAMERIRQ/+ RIRQ/RUN+ RUNRERR+ RERRIODT+ IODTRSEL+ RSELIOCLK+ IOCLK0V 0V SHIELD 26-PIN MALE

Expansion Transmitter or Expansion Receiver Module Transmitting Port

Expansion Transmitter or Expansion Receiver Module Receiving Port

26-PIN FEMALE

26-PIN FEMALE

Building a Custom Expansion Cable


Custom expansion cables can be built using Connector Kit IC200ACC202, Crimper AMP 90800-1, and Belden 8138, Manhattan/CDT M2483, Alpha 2 3498C, or equivalent AWG #28 (0.089mm ) cable.

GFK-1503D

Chapter 4 Installation

4-7

4
Connecting the Expansion Cable: Single-ended
For a system with one non-isolated expansion rack (IC200ERM002) and NO Expansion Transmitter, connect the expansion cable from the serial port on the VersaMax CPU to the Expansion Receiver as shown below. The maximum cable length is one meter. Cables cannot be fabricated for this type of installation; cable IC200CBL600 must be ordered separately.
VersaMax PLC or NIU I/O Station Main Rack
PS

1M

CPU/NIU

VersaMax Expansion Rack PS

ERM

No Terminator Plug is needed in a single-ended installation; however, it will not impede system operation if installed.

Single-Ended Inter-Rack Connection (IC200CBL600)


PIN PIN

VersaMax CPU or NIU Serial Port

16 15

1 2 3 6 9 10 12 16 14

0V T_IOCLK T_RUN T_IODT_ T_RERR T_RIRQ_ T_FRAME T_RSEL 0V

4 7 22 14 18 15 11 10 19 23 1 1M

SINGLE_ 0V T_IOCLK T_RUN T_IODT_ T_RERR T_RIRQ_ T_FRAME T_RSEL 0V SHIELD

IC200ERM002

Expansion Receiver Receiving Port

16-PIN MALE

16-PIN FEMALE

26-PIN MALE

26-PIN FEMALE

Power Sources for Single-Ended Expansion Rack Systems


When operating the system in single-ended mode, power supplies for the main rack and expansion rack must use the same main power source. The main rack and expansion racks cannot be switched ON and OFF separately; either both must be ON or both must be OFF for proper operation. Power for modules in the expansion rack comes from the Power Supply installed on the Expansion Receiver Module. If the expansion rack includes a Power Supply Booster Carrier and additional rack Power Supply, it must be tied to the same source as the Power Supply on the Expansion Receiver Module.
4-8 VersaMax PLC Users Manual January 2006 GFK-1503D

4 Installing Power Supply Modules


Power Supply modules install directly onto the CPU module, Expansion Receiver Modules, and supplementary power supply carriers. The Power Supply on the CPU or Expansion Receiver Module supplies +5V and +3.3V to downstream modules through the mating connector. The number of modules that can be supported depends on the power requirements of the modules. Additional booster Power Supplies can be used as needed to meet the power needs of all modules. If the rack includes any Power Supply Booster Carrier and additional rack Power Supply, it must be tied to the same source as the Power Supply on the CPU. The configuration software provides power calculations with a valid hardware configuration. Power Supply installation instructions are given below. 1. The latch on the power supply must be in the unlocked position. 2. Align the connectors and the latch post and press the power supply module down firmly, until the two tabs on the bottom of the power supply click into place. Be sure the tabs are fully inserted in the holes in bottom edge of the CPU, ERM, or carrier. 3. Turn the latch to the locked position to secure the power supply.

Removing the Power Supply


Exercise care when working around operating equipment. Devices may become very hot and could cause injury. 1. Remove power. 2. Turn the latch to the unlocked position as illustrated.

3. Press the flexible panel on the lower edge of the power supply to disengage the tabs on the power supply from the holes in the carrier. 4. Pull the power supply straight off.

GFK-1503D

Chapter 4 Installation

4-9

4 Installing Additional Modules


A CPU or Expansion Receiver Module can serve up to 8 additional I/O and option modules on the same section of DIN rail. Power must be off before adding a carrier to the rack. Before joining carriers to the CPU or ERM, remove the connector cover on the righthand side of the CPU/ERM. Do not discard this cover; you will need to install it on the last carrier. It protects the connector pins from damage and ESD during handling and use. Do not remove the connector cover on the lefthand side.
Connector Cover Connector Cover

Install each carrier close to the previously-installed carrier, then slide the properly-aligned carriers together to join the mating connectors. To avoid damaging the connector pins, do not force or slam carriers together.

DIN-rail clamps (available as part number IC200ACC313) should be installed at both ends of the station to lock the modules in position.

4-10

VersaMax PLC Users Manual January 2006

GFK-1503D

Activating or Replacing the Backup Battery


The CPU module is shipped with a battery already installed. The battery holder is located in the top side of the CPU module. Before the first use, activate the battery by pulling and removing the insulator tab.

Lithium Battery Replacement


To replace the battery, use a small screwdriver to gently pry open the battery holder. Replace battery only with one of the following: GE Fanuc Panasonic IC200ACC001 BR2032

Use of another battery may present a risk of fire or explosion.

Caution
Battery may explode if mistreated. Do not recharge, disassemble, heat above 100 deg.C (212 deg.F) or incinerate.

GFK-1503D

Chapter 4 Installation

4-11

4 Serial Port Connections


PORT 1

1 5
RS232 PORT 2

8
RS485

Providing Power to an External Device from Port 2


If either port is set up for communications with a serial device that requires 100mA or less at 5VDC, the device can obtain power from Port 2.

Cable Lengths and Baud Rates


Maximum cable lengths (the total number of feet from the CPU to the last device attached to the cable) are: Port 1 (RS-232) = 15 meters (50 ft.) Port 2 (RS-485) = 1200 meters (4000 ft.) Both ports support configurable baud rates, as listed in the CPU descriptions in this manual. The following pre-assembled cables are available:
IC200CBL001 IC200CBL002 CPU Programming Cable RS232 Expansion Firmware Upgrade Cable

4-12

VersaMax PLC Users Manual January 2006

GFK-1503D

4
Port 1: RS-232 Pin Assignments for Port 1
Port 1 is an RS-232 port with a 9-pin female D-sub connector. It is used as the boot loader port for upgrading the CPU firmware. The pinout of Port 1 allows a simple straight-through cable to connect with a standard AT-style RS-232 port. Cable shielding attaches to the shell.
Pin 1 2 3 4 5 6 7 8 9 Shell Signal n/c TXD RXD n/c GND n/c CTS RTS n/c SHLD -Cable Shield wire connection / 100% (Continuous) shielding cable shield connection Input Output Clear to Send input Request to Send output -0V/GND signal reference Output Input Transmit Data output Receive Data input Direction Function

RS-232 Point to Point Connection


In point-to-point configuration, two devices are connected to the same communication line. For RS-232, the maximum length is 15 meters (50ft).
PC 9-Pin Serial Port 9-pin female CPU Port 1 9-pin male

6 7 8 9

1 2 3 4 5

1 2 3 4 5

6 7 8 9

(2) RXD (3) TXD (5) GND (7) RTS (8) CTS

(2) TXD (3) RXD (5) GND (7) CTS (8) RTS

The shield must connect to shell of connectors on both ends of the cable.

GFK-1503D

Chapter 4 Installation

4-13

4
Connector and Cable Specifications for Port 1
Vendor Part numbers below are provided for reference only. Any part that meets the same specification can be used. Cable: Belden 9610 9 Pin Male Connector: Computer cable, overall braid over foil shield 5 conductor 30 Volt / 80C (176F) 24 AWG tinned copper, 7x32 stranding Vendor: Plug: Type: Pin: ITT/Cannon Crimp DEA9PK87F0 030-2487-017 AMP 205204-1 66506-9 Solder ITT/Cannon ZDE9P -AMP 747904-2 -Kit * ITT Cannon DE121073-54 [9-pin size backshell kit]: Metal-Plated Plastic (Plastic with Nickel over Copper) Cable Grounding Clamp (included) 40 cable exit design to maintain low-profile installation Plus ITT Cannon 250-8501-010 [Extended Jackscrew]: Threaded with #4-40 for secure attachment to CPU001 port Order Qty 2 for each cable shell ordered

Connector Shell:

Critical Information any other part selected should meet or exceed this requirement. Use of this kit maintains the 70mm installed depth.

4-14

VersaMax PLC Users Manual January 2006

GFK-1503D

4
Port 2: RS-485 Pin Assignments for Port 2
Port 2 is an RS-485 port with a 15-pin female D-sub connector. This can be attached directly to an RS-485 to RS-232 adapter.
Pin 1 2, 3, 4 5 6 7 8 9 10 11 12 13 14 15 Shell Signal SHLD n/c P5V RTSA GND CTSB RT RDA RDB SDA SDB RTSB CTSA SHLD Output Output -Input -Input Input Output Output Output Input -+5.1VDC to power external devices (100mA max.) Request to Send (A) output 0V/GND reference signal Clear to Send (B) input Resistor Termination (120 ohm) for RDA Receive Data (A) input Receive Data (B) input Transmit Data (A) output Transmit Data (B) output Request to Send (B) output Clear to Send (A) input Cable Shield wire connection / 100% (Continuous) shielding cable shield connection Direction -Function Cable Shield Drain wire connection

GFK-1503D

Chapter 4 Installation

4-15

4
Connector and Cable Specifications for Port 2
Vendor Part numbers below are provided for reference only. Any part that meets the same specification can be used.
Cable: Belden 8105 Low Capacitance Computer cable, overall braid over foil shield 5 Twisted-pairs Shield Drain Wire 30 Volt / 80C (176F) 24 AWG tinned copper, 7x32 stranding Velocity of Propagation = 78% Nominal Impedance = 100 Type: Vendor: Plug: Pin: Crimp ITT/Cannon DAA15PK87F0 030-2487-017 AMP 205206-1 66506-9 Solder ITT/Cannon ZDA15P -AMP 747908-2 -Kit* ITT Cannon DA121073-50 [15-pin size backshell kit]: Metal-Plated Plastic (Plastic with Nickel over Copper) Cable Grounding Clamp (included) 40 cable exit design to maintain low-profile installation Plus ITT Cannon 250-8501-009 [Extended Jackscrew]: Threaded with (metric) M3x0.5 for secure attachment Order Qty 2 for each cable shell ordered

15 Pin Male Connector:

Connector Shell:

Critical Information any other part selected should meet or exceed this requirement.

4-16

VersaMax PLC Users Manual January 2006

GFK-1503D

4
RS-485 Point to Point Connection with Handshaking
In point-to-point configuration, two devices are connected to the same communication line. For RS-485, the maximum cable length is 1200 meters (4000 feet). Modems can be used for longer distances.
Computer PIN RD ( A' ) RD ( B' ) SD ( A ) SD ( B ) CTS ( A' ) CTS ( B' ) RTS ( B ') RTS ( A ) GND SHLD Up to 15.2 meters (50 ft) without isolation

Shielded Twisted Pairs

PLC PIN 12 13 10 11 9 6 14 8 15 3 2 7 1 SD ( A ) SD ( B ) RD ( A' ) RD ( B ' ) RT RTS ( A ) RTS ( B ) CTS ( B' ) CTS ( A' ) GND SHLD

GFK-1503D

Chapter 4 Installation

4-17

4
RS-485 Multidrop Serial Connections
In the multidrop configuration, the host device is configured as the master and one or more PLCs are configured as slaves. The maximum distance between the master and any slave may not exceed 4000 feet (1200 meters). This figure assumes good quality cables and a moderately noisy environment. A maximum of 8 slaves can be connected using RS-485 in a daisy chain or multidrop configuration. The RS-485 line must include handshaking and use wire type as specified earlier.
Master Slave Station Last Station

When wiring RS-485 multidrop cables, reflections on the transmission line can be reduced by daisy-chaining the cable as shown below. Make connections inside the connector to be attached to the PLC. Avoid using terminal strips to other types of connectors along the length of the transmission line.
Computer RS-232 Port
9 Pin Male Connector 9-Pin Female to 25Pin Male RS-232 Shielded Cable
PIN RD TD RTS CTS DCD DTR GND 2 3 7 8 1 4 5 PIN 3 2 5 20 8 7 RD TD CTS DTR DCD GND

RS-232/RS-485 Converter IC690ACC900


PIN DCD(A) DCD(B) RD(A) RD(B) SD(A) SD(B) RT CTS(A) CTS(B) RTS(A) RTS(B) +5V 0V SHLD 25-PIN FEMALE RS-232 PORT 15-PIN FEMALE RS-485 PORT 2 3 10 11 12 13 9 15 8 6 14 5 7 1

RS-485 Cables Make connections inside D-connectors


PIN 2 3 12 13 10 11 9 6 14 15 8 5 7 1

CPU RS-485 Port


15 Pin Female Connector

(NC)

SHLD

SD(A) SD(B) RD(A) RD(B) RT RTS(A) RTS(B) CTS(A) CTS(B) +5V 0V SHLD

15- PIN MALE 5V 0V TO OTHER PLC's

Power Source for Converter. Must be wired no less than 3 meters (10 feet) from the converter.

Termination resistance for the Receive Data (RD) signal must be connected only on units at the ends of lines. This termination is made at the CPU by connecting a jumper between pin 9 and pin 10 inside the D-shell connector. Ground Potential: Multiple units not connected to the same power source must have common ground potential or ground isolation for proper operation of the system.
4-18 VersaMax PLC Users Manual January 2006 GFK-1503D

4 Ethernet Connection for CPUE05


The Ethernet port on PLC module IC200CPUE05 connects directly to a 10BaseT (twisted pair) network without an external transceiver. Connect the port to an external 10BaseT hub or switch or a hub or repeater with autosense of 10/100 using a twisted pair cable. Cables are readily available from commercial distributors. GE Fanuc recommends purchasing rather than making cables. Your 10BaseT twisted pair cables must meet the applicable IEEE 802 standards.

Network Connection
Connection of the CPUE05 to a 10BaseT network is shown below:
CPUE05 10BaseT Hub

10BaseT

Twisted Pair Cable

To Other Network Devices

The cable between each node and a hub or repeater can be up to 100 meters in length. Typical hubs or repeaters support 4 to 12 nodes connected in a star wiring topology.
Host Computer or Control Device Running a Host Communications Toolkit Application VersaMax PLC with CPUE05 VersaMax PLC with CPUE05

Series 90-70 PLC with Ethernet Interface Series 90-30 PLC with Ethernet Interface

Programmer Software running on a PC

Ethernet Cable Hub

GFK-1503D

Chapter 4 Installation

4-19

4 CE Mark Installation Requirements


The following requirements for surge, electrostatic discharge (ESD), and fast transient burst (FTB) protection must be met for applications that require CE Mark listing:

The VersaMax PLC is considered to be open equipment and should therefore be installed in an enclosure (IP54). This equipment is intended for use in typical industrial environments that utilize anti-static materials such as concrete or wood flooring. If the equipment is used in an environment that contains static material, such as carpets, personnel should discharge themselves by touching a safely grounded surface before accessing the equipment. If the AC mains are used to provide power for I/O, these lines should be suppressed prior to distribution to the I/O so that immunity levels for the I/O are not exceeded. Suppression for the AC I/O power can be made using line-rated MOVs that are connected line-to-line, as well as line-to-ground. A good high-frequency ground connection must be made to the line-to-ground MOVs. AC or DC power sources less than 50V are assumed to be derived locally from the AC mains. The length of the wires between these power sources and the PLC should be less than a maximum of approximately 10 meters. Installation must be indoors with primary facility surge protection on the incoming AC power lines. In the presence of noise, serial communications could be interrupted.

4-20

VersaMax PLC Users Manual January 2006

GFK-1503D

Chapter

Configuration

This chapter describes the process by which a VersaMax CPU and the modules it serves are configured. Configuration determines certain characteristics of module operation and also establishes the program references that will used by each module in the system.

Autoconfiguration or programmer configuration Configuring racks and slots Configuring CPU parameters Configuring CPU memory allocation Configuring serial port parameters Storing a configuration from a programmer Autoconfiguration

GFK-1503D

5-1

5 Using Autoconfiguration or Programmer Configuration


VersaMax PLCs can be either autoconfigured or configured from a programmer using configuration software. Both types of configuration are described in this chapter.

Autoconfiguration
Autoconfiguration occurs at powerup, when the PLC CPU automatically reads the configuration of the modules installed in the system and creates the overall system configuration. Modules that have software-configurable features can only use their default settings when autoconfigured.

Software Configuration
Most PLC systems use a customized configuration that is created using configuration software and stored to the CPU from a programmer. The CPU retains a software configuration across power cycles. After a software configuration is stored to the CPU, the CPU will not autoconfigure when power-cycled. The configuration software can be used to:

Create a new configuration Store (write) a configuration to the CPU Load (read) an existing configuration from a CPU Compare the configuration in a CPU with a configuration file stored in the programmer Clear a configuration that was previously stored to the CPU

The CPU stores a software configuration in its non-volatile RAM. Storing a configuration disables autoconfiguration, so the PLC will not overwrite the configuration during subsequent startups. However, actually clearing a configuration from the programmer does cause a new autoconfiguration to be generated. In that case, autoconfiguration is enabled until a configuration is stored from the programmer again. One of the parameters that can be controlled by the software configuration is whether the CPU reads the configuration and program from Flash at powerup, or from RAM. If Flash is the configured choice, the CPU will read a previously-stored configuration from its Flash memory at powerup. If RAM is the choice, the CPU will read a configuration and application program from its RAM memory at powerup.
5-2 VersaMax PLC Users Manual January 2006 GFK-1503D

5 Configuring Racks and Slots


Even though a VersaMax PLC does not have a module rack, both autoconfiguration and software configuration use the traditional convention of racks and slots to identify module locations in the system. Each logical rack consists of the CPU or an Expansion Receiver module plus up to 8 additional I/O and option modules mounted on the same DIN rail. Each I/O or option module occupies a slot. The module next to the CPU or Expansion Receiver module is in slot 1. Booster power supplies do not count as occupying slots.
Main Rack (rack 0) Booster Power Supply

CPU

The main rack is rack 0. Additional racks are numbered 1 to 7.

GFK-1503D

Chapter 5 Configuration

5-3

5
In a system that uses just one expansion rack which is attached to the expansion bus by a non-isolated Expansion Receiver Module (IC200ERM002), the expansion rack must be configured as rack 1.
VersaMax PLC Station Main Rack
PS

1M

CPU/NIU

VersaMax Expansion Rack PS

ERM

5-4

VersaMax PLC Users Manual January 2006

GFK-1503D

5
In a system with an Expansion Transmitter Module (IC200BTM001) and up to seven expansion racks, each with an Isolated Expansion Receiver Module (IC200ERM001 or IC200ERM002), the additional racks are configured as rack 1 through rack 7.
VersaMax PLC Main Rack (0) ETM PS

CPU/NIU VersaMax ExpansionRack 1 15M with any IC200ERM002 ERMs 750M with all IC200ERM001 ERMs PS

ERM VersaMax ExpansionRack 7 PS

Terminator Plug

ERM

GFK-1503D

Chapter 5 Configuration

5-5

5 Software Configuration
The configuration software makes it possible to create a customized configuration for the VersaMax PLC system. For CPUE05, it is also used to configure Ethernet Global Data. When you enter Hardware Configuration for VersaMax equipment folders, the default view is the Rack (Main). A new configuration already includes a default power supply (PWR001) and CPU (CPU001). Both can easily be changed to match the actual hardware in the PLC system. To configure the PLC, you will:

Configure the rack type (non-expanded, single-ended expanded, or multi-rack expanded). Configure the power supply type and any booster power supplies and carriers. (Note that CPU005 and CPUE05 both require an expanded 3.3V supply.) Configure the CPU. This includes changing the CPU type if necessary, and assigning its parameters as described in this chapter. Configure the parameters of the CPU serial ports, as explained in this chapter. For CPUE05, configure its Ethernet parameters, as explained in chapter 6. Configure the expansion modules if the system has expansion racks. Add module carriers and define wiring assignments. Place modules on carriers and select their parameters. Configurable parameters of I/O modules are described in the VersaMax Modules, Power Supplies, and Carriers Users Manual (GFK-1504). Save the configuration file so that it can be stored to the PLC.

Step-by-step instructions for using the configuration software are provided in the VersaPro Software Users Manual (GFK-1670). Additional information is available in the online help.

5-6

VersaMax PLC Users Manual January 2006

GFK-1503D

5
Configuring CPU and Expansion Parameters
The table below lists configurable parameters for VersaMax PLC CPUs, and for expansion racks. Parameter Description Default
Normal

Choices
Normal, Constant Sweep 5200mS

Scan Parameters Sweep Mode Normal: sweep runs until it is complete. Constant: sweep runs for time specified in Sweep Tmr.

Sweep Times If Constant Sweep mode was selected, a Constant Sweep 100mS (mSecs) Time (in milliseconds) can be specified. Settings Parameters I/O Scan-Stop Determines whether I/O is to be scanned while the PLC is No in STOP mode. Powerup Mode Selects powerup mode. Last Logic/Configura tion From Registers Passwords Checksum Words per Sweep Default Modem Turnaround Time Default Idle Time Source of program and configuration when the PLC is powered up. Selects source of register data when PLC is powered up. Determines whether the password feature is enabled or disabled. (If passwords are disabled, the only way to enable them is to clear the PLC memory.) The number words in the application program to be checksummed each sweep RAM RAM Enabled 8

Yes, No Last, Stop, Run RAM, Flash RAM, Flash Enabled, Disabled 8 to 32 0255mS 160

SFC Timer Faults SNP ID Switch Run/Stop Switch Memory Protect Diagnostics Fatal Fault Override EZ Program Store
GFK-1503D

Modem turnaround time (10ms/unit) This is the time 0mS required for the modem to start data transmission after receiving the transmit request. Time (in seconds) the CPU waits to receive the next 10 message from the programming device before it assumes that the programming device has failed and proceeds to its base state. Communication with the programmer is terminated and will have to be reestablished. Enables or disables viewing of SFC Timer faults. Disabled None Enabled Disabled Enabled Disabled

Determines whether the switch will control Run/Stop mode operation Determines whether the switch will control RAM memory protection. Unless your application requires unusually fast power up, leave this setting ENABLED. The DISABLED setting causes the PLC to power up without running diagnostics. Determines whether fatal faults will normally be overridden. Specifies where data that is read from the EZ Program Store device will be loaded.

Enabled/Dis abled Editable Enabled, Disabled Enabled, Disabled Enabled, Disabled

Enabled, Disabled RAM only RAM only, RAM & Flash


5-7

Chapter 5 Configuration

5
Configuring CPU Memory Allocation
CPU001 and CPU002 (release 2.0 or later), CPU005 and CPUE05 have configurable user memory. The configurable memory is equal to the sum of the application program, hardware configuration, registers (%R), analog inputs (%AI), and analog outputs (%AQ). The amount of memory allocated to the application program and hardware configuration are automatically determined by the actual program and configuration entered from the programmer. The rest of the configurable memory can easily be configured to suit the application. For example, an application may have a relatively large program that uses only a small amount of registers and analog memory. Similarly, there might be a small logic program but a larger amount of memory needed for registers and analog inputs and outputs.

Configurable Memory for CPU Module IC200CPU001, CPU002, CPU005


Configurable memory CPU001: 34K bytes maximum CPU002: 42K bytes maximum CPU005: 128K bytes maximum 128 bytes minimum 12K bytes 20K bytes 400 bytes minimum 256 bytes (128 words) minimum 4,096 bytes (2048 words) 256 bytes (128 words) minimum 256 bytes (128 words) minimum

Application program size (not configurable) CPU001, for rel. 1.50 compatibility CPU002, for rel. 1.50 compatibility Hardware configuration size (not configurable) Registers (%R) CPU001/002, for rel. 1.50 compatibility Analog Inputs (%AI) Analog Outputs (%AQ)

Configurable Memory for CPU Module IC200CPUE05


Configurable memory Application program size (not configurable) Hardware configuration size (not configurable) Registers (%R) Analog Inputs (%AI) Analog Outputs (%AQ) 128K bytes maximum 128 bytes minimum 528 bytes minimum 256 bytes (128 words) minimum 256 bytes (128 words) minimum 256 bytes (128 words) minimum

If you reconfigure memory allocation from the default sizes, storing a hardware configuration to the PLC in the future will clear memory contents. If you want to retain memory contents, first load memory contents from the PLC to the programmer. Then, re-store memory when you store the hardware configuration from the programmer to the PLC.

5-8

VersaMax PLC Users Manual January 2006

GFK-1503D

5
Configuring Serial Port Parameters
Both ports on a VersaMax PLC CPU are configurable for SNP slave or RTU slave operation. 4-wire and 2-wire RTU are supported. For CPUE05 only, port 1 can also be configured (on another tab) for Local Station Manager operation. The Local Station Manager parameters may differ from the Port A parameters. Feature Description Default Choices
Port Mode Parity Data Rate (bps) Defines the protocol. Determines whether parity is added to words SNP SNP, Serial I/O, RTU, Disabled. CPUE05 can also be configured as a Local Station Manager. Odd, Even, None

Flow Control (not required if Port Mode is SNP) Timeout (If Port Mode is SNP) Stop Bits (If Port Mode is SNP or Serial I/O) SNP ID Receive to transmit delay Turnaround delay RTS drop delay

Odd. For CPUE05, when Port Mode is Local Station Manager, default is None. Data transmission rate (in Serial comms modes: 19200 SNP: 4800, 9600, 19200, 38400 bits per second). RTU: 1200, 2400, 4800, 9600, 19200, 38400, 57600 Serial I/O: 4800, 9600, 19200, 38400, 57600 CPUE05 in Local Station Local Station Manager mode: 1200, 2400, 4800, 9600, 19200, Manager mode: 9600 38400, 57600, 115200 RTU mode: None, Hardware Specifies the method of flow None control to use. Serial I/O mode: None, Hardware, When changing Flow Software Control from None to CPUE05 in Local Station Hardware, Turnaround Manager mode: None, Hardware Delay is reset to 0. Long, Medium, Short, None Specifies the set of timeout Long values to be used by Protocol. Number of stop bits used in 1 1, 2 transmission. (Most serial devices use one stop bit; slower devices use two.) 8-byte ID for Port 1. None Editable Delay between receiving 0 SNP: Not available last character of a message RTU and Serial IO: 0-255 (units to asserting RTS of 10ms, e.g. 10=100ms) SNP: none SNP: Long, Medium, Short, none Delay between asserting RTS and transmitting a RTU & Serial IO: 0 RTU & Serial IO: 0-255 (units of message 10ms, e.g. 10=100ms) 0 SNP: Not Available Delay between when the last character of a message RTU and Serial IO: 0-255 (units is transmitted and when of 10ms, e.g. 10=100ms) RTS is dropped.

The VersaPro software allows configuration of RTU and Serial I/O at 115.2K baud. However, these baud rates are not supported by the CPU. If a configuration using these baud rates is stored to the PLC: 1. For RTU, an Unsupported Feature in Configuration fault is logged and the PLC transitions to Stop Faulted mode.

GFK-1503D

Chapter 5 Configuration

5-9

5
2. For Serial I/O, the same fault is logged when the transition to Run mode occurs. The PLC will immediately transition to Stop Faulted mode.

RTU and Serial IO Delays


The receive to transmit, turnaround, and RTS drop delay parameters can be configured to customize communications timing for radio modems. receive to transmit delay: The minimum length of time between the CPU receiving the last character of an incoming message and the CPU asserting RTS. Asserting RTS is followed by the transmission of the response message. This delay is configured as a minimum time because the actual delay is dependent upon the CPU sweep time. turnaround delay: The length of time between the CPU asserting RTS and the CPU beginning to transmit a message. RTS drop delay: The length of time between the CPU transmitting the last character of a response message and the CPU dropping RTS. The RTS drop delay can vary by 1 ms.
Rx

RTS (CPU) TD1 CTS (Master) TD3

Tx (CPU transmit) TD2

Tx

TD1 is the Receive to Transmit delay TD2 is the Turnaround Delay TD3 is the RTS Drop Delay

Configuration Required to use Winloader


The Winloader utility, which can be used for firmware updates, requires SNP configuration. If Port 1 is configured for another mode or forced to Local Station Manager operation, Winloader will not be able to do a firmware update on port 1.

Note for RTU Communications


When using RTU communications, it may be necessary to increase the RTU timeout configured on the master device as the PLC slave scan time increases. It is not necessary to change the configuration of the VersaMax CPU itself, however.
5-10 VersaMax PLC Users Manual January 2006 GFK-1503D

5
Storing a Configuration from a Programmer
Ordinarily, a VersaMax PLC system is configured by creating a configuration file on the programmer (computer), then transferring the file from the programmer to the PLC CPU via the CPU port. The CPU stores the configuration file in its non-volatile RAM memory. The configuration is stored whether I/O scanning is enabled or not. After the configuration is stored, I/O scanning is enabled or disabled according to the newly-stored configuration parameters.

Autoconfiguration and Storing a Configuration


Clearing a configuration from the programmer causes a new autoconfiguration to be generated. Autoconfiguration remains enabled until the configuration is stored from the programmer again. Storing a configuration disables autoconfiguration.

Storing a Configuration with Non-default Memory Allocation


If you reconfigure reference tables from the default sizes, storing a hardware configuration to the PLC in the future will clear memory contents. If you want to retain memory contents, first load reference memory contents from the PLC to the programmer. Then, re-store reference memory when you store the hardware configuration from the programmer to the PLC.

Default Serial Port Parameters


When a programmer is first connected, the PLC communicates using the default communications parameters: 19,200 baud, odd parity, one start bit, one stop bit, and eight data bits. If these parameters are re-configured, the new settings will be used at powerup instead.

Serial Port Configuration Takes Effect After Removing Programmer


If a hardware configuration is stored to the CPU, the configuration for the serial port to which the programmer is connected is not actually installed until the programmer is removed. After removal of the programmer, there is a delay before the new protocol begins operating. This delay is equal to the configured T3 time.

GFK-1503D

Chapter 5 Configuration

5-11

5 Autoconfiguration
When autoconfiguration is enabled and no previous autoconfiguration exists, at powerup the CPU automatically reads the configuration of the modules installed in the system and creates an overall system configuration. If a previous autoconfiguration is present at powerup, the configuration is processed as described on the next page. Modules that have software-configurable features use their default settings when autoconfigured. These features are described in the VersaMax Modules, Power Supplies, and Carriers Manual (GFK-1504). At powerup, the CPU by default automatically generates a configuration that includes all of the modules that are physically present in the system, starting at slot 1 of rack 0 (the main rack). Autoconfiguration of a rack stops at the first empty slot or faulted module and continues with the next rack. For example, if there are modules physically present in slots 1, 2, 3, 5, and 6, the modules in slots 5 and 6 are not autoconfigured. To autoconfigure a system with expansion racks, either all racks must be powered from the same source or the expansion racks must be powered up before the main rack.

Autoconfiguration Assigns Reference Addresses


Modules are automatically assigned reference addresses in ascending order. For example, if the system contains a 16 point input module, an 8point input module, a 16-point output module, and another 16-point input module, in that order, the input modules are assigned reference addresses of %I0001, %I0017, and %I0025, respectively. For modules that utilize multiple data types (for example, mixed I/O modules), each data type is assigned reference addresses individually.

5-12

VersaMax PLC Users Manual January 2006

GFK-1503D

5
Autoconfiguration Diagnostics
Module Present But Non-Working During Autoconfiguration: If a module is physically present but not working during autoconfiguration, the module is not configured and the CPU generates an extra module diagnostic. Empty Slot During Autoconfiguration: Autoconfiguration of a rack stops at the first empty slot. Modules located after the empty slot are not autoconfigured. The CPU generates an extra module diagnostic for each of them. Previously-Configured Modules Present During Autoconfiguration: Previouslyconfigured modules are not removed from the configuration during autoconfiguration unless no modules are present in the system. For example, if modules are configured in slots 1, 2, and 3 then power is removed and the module in slot 1 is removed, when power is reapplied the modules in slots 2 and 3 are autoconfigured normally. The original module in slot 1 is not removed from the configuration. The CPU generates a loss of module diagnostic for slot 1. Different Module Present During Autoconfiguration: If a slot was previouslyconfigured for one module type but has a different module installed during autoconfiguration, the CPU generates a configuration mismatch diagnostic. The slot remains configured for the original module type. Unconfigured Module Installed After Autoconfiguration: If a module that was not previously-configured is installed-after powerup, the CPU generates an extra module diagnostic and the module is not added to the configuration. Previously-configured Module Installed After Autoconfiguration : If a module that was previously-configured but missing at powerup is installed-after powerup, the CPU generates an addition of module diagnostic and the module is added back into the I/O scan. All Modules Removed After Autoconfiguration: If all modules are absent at powerup, the CPU clears the configuration. This allows modules to be inserted and added to the configuration at the next powerup.

GFK-1503D

Chapter 5 Configuration

5-13

5
Diagnostic Message Summary
addition of module addition of module configuration mismatch extra module A module is present at powerup but not configured. It is added to the configuration. Autoconfiguration is enabled and the module is capable of being autoconfigured. A previously-configured module is inserted after powerup. The CPU resumes scanning of the module. A module was found at or after powerup that does not match the configuration for that slot. 1. 2. 3. 1. 2. A module is present at powerup but not configured. Autoconfiguration is not enabled. A previously-unconfigured module is inserted after powerup. An Expansion Receiver Module that was not previously configured is present during configuration. During normal operation, communication is restored with a previously missing or failed Expansion Receiver Module. The CPU starts scanning I/O for the modules in that rack. Addition of Module faults are not generated when scanning resumes. However, if communications cannot be restored with any modules in the rack, Loss of Module faults are generated. A previously configured Expansion Receiver Module is not present during configuration. During normal operation, a previously working Expansion Receiver Module stops working. Modules in the same expansion rack are terminated.

loss of module addition of rack

A configured module is missing during powerup or normal operation.

loss of rack

1. 2.

extra rack Expansion Transmitter mismatch expansion bus speed change unsupported feature

A previously-unconfigured Expansion Receiver module is inserted after powerup. Modules in the expansion rack are ignored. 1. 2. An Expansion Transmitter Module (IC200ETM001) is present but not configured. An Expansion Transmitter Module (IC200ETM001) is configured but not present.

The expansion bus speed automatically calculated by the CPU during autoconfiguration has changed. A module is present that is not supported by the CPU.

5-14

VersaMax PLC Users Manual January 2006

GFK-1503D

Chapter

Ethernet Configuration

This chapter describes the configuration needed for the Ethernet interface of VersaMax CPU module IC200CPUE05:

Ethernet configuration overview Configuring the characteristics of the Ethernet interface Configuring Ethernet Global Data Configuring Advanced User Parameters

The Ethernet interface configuration described in this chapter must be set up in addition to the basic CPU configuration described in chapter 5.

GFK-1503D

6-1

6 Ethernet Configuration Overview


The Ethernet configuration for CPU module IC200CPUE05 includes:

Configuring the characteristics of the Ethernet interface. This is part of the CPU configuration. Configuring Ethernet Global Data. This is reached via the rack operations configuration. (Optional, not required for most systems). Configuring advanced parameters. This requires creating a separate ASCII parameter file that is stored to the PLC with the hardware configuration. (Optional, not required for most systems). Setting up Port 1 for Local Station Manager operation. This is part of the basic CPU configuration as described in chapter 5. Note that Local Station Manager parameters are configured independently of the Port 1 parameters.

After the configuration is completed and stored to the PLC, it is maintained in memory by the PLC CPU. The configuration may be saved into and retrieved from Flash memory, which provides nearly permanent backup of the configuration data across loss of power and battery backup. Every time CPUE05 is powered up or has its configuration changed or cleared, it delivers the Ethernet configuration data back to the Ethernet interface. The Ethernet interface portion of CPUE05 saves its configuration data in battery-backed memory. If the CPU battery backup is lost and the configuration has not been saved to Flash, the Ethernet interface loses its backup configuration data. If that happens, after powerup the Ethernet interface operates with its factory default settings until it is reconfigured. This default operation includes reverting to an IP address of 0.0.0.0. Because the backup Ethernet configuration data is actually stored by the Ethernet interface portion of CPUE05, it is not affected by a PLC Clear Configuration operation. When the PLC Configuration is cleared, the CPU operates in Autoconfiguration mode, as described below.

Autoconfiguration
If the PLC CPU has not had a configuration stored from the programmer, it automatically creates its own configuration at powerup. To create the Autoconfiguration, the CPU reads configuration data from each module and from the Ethernet interface. This includes an Advanced User Parameter file for the Ethernet interface. When an Autoconfiguration is present in the PLC CPU, it is possible to edit some of the Ethernet configuration parameters from the Station Manager. This changes the parameters that are stored in the Ethernet interface itself. If the PLC is power-cycled or cleared, the edited configuration will be retrieved by the CPU from the Ethernet interface.

6-2

VersaMax PLC Users Manual January 2006

GFK-1503D

6 Configuring the Ethernet Interface


The CPUs fundamental Ethernet operating characteristics must be correctly configured for proper operation over an Ethernet network. The default configuration cannot supply valid network address data. Parameters
Configuration Mode IP Address, Subnet Mask, and Gateway IP Address

Description
This is fixed as TCP/IP. It cannot be changed. The IP Address is the unique address of the Ethernet interface as a node on the network. On a large network, a subnet mask can be used to identify a section of the overall network. A gateway address can be used to identify a gateway that joins one network with another. These parameters must be correct or the Ethernet interface may be unable to communicate on the network and/or network operation may be disrupted. It is especially important that each node on the network is assigned a unique IP address. These values should be assigned by the person in charge of your network (the network administrator). TCP/IP network administrators are familiar with these parameters. If you have no network administrator and are using a simple isolated network with no gateways, you can use the following values as local IP addresses: 10.0.0.2 First PLC 10.0.0.3 Second PLC 10.0.0.4 Third PLC . . 10.0.0.254 PLC Programmer or host Also, in this case, set the subnet mask and Gateway IP address to 0.0.0.0. See chapter 13 for more detailed information about IP Addressing and gateways. Note: If this simple, isolated network is ever connected to another network, the IP addresses 10.0.0.2 through 10.0.0.254 must not be used and the subnet mask and Gateway IP address must be assigned by the network administrator. The IP addresses must be assigned so that they are compatible with the connected network. The beginning reference for 10 bytes of Ethernet status data. The content of this data is described in chapter 13, Checking the Status of the Ethernet Interface. The Status address can be assigned to %I, %Q, %R, %AI or %AQ memory. The default value is the next available %I address. Note: Do not use the 10 bytes assigned to the Status bits for other purposes or your data will be overwritten. This value is automatically set to either 80 bits (for %I and %Q Status address locations) or 5 words (for %R, %AI, and %AQ Status address locations). IP addresses of up to 3 NTP time servers used to synchronize timestamps in produced Ethernet Global Data exchanges. If no NTP time servers are configured here, the Ethernet interface is initialized from the clock in the CPU instead. See Timestamping of Ethernet Global Data Exchanges in chapter 13 for more information.

Status Address

Status Length Network Time Servers

GFK-1503D

Chapter 6 Ethernet Configuration

6-3

6 Configuring Ethernet Global Data


VersaMax CPU IC200CPUE05 can be configured for up to 32 Ethernet Global Data exchanges (any combination of produced and consumed). (See Ethernet Global Data in chapter 13 for a discussion of this feature). Configuration defines both the content of an exchange, its data ranges, and its operational characteristics. Each Ethernet Global Data produced or consumed exchange must be configured individually for each PLC. You can configure:

Up to 1200 data ranges for all Ethernet Global Data exchanges. Up to 100 data ranges per exchange. A data length of 1 byte to 1400 bytes per exchange. The total size of an exchange is the sum of the lengths of all of the data ranges configured for that exchange.

Different exchanges may have different data ranges. Multiple exchanges can also share some or all of the same data ranges even if the exchanges are produced at different rates. (Note: The programming software will not permit consumed exchanges to share data ranges). The Ethernet Global Data configuration screens are reached via the rack configuration (not the CPU configuration).

Before You Configure EGD Exchanges


Before configuring Ethernet Global Data exchanges, you will need to collect information about the PLCs that will be exchanging the data. Note that this information will be needed for each PLCs configuration. See chapter 13 for details.


6-4

Determine for each PLC what data needs to be produced and consumed. Make a list of the IP addresses of the Ethernet Interfaces in the PLCs that are being used to produce or consume the exchanges. Identify the members of up to 32 groups of devices that will share Ethernet Global Data exchanges. Decide on appropriate repetition rates and timeout periods for the exchanges. Identify the content of each exchange in the producer, and identify appropriate data ranges in the consumers to receive the data. It is not necessary to consume all of the data from a produced exchange in each consumer. A consumed exchange may be configured to ignore specified data ranges.
VersaMax PLC Users Manual January 2006 GFK-1503D

6 Configuring a Global Data Exchange for a Producer


Each Global Data exchange must be configured in the producer as defined below. The exchange must also be configured in each consumer, as explained next. Parameters
Local Producer ID Exchange ID Adapter Name Consumer Type Consumer Address Send Type Producer Period

Description
The address that uniquely identifies the CPUE05 as an Ethernet Global Data device across the network. It is a dotted-decimal number. The default is the same as the IP address of the CPUE05. The default can be changed. A number that identifies a specific data exchange. Always 0.0 for CPUE05. Select whether the datas destination will be a single device (IP address) or one of 32 predefined device groups (Group ID). See Ethernet Global Data Groups in chapter 13 for more information. If the Consumer Type above is IP Address, this is the IP address of a single device to receive the exchange. If the Consumer Type is Group ID, this is the groups ID number (132). See chapter 13 for more information about IP Addresses. Currently fixed at always. Ethernet Global Data will always be sent when the PLCs I/O scan is enabled. It will not be sent when the I/O scan is disabled. The scheduled repetition period for sending the data on the network. The range is 10 3,600,000 milliseconds (10 milliseconds to 1 hour). The default is 200 milliseconds. Round this value to the nearest 10 milliseconds before you enter it. The producer period has a resolution of 10 milliseconds. If you enter a value such as 12 milliseconds, the actual producer period will be rounded up to 20 milliseconds. For easier troubleshooting and efficient network usage, set the Producer Period to the same value as the Consumer Period. Do not produce data faster than is required by your application. For example, it is usually not useful to produce data faster than the scan time of the producer or consumer PLCs. This reduces the load on the network and on the devices, providing capacity for other transfers. Currently not used.

Reply Rate Status Word

A data range that identifies the memory location where the status value for the produced exchange will be placed. See Checking the Status of an Exchange in chapter 13 for details. Note that the Status Word address must be unique; it is not automatically assigned the next highest address. Reference Low Point High Point Description example: Offset Status: Where the PLC will Status %R 99 99 place the status data. A list of 1 to100 data ranges that will be sent in the exchange. Data is sent as a contiguous set of bytes. See Checking the Status of an Exchange in chapter 13 for details. The total size can be up to 1400 bytes. The list of data ranges to be sent in an exchange specifies: Offset Reference Low Point High Point Description example: 0.0 %R 100 105 Conveyor1 in PLC1 10.0 %I 345 352 Conveyor1 limit switch in PLC1
6-5

Exchange Data Ranges

GFK-1503D

Chapter 6 Ethernet Configuration

6 Configuring a Global Data Exchange for a Consumer


To receive a Global Data Exchange, configure the following information: Parameters
Local Producer ID Exchange ID Adapter Name Producer ID Group ID

Description
The address that uniquely identifies the CPUE05 as an Ethernet Global Data device across the network. The default is the same as the IP address of the CPUE05. The default can be changed. A number that identifies that specific data exchange. It must match the Exchange ID specified in the produced exchange (in the sending device). Always 0.0 for CPUE05 The Local Producer ID of the device sending the exchange. Used only if the same data is consumed by more than one consuming device. Enter the same Group ID that has been configured as the Consumer Address in the producer device. Not used. Default is 200mS. The maximum time the Ethernet interface allows between seeing samples on the network without reporting a refresh error status. This error status means a first or subsequent packet of data has not arrived within the specified time. The range is 0, or 103,600,000 milliseconds. The value should be at least double the producers producer period value. The default is 0, which disables timeout detection. The update timeout period should be greater than the exchange production period. (A value at least twice the production period is recommended.) Round this value to the nearest 10 milliseconds before you enter it. The update timeout has a resolution of 10 milliseconds. If you enter a value such as 22 milliseconds, the actual update timeout will be rounded up to 30 milliseconds.

Consumer Period Update Timeout

Status Word

A data range that identifies the memory location where the status value for the consumed exchange will be placed. See chapter 13 for details of the status value. Note that the Status Word address must be unique; it is not automatically assigned the next highest address. Reference %R Low Point High Point 99 99 Description Status: Where the PLC will place the status data.

example: Offset Status

6-6

VersaMax PLC Users Manual January 2006

GFK-1503D

6
Defining a Global Data Exchange for a Consumer (continued)
Parameters
Time Stamp

Description
A data range that identifies the memory location where the timestamp of the last data packet will be placed. The timestamp is not an actual date; it is an 8-byte value representing the time elapsed since midnight, January 1, 1970. The first four bytes contain a signed integer representing seconds and the next four bytes contain a signed integer representing nanoseconds. This value represents the time in the producer when the data sample originated. It can be examined to determine if a new packet received from the network has a new data sample or if it is the same data received previously. The timestamp information produced by the PLC currently has a resolution of 100 microseconds if no network synchronization is used. If NTP is used to perform network time synchronization, the timestamp information has a resolution of 1 millisecond and has 10 millisecond accuracy between PLCs on the same LAN. NTP may be enabled in the configuration of the CPUE05. Once NTP time synchronization is configured, the CPUE05 will synchronize itself to an external NTP time server if one exists.

Reference example: Offset Time Stamp %R

Low Point High Point 91 94

Description Time Stamp: Optional place for the PLC to put the timestamp.

Exchange Data Ranges

A list of 1 to100 data ranges that will be received in the exchange. Data is received as a contiguous set of bytes. The total size of all combined elements can be up to 1400 bytes. For consumed exchanges, %S memory types and override references are not allowed. See Table 4-2 for valid memory types. Note: If the consumed exchange length does not match that of the produced exchange, PLC Faults and Ethernet exception entries occur. The list of data ranges to be received in an exchange specifies:

example: Offset 0.0 10.0

Reference %R %I

Low Point 100 257

High Point 104 264

Description Conveyor1 in PLC1 Conveyor1 limit switch in PLC1

GFK-1503D

Chapter 6 Ethernet Configuration

6-7

6
Selective Consumption
Not all data ranges within a produced exchange need to be consumed by each PLC. For example, a producer is producing an exchange consisting of a 4-byte floating point value, followed by a 2-byte integer, followed by a 2byte analog value. If the consuming PLC wants to consume only the analog value and place it into %AI003, the consumer might be configured as shown below.
Offset 0 6 Reference Ignore (bytes) %AI Low Point 1 3 High Point 6 3 Description Ignore float and integer

Note that the total length of the exchange must be the same in producer and consumer, even if the consumer is ignoring bytes at the end of the message. Failure to configure any ignored bytes in the consumed exchange will result in exchange exception log and fault table entries, error status in the exchange status data, and no data being transferred for the exchange.

6-8

VersaMax PLC Users Manual January 2006

GFK-1503D

6 Configuring Advanced User Parameters


Advanced User Parameters are internal operating parameters used by the Ethernet interface. For most applications, the default Advanced User Parameters should not be changed. If it is necessary to modify any of these parameters, it must be done by creating an Advanced User Parameter file, using any ASCII text editor. This file must contain the names and values of only those parameters that are being changed. The file must be named AUP_0_0.apf. The completed file must be placed into the PLC folder that contains the PLC configuration. When the entire hardware configuration is stored from the programmer to the PLC, the programmer software also stores the parameters from the AUP_0_0.apf file.

Format of the Advanced User Parameters File


The Advanced User Parameters file must have this format:
AUP_0_0 <parameter name> = <parameter value> <parameter name> = <parameter value> <parameter name> = <parameter value>

All parameter names are lowercase. The equal sign ( = ) is required between the parameter name and parameter value. Parameter values are converted to lowercase unless they are enclosed in a pair of double quotes. The format for the individual parameter values depends on the parameter. Numeric parameters are entered in decimal or hexadecimal format; hexadecimal values must end with an h or H character. IP address parameters must be entered in standard dotted decimal format. Character string values are case-sensitive. Uppercase parameter values must be enclosed within a pair of double quotes. (The enclosing quotes are not part of the data and are removed during processing). Comments in the file must start with a semicolon character. All characters in the same line following a semicolon are ignored. Blank lines are also ignored. The following example sets the station manager password to system and the IP time-to-live for point-to-point Ethernet Global Data exchanges to 4.

Example Advanced User Parameter File


AUP_0_0 stpasswd = system gucast_ttl=4
GFK-1503D

; ;

set the password to system set the EGD unicast IP TTL to 4


6-9

Chapter 6 Ethernet Configuration

6
Advanced User Parameter Definitions
The following Advanced User Parameters can be configured for the CPUE05 Ethernet interface.
Name staudp stpasswd crsp_tout fflush gctl_port gdata_port gbcast_ttl gucast_ttl gXX_udp gXX_ttl gXX_addr ittl ifrag_tmr wnodelay wkal_idle wkal_cnt wkal_intvl wmsl wsnd_buf wrcv_buf nmin_poll1 nmax_poll1 nmin_poll2 nmax_poll2 nmin_poll3 nmax_poll3 nsync_tout Description Remote Station Manager UDP port Station Manager password Transfer/Response timeout value (in seconds) ARP cache timeout interval (in seconds) UDP port for Ethernet Global Data control messages UDP port for point-to-point Ethernet Global Data messages IP time-to-live for global broadcast messages (hop count) IP time-to-live for point-to-point messages (hop count) UDP port for host group XX IP time-to-live for host group (multicast) messages (hop count) IP group address for host group XX (must be class D address) IP header default time-to-live (hop count) IP fragment timeout interval (in seconds) TCP nodelay option (0=inactive, 1=active) TCP keepalive timer value (in seconds) TCP keepalive probe count TCP keepalive probe interval (in seconds) TCP maximum segment lifetime (in seconds) TCP send buffer size in bytes TCP receive buffer size in bytes NTP min. poll interval for host 1. The value specifies log(2) of the interval in seconds (eg: the value 3 means 8 secs, 4 means 16 sec, etc) NTP maximum poll interval for host 1 (in log(2) of seconds) NTP min. poll interval for host 2 (in log(2) of seconds) NTP max. poll interval for host 2 (in log(2) of seconds) NTP min. poll interval for host 3 (in log(2) of seconds) NTP max. poll interval for host 3 (in log(2) of seconds) NTP synchronization timeout period (in seconds). The max. time between network time updates to remain synchronized). Default 18245 (4745H) system 16 (0010H) 0 604800 (93a80H) 7937 (1f01H) 18246 (4746H) 1 (1H) 16 (10H) 18246 (4746H) 1 (1H) 224.0.7.XX 64 (0040H) 3 (0003H) 0 (000H) 240 (00f0H) = 4.0 minutes 2 (0002H) 60 (003cH) 30 (001eH) 4096 (1000H) 4096 (1000H) 6 (0006H) = 64 seconds 10 (000aH) = 1024 sec. 6 (0006H) = 64 sec. 10 (000aH) = 1024 sec. 6 (0006H) = 64 sec. 10 (000aH) = 1024 sec. 300 (012cH) 150 65535 (0096H ffffH) Range 0-65535 (ffffH) 0-8 char, case sensitive, no spaces 10 3600 (0e10H) 600 (0258H) 0-65535 (ffffH) 0-65535 (ffffH) 0-255 (00ffH) 0-255 (00ffH) 0-65535 (ffffH) 0-255 (00ffH) 224.0.0.2 239.255.255.255 0-255 (00ffH) 0-65535 (ffffH) 0,1 0-65535 (ffffH)

0-32767 (7fffH) 4 14 (000eH) (16 16384 sec)

6-10

VersaMax PLC Users Manual January 2006

GFK-1503D

Chapter

CPU Operation

This chapter describes the operating modes of the VersaMax PLC CPUs, and shows the relationship between the application program execution and other tasks performed by the CPU.

CPU Operating Modes


The application program in a PLC executes repeatedly. In addition to executing the application program, the PLC CPU regularly obtains data from input devices, sends data to output devices, performs internal housekeeping, and performs communications tasks. This sequence of operations is called the sweep.

The basic operating mode of the PLC is called Standard Sweep mode. In this mode, the CPU performs all parts of its sweep normally. Each sweep executes as quickly as possible with a different amount of time consumed each sweep. The PLC may instead operate in Constant Sweep Time mode. In this mode, the CPU performs the same series of actions but each sweep takes the same amount of time. The PLC may also be in either of two Stop modes:

Stop with I/O Disabled mode Stop with I/O Enabled mode

GFK-1503D

7-1

7 Parts of the CPU Sweep

Start of Sweep Housekeeping

Housekeeping
NO

I/O Enabled ? YES Input Scan

Data Input

Run Mode ? YES Logic Solution

NO

Program Execution

Scan Time of CPU

I/O Enabled ? YES Output Scan

NO

Data Output

Programmer Communications System Communications

Programmer Service System Communications

Application Program Checksum Calculation and Verification of Physical and Programmed Configuration Start Next Sweep

Diagnostics

7-2

VersaMax PLC Users Manual January 2006

GFK-1503D

7
Parts of the CPU Sweep
Start of Sweep Housekeeping Housekeeping includes the tasks necessary to prepare for the start of the sweep. Before starting the actual sweep, the CPU: Calculates the sweep time Schedules the start of the next sweep Determines the mode of the next sweep Updates the fault reference tables Resets the Watchdog timer If the PLC is in Constant Sweep Time mode, the sweep is delayed until the required sweep time elapses. If the required time has already elapsed, the OV_SWP %SA0002 contact is set, and the sweep continues without delay. Next, the CPU updates timer values (hundredths, tenths, and seconds). When the sweep starts, the CPU first scans inputs from input modules and option modules that provide input-type data. Modules are scanned in ascending reference address order. Discrete input modules are scanned before analog input modules. The CPU stores this new input data in the appropriate memories. If the CPU has been configured to not scan I/O in Stop mode, the input scan is skipped when the CPU is in Stop mode. For CPUE05, if the CPU is in run mode and the consumer period of an Ethernet Global Data exchange has expired, the CPU copies the data for that exchange from the Ethernet interface to the appropriate reference memory. Next, the CPU solves the application program logic. It always starts with the first instruction in the program. It ends when the END instruction is executed. Solving the logic creates a new set of output data. Immediately after the logic solution, the CPU scans all output modules in ascending reference address order. The output scan is completed when all output data has been sent. If the CPU has been configured to not scan I/O in Stop mode, the output scan is also skipped when the CPU is in Stop mode. For CPUE05, if I/O is enabled and the producer period of an Ethernet Global Data exchange has expired, the CPU copies the data for that exchange from the appropriate reference memory to the Ethernet interface. If there is a programming device attached, the CPU next executes the programmer communications window. The programmer communications window will not execute if there is no programmer attached. In the default limited window mode, each sweep the CPU honors one service request. The time limit for programmer communications is 6 milliseconds. If the programmer makes a request that requires more than 6 milliseconds to process, the processing is spread out over multiple sweeps. Next, the CPU processes communications requests from intelligent option modules. The modules are polled in round-robin fashion, so no module has priority. In default (Run to Completion) mode, the length of the system communications window is limited to 400 milliseconds. If a module makes a request that requires more than 400 milliseconds to process, the request is spread out over multiple sweeps. In Limited mode, option modules that communicate with the PLC using the system window have less impact on sweep time, but response to their requests is slower. A checksum calculation is performed on the application program at the end of every sweep. You can specify from 0 to 32 words to be checksummed. If the calculated checksum does not match the reference checksum, the program checksum failure exception flag is raised. A fault is entered in the PLC fault table and the PLC goes to Stop mode. If the checksum calculation fails, the programmer communications window is not affected. Each sweep, the CPU verifies the physical configuration of one module against its programmed configuration. A missing, additional, or mismatched module causes a fault to be generated.

Input Scan

Application Program Logic Scan Output Scan

Programmer Communications Window

System Communications Window

Diagnostics

GFK-1503D

Chapter 7 CPU Operation

7-3

7 Standard CPU Sweep Operation


Standard Sweep operation is the normal operating mode of the PLC CPU. In Standard Sweep operation, the CPU repeatedly executes the application program, updates I/O, and performs communications and other tasks shown in the diagram: 1. 2. 3. 4. 5. 6. 7. The CPU performs its start-of-sweep housekeeping tasks. It reads inputs. It executes the application program. It updates outputs If a programming device is present, the CPU communicates with it. It communicates with other devices. It performs diagnostics

Except for communicating with a programmer, all these steps execute every sweep. Programmer communications occur only when needed. In this mode, the CPU performs all parts of its sweep normally. Each sweep executes as quickly as possible with a different amount of time consumed each sweep.

The Sweep Windows


The programmer communications window and the system communications window have two operating modes:
Limited Mode Run to Completion Mode The execution time of the window is 6ms. The window terminates when it has no more tasks to complete or when 6ms has elapsed. Regardless of the time assigned to a particular window the window runs until all tasks within that window are completed (up to 400ms).

SVCREQ 2 can be used in the application program to obtain the current times for each window.

The Watchdog Timer


When the CPU is in Standard Sweep mode, the Watchdog Timer catches failure conditions that could cause an unusually long sweep. The length of the Watchdog Timer is 500 milliseconds. It restarts from zero at the beginning of each sweep. If the sweep takes longer than 500mS, the OK LED on the CPU module goes off. The CPU resets, executes its powerup logic, generates a watchdog failure fault, and goes to Stop mode. Communications are temporarily interrupted.
7-4 VersaMax PLC Users Manual January 2006 GFK-1503D

7
Constant Sweep Time Operation
If the application requires that each CPU sweep take the same amount of time, the CPU can be configured to operate in Constant Sweep Time mode. This operating mode assures that the inputs and outputs in the system are updated at constant intervals. This mode can also be used to implement a longer sweep time, to assure that inputs have time to settle after receiving output data from the program.

Changing the Configured Default for Constant Sweep Mode


If the PLC is in STOP mode, its Configured Constant Sweep mode can be edited. After this is done, the configuration must be Stored to the CPU for the change to take effect. Once stored, Constant Sweep Time mode becomes the default sweep mode.

The Constant Sweep Timer


During operation in Constant Sweep Time mode, the CPUs Constant Sweep Timer controls the length of the sweep. The timer length can be 5 to 500 milliseconds. The time should be at least 10 milliseconds longer than the CPUs sweep time when it is in Standard Sweep mode, to prevent extraneous oversweep faults. If the Constant Sweep Timer expires before the sweep completes, the CPU still completes the entire sweep, including the windows. However, it automatically provides notice when a too-long sweep has occurred. On the next sweep after the oversweep, the CPU places an oversweep alarm in the PLC fault table. Then, at the beginning of the following sweep, the CPU sets the OV_SWP fault contact (%SA0002). The CPU automatically resets the OV_SWP contact when the sweep time no longer exceeds the Constant Sweep Timer. The CPU also resets the OV_SWP contact if it is not in Constant Sweep Time mode. As with other fault contacts, the application program can monitor this contact to keep informed about the occurrence of oversweep conditions.

Enabling/Disabling Constant Sweep Time, Reading or Setting the Length of the Timer
SVCREQ 1 can be included in the application program to enable or disable Constant Sweep Time mode, change the length of the Constant Sweep Time, read whether Constant Sweep Time is currently enabled, or read the Constant Sweep Time length.

GFK-1503D

Chapter 7 CPU Operation

7-5

7 CPU Stop Modes


The PLC may also be in either of two Stop modes:

Stop with I/O Disabled mode Stop with I/O Enabled mode

When the PLC is in Stop mode, the CPU does not execute the application program logic. You can configure whether or not the I/O will scanned during Stop mode. Communications with the programmer and intelligent option modules continue in Stop mode. In addition, faulted board polling and board reconfiguration execution continue in Stop mode. SVCREQ 13 can be used in the application program to stop the PLC at the end of the next sweep. All I/O will go to their configured default states, and a diagnostic message will be placed in the PLC Fault Table.

Flash Memory
A VersaMax PLC stores the current configuration and application in nonvolatile battery-backed RAM. The programmer software can be used to store a copy of the current configuration, application program, and reference tables (excluding overrides) to Flash memory. The programmer can also be used to read a previously-stored configuration, application program, or reference tables from Flash into RAM, or to verify that Flash and RAM contain identical data. By default, the PLC reads the configuration, program logic, and reference tables from RAM at powerup. However, it can be configured to read them from Flash. This is recommended, because data in Flash is non-volatile, even in the case of a battery failure.

7-6

VersaMax PLC Users Manual January 2006

GFK-1503D

7 Controlling the Execution of a Program


The VersaMax CPU Instruction Set contains several powerful Control functions that can be included in an application program to limit or change the way the CPU executes the program and scans I/O.

Calling a Subroutine Block


The CALL function can be used to cause program execution to go to a specific subroutine. Conditional logic placed before the Call function controls the circumstances under which the CPU performs the subroutine logic. After the subroutine is finished, program execution resumes at the point in the logic directly after the CALL instruction.

Creating a Temporary End of Logic


The END function can be used to provide a temporary end of logic. It can be placed anywhere in a program. No logic beyond the END function is executed, and program execution goes directly back to the beginning. This ability makes the END function useful for debugging a program. The END function should not be placed in logic associated with or called by a Sequential Function Chart control structure. If this occurs, the PLC will be placed in STOP/FAULT mode at the end of the current sweep and an SFC_END fault will be logged.

Executing Rungs of Logic without Logical Power Flow


The nested Master Control Relay can be used to execute a portion of the program logic with no logical power flow. Logic is executed in a forward direction and coils in that part of the program are executed with negative power flow. Master Control Relay functions can be nested to 8 levels deep.

Jumping to Another Part of the Program


The Jump function can be used to cause program execution to move either forward or backward in the logic. When a nested Jump function is active, the coils in the part of the program that is skipped are left in their previous states (not executed with negative power flow, as they are with a Master Control Relay). Jump functions can also be nested. Jumps cannot span blocks, SFC actions, SFC transitions, or SFC pre- or post-processing logic.

GFK-1503D

Chapter 7 CPU Operation

7-7

7 Run/Stop Mode Switch Operation


The CPU Run/Stop mode switch can be configured to place the CPU in Stop or Run mode. It can also be configured to prevent writing to program or configuration memory and forcing or overriding discrete data. It defaults to enabled Run/Stop mode selection and disabled memory protection.

Configurable Run/Stop Mode Operation


If Run/Stop mode switch operation is enabled, the switch can be used to place the CPU in Run mode. If the CPU has non-fatal faults and is not in Stop/Fault mode, placing the switch in Run position causes the CPU to go to Run mode. Faults are NOT cleared. If the CPU has fatal faults and is in Stop/Fault mode, placing the switch in Run position causes the Run LED to blink for 5 seconds. While the Run LED is blinking, the CPU switch can be used to clear the fault table and put the CPU in Run mode. After the switch has been in Run position for at least second, move it to Stop position for at least second. Then move it back to Run position. The faults are cleared and the CPU goes to Run mode. The LED stops blinking and stays on. This can be repeated if necessary. If the switch is not toggled as described, after 5 seconds the Run LED goes off and the CPU remains in Stop/Fault mode. Faults stay in the fault table.

Configurable Memory Protection


Operation of the switch can be configured to prevent writing to program memory and configuration, and to prevent forcing or overriding data.

Summary of CPU Switch Run/Stop Operation


Run/Stop Mode Configuration Off On On Off On On I/O Scan Stop Configuration has no effect has no effect has no effect has no effect No Yes Switch Position has no effect Run/On Stop/Off Toggle Switch from Stop to Run Toggle switch from Run to Stop Toggle switch from Run to Stop CPU Operation All modes are allowed. All modes are allowed. CPU not allowed to go to Run mode. CPU goes to Run mode if no fatal faults are present; otherwise, the Run LED blinks for 5 seconds. PLC goes to STOPNO IO PLC goes to STOPIO

7-8

VersaMax PLC Users Manual January 2006

GFK-1503D

7 Privilege Levels and Passwords


Passwords are an optional configurable feature of the VersaMax PLC. Passwords provide different levels of access privilege to the PLC when the programmer is in Online or Monitor mode. Passwords are not used if the programmer is in Offline mode. Passwords can restrict:

Changing I/O and PLC configuration data Changing programs Reading PLC data Reading programs

There is one password for each privilege level in the PLC. Each password may be unique or the same password can be used for more than one level. Passwords are one to seven ASCII characters in length. By default, there is no password protection. Passwords are set up, changed, or removed using the programming software. After passwords have been set up, access to the PLC is restricted unless the proper password is entered. Entering a correct password allows access to the requested level and to all lower levels. For example, the password for level 3 allows access to levels 0, 1, 2, and 3. If PLC communications are suspended, protection automatically returns to the highest unprotected level. For example: If a password is set at levels 2 & 3, but none at level 4, if the software disconnects and reconnects, the access level is 4. Privilege level 1 is always available because no password can be set for this level.
Level 4 Least Protected Access Description Write to all configuration or logic. Configuration may only be written in Stop mode; logic may be written in Stop or Run mode (if run-mode store is supported). Set or delete passwords for any level. Plus all access from levels 3,2 and 1. NOTE: This is the default if no passwords are defined. Write to all configuration and logic when the CPU is in Stop mode, including word-for-word changes (when supported), the addition/deletion of program logic, and the overriding of discrete I/O. Read/Write/Verify user flash. Store reference/override tables. Change sweep mode. Plus all access from levels 2 and 1. Write to any data memory, but this does not include storing tables. This includes the toggle/force of reference values but does not include overriding discrete I/O. The PLC can be started or stopped. PLC and I/O fault tables can be cleared. Plus all access from level 1. Read any PLC data except for passwords. This includes reading fault tables, current status, performing datagrams, verifying logic/config, and loading program and configuration from the PLC. No PLC memory may be changed. 7-9

1 Most Protected GFK-1503D

Chapter 7 CPU Operation

7
Protection Level Request from Programmer
Upon connection to the CPU, the programming software automatically requests the CPU to move to the highest unprotected level. That gives the programmer access to the highest unprotected level without having to specifically request a particular level. A privilege change may be to a lower level or to a higher level. The privilege level is changed from the programmer by entering the new level and the correct password for that level. If the wrong password is entered, the change is denied and a fault is logged in the PLC fault table. A request to change to a privilege level that is not password-protected is made by supplying the new level and an empty password.

Notes on Using Passwords

To re-enable passwords after passwords have been disabled, the PLC must be power-cycled with the battery removed for long enough to completely discharge the super-capacitor and erase the PLC's memory. If the passwords prevent changing the run/stop mode, firmware upgrades cannot be performed if the PLC is in run mode. The Run/Stop switch (if configured) will place the PLC in run or stop mode regardless of the passwords.

The OEM Protection Feature


The OEM protection feature is similar to the passwords and privilege levels and provides an even higher level of security. The feature is enabled or disabled using a 1 to 7 character password called the OEM key. When OEM protection is enabled, no write-access to the PLC program and configuration is permitted. Reading the configuration from the PLC is permitted. In this mode, no user flash operations are allowed. When the OEM key password has been created, the OEM key can be locked in two ways: by choosing the locked setting from the programming software or by power-cycling the PLC. (The OEM key locked status does not change when PLC communications are suspended.)

Clearing Logic/Configuration, and References


It is possible to clear logic, configuration, and references from the programmer with the CPU at any privilege level, even with the OEM key locked. Operators can clear logic, configuration, and references, and store a new application program to the CPU without knowing passwords. If passwords and/or the OEM key have been set and written to flash, a read from flash updates the protection level. In this case, it is not necessary to reenter the password to gain access to a particular level. A Clear All does not clear user flash.
7-10 VersaMax PLC Users Manual January 2006 GFK-1503D

Chapter

Elements of an Application Program

This chapter provides basic information about the application program for a VersaMax PLC.

Structure of an application program Subroutines Program languages The Instruction Set

GFK-1503D

8-1

8 Structure of an Application Program


The application program consists of all the logic needed to control the operations of the PLC CPU and the modules in the system. Application programs are created using the programming software and transferred to the PLC. Programs are stored in the CPUs non-volatile memory. During the CPU Sweep (described in the previous chapter), the CPU reads input data from the modules in the system and stores the data in its configured input memory locations. The CPU then executes the entire application program once, utilizing this fresh input data. Executing the application program creates new output data that is placed in the configured output memory locations. After completing the end of the application program, the CPU writes the output data to modules in the system.
Read Inputs

Execute Application Program Write Outputs

8-2

VersaMax PLC Users Manual January 2006

GFK-1503D

8 Subroutines
The program can consist of one Main program that executes completely during each CPU sweep.

Main Program

Or a program can be divided into subroutines. The maximum size of a main program or subroutine block is 64kB. The program can contain up to 255 subroutines. Subroutines can simplify programming and reduce the overall amount of logic. Each subroutine can be called as needed. The main program might serve primarily to sequence the subroutine blocks.
Subroutine 2 Program Subroutine 3 Subroutine 4

GFK-1503D

Chapter 8 Elements of an Application Program

8-3

8
A subroutine block can be called many times as the program executes. Logic that should be repeated can be placed in a subroutine block, reducing total program size.

Program

Subroutine 2

In addition to being called from the program, subroutine blocks can also be called by other subroutine blocks. A subroutine block can even call itself.

Main Program

Subroutine 2 Subroutine 3

Subroutine 4

The main program is level 1. The program can include up to eight additional nested call levels.

8-4

VersaMax PLC Users Manual January 2006

GFK-1503D

8
Declaring a Subroutine
A subroutine must be declared through the block declaration editor of the programming software.

Calling a Subroutine
A subroutine invoked in the program is using a CALL instruction. Up to 64 subroutine block declarations and 64 CALL instructions are allowed for each block in the program.
%I0004 %I0006 %Q0001

CALL subroutine %I0010 %Q0010

%I0003

GFK-1503D

Chapter 8 Elements of an Application Program

8-5

8 Program Languages
Programs can be created in Ladder Diagram or Instruction List format. The main program or subroutines within the program can also be created in Sequential Function Chart format. The PLC programming software can be used to create both types of logic.

Sequential Function Chart


Sequential Function Chart (SFC) is a graphic method of representing the functions of a sequential automated system as a sequence of steps and transitions. Each step represents commands or actions that are either active or inactive. The flow of control passes from one step to the next through a conditional transition that is either true (1) or false (0). If the transition condition is true (1), control passes from the current step (which becomes inactive) to the next step, which then becomes active. The logic associated with a step is executed when the step is active. This logic is programmed in Ladder Diagram format. The transitions between steps are also programmed as Ladder Diagram logic.

Step 1
Trans1

Transition 1
Step 2
Trans2

Transition 2
Step 3

8-6

VersaMax PLC Users Manual January 2006

GFK-1503D

8
Ladder Diagram
This traditional PLC programming language, with its rung-like structure, executes from top to bottom. The logic execution is thought of as power flow, which proceeds down along the left rail of the ladder, and from left to right along each rung in sequence.
Power Rail Relay Power flow into function Power flow out of function
%Q0001 MUL_ INT

%I0001

%R0123 CONST 00002

I1 I2

%R0124 Multiplication function Coil

The flow of logical power through each rung is controlled by a set of simple program functions that work like mechanical relays and output coils. Whether or not a relay passes logical power flow along the rung depends on the content of a memory location with which the relay has been associated in the program. For instance, a relay might pass power flow if its associated memory location contained the value 1. The same relay would not pass power flow if the memory location contained the value 0. If a relay or other function in a rung does not pass logical power flow, the rest of that rung is not executed. Power then flows down along the left rail to the next rung. Within a rung, there are many complex functions that can be used for operations like moving data stored in memory, performing math operations, and controlling communications between the CPU and other devices in the system. Some program functions, such as the Jump function and Master Control Relay, can be used to control the execution of the program itself. Together, this large group of Ladder Diagram relays, coils, and functions is called the Instruction Set of the CPU.

GFK-1503D

Chapter 8 Elements of an Application Program

8-7

8 The Instruction Set


The VersaMax PLC CPU provides a powerful Instruction Set for building application programs. As a guide to the programming capabilities of the VersaMax PLC, all of the relays, coils, functions, and other elements of the Instruction Set are summarized on the following pages. Complete reference information is included in the documentation and online help for the programming software.

Contacts
| | |/| <+> Normally Open Normally Closed Continuation Passes power if the associated reference is ON. Passes power if the associated reference is OFF. Passes power to the right if the preceding continuation coil is set ON.

Coils
( ) (/) ( ) ( ) (S) (R) (SM) Normally Open Negated Positive Transition Negative Transition SET RESET Retentive SET Sets the associated reference ON if the coil receives power. Otherwise OFF. Sets the associated discrete reference ON if the coil does not receive power. Otherwise OFF. If power flow was OFF to this coil the last time it was executed and is ON this time, then the coil is turned ON. Otherwise, the coil is turned OFF. If power flow was ON to this coil the last time it was executed and is OFF this time, then the coil is turned ON. Otherwise, the coil is turned OFF. Sets the associated discrete reference ON if the coil receives power. It remains set until reset by an (R) coil. Sets the associated discrete reference OFF if the coil receives power. It remains reset until set by an (S) coil. Sets the associated reference is set ON if the coil receives power. The reference remains set until reset by an (RM) coil. Its state is retained through power failure and STOP-TO-RUN transition. Resets the associated discrete reference OFF if the coil receives power. The reference remains reset until set by an (SM) coil. Its state is retained through power failure and STOP-TO-RUN transition. Sets the associated discrete reference ON if the coil does not receive power. The state is retained through power failure and STOP-TO-RUN transition. Otherwise OFF. Sets the associated discrete reference ON if the coil receives power. The state is retained through power failure and STOP-TO-RUN transition. Otherwise OFF. If power to the coil is ON, the continuation coil sets the next continuation contact ON. If power is OFF, the continuation coil sets the next continuation contact OFF.

(RM)

Retentive RESET Negated Retentive Retentive Continuation

(/M)

(M) <+>

8-8

VersaMax PLC Users Manual January 2006

GFK-1503D

8
Timers and Counters
ondtr oftd tmr upctr dnctr On-Delay Stopwatch Timer Off-Delay Timer On-Delay Timer Up Counter Down Counter Accumulates time while receiving power The current value is reset to zero when the Reset input receives power. Accumulates time while NOT receiving power. Accumulates time while receiving power The current value is reset to zero when there is no power flow. Increments by 1 each time the function receives transitional power. Counts down from a preset value every time the function receives transitional power.

Math Functions
add sub mul div mod expt sin cos tan asin acos atan deg rad scale sqroot Log ln exp Addition Subtraction Multiplication Division Modulo Division Power of X Trigonometric Sine Trigonometric Cosine Trigonometric Tangent Inverse Sine Inverse Cosine Inverse Tangent Convert to Degrees Convert to Radians Scaling Square Root Base 10 Logarithm Natural Logarithm Power of e Adds two numbers. Subtracts one number from another. Multiplies two numbers. Divides one number by another, yielding a quotient. Divides one number by another, yielding a remainder. Raises X to the power specified by IN and places the result in Q. Finds the trigonometric sine of a real number. Finds the trigonometric cosine of a real number. Finds the trigonometric tangent of a real number. Finds the inverse sine of a real number. Finds the inverse cosine of a real number. Finds the inverse tangent of a real number. Performs a RAD_TO_DEG conversion on a real radian value. Performs a DEG_TO_RAD conversion on a real degree value. Scales an input constant or word value. Finds the square root of an integer or real value. Finds the base 10 logarithm of a real value. Finds the natural logarithm base of a real number. Raises the natural logarithm base to the power specified by input.

GFK-1503D

Chapter 8 Elements of an Application Program

8-9

8
Relational Functions
eq ne gt ge lt le range Equal Not Equal Greater Than Greater Than or Equal To Less Than Less Than or Equal To Range Tests for equality between two numbers. Tests for non-equality between two numbers. Tests whether one number is greater than another. Passes power if the first number is greater than the second. Tests whether one number is greater than or equal to another Tests whether one number is less than another. Test whether one number is greater than or equal to another. Test the input value against a range of two numbers.

Bit Operation Functions


and or xor not shl shr rol ror bittst bitset bitclr bitpos mskcmp Logical AND Logical OR Logical Exclusive OR Logical Invert Shift Left Shift Right Rotate Left Rotate Right Bit Test Bit Set Bit Clear Bit Position Masked Compare Performs Logical AND of two bit strings. Performs Logical OR of two bit strings. performs Logical Exclusive OR of two bit strings. Performs a logical inversion of a bit string. Shifts a bit string left. Shifts a bit string right. Rotates a bit string left. Rotates a bit string right. Test a bit within a bit string. Sets one bit within a string to true. Sets one bit within a string to false. Locates a bit set to true within a bit string. Performs a masked compare of two arrays.

8-10

VersaMax PLC Users Manual January 2006

GFK-1503D

8
Data Move Functions
move blkmov blkclr shfreg bitseq comreq Move Block Move Block Clear Shift Register Bit Sequencer Communication Request Moves one or more bits of data. Moves a block of up to 7 constants. Clears to zero one or more bytes/words of memory. Shifts one or more words or bits of data through a block of memory. Sequences a 1 through a group of bits in PLC memory. Sends a communications request.

Table Functions
arrmov srh eq srh ne srh gt srh ge srh lt srh le Array Move Search Equal Search Not Equal Search Greater Than Search Greater Than or Equal Search Less Than Search Less Than or Equal Copies a specified number of data elements from a source array to a destination array. Searches array for values equal to a specified value. Searches array for values not equal to a specified value. Searches array for values greater than a specified value. Searches array for values greater than or equal to a specified value. Searches array for values less than a specified value. Searches array for values less than or equal to a specified value.

Conversion Functions
bcd-4 word int tdint real Convert to BCD-4 (From INT) Converts a number to 4-digit BCD format. Convert to Word (From REAL) Converts a Real value to Word format. Convert to INT (From BCD-4 or REAL) Convert to DINT (From BCD-4 or REAL) Convert to Real (From INT, DINT, BCD-4 or WORD) Truncate to INT (from REAL) Truncate to Double Precision INT (from REAL) Converts a number to signed integer format. Converts a number to double precision integer format. Converts a value to real value format.

int dint

Truncates to a 16-bit signed number. The range is 32,768 to +32,767. Truncates to a 32-bit signed number. The range is -2,147,483,648 to +2,147,483,647.

GFK-1503D 11

Chapter 8 Elements of an Application Program

8-

8
Control Functions
call do io Call Do I/O Causes a program execution to go to a specified subroutine block. Services a specified range of inputs or outputs immediately (all inputs or outputs on a module will be serviced if any addresses on that module are included in the function partial I/O module updates are not performed Selects the non-interacting independent PID algorithm. Selects the ISA PID algorithm. The program executes from the first rung to the last rung or the END instruction, whichever is encountered first. This instruction is useful for debugging purposes. A rung explanation. A special PLC service function. Starts a master control relay range. An MCR causes all rungs between the MCR and its subsequent ENDMCR to be executed with no power flow. Up to 8 MCRs can be nested. Ends a master control relay range. Jumps to a specified location indicated by a LABEL in the logic. The target location of a JUMP instruction. Multiple Jump instructions can reference the same label. (future) Operates like a mechanical drum sequencer, selecting a 16bit output pattern from an array of stored patterns, and sending it to a set of outputs.

pidind pidisa end

Independent PID Algorithm ISA PID Algorithm Temporary End of Logic

commnt svcreq mcr

Comment Service Request Master Control Relay

endmcr jump label drumseq

End Master Control Relay Jump Label Drum Sequencer

8-12

VersaMax PLC Users Manual January 2006

GFK-1503D

Chapter

Program Data

This chapter describes the types of data that can be used in an application program, and explains how that data is stored in the VersaMax PLCs memory.

Data memory references Retentiveness of data Using names and descriptions for program references System status references Time tick contacts How program functions handle numerical data

GFK-1503D

9-1

9 Data Memory References


The PLC stores program data in both bit memory and word memory. Both bit memory and word memory are divided into different types with specific characteristics. By convention, each type is normally used for a specific type of data, as explained below. However, there is great flexibility in actual memory assignment. Individual memory locations are indexed using alphanumeric identifiers called references. The references letter prefix identifies the memory area. The numerical value is the offset within that memory area.

Word Memory References


Each word memory address (reference) is on a 16-bit word boundary. The PLC uses three types of references for data stored in word memory. %AI Normally used for analog inputs. %AQ Normally used for analog outputs. %R Registers are normally used to store program data in word format. Word memory is represented below. The example below shows ten addresses. Each has 16 bits that together contain one value. The PLC cannot access individual bits in word memory.
addresses 1 2 3 4 5 6 7 8 9 10 12467 12004 231 359 14 882 24 771 735 000

9-2

VersaMax PLC Users Manual January 2006

GFK-1503D

9
Bit Memory References
Each bit memory address (reference) is on a bit boundary. Data is stored in bit memory as represented below. The illustration shows 160 individually-addressed bits, with address 1 in the upper left and address 160 in the lower right.
addresses 1 0 0 1 1 0 1 1 1 1 0 2 3 4 5 1 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 1 0 6 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 0 0 0 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 0 0 0 1 0 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 1 0 0 1 1 0 0 1 1 0 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 1 0 0 1 ... 160 0 1 0 1 1 1 1 0 1 0 1 0 1 0 1 0 0 0 0 0

The PLC uses six types of references for data stored in bit memory. %I Normally used for discrete inputs, and viewable in the Input Status Table.

%Q Normally used for physical output references, and viewable in the Output Status Table. A %Q reference may be either retentive or non-retentive, depending on its use in the program. %M Normally used to represent internal references. A specific %M reference may be either retentive or non-retentive, depending on its use in the program. %T Used for temporary references that can be used many times in a program. Data with %T references is not retained through loss of power or RUN-TO-STOP-TO-RUN transitions. %T references cannot be used with retentive coils.
System status references, which have specific predefinitions.

%S, %SA, %SB, and %SC can be used for any type of logic contact. %SA, %SB, and %SC can be used for retentive coils. %S can be used as inputs to functions or function blocks. %SA, %SB, and %SC can be used as inputs or outputs of functions and function blocks. %G Used for Global Data. Data in %G references is retained through power loss. %G references can be used with contacts and retentive coils, but not on non-retentive coils.

%S

Transition Bits and Override Bits


%I, %Q, %M, and %G references have associated transition and override bits. %T, %S, %SA, %SB, and %SC references have associated transition bits only. The CPU uses transition bits for transitional coils. When override bits are set, the associated references can only be changed from the programmer.
GFK-1503D Chapter 9 Program Data 9-3

9 Retentiveness of Data
Data is retentive if it is automatically saved when the PLC is stopped or power cycled. The following data is retentive:

Program logic Fault tables and diagnostics Overrides Word data (%R, %AI, %AQ) Bit data (%I, %SC, %G, fault bits and reserved bits) Word data stored in %Q and %M. Data in %Q or %M references that are used as function block outputs or with retentive coils: -(M)- retentive coils -(/M)- negated retentive coils -(SM)- retentive SET coils -(RM)- retentive RESET coils The last time a %Q or %M reference is used with a coil, the coil type determines whether the data is retentive or non-retentive. For example, if %Q0001 was last programmed as the reference of a retentive coil, the %Q0001 data is retentive. However, if %Q0001 was last programmed on a non-retentive coil, then the %Q0001 data is non-retentive.

%Q or %M references that have been made retentive by specifically declaring them to be retentive. %Q and %M references default to nonretentive. The states of transition coils. %T data %S, %SA, and %SB data (but %SC bit data IS retentive). %Q and %M references that have not been declared to be retentive. %Q and %M references that are used with non-retentive coils: -( )- coils -(/)- negated coils -(S)- SET coils -(R)- RESET coils

The following data is non-retentive:

9-4

VersaMax PLC Users Manual January 2006

GFK-1503D

9 System Status References


The PLC stores system status data in predefined references in %S, %SA, %SB, and %SC memory. Each system status reference has a descriptive name. For example, time tick references are named T_10MS, T_100MS, T_SEC, and T_MIN. Examples of convenience references include FST_SCN, ALW_ON, and ALW_OFF.

Using the System Status References


System status references can be used as needed in application programs. For example, the following function block uses the FST_SCN (first scan) status reference to control power flow to a Block Clear function. In this example, at powerup, 32 words of %Q memory (512 points) beginning at %Q0001 are filled with zeros.
FST_SCN | |

BLK_ CLR WORD IN LEN 00032

%Q0001

GFK-1503D

Chapter 9 Program Data

9-5

9
%S References
References in %S memory are read only. Reference
%S0001 %S0002 %S0003 %S0004 %S0005 %S0006 %S0007 %S0008 %S0009 %S0010

Name
FST_SCN LST_SCN T_10MS T_100MS T_SEC T_MIN ALW_ON ALW_OFF SY_FULL IO_FULL

Definition
Set to 1 when the current sweep is the first sweep. Reset from 1 to 0 when the current sweep is the last sweep. 0.01 second timer contact. 0.1 second timer contact. 1.0 second timer contact. 1.0 minute timer contact. Always ON. Always OFF. Set when the PLC fault table fills up. Cleared when an entry is removed and when the PLC fault table is cleared. Set when the I/O fault table fills up. Cleared when an entry is removed from the I/O fault table and when the I/O fault table is cleared. Set when an override exists in %I, %Q, %M, or %G memory. reserved Set when background program check is active. Set to indicate a bad battery in the CPU. The contact reference is updated once per sweep. reserved SNP-X host is actively attached to CPU port 1. (Port 2 defaults to disabled, and must be activated with a CRQ). SNP-X host has read data from CPU port 1. SNP-X host has written data to CPU port 1. Set ON when a relational function using REAL data executes successfully. It is cleared when either input is NaN (Not a Number).

%S0011 %S0012 %S0013 %S0014 %S0015, 16 %S0017 %S0018 %S0019 %S0020 %S0021 %S0022

OVR_PRE PRG_CHK PLC_BAT

SNPXACT SNPX_RD SNPX_WT

FF_OVR USR_SW

Set to report a Fatal Fault Overide. Set to reflect the state of the CPU mode switch. 1 = Run/On 0 = Stop/Off reserved

%S0023-32

9-6

VersaMax PLC Users Manual January 2006

GFK-1503D

9
%SA, %SB, and %SC References
References in %SA, %SB, and %SC memory can be both read and written to. Reference
%SA0001

Name
PB_SUM

Definition
Set when a checksum calculated on the application program does not match the reference checksum. If the fault was due to a temporary failure, the discrete bit can be cleared by again storing the program to the CPU. If the fault was due to a hard RAM failure, the CPU must be replaced. Set when a PLC in CONSTANT SWEEP mode detects that the previous sweep took longer than the time specified. Cleared when the PLC detects that the previous sweep did not take longer than specified. Also cleared during transition from STOP to RUN mode. Set when an application fault occurs. Cleared when the PLC transitions from STOP to RUN mode. reserved Set when a configuration mismatch is detected during power-up or a configuration store. Cleared by powering up the PLC after correcting the condition. Set when the diagnostics detects a problem with the CPU hardware. Cleared by replacing the CPU module. Set when a low battery fault occurs. Cleared by replacing the battery then powering up the PLC. reserved Set when an I/O module stops communicating with the CPU. Cleared by replacing the module and cycling system power. Set when an option module stops communicating with the CPU. Cleared by replacing the module and cycling power on the main rack. reserved Set when an I/O module is added. Cleared by cycling PLC power and when the configuration matches the hardware after a store. Set when an option module is added. Cleared by cycling PLC power and when the configuration matches the hardware after a store. reserved Set when a hardware failure is detected in an option module. Cleared by replacing the module and cycling PLC power. reserved Set when an unrecoverable software fault is detected in an option module. Cleared by cycling PLC power and when the configuration matches the hardware.

%SA0002

OV_SWP

%SA0003 %SA0004-8 %SA0009

APL_FLT

CFG_MM

%SA0010 %SA0011 %SA0012,13 %SA0014 %SA0015 %SA0016-18 %SA0019 %SA0020 %SA0021-26 %SA0027 %SA0028-30 %SA0031

HRD_CPU LOW_BAT

LOS_IOM LOS_SIO

ADD_IOM ADD_SIO

HRD_SIO

SFT_SIO

GFK-1503D

Chapter 9 Program Data

9-7

9
Reference %SB0001-9 %SB0010 %SB0011 %SB0012 %SB0013 %SB0014 %SC0001-8 %SC0009 %SC0010 %SC0011 %SC0012 %SC0013 %SC0014 %SC0015 ANY_FLT SY_FLT IO_FLT SY_PRES IO_PRES HRD_FLT SFT_FLT SFT_CPU STOR_ER BAD_RAM BAD_PWD Name reserved Set when the CPU detects corrupted RAM memory at powerup. Cleared when RAM memory is valid at powerup. Set when a password access violation occurs. Cleared when the PLC fault table is cleared. reserved Set when the CPU detects an unrecoverable error in the software. Cleared by clearing the PLC fault table. Set when an error occurs during a programmer store operation. Cleared when a store operation is completed successfully. reserved Set when any fault occurs. Cleared when both fault tables have no entries. Set when any fault occurs that causes an entry to be placed in the PLC fault table. Cleared when the PLC fault table has no entries. Set when any fault occurs that causes an entry to be placed in the I/O fault table. Cleared when the I/O fault table has no entries. Set as long as there is at least one entry in the PLC fault table. Cleared when the PLC fault table has no entries. Set as long as there is at least one entry in the I/O fault table. Cleared when the I/O fault table has no entries. Set when a hardware fault occurs. Cleared when both fault tables have no entries. Set when a software fault occurs. Cleared when both fault tables have no entries. Definition

9-8

VersaMax PLC Users Manual January 2006

GFK-1503D

9 How Program Functions Handle Numerical Data


Regardless of where data is stored in memoryin one of the bit memories or one of the word memories--the application program can handle it as different data types.
Type BIT Name Bit Description A Bit data type is the smallest unit of memory. It has two states, 1 or 0. The programmer functions use the term BOOL for bit-type data. A Byte data type has an 8-bit value. The valid range is 0 to 255 (0 to FF in hexadecimal). A Word data type uses 16 consecutive bits of data memory; but, instead of the bits in the data location representing a number, the bits are independent of each other. Each bit represents its own binary state (1 or 0). The valid range of word values is 0 to +65,535 (FFFF). Four-Digit Four-digit BCD numbers use 16-bit data Binary Coded memory locations. Each BCD digit uses Decimal four bits and can represent numbers between 0 and 9. BCD coding of the 16 bits has a value range of 0 to 9999. Floating-Point Real numbers use two consecutive 16-bit memory locations. The range of numbers that can be stored in this format is 1.401298E-45 to 3.402823E+38. See the next page for more information. Signed integer data uses 16-bit memory locations. Signed integers are represented in 2's complement notation. Bit 16 is the sign bit, (0 = positive, 1 = negative). Their range is -32,768 to +32,767. Double precision signed integers data uses two consecutive 16-bit memory locations. They are represented in 2's complement notation. Bit 32 is the sign bit, (0 = positive, 1 = negative). Their range is -2,147,483,648 to +2,147,483,847.
Word 1 16 bit positions 16 1

Data Format

BYTE

Byte

WORD

BCD-4

Word 1 2 1 4 Word 3 2 16 13 9 5

4 BCD Digits 1 Bit Positions

REAL

Word 2

Word 1

+/1 17 16 32 23 bit mantissa 8 bit exponent Twos Complement Values

INT

Signed Integer

Word 1 +/16 1 Twos Complement Values 16 bit positions

DINT

Double Precision Signed Integer

Word 2 +/32

Word 1 17 16 1

Twos Complement Values

GFK-1503D

Chapter 9 Program Data

9-9

9
Real Numbers
The REAL data type, which can be used for some Math functions and Numerical functions, is actually floating point data. Floating-point numbers are stored in single precision IEEE-standard format. This format requires 32 bits, which occupy two (adjacent) 16-bit PLC words.
Most Significant Register Bits 17-32 32 17 16 23-bit mantissa 8-bit exponent 1-bit sign (Bit 32) Least Significant Register Bits 1-16 1

For example, if the floating-point number occupies registers %R0005 and %R0006, then %R0005 is the least significant register and %R0006 is the most significant register. The range of numbers that can be stored in this format is from 1.401298E45 to 3.402823E+38 and the number zero.

Errors in Real Numbers and Operations


Overflow occurs when a number greater than 3.402823E+38 or less than -3.402823E+38 is generated by a REAL function. The ok output of the function is set OFF; and the result is set to positive infinity (for a number greater than 3.402823E+38) or negative infinity (for a number less than 3.402823E+38). You can determine where this occurs by testing the sense of the ok output.
POS_INF NEG_INF = 7F800000h = FF800000h IEEE positive infinity representation in hex. IEEE negative infinity representation in hex.

If the infinities produced by overflow are used as operands to other REAL functions, they may cause an undefined result. This result is referred to as NaN (Not a Number). For example, the result of adding positive infinity to negative infinity is undefined. When the ADD_REAL function is invoked with positive infinity and negative infinity as its operands, it produces NaN for its result.

9-10

VersaMax PLC Users Manual January 2006

GFK-1503D

9 Time-Tick Contacts
There are four time-tick contacts. They can be used to provide regular pulses of power flow to other program functions. The four time-tick contacts have time durations of 0.01 second, 0.1 second, 1.0 second, and 1 minute. The state of these contacts does not change during the execution of the sweep. These contacts provide a pulse having an equal on and off time duration. The contacts are referenced as T_10MS (0.01 second), T_100MS (0.1 second), T_SEC (1.0 second), and T_MIN (1 minute). The following timing diagram represents the on/off time duration of these contacts.
T XXXXX X SEC

X/2 SEC

X/2 SEC

These time-tick contacts represent specific locations in %S memory.

GFK-1503D

Chapter 9 Program Data

9-11

9-12

VersaMax PLC Users Manual January 2006

GFK-1503D

Chapter

10

Instruction Set Reference

This section is a reference to the functions in the VersaMax PLC Instruction Set:
Bit Operation Functions Logical AND, Logical OR Exclusive OR, Logical Invert (NOT) Shift Right/Shift Left Rotate Right/Rotate Left Bit Test Bit Set, Bit Clear Masked Compare Bit Position Bit Sequencer Control Functions Do I/O Call End Comment Master Control Relay Drum Sequencer Service Request (see chapter 11) PID (see chapter 14) Data Move Functions Move Block Move Block Clear Shift Register Communication Request Data Type Conversion Functions Convert to BCD-4 Convert to Signed Integer Convert to Double Precision Signed Integer Convert to Real Convert Real to Word Truncate Real Number PID (see chapter 14) Math and Numerical Functions Add, Subtract, Multiply, Divide Modulo Division Scaling Square Root Trigonometric Functions Logarithmic/Exponential Functions Convert Radians / Degrees

Relational Functions Equal Not Equal Greater Than Less Than Greater or Equal Less or Equal Range Relay Functions Contacts, Coils Fault and No Fault Contacts Alarm Contacts Table Functions Array Move Search Timer and Counter Functions Time-tick Contacts On Delay Stopwatch Timer On Delay Timer Off Delay Timer Up Counter Down Counter

GFK-1503D

10-1

10 Bit Operation Functions


The Bit Operation functions perform comparison, logical, and move operations on bit strings. The Bit Operation functions are:

Logical AND Logical OR Exclusive OR Logical Invert (NOT) Shift Right/Shift Left Rotate Right/Rotate Left

Bit Test Bit Set, Bit Clear Masked Compare Bit Position Bit Sequencer

Data Lengths for the Bit Operation Functions


The Logical AND, OR, XOR, and NOT (Invert) functions operate on a single word of data. The other Bit Operation functions may operate on up to 256 words. All Bit Operation functions require Word-type data. However, they operate on data as a continuous string of bits, with bit 1 of the first word being the Least Significant Bit (LSB). The last bit of the last word is the Most Significant Bit (MSB). For example, if you specified three words of data beginning at reference %R0100, it would be operated on as 48 contiguous bits.
%R0100 16 %R0101 32 %R0102 48 (MSB) 15 31 47 14 30 46 13 29 45 12 28 44 11 27 43 10 26 42 9 25 41 8 24 40 7 23 39 6 22 38 5 21 37 4 20 36 3 19 35 2 18 34 1 17 33 bit 1 (LSB)

Overlapping input and output reference address ranges in multi-word functions is not recommended, it can produce unexpected results.

10-2

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Bit Operation Functions Logical AND, Logical OR
Each scan that power is received, a Logical AND or Logical OR function examines each bit in bit string I1 and the corresponding bit in bit string I2, beginning at the least significant bit in each. A string length of 256 words can be selected.

Logical AND
If both bits examined by the Logical AND function are 1, a 1 is placed in the corresponding location in output string Q. If either or both bits are 0, a 0 is placed in string Q in that location. The Logical AND function can be used to build masks or screens, where only certain bits are passed through (bits opposite a 1 in the mask), and all other bits are set to 0. The Logical AND function can also be used to clear an area of word memory by ANDing the bits with another bit string known to contain all 0s. The I1 and I2 bit strings specified may overlap.

Logical OR
If either or both bits examined by the Logical OR function is 1, a 1 is placed in the corresponding location in output string Q. If both bits are 0, a 0 is placed in string Q in that location. The Logical OR function can be used to combine strings or to control many outputs with one simple logical structure. The Logical OR function is the equivalent of two relay contacts in parallel multiplied by the number of bits in the string. It can be used to drive indicator lamps directly from input states, or to superimpose blinking conditions on status lights.
Enable Input 1 Input 2 AND_ WORD I1 Q I2 OK Output

GFK-1503D

Chapter 10 Instruction Set Reference

10-3

10
Bit Operation Functions Logical AND, Logical OR Parameters of the Logical AND and Logical OR Functions
Input/ Output
enable I1 I2 ok Q

Choices
flow

Description
When the function is enabled, the operation is performed.

I, Q, M, T, S, G, R, AI, AQ, Constant or reference for the first word of the first string. constant I, Q, M, T, S, G, R, AI, AQ, Constant or reference for the first word of the second string. constant flow, none The OK output is energized whenever enable is energized. I, Q, M, T, SA, SB, SC (not Output Q contains the result of the operation. S), G, R, AI, AQ

Example of the Logical AND Function


In the example, when input %I0001 is set, the 16-bit strings represented by nicknames WORD1 and WORD2 are examined. The results of the Logical AND are placed in output string RESULT.
%I0001 AND_ WORD WORD1 WORD2 I1 Q I2 RESULT WORD1 WORD2 RESULT 0 0 0 1 1 1 1 1 1 1 0 0 1 0 0 0 1 1 0 1 1 1 0 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0 0 0 0 1 1 1 1 0 0 0

10-4

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Bit Operation Functions Exclusive OR
The Exclusive OR function compares each bit in bit string I1 with the corresponding bit in string I2. If the bits are different, a 1 is placed in the corresponding position in the output bit string.
Enable Input 1 Input 2 XOR_ WORD I1 Q I2 OK Output

Each scan that power is received, the Exclusive OR function examines each bit in string I1 and the corresponding bit in string I2, beginning at the least significant bit in each. For each two bits examined, if only one is 1, then a 1 is placed in the corresponding location in bit string Q. The Exclusive OR function passes power flow to the right whenever power is received. If string I2 and output string Q begin at the same reference, a 1 placed in string I1 will cause the corresponding bit in string I2 to alternate between 0 and 1, changing state with each scan as long as power is received. Longer cycles can be programmed by pulsing the power flow to the function at twice the desired rate of flashing; the power flow pulse should be one scan long (one-shot type coil or self-resetting timer). The Exclusive OR function is useful for quickly comparing two bit strings, or to blink a group of bits at the rate of one ON state per two scans.

Parameters of the Exclusive OR Function


Input/ Output
enable I1 I2 ok Q

Choices
flow I, Q, M, T, S, G, R, AI, AQ, constant I, Q, M, T, S, G, R, AI, AQ, constant flow, none I, Q, M, T, SA, SB, SC (not S), G, R, AI, AQ

Description
When the function is enabled, the operation is performed. Constant or reference for the first word to be XORed. Constant or reference for the second word to be XORed. The OK output is energized whenever enable is energized. Output Q contains the result of the operation.

GFK-1503D

Chapter 10 Instruction Set Reference

10-5

10
Bit Operation Functions Exclusive OR Example
In the example, whenever %I0001 is set, the bit string represented by the nickname WORD3 is cleared (set to all zeros).
%I0001 XOR_ WORD WORD3 WORD3 I1 Q I2 WORD3

I1 (WORD3) I2 (WORD3)

0 0

0 0

0 0

1 1

1 1

1 1

1 1

1 1

1 1

1 1

0 0

0 0

1 1

0 0

0 0

0 0

Q (WORD3)

10-6

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Bit Operation Functions Logical Invert (NOT)
The Logical Invert (NOT) function sets the state of each bit in the output bit string Q to the opposite of the state of the corresponding bit in bit string I1. All bits are altered on each scan that power is received, making output string Q the logical complement of I1. The function passes power flow to the right whenever power is received. A length of 256 words can be selected.
Enable Input 1 NOT_ WORD I1 Q OK Output

Parameters of the Logical Invert Function


Input/ Output
enable I1 ok Q

Choices
flow

Description
When the function is enabled, the operation is performed.

I, Q, M, T, S, G, R, AI, Constant or reference for the word to be negated. AQ, constant flow, none The OK output is energized whenever enable is energized.

I, Q, M, T, SA, SB, SC Output Q contains the result of the operation. (not S), G, R, AI, AQ

Example
In the example, whenever input %I0001 is set, the bit string represented by the nickname TAC is set to the inverse of bit string CAT.
%I0001 NOT_ WORD CAT I1 Q TAC

GFK-1503D

Chapter 10 Instruction Set Reference

10-7

10
Bit Operation Functions Shift Bits Right, Shift Bits Left
The Shift Left function shifts all the bits in a word or group of words to the left by a specified number of places. When the shift occurs, the specified number of bits is shifted out of the output string to the left. As bits are shifted out of the high end of the string, the same number of bits is shifted in at the low end.
MSB B2 1 1 0 1 1 1 1 1 1 1 0 0 1 0 LSB 0 0 B1

The Shift Right function is used to shift all the bits in a word or group of words a specified number of places to the right. When the shift occurs, the specified number of bits is shifted out of the output string to the right. As bits are shifted out of the low end of the string, the same number of bits is shifted in at the high end.
MSB B1 1 1 0 1 1 1 1 1 1 1 0 0 1 0 LSB 0 0 B2

A string length of 1 to 256 words can be selected for either function.


Enable Word to be shifted in Number of bits Bit shifted in SHIFTL WORD IN B2 N B1 Q Last bit shifted out Output

If the number of bits to be shifted (N) is greater than the number of bits in the array * 16, the array (Q) is filled with copies of the input bit (B1), and the input bit is copied to the output power flow (B2). If the number of bits to be shifted is zero, then no shifting is performed; the input array is copied into the output array; and input bit (B1) is copied into the power flow. The bits being shifted into the beginning of the string are specified via input parameter B1. If a length greater than 1 has been specified as the number of bits to be shifted, each of the bits is filled with the same value (0 or 1). This can be:

The boolean output of another program function. All 1s. To do this, use the special reference nickname ALW_ON as a permissive to input B1. All 0s. To do this, use the special reference nickname ALW_OFF as a permissive to input B1.

The function passes power flow to the right, unless the number of bits specified to be shifted is zero. Output Q is the shifted copy of the input string. If you want the input string to be shifted, the output parameter Q must use the same memory location as the input parameter IN. The entire shifted string is written on each scan that power is received. Output B2 is the last bit shifted out. For example, if four bits were shifted, B2 would be the fourth bit shifted out.
10-8 VersaMax PLC Users Manual January 2006 GFK-1503D

10
Bit Operation Functions Shift Bits Right, Shift Bits Left Parameters of the Shift Right / Left Functions
Input/ Output
enable IN N B1 B2 Q

Choices
flow I, Q, M, T, S, G, R, AI, AQ I, Q, M, T, G, R, AI, AQ, constant flow flow, none I, Q, M, T, SA, SB, SC, G, R, AI, AQ

Description
When the function is enabled, the shift is performed. IN contains the first word to be shifted. N contains the number of places (bits) that the array is to be shifted. B1 contains the bit value to be shifted into the array. B2 contains the bit value of the last bit shifted out of the array. Output Q contains the first word of the shifted array.

Example
In the example, whenever input %I0001 is set, the output bit string contained in the memory location represented by the nickname WORD2 is made a copy of of the bits in location WORD1. The output string is left-shifted by 8 bits, as specified by the input LENGTH. The resulting open bits at the beginning of the output string are set to the value of %I0002.
%I0001 SHIFTL WORD IN B2 N B1 Q

WORD1 LENGTH 8 %I0002

OUTBIT WORD2

GFK-1503D

Chapter 10 Instruction Set Reference

10-9

10
Bit Operation Functions Rotate Bits Right, Rotate Bits Left
The Rotate Left function rotates all the bits in a string a specified number of places to the left. When rotation occurs, the specified number of bits is rotated out of the input string to the left and back into the string on the right. The Rotate Right function rotates the bits in the string to the right. When rotation occurs, the specified number of bits is rotated out of the input string to the right and back into the string on the left. A length of 1 to 256 words can be selected for either function. The number of places to rotate must be more than zero and less than the number of bits in the string. The Rotate Bits function passes power flow to the right, unless the number of bits specified to be rotated is greater than the total length of the string or is less than zero. The result is placed in output string Q. If you want the input string to be rotated, the output parameter Q must use the same memory location as the input parameter IN. The entire rotated string is written on each scan that power is received.
Enable Word to be rotated ROL WORD IN Q OK Output

Number of bits

Parameters of the Rotate Bits Right / Left Functions


Input/ Output
enable IN N ok Q

Choices
flow I, Q, M, T, S, G, R, AI, AQ I, Q, M, T, G, R, AI, AQ, constant flow, none

Description
When the function is enabled, the rotation is performed. IN contains the first word to be rotated. N contains the number of places the array is to be rotated. The OK output is energized when the rotation is energized and the rotation length is not greater than the array size.

I, Q, M, T, SA, SB, SC, G, R, AI, AQ Output Q contains the first word of the rotated array.

Example
In the example, whenever input %I0001 is set, the input bit string in location %R0001 is rotated 3 bits. The result is placed in %R0002. The input bit string %R0001 is not changed by the function. If the same reference is used for IN and Q, a rotation will occur in place.
%I0001 ROL WORD %R0001 CONST +00003 IN Q %R0002 MSB LSB

%R0001 %R0002 after %I0001 is set

1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0
MSB LSB

1 1 0 0 0 0 0 0 0 0 0 0 0

1 1 1

10-10

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Bit Operation Functions Bit Test
The Bit Test function tests a bit within a bit string to determine whether that bit is currently 1 or 0. The result of the test is placed in output Q. Each sweep power is received, the Bit Test function sets its output Q to the same state as the specified bit. If a register rather than a constant is used to specify the bit number, the same function block can test different bits on successive sweeps. If the value of BIT is outside the range (1 < BIT < (16 * length) ), then Q is set OFF. A string length of 1 to 256 words can be selected.
Enable BIT_ TEST_ WORD IN Q BIT Output

Bit to be tested Bit number of IN

Parameters of the Bit Test Function


Input/ Output
enable IN BIT Q

Choices
flow I, Q, M, T, S, G, R, AI, AQ I, Q, M, T, G, R, AI, AQ, constant flow, none

Description
When the function is enabled, the bit test is performed. IN contains the first word of the data to be operated on. BIT contains the bit number of IN that should be tested. Valid range is (1 < BIT < (16 * length)). Output Q is energized if the bit tested was a 1.

Example
In the example, whenever input %I0001 is set, the bit at the location contained in reference PICKBIT is tested. The bit is part of string PRD_CDE. If it is 1, output Q passes power flow and the coil %Q0001 is turned on.
%I0001 BIT_ TEST_ WORD PRD_CDE IN Q %Q0001 ( )

PICKBIT

BIT

GFK-1503D

Chapter 10 Instruction Set Reference

10-11

10
Bit Operation Functions Bit Set and Bit Clear
The Bit Set function sets a bit in a bit string to 1. The Bit Clear function sets a bit in a string to 0. Each sweep that power is received, the function sets the specified bit. If a variable (register) rather than a constant is used to specify the bit number, the same function block can set different bits on successive sweeps. A string length of 1 to 256 words can be selected. The function passes power flow to the right, unless the value for BIT is outside the range (1 < BIT < (16 * length) ). Then, OK is set OFF.
Enable BIT_ SET_ WORD IN OK

First word Bit number of IN

BIT

Parameters of the Bit Set and Bit Clear Functions


Input/ Output
enable IN BIT ok

Choices
flow I, Q, M, T, SA, SB, SC, G, R, AI, AQ I, Q, M, T, G, R, AI, AQ, constant flow, none

Description
When the function is enabled, the bit operation is performed. IN contains the first word of the data to be operated on. BIT contains the bit number of IN that should be set or cleared. Valid range is (1 < BIT < (16 * length) ). The OK output is energized whenever the bit input is valid and enable is energized.

Example
In the example, whenever input %I0001 is set, bit 12 of the string beginning at reference %R0040 is set to 1.
%I0001 BIT_ SET WORD %R0040 CONST 00012 IN Q BIT

10-12

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Bit Operation Functions Masked Compare
The Masked Compare function compares the contents of two separate bit strings. It provides the ability to mask selected bits. Input string 1 might contain the states of outputs such as solenoids or motor starters. Input string 2 might contain their input state feedback, such as limit switches or contacts.
Enable MASK_ COMP_ WORD I1 MC I2 M BIT Q BN Miscompare Output Bit number of last compare

Input 1 Input 2 Bit string mask Bit number

When the function receives power flow, it begins comparing the bits in the first string with the corresponding bits in the second string. Comparison continues until a miscompare is found or until the end of the string is reached. The BIT input stores the bit number where the next comparison should start (a 0 indicates the first bit in the string). The BN output stores the bit number where the last comparison occurred (where a 1 indicates the first bit in the string). Using the same reference for BIT and BN causes the compare to start at the next bit position after a miscompare; or, if all bits compared successfully upon the next invocation of the function block, the compare starts at the beginning. If you want to start the next comparison at some other location in the string, you can enter different references for BIT and BN. If the value of BIT is a location that is beyond the end of the string, BIT is reset to 0 before starting the next comparison.

Parameters of the Masked Compare Function


Input/ Output
enable I1 I2 M BIT MC Q BN length

Choices
flow R, AI, AQ For WORD only: I, Q, M, T, S, G R, AI, AQ For WORD only: I, Q, M, T, S, G R, AI, AQ For WORD only: I, Q, M, T, SS, SB, SC, G I, Q, M, T, S, G, R, AI, AQ, constant

Description
Permissive logic to enable the function. Reference for the first bit string to be compared. Reference for the second bit string to be compared. Reference for the bit string mask. Reference for the bit number where the next comparison should start. User logic to determine if a miscompare has occurred. Output copy of the mask (M) bit string.

flow, none R, AI, AQ For WORD only: I, Q, M, T, SA, SB, SC, G I, Q, M, T, S, G, R, AI, AQ Bit number where the last miscompare occurred. The number of words in the bit string. Max. is 4095 for Constant WORD and 2047 for DWORD.
Chapter 10 Instruction Set Reference 10-13

GFK-1503D

10
Bit Operation Functions Masked Compare Operation of the Masked Compare
If all corresponding bits in strings I1 and I2 match, the function sets the miscompare output MC to 0 and BN to the highest bit number in the input strings. The comparison then stops. On the next invocation of a Masked Compare Word, it is reset to 0. When the two bits currently being compared are not the same, the function checks the correspondingly numbered bit in string M (the mask). If the mask bit is a 1, the comparison continues until it reaches another miscompare or the end of the input strings. If a miscompare is detected and the corresponding mask bit is a 0, the function does the following: 1. Sets the corresponding mask bit in M to 1. 2. Sets the miscompare (MC) output to 1. 3. Updates the output bit string Q to match the new content of mask string M 4. Sets the bit number output (BN) to the number of the miscompared bit. 5. Stops the comparison.

Example
In the example, after first scan the Masked Compare Word function executes. It compares %M000116 with %M001732. %M003348 contain the mask. The value in %R0001 determines the bit position in the two input strings where the comparison starts.
FST_SCN | | %M0001 %M0017 %M0033 %R0001 MASK COMP_ WORD I1 MC I2 M BIT Q BN %M0033 %R0001

%Q0001 (S)

Before the function block is executed, the contents of the above references are:
(I1 ) %M0001 (I2) %M0017 = 6C6Ch = = 606Fh = = = = 0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 1 0 1 1 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 OFF

(M/Q) %M0033 = 000Fh (BIT/BN) %R0001 (MC) %Q0001

The contents of these references after the function block is executed are:
(I1 ) %M000 1 (I2) %M00 17 (M/Q) %M0033 (BIT/BN) %R000 1 (MC) %Q0001 = (same) = = (same) = = = = 0 0 0 8 ON 1 1 1 1 0 0 0 1 1 0 0 1 1 0 0 0 0 0 0 1 1 0 1 1 0 1 1 0 0 0 0 1 1 0 1 1 0 1 1 0 0 1 1 1 1

In this example, contact %T1 and coil %M100 force one and only one execution; otherwise the function would repeat with possibly unexpected results.

10-14

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Bit Operation Functions Bit Position
The Bit Position function locates a bit set to 1 in a bit string. Each sweep that power is received, the function scans the bit string starting at IN. When the function stops scanning, either a bit equal to 1 has been found or the entire length of the string has been scanned. POS is set to the position within the bit string of the first non-zero bit; POS is set to zero if no non-zero bit is found. A string length of 1 to 256 words can be selected. The function passes power flow to the right whenever enable is ON.
Enable First word BIT_ POS_ WORD IN POS Position of non-zero bit or 0 OK

Parameters for the Bit Position Function


Input/ Output
enable IN ok POS

Choices
flow I, Q, M, T, S, G, R, AI, AQ flow, none I, Q, M, T, G, R, AI, AQ

Description
When the function is enabled, a bit search operation is performed. IN contains the first word of the data to be operated on. The OK output is energized whenever enable is energized. The position of the first non-zero bit found, or zero if a non-zero bit is not found.

Example
In the example, if %I0001 is set, the bit string starting at %M0001 is searched until a bit equal to 1 is found. Coil %Q0001 is turned on. If a bit equal to 1 is found, its location within the bit string is written to %AQ001. If %I0001 is set, bit %M0001 is 0, and bit %M0002 is 1, then the value written to %AQ001 is 2
%I0001 BIT_ POS WORD %M0001 IN Q POS %AQ0001 %Q0001 ( )

GFK-1503D

Chapter 10 Instruction Set Reference

10-15

10
Bit Operation Functions Bit Sequencer
The Bit Sequencer function performs a bit sequence shift through an array of bits.
Enable Reset Direction Number Starting Address BIT_ SEQ R DIR STEP ST Address OK

The operation of the function depends on the previous value of the parameter EN: R Current Execution
OFF OFF OFF OFF ON

EN Previous Execution
OFF OFF ON ON ON/OFF

EN Current Execution
OFF ON OFF ON ON/OFF

Bit Sequencer Execution


Bit sequencer does not execute. Bit sequencer increments/decrements by 1. Bit sequencer does not execute. Bit sequencer does not execute. Bit sequencer resets.

The reset input (R) overrides the enable (EN) and always resets the sequencer. When R is active, the current step number is set to the value passed in via the step number parameter. If no step number is passed in, step is set to 1. All of the bits in the sequencer are set to 0, except for the bit pointed to by the current step, which is set to 1. When Enable is active and Reset is not active, the bit pointed to by the current step number is cleared. The current step number is incremented or decremented, based on the direction parameter. Then, the bit pointed to by the new step number is set to 1. The parameter ST is optional. If it is not used, the Bit Seqencer function operates as described above, except that no bits are set or cleared. The function just cycles the current step number through its legal range.

Memory Required for a Bit Sequencer


Each bit sequencer uses three words (registers) of %R memory to store the information:
word 1 word 2 word 3 current step number length of sequence (in bits) control word

10-16

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Bit Operation Functions Bit Sequencer
Word 3 (the control word) stores the state of the boolean inputs and outputs of its associated function block, in the following format:
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Reserved OK (status output) EN (enable input)

Parameters for the Bit Sequencer Function


Input/ Output
address enable R DIR STEP ST ok

Choices
R flow flow flow I, Q, M, T, G, R, AI, AQ, constant, none I, Q, M, T, SA, SB, SC, G, R, AI, AQ, none flow, none

Description
Address is the location of the bit sequencers current step, length, and the last enable and OK status. When the function is enabled, if it was not enabled on the previous sweep and if R is not energized, the bit sequence shift is performed. When R is energized, the bit sequencers step number is set to the value in STEP (default = 1), and the bit sequencer is filled with zeros, except for the current step number bit. When DIR is energized, the bit sequencers step number is incremented prior to the shift. Otherwise, it is decremented. When R is energized, the step number is set to this value. ST contains the first word of the bit sequencer. Optional. The OK output is energized whenever the function is enabled.

Example
In the example, the Bit Sequencer operates on register memory %R0001. Its static data is stored in registers %R001012. When CLEAR is active, the sequencer is reset and the current step is set to step number 3. The first 8 bits of %R0001 are set to zero. When NXT_SEQ is active and CLEAR is not active, the bit for step number 3 is cleared and the bit for step number 2 or 4 (depending on whether DIR is energized) is set.
NXT CYC CLEAR DIRECT CONST 00003 %R0001 BIT_ SEQ R DIR STEP ST %R0010

GFK-1503D

Chapter 10 Instruction Set Reference

10-17

10 Control Functions
This section describes the control functions, which may be used to limit program execution and to change the way the CPU executes the application program.

Service specified I/O: DO IO Go to a subroutine block: CALL Temporary program end: END Execute a group of logic rungs without power flow: MCR Go to a specified location in the program: JUMP, LABEL Place a text explanation in the program logic: COMMENT Provide predefined On/Off patterns to a set of 16 discrete outputs in the manner of a mechanical DRUM SEQUENCER.

The more complex Control Functions; Service Request and the PID algorithms, are described in other chapters of this manual.

10-18

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Control Functions Do I/O
The Do I/O function updates inputs or outputs for one scan while the program is running. The Do I/O function can also be used to update selected I/O during the program in addition to the normal I/O scan. I/O is serviced in increments of entire I/O modules; the PLC adjusts the references, if necessary, while the function executes.
enable Starting address Ending address DO_IO ST END ALT OK

Execution of the function continues until all inputs in the selected range have reported or all outputs have been serviced on the I/O modules. Program execution then returns to the next function. If the range of references includes an option module, all the input data (%I and %AI) or all the output data (%Q and %AQ) for that module will be scanned. The ALT parameter is ignored while scanning intelligent I/O modules or the Ethernet interface. The function passes power to the right whenever power is received, unless:

Not all references of the type specified are present within the selected range. The CPU is not able to properly handle the temporary list of I/O created by the function. The range specified includes modules that are associated with a Loss of I/O" fault. Input/ Output
enable ST END ALT

Parameters of the Do I/O Function


Choices
flow I, Q, AI, AQ I, Q, AI, AQ I, Q, M, T, G, R, AI, AQ, constant, none

Description
When the function is enabled, a limited input or output scan is performed. The starting address of the I/O to be serviced. The ending address of the I/O to be serviced. For the input scan, ALT specifies the address to store scanned input point/word values. For the output scan, ALT specifies the address to get output point/word values from to send to the I/O modules. OK is energized when the scan completes normally.

ok

flow, none

GFK-1503D

Chapter 10 Instruction Set Reference

10-19

10
Control Functions Do I/O Do I/O for Inputs
If input references are specified, when the function receives power flow, the PLC scans input points from the starting reference (ST) to the END reference. If a reference is specified for ALT, copies of the new input values are placed in memory beginning at that reference, and the real input values are not updated. ALT must be the same size as the reference type scanned. If a discrete reference is used for ST and END, ALT must also be discrete. If no reference is specified for ALT, the real input values are updated. This allows inputs to be scanned one or more times during the program execution portion of the CPU sweep.

Example Do I/O for Inputs:


In this example, when the function receives power flow, the PLC scans references %I0001-64 and %Q0001 is turned on. Copies of the scanned inputs are placed in internal memory from %M0001-64. Because a reference is specified for ALT, the real inputs are not updated. This allows the current values of inputs to be compared with their values at the beginning of the scan.
%I0001 DO_IO %I0001 %I0064 %M0001 ST END ALT %Q0001

Do I/O for Outputs


If output references are specified, when the function receives power flow, the PLC writes the latest output values from the starting reference (ST) to the END reference to the output modules. If outputs should be written to the output modules from internal memory other than %Q or %AQ, the beginning reference can be specified for ALT.

Example Do I/O For Outputs:


In the next example, when the function receives power flow, the PLC writes values from references %R0001-0004 to analog output channels %AQ001-004 and %Q0001 is turned on. Because a reference is entered for ALT, the values at %AQ001-004 are not written to output modules.
%I0001 DO_IO %AQ001 %AQ004 %R0001 ST END ALT %Q0001

If no reference were specified for ALT, the PLC would write values at references %AQ001-004 to analog output channels.

10-20

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Control Functions Do I/O Do I/O to One Module (Enhanced Do I/O)
The Do I/O function can be used on a single discrete input or discrete output module located in the main PLC. Execution of the function is much faster when just one module is read or written to. The module to be read/written is specified in the ALT parameter. For example, a constant value of 2 in this parameter indicates to the CPU that it is to execute the Do I/O function block for the module in location 2. The start and end references must be either %I or %Q. These references specify the first and last reference the module is configured for.

Example Do I/O for One Module


In this example, the Do I/O function is executed only to a 16-point input module which is configured at %I0001 through %I0016 in location 2.
%I0001 DO_IO %I0001 %I0016 CONST 00002 ST END ALT %Q0001

GFK-1503D

Chapter 10 Instruction Set Reference

10-21

10
Control Functions Call
The Call function causes program execution to go to a specified subroutine block.
CALL (subroutine)

When the Call function receives power flow, it causes the scan to go immediately to the designated subroutine block and execute it. After the subroutine block execution is complete, control returns to the point in the logic immediately following the Call instruction.

Example
%I0004 %I0006 %T0001

CALL (subroutine) %I0010 %Q0010

%I0003 %I0001

10-22

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Control Functions End of Logic
The End of Logic function provides a temporary end of logic. The program executes from the first rung to the last rung or the End of Logic function, whichever is encountered first. The End of Logic function unconditionally terminates program execution. There can be nothing after the end function in the rung. No logic beyond the End of Logic function is executed, and control is transferred to the beginning of the program for the next sweep. The End of Logic function is useful for debugging purposes because it prevents any logic which follows from being executed. The programming software provides an [ END OF PROGRAM LOGIC ] marker to indicate the end of program execution. This marker is used if no End of Logic function is programmed in the logic.

[ END ]

Example
In the example, an End of Logic function is programmed to terminate the end of the current sweep.
[ STOP ] END]

GFK-1503D

Chapter 10 Instruction Set Reference

10-23

10
Control Functions Master Control Relay (MCR) / End MCR
All rungs between an active Master Control Relay (MCRN) and its corresponding End Master Control Relay (ENDMCRN) function are executed without power flow to coils. The ENDMCRN associated with the Master Control Relay is used to resume normal program execution. Unlike Jump functions, Master Control Relays can only move forward; the ENDMCRN must appear after its corresponding Master Control Relay instruction in a program.

Nested MCR
A Nested Master Control Relay function can be nested completely within another MCRN/ENDMCRN pair. There can be multiple Master Control Relay functions with a single ENDMCRN. The Master Control Relay function has an enable input and a name. This name is used again with the ENDMCRN. The Master Control Relay has no outputs; there can be nothing after it in a rung.
(name)

enable

MCR

With a Master Control Relay, function blocks within the scope of the Master Control Relay are executed without power flow, and coils are turned off. The ENDMCRN function must be tied to power rail; there can be no logic before it in the rung. The name of the ENDMCRN associates it with the corresponding Master Control Relay(s). The ENDMCRN function has no outputs; there can be nothing after it in a rung.
(name) ENDMCRN

10-24

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Control Functions Master Control Relay (MCR) / End MCR Example Master Control Relay and ENDMCRN Functions
In the example, when %I0002 is ON, the Master Control Relay is enabled. When the Master Control Relay is enabled--even if %I0001 is ON--the Addition function block is executed without power flow (i.e., it does not add 1 to %R0001), and %Q0001 is turned OFF. If %I0003 and %I0004 are ON, %Q0003 is turned OFF and %Q0004 remains ON.
%I0002 %I0001 ADD_ INT %R0001 1 %I0003 %I0004 I1 I2 %Q0003 %Q0004 S Q %R0001 FIRST MCRN %Q0001

FIRST ENDMCRN

GFK-1503D

Chapter 10 Instruction Set Reference

10-25

10
Control Functions Jump, Label
The Nested Jump instruction causes a portion of the program logic to be bypassed. Program execution continues at the Label specified. When the Jump is active, all coils within its scope are left at their previous states. This includes coils associated with timers, counters, latches, and relays. The Nested Jump instruction has the form ----->>LABEL01, where LABEL01 is the name of the corresponding nested Label instruction. A nested Jump can be placed anywhere in a program. There can be multiple nested Jump instructions corresponding to a single nested Label. Nested Jumps can be either forward or backward Jumps. There can be nothing after the Jump instruction in the rung. Power flow jumps directly from the instruction to the rung with the named label. Caution To avoid creating an endless loop with forward and backward Jump instructions, a backward Jump must contain a way to make it conditional.

Label
The Label instruction is the target of a Jump. Use the Label instruction to resume normal program execution. There can be only one Label with a particular name in a program. The Label instruction has no inputs and no outputs; there can be nothing either before or after a Label in a rung.

10-26

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Control Functions Jump, Label Example Jump and Label Instructions
In the example, whenever Jump TEST1 is active, power flow is transferred to Label TEST1. With a Jump, any function blocks between the Jump and the Label are not executed, and coils are not affected. In the example, when %I0002 is ON, the Jump is taken. Since the logic between the Jump and the Label is skipped, %Q0001 is unaffected (if it was ON, it remains ON; if it was OFF, it remains OFF).
%I0001 >>TEST1 %I0001 ADD_ INT %R0001 1 >>TEST1 I1 I2 Q %R0001 %Q0001

GFK-1503D

Chapter 10 Instruction Set Reference

10-27

10
Control Functions Comment
The Comment function is used to enter a comment (rung explanation) in the program. A comment can have up to 2048 characters of text. Longer text can be included in printouts using an annotation text file. It is represented in the ladder logic like this:

(* COMMENT *)

10-28

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Control Functions Drum Sequencer
The Drum Sequencer function is a program instruction that operates like a mechanical drum sequencer. The Drum Sequencer steps through a set of potential output bit patterns and selects one based on inputs to the function block. The selected value is copied to a group of 16 discrete output references.
Enable Step Reset Pattern Dwell Time Fault Timeout DRUM Control Block Length OK Out Drum Coil Dwell Timeout Timeout Fault First Follower

Power flow to the Enable input causes the Drum Sequencer to copy the content of a selected reference to the Out reference. Power flow to the Reset input or to the Step input selects the reference to be copied. The Control Block input is the beginning reference for the Drum Sequencer functions parameter block, which includes information used by the function.

GFK-1503D

Chapter 10 Instruction Set Reference

10-29

10
Control Functions Drum Sequencer Parameters of the Drum Sequencer Function
Input/ Output
enable Step

Choices
flow flow

Description

Reset

Pattern

Dwell Time

Fault Timeout Control Block Length ok OUT Drum Coil Dwell Timeout Timeout Fault First Follower

The Enable input controls execution of the function. The Step input can be used to go one step forward in the sequence. When the Enable input receives power flow and the Step input makes an Off to On transition, the Drum Sequencer moves one step. When Reset is active, the function ignores the Step input. flow The Reset input can be used to select a specific step in the sequence. When Enable and Reset both receive power flow, the function copies the Preset Step value in the Control Block to the Active Step reference, also in the Control Block. Then the function block copies the value in the Preset Step reference to the Out reference bits. When Reset is active, the function ignores the Step input. R, AI, AQ The starting address of an array of words, each representing one step of the Drum Sequencer. The value of each word represents the desired combination of outputs for a particular value of Active Step. The number of elements in the array is equal to the length input. R, AI, AQ, This optional input array of words has one element for each element in the Pattern none array. Each value in the array represents the dwell time for the corresponding step of the Drum Sequencer in 0.1 second units. When the dwell time expires for a given step the Dwell Timeout bit is set. If a Dwell Time is specified the drum cannot sequence into its next step until the Dwell Time has expired. R, AI, AQ, This optional input array of words has one element for each element in the Pattern none array. Each value in the array represents the fault timeout for the corresponding step of the Drum Sequencer in 0.1 second units. When the fault timeout has expired the Fault Timeout bit is set. R The beginning reference address of the functions parameter block. The length of the Control Block is 5 words. A more complete description of what is contained within this block is listed below. CONST Value between 1 and 128 that specifies the number of steps. flow, none OK is energized if Enable is On and no error condition is detected. If Enable is Off, this output will always be Off. I, Q, M, T, G, A word of memory containing the element of the Pattern Array that corresponds to R, AI, AQ the current Active Step. I, Q, M, T, G, This optional bit reference is set whenever the function block is enabled and Active none Step is not equal to Preset Step. I, Q, M, T, G, This optional bit reference is set if the dwell time for the current step has expired. none I, Q, M, T, G, This optional bit reference is set if the drum has been in a particular step longer than none the steps specified Fault Timeout. I, Q, M, T, G, This optional array of bits has one element for each step of the Drum Sequencer. No none more than one bit in the array is On at any time and that bit corresponds to the value of the Active Step

10-30

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Control Functions Drum Sequencer Parameter Block for the Drum Sequencer Function
The parameter block (control block) for the Drum Sequencer function contains information needed to operate the Drum Sequencer.
address address + 1 address + 2 address + 3 Active Step Preset Step Step Control Timer Control

Active Step The active step value specifies the element in the Pattern array to copy to the Out output memory location. This is used as the array index into the Pattern, Dwell Time, Fault Timeout, and First Follower arrays. Preset Step is On. A word input that is copied to the Active Step output when the Reset

Step Control A word that is used to detect Off to On transitions on both the Step input and the Enable input. The Step Control word is reserved for use by the function block, and must not be written to. Timer Control Two words of data that hold values needed to run the timer. These values are reserved for use by the function block and must not be written to.

Notes on Using the Drum Sequencer Function


1. The Dwell Timeout Output bit is cleared the first time the drum is in a new step. This is true:

Whether the drum is introduced to a new step by changing the Active Step or by using the Step Input. Regardless of the Dwell Time Array value associated with the step (even if it is 0). During the first sweep the Active Step is initialized.

2. The Active and Preset Step of the Drum Sequencers control block must be initialized for the Drum Sequencer to work or to pass power flow. Even if the Active Step is in the correct range (between 1 and length of the Pattern array) and the Preset Step is not used, the drum will not function if the Preset Step is not in the proper range.

GFK-1503D

Chapter 10 Instruction Set Reference

10-31

10 Data Move Functions


The Data Move functions of the Instruction Set provide basic data move capabilities.

Move Data. This function copies data as individual bits, so the new location does not have to be the same data type. Block Move. This function places constants into seven specified memory locations. Block Clear. This function fills an area of memory with zeros. Shift Register. This function shifts one or more data words or data bits from a reference location into a specified area of memory. Data already in the area is shifted out. Communication Request (COMMREQ). This important function allows the CPU to communicate with intelligent modules in the system, for example, communications modules. The basic format of the COMMREQ function is shown in this chapter. The detailed parameters needed to program specific communications tasks are provided in the documentation for each module.

10-32

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Data Move Functions Move Data
The Move function copies data as individual bits from one location to another. Because the data is copied in bit format, the new location does not need to be the same data type as the original. When the Move function receives power flow, it copies data from input parameter IN to output parameter Q as bits. If data is moved from one location in discrete memory to another, (for example, from %I memory to %T memory), the transition information associated with the discrete memory elements is updated to indicate whether or not the Move operation caused any discrete memory elements to change state. Data at the input parameter does not change unless there is an overlap in the source and destination.
Enable Value to be Moved MOVE INT IN Q OK Output

Note that if an array of Bit-type data specified in the Q parameter does not include all the bits in a byte, the transition bits associated with that byte (which are not in the array) are cleared when the Move function receives power flow. The input IN can be either a reference for the data to be moved or a constant. If a constant is specified, then the constant value is placed in the location specified by the output reference. For example, if a constant value of 4 is specified for IN, then 4 is placed in the memory location specified by Q. If the length is greater than 1 and a constant is specified, then the constant is placed in the memory location specified by Q and the locations following, up to the length specified. Do not allow overlapping of IN and Q parameters. The result of the Move depends on the data type selected for the function, as shown below. For example, if the constant value 9 is specified for IN and the length is 4, then 9 is placed in the bit memory location specified by Q and the three locations following:
MOVE_BOOL
Enable MOVE BOOL IN Q OK Output msb 1 0 lsb 0 1 MOVE INT IN Q

MOVE_INT
Enable OK Output 9 9 9 9

(Length = 4 bits)

(Length = 4 words)

The function passes power to the right whenever power is received.

GFK-1503D

Chapter 10 Instruction Set Reference

10-33

10
Data Move Functions Move Data Parameters for the Move Data Function
Input/ Output
enable Length

Choices
flow

Description

IN

ok Q

When the function is enabled, the move is performed. The number of bits, words, or double words of data to be copied. This is the length of IN. Length must be from 1 to 256 for all types except BIT. If IN is a constant and Q is type BIT, the length must be between 1 and 16. If IN is type Bit, the length must be between 1 and 256 bits. I, Q, M, T, G, R, AI, AQ, IN contains the value to be moved. For MOVE_BOOL, any constant discrete reference may be used; it does not need to be byte For bit or word data only: aligned. However, 16 bits, beginning with the reference address specified, are displayed online. S For real data: R, AI, AQ flow, none The OK output is energized whenever the function is enabled. I, Q, M, T, G, R, AI, AQ, When the move is performed, the value at IN is written to Q. For bit/ word data: SA, SB, For MOVE_BOOL, any discrete reference may be used; it does SC not need to be byte aligned. However, 16 bits, beginning with For real data: R, AI, AQ the reference address specified, are displayed online.

Example 1
When enabling input %Q0014 is ON, 48 bits are moved from memory location %M0001 to memory location %M0033. (%M0001 and %M0003 are defined as WORD types if length 3.)
%Q0014 | | %M0001 MOVE WORD IN Q %M0033

Even though the destination overlaps the source for 16 bits, the move is done correctly. Before using the Move function: After using the Move function:
INPUT (%M0001 through %M0048) %M0016 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 %M0032 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 %M0048 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 INPUT (%M0033 through %M0080) 1 %M0048 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 %M0064 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 %M0080 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 33

10-34

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Data Move Functions Block Move
The Block Move function copies a block of seven constants to a specified location. When the Block Move function receives power flow, it copies the constant values into consecutive locations beginning at the destination specified in output Q. The function passes power to the right whenever power is received.
Enable Constant value Constant value Constant value Constant value Constant value Constant value Constant value BLKMV INT I1 Q I2 I3 I4 I5 I6 I7 OK Output

Parameters of the Block Move Function


Input/ Output
enable I1 to I7 ok Q

Choices
flow constant flow, none I, Q, M, T, G, R, AI, AQ For Word data: SA, SB, SC For Real data: R, AI, AQ

Description
When the function is enabled, the block move is performed. I1 through I7 contain seven constant values. The OK output is energized whenever the function is enabled. Output Q contains the first element of the moved array. I1 is moved to Q.

Example
In the example, when the enabling input represented by the nickname FST_SCN is ON, the Block Move function copies the input constants into memory locations %R001016.
FST_SCN | | CONST +32767 CONST -32768 CONST +00001 CONST +00002 CONST -00002 CONST -00001 CONST +00001 BLKMV INT I1 I2 I3 I4 I5 I6 I7 Q %R010

GFK-1503D

Chapter 10 Instruction Set Reference

10-35

10
Data Move Functions Block Clear
The Block Clear function fills a specified block of data with zeros. When the function receives power flow, it writes zeros into the memory location beginning at the reference specified by IN. When the data to be cleared is from discrete memory (%I, %Q, %M, %G, or %T), the transition information associated with the references is also cleared. The function passes power to the right whenever power is received.
Enable Word to be cleared BLK_ CLR WORD IN OK

Parameters of the Block Clear Function


Input/ Output
enable IN Length ok flow, none

Choices
flow

Description
When the function is enabled, the array is cleared.

I, Q, M, T, SA, SB, SC, G, IN contains the first word of the array to be cleared. R, AI, AQ The length of IN must be between 1 and 256 words. The number of words that will be cleared. This is the length of IN. The OK output is energized whenever the function is enabled.

Example
In the example, at powerup, 32 words of %Q memory (512 points) beginning at %Q0001 are filled with zeros. %Q is defined as WORD of length 32.
FST_SCN | | BLK_ CLR WORD IN

%Q0001

10-36

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Data Move Functions Shift Register
The Shift Register function shifts one or more data words or data bits from a reference location into a specified area of memory. For example, one word might be shifted into an area of memory with a specified length of five words. As a result of this shift, another word of data would be shifted out of the end of the memory area. The reset input (R) takes precedence over the function enable input. When the reset is active, all references beginning at the shift register (ST) up to the length specified for LEN, are filled with zeros. If the function receives power flow and reset is not active, each bit or word of the shift register is moved to the next highest reference. The last element in the shift register is shifted into Q. The highest reference of the shift register element of IN is shifted into the vacated element starting at ST. The contents of the shift register are accessible throughout the program because they are overlaid on absolute locations in logic addressable memory.
Enable Reset Value to be shifted (first bit or word) SHFR_ WORD R IN ST Q OK Output

For VersaMax CPUs, when this function is used to rotate a bit sequence around a range of discrete references, separate references must be used for ST and Q, and additional logic must be provided to copy the output word from the Q reference back to the ST reference. This function may be used, for example, to control the repetition of a fixed sequence of actions. In this example, each of the discrete references in the range of the SHFR_BIT instruction would be used as the permissive contact for one of the repeated actions.

Parameters of the Shift Register Function


Input/ Output
enable Length

Choices

Description

flow When enable is energized and R is not, the shift is performed. 1 to 256 bits / The length of the shift register in bits or words. Length is defined as the length of IN. words. R flow When R is energized, the shift register located at ST is filled with zeros. IN I, Q, M, T, S, G, R, IN contains the value to be shifted into the first bit or word of the shift register. For AI, AQ, constant SHFR_BIT, any discrete reference may be used; it does not need to be byte aligned. ST I, Q, M, T, SA, SB, ST contains the first bit or word of the shift register. For SHFR_BIT, any discrete SC, G, R, AI, AQ reference may be used; it does not need to be byte aligned. ok flow, none OK is energized whenever the function is enabled and R is not enabled. Q I, Q, M, T, SA, SB, Output Q contains the bit or word shifted out of the shift register. For SHFR_BIT, any SC, G, R, AI, AQ discrete reference may be used; it does not need to be byte aligned. CAUTION: the use of overlapping input and output reference address ranges in multi-word functions is not recommended; it may produce unexpected results.
GFK-1503D Chapter 10 Instruction Set Reference 10-37

10
Data Move Functions Shift Register Example 1:
In the example, the shift register operates on register memory locations %R0001 through %R0100. (%R0001 is defined as type Word of length 100). When the reset reference CLEAR is active, the Shift Register words are set to zero. When the NXT_CYC reference is active and CLEAR is not active, the word from output status table location %Q0033 is shifted into the Shift Register at %R0001. The word shifted out of the Shift Register from %R0100 is stored in output %M0005.
NXT_CYC | | CLEAR | | %Q0033 %R0001 SHFR_ WORD R IN ST Q %M0005

Example 2:
In this example, the Shift Register operates on memory locations %M0001 through %M0100. (%M0001 is defined as type Boolean of length 100). When the reset reference CLEAR is active, the Shift Register function fills %M0001 through %M0100 with zeros. When NXT_CYC is active and CLEAR is not, the Shift Register function shifts the data in %M0001 to %M0100 down by one bit. The bit in %Q0033 is shifted into %M0001 while the bit shifted out of %M0100 is written to %M0200.
NXT_CYC | | CLEAR | | %Q0033 %M0001 SHFR_ BIT R IN ST Q %M0200

10-38

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Data Move Functions Communication Request
The Communication Request (COMMREQ) function communicates with an intelligent module. Many types of COMM REQs have been defined. The information below describes only the basic format of the function. When the function receives power flow, a command block of data is sent to the specified module. After sending the COMMREQ, the program can either suspend execution and wait for a reply for a maximum waiting period specified in the command, or resume immediately.
Enable First word of command block Location Task identifier COMM_ REQ IN FT SYSID TASK

Parameters of the COMMREQ Function


Input/ Output
enable IN SYSID TASK FT

Choices
flow R, AI, AQ I, Q, M, T, G, R, AI, AQ, constant flow, none

Description
When the function is energized, the communications request is performed. IN contains the first word of the command block. SYSID contains the rack number (most significant byte) and slot number (least significant byte) of the target device. FT is energized if an error is detected processing the COMM REQ: 1. 2. 3. 4. The specified target address is not present (SYSID). The specified task is not valid for the device (TASK). The data length is 0. The devices status pointer address (in the command block) does not exist.

R AI, AQ, constant TASK contains the task ID of the process on the target device.

GFK-1503D

Chapter 10 Instruction Set Reference

10-39

10
Data Move Functions Communication Request Command Block for the COMMREQ Function
The Command Block starts at the reference specified in COMMREQ parameter IN. The length of the Command Block depends on the amount of data sent to the device. The Command Block contains the data to be communicated to the other device, plus information related to the execution of the COMM REQ. The Command Block has the following structure:
address address + 1 address + 2 address + 3 address + 4 address + 5 address + 6 to address + 133 Length (in words) Wait/No Wait Flag Status Pointer Memory Status Pointer Offset Idle Timeout Value Maximum Communication Time Data Block

Example
In the example, when enabling input %M0020 is ON, a Command Block starting at %R0016 is sent to communications task 1 in the device located at rack 1, slot 2 of the PLC. If an error occurs processing the COMMREQ, %Q0100 is set.
%M0020 | | %R0016 CONST 0102 CONST 00001 COMM_ REQ IN FT SYSID TASK

%Q0100 ( )

10-40

VersaMax PLC Users Manual January 2006

GFK-1503D

10 Data Type Conversion Functions


The Data Type Conversion functions are used to change a data item from one number type to another. Many programming instructions, such as math functions, must be used with data of one type.

Convert data to BDC-4 Convert data to signed integer Convert data to double-precision integer Convert data to Real Convert data to Word Round a Real number toward zero (TRUN)

GFK-1503D

Chapter 10 Instruction Set Reference

10-41

10
Data Type Conversion Functions Convert Signed Integer Data to BCD-4
The Convert to BCD-4 function outputs the four-digit BCD equivalent of signed integer data. The original data is not changed by this function. Data can be converted to BCD format to drive BCD-encoded LED displays or presets to external devices such as high-speed counters. When the function receives power flow, it performs the conversion, making the result available via output Q. The function passes power flow when power is received, unless the specified conversion would result in a value that is outside the range 0 to 9999.
Enable INT_ TO BCD4 IN Q OK

Value to be converted

Output

Parameters of the Convert to BCD-4 Function


Input/ Output
enable IN OK Q

Choices
flow I, Q, M, T, G, R, AI, AQ, constant flow, none I, Q, M, T, G, R, AI, AQ

Description
When the function is enabled, the conversion is performed. IN contains a reference for the integer value to be converted to BCD-4. The OK output is energized when the function is performed without error. Output Q contains the BCD-4 form of the original value in IN.

Example
In the example, whenever input %I0002 is set and no errors exist, the integer at input location %I0017 through %I0032 is converted to four BCD digits, and the result is stored in memory locations %Q0033 through %Q0048. Coil %Q1432 is used to check for successful conversion.
%I0002 INT_ TO BCD4 %I0017 IN Q %Q0033 %Q1432

10-42

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Data Type Conversion Functions Convert to Signed Integer
The Convert to Signed Integer function outputs the integer equivalent of BCD-4 or Real data. The original data is not changed by this function. When the function receives power flow, it performs the conversion, making the result available via output Q. The function always passes power flow when power is received, unless the data is out of range.
Enable BCD4_ TO_ INT IN Q OK

Value to be converted

Output

Parameters of the Convert to Signed Integer Function


Input/ Output
enable IN

Choices
flow For BCD-4: I, Q, M, T, G, R, AI, AQ, constant For REAL: R, AI, AQ flow, none

Description
When the function is enabled, the conversion is performed. IN contains a reference for the BCD-4, REAL, or Constant value to be converted to integer. The OK output is energized whenever enable is energized, unless the data is out of range or NaN (Not a Number). Output Q contains the integer form of the original value in IN.

ok

I, Q, M, T, G, R, AI, AQ

Example
In the example, whenever input %I0002 is set, the BCD-4 value in PARTS is converted to a signed integer and passed to the Addition function, where it is added to the signed integer value represented by the reference RUNNING. The sum is output by the Addition function to the reference TOTAL.
%I0002 BCD4 TO INT PARTS IN Q %R0001 %R0001 RUNNING ADD_ INT IN1 Q IN2 TOTAL

GFK-1503D

Chapter 10 Instruction Set Reference

10-43

10
Data Type Conversion Functions Convert to Double Precision Signed Integer
The Convert to Double Precision Signed Integer function outputs the double precision signed integer equivalent of real data. The original data is not changed by this function. When the function receives power flow, it performs the conversion, making the result available via output Q. The function always passes power flow when power is received, unless the real value is out of range.
Enable REAL TO_ DINT IN Q OK

Value to be converted

Output

Note that loss of precision can occur when converting from Real-type data to DoublePrecision Integer, because Real data has 24 significant bits.

Parameters of the Convert to Double Precision Signed Integer Function


Input/ Output
enable IN ok Q

Choices
flow I, Q, M, T, G, R, AI, AQ, constant flow, none R, AI, AQ

Description
When the function is enabled, the conversion is performed. Constant or reference for the value to be converted OK is energized whenever enable is energized, unless the real value is out of range. Reference that contains the double precision signed integer form of the original value.

Example
In the example, whenever input %I0002 is set, the integer value at input location %I0017 is converted to a double precision signed integer and the result is placed in location %R0001. The output %Q1001 is set whenever the function executes successfully.
%I0002 INT_ TO DINT %I0017 IN Q %R0001 %Q1001

10-44

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Data Type Conversion Functions Convert to Real Data
The Convert to Real function outputs the real value equivalent of the input data. The original data is not changed by this function. When the function receives power flow, it performs the conversion, making the result available via output Q. The function passes power flow when power is received, unless the specified conversion would result in a value that is out of range. Note that loss of precision can occur when converting from Double-Precision Integer to Real data, because since the number of significant bits is reduced to 24.
Enable INT_ TO REAL IN Q OK

Value to be converted

Output

Parameters of the Convert to Real Function


Input/ Output
enable IN ok Q

Choices
flow

Description
When the function is enabled, the conversion is performed.

IN contains a reference for the integer value to be converted to R, AI, AQ, constant For INT only: I, Q, M, T, G Real. flow, none R, AI, AQ OK is energized when the function is performed without error. The Real form of the original value in IN.

Example
In the example, the integer value of input IN is 678. The result value placed in %T0016 is 678.000.
%I0002 INT_ TO REAL %T0001 IN Q %R0016

GFK-1503D

Chapter 10 Instruction Set Reference

10-45

10
Data Type Conversion Functions Convert Real Data to Word Data
The Convert to Word function outputs the Word equivalent of Real data. The original data is not changed by this function. When the function receives power flow, it performs the conversion, making the result available via output Q. The function passes power flow when power is received, unless the specified conversion would result in a value that is outside the range 0 to FFFFh.
Enable REAL TO WORD IN Q OK

Value to be converted

Output

Parameters of the Convert to Word Function


Input/ Output
enable IN ok Q

Choices
flow R, AI, AQ, constant flow, none I, Q, M, T, G, R, AI, AQ

Description
When the function is enabled, the conversion is performed. IN contains a reference for the value to be converted to Word type. OK is energized when the function is performed without error. Contains the word form of the original value in IN.

Example
%I0002 REAL TO WORD %R0001 IN Q %R0003 HI_LIM LOW_LIM RANGE WORD %Q1001 L1 Q L2 IN

%R0003

10-46

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Data Type Conversion Functions Truncate Real Number
The Truncate function copies a Real number and rounds the copied number down to an integer or double precision integer. The original data is not changed by this function. When the function receives power flow, it performs the conversion, making the result available via output Q. The function passes power flow when power is received, unless the specified conversion would result in a value that is out of range or unless IN is not a number.
Enable REAL TRUN_ INT IN Q OK

Value to be converted

Output

Parameters of the Truncate Function


Input/ Output
enable IN ok Q

Choices
flow R, AI, AQ, constant flow, none

Description
When the function is enabled, the conversion is performed. IN contains a reference for the real value to be truncated. The OK output is energized when the function is performed without error, unless the value is out of range or IN is NaN.

R, AI, AQ Q contains the truncated INT or DINT value of the original For integer only: I, Q, M, T, value in IN. G

Example
In the example, the displayed constant is truncated and the integer result 562 is placed in %T0001.
%I0002 REAL TRUN_ INT CONST 5.62987E+02 IN Q OK

%T0001

GFK-1503D

Chapter 10 Instruction Set Reference

10-47

10 Math and Numerical Functions


This section describes the Math and Numerical functions of the Instruction Set:

Standard Math Functions: Addition, Subtraction, Multiplication, Division Modulo Division Scaling Function Square Root Trigonometric functions Logarithmic/Expontial functions Convert to Degrees Convert to Radians

Converting Data for the Math and Numerical Functions


The program may need to include logic to convert data to a different type before using a Math or Numerical function. The description of each function includes information about appropriate data types. The section Data Type Conversion Functions explains how to convert data to a different type.

10-48

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Math and Numerical Functions Add, Subtract, Multiply, Divide
The standard math functions are Addition, Subtraction, Multiplication, and Division. The Division function rounds down; it does not round to the closest integer. (For example, 24 DIV 5 = 4.) When a math function receives power flow, the operation is performed on input parameters I1 and I2. Parameters I1, I2, and output Q must be the same data type.
Enable Input 1 Input 2 ADD_ INT I1 Q I2 OK Output

The math functions pass power if there is no math overflow. If an overflow occurs, the result is the largest value with the proper sign and no power flow.

Parameters of the Standard Math Functions


Input/ Output
enable I1

Choices
flow All data types: R, AI, AQ, constant INT data type only: I, Q, M, T, G All data types: R, AI, AQ, constant INT data type only: I, Q, M, T, G flow, none All data types: R, AI, AQ INT only: I, Q, M, T, G

Description
When the function is enabled, the operation is performed. I1 contains a constant or reference for the first value used in the operation. (I1 is on the left side of the mathematical expression, as in I1 + I2). Range for constants in double-precision signed integer operations is minimum/maximum DINT. I2 contains a constant or reference for the second value used in the operation. (I2 is on the right side of the mathematical expression, as in I1 + I2). Range for constants in double-precision signed integer operations is minimum/maximum DINT. The OK output is energized when the function is performed without overflow, unless an invalid operation occurs. Output Q contains the result of the operation.

I2

ok Q

Data Types for Standard Math Functions


Standard math functions operate on these types of data:
INT DINT REAL Signed integer Double precision signed integer Floating Point

The input and output parameter data types must be the same (16 bits or 32 bits).
GFK-1503D Chapter 10 Instruction Set Reference 10-49

10
Math and Numerical Functions Add, Subtract, Multiply, Divide Avoiding Overflows
Be careful to avoid overflows when using Multiplication and Division functions. If you have to convert Integer to Double-Precision Integer values, remember that the CPU uses standard 2s complement with the sign extended to the highest bit of the second word. You must check the sign of the low 16-bit word and extend it into the second 16 bit word. If the most significant bit in a 16-bit INT word is 0 (positive), move a 0 to the second word. If the most significant bit in a 16-bit word is 1 (negative), move a 1 or hex 0FFFFh to the second word. Converting from Double-Precision Integer to Integer data is easier, because the low 16bit word (first register) is the integer portion of a Double-Precision Integer 32-bit word. The upper 16 bits or second word should be either a 0 (positive) or 1 (negative) value or the Double-Precision Integer number will be too big to convert to 16 bits.

Example
This example uses the Addition and Subtraction functions to keep track of the number of parts in a temporary storage area. Each time a part enters the storage area, power flows through relay %I0004 to a positive transition coil with reference %M0001. Relay %M0001 then enables the Addition function, adding the (constant) value 1 to the current total value in %R0201. Each time a part leaves the storage area, power flows through relay %I0005 to a positive transition coil with reference %M0002. Relay %M0002 then enables the Subtraction function, subtracting the (constant) value 1 from the current total value in %R0201.
%I0004 %M0001

%I0005 %M0001 ADD_ INT %R0201 CONST +00001 %M0002 SUB_ INT %R0201 CONST +00001 I1 Q I2 %R0201 I1 Q I2 %R0201

%M0002

10-50

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Math and Numerical Functions Modulo Division
The Modulo Division function divides one value by another of the same data type, to obtain the remainder. The sign of the result is always the same as the sign of input parameter I1. The Modulo function operates on these types of data:
INT DINT Signed integer Double precision signed integer

When the function receives power flow, it divides input I1 by input I2. These parameters must be the same data type. Output Q is calculated using the formula:
Q = I1-((I1 DIV I2) * I2)

The division produces an integer. Q is the same data type as inputs I1 and I2. OK is always ON when the function receives power flow, unless there is an attempt to divide by zero. In that case, it is set OFF.
Enable Input 1 Input 2 MOD_ INT I1 Q I2 OK Output

Parameters of the Modulo Division Function


Input/ Output
enable I1

Choices
flow All data types: R, AI, AQ, constant INT data type only: I, Q, M, T, G All data types: R, AI, AQ, constant INT data type only: I, Q, M, T, G flow, none All data types: R, AI, AQ INT data type only: I, Q, M, T, G

Description
When the function is enabled, the operation is performed. I1 contains a constant or reference for the value to be divided by I2. Range for constants in double precision signed integer operations is minimum/maximum DINT. I2 contains a constant or reference for the value to be divided into I1. Range for constants in double precision signed integer operations is minimum/maximum DINT. The OK output is energized when the function is performed without overflow. Output Q contains the result of dividing I1 by I2 to obtain a remainder.

I2

ok Q

Example
In the example, the remainder of the integer division of BOXES into PALLETS is placed into NT_FULL whenever %I0001 is ON.
%I0001 PALLETS -00017 BOXES +0006 MOD_ INT I1 Q I2 NT_FULL -0005

GFK-1503D

Chapter 10 Instruction Set Reference

10-51

10
Math and Numerical Functions Scaling
The Scaling function scales an input parameter and places the result in an output location. For integer-type data, all parameters must be integer-based (signed). For wordtype data, all parameters must be word-based (unsigned).
Enable Max. Input Value Min. Input Value Max. Output Value Min. Output Value Input SCALE_ INT IHI OUT ILO OHI OLO IN OK Output

Parameters of the Scaling Function


Input/ Output
enable IHI ILO OHI OLO IN ok OUT

Choices
flow R ,AI, AQ, constant R ,AI, AQ, constant R, AI, AQ, constant flow, none R, AI, AQ

Description
When the function is enabled, the operation is performed. IHI and ILO contain a constant or reference for the upper and lower limits of the unscaled data. These limits, together with the values for OHI and OLO, are used to calculate the scaling factor that will be applied to the input value IN. OHI and OLO contain a constant or reference for the upper and lower limits of the scaled data. IN contains a constant or reference for the actual value to be scaled. The OK output is energized when the function is performed without overflow. Output OUTcontains the scaled equivalent of the input value.

Example
In the example, the registers %R0120 through %R0123 are used to store the high and low scaling values. The input value to be scaled is analog input %AI0017. The scaled output data is used to control analog output %AQ0017. The scaling is performed whenever %I0001 is ON.
%I0001
SCALE_ INT IHI OUT ILO OHI OLO IN OK %AQ0017

%R0120 %R0121 %R0122 %R0123 %AI0017

10-52

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Math and Numerical Functions Square Root
The Square Root function finds the square root of a value. When the function receives power flow, the value of output Q is set to the integer portion of the square root of the input IN. The output Q must be the same data type as IN. The Square Root function operates on these types of data:
INT DINT REAL Signed integer Double precision signed integer Floating Point

OK is set ON if the function is performed without overflow, unless one of these invalid REAL operations occurs:

IN < 0 IN is NaN (Not a Number)


Enable SQROOT INT OK

Otherwise, OK is set OFF.

Input

Output

Parameters of the Square Root Function


Input/ Output
enable IN

Choices
flow All data types: R, AI, AQ, constant INT data type only: I, Q, M, T, G flow, none All data types: R, AI, AQ INT data type only: I, Q, M, T, G

Description
When the function is enabled, the operation is performed. A constant or reference for the value whose square root is to be calculated. If IN is less than zero, the function will not pass power flow. Range for constants is minimum/maximum DINT for double-precision signed integer operations. The OK output is energized when the function is performed without overflow, unless an invalid operation occurs. Output Q contains the square root of IN.

ok Q

Example
In the example, the square root of the integer number located at %AI001 is placed into the result located at %R0003 whenever %I0001 is ON.
%I0001 SQROOT INT %AI001 IN Q %R0003

GFK-1503D

Chapter 10 Instruction Set Reference

10-53

10
Math and Numerical Functions Trigonometric Functions
There are six Trigonometric functions: Sine, Cosine, Tangent, Inverse Sine, Inverse Cosine, and Inverse Tangent.

Sine, Cosine, and Tangent


When a Sine, Cosine, or Tangent function receives power flow, it operates on IN, whose units are radians, and stores the result in output Q. Both IN and Q are floating-point values.
Enable Input SIN_ REAL IN Q OK Output

The Sine, Cosine, and Tangent functions accept a broad range of input values, where
263 < IN <+263, (263 = 9.22x1018)

Inverse Sine, Cosine, and Tangent


When an Inverse Sine, Cosine, or Tangent function receives power flow, it operates on IN and stores the result in output Q, whose units are radians. Both IN and Q are floating-point values. The Inverse Sine and Cosine functions accept a narrow range of input values, where -1 < IN < 1. Given a valid value for the IN parameter, the Inverse Sine Real function produces a result Q such that:
ASIN (IN)

< Q <

The Inverse Cosine Real function produces a result Q such that:


ACOS (IN)

< Q <

The Inverse Tangent function accepts the broadest range of input values, where IN + . Given a valid value for the IN parameter, the Inverse Tangent Real function produces a result Q such that: ATAN (IN) = < Q <
2 2

10-54

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Math and Numerical Functions Trigonometric Functions
Parameters of the Trigonometric Functions
Input/ Output
enable IN ok

Choices
flow R, AI, AQ, constant flow, none

Description
When the function is enabled, the operation is performed. IN contains the constant or reference real value to be operated on. OK is energized when the function is performed without overflow, unless an invalid operation occurs and/or IN is NaN. Output Q contains the trigonometric value of IN.

R, AI, AQ

Example
In the example, the Cosine of the value in %R0001 is placed in %R0033.
COS_ REAL %R0001 IN Q +3.141500 %R0033 -1.000000

GFK-1503D

Chapter 10 Instruction Set Reference

10-55

10
Math and Numerical Functions Logarithmic / Exponential Functions
When a Logarithmic or Exponential function receives power flow, it performs the appropriate logarithmic/exponential operation on the Real value in input IN and places the result in output Q.

For the Base 10 Logarithm (LOG) function, the base 10 logarithm of IN is placed in Q. For the Natural Logarithm (LN) function, the natural logarithm of IN is placed in Q. For the Power of E (EXP) function, e is raised to the power specified by IN and the result is placed in Q. For the Power of X (EXPT) function, the value of input I1 is raised to the power specified by the value I2 and the result is placed in output Q. (The EXPT function has three input parameters and two output parameters.)

The OK output receives power flow unless the input is NaN (Not a Number) or is negative.
Enable Input LOG_ REAL IN Q OK Output Enable Input 1 Input 2 EXPT_ REAL I1 Q I2 OK Output

Parameters of the Logarithmic/Exponential Functions


Input/ Output
enable IN or I1, I2 ok Q

Choices
flow R, AI, AQ, constant flow, none R, AI, AQ

Description
When the function is enabled, the operation is performed. For EXP, LOG, and LN, IN contains the real value to be operated on. The EXPT function has two inputs, I1 and I2. For EXPT, I1 is the base value and I2 is the exponent. OK is energized when the function is performed without overflow, unless an invalid operation occurs and/or IN is NaN or is negative. Output Q contains the logarithmic/exponential value of IN.

Example of the EXPT Function


In the example, the value of %AI001 is raised to the power of 2.5 and the result is placed in %R0001.
EXPT_ REAL %AI001 CONST 2.50000E+00 I1 Q I2 %R0001

10-56

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Math and Numerical Functions Radian Conversion Functions
When Degree/Radian Conversion function receives power flow, the appropriate conversion (radians to degrees or degrees to radians) is performed on the Real value in input IN and the result is placed in output Q. The OK output will receive power flow unless IN is NaN (Not a Number).
Enable RAD_ TO DEG IN Q OK

Input

Output

Parameters of the Radian Conversion Function


Input/ Output
enable IN ok Q

Choices
flow R, AI, AQ, constant flow, none R, AI, AQ

Description
When the function is enabled, the operation is performed. IN contains the real value to be operated on. The OK output is energized when the function is performed without overflow, unless IN is NaN. Output Q contains the converted value of IN.

Example
In the example, +1500 is converted to DEG and is placed in %R0001.

RAD_ TO DEG CONST +1500.000 IN Q %R0001 85943.67

GFK-1503D

Chapter 10 Instruction Set Reference

10-57

10 Relational Functions
The Relational functions can be used to compare two numbers and to determine whether a number lies within a specified range.

Equal Not Equal Greater Than Greater Than or Equal Less Than Less Than or Equal Range

Test two numbers for equality Test two numbers for non-equality Test whether one number is greater than another Test whether one number is greater than or equal to another Test whether one number is less than another Test whether one number is less than or equal to another Tests whether one number lies between two other numbers

When the function receives power flow, it compares input IN1 to input IN2. These parameters must be the same data type.
Enable Input 1 Input 2 EQ_ INT I1 Q I2 Output

If inputs IN1 and IN2 match the specified relational condition, output Q receives power flow and is set ON (1); otherwise, it is set OFF (0).

Data Types for Relational Functions


Relational functions operate on these types of data:
INT DINT REAL Signed integer Double precision signed integer Floating Point

The %S0020 bit is set ON when a relational function using Real data executes successfully. It is cleared when either input is NaN (Not a Number).

10-58

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Relational Functions Equal, Not Equal, Less Than, Less/Equal, Greater Than, Greater/Equal Parameters for the Relational Functions
Input/ Output
enable IN1

Choices
flow R, AI, AQ, constant For INT data only: I, Q, M, T, G R, AI, AQ, constant For INT data only: I, Q, M, T, G flow, none

Description
When the function is enabled, the operation is performed. IN1 contains a constant or reference for the first value to be compared. IN1 must be a valid number. Constants must be integers for double precision signed integer operations. IN1 is on the left side of the relational equation, as in IN1 < IN2. IN2 contains a constant or reference for the second value to be compared. IN2 must be a valid number. Constants must be integers for double precision signed integer operations. IN2 is on the right side of the relational equation, as in IN1 < IN2. Output Q is energized when IN1 and IN2 match the specified relation.

IN2

Example
In the example, two double precision signed integers are tested for equality. When the relay %I0001 passes power flow to the LE (Less or Equal) function, the value presently in the reference nicknamed PWR_MDE is compared to the value presently in the reference BIN_FUL. If the value in PWR_MDE is less than or equal to the value in BIN_FUL, coil %Q0002 is turned on.
%I0001 LE_ INT PWR_MDE BIN_FUL IN1 Q IN2 %Q0002

GFK-1503D

Chapter 10 Instruction Set Reference

10-59

10
Relational Functions Range
The Range function determines if a value is within the range of two numbers.

Data Types for the Range Function


The Range function operates on these types of data:
INT DINT WORD Signed integer (default). Double precision signed integer. Word data type.

When the Range function is enabled, it compares the value of input IN against the range specified by limits L1 and L2. Either L1 or L2 can be the high or low limit. When the value is within the range specified by L1 and L2, inclusive, output parameter Q is set ON (1). Otherwise, Q is set OFF (0).
Enable Limit 1 Limit 2 Value to be compared RANGE INT L1 Q L2 IN Output

Parameters for the Range Function


Input/ Output
enable L1

Choices
flow

Description
When the function is enabled, the operation is performed.

R, AI, AQ, constant L1 contains the start point of the range. INT and WORD only: I, Constants must be integer values for double precision signed Q, M, T, G integer operations. R, AI, AQ, constant L2 contains the end point of the range. INT and WORD only: I, Constants must be integer values for double precision signed Q, M, T, G integer operations. R, AI, AQ IN contains the value to be compared against the range INT and WORD only: I, specified by L1 and L2. Q, M, T, G flow, none Output Q is energized when the value in IN is within the range specified by L1 and L2, inclusive.

L2

IN

10-60

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Relational Functions Range Example
In this example, when the Range function receives power flow from relay %I0001, the function determines whether the value in %AI001 is within the range 0 to 100. %R0001 contains the value 100. %R2 contains the value 0.
%I0001 RANGE INT %R0001 %R0002 %AI001 L1 Q L2 IN %Q0001

Output coil %Q0001 is On only if the value presently in %AI0001 is within the range 0 to 100.
IN Value %AI001 <0 0 100 > 100 Q State %Q0001 OFF ON OFF

GFK-1503D

Chapter 10 Instruction Set Reference

10-61

10 Relay Functions
Normally Open Contact | | Normally Closed Contact |/| Normally Open Coil ( ) Retentive SET Coil (SM) Retentive RESET Coil (RM) Negated Retentive Coil (/M) Negated Coil (/) Retentive Coil (M) SET Coil (S) RESET Coil (R) Positive Transition Coil () Negative Transition Coil () Vertical Link vert | Horizontal Link horz Continuation Coil <+> Continuation Contact <+>

Each relay contact and coil has one input and one output. Together, they provide logic flow through the contact or coil.

Input

----| |----

Output

10-62

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Relay Functions Normally-open, Normally-closed, Continuation Contacts
A contact is used to monitor the state of a reference. Whether the contact passes power flow depends on the state or status of the reference being monitored and on the contact type. A reference is ON if its state is 1; it is OFF if its state is 0. Type of Contact
Normally Open Normally Closed Continuation Contact

Display
-| |-|/|<+>---

Contact Passes Power to Right:


When reference is ON. When reference is OFF. If the preceding continuation coil is set ON.

Normally Open Contact -| |A normally open contact acts as a switch that passes power flow if the associated reference is ON (1).

Normally Closed Contact -|/|A normally closed contact acts as a switch that passes power flow if the associated reference is OFF (0).

Example
The example shows a rung with 10 elements having nicknames from E1 to E10. Coil E10 is ON when reference E1, E2, E5, E6, and E9 are ON and references E3, E4, E7, and E8 are OFF.
E1 E2 E3 E4 E5 E6 E7 E8 E9 E10

Continuation Coils and Contacts


Continuation coils and continuation contacts are used to continue relay ladder rung logic beyond the last column. The state of the last executed continuation coil is the flow state used on the next executed continuation contact. If the flow of logic does not execute a continuation coil before it executes a continuation contact, the state of the contact is no flow. There can be only one continuation coil and contact per rung; the continuation contact must be in column 1, and the continuation coil must be in the last column.

GFK-1503D

Chapter 10 Instruction Set Reference

10-63

10
Relay Functions Coils
Coils are used to control discrete references. Conditional logic must be used to control the flow of power to a coil. Coils cause action directly; they do not pass power flow to the right. If additional logic in the program should be executed as a result of the coil condition, an internal reference for the coil, or a continuation coil/contact combination may be used. Coils are always located at the rightmost position of a line of logic:

References and Coil Checking


When the level of coil checking is set to single, you can use a specific %M or %Q reference with only one Coil, but you can use it with one Set Coil and one Reset Coil simultaneously. When the level of coil checking is warn multiple or multiple, each reference can be used with multiple Coils, Set Coils, and Reset Coils. With multiple usage, a reference could be turned On by either a Set Coil or a normal Coil and could be turned Off by a Reset Coil or by a normal Coil.

Power Flow and Retentiveness


The following table summarizes how power flow to different types of coils affects their reference. The states of retentive coils are saved when power is cycled or when the PLC goes from Stop to Run mode. The states of non-retentive coils are set to zero when power is cycled or the PLC goes from Stop to Run mode. Type of Coil Symbol Power to Coil Result
Normally Open Negated Retentive Negated Retentive Positive Transition Negative Transition SET RESET Retentive SET Retentive RESET Continuation Coil -( )-(/)-(M)-(/M)-(P)-(N)-(S)-(R)-(SM)-(RM)----<+> ON OFF ON OFF ON OFF ON OFF OFFON ONOFF ON OFF ON OFF ON OFF ON OFF ON OFF Sets reference ON, non-retentive. Sets reference OFF, non-retentive. Sets reference OFF, non-retentive. Sets reference ON, non-retentive. Sets reference ON, retentive. Sets reference OFF, retentive. Sets reference OFF, retentive. Sets reference ON, retentive. If power flow into the coil was OFF the previous sweep and is ON this sweep, sets the coil ON. If power flow into the coil was ON the previous sweep and is OFF this sweep, sets the coil ON. Sets reference ON until reset OFF by ( R ), non-retentive. Does not change the coil state, non-retentive. Sets reference OFF until set ON by (S), non-retentive. Does not change the coil state, non-retentive. Sets reference ON until reset OFF by (RM), retentive. Does not change the coil state. Sets reference OFF until set ON by (SM)-, retentive. Does not change the coil state. Sets next continuation contact ON. Sets next continuation contact OFF.

10-64

VersaMax PLC Users Manual January 2006

GFK-1503D

10

Relay Functions Coils


A coil sets a discrete reference ON while it receives power flow. It is non-retentive; therefore, it cannot be used with system status references (%SA, %SB, %SC, or %G).

Example
In the example, coil E3 is ON when reference E1 is ON and reference E2 is OFF.
E1 E2 E3

Negated Coil
A negated coil sets a discrete reference ON when it does not receive power flow. It is not retentive, so it cannot be used with system status references (%SA, %SB, %SC, or %G).

Example
In the example, coil E3 is ON when reference E1 is OFF.
E1 E2 E2 E3

Retentive Coil
Like a normally open coil, the retentive coil sets a discrete reference ON while it receives power flow. The state of the retentive coil is retained across power failure. Therefore, it cannot be used with references from strictly non-retentive memory (%T).

Negated Retentive Coil


The negated retentive coil sets a discrete reference ON when it does not receive power flow. The state of the negated retentive coil is retained across power failure. Therefore, it cannot be used with references from strictly non-retentive memory (%T).

GFK-1503D

Chapter 10 Instruction Set Reference

10-65

10
Relay Functions Coils Positive Transition Coil
If the reference associated with a positive transition coil was OFF , when the coil receives power flow it is set to ON until the next time the coil is executed. (If the rung containing the coil is skipped on subsequent sweeps, it will remain ON.) This coil can be used as a one-shot. Do not write from external devices (e.g., PCM, programmer, ADS, etc.) to references used on positive transition coils since it will destroy the one-shot nature of these coils. Transitional coils can be used with references from either retentive or non-retentive memory (%Q, %M, %T, %G, %SA, %SB, or %SC).

Negative Transition Coil


If the reference associated with this coil is OFF, when the coil stops receiving power flow the reference is set to ON until the next time the coil is executed. Do not write from external devices to references used on negative transition coils since it will destroy the one-shot nature of these coils. Transitional coils can be used with references from either retentive or non-retentive memory (%Q, %M, %T, %G, %SA, %SB, or %SC).

Example
In the example, when reference E1 goes from OFF to ON, coils E2 and E3 receive power flow, turning E2 ON for one logic sweep. When E2 goes from ON to OFF, power flow is removed from E2 and E3, turning coil E3 ON for one sweep.
E1 E2 E2 (P) E3 (N)

10-66

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Relay Functions Coils SET Coil
SET and RESET are non-retentive coils that can be used to keep (latch) the state of a reference either ON or OFF. When a SET coil receives power flow, its reference stays ON (whether or not the coil itself receives power flow) until the reference is reset by another coil.

RESET Coil
The RESET coil sets a discrete reference OFF if the coil receives power flow. The reference remains OFF until the reference is set by another coil. The last-solved SET coil or RESET coil of a pair takes precedence.

Example
In the example, the coil represented by E1 is turned ON whenever reference E2 or E6 is ON. The coil represented by E1 is turned OFF whenever reference E5 or E3 is ON.
E2 E6 E5 E3 E1 R E1 S

Retentive SET Coil


Retentive SET and RESET coils are similar to SET and RESET coils, but they are retained across power failure or when the PLC transitions from to Run mode. A retentive SET coil sets a discrete reference ON if the coil receives power flow. The reference remains ON until reset by a retentive RESET coil.

Retentive RESET Coil


This coil sets a discrete reference OFF if it receives power flow. The reference remains OFF until set by a retentive SET coil. The state of this coil is retained across power failure or when the PLC transitions from Stop to Run mode.

GFK-1503D

Chapter 10 Instruction Set Reference

10-67

10 Table Functions
The Table functions are used to:

Copy array data: ARRAY MOVE Search for values in an array

The maximum length allowed for these functions is 32,767 for any type.

Data Types for the Table Functions


Table functions operate on these types of data:
INT DINT BOOL * BYTE WORD Signed integer Double precision signed integer Bit data type Byte data type Word data type

* Applies to Array Move only.

10-68

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Table Functions Array Move
The Array Move function copies a specified number of elements from a source array to a destination array. When the function receives power flow, it copies the number of elements specified from the input array, starting at the indexed location. The function then writes the copied elements to the output array starting with the indexed location. For bit data, when word-oriented memory is selected for the parameters of the source array and/or destination array starting address, the least significant bit of the specified word is the first bit of the array. The indices in an Array Move instruction are 1-based. In using an Array Move, no element outside either the source or destination arrays (as specified by their starting address and length) may be referenced. The OK output receives power flow unless one of the following occurs:

Enable is OFF. (N + SNX 1) is greater than (length). (N + DNX 1) is greater than (length).
Enable Source array address Source array index Destination array index (elements to transfer) ARRAY MOVE_ BOOL SR DS SNX DNX N OK Destination array address

Parameters for the Array Move Function


Input/ Output
enable SR

Choices
flow For all: R, AI, AQ For INT, BIT, BYTE, WORD: I, Q, M, T, G, For BIT, BYTE, WORD: SA, SB, SC I, Q, M, T, G, R, AI, AQ, constant I, Q, M, T, G, R, AI, AQ, constant I, Q, M, T, G, R, AI, AQ, constant flow, none For all: SA, SB, SC, R, AI, AQ For INT, BIT, BYTE, WORD: I, Q, M, T, G

Description
When the function is enabled, the operation is performed. SR contains the starting address of the source array. For ARRAY_MOVE_ BOOL, any reference may be used; it does not need to be byte aligned. SNX contains the index of the source array. DNX contains the index of the destination array. N provides a count indicator. OK is energized whenever enable is energized. The starting address of the destination array. For ARRAY_MOVE_ BOOL, any reference may be used; it does not need to be byte aligned. The number of elements starting at SR and DS that make up each array. It is defined as the length of SR+DS.
10-69

SNX DNX N ok DS length

GFK-1503D

Chapter 10 Instruction Set Reference

10
Table Functions Array Move
Example 1:
In this example, if %R100=3 then %R0003 - %R0007 of the array %R0001 - %R0016 is read and is written into %R0104 - %R0108 of the array %R0100 - %R0115. (%R001 and %R0100 are declared as type WORD of length 16.)
%I0001 ARRAY MOVE_ WORD R DS %R0100

%R0001 %R0100 CONST 00005 CONST 00005

SNX DNX N

Example 2:
Using bit memory for SR and DS, %M0011 - %M0017 of the array %M0009 - %M0024 is read and then written to %Q0026 - %Q0032 of the array %Q0022 - %Q0037. (%M009 and %Q0022 are declared as type BOOL of length 16).
%I0001 ARRAY MOVE_ BOOL SR DS SNX DNX N %Q0022

%M0009 CONST 00003 CONST 00005 CONST 00007

Example 3:
Using word memory, for SR and DS, the third least significant bit of %R0001 through the second least significant bit of %R0002 of the array containing all 16 bits of %R0001 and four bits of %R0002 is read and then written into the fifth least significant bit of %R0100 through the fourth least significant bit of %R0101 of the array containing all 16 bits of %R0100 and four bits of %R0101. 0001 and %R0100 are declared as type BOOL of length 20).
%I0001 ARRAY MOVE_ BOOL SR DS SNX DNX N %R0100

%R0001 CONST 00003 CONST 00005 CONST 00016

10-70

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Table Functions Search for Array Values
Use the Search functions listed below to search for values in an array.

Search Equal Search Not Equal Search Greater Than Search Greater Than or Equal Search Less Than Search Less Than or Equal

Equal to a specified value. Not equal to a specified value. Greater than a specified value. Greater than or equal to a specified value. Less than a specified value. Less than or equal to a specified value.

When the Search function receives power, it searches the specified array. Searching begins at the starting address (AR) plus the index value (NX).
enable Starting address Input index Object of search SRCH_ EQ_ INT AR FD NX NX IN Found indication Output index

The search continues until the array element of the search object (IN) is found or until the end of the array is reached. If an array element is found, the Found Indication (FD) is set ON and the Output Index (output NX) is set to the relative position of this element within the array. If no array element is found before the end of the array is reached, the Found Indication (FD) is set OFF and the Output Index (output NX) is set to zero. Valid values for input NX are 0 to (length)- 1. NX should be set to zero to begin searching at the first element. This value increments by one at the time of execution. Therefore, the values of output NX are 1 to (length). If the value of input NX is out-of-range, (< 0 or > length), its value defaults to zero.

Parameters of the Search Functions


Input/ Output enable AR Input NX IN Output NX FD length Choices Description flow When the function is enabled, the search is performed. For all: R, AI, AQ Contains the starting address of the array. For INT, BYTE, WORD: I, Q, M, T, G, For BYTE, WORD: S I, Q, M, T, G, R, AI, AQ, constant Contains the zero-based index into the array at which to begin the search. For all: R, AI, AQ, constant IN contains the object of the search. For INT, BYTE, WORD: I, Q, M, T, G, For BYTE, WORD: S I, Q, M, T, G, R, AI, AQ Holds the one-based position within the array of the search target. flow, none FD indicates that an array element has been found and the function was successful. 1 to 32,767 bytes or words. The number of elements starting at AR that make up the array to be searched.

GFK-1503D

Chapter 10 Instruction Set Reference

10-71

10
Table Functions Search for Array Values
Example 1:
The array AR is defined as memory addresses %R0001 - %R0005. When EN is ON, the portion of the array between %R0004 and %R0005 is searched for an element whose value is equal to IN. If %R0001 = 7, %R0002 = 9, %R0003 = 6, %R0004 = 7, %R0005 = 7, and %R0100 = 7, then the search will begin at %R0004 and conclude at %R0004 when FD is set ON and a 4 is written to %R0101.
%I0001 SRCH_ EQ__ INT AR FD NX NX IN %R0101

%R0001 CONST 00003 %R0100

%Q0001 ( )

Example 2:
Array AR is defined as memory addresses %AI001 - %AI016. The values of the array elements are 100, 20, 0, 5, 90, 200, 0, 79, 102, 80, 24, 34, 987, 8, 0, and 500. Initially, %AQ001 is 5. When EN is ON, each sweep will search the array looking for a match to the IN value of 0. The first sweep will start searching at %AI006 and find a match at %AI007, so FD is ON and %AQ001 is 7. The second sweep will start searching at %AI008 and find a match at %AI015, so FD remains ON and %AQ001 is 15. The next sweep will start at %AI016. Since the end of the array is reached without a match, FD is set OFF and %AQ001 is set to zero. The next sweep will start searching at the beginning of the array.
%I0001 SRCH_ EQ__ INT AR FD NX NX IN %AQ001

%AI001 %AQ001 00005 CONST

%M001 ( )

10-72

VersaMax PLC Users Manual January 2006

GFK-1503D

10 Timer and Counter Functions


This section describes the timing and counting functions of the Instruction Set. The data associated with these functions is retentive through power cycles.


Time-Tick Contacts

On-Delay Stopwatch Timer Off-Delay Timer On-Delay Timer Up Counter Down Counter

In addition to the Timer functions of the Instruction Set, the VersaMax PLC has four time-tick contacts. These contacts can be used to provide regular pulses of power flow to other program functions. The four time-tick contacts have time durations of 0.01 second, 0.1 second, 1.0 second, and 1 minute. The state of these contacts does not change during the execution of the sweep. These contacts provide a pulse having an equal on and off time duration. The contacts are referenced as T_10MS (0.01 second), T_100MS (0.1 second), T_SEC (1.0 second), and T_MIN (1 minute). The following timing diagram represents the on/off time duration of these contacts.
X SEC

T XXXXX

X/2 SEC

X/2 SEC

These time-tick contacts represent specific locations in %S memory.

GFK-1503D

Chapter 10 Instruction Set Reference

10-73

10
Timer and Counter Functions Function Block Data Required for Timers and Counters
Each timer or counter uses three words (registers) of %R memory to store the following information:
current value (CV) preset value (PV) control word word 1 word 2 word 3

When you enter a timer or counter, you must enter a beginning address for these three words (registers). Do not use consecutive registers for the 3 word timer/counter blocks. Timers and counters will not work if you place the current value of a block on top of the preset for the previous block.
Enable Reset Preset Value
DNCTR

time

(Q)

R PV

Address

The control word stores the state of the boolean inputs and outputs of its associated function block in the following format:
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Reserved Reset input Enable input, previous execution Q (counter/timer status output) EN (enable input)

Bits 0 through 11 are used for timer accuracy; not for counters. If the Preset Value (PV) is not a constant, PV is normally set to a different location than the second word. Some applications use the second word address for the PV, such as using %R0102 when the bottom data block starts at %R0101. It is then possible to change the Preset Value while the timer or counter is running. The first (CV) and third (Control) words can be read but should not be written, or the function will not work.

10-74

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Timer and Counter Functions On Delay Stopwatch Timer
A retentive On-Delay Stopwatch Timer (ONDTR) increments while it receives power flow and holds its value when power flow stops. Time may be counted in tenths (0.1), hundredths (0.01), or thousandths (0.001) of a second. The range is 0 to +32,767 time units. The state of this timer is retentive on power failure; no automatic initialization occurs at power-up. When this function first receives power flow, it starts accumulating time (current value). When this timer is encountered in the ladder logic, its Current Value is updated.
Enable Reset Preset Value ONDTR 1.00s R PV Address (Q)

Current Value

When the Current Value equals or exceeds the Preset Value PV, output Q is energized. As long as the timer continues to receive power flow, it continues accumulating until the maximum value is reached. Once the maximum value is reached, it is retained and output Q remains energized regardless of the state of the enable input. If multiple occurrences of the same timer with the same reference address are enabled during a CPU sweep, the current values of the timers will be the same.

Parameters of the On Delay Stopwatch Timer Function


Input/ Output
address

Choices
R

Description
The function uses three consecutive words (registers) of %R memory to store the following: Current value (CV) =word 1. Preset value (PV) = word 2. Control word = word 3. Do not use this address with other instructions. Careful: Overlapping references cause erratic timer operation. When enable receives power flow, the timers Current Value increments. When R receives power flow, it resets the Current Value to zero. The Preset Value, which is used when the timer is enabled or reset. Output Q is energized when the current value of the timer is greater than or equal to the Preset Value. Time increment for the low bit of the PV preset and CV current value.

enable R PV Q time

flow flow I ,Q, M, T, G, R, AI, AQ, constant, none flow, none tenths, hundredths, or thousandths of seconds

GFK-1503D

Chapter 10 Instruction Set Reference

10-75

10
Timer and Counter Functions On Delay Stopwatch Timer Operation of the On Delay Timer Function
a42931 ENABLE RESET Q A B C D E F G H

A. B. C. D. E. F. G. H.

ENABLE goes high; timer starts accumulating Current value reaches preset value PV; Q goes high RESET goes high; Q goes low, accumulated time is reset (CV=0) RESET goes low; timer then starts accumulating again ENABLE goes low; timer stops accumulating. Accumulated time stays the same ENABLE goes high again; timer continues accumulating time Current value becomes equal to preset value PV; Q goes high. Timer continues to accumulate time until ENABLE goes low, RESET goes high or current value becomes equal to the maximum time ENABLE goes low; timer stops accumulating time.

When power flow to the timer stops, the current value stops incrementing and is retained. Output Q, if energized, will remain energized. When the function receives power flow again, the current value again increments, beginning at the retained value. When reset R receives power flow, the current value is set back to zero and output Q is de-energized unless PV equals zero.

Example
In the example, a retentive on-delay timer is used to create a signal (%Q0011) that turns on 8.0 seconds after %Q0010 turns on, and turns off when %Q0010 turns off.
%Q0010 %Q0010 R CONST +00080 PV ONDTR
0.15

%Q0011

%R0004

10-76

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Timer and Counter Functions On Delay Timer
The On-Delay Timer (TMR) increments while it receives power flow and resets to zero when power flow stops. Time may be counted in tenths of a second (the default selection), hundredths of a second, or thousandths of a second. The range is 0 to +32,767 time units. The state of this timer is retentive on power failure; no automatic initialization occurs at power-up.
Enable TMR TENTHS PV (Q)

Preset Value

Current Value

Address-3 words

When the On Delay Timer function receives power flow, the timer starts accumulating time (Current Value). The Current Value is updated when it is encountered in the logic to reflect the total elapsed time the timer has been enabled since it was last reset. If multiple occurrences of the same timer with the same reference address are enabled during a CPU sweep, the Current Values of the timers will be the same. This update occurs as long as the enabling logic remains ON. When the current value equals or exceeds the Preset Value PV, the function begins passing power flow to the right. The timer continues accumulating time until the maximum value is reached. When the enabling parameter transitions from ON to OFF, the timer stops accumulating time and the Current Value is reset to zero.

Parameters for the On Delay Timer Function


Input/ Output
address

Choices
R

Description

enable PV Q time

The function uses three consecutive words (registers) of %R memory to store the following: Current value (CV) = word 1. Preset value (PV) = word 2. Control word = word 3. Do not use this address with other instructions. Careful: Overlapping references cause erratic operation of the timer. flow When enable receives power flow, the timers current value is incremented. When the TMR is not enabled, the current value is reset to zero and Q is turned off. I Q, M, T, G, R, AI, AQ, PV is the value to copy into the timers preset value when the timer is constant, none enabled or reset. flow, none Output Q is energized when TMR is enabled and the current value is greater than or equal to the preset value. tenths (0.1), hundredths Time increment for the low bit of the PV preset and CV current value. (0.01), or thousandths (0.001) of seconds

GFK-1503D

Chapter 10 Instruction Set Reference

10-77

10
Timer and Counter Functions On Delay Timer Operation of the On-Delay Timer Function
a42933 ENABLE Q A B C D E

A. B. C. D. E.

ENABLE goes high; timer begins accumulating time. Current value reaches preset value PV; Q goes high, and timer continues accumulating time. ENABLE goes low; Q goes low; timer stops accumulating time and current time is cleared. ENABLE goes high; timer starts accumulating time. ENABLE goes low before current value reaches preset value PV; Q remains low; timer stops accumulating time and is cleared to zero (CV=0).

Example
In the example, a delay timer (with address) TMRID is used to control the length of time that coil is on. This coil has been assigned the Nickname DWELL . When the normally open (momentary) contact with the Nickname DO_DWL is on, coil DWELL is energized. The contact of coil DWELL keeps coil DWELL energized (when contact DO_DWL is released), and also starts the timer TMRID. When TMRID reaches its preset value of one-half second, coil REL energizes, interrupting the latched-on condition of coil DWELL. The contact DWELL interrupts power flow to TMRID, resetting its current value and de-energizing coil REL. The circuit is then ready for another momentary activation of contact DO_DWL.
DO_DWL DWELL REL REL DWELL

DWELL

TMR
0.15

CONST +00005

PV

TMRID

10-78

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Timer and Counter Functions Off Delay Timer
The Off-Delay Timer increments while power flow is off and resets to zero when power flow is on. Time may be counted in tenths (0.1), hundredths (0.01), or thousandths (0.001) of a second. Range is 0 to +32,767 time units. The state of this timer is retentive on power failure; no automatic initialization occurs at power-up.
Enable OFDT 1.00s PV CV (Q)

Preset Value

Current Value

Address-3 words

When the Off-Delay Timer first receives power flow, it passes power to the right, and the Current Value (CV) is set to zero. The function uses word 1 [register] as its CV storage location. The output remains on as long as the function receives power flow. If the function stops receiving power flow from the left, it continues to pass power to the right, and the timer starts accumulating time in the Current Value. The Off-Delay Timer does not pass power flow if the Preset Value is zero or negative. If multiple occurrences of the same timer with the same reference address are enabled during a CPU sweep, the Current Values of the timers will be the same. Each time the function is invoked with the enabling logic set to OFF, the Current Value is updated to reflect the elapsed time since the timer was turned off. When the Current Value (CV) is equal to the Preset Value (PV), the function stops passing power flow to the right and the timer stops accumulating. When the function receives power flow again, the current value resets to zero. When this timer is used in a program block that is not called every sweep, it accumulates time between calls to the program block unless it is reset. That means it functions like a timer in a program with a much slower sweep than the timer in the main program block. For program blocks that are inactive for a long time, the timer should be programmed to allow for this catch-up. For example, if a timer in a program block is reset and the program block is inactive for four minutes, when the program block is called, four minutes of time will have accumulated. This time is applied to the timer when enabled unless the timer is first reset.

Example
In the example, an Off-Delay Timer is used to turn off an output (%Q00001) whenever an input (%I00001) turns on. The output is turned on again 0.3 seconds after the input goes off.
%I00001 OFDT
0.10

%Q00001

CONST +00003

PV CV

%R00019

GFK-1503D

Chapter 10 Instruction Set Reference

10-79

10
Timer and Counter Functions Off Delay Timer Operation of the Off-Delay Timer Function
ENABLE Q A B C D E F G H

A. B. C. D. E. F. G. H.

ENABLE and Q both go high; timer is reset (CV = 0). ENABLE goes low; timer starts accumulating time. CV reaches PV; Q goes low, and timer stops accumulating time. ENABLE goes high; timer is reset (CV = 0). ENABLE goes low; timer starts accumulating time. ENABLE goes high; timer is reset (CV = 0). ENABLE goes low; timer begins accumulating time. V reaches PV; Q goes low, and timer stops accumulating time.

Parameters of the Off-Delay Timer Function


Input/ Output
address

Choices
R

Description
The function uses three consecutive words (registers) of %R memory to store the following: Current value (CV) = word 1. Preset value (PV) = word 2. Control word = word 3. Do not use this address with other instructions. Careful: Overlapping references cause erratic operation of the timer. When enable receives power flow, the timers current value is incremented. PV is the value to copy into the timers preset value when the timer is enabled or reset. For a register (%R) OV reference, the PV parameter is specified as the second word of the address parameter. For example, an address parameter of %R0001 would use %R0002 as the PV parameter. Output Q is energized when the current value is less than the preset value. The Q state is retentive on power failure; no automatic initialization occurs at power-up.

enable PV

flow I Q, M, T, G, R, AI, AQ, constant, none

flow, none

time

tenths, hundredths, or Time increment for the low bit of the PV preset and CV current value. thousandths of seconds
VersaMax PLC Users Manual January 2006 GFK-1503D

10-80

10
Timer and Counter Functions Up Counter
The Up Counter function counts up to a designated value. The range is 0 to +32,767 counts. When the Up Counter reset is ON, the Current Value of the counter resets to 0. Each time the enable input transitions from OFF to ON, the Current Value increments by 1. The current value can be incremented past the Preset Value PV. The output is ON whenever the Current Value is greater than or equal to the Preset Value. The state of the CTU is retentive on power failure; no automatic initialization occurs at power-up.
Enable Reset Preset Value
CTU R PV

(Q)

Address

Parameters of the Up Counter Function


Input/ Output
address

Choices
R

Description
The function uses three consecutive words (registers) of %R memory to store the following: Current value (CV) = word 1. Preset value (PV) = word 2. Control word = word 3. Do not use this address with another up counter, down counter, or any other instruction or improper operation will result. Careful: Overlapping references cause erratic operation of the counter. On a positive transition of enable, the current count is incremented by one. When R receives power flow, it resets the current value back to zero.

enable R PV

flow flow

I, Q, M, T, G, R, PV is the value to copy into the counters preset value when the counter is AI, AQ, enabled or reset. constant, none flow, none Output Q is energized when the Current Value is greater than or equal to the Preset Value.

Example of the Up Counter Function


In the example, every time input %I0012 transitions from OFF to ON, up counter PRT_CNT counts up by 1; internal coil %M0001 is energized when 100 parts have been counted. When %M0001 is ON, the accumulated count is reset to zero.
%I0012 %M0001 CTU R PV %M0001

CONST +00100

PRT_CNT

GFK-1503D

Chapter 10 Instruction Set Reference

10-81

10
Timer and Counter Functions Down Counter
The Down Counter function counts down from a preset value. The minimum Preset Value is zero; the maximum present value is +32,767 counts. The minimum Current Value is 32,768. When reset, the Current Value of the counter is set to the Preset Value PV. When the enable input transitions from OFF to ON, the Current Value is decremented by one. The output is ON whenever the Current Value is less than or equal to zero. The Current Value of the Down Counter is retentive on power failure; no automatic initialization occurs at power-up.
Enable CTD Reset Preset Value
R PV

(Q)

Address

Parameters of the Down Counter Function


Input/ Output
address

Choices
R

Description
The function uses three consecutive words (registers) of %R memory to store the following: Current value (CV) = word 1. Preset value (PV) = word 2. Control word = word 3. Do not use this address with another down counter, up counter, or any other instruction or improper operation will result. Careful: Overlapping references will result in erratic counter operation.

enable R PV Q

flow flow

On a positive transition of enable, the Current Value is decremented by one. When R receives power flow, it resets the Current Value to the Preset Value.

I, Q, M, T, G, R, AI, AQ, PV is the value to copy into the counters Preset Value when the constant, none counter is enabled or reset. flow, none Output Q is energized when the Current Value is less than or equal to zero.

10-82

VersaMax PLC Users Manual January 2006

GFK-1503D

10
Timer and Counter Functions Down Counter
Example 1:
In the example, the down counter identified as COUNTP counts 500 new parts before energizing output %Q0005.
NEW_PRT NXT_BAT CONST +0500 CTD R PV COUNTP %Q0005

Example 2: Keeping Track of Parts in a Temporary Storage Area


The following example shows how the PLC can keep track of the number of parts in a temporary storage area. It uses an up/down counter pair with a shared register for the accumulated or current value. When parts enter the storage area, the up counter increases the current value of the parts in storage by 1. When a part leaves the storage area, the down counter decrements by 1, decreasing the inventory storage value by 1. The two counters use different register addresses. When a register counts, its current value must be moved to the current value register of the other counter.
%I00003 %I00001 %I00009 %I00003 %I00001 CTU R CONST +00005 MOVE_ INT %R0100 IN Q %R0104 PV %R0100

%I00003 %I00002 %I00009 %I00002 %I00003 CONST +00005 MOVE_ INT %R0104 IN Q

CTD R PV %R0104

%R0100

See the pages on Math functions for an example of using the Addition and Subtraction functions to provide storage tracking.

GFK-1503D

Chapter 10 Instruction Set Reference

10-83

10

10-84

VersaMax PLC Users Manual January 2006

GFK-1503D

Chapter

11

The Service Request Function

This chapter explains the Service Request (SVCREQ) function, which requests a special PLC service. It describes SVCREQ parameters for the VersaMax CPU.

SVCREQ Function Numbers Format of the SVCREQ Function SVCREQ 1: Change/Read Constant Sweep Timer SVCREQ 2: Read Window Times SVCREQ 3: Change Programmer Communications Window Mode SVCREQ 4: Change System Communications Window Mode SVCREQ 6: Change/Read Number of Words to Checksum SVCREQ 7: Read or Change the Time-of-Day Clock SVCREQ 8: Reset Watchdog Timer SVCREQ 9: Read Sweep Time from Beginning of Sweep SVCREQ 10: Read Folder Name SVCREQ 11: Read PLC ID SVCREQ 13: Shut Down (Stop) PLC SVCREQ 14: Clear Fault SVCREQ 15: Read Last-Logged Fault Table Entry SVCREQ 16: Read Elapsed Time Clock SVCREQ 18: Read I/O Override Status SVCREQ 23: Read Master Checksum SVCREQ 26/30: Interrogate I/O

GFK-1503D

11-1

11 SVCREQ Function Numbers


Each Service Request has its own function number, as listed in the following table. Function #
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19-22 23 26/30 27, 28 29 31-255 Read Window Times Change Programmer Communications Window Mode and Time Change System Communications Window Mode and Time reserved Change/Read Number of Words to Checksum Change/Read Time-of-Day Clock Reset Watchdog Timer Read Sweep Time from Beginning of Sweep Read Folder Name Read PLC ID reserved Shut Down the PLC Clear Fault Tables Read Last-Logged Fault Table Entry Read Elapsed Time Clock reserved Read I/O Override Status reserved Read Master Checksum Interrogate I/O reserved Read Elapsed Power Down Time reserved

Description
Change/Read Constant Sweep Timer

11-2

VersaMax PLC Users Manual January 2006

GFK-1503D

11 Format of the SVCREQ Function


The SVCREQ function has three inputs and one output.
enable Function number Beginning reference SVC_ REQ FNC PARM OK

When the SVCREQ receives power flow, the PLC is requested to perform the function number FNC indicated. Parameters for the function are located beginning at the reference given for PARM. This is the beginning of the parameter block" for the function. The number of 16-bit references required depends on the SVCREQ function being used. Parameter blocks may be used as both inputs for the function and the location where data may be output after the function executes. Therefore, data returned by the function is accessed at the same location specified for PARM. The SVCREQ function passes power flow unless an incorrect function number, incorrect parameters, or out-of-range references are specified. Specific SVCREQ functions have additional causes for failure.

Parameters of the SVCREQ Function


Input/Output enable FNC PARM ok Choices flow I, Q M, T, G, R, AI, AQ, constant I, Q M, T, G, R, AI, AQ flow, none Description When enable is energized, the service request is performed. Contains the constant or reference for the requested service. Contains the beginning reference for the parameter block for the requested service. OK is energized when the function is performed without error.

Example of the SVCREQ Function


In the example, when the enabling input %I0001 is ON, SVCREQ function number 7 is called, with the parameter block located starting at %R0001. Output coil %Q0001 is set ON if the operation succeeds.
%I0001 SVC_ REQ CONST 00007 %R0001 FNC PARM %Q0001

GFK-1503D

Chapter 11 The Service Request Function

11-3

11 SVCREQ 1: Change/Read Constant Sweep Timer


Use SVCREQ 1 to enable or disable Constant Sweep Time mode, change the length of the Constant Sweep Time, read whether Constant Sweep Time is currently enabled, or read the Constant Sweep Time length.

Input Parameter Block for SCVREQ 1


For this function, the parameter block has a length of two words.

Disable Constant Sweep Mode


To disable Constant Sweep mode, enter SVCREQ function #1 with this parameter block:
address address + 1 0 ignored

Enable Constant Sweep Mode


To enable Constant Sweep mode, enter SVCREQ function #1 with this parameter block:
address address + 1 1 0 or timer value

Note: If the timer should use a new value, enter it in the second word. If the timer value should not be changed, enter 0 in the second word. If the timer value does not already exist, entering 0 causes the function to set the OK output to OFF.

Change the Constant Sweep Time


To change the timer value without changing the selection for sweep mode state, enter SVCREQ function #1 with this parameter block:
address address + 1 2 new timer value

Read the Constant Sweep State and Time


To read the current timer state and value without changing either, enter SVCREQ function #1 with this parameter block:
address address + 1 3 ignored

11-4

VersaMax PLC Users Manual January 2006

GFK-1503D

11
Successful execution will occur, unless: 1. A number other than 0, 1, 2, or 3 is entered as the requested operation: 2. The sweep time value is greater than 500ms (0.5 seconds). 3. Constant sweep time is enabled with no timer value programmed or with an old value of 0 for the timer. After the function executes, the function returns the timer state and value in the same parameter block references:
0 = disabled address address + 1 1 = enabled current timer value

Example of SVCREQ 1
In this example, if contact OV_SWP is set, the Constant SweepTimer is read, the timer is increased by two milliseconds, and the new timer value is sent back to the PLC. The parameter block is in local memory at location %R0050. Because the MOVE and ADD functions require three horizontal contact positions, the example logic uses discrete internal coil %M00001 as a temporary location to hold the successful result of the first rung line. On any sweep in which OV_SWP is not set, %M00001 is turned off.
OV_SWP MOVE WORD CONST 00003 IN Q CONST 00001 %R0050 SVC_ REQ FNC PARM %R0051 CONST 00002 ADD_ INT I1 I2 Q %R00051 %M00001 ( )

%M00001 MOVE WORD CONST 00001 IN Q %R00050 CONST 00001 %R00050 SVC_ REQ FNC PARM

GFK-1503D

Chapter 11 The Service Request Function

11-5

11 SVCREQ 2: Read Window Times


SVCREQ 2 can be used to read the times of the programmer communications window and the system communications window. These windows can operate in Limited or Run to Completion Mode. Mode Name
Limited Mode

Value
0

Description
The execution time of the window is limited to 6ms. The window terminates when it has no more tasks to complete or after 6ms elapses. Regardless of the time assigned to a window, it runs until all tasks within that window are completed (up to 400ms).

Run to Completion Mode

A window is disabled when the time value is zero.

Output Parameter Block for SVCREQ 2


The parameter block has a length of three words:
High Byte address address + 1 address + 2 Mode Mode must be zero Low Byte Value in ms Value in ms must be zero Programmer Window System Communications Window reserved

All parameters are output parameters. It is not necessary to enter values in the parameter block to program this function.

Example of SVCREQ 2
In the following example, when enabling output %Q00102 is set, the CPU places the current time values of the windows in the parameter block starting at location %R0010.
%Q00102 SVC_ REQ CONST 00002 %R0010 FNC PARM

11-6

VersaMax PLC Users Manual January 2006

GFK-1503D

11 SVCREQ 3: Change Programmer Communications Window Mode


Use SVCREQ 3 to change the programmer communications window mode (Limited or Run-to-Completion). The change occurs during the next CPU sweep after the function is called. The time of the window cannot be changed; it is always 6ms. SVCREQ 3 passes power flow to the right unless a mode other than 0 (Limited) or 2 (Run-to-Completion) is selected. The parameter block has a length of one word.

Changing the Programmer Communications Window Mode


To change the programmer window, enter SVCREQ 3 with this parameter block:
High Byte address Mode Low Byte 6

Example of SVCREQ 3
In the following example, when enabling input %I006 goes ON, the programmer communications window is enabled and assigned a value of 6ms. The parameter block is in reference memory location %R0051.
%I0006 MOVE WORD CONST 0006 IN Q %R0051 CONST 00003 %R0051 SVC_ REQ FNC PARM

GFK-1503D

Chapter 11 The Service Request Function

11-7

11 SVCREQ 4: Change System Communications Window Mode


Use SVCREQ 4 to change the system communications window mode (Limited or Run-to-Completion). The change occurs during the next CPU sweep after the function is called. The time of the window cannot be changed; it is always 6ms. SVCREQ 4 passes power flow to the right unless a mode other than 0 (Limited) or 2 (Run-to-Completion) is selected. The parameter block has a length of one word.

Changing the System Communications Window Mode


To change the programmer window, enter SVCREQ 4 with this parameter block:
High Byte address Mode Low Byte 6

Example of SVCREQ 4
In the following example, when enabling input %I0003 is ON the system communications window is changed to Run-to-Completion mode. The parameter block is at location %R0025.
%I0003 MOVE_ WORD CONST 0200 IN Q %R0025 CONST 0004 %R0025

SVC_ REQ FNC PARM

11-8

VersaMax PLC Users Manual January 2006

GFK-1503D

11 SVCREQ 6: Change/Read Number of Words to Checksum


Use SVCREQ 6 to read or change the number of words in the program to be checksummed. The function is successful unless some number other than 0 or 1 is entered as the requested operation.

Parameter Block Formats for SVCREQ 6


The parameter block has a length of 2 words. To read the word count, the first word of the parameter block must contain a zero:
address address + 1 0 (read word count) ignored

The function returns the current word count in the second word of the parameter block.
address address + 1 0 current word count

To change the word count, the first word of the parameter block must contain a one:
address address + 1 1 (change word count) new word count (0 to 32)

The PLC will change the number of words to be checksummed to the new value.

GFK-1503D

Chapter 11 The Service Request Function

11-9

11
Example of SVCREQ 6
In the example, when enabling contact FST_SCN is set, the parameter blocks for the checksum function are built. Later in the program, if input %I0137 turns on, the SVCREQ reads the number of words being checksummed. The parameter block for the Read function is located at %R0150-151. The ADD function adds 32 to the current word count in %R0151 and places the result in %R0153. The parameter block for the Change function is located at %R00152-153. The second SVCREQ then changes to the new word count specified in %R0153.
FST_SCN XOR_ INT %R0150 %R0150 I1 I2 Q %R0150 CONST 00001 MOVE INT IN Q %R0152

%I0137

SVC_ REQ FNC PARM %R0151 CONST 00032

ADD_ INT I1 I2 Q %R0153 CONST 00006 %R0152

SVC_ REQ FNC PARM

CONST 00006 %R0150

11-10

VersaMax PLC Users Manual January 2006

GFK-1503D

11 SVCREQ 7: Read or Change the Time-of-Day Clock


Use SVCREQ 7 to read or change the time of day clock in the PLC. The data can be either BCD or ASCII. Either 2-digit-year or 4-digit-year format is available. The function is successful unless some number other than 0 (read) or 1 (change) is entered for the requested operation, or an invalid data format is specified, or data is provided in an unexpected format.

Parameter Block Format for SVCREQ 7


For the date/time functions, the length of the parameter block depends on the data format. The data block is either BCD or ASCII. BCD format requires 6 words; packed ASCII requires 12 words (13 words for 4-digit year). For both data types:

Hours are stored in 24-hour format. Day of the week is a numeric value from 1 (Sunday) to 7 (Saturday).
2-Digit Year Format address address + 1 address + 2 to end 0 = read time and date 1 = set time and date 1 = BCD format 3 = packed ASCII format data 4-Digit Year Format 0 = read time and date 1 = set time and date 81h = BCD format 83h = packed ASCII format data

Words 3 to the end of the parameter block contain output data returned by a read function, or new data being supplied by a change function. In both cases, format of these data words is the same. When reading the date and time, words (address + 2) to the end of the parameter block are ignored on input.

GFK-1503D

Chapter 11 The Service Request Function

11-11

11
SVCREQ 7 Parameter Block Content: BCD Format
In BCD format, each time and date item occupies one byte, so the parameter block has six words.

2-Digit Year
The last byte of the sixth word is not used. When setting the date and time, this byte is ignored; when reading date and time, the function returns 00.
Parameter Block Format: High Byte: Low Byte Example: Read Date and Time in BCD format (Sun., July 3, 1998, at 2:45:30 p.m.)

1 = change month hours seconds (null)

or 0 = read year day of month minutes day of week

address address + 1 address + 2 address + 3 address + 4 address + 5 07 (July) 14 (hours)

0 (read) 1 (BCD format) 98 (year) 03 (day) 45 (minutes) 06 (Friday)

1 (BCD format)

30 (seconds) 00

4-Digit Year
The parameter block has six words. All bytes are used.
Parameter Block Format: High Byte: Low Byte Example: Read Date and Time in BCD format (Sun., July 3, 1998, at 2:45:30 p.m.)

1 = change year day of month minutes day of week

or 0 = read year month hours seconds

address address + 1 address + 2 address + 3 address + 4 address + 5

00 00 19 (year) 03 (day) 45 (minutes) 06 (Friday)

00 (read) 81h (BCD, 4-digit) 98 (year) 07 (July) 14 (hours) 30 (seconds)

81h (BCD format, 4-digit)

11-12

VersaMax PLC Users Manual January 2006

GFK-1503D

11
SVCREQ 7 Parameter Block Content: Packed ASCII Format
In Packed ASCII format, each digit of the time and date items is an ASCII formatted byte. Spaces and colons are embedded into the data to format it for printing or display. ASCII format requires 12 words in the parameter block (13 words for 4-digit year).

2-Digit Year
Parameter Block Format: High Byte Low Byte 1 = change year month (space) day of month hours : minutes seconds (space) day of week or 0 = read year (space) month day of month (space) hours minutes : seconds day of week Example: Read Date and Time in Packed ASCII Format (Mon, Oct. 5, 1998 at 11:13:00pm)

address address + 1 address + 2 address + 3 address + 4 address + 5 address + 6 address + 7 address + 8 address + 9 address + 10 address + 11
38 (8) 31 (1) 20 (space) 35 (5) 31 (1) 3A ( : ) 33 (3) 30 (0) 20 (space) 32 (2: Mon.)

0 (read) 3 (ASCII format) 39 (9) 20 (space) 30 (0) 30 (leading 0) 20 (space) 31 (1) 31 (1) 3A ( : ) 30 (0) 30 (leading 0)

3 (ASCII format)

4-Digit Year
Parameter Block Format: High Byte Low Byte 1 = change year (hundreds) year (ones) month (tens) (space) day of month (ones) hours (tens) : (colon) minutes (ones) seconds (tens) (space) day of week (ones) GFK-1503D or 0 = read Example: Read Date and Time in Packed ASCII Format (Mon, Oct. 5, 1998 at 11:13:00pm)

address address + 1 address + 2 address + 3 address + 4 address + 5 address + 6 address + 7 address + 8 address + 9 address + 10 address + 11
39 (9) 38 (8) 31 (1) 20 (space) 35 (5) 31 (1) 3A ( : ) 33 (3) 30 (0) 20 (space) 32 (2: Mon.)

0 (read) 83h (ASCII 4 digit) 31 (1) 39 (9) 20 (space) 30 (0) 30 (leading 0) 20 (space) 31 (1) 31 (1) 3A ( : ) 30 (0) 30 (leading 0)

83h (ASCII 4 digit) year (thousands) year (tens) (space) month (ones) day of month (tens) (space) hours (ones) minutes (tens) : (colon) seconds (ones)

day of week (tens) address + 12

Chapter 11 The Service Request Function

11-13

11
Example of SVCREQ 7
In the example, when called for by previous logic, a parameter block for the time-of-day clock is built. It requests the current date and time, then sets the clock to 12 noon using BCD format. The parameter block is located at location %R0300. Array NOON has been set up elsewhere in the program to contain the values 12, 0, and 0. (Array NOON must also contain the data at %R0300.) BCD format requires six contiguous memory locations for the parameter block.
FST_SCN MOVE INT CONST +04608 %I0016 MOVE INT CONST +00000 IN Q %R0300 CONST +00001 MOVE INT IN Q %R0301 CONST +00007 %R0300 SVC_ REQ FNC PARM IN Q NOON CONST +00000 MOVE INT IN Q MIN_SEC

%T0001

%T0001

%I0017

AND_ WOR I1 I2 Q %R0303 %R0303 NOON

ADD_ INT I1 I2 Q %R0303

%R0303 CONST 00FF %T0001 %I0017

MOVE INT IN Q %R0304 CONST +00001

MOVE INT IN Q %R0300 CONST +00007 %R0300

SVC_ REQ FNC PARM

MIN_SEC

11-14

VersaMax PLC Users Manual January 2006

GFK-1503D

11 SVCREQ 8: Reset Watchdog Timer


Use SVCREQ 8 to reset the watchdog timer during the sweep. Ordinarily, when the watchdog timer expires, the PLC shuts down without warning. SVCREQ 8 allows the timer to keep going during a time-consuming task (for example, while waiting for a response from a communications line).
Caution

Be sure that resetting the watchdog timer does not adversely affect the controlled process.

Parameter Block Format for SVCREQ 8


This function has no associated parameter block.

Example of SVCREQ 8
In this example, power flow through enabling output %Q0027 or input %I1476 or internal coil %M00010 causes the watchdog timer to be reset.
%Q0127 %I1476 %M0010 SVC_ REQ FNC PARM

CONST 0008

GFK-1503D

Chapter 11 The Service Request Function

11-15

11 SVCREQ 9: Read Sweep Time from Beginning of Sweep


Use SVCREQ 9 to read the time in milliseconds since the start of the sweep. The data format is unsigned 16-bit integer.

Output Parameter Block Format for SVCREQ 9


The parameter block is an output parameter block only; it has a length of one word.
address time since start of sweep

Example of SVCREQ 9
In the following example, the elapsed time from the start of the sweep is always read into location %R0200. If it is greater than 100ms, internal coil %M0200 is turned on.
SVC_ REQ FNC PARM %R0200 CONST 0100 GT_ INT I1 I2 Q

CONST 00009 %R0200

%M0200

11-16

VersaMax PLC Users Manual January 2006

GFK-1503D

11 SVCREQ 10: Read Folder Name


Use SVCREQ 10 to read the name of the currently-executing folder.

Output Parameter Block Format for SVCREQ 10


The output parameter block has a length of four words. It returns eight ASCII characters; the last is a null character (00h). If the program name has fewer than seven characters, null characters are added to the end.
Low Byte address address + 1 address + 2 address + 3 character 1 character 3 character 5 character 7 High Byte character 2 character 4 character 6 00

Example of SVCREQ 10
In this example, when enabling input %I0301 goes OFF, register location %R0099 is loaded with the value 10, which is the function code for the Read Folder Name function. The Program Block READ_ID is then called to retrieve the folder name. The parameter block is located at address %R0100.
%I0301 MOVE UINT CONST 0010 IN Q %R0099 READ_ID

Program Block READ_ID

SVC_ REQ %R0099 %R0100 FNC PARM

GFK-1503D

Chapter 11 The Service Request Function

11-17

11 SVCREQ 11: Read PLC ID


Use SVCREQ 11 to read the name of the PLC executing the program.

Output Parameter Block Format for SVCREQ 11


The output parameter block has a length of four words. It returns eight ASCII characters; the last is a null character (00h). If the PLC ID has fewer than seven characters, null characters are added to the end.
Low Byte address address + 1 address + 2 address + 3 character 1 character 3 character 5 character 7 High Byte character 2 character 4 character 6 00

Example of SVCREQ 11
In this example, when enabling input %I0302 goes OFF, register location %R0099 is loaded with the value 11, which is the function code for the Read PLC ID function. The program block READ_ID is then called to retrieve the ID. The parameter block is located at address %R0100.
%I0303 MOVE UINT CONST 0011 IN Q %R0099 READ_ID

Program Block READ_ID

SVC_ REQ %R0099 %R0100 FNC PARM

11-18

VersaMax PLC Users Manual January 2006

GFK-1503D

11 SVCREQ 13: Shut Down (Stop) PLC


Use SVCREQ 13 to stop the PLC at the end of the next sweep. All outputs go to their designated default states at the start of the next PLC sweep. An informational Shut Down PLC" fault is placed in the PLC Fault Table. The I/O scan continues as configured.

Parameter Block for SVCREQ 13


This function has no parameter block.

Example of SVCREQ 13
In the example, when a Loss of I/O Module" fault occurs, SVCREQ 13 executes. The PARM input is not used. This example uses a JUMP to the end of the program to force a shutdown if the Shutdown PLC function executes successfully. This JUMP and LABEL are needed because the transition to Stop mode does not occur until the end of the sweep in which the function executes.
LOS_MD %T0001

%T0001 SVC_ REQ CONST 00013 FNC PARM >> END_PRG

END_PRG

GFK-1503D

Chapter 11 The Service Request Function

11-19

11 SVCREQ 14: Clear Fault


Use SVCREQ 14 to clear either the PLC fault table or the I/O fault table. The SVCREQ output is set ON unless some number other than 0 or 1 is entered as the requested operation.

Input Parameter Block for SVCREQ 14


For this function, the parameter block has a length of 1 word. It is an input parameter block only. There is no output parameter block.
0 = clear PLC fault table. 1 = clear I/O fault table.

Example of SVCREQ 14
In the example, when input %I0346 is on and input %I0349 is on, the PLC fault table is cleared. When input %I0347 is on and input %I0349 is on, the I/O fault table is cleared. When input %I0348 is on and input %I0349 is on, both are cleared. The parameter block for the PLC fault table is located at %R0500; for the I/O fault table the parameter block is located at %R0550. Both parameter blocks are set up elsewhere in the program.
%I0349 %I0346 SVC_ REQ %I0348 CONST 00014 %R0500 %I0349 %I0347 SVC_ REQ %I0348 CONST 00014 %R0550 FNC PARM FNC PARM

11-20

VersaMax PLC Users Manual January 2006

GFK-1503D

11 SVCREQ 15: Read Last-Logged Fault Table Entry


Use SVCREQ 15 to read the last entry logged in either the PLC fault table or the I/O fault table. The SVCREQ output is set ON unless some number other than 0 or 1 is entered as the requested operation or the fault table is empty.

Input Parameter Block for SVCREQ 15


For this function, the parameter block has a length of 22 words. The input parameter block has this format:
2-Digit Year Format address 0 = Read PLC fault table. 1 = Read I/O fault table. 4-Digit Year Format 8 = Read PLC fault table. 9 = Read I/O fault table.

The format of the output parameter block depends on whether the function reads data from the PLC fault table or the I/O fault table. PLC Fault Table Output Format
High Byte spare spare slot fault action Low Byte 0 long/short spare rack task fault group error code fault specific data

I/O Fault Table Output Format


High Byte address + 1 address + 2 address + 3 address + 4 address + 5 address + 6 address + 7 address + 8 to address + 18 address + 19 address + 20 address + 21 memory type Low Byte 1 long/short

slot
block fault action fault type fault specific data

offset rack
bus

point
fault group fault category fault description

minutes day of month

seconds hour month

minutes day of month year

seconds hour month

2-Digit Year year Format or 4-Digit Year spare Format

month year

address + 21 address + 22

spare

month year

GFK-1503D

Chapter 11 The Service Request Function

11-21

11
Long/Short Value
The first byte of word address +1 contains a number that indicates the length of the fault-specific data in the fault entry. These possible values are:
PLC fault table I/O fault table 00 = 8 bytes (short) 01 = 24 bytes (long) 02 = 5 bytes (short) 03 = 21 bytes (long)

Example of SVCREQ 15
When inputs %I0250 and %I0251 are both on, the first Move function places a zero (read PLC fault table) into the parameter block for SVCREQ 15. When input %I0250 is on and input %I0251 is off, the Move instruction instead places a one (read I/O fault table) in the SVCREQ parameter block. The parameter block is located at location %R0600.
%I0250 %I0251 MOVE INT CONST 00000 %I0250 %I0251 MOVE INT CONST 00001 ALW_ON SVC_ REQ CONST 00015 %R0600 FNC PARM IN Q LEN 00001 %R0600 IN Q LEN 00001 %R0600

11-22

VersaMax PLC Users Manual January 2006

GFK-1503D

11 SVCREQ 16: Read Elapsed Time Clock


Use SVCREQ 16 to read the system's elapsed time clock. The elapsed time clock measures the time in seconds since the PLC was powered on.

Output Parameter Block for SVCREQ 16


This function has an output parameter block only. Its length is 3 words.
address address + 1 address + 2 seconds from power on (low order) seconds from power on (high order) 100 microsecond ticks

The first two words are the elapsed time in seconds. The last word is the number of 100 microsecond ticks in the current second.

Example of SVCREQ 16
In the example, when internal coil %M0233 is on, the SVCREQ with a parameter block located at %R0127 reads the system's elapsed time clock and sets internal coil %M0234. When coil %M0233 is off, the SVCREQ with a parameter block at %R0131 reads the elapsed time clock again. The subtraction function finds the difference between the first and second readings, which have been stored in the SVCREQ parameter blocks. The subtraction ignores the hundred microsecond ticks. The difference between the two readings is placed in memory location %R0250.
%M0223 SVC_ REQ CONST 00016 %R0127 %M0233 FNC PARM %M0234 SVC_ REQ CONST 00016 %R0131 FNC PARM %R0131 %R0127 SUB_ D INT I1 I2 Q %R0250 %M0234 R %M0234 S

GFK-1503D

Chapter 11 The Service Request Function

11-23

11 SVCREQ 18: Read I/O Override Status


Use SVCREQ 18 to check for any overrides in the CPU's %I and %Q memories.

Output Parameter Block for SVCREQ 18


This function has an output parameter block only. Its length is 1 word.
address 0 = No overrides are set. 1 = Overrides are set.

Example of SVCREQ 18
The following SVCREQ reads the status of I/O overrides memory into location %R1003. The equality function checks %R1003 to see if it is equal to (the constant) 1. If it is, the equality function turns on output %T0001.
%I0001 SVC_ REQ FNC PARM EQ_ INT I1 I2 Q %T0001

CONST 00018 %R1003

CONST 00001 %R1003

11-24

VersaMax PLC Users Manual January 2006

GFK-1503D

11 SVCREQ 23: Read Master Checksum


Use SVCREQ 23 to read the master checksums of the application program and the configuration. The SVCREQ output is always ON if the function is enabled.

Output Parameter Block for SVCREQ 23


For this function, the output parameter block has a length of 12 words with this format: The first two items in the output parameter block indicate when the program and configuration checksums are valid. (Program checksums may not be valid during a Run Mode Store.)
address address + 1 address + 2 address + 3 address + 5 address + 6 address + 8 address + 9 address + 10 Master Program Checksum Valid (0 = not valid, 1 = valid) Master Configuration Checksum Valid (0 = not valid, 1 = valid) Number of Program Blocks (including _MAIN) Size of User Program in Bytes (DWORD data type) Program Additive Checksum Program CRC Checksum (DWORD data type) Size of Configuration Data in Bytes Configuration Additive Checksum Configuration CRC Checksum (DWORD data type)

Example of SVCREQ 23
In the example, when input %I0251 is ON, the master checksum information is placed into the parameter block at %R0050 and the output coil (%Q0001) is turned on.
%I0251 SVC_ REQ FNC PARM %Q0001

CONST 00023 %R0050

GFK-1503D

Chapter 11 The Service Request Function

11-25

11 SVCREQ 26/30: Interrogate I/O


Use SVCREQs 26 and 30 to check whether the installed modules match the software configuration. If not, these SVCREQs place appropriate addition, loss, and mismatch faults in the PLC and/or I/O fault tables. SVCREQs 26 and 30 both perform the same function. The more configuration faults there are, the longer it takes these SVCREQs longer to execute. These SVCREQs have no parameter block. They always output power flow.

Example of SVCREQ 26
In the example, when input %I0251 is ON, the SVCREQ checks the installed modules and compares them to the software configuration. Output %Q0001 is turned on after the SVCREQ is complete.
%I0251 SVC_ REQ CONST 00026 %R0050 FNC PARM %Q0001

11-26

VersaMax PLC Users Manual January 2006

GFK-1503D

11 SVCREQ 29: Read Elapsed Power Down Time


Use SVCREQ 29 to read the amount of time elapsed between the last power-down and the most recent powerup. If the watchdog timer expired before power-down, the PLC is not able to calculate the power down elapsed time, so the time is set to 0. The SVCREQ output is always ON.

Output Parameter Block for SVCREQ 29


This function has an output parameter block only. The parameter block has a length of 3 words.
address address + 1 address + 2 Power-Down Elapsed Seconds (low order) Power-Down Elapsed Seconds (high order) zero

The first two words are the power-down elapsed time in seconds. The last word is always 0.

Example of SVCREQ 29
In the example, when input %I0251 is ON, the Elapsed Power-Down Time is placed into the parameter block that starts at %R0050. The output coil (%Q0001) is turned on.
%I0251 SVC_ REQ FNC PARM %Q0001

CONST 00029 %R0050

GFK-1503D

Chapter 11 The Service Request Function

11-27

11

11-28

VersaMax PLC Users Manual January 2006

GFK-1503D

Chapter

12

Serial I/O / SNP / RTU Protocols

This chapter describes the VersaMax CPUs Serial I/O feature, which can be used to control the read/write activities of one of the CPU ports directly from the application program. This chapter also contains instructions for using COMMREQs to configure the CPU serial ports for SNP, RTU, or Serial I/O protocol.

Format of the COMMREQ Function Configuring Serial Ports Using the COMMREQ Function

RTU Slave/SNP Slave Operation with a Programmer Attached COMMREQ Command Block for Configuring SNP Protocol COMMREQ Data Block for Configuring RTU Protocol COMMREQ Data Block for Configuring Serial I/O

Serial I/O COMMREQ Commands Initialize Port Set Up Input Buffer Flush Input Buffer Read Port Status Write Port Control Cancel Operation Autodial Write Bytes Read Bytes Read String

Details of RTU and SNP protocol are described in the Serial Communications Users Manual (GFK-0582).

GFK-1503D

12-1

12 Format of the Communication Request Function


Serial I/O is implemented through the use of Communication Request (COMMREQ) functions. The operations of the protocol, such as transmitting a character through the serial port or waiting for an input character, are implemented through the COMMREQ function block. In CPUE05, Serial I/O is not available for Port 1 when that port is configured or forced for Station Manager operation. The COMMREQ requires that all its command data be placed in the correct order (in a command block) in the CPU memory before it is executed. The COMMREQ should then be executed by a contact of a one-shot coil to prevent sending the data multiple times. A series of Block Move (BLKMV) commands should be used to move the words to create a command block in the Register tables. The COMMREQ function has three inputs and one output. When the function receives power flow, a command block of data is sent to the specified module.
Enable First word of command block Location Task identifier COMM_ REQ IN FT SYSID TASK

Parameters of the COMMREQ Function


Input/ Output
enable IN SYSID

Choices
flow R, AI, AQ

Description
When the function is energized, the communications request is performed. IN contains the first word of the command block.

I, Q, M, T, G, R, SYSID contains the rack number (most significant byte) and slot AI, AQ, number (least significant byte) of the target device. For the CPU, constant SYSID must specify rack/slot 0. R AI, AQ, constant flow, none TASK specifies the port for which the operation is intended: task 19 for port 1 task 20 for port 2 FT is energized if an error is detected processing the COMMREQ: The specified target address is not present (SYSID). The specified task is not valid for the device (TASK). The data length is 0. The devices status pointer address (in the command block) does not exist.
GFK-1503D

TASK

FT

12-2

VersaMax PLC Users Manual January 2006

12
Command Block for the COMMREQ Function
The Command Block starts at the reference specified in COMMREQ parameter IN. The length of the Command Block depends on the amount of data sent to the device. The Command Block contains the data to be communicated to the other device, plus information related to the execution of the COMMREQ. The Command Block has the following structure:
address address + 1 address + 2 address + 3 address + 4 address + 5 address + 6 to address + 133 Length (in words) Wait/No Wait Flag Status Pointer Memory Status Pointer Offset Idle Timeout Value Maximum Communication Time Data Block

Example of the COMMREQ Function


In the example, when %M0021 is ON, a Command Block located starting at %R0032 is sent to port 2 (communications task 20) of the CPU (rack 0, slot 0). If an error occurs processing the COMMREQ, %Q0110 is set.
%M0021 | | %R0032 CONST 0000 CONST 00020 COMM_ REQ IN FT SYSID TASK

%Q0110 ( )

GFK-1503D

Chapter 12 Serial I/O / SNP / RTU Protocols

12-3

12 Configuring Serial Ports Using the COMMREQ Function


The following tables list the command block values required for setting up a Serial Port for SNP, RTU, and Serial I/O. All values are in hexadecimal unless otherwise indicated. The BLKMV commands that are used to create the command block are described in the example. It is important to note that 2 parameters have been added to the RTU and Serial IO port configuration COMMREQ, receive to transmit delay and RTS drop delay. When these parameters are included in a COMMREQ the data block length must be set to 12H. If a value of 10H is used, the COMMREQ will still be processed however the receive to transmit and RTS drop delays would not be recognized. It is also important to note that if a COMMREQ containing the receive to transmit delay and RTS drop delay is sent to a CPU that does not support these delay features the CPU will accept and process the COMMREQ but will ignore the receive to transmit, RTS drop delay, and turnaround delay (i.e. turn around delay will be ignored only for the RTU and Serial IO protocols in this case). Note: Either the old form (length 10H) or the new form (length 12H) of the COMMREQ can be used. Only the new form supports the new parameters.

Timing
If a port configuration COMMREQ is sent to a serial port that currently has an SNP/SNPX master (for example, the programmer) connected to it, the serial port configuration specified by the COMMREQ does not take effect until the CPU detects a loss of the SNP/SNPX master. This occurs the configured T3 time after the master disconnects. The COMMREQ status word for the port configuration COMMREQ is updated as soon as the CPU verifies that the specified configuration is valid. That means a COMMREQ Successful value may be returned by the Port Configuration COMMREQ before the specified configuration is actually installed.

Sending Another COMMREQ to the Same Port


The application program must wait at least 2 seconds plus the configured T3 time after a new serial port protocol is installed before sending any COMMREQs specific to that protocol to the port. This applies to a new protocol installed by Storing a new hardware configuration or by a port configuration COMMREQ. If the port is configured for Serial I/O, this waiting period must also follow any Stop to Run mode transition of the CPU.

12-4

VersaMax PLC Users Manual January 2006

GFK-1503D

12
Invalid Port Configuration Combinations
The configurations of both ports must be compatible. One port must be available for PLC programmer connection. The CPU rejects the following combinations:
Port 1 Disabled Disabled Serial I/O (CPU Run/Stop switch disabled) Serial I/O (CPU Run/Stop switch disabled) Station Manager Station Manager Port 2 Disabled Serial I/O (CPU Run/Stop switch disabled) Disabled Serial I/O (CPU Run/Stop switch disabled) Disabled Serial I/O (CPU Run/Stop switch disabled)

GFK-1503D

Chapter 12 Serial I/O / SNP / RTU Protocols

12-5

12
RTU Slave/SNP Slave Operation With Programmer Attached
A programmer (an SNP/SNPX device) can be attached to port 1 or port 2 while RTU Slave mode is active on the port. For multi-drop connections, the CPU must have been configured to use an appropriate PLC ID. Note that for a multi-drop SNP connection with the port currently configured for RTU, the SNP ID associated with the CPU settings must match the multi-drop ID. The programmer must use the same serial communications parameters (baud rate, parity, stop bits, etc) as the currently-active RTU Slave protocol for it to be recognized. When the CPU recognizes the programmer, the CPU removes the RTU Slave protocol from the port and installs SNP Slave as the currently-active protocol. The SNP ID, modem turnaround time, and default idle time for this new SNP Slave session are obtained from the configured CPU settings, not the port 1 or port 2 configurations. Connection should be established within 12 seconds. When the programmer connection has been enabled, normal programmer communications can take place. (Failure of the programmer to establish communications within 12 seconds is treated as a Loss of Programmer Communications). The programmer may send a new protocol via configuration or a Serial Port Setup COMMREQ. (COMMREQs not supported by SNP Slave protocol are rejected). If a new protocol is received, it will not take effect until the programmer is disconnected. After the programmer is removed, there is a slight delay (equal to the configured SNP T3 timeout) before the CPU recognizes its absence. During this time, no messages are processed on the port. The CPU detects removal of the programmer as an SNP Slave protocol timeout. Therefore, it is important to be careful when disabling timeouts used by the SNP Slave protocol.

12-6

VersaMax PLC Users Manual January 2006

GFK-1503D

12
When the CPU recognizes the disconnect, it reinstalls RTU Slave protocol unless a new protocol has been received. In that case, the CPU installs the new protocol instead.

Example
1. Port 1 is running RTU Slave protocol at 9600 baud. 2. A programmer is attached to port 1. The programmer is using 9600 baud. 3. The CPU installs SNP Slave on port 1 and the programmer communicates normally. 4. The programmer stores a new configuration to port 1. The new configuration sets the port for SNP Slave at 4800 baud (it will not take effect until the port loses communications with the programmer). 5. When the CPU loses communications with the programmer, the new configuration takes effect.

GFK-1503D

Chapter 12 Serial I/O / SNP / RTU Protocols

12-7

12
Example COMMREQ Command Block for Configuring SNP Protocol
Values Address Address + 1 Address + 2 Address + 3 10H 0 = No Wait 0008 = %R, register memory Meaning Data Block Length WAIT/NOWAIT Flag Status Word Pointer Memory Type

Zero-based number that gives the address Status Word Pointer Offset of the COMMREQ status word (for example, a value of 99 gives an address of 100 for the status word) 0 (Only used in Wait/No Wait mode) 0 (Only used in Wait/No Wait mode) FFF0H 0001 0000=Slave 7=38400, 6=19200, 5=9600, 4=4800 0 = None, 1 = Odd, 2 = Even 1 = None Idle Timeout Value Maximum Communication Time Command Word (serial port setup) Protocol: 1=SNP Port Mode Data Rate Parity Flow Control

Address + 4 Address + 5 Address + 6 Address + 7 Address + 8 Address + 9 Address + 10 Address + 11 Address + 12 Address + 13 Address + 14 Address + 15 Address + 16 Address + 17 Address + 18 Address + 19 Address + 20 Address + 21

0 = None, 1 = 10ms, 2 = 100ms, 3 = 500ms Turnaround Delay 0 = Long, 1 = Medium, 2 = Short, 3 = None Timeout 1 = 8 bits 0 = 1 Stop Bit, 1 = 2 Stop bits not used not used user-provided* user-provided* user-provided* user-provided* Bits Per Character Stop Bits Interface Duplex Mode Device identifier bytes 1 and 2 Device identifier bytes 3 and 4 Device identifier bytes 5 and 6 Device identifier bytes 7 and 8

The device identifier for SNP Slave ports is packed into words with the least significant character in the least significant byte of the word. For example, if the first two characters are A and B, the Address + 18 will contain the hex value 4241.

12-8

VersaMax PLC Users Manual January 2006

GFK-1503D

12
Example COMMREQ Data Block for Configuring RTU Protocol
Values
First 6 words Address + 6 Address + 7 Address + 8 Address + 9 FFF0H 0003 0000 2=1200, 3-2400, 4=4800, 5=9600, 6=19200,7=38400*, 8=57600** *CPU models IC200CPU005 and CPUE05 only Address + 10 Address + 11 Address + 12 Address + 13 Address + 14 Address + 15 Address + 16 Address + 17 Address + 18 Address + 22* Address + 22* 0 = None, 1 = Odd, 2 = Even 0 = Hardware, 1 = None not used not used not used not used 0 = 2-wire, 1 = 4-wire Station Address (1-247) Parity Flow Control Timeout Bits per Character Stop Bits Interface Duplex Mode Device Identifier Device Identifier Command Protocol: 0003=RTU Port Mode: 0000=Slave Data Rate

Meaning
Reserved for COMMREQ use.

0-255 (units of 10ms,e.g. 10=100ms) Turnaround delay

Address + 1921 not used

0-255 (units of 10ms,e.g. 10=100ms) Receive to transmit delay 0-255 (units of 10ms,e.g. 10=100ms) RTS drop delay

Notes
The data block length (Address + 0) for a COMMREQ that includes the Receive to transmit delay and RTS drop delay should be 12H not 10H. Both forms (Length 10H and 12H) are supported If RTU is configured for 115.2K baud. a major error code 12 (0cH) and a minor error code 2 (02H) is returned in the COMMREQ status word. This will occur for any unsupported baud rate.

GFK-1503D

Chapter 12 Serial I/O / SNP / RTU Protocols

12-9

12
Example COMMREQ Data Block for Configuring Serial I/O Protocol
Values
First 6 words Address + 6 Address + 7 Address + 8 Address + 9 FFF0H 0005 0 = Slave 4=4800, 5=9600, 6=19200, 7=38400*, 8=57600** *CPU models IC200CPU005 and CPUE05 only Address + 10 Address + 11 Address + 12 Address + 13 Address + 14 Address + 15 Address + 16 Address + 17 Address + 22* Address + 22* 0 = None, 1 = Odd, 2 = Even 0 = Hardware, 1 = None 0-255 (units of 10ms,e.g. 10=100ms) 0 = Long 0=7 bits, 1=8 bits 0 = 1 stop bit, 1 = 2 stop bits not used 0 = 2-wire, 1 = 4-wire 0-255 (units of 10ms,e.g. 10=100ms) 0-255 (units of 10ms,e.g. 10=100ms) Parity Flow Control Turnaround Delay Timeout Bits per Character Stop Bits Interface Duplex Mode Device Identifier Receive to transmit delay RTS drop delay Command Protocol: 0005=Serial IO Port Mode Data Rate

Meaning
Reserved for COMMREQ use.

Address + 1821 not used

Notes
The data block length (Address + 0) for a COMMREQ that includes the Receive to transmit delay and RTS drop delay should be 12H not 10H. Both forms (Length 10H and 12H) are supported. If Serial I/O is configured for 115.2K baud. a major error code 12 (0cH) and a minor error code 2 (02H) is returned in the COMMREQ status word. This will occur for any unsupported baud rate.

12-10

VersaMax PLC Users Manual January 2006

GFK-1503D

12 Calling Serial I/O COMMREQs from the PLC Sweep


Implementing a serial protocol using Serial I/O COMMREQs may be restricted by the PLC sweep time. For example, if the protocol requires that a reply to a certain message from the remote device be initiated within 5mS of receiving the message, this method may not be successful if the PLC sweep time is 5mS or longer, since timely response is not guaranteed. Since the Serial I/O is completely driven by the application program, in STOP mode a port configured as Serial I/O automatically reverts to SNP slave, to facilitate programmer communication. Therefore, while in Stop mode, Serial I/O protocol is not active; it is only active when the PLC is in Run mode. When the port reverts back to SNP Slave, the same serial communications parameters (baud rate, parity, stop bits ) as the currently-active Serial I/O protocol are used. Therefore the programmer must use the same parameters for it to be recognized. If any of the parameter values associated with the Serial I/O protocol are not supported by the SNP Slave protocol, the programmer will not be able to communicate with the PLC via that port.

Compatibility
The COMMREQ function blocks supported by Serial I/O are not supported by other currently-existing protocols (such as SNP slave, SNP master, and RTU slave). Errors are returned if they are attempted for a port configured for one of those protocols.

GFK-1503D

Chapter 12 Serial I/O / SNP / RTU Protocols

12-11

12
Status Word for Serial I/O COMMREQs
A value of 1 is returned in the COMMREQ status word upon successful completion of the COMMREQ. Any other value returned is an error code where the low byte is a major error code and the high byte is a minor error code.
Major Error Code 1 (01h) 12 (0Ch) Description Successful Completion (this is the expected completion value in the COMMREQ status word). Local error Error processing a local command. The minor error code identifies the specific error. 1 (01h) Wait-type command is not permitted. Use No-Wait command. 2 (02h) COMMREQ command is not supported. 5 (05h) Error writing COMMREQ status word to PLC memory. 6 (06h) Invalid PLC memory type specified. 7 (07h) Invalid PLC memory offset specified. 8 (08h) Unable to access PLC memory. 9 (09h) Data length exceeded. 12 (0Ch) COMMREQ data block length too small. 14 (0Eh) COMMREQ data is invalid. 15 (0Fh) Could not allocate system resources to complete COMMREQ. Remote error Error processing a remote command. The minor error code identifies the error. 2 (02h) Number of bytes requested to read is greater than input buffer size OR number bytes requested to write is zero or greater than 250 bytes. 3 (03h) COMMREQ data block length is too small. String data is missing or incomplete. 4 (04h) Receive timeout awaiting serial reception of data 8 (08h) Unable to access PLC memory. 12 (0Ch) COMMREQ data block length too small. 48 (30h) Serial output timeout. The serial port was unable to transmit the string. (Could be due to missing CTS signal when the serial port is configured to use hardware flow control.) 50 (32h) COMMREQ timeout. The COMMREQ did not complete within a 20-second time limit. Autodial Error An error occurred while attempting to send a command string to an attached external modem. The minor error code identifies the specific error. 1 (01h) Not used. 2 (02h) The modem command string length exceeds end of reference memory type. 3 (03h) COMMREQ Data Block Length too small. Output command string data missing or incomplete. 4 (04h) Serial output timeout. The serial port was unable to transmit the modem autodial output. 5 (05h) Response was not received from modem. Check modem and cable. 6 (06h) Modem responded with BUSY. Modem is unable to complete the requested connection. The remote modem is already in use; retry the connection request later. 7 (07h) Modem responded with NO CARRIER. Modem is unable to complete the requested connection. Check the local and remote modems and the telephone line. 8 (08h) Modem responded with NO DIALTONE. Modem is unable to complete the requested connection. Check the modem connections and the telephone line. 9 (09h) Modem responded with ERROR. Modem is unable to complete the requested command. Check the modem command string and modem. 10 (0Ah) Modem responded with RING, indicating that the modem is being called by another modem. Modem is unable to complete the requested command. Retry the modem command later. 11 (0Bh) Unknown response received from the modem. Modem unable to complete the request. Check the modem command string and modem. Response should be CONNECT or OK. 50 (32h) COMMREQ timeout. The COMMREQ did not complete within a 20-second time limit. GFK-1503D

13 (0Dh)

14 (0Eh)

12-12

VersaMax PLC Users Manual January 2006

12 Serial I/O COMMREQ Commands


The following COMMREQs are used to implement Serial I/O:

Local COMMREQs - do not receive or transmit data through the serial port.

Initialize Port (4300) Set Up Input Buffer (4301) Flush Input Buffer (4302) Read Port Status (4303) Write Port Control (4304) Cancel Operation (4399)

Remote COMMREQs - receive and/or transmit data through the serial port.

Autodial (4400) Write bytes (4401) Read bytes (4402) Read String (4403)

GFK-1503D

Chapter 12 Serial I/O / SNP / RTU Protocols

12-13

12
Overlapping COMMREQs
Some of the Serial I/O COMMREQs must complete execution before another COMMREQ can be processed. Others can be left pending while others are executed.

COMMREQS that Must Complete Execution

Autodial (4400) Initialize Port (4300) Set Up Input Buffer (4301) Flush Input Buffer (4302) Read Port Status (4303) Write Port Control (4304) Cancel Operation (4399) Serial Port Setup (FFF0)

COMMREQs that Can be Pending While Others Execute


The table below shows whether Write Bytes, Read Bytes and Read String COMMREQs can be pending when other COMMREQs are executed.
NEW COMMREQ Currently- Autodial pending (4400) COMMREQs Write Bytes (4401) Read Bytes (4402) Read String (4403) No No No Write Bytes (4401) No Yes Yes Initialize Set Up Port Input (4300) Buffer (4301) Yes Yes Yes Yes No No Flush Input Buffer (4302) Yes No No Read Port Status (4303) Yes Yes Yes Write Port Control (4304 Yes Yes Yes Read Bytes (4402) Yes No No Read Cancel String Operatio (4403) n (4399) Yes No No Yes Yes Yes Serial Port Setup (FFF0) No No No

12-14

VersaMax PLC Users Manual January 2006

GFK-1503D

12
Initialize Port Function (4300)
This function causes a reset command to be sent to the specified port. It also cancels any COMMREQ currently in progress and flushes the internal input buffer. RTS is set to inactive.

Example Command Block for the Initialize Port Function


VALUE (decimal) address address +1 address +2 address +3 address +4 address +5 address +6 0001 0000 0008 0000 0000 0000 4300 VALUE (hexadecimal) 0001 0000 0008 0000 0000 0000 10CC Data block length NOWAIT mode Status word memory type (%R) Status word address minus 1 (%R0001) Not used Not used Initialize port command MEANING

Operating Notes
Note: COMMREQs that are cancelled due to this command executing do not have their respective COMMREQ status words updated. Caution: If this COMMREQ is sent when a Write Bytes (4401) COMMREQ is transmitting a string from a serial port, transmission is halted. The position within the string where the transmission is halted is indeterminate. In addition, the final character received by the device the CPU is sending to is also indeterminate.

GFK-1503D

Chapter 12 Serial I/O / SNP / RTU Protocols

12-15

12
Set Up Input Buffer Function (4301)
This function can be used to change the size of the internal memory buffer where input data will be placed as it is received. By default, the buffer is set to a maximum of 2K bytes. As data is received from the serial port it is placed in the input buffer. If the buffer becomes full, any additional data received from the serial port is discarded and the Overflow Error bit in the Port Status word (See Read Port Status Function) is set.

Retrieving Data from the Buffer


Data can be retrieved from the buffer using the Read String or Read Bytes function. It is not directly accessible from the application program. If data is not retrieved from the buffer in a timely fashion, some characters may be lost.

Example Command Block for the Set Up Input Buffer Function


VALUE (decimal) address address +1 address +2 address +3 address +4 address +5 address +6 address +7 0002 0000 0008 0000 0000 0000 4301 0064 VALUE (hexadecimal) 0002 0000 0008 0000 0000 0000 10CD 0040 NOWAIT mode Status word memory type (%R) Status word address minus 1 (%R0001) Not used Not used Setup input buffer command Buffer length (in words) MEANING Data block length

Operating Notes
It is not possible to set the buffer length to zero. If zero is entered as the buffer length, the buffer size will be set to the 2K bytes default. If a length greater than 2K bytes is specified, an error is generated.

12-16

VersaMax PLC Users Manual January 2006

GFK-1503D

12
Flush Input Buffer Function (4302)
This operation empties the input buffer of any characters received through the serial port but not yet retrieved using a read command. All such characters are lost.

Example Command Block for the Flush Input Buffer Function


VALUE (decimal) address address +1 address +2 address +3 address +4 address +5 address +6 0001 0000 0008 0000 0000 0000 4302 VALUE (hexadecimal) 0001 0000 0008 0000 0000 0000 10CE NOWAIT mode Status word memory type (%R) Status word address minus 1 (%R0001) Not used Not used Flush input buffer command MEANING Data block length

GFK-1503D

Chapter 12 Serial I/O / SNP / RTU Protocols

12-17

12
Read Port Status Function (4303)
This function returns the current status of the port. The following events can be detected: 1. A read request was initiated previously and the required number of characters has now been received or the specified time-out has elapsed. 2. A write request was initiated previously and transmission of the specified number of characters is complete or a time-out has elapsed. The status returned by the function indicates the event or events that have completed. More than one condition can occur simultaneously, if both a read and a write were initiated previously.

Example Command Block for the Read Port Status Function


VALUE (decimal) address address +1 address +2 address +3 address +4 address +5 address +6 address +7 address +8 0003 0000 0008 0000 0000 0000 4303 0076 0101 VALUE (hexadecimal) 0003 0000 0008 0000 0000 0000 10CF 004C 0065 NOWAIT mode Status word memory type (%R) Status word address minus 1 (%R0001) Not used Not used Read port status command Port status memory type (%M) Port status memory offset (%M101) MEANING Data block length

12-18

VersaMax PLC Users Manual January 2006

GFK-1503D

12
Port Status
The port status consists of a status word and the number of characters in the input buffer that have not been retrieved by the application (characters which have been received and are available).
word 1 word 2 Port status word (see below) Characters available in the input buffer

The Port Status Word can be:


Bit 15 Name RI Definition Read In progress Meaning Set Cleared 14 RS Read Success Set Cleared 13 RT Read Time-out Set Cleared 12 WI Write In progress Set Cleared 11 WS Write Success Set Cleared 10 9 8 WT CA OF Write Time-out Character Available OverFlow error Set Cleared Set Cleared Set Cleared 7 6 5 FE PE CT Framing Error Parity Error CTS is active Set Cleared Set Cleared Set Cleared 4-0 GFK-1503D U not used, should be 0 12-19 Read Bytes or Read String invoked Previous Read bytes or String has timed out, been canceled, or finished Read Bytes or Read String has successfully completed New Read Bytes or Read String invoked Receive timeout occurred during Read Bytes or Read String New Read Bytes or Read String invoked New Write Bytes invoked Previously-invoked Write Bytes has timed out, been canceled, or finished Previously-invoked Write Bytes has successfully completed New Write Bytes invoked Transmit timeout occurred during Write Bytes New Write Bytes invoked Unread characters are in the buffer No unread characters in the buffer Overflow error occurred on the serial port or internal buffer Read Port Status invoked Framing error occurred on the serial port Read Port Status invoked Parity error occurred on the serial port Read Port Status invoked CTS line on the serial port is active or the serial port does not have a CTS line CTS line on the serial port is not active

Chapter 12 Serial I/O / SNP / RTU Protocols

12
Write Port Control Function (4304)
This function forces RTS for the specified port:

Example Command Block for the Write Port Control Function


VALUE (decimal) address address +1 address +2 address +3 address +4 address +5 address +6 address +7 0002 0000 0008 0000 0000 0000 4304 xxxx VALUE (hexadecimal) 0002 0000 0008 0000 0000 0000 10D0 xxxx NOWAIT mode Status word memory type (%R) Status word address minus 1 (%R0001) Not used Not used Write port control command Port control word MEANING Data block length

Port Control Word


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

The Port Control Word can be: 15 RTS Commanded state of the RTS output 1 = Activates RTS 0 = Deactivates RTS Unused (should be zero)

0-14

Operating Note
For CPU port 2 (RS-485), the RTS signal is also controlled by the transmit driver. Therefore, control of RTS is dependent on the current state of the transmit driver. If the transmit driver is not enabled, asserting RTS with the Write Port Control COMMREQ will not cause RTS to be asserted on the serial line. The state of the transmit driver is controlled by the protocol and is dependent on the current Duplex Mode of the port. For 2-wire and 4-wire Duplex Mode, the transmit driver is only enabled during transmitting. Therefore, RTS on the serial line will only be seen active on port 2 (configured for 2-wire or 4-wire Duplex Mode) when data is being transmitted. For point-to-point Duplex Mode, the transmit driver is always enabled. Therefore, in point-to-point Duplex Mode, RTS on the serial line will always reflect what is chosen with the Write Port Control COMMREQ.

12-20

VersaMax PLC Users Manual January 2006

GFK-1503D

12
Cancel Commreq Function (4399)
This function cancels the current operations in progress. It can be used to cancel both read operations and write operations. If a read operation is in progress and there are unprocessed characters in the input buffer, those characters are left in the input buffer and available for future reads. The serial port is not reset.

Example Command Block for the Cancel Operation Function


VALUE (decimal) address address +1 address +2 address +3 address +4 address +5 address +6 address +7 0002 0000 0008 0000 0000 0000 4399 0001 VALUE (hexadecimal) 0002 0000 0008 0000 0000 0000 112F 0001 NOWAIT mode Status word memory type (%R) Status word address minus 1 (%R0001) Not used Not used Cancel operation command Transaction type to cancel 1 All operations 2 Read operations 3 Write operations MEANING Data block length (2)

Operating Notes
This function does not update the status of words of the cancelled COMMREQs. Caution: If this COMMREQ is sent in either Cancel All or Cancel Write mode when a Write Bytes (4401) COMMREQ is transmitting a string from a serial port, transmission is halted. The position within the string where the transmission is halted is indeterminate. In addition, the final character received by the device the CPU is sending to is also indeterminate.

GFK-1503D

Chapter 12 Serial I/O / SNP / RTU Protocols

12-21

12
Autodial Function (4400)
This feature allows the VersaMax CPU to automatically dial a modem and send a specified byte string. To implement this feature, the port must be configured for Serial I/O. For example, pager enunciation can be implemented by three commands, requiring three COMMREQ command blocks: Autodial: 04400 (1130h) Dials the modem. Write Bytes: 04401 (1131h) Specifies an ASCII string, from 1 to 250 bytes in length, to send from the serial port. Autodial: 04400 (1130h) It is the responsibility of the PLC application program to hang up the phone connection. This is accomplished by reissuing the autodial command and sending the hang up command string.

Autodial Command Block


The Autodial command automatically transmits an Escape sequence that follows the Hayes convention. If you are using a modem that does not support the Hayes convention, you may be able to use the Write Bytes command to dial the modem. Examples of commonly used command strings for Hayes-compatible modems are listed below:
Command String ATDP15035559999<CR> ATDT15035559999<CR> ATDT9,15035559999<CR> ATH0<CR> ATZ <CR> Length 16 (10h) 16 (10h) 18 (12h) 5 (05h) 4 (04h) Function Pulse dial the number 1-503-555-9999 Tone dial the number 1-503-555-9999 Tone dial using outside line with pause Hang up the phone Restore modem configuration to internally saved values

12-22

VersaMax PLC Users Manual January 2006

GFK-1503D

12
Example Autodial Command Block
This example COMMREQ command block dials the number 234-5678 using a Hayes-compatible modem.
Word 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Definition 0009h 0000h 0008h 0000h 0000h 0000h 04400 (1130h) 00030 (001Eh) 0012 (000Ch) 5441h 5444h 3332h 3534h 3736h 0D38h NOWAIT mode Status word memory type (%R) Status word address minus 1 (Register 1) not used not used Autodial command number Modem response timeout (30 seconds) Number of bytes in command string A (41h), T (54h) D (44h), T (54h) Phone number: 2 (32h), 3 (33h) 4 (34h), 5 (35h) 6 (36h), 7 (37h) 8 (38h) <CR> (0Dh) Values CUSTOM data block length (includes command string)

GFK-1503D

Chapter 12 Serial I/O / SNP / RTU Protocols

12-23

12
Write Bytes Function (4401)
This operation can be used to transmit one or more characters to the remote device through the specified serial port. The character(s) to be transmitted must be in a word reference memory . They should not be changed until the operation is complete. Up to 250 characters can be transmitted with a single invocation of this operation. The status of the operation is not complete until all of the characters have been transmitted or until a timeout occurs (for example, if hardware flow control is being used and the remote device never enables the transmission).

Example Command Block for the Write Bytes Function


VALUE (decimal) address address +1 address +2 address +3 address +4 address +5 address +6 address +7 address +8 address +9 address +10 address +11 0006 0000 0008 0000 0000 0000 4401 0030 0005 25960 27756 0111 VALUE (hexadecimal) 0006 0000 0008 0000 0000 0000 1131 001E 0005 6568 6C6C 006F NOWAIT mode Status word memory type (%R) Status word address minus 1 (%R0001) Not used Not used Write bytes command Transmit time-out (30 seconds). See note below. Number of bytes to write h (68h), e (65h) l (6Ch), l (6Ch) o (6Fh) MEANING Data block length (includes characters to send)

Although printable ASCII characters are used in this example, there is no restriction on the values of the characters which can be transmitted.

Operating Notes
Note: Specifying zero as the Transmit time-out sets the time-out value to the amount of time actually needed to transmit the data, plus 4 seconds. Caution: If an Initialize Port (4300) COMMEQ is sent or a Cancel Operation (4399) COMMREQ is sent in either Cancel All or Cancel Write mode while this COMMREQ is transmitting a string from a serial port, transmission is halted. The position within the string where the transmission is halted is indeterminate. In addition, the final character received by the device the CPU is sending to is also indeterminate.

12-24

VersaMax PLC Users Manual January 2006

GFK-1503D

12
Read Bytes Function (4402)
This function causes one or more characters to be read from the specified port. The characters are read from the internal input buffer and placed in the specified input data area. The function returns both the number of characters retrieved and the number of unprocessed characters still in the input buffer. If zero characters of input are requested, only the number of unprocessed characters in the input buffer is returned. If insufficient characters are available to satisfy the request and a non-zero value is specified for the number of characters to read, the status of the operation is not complete until either sufficient characters have been received or the time-out interval expires. In either of those conditions, the port status indicates the reason for completion of the read operation. The status word is not updated until the read operation is complete (either due to timeout or when all the data has been received). If the time-out interval is set to zero, the COMMREQ remains pending until it has received the requested amount of data, or until it is cancelled. If this COMMREQ fails for any reason, no data is returned to the buffer. Any data that was already in the buffer remains, and can be retrieved with a subsequent read request.

Example Command Block for the Read Bytes Function


VALUE (decimal) address address +1 address +2 address +3 address +4 address +5 address +6 address +7 address +8 address +9 address +10 0005 0000 0008 0000 0000 0000 4402 0030 0005 0008 0100 VALUE (hexadecimal) 0005 0000 0008 0000 0000 0000 1132 001E 0005 0008 0064 MEANING Data block length NOWAIT mode Status word memory type (%R) Status word address minus 1 (%R0001) Not used Not used Read bytes command Read time-out (30 seconds) Number of bytes to read Input data memory type (%R). Input data memory address (%R0100)

GFK-1503D

Chapter 12 Serial I/O / SNP / RTU Protocols

12-25

12
Return Data Format for the Read Bytes Function
The return data consists of the number of characters actually read, the number of characters still available in the input buffer after the read is complete (if any), and the actual input characters.
Address Address + 1 Address + 2 Address + 3 Address + n Number of characters actually read Number of characters still available in the input buffer, if any first two characters (first character is in the low byte) third and fourth characters (third character is in the low byte) subsequent characters

Operating Note
If the input data memory type parameter is specified to be a word memory type, and if an odd number of bytes are actually received, then the high byte of the last word to be written with the received data is set to zero. As data is received from the serial port it is placed in the internal input buffer. If the buffer becomes full, then any additional data received from the serial port is discarded and the Overflow Error bit in the Port Status word (See Read Port Status Function) is set.

12-26

VersaMax PLC Users Manual January 2006

GFK-1503D

12
Read String Function (4403)
This function causes characters to be read from the specified port until a specified terminating character is received. The characters are read from the internal input buffer and placed in the specified input data area. The function returns both the number of characters retrieved and the number of unprocessed characters still in the input buffer. If zero characters of input are requested, only the number of unprocessed characters in the input buffer are returned. If the terminating character is not in the input buffer, the status of the operation is not complete until either the terminating character has been received or the time-out interval expires. In either of those conditions, the port status indicates the reason for completion of the read operation. If the time-out interval is set to zero, the COMMREQ remains pending until it has received the requested string, terminated by the specified end character. If this COMMREQ fails for any reason, no data is returned to the buffer. Any data that was already in the buffer remains, and can be retrieved with a subsequent read request.

Example Command Block for the Read String Function


VALUE (decimal) 0005 0000 0008 0000 0000 0000 4403 0030 0013 0008 0100 VALUE (hexadecimal) 0005 0000 0008 0000 0000 0000 1133 001E 000D 0008 0064 MEANING Data block length NOWAIT mode Status word memory type (%R) Status word address minus 1 (%R0001) Not used Not used Read string command Read time-out (30 seconds) Terminating character (carriage return): must be between 0 and 255 (0xFF), inclusive Input data memory type (%R) Input data memory address (%R0100)

address address +1 address +2 address +3 address +4 address +5 address +6 address +7 address +8 address +9 address +10

GFK-1503D

Chapter 12 Serial I/O / SNP / RTU Protocols

12-27

12
Return Data Format for the Read String Function
The return data consists of the number of characters actually read, the number of characters still available in the input buffer after the read is complete (if any), and the actual input characters:
Address Address + 1 Address + 2 Address + 3 Address + n Number of characters actually read Number of characters still available in the input buffer, if any first two characters (first character is in the low byte) third and fourth characters (third character is in the low byte) subsequent characters

Operating Note
If the input data memory type parameter is specified to be a word memory type, and if an odd number of bytes are actually received, then the high byte of the last word to be written with the received data is set to zero. As data is received from the serial port it is placed in the internal input buffer. If the buffer becomes full, then any additional data received from the serial port is discarded and the Overflow Error bit in the Port Status word (See Read Port Status Function) is set.

12-28

VersaMax PLC Users Manual January 2006

GFK-1503D

Chapter

13

Ethernet Communications

This chapter describes the Ethernet communications features of VersaMax CPU model IC200CPUE05.

Overview of the Ethernet interface IP Addressing Routers Ethernet Global Data Checking the status of an Ethernet Global Data exchange Diagnostic Tools Troubleshooting Common Ethernet Difficulties

GFK-1503D

13-1

13 Overview of the Ethernet Interface


VersaMax CPU model IC200CPUE05 has a built-in Ethernet interface that makes it possible to communicate on a 10BaseT network in either halfduplex or full-duplex mode. Using 10/100 hubs allows CPUE05 to communicate on a network containing 100Mb devices.Host Computer or Control Device Running a Host Communications Toolkit Application Series 90-70 PLC with Ethernet Interface Programmer Software runninng on a PC

VersaMax PLC with CPUE05

VersaMax PLC with CPUE05

Series 90-30 PLC with Ethernet Interface

Ethernet Cable

Hub

Use the Ethernet interface to:

Send and receive Ethernet Global Data. Ethernet Global Data can be
used for highly efficient periodic data transfer on the LAN.

Access data from CPUE05 using a Host computer. Computer


applications can access data from CPUE05 through its SRTP server capability.

Communicate simultaneously to multiple devices. The multiplexing capabilities of Ethernet interface, along with Ethernet networks high capacity, allow CPUE05 to communicate with several other devices at the same time. Indirectly attach to other Local Area Networks and/or wide area networks via third party IP routers. CPUE05 can communicate with
remote PLCs and other nodes via an IP Router.

Communicate with remote computers via Serial Line Protocol (SLIP) using modems and/or serial lines. Using third party SLIP devices, a
remote host computer can be attached to a TCP/IP network. Once attached, the serial communications can be routed over the Ethernet interface to the CPUE05.

Maintain compatibility with other devices. CPUE05 is compatible with the GE Fanuc Series 90-30 Ethernet Interface, Series 90-30 CPU364 Embedded Ethernet Interface, and Series 90-70 Ethernet Interface (Type 2). It is also compatible with GE Fanuc programming packages supporting TCP/IP Ethernet communications.
GFK-1503D

13-2

VersaMax PLC Users Manual January 2006

13
Ethernet Global Data
CPUE05 also supports up to 32 simultaneous Ethernet Global Data exchanges. Ethernet Global Data exchanges are configured using the PLC programming software, then stored to the PLC. Both Produced and Consumed exchanges may be configured. CPUE05 supports up to 1200 data ranges across all Ethernet Global Data exchanges, and can be configured for selective consumption of Ethernet Global Data exchanges.

SRTP Server
CPUE05 supports up to eight simultaneous SRTP Server connections for use by other devices on the Ethernet network, such as the PLC programmer, CIMPLICITY HMI, SRTP channels for Series 90 PLCs, and Host Communications Toolkit applications. No PLC programming is required for server operation.

SRTP Channels
SRTP Channels can be used by a Series 90-30 or Series 90-70 PLC to communicate with CPUE05. The CPUE05 cannot initiate SRTP channels.

Attachment to the Ethernet LAN


The Ethernet port uses a twisted pair cable of up to 100 meters in length between each node and a hub or repeater. Typical hubs or repeaters support 4 to 12 nodes connected in a star wiring topology.

The Station Manager Software


CPUE05 provides built-in Station Manager support. It accommodates online diagnostic and supervisory access through either the Station Manager port or via Ethernet. Station Manager services include:

An interactive set of commands for interrogating and controlling the station. Unrestricted access to observe internal statistics, an exception log, and configuration parameters. Password security for commands that change station parameters or operation. Access to the Station Manager requires a user-provided computer terminal or terminal emulator.

GFK-1503D

Chapter 13 Ethernet Communications

13-3

13 IP Addressing
The CPUE05 must have a unique IP address that identifies it on the Ethernet network. The IP Address is assigned using the configuration software, as described in chapter 6. The IP address is 32 bits long and has a netid part and a hostid part. The format of the IP address depends on the network class:
01 Class A 0 01 Class B 1 0 01 2 Class C 1 1 0 netid 8 netid 8 netid 16 16 8 16 hostid 24 hostid 24 hostid 31 31 24 31

Each IP address on a network has:

The same class. Each network is a Class A, Class B or Class C network. A Class A network can support 16,777,214 hosts, Class B: 65,534 hosts, and Class C: 254 hosts. The same netid, which is generally assigned by the Internet authorities

A different hostid, giving it a unique IP address. The hostid is generally assigned by your local network administrator. IP addresses are written in dotted-decimal format as four decimal integers (0-255) separated by periods. Each integer represents one byte of the IP address. For example, the 32-bit IP address 00001010 00000000 00000000 00000001 is written as 10.0.0.1 The class of an IP address is indicated by the first decimal integer: Range of first integer
0 - 127 128 - 191 192 - 223 224-239 240 - 255

Class
A B C D (Reserved for Multicast Use) E (Reserved for Experimental Use)

RFC 1918 reserves IP addresses in the following ranges for private networks.
10.0.0.0 10.255.255.255 (Class A) 172.16.0.0 172.31.255.255 (Class B) 192.168.0.0 192.168.255.255 (Class C) x.y.z.1 is reserved for gateways. x.y.z.255 is reserved for subnet broadcast
13-4 VersaMax PLC Users Manual January 2006 GFK-1503D

13 Routers
Routers connect individual physical networks into a system of networks. When a node on one network needs to communicate with a node on another network, a Router transfers the data between the two networks.

Example: Networks Connected by a Router


The following figure shows Network 1 and Network 2 connected by Router R.

A
172.16.0.2 Network 1 172.16.0.1

R B
172.17.0.2

Router

C
172.17.0.3 Network 2

172.17.0.1

Host B can communicate with host C directly because they are on the same network. Their IP addresses have the same netid. However, to send data to host A, which is on another network (it has a different netid,) host B must send it via the router. The router has two IP addresses (172.16.0.1 and 172.17.0.1). The first is used by hosts on Network 1 and the second is used by hosts on Network 2. In this example, the routers IP address on Network 2 is 172.17.0.1. This address would be configured in host B as its default gateway address.

GFK-1503D

Chapter 13 Ethernet Communications

13-5

13 Ethernet Global Data


Ethernet Global Data is data that is automatically sent from one Ethernet device to one or more others. Once Ethernet Global Data has been configured, the data is sent automatically during system operation. No program interaction is necessary to produce or consume the global data. The device that sends the Ethernet Global Data is called the producer. Each device that receives Ethernet Global Data is called a consumer. Each unique Ethernet Global Data message is called an exchange.
PLC1 - Producer PLC2 - Consumer

P
Exchange

C
Ethernet Network

Ethernet Global Data provides simple, regular communication of data between devices. It should not be used for event notification if possible loss of data would be significant. VersaMax CPU IC200CPUE05 can be configured for up to 32 produced Ethernet Global Data exchanges (total of Produced and Consumed) s. Each Ethernet Global Data exchange must be configured individually for each PLC and consists of one or more data ranges. See chapter 6 for configuration information.

The Frequency of Sending/Receiving an Exchange


During configuration, the repetition period of each Ethernet Global Data exchange is set up for the producer. The range is 10 milliseconds to 1 hour, which is selectable in increments of 10 mS. It is not necessary to produce and consume data faster than the application requires. This reduces the load on the network and on the devices, providing capacity for other transfers.

The Consumer Update Timeout Period


As part of the configuration for each consumed exchange, a timeout period can be set up for the exchange. The CPU reports an error if the first or subsequent packet of data has not arrived within the specified time. The range is 0 for no timeout detection, or 10 to 3,600,000 milliseconds. The consumers timeout period should be greater than the producers repetition period. GE Fanuc recommends that the consumer timeout be set to no lower than twice the production period,
13-6 VersaMax PLC Users Manual January 2006 GFK-1503D

13
Ethernet Global Data Groups
If more than one device on the network should consume a Global Data exchange, those devices can be set up as a group. The network can include up to 32 numbered groups. Groups allow each sample from the producer to be seen simultaneously by all consumers in the group. A device can belong to more than one group, as illustrated below.
Group 2
I0.0.0.1 I0.0.0.2

Group 1
I0.0.0.3 I0.0.0.4

Group 2
I0.0.0.5 I0.0.0.6 I0.0.0.7 I0.0.0.8

Each device in a group responds to the groups assigned ID number. For CPUE05, the Group IDs are 1 to 32. Each Group ID corresponds to a Multicast (Class D) IP address reserved by the Internet authorities. The default Multicast IP addresses used by Ethernet Global Data are: Group ID 1 2 . . . 32 IP Address 224.0.7.1 224.0.7.2 . . . 224.0.7.32

Group Multicast IP Addresses used by Ethernet Global Data should not be changed unless the defaults would cause a network conflict. If necessary, they can be changed within the reserved range of multicast IP addresses (224.0.0.0 through 239.255.255.255). The change must be made using an Advanced User Parameter File.

GFK-1503D

Chapter 13 Ethernet Communications

13-7

13
Timestamping of Ethernet Global Data Exchanges
The PLC CPU timestamps each Ethernet Global Data Message it produces. The timestamp indicates when the data was transferred from the producing PLC's CPU to its Ethernet interface for transmission over the network. The PLC CPU obtains the timestamp data from the time clock in the Ethernet interface. The CPU only uses this timestamp for Ethernet Global Data exchanges. The timestamp from the Ethernet interface does not affect the time of the CPU's internal time clock.
CPUE05 CPU Ethernet interface

CPU time clock timestamp time clock

EGD with timestamp

Synchronizing the Timestamp


The timestamp clock in the Ethernet interface is synchronized to either the clock in the CPU or an external Network Time Protocol (NTP) server.

The CPU Time Clock: If no NTP servers are configured, the Ethernet interfaces built-in time clock is synchronized once, at power-up or restart, to the clock in the CPU. Because the clocks in the other devices on the network are not synchronized with the CPUE05, their timestamps cannot be compared accurately.
CPUE05 CPU Ethernet interface

CPU time clock

CPU Time

timestamp

time clock

13-8

VersaMax PLC Users Manual January 2006

GFK-1503D

13
NTP Server's Time Clock: If time servers are configured and present on the network (see chapter 6 for configuration details), the Ethernet interfaces built-in clock is periodically synchronized to the clock from one to three NTP servers on the network. The Ethernet interface periodically requests time from the servers and uses the time from the most accurate server (based on NTP stratum number).
CPUE05 CPU Ethernet interface NTP Time Server on Network

CPU time clock time clock

NTP Time

timestamp

EGD with timestamp

All Ethernet interfaces that have been configured to use Network Time Protocol will have updated, synchronized timestamps because they are all controlled by the NTP server clock. Therefore, accurate timing comparisons between exchanged data can be made. For example, if several PLCs sent alarm data, it might be helpful to know the order in which the alarms occurred. Multiple NTP servers can be used to improve the availability of time servers. When the time is obtained from an NTP server, dates from January 1, 1970 are supported by the Ethernet Interface.

Configuring NTP for the CPUE05 Ethernet Interface


To implement Network Time Protocol in the Ethernet interface in CPUE05, the IP address of one to three NTP Time Servers are specified in the PLC Ethernet configuration. See Configuring the Ethernet Interface in chapter 6 for details. CPUE05 does not support multicast NTP operation; multiple NTP servers may be specified individually. The Ethernet interface in CPUE05 always operates in client mode. It will synchronize to an NTP time server, but it will not synchronize other devices on the network. Time synchronization takes multiple message exchanges to reach maximum precision. Based on the default configuration of poll times, NTP synchronization should occur approximately 2 minutes after a time server has been established.
GFK-1503D Chapter 13 Ethernet Communications 13-9

13
The Content of an Ethernet Global Data Exchange
Each Ethernet Global Data exchange is composed of one or more data ranges transmitted as a sequence of 1 to 1400 bytes of data. The content of the data is defined for both the producer and consumers of the data. In this example, a producer sends an 11-byte exchange consisting of the current contents of %R00100 through %R00104 followed by the current contents of %I00257 through %I00264: Address
%R00100 %I00257

Length
5 1

Type
WORD BYTE

Description
Conveyor1 in PLC1 Conveyor1 limit switch in PLC1

The same exchange can be configured for each consumer to suit the needs of the application. The size of the exchange must be consistent on all nodes.

Data Types for Ethernet Global Data


The table below lists memory types that can be configured for produced and/or consumed Ethernet Global Data. Type
%R %AI %AQ %I %Q %T %M %SA %SB %SC %G

Description
Register memory in word mode Analog input memory in word mode Analog output memory in word mode Discrete input memory in byte mode Discrete output memory in byte mode Discrete temporary memory in byte mode Discrete momentary memory in byte mode Discrete system memory group A in byte mode Discrete system memory group B in byte mode Discrete system memory group C in byte mode Discrete global data table in byte mode

Producer or Consumer
P/C P/C P/C P/C P/C P/C P/C P/C P/C P/C P/C

13-10

VersaMax PLC Users Manual January 2006

GFK-1503D

13
The Data Ranges in a Global Data Exchange
The variable ranges in an exchange are defined in the Ethernet Global Data configuration in hardware configuration. There can be:

Up to 1200 data ranges for all EGD exchanges for one CPUE05. Up to 100 data ranges per exchange. A length of 1 byte to 1400 bytes per exchange. The total size of an exchange is the sum of the data lengths of all of the data ranges configured for that exchange.

Different exchanges may share some or all of the same data ranges even if the exchanges are produced at different rates. A consumer does not have to consume all of the data from a produced exchange. A consumed exchange may be configured to ignore specified data ranges. (See Selective Consumption in chapter 6.)

Effect of PLC Modes and Actions on Ethernet Global Data


The usual PLC mode for Ethernet Global Data operation is Run with I/O enabled. In that mode, Ethernet Global Data remains configured and exchanges are both produced and consumed. If the PLC mode is set to Stop with I/O disabled, the Producer ID remains configured, but production and consumption stops. The samples of the consumed exchanges received while the PLC is stopped continue to be processed by the Ethernet interface. The latest received data from the network will be available to the application when the PLC returns to an I/O enabled state. The table below summarizes what happens to the configuration and operation of Ethernet Global Data in different PLC modes. Exchanges continue to be PLC Mode or Action RUN-Outputs Enabled STOP-I/O Enabled STOP-I/O Disabled Produced yes yes no Consumed yes yes no *

* The latest data from the network is available to the application when the PLC transitions from Stop to Run mode.

GFK-1503D

Chapter 13 Ethernet Communications

13-11

13
EGD Synchronization
Ethernet Global Data attempts to provide the most up-to-date process data, consistent with the configured schedule. The Ethernet interface maintains a timer for each produced exchange. When the timer for the exchange expires, the Ethernet interface requests that the data for the exchange be transferred from reference memory during the output scan portion of the next CPU sweep. Once the data has been transferred by the CPU sweep, the Ethernet interface immediately formulates a sample and transfers the sample on the network. As soon as a sample for a consumed exchange is received, it is transferred to the CPU during the next input scan portion of the CPU sweep. The result of this scheduling method for Ethernet Global Data is a variability of up to one producer CPU sweep time in the interval between samples produced on the network. This variability in the time between samples is present to assure that the most up-to-date data is being transferred. In general, it is not useful or necessary to configure the production period to be less than the CPU sweep time. If the producer period for an exchange is set lower than the CPU sweep time, the Ethernet interface will send a stale sample (a sample containing the same data as previously sent) at the configured interval. When the fresh CPU data becomes available at the end of the sweep, the Ethernet interface will immediately send another sample with the fresh data. The timer of the produced exchange is not reset when this sample is sent. This can result in more samples in the network than would be expected from the configured period.

13-12

VersaMax PLC Users Manual January 2006

GFK-1503D

13
Timing Examples
The following illustrations show the relationship between the PLC output scan time, the produced exchange timer, and data samples on the network.

Example 1
Only one sample is produced on the network per producer period expiration. The variability between samples can be up to producer CPU sweep time.
Producer Period = 1.5 Times CPU Sweep Producer PLC Output Scan Ethernet Global Data Production Timer Expires Sample on Network

Example 2
More than one sample can be produced per producer period expiration and stale samples are produced to the network.
Producer Period = 2/3 Time of CPU Sweep Producer PLC Output Scan Ethernet Global Data Production Timer Expires Sample on Network

Stale Data is Produced

GFK-1503D

Chapter 13 Ethernet Communications

13-13

13 Diagnostic Tools
There are several tools to assist you in diagnosing problems that may occur with Ethernet operations and Ethernet Global Data.

Check the Ethernet LEDs, as detailed on the following pages, to troubleshoot a problem on power-up of the Ethernet Interface. The LEDs provide an immediate visual summary of the operating state of the Interface. Use the PLC Fault Table, also explained in this chapter. The PLC Fault Table records exceptions logged by the PLC, the Ethernet interface, and other modules. The PLC Fault Table is accessed through the PLC programming software. The application program can use special status data to monitor Ethernet operations.

The Ethernet interface status address, selected during PLC configuration, contains information about the operating status of the Ethernet interface. The Exchange Status words, selected during Ethernet Global Data configuration, contain information about the status of exchange operations.

Use the Station Manager function to troubleshoot a problem with the Ethernet Interface, with the network, with PLC backplane communication, or with your application. The LOG, TALLY, and STAT Station Manager commands are especially useful. Refer to the VersaMax PLC Ethernet Station Manager Manual, for information on how to access and use the Station Manager.

13-14

VersaMax PLC Users Manual January 2006

GFK-1503D

13
What to do if you Cannot Solve the Problem
If you still cannot solve your problem, call GE Fanuc Automation NA, 1800-GE FANUC. Please have the following information available when you call.

The Name and Catalog Number marked on the product. Description of symptoms of problem. Depending on the problem, you may also be asked for the following information: 1. The ladder logic application program and the PLC sweep length at the time the problem occurred. 2. A listing of the configuration parameters for the Ethernet Interface that failed. 3. A description of the network configuration. This should include the number of PLCs and host computers accessing the network, the type of network cable used (e.g. twisted pair, fiber optic, etc.), length of network cable, and the number and manufacturer of transceivers, hubs, and network switches used.

Checking the Ethernet LEDs


After configuring the Interface, follow the steps below to verify that the Ethernet Interface is operating correctly. 1. Turn power OFF to the PLC for 35 seconds, then turn the power back ON. This starts a series of diagnostic tests. During powerup diagnostics, after a brief delay the STAT LED on the Ethernet side of the CPU module blinks. Both the LAN and PORT1 LEDs are off. If a fatal diagnostic failure occurs, the failure is indicated by a two-digit pattern in amber on the STAT LED. After successful power-up, all three LEDs on the Ethernet side turn on briefly. Then the STAT and LAN LEDs should be green. The LAN LED blinks when there is traffic. If the STAT LED is amber, check the PLC Fault Table. With the Station Manager feature, you can also use the LOG command as explained in GFK-1876, The VersaMax PLC Ethernet Station Manager Manual.

2.

3.

If a problem occurs during power-up, the Ethernet interface may not begin operating. Check the Ethernet LEDs, as explained on the following pages.

GFK-1503D

Chapter 13 Ethernet Communications

13-15

13
Ethernet LEDs
Off
LAN STAT PORT 1 Off Off Off

Indications

Actions

Make sure the PLC has power Look in the PLC Fault Table for problems Recheck configuration Check module installation

LAN STAT PORT 1

Off Fast blink green Off

Performing powerup diagnostics

If the problem persists, replace PLC CPU No action necessary; diagnostics will complete within 3 to 10 seconds.

LAN STAT PORT 1

Off Blinking amber Off

Hardware failure mode. STAT: Blinks 2-digit error code: 1 2 unexpected interrupt 1 3 timer failure 1 4 DMA failure 2 1 RAM failure 2 2 stack error 2 3 shared memory interface error 2 4 firmware CRC error 3 - 1 unidentified instruction, or divide by 0 3 2 unexpected SWI interrupt 3 3 prefetch abort error 3 - 4 data abort error 3 5 unexpected IRQ request 3 6 unexpected FIQ interrupt 3 - 7 reserved exception error 4 - 1 fatal operating system startup or EEPROM error

Note error code Power cycle or restart Ethernet interface If problem persists, replace the PLC hardware.

13-16

VersaMax PLC Users Manual January 2006

GFK-1503D

13
Ethernet LEDs
LAN STAT PORT 1 Off Slow blink green Off

Indications
Waiting for Ethernet configuration data from CPU. PORT 1: PLC CPU is controlling Port 1.

Actions

Use the PLC programmer to update the configuration, then store the configuration to the PLC. Power cycle the PLC.

LAN STAT PORT 1

LAN STAT PORT 1

LAN STAT PORT 1

LAN STAT PORT 1

Waiting for IP Address LAN: Ethernet interface is Slow blink green online. Flickers during Off activity. STAT: IP Address has not been configured. PORT 1: PLC CPU is controlling Port 1. Waiting for IP Address Green / flickering LAN: Ethernet interface is Slow blink green online. Flickers during activity. Amber STAT: IP Address has not been configured. PORT 1: Available for Station Manager use Waiting for IP Address Amber LAN: Ethernet interface is Slow blink green offline. Attempting to recover Amber if possible. STAT: IP Address has not been configured. PORT 1: PLC CPU is controlling Port 1. Waiting for IP Address Amber LAN: Ethernet interface is Slow blink green offline. Attempting to recover Amber if possible. STAT: IP Address has not been configured. PORT 1: Available for Station Manager use
Green / flickering

Clear faults and press the Restart pushbutton for less than 5 seconds to restart the Ethernet interface. IP address has not been configured, or has been configured as 0.0.0.0 Use the PLC programmer to configure a non-zero IP address.

GFK-1503D

Chapter 13 Ethernet Communications

13-17

13
Ethernet LEDs
LAN STAT PORT 1 Green / flickering Green Off

Indications
Operational LAN: Ethernet interface is online. Flickers during activity. STAT: No exception detected PORT 1: PLC CPU is controlling Port 1. Operational LAN: Ethernet interface is online. Flickers during activity. STAT: No exception detected PORT 1: Forced to Station Manager use Operational LAN: Ethernet interface is offline. Attempting to recover if possible. STAT: No exception detected PORT 1: PLC CPU is controlling Port 1. Operational LAN: Ethernet interface is offline. Attempting to recover if possible. STAT: No exception detected PORT 1: Forced to Station Manager use Software Load Loading new firmware (via CPU serial port)

Actions
If LAN is off, the problem may be: Network cable not connected either at the PLC or at the hub. Hub disconnected/failed. Network cable not properly terminated. If STAT is amber, an exception condition has occurred.

LAN STAT PORT 1

Green / flickering Green Amber

LAN STAT PORT 1

Amber Green Off

LAN STAT PORT 1

Amber Green Amber

LAN STAT PORT 1

Slow blink green, all LEDS blink in unison

No action necessary; the Ethernet interface restarts automatically after loading is complete

13-18

VersaMax PLC Users Manual January 2006

GFK-1503D

13
Using the PLC Fault Table
Most error conditions involving the Ethernet interface generate faults in the PLC Fault table. The table on the next page lists Ethernet interface faults and corrective actions. To display fault text for the Ethernet interface, access the PLC Fault Table from the programmer. For the Ethernet interface the leftmost 14 digits of extra fault data show the corresponding log Events (2 digits) and Entries 2, 3, 4, 5, and 6 (in that order, 4 digits each), and other optional data. The following example reports an Event 8, Entry 2=9, Entry 3=4, Entry 4 = 22H, Entry 5 = 1, Entry 6=c74H, and SCode = 80050028H.
0800090004002200010c7480050028000000000000000000

SCode Entry 6 Entry 5 Entry 4 Entry 3 Entry 2 Event

This information can be used to refer directly to detailed fault descriptions included in the Log event table under the LOG command in the VersaMax PLC Station Manager Manual. Please note some internal system errors display error messages as ASCII text in the fault extra data.

GFK-1503D

Chapter 13 Ethernet Communications

13-19

13
PLC Fault Table Descriptions
PLC Fault
Backplane communications with PLC fault; lost request

User Action
Check that PLC CPU is running normally (usually in Run mode) * Check to make sure you are not sending COMMREQs faster than the Ethernet interface can process them. *

Bad local application request; discarded Check for valid COMMREQ command code. * request Bad remote application request; discarded request Cant locate remote node; discarded request Try to validate the operation of the remote node. * Error reported when message received where IP address cannot be resolved. Error may indicate that remote host is not operational on the network. Check that remote host is operational on network and its addresses are correct. Message from PLC for unknown Ethernet interface task. Check COMMREQ function block. Check COMMREQ to make sure sent in no-wait mode. The Ethernet interface does not have free memory to process communications. * Verify that connection limits are not being exceeded. Ethernet interface is not properly connected to the network. Check the connection to the network hub or switch. Internal system error. *

Comm_req Bad task ID programmed Comm_req Wait mode not allowed LAN data memory exhausted check parms; resuming LAN I/F capacity exceeded; discarded request LAN transceiver fault; Off network until fixed LAN system-software fault; aborted connection resuming LAN system-software fault; restarted LAN IF LAN system-software fault; resuming Module software corrupted; requesting reload Module state doesnt permit Comm_Req; discarded Unsupported feature in configuration

Catastrophic internal system error. Contact GE Fanuc Automation NA. COMMREQ received when Ethernet interface cannot process COMMREQ. Make sure Ethernet interface is configured and online. Attempt has been made to configure a feature not supported by the Ethernet interface. Check CPU revision; order upgrade kit for CPU and/or Ethernet interface.

* If the problem persists, contact GE Fanuc Automation NA.

13-20

VersaMax PLC Users Manual January 2006

GFK-1503D

13
Checking the Status of the Ethernet Interface
The application program can monitor the status of the Ethernet interface using the status bits described below. The beginning address of the data is the Status Address entered when configuring the CPU. See Configuring the Ethernet Interface in chapter 6 for details. The Ethernet interface updates these status bits every PLC I/O scan. The Ethernet status bits normally occupy a single block of memory. Most of these bits are reserved. Five are of interest for checking the status of the Ethernet interface: Status Bits
12 3 4-12 13 14 15 16 17-80 LAN OK Resource problem Reserved, always 0 LAN Interface OK Reserved Full-duplex Reserved, always 0

Brief Description
Reserved, always 0

Bit 3: Full Duplex

If this bit 3 is 1, CPUE05 is operating in full-duplex Ethernet mode. Fullduplex or half-duplex operation is automatically negotiated between the CPUE05 and its immediately-connected network device, usually a network hub. If this bit is 0, CPUE05 is operating in half-duplex Ethernet mode. This bit is only valid if bit 13 (LAN OK) is 1. This bit is 1 while the Ethernet interface is able to communicate on the network. If the network is not accessible due to local or network problems, this bit is 0. When communication resumes, it is automatically set to 1. This bit is 1 whenever the Ethernet interface has a resource problem (i.e., lack of data memory). The bit is reset to 0 on a subsequent PLC sweep. The Ethernet interface may or may not be able to continue functioning, depending on the severity of the problem. Use the PLC Fault Table to identify the problem. The Station Manager STAT B and LOG commands can also provide more information. When this bit is 1, the Ethernet interface is properly initialized. When this bit is 0, all other Ethernet status bits are invalid.

Bit 13: LAN OK Bit 14: Resource Problem

Bit 16: LAN Interface OK

GFK-1503D

Chapter 13 Ethernet Communications

13-21

13
Checking the Status of an Ethernet Global Data Exchange
To check the status of any Ethernet Global Data exchange, monitor the value in the Exchange Status word (selected during Ethernet Global Data configuration). The PLC automatically writes exchange status information in this location when:

a producer/consumer period expires ( the value is set for the entire period). an Ethernet Global Data configuration is stored to the PLC. the PLC powers up and it has an Ethernet Global Data configuration. the Ethernet interface configured for Ethernet Global Data is restarted.

If the application program uses the Exchange Status word to check exchange status, it must clear this word to 0 once a non-zero value is written to it. That allows the application program to detect a new exchange status in subsequent sweeps.

13-22

VersaMax PLC Users Manual January 2006

GFK-1503D

13
The Exchange Status word uses the error codes below to report exchange status. See also the Troubleshooting Common Ethernet Difficulties section later in this chapter.
Value (Decimal) 0 Error Exchange status has not been updated No error NTP error Specification error Description Produced: Initial value until the first producer period refresh occurs. Consumed: The data has not been refreshed and timeout has not expired. Produced: The produced exchange is producing data. Consumed: The data has been refreshed on schedule. Consumed only: The CPU is configured for network time synchronization, but is not synchronized. Produced and Consumed: Error configuring the exchange. For CPUE05, this error does NOT indicate a consumed exchange size miscomparison.

1 3 4 6 7 10 12 14

Refresh timeout Consumed only: The timeout period has expired but data without data. has not been refreshed from the network. Consumed only: The data has been refreshed since the Data after previous consumption, but was not refreshed within the refresh timeout timeout period. IP connection not available Lack of resource error Length error Produced and Consumed: The IP network connection is not available. Produced and Consumed: Local resources are not available to establish the exchange. Look in the PLC Fault Table for details. Consumed only: The packet received did not match the length expected.

18

Produced and Consumed: The Ethernet interface is not communicating with the CPU. A loss of module or reset of Loss of Ethernet module PLC Fault Table entry may also be present. If the interface error failure is transient in nature, the status of the exchange may change at a later time. That indicates subsequent transfers on the exchange were successful. EGD not supported No response Other error Exchange deleted This error cannot occur with CPUE05. Produced and Consumed: Ethernet interface failed to establish exchange. Produced and Consumed: Error other than 12, 14, 18, or 26 when establishing an exchange. Look in the PLC Fault Table for information. Produced And Consumed: Exchange has been deleted and will no longer be scanned.

22 26 28 30

GFK-1503D

Chapter 13 Ethernet Communications

13-23

13
Using the Ethernet Station Manager Function
CPUE05 provides local Station Manager operation via Port 1. This port can be configured for either CPU serial communications (SNP, RTU, Serial I/O) or local Station Manager use. While Port 1 is configured as a local Station Manager, it cannot be used for CPU serial communications or firmware loading. However, if the port is configured as a CPU port instead (the default setting), it can temporarily be forced to local Station Manager operation using the Restart pushbutton (or using the chport1 Station Manager command). The CPUE05 also supports remote Station Manager operation over the Ethernet network via UDP protocol. With UDP protocol, the remote station is addressed via an IP address. Unlike some Series 90 Ethernet products, CPUE05 cannot send or receive remote Station Manager messages that have been sent to a specified MAC address. For a detailed description of Station Manager functions, please refer to GFK-1876, the VersaMax PLC Ethernet Station Manager Users Manual.

13-24

VersaMax PLC Users Manual January 2006

GFK-1503D

13 Troubleshooting Common Ethernet Difficulties


Some common Ethernet errors are described below. Ethernet errors are generally indicated in the PLC Fault Table and the Ethernet exception log. As previously explained in Using the PLC Fault Table, PLC Faults generated by the Ethernet interface contain Ethernet exception events within the extra fault data. See the VersaMax Station Manager Manual, GFK-1876 for detailed descriptions of Ethernet exception events.

PLC Timeout Errors


When the SRTP traffic to the CPUE05 exceeds the PLCs ability to process the requests, PLC Timeout errors may occur. PLC Timeout errors will take down an SRTP Server connection; in this case, the remote SRTP client must reestablish a new SRTP connection to the CPUE05. This error is indicated in the PLC Fault Table as: Backplane communication with PLC fault; lost request with exception Event = 8, Entry 2 = 8 Backplane communication with PLC fault; lost request (no exception Event) These errors may also be accompanied by either of the following: Backplane communication with PLC fault; lost request with exception Event = 8, Entry 2 = 6 LAN system-software fault; resuming with exception Event = 8, Entry 2 = 16 The PLC Timeout condition occurs when the CPUE05 cannot process requests within a specified timeout period. The remedy is to reduce the requests, or increase the processing capacity in the PLC.
Cause Heavy SRTP traffic. Long PLC sweep time. PLC Communication Window set to LIMITED mode. Corrective Action Reduce the size, number, or frequency of SRTP requests at the remote SRTP client. Modify the PLC application to reduce the PLC sweep time. Change to RUN-TO-COMPLETION mode.

If none of the above corrective actions is feasible, the timeout interval may be lengthened. The timeout interval is specified by the crsp_tmot Advanced User Parameter. The default timeout value is 15 seconds. See Configuring Advanced User Parameters in chapter 6 to change Advanced User Parameter values.
GFK-1503D Chapter 13 Ethernet Communications 13-25

13
Note that changing this timeout value does not reduce the actual time for the PLC to process the requests.

Unexpected Ethernet Restart or Runtime Errors


Sustained heavy EGD and/or SRTP operation can exceed the data transfer and processing capacity of the CPUE05. This can result in missed EGD exchanges, unexpected automatic restarts of the Ethernet interface within the CPUE05, or runtime fatal errors at the Ethernet interface. Restart errors are indicated in the PLC Fault Table as one or more of the following: Loss of daughterboard (no exception Event) Reset of daughterboard (no exception Event) LAN system-software fault; restarted LAN I/F with exception Event = 3, Entry 2 = 1, Entry 3 = 5f0fH After any of the above errors, the Ethernet interface restarts itself automatically without manual intervention. The above Ethernet restarts may be accompanied by one or more of the following in the PLC Fault Table: Backplane communications with PC fault; lost request (no exception event) LAN system-software fault; resuming with exception Event = 28, Entry 2 = 1, SCode = 95255037H Runtime errors suspend normal operation and a blink fatal error code in amber at the STAT LED. To recover, manually restart the Ethernet interface. Runtime error codes 31 and 33 have been observed under heavy load. See Checking the Ethernet LEDs section earlier in this chapter for descriptions of runtime diagnostic fatal error codes. All Ethernet Global Data (EGD) exchanges default to status code 18 (0012H) during a loss or reset of the Ethernet interface. EGD operation will resume after the restart is complete. These restart and runtime errors occur when the CPUE05 cannot process the attempted volume of EGD and/or SRTP requests. As these errors have been observed only when the CPUE05 is connected to a repeater-type network hub, the primary remedy is to replace the repeater-type hub with a switching-type network hub. A secondary remedy is to reduce the number, size, or frequency of the EGD exchanges and/or transfers over SRTP connections.

13-26

VersaMax PLC Users Manual January 2006

GFK-1503D

13
EGD Configuration Mismatch Errors
When using Ethernet Global Data, the produced exchange (defined at the producer) must agree with the consumed exchange (defined at the consumer). The consumer generates an error when the size of an exchange received from the network differs from the configured size for that consumed exchange. This error is indicated in the PLC Fault Table as: LAN system-software fault; resuming with exception Event = 28, Entry 2 = 1d As this error is generated each time the mismatched exchange is received, the Ethernet exception log can quickly fill up with mismatch error events.
Cause Producer and Consumer exchange definitions are of different size. Corrective Action Review the conflicting exchange definitions at the producer and at the consumer. Change the incorrect exchange definition so that produced and consumed definitions are the same size.

If the consumer wishes to ignore certain portions of a consumed exchange, be sure that the length of the ignored portions is correct. The ignored portion is specified as a byte count.

Receive Resource Exhaustion Errors


Heavy network traffic can exhaust available memory in the Ethernet interface used for network communications. This most often occurs under heavy Ethernet Global Data (EGD) traffic on a busy network. Since the traffic on the network is unpredictable, this error condition may always occur. This error is indicated in the PLC Fault Table as: LAN system-software fault; resuming with exception Event = 28, Entry 2 = 1
Cause Heavy EGD traffic exhausts network data buffers. Bursts of heavy network traffic are received at the CPUE05. Corrective Action Modify the application to reduce the number, size, or frequency of produced and consumed EGD exchanges. Analyze the broadcast and multicast network traffic received at the CPUE05. Reduce such traffic if possible.
13-27

GFK-1503D

Chapter 13 Ethernet Communications

13
Station Manager Lockout under Heavy Load
Sustained heavy EGD and/or SRTP Server load can utilize all processing resources within the Ethernet interface, effectively locking out the Station Manager function. The Station Manager appears inoperative under either local or remote operation. The Ethernet interface always gives higher priority to data communication functions than to the Station Manager. When the processing load is reduced, the Station Manager becomes operative once again. This condition is not reported to the PLC Fault Table or Ethernet exception log.

PING Restrictions
To conserve network data buffer resources, the CPUE05 process only one ICMP control message at a time. An ICMP Echo (ping) request that arrives while the CPUE05 is processing another ICMP control message is discarded. When multiple remote hosts attempt to ping the CPUE05 at the same time, some individual ping requests may be ignored depending upon the timing of the ping requests on the network. The CPUE05 may initiate ping requests to another host on the network via the ping Station Manager command. The ping request sequence is restricted to one remote host at a time. Discarded ping requests are not reported to the PLC Fault Table or Ethernet exception log.

SRTP Connection Timeout


When a remote SRTP client is abruptly disconnected from a CPUE05 (for example, by disconnecting the Ethernet cable), the underlying TCP connection attempts to re-establish communication. The SRTP connection in the CPUE05 remains open for approximately 5 minutes while TCP attempt to reconnect; during this interval, the SRTP connection is unavailable. If all the SRTP connections in the CPUE05 are in use or otherwise unavailable, a new SRTP client connection must wait until the TCP reconnect time expires on an existing connection. The SRTP connection timeout is normal expected behavior, and is consistent with other GE Fanuc PLC products.

13-28

VersaMax PLC Users Manual January 2006

GFK-1503D

Chapter

14

PID Built-in Function Block

This chapter describes the PID (Proportional plus Integral plus Derivative) built-in function block, which is used for closed-loop process control.

Operands of the PID Function Reference Array for the PID Function PID Algorithm Selection and Gain Calculations Determining the Process Characteristics Setting and Tuning Loop Gains Example

GFK-1503D

14-1

14 Operands of the PID Function


The PID function compares feedback from a process variable (PV) with a desired process set point (SP) and updates a control variable (CV) based on the error. The PID function uses PID loop gains and other parameters stored in a 40-word reference array of 16-bit integer words to solve the PID algorithm at the desired time interval.

Parameters of the PID Function Block


Parameter Description Allowed Types WORD Allowed Operands R, L, P, W and symbolic Optional No

Address Location of the PID reference array, (????) which contains user-configurable and internal parameters, described on page 14-3. Uses 40 words that cannot be shared. SP The control loop or process Set Point. Set using Process Variable counts, the PID function adjusts the output Control Variable so that the Process Variable matches the Set Point (zero error). Process Variable input from the process being controlled. Often a %AI input. When energized to 1 (through a contact), the PID function block is in manual mode. If this input is 0, the PID function block is in automatic mode. If energized along with MAN, increases the Control Variable by 1 CV count per solution of the PID function.

INT, BOOL array of length 16 or more

All except S, No SA, SB, and SC

PV

INT, BOOL array of length 16 or more NA

All except S, No SA, SB, and SC, and constant Flow No

MAN

UP

NA

Flow

No

DN

If energized along with MAN, decreases NA the Control Variable by 1 CV count per solution of the PID function. The Control Variable output to the process. Often a %AQ output. INT, BOOL array of length 16 or more

Flow

No

CV

All except %S and constant

No

14-2

VersaMax PLC Users Manual January 2006

GFK-1503D

14 Reference Array for the PID Function


This parameter block for the PID function occupies 40 words of memory, located at the starting Address specified in the PID function block operands. Some of the words are configurable. Other words are used by the CPU for internal PID storage and are normally not changed. Every PID function call must use a different 40-word memory area, even if all the configurable parameters are the same. The configurable words of the reference array must be specified before executing the PID function. Zeros can be used for most default values. Once suitable PID values have been chosen, they can be defined as constants in BLKMOV functions so the program can set and change them as needed. The PID function does not pass power flow if there is an error in the configurable parameters. The function can be monitored using a temporary coil while modifying data. Note: If you set the Override bit (bit 0) of the Control Word (word 15 of the reference array) to 1, the next four bits of the control word must be set to control the PID function block input contacts, and the Internal SP (word 16) and Internal PV (word 18) must be set because you have taken control of the PID function block away from the ladder logic.

Scaling Input and Outputs


All parameters of the PID function are 16 bit integer words for compatibility with 16 bit analog process variables. Some parameters must be defined in either PV counts or units or in CV counts or units. The SP input must be scaled over the same range as the PV, because the PID function calculates error by subtracting these two inputs. The process PV and control CV counts do not have to use the same scaling. Either may be -32000 or 0 to 32000 to match analog scaling, or from 0 to 10000 to display variables as 0.00% to 100.00%. If the process PV and control CV do not use the same scaling, scale factors are included in the PID gains.

Reference Array Parameters


The reference array parameters are described on the following pages. The Machine Edition software allows you to modify the configurable parameters for a PID instruction in real time in online programmer mode. To customize PID parameters, right click the PID function and select Tuning.

GFK-1503D

Chapter 14 PID Built-in Function Block

14-3

14

Words 1 Loop Number

Parameter/Description

Low Bit Units Integer

Range 0 to 255 (for user display only) Set by the CPU 0 (every sweep) to 65535 (10.9 Min) At least 10ms. Dead Band +: 0 to 32767 (never negative) Dead Band -: -32768 to 0 (never positive)

(Address + 0) Optional number of the PID block. It provides a common identification in the CPU with the loop number defined by an operator interface device. 2 Algorithm (Address + 1) 1 = ISA algorithm 2 = independent algorithm 3 Sample Period 10 ms. (Address + 2) The shortest time, in 10 ms. increments, between solutions of the PID algorithm. For example, use a 10 for a 100ms. sample period.

Dead Band + 4,5 (Address + 3, Dead Band Address + 4) Integral values defining the upper (+) and lower (-) Dead Band limits. If no Dead Band is required, these values must be 0. If the PID Error (SP - PV) or (PV SP) is above the (-) value and below the (+) value, the PID calculations are solved with an Error of 0. If nonzero, the (+) value must greater than 0 and the (-) value less than 0 or the PID block will not function. Leave these at 0 until the PID loop gains are set up or tuned. A Dead Band might be added to avoid small CV output changes due to variations in error.

PV Counts

PID_IND: Proportional Gain (Kp) 0.01 6 CV%/PV% (Address + 5) PID_ISA: Controller gain (Kc = Kp) PID_IND: Change in the Control Variable in CV Counts %CV / %PV for a 100 PV Count change in the Error term. Entered as an integer representing a fixed-point decimal ratio with two decimal places. Displayed as a ratio of percentages with two decimal places. For example, a Kp entered as 450 is displayed as 4.50 and results in a Kp * Error / 100 or 450 * Error / 100 contribution to the PID Output. PID_ISA: Same as PID_IND. Kp is generally the first gain set when adjusting a PID loop.

0 to 327.67%

14-4

VersaMax PLC Users Manual January 2006

GFK-1503D

14
Words 7 Parameter/Description Low Bit Units Range 0 to 327.67 sec

PID_IND: Derivative Gain (Kd) 0.01 PID_ISA: Derivative Time (Td = Kd) seconds (Address + 6) PID_IND: Change in the Control Variable in CV Counts if the Error or PV changes 1 PV Count every 10 ms. Entered as an integer representing a fixed-point decimal time in seconds with two decimal places. The least significant digit represents 0.01 second (10ms.) units. Displayed as seconds with two decimal places. For example, Kd entered as 120 is displayed as 1.20 Sec and results in a Kd * Error / delta time or 120 * 4 / 3 contribution to the PID Output if Error changing by 4 PV Counts every 30ms. Kd can be used to speed up a slow loop response, but is very sensitive to PV input noise. This noise sensitivity can be reduced by using the derivative filter, which is enabled by setting bit 5 of the Config Word (see page 14-7.) PID_ISA: The ISA derivative time in seconds, Td, is entered and displayed in the same way as Kd. Total derivative contribution to PID Output is Kc * Td * Error / dt. PID_IND: Integral Rate (Ki) Repeats/ 0.001 Sec. (Address + 7) PID_ISA: Integral Rate (1/Ti = Ki) PID_IND: Rate of change in the Control Variable in CV Counts per second when the Error is a constant 1 PV Count. Entered as an integer representing a fixed-point decimal rate with three decimal places. The least significant digit represents 0.001 counts per second, or 1 count per 0.001 second. Displayed as Repeats/Sec with three decimal places. 8 For example, Ki entered as 1400 is displayed as 1.400 Repeats/Sec and results in a Ki * Error * dt or 1400 * 20 * 50/1000 = 1,400 contribution to PID Output for an Error of 20 PV Counts and a 50 ms. CPU sweep time (Sample Period of 0). PID_ISA: The ISA Integral Time in seconds, Ti, must be inverted and entered, as integral rate, as described for PID_IND. Total integral contribution to PID Output is Kc * Ki * Error * dt. Ki is usually the second gain set after Kp.

0 to 32.767 repeats/sec

GFK-1503D

Chapter 14 PID Built-in Function Block

14-5

14
Words 9 Parameter/Description CV Bias/Output Offset Low Bit Units CV Counts Range -32768 to 32767 (add to PID output)

(Address + 8) Number of CV Counts added to the PID Output before the rate and amplitude clamps. It can be used to set non-zero CV values when only Kp Proportional gains are used, or for feed-forward control of this PID loop output from another control loop. CV Upper Clamp CV Counts 10, 11 (Address + 9. CV Lower Clamp Address + Number of CV Counts that define the highest and 10) lowest value that CV is allowed to take. These values are required. The Upper Clamp must have a more positive value than the Lower Clamp, or the PID block will not work. These are usually used to define limits based on physical limits for a CV output. They are also used to scale the Bar Graph display for CV. The PID block has anti-reset-windup, controlled by bit 4 of the Config Word, to modify the integral term value when a CV clamp is reached. 12 (Address + 11) Minimum Slew Time Seconds / Minimum number of seconds for the CV output to move Full Travel from 0 to full travel of 100% or 32000 CV Counts. It is an inverse rate limit on how fast the CV output can change. If positive, CV cannot change more than 32000 CV Counts times the solution time interval (seconds) divided by Minimum Slew Time. For example, if the Sample Period is 2.5 seconds and the Minimum Slew Time is 500 seconds, CV cannot change more than 32000 * 2.5 / 500 or 160 CV Counts per PID solution. The integral term value is adjusted if the CV rate limit is exceeded. When Minimum Slew Time is 0, there is no CV rate limit. Set Minimum Slew Time to 0 while tuning or adjusting PID loop gains.

-32768 to 32767 (Word 10 must be greater than word 11.)

0 (none) to 32000 sec to move full CV travel

14-6

VersaMax PLC Users Manual January 2006

GFK-1503D

14
Words 13 (Address + 12)
Config Word

Parameter/Description

Low Bit Units Low 6 bits

Range Boolean

used The low 6 bits of this word are used to modify default PID settings. The other bits should be set to 0. Bit 0: Error Term Mode. When this bit is 0, the error term is SP - PV. When this bit is 1, the error term is PV - SP. Setting this bit to 1 modifies the standard PID Error Term from the normal (SP PV) to (PV SP), reversing the sign of the feedback term. This mode is used for reverse acting controls where the CV must go down when the PV goes up. Bit 1: Output Polarity. When this bit is 0, the CV output is the output of the PID calculation. When it is set to 1, the CV output is the negated output of the PID calculation. Setting this bit to 1 inverts the Output Polarity so that CV is the negative of the PID output rather than the normal positive value. Bit 2: Derivative action on PV. When this bit is 0, the derivative action is applied to the error term. When it is set to 1, the derivative action is applied to PV only. Bit 3: Deadband action. When the Deadband action bit is 0, the actual error value is used for the PID calculation. When the Deadband action bit is 1, deadband action is chosen. If the error value is within the deadband limits, the error used for the PID calculation is forced to be zero. If, however, the error value is outside the deadband limits, the magnitude of the error used for the PID calculation is reduced by the deadband limit (|error| = |error deadband limit|). Bit 4: Anti-reset windup action. When this bit is 0, the anti-reset-windup action uses a reset (integral term) backcalculation. When the output is clamped, the accumulated integral term is replaced with whatever value is necessary to produce the clamped output exactly. When the bit is 1, the accumulated term is replaced with the value of the integral term at the start of the calculation. In this way, the pre-clamp integral value is retained as long as the output is clamped. This option is not recommended for new applications. See CV Amplitude and Rate Limits on page 14-15. Bit 5: Enable derivative filtering. When this bit is set to 0, no filtering is applied to the derivative term. When set to 1, a first order filter is applied. This will limit the effects of higher frequency process disturbances, such as measurement noise, on the derivative term. Setting Config Word: Set Config Word to 0 for default operation. Add 1 (16#0001) to set bit 0, add 2 (16#0002) to set bit 1, add 4 (16#0004) to set bit 2, add 8 (16#0008) to set bit 3, add 16 (16#0010) to set bit 4, and add 32 (16#0020) to set bit 5. For example, to set bits 0, 3 and 5 only, set Config Word to 1 + 8 + 32 = 41 (16#0029). Some users will find the Config Word value easier to interpret in hexadecimal (16#) format.

GFK-1503D

Chapter 14 PID Built-in Function Block

14-7

14
Words 14 (Address + 13) Parameter/Description Manual Command Set to the current CV output while the PID block is in Automatic mode. When the block is switched to Manual mode, this value is used to set the CV output and the internal value of the integral term within the Upper and Lower Clamp and Slew Time limits. Control Word If the Override bit (bit 0) is set to 1, the Control Word and the internal SP, PV and CV parameters must be used for remote operation of the PID block (see below). This allows a remote operator interface device, such as a computer, to take control away from the PLC program. Caution: If you do not want to allow remote operation of the PID block, make sure the Control Word is set to 0. If the low bit is 0, the next 4 bits can be read to track the status of the PID input contacts as long as the PID Enable contact has power. Control Word is a discrete data structure with the first five bit positions defined in the following format:
Bit 0 1 Word Function Value 1 2 Override Manual / Auto Enable UP / Raise DN / Lower Status or External Action if Override bit is set to 1 If 0, monitor block contacts below. If 1, set them externally. If 1, block is in Manual mode. If other numbers, it is in Automatic mode. Should normally be 1. Otherwise, block is never called. If 1 and Manual (bit 1) is 1, CV is incremented every solution. If 1 and Manual (bit 1) is 1, CV is decremented every solution.

Low Bit Units CV Counts

Range Tracks CV in Auto or sets CV in Manual

15 (Address + 14)

Boolean Maintained by the CPU, unless bit 0 (Override) is set to 1.

2 3 4

4 8 16

16 (Address + 15)

Internal SP Tracks the SP input. If Override = 1, must be set externally to solve the PID algorithm using an alternate SP value. The original SP value is maintained until overwritten.

Set and maintained by the CPU, unless bit 1 0 (Override) of Control Word is set to 1. Set and maintained by the CPU.

Nonconfigurable , unless bit 10 (Override) of Control Word is set to 1. Nonconfigurable .

17 (Address + 16)
14-8

Internal CV Tracks CV output.

VersaMax PLC Users Manual January 2006

GFK-1503D

14
Words 18 (Address + 17) Internal PV Tracks PV input. Must be set externally if Override bit is set to 1. Parameter/Description Low Bit Units Set and maintained by the CPU, unless bit 10 (Override) of Control Word is set to 1. Set and maintained by the CPU. Range Nonconfigurable unless bit 10 (Override) of Control Word is set to 1. Nonconfigurable .

19 (Address + 18)

Output Signed word value representing the output of the function block before the optional inversion. If the output polarity bit in the Config Word is set to 0, this value equals the CV output. If the output polarity bit is set to 1, this value equals the negative of the CV output. Derivative Term Storage Used internally for storage of intermediate values. Do not write to this location. Integral Term Storage

20 (Address + 19) 21, 22

(Address + Used internally for storage of intermediate values. Do 20. Address not write to these locations. + 21) 23 (Address +22) 24 26 Slew Term Storage Used internally for storage of intermediate values. Do not write to this location. Previous Solution Time Set and maintained by the CPU. Nonconfigurable .

(Address + Internal storage of (time of last PID solution. Normally 23 Address do not write to these locations. Some special circumstances may justify writing to these locations. + 25) Note: If you call the PID block in Automatic mode after a long delay, you might want to use SVC_REQ #16 or SVC_REQ #51 to load the current CPU elapsed time clock into Word 24 to update the last PID solution time to avoid a step change of the integral term.

GFK-1503D

Chapter 14 PID Built-in Function Block

14-9

14
Words 27 (Address + 26) Parameter/Description Integral Remainder Storage Holds remainder from integral term scaling. Low Bit Units Set and maintained by the CPU. PV Counts Range Nonconfigurable . -32768 to 32767

SP, PV Lower Range 28, 29 (Address + SP, PV Upper Range 27, Address Optional integer values in PV Counts that define high + 28) and low display values for SP and PV. (Word 29 must be greater than word 28.) 30 (Address + 29) Reserved Word 30 is reserved. Do not use this location.

N/A

Nonconfigurable . Nonconfigurable . Nonconfigurable

Previous Derivative Term Storage 31, 32 Set and (Address + Used in calculations for derivative filter. Do not write to maintained by the CPU. 30, Address these locations. + 31) 33 40 Reserved N/A (Address + Words 32-39 are reserved. Do not use these 32 Address references. + 39)

14-10

VersaMax PLC Users Manual January 2006

GFK-1503D

14 Operation of the PID Function


Automatic Operation
The PID function can be called as often as every 10 milliseconds by providing power flow to the Enable input and no power flow to the Manual input. The function block compares the current CPU time with the last PID solution time stored in the reference array. If the interval between the two times is equal to or greater than the Sample Period (word 3 of the reference array) and also equal to or greater than 10 milliseconds, the PID algorithm is solved using this time interval. Both the last solution time and CV output are updated. In Automatic mode, the output CV is placed in the Manual Command parameter (word 14 of the reference array). Note: If you call the PID block in Auto mode after a long delay, you may want to use SVC_REQ 16 or SVC_REQ 51 to load the current CPU time into the stored previous solution time (word 24 of the reference array, described on page 14-9). This will update the last PID solution time and avoid a large step change of the integral term.

Manual Operation
The PID function block is placed in Manual mode by providing power flow to both the Enable and Manual input contacts. The output CV is set from the Manual Command parameter. If either the UP or DN inputs have power flow, the Manual Command word is incremented (UP) or decremented (DN) by one CV count every PID solution. For faster manual changes of the output CV, it is also possible to add or subtract any CV count value directly to/from the Manual Command word (word 14 of the reference array). The PID function block uses the CV Upper Clamp and CV Lower Clamp parameters to limit the CV output. If a positive Minimum Slew Time (word 12 of the reference array) is defined, it is used to limit the rate of change of the CV output. If either CV Clamp or the rate of change limit is exceeded, the value of the integral (reset) term is adjusted so that CV is at the limit. The anti-resetwindup feature assures that when the error term tries to drive CV above (or below) the clamps for a long period of time, the CV output will move off the clamp immediately when the error term changes sufficiently. This operation, with the Manual Command tracking CV in Automatic mode and setting CV in Manual mode, provides a bump-less transfer between Automatic and Manual modes. The CV Upper and Lower Clamps and the Minimum Slew Time always apply to the CV output in Manual mode and the integral term is always updated. This assures that when a user rapidly changes the Manual
GFK-1503D Chapter 14 PID Built-in Function Block 14-11

14
Command value in Manual mode, the CV output cannot change any faster than the slew rate limit set by the Minimum Slew Time, and the CV cannot go above the CV Upper Clamp limit or below the CV Lower Clamp limit.

Time Interval for the PID Function


The start time of each PLC sweep is used as the current time when calculating the time interval between solutions of the PID function. The times and time intervals have a resolution of 100 microseconds. When an application uses multiple PID functions, all of them use the same time value. The PID algorithm is solved when the current time is equal to or greater than the time of the last PID solution plus the Sample Period or 10 milliseconds; whichever is larger. If the Sample Period is set for execution on every sweep (value = 0), the PID function is restricted to a minimum of 10 milliseconds between solutions. If the sweep time is less than 10 milliseconds, the PID function waits until enough sweeps have occurred to accumulate an elapsed time of 10 milliseconds. For example, if the sweep time is 9 milliseconds, the PID function executes every other sweep, and the time interval between solutions is 18 milliseconds. If a specific PID function is executed more than once per sweep (by referencing the same reference array location in multiple PID function blocks), the algorithm is solved only on the first call. The longest possible interval between executions is 65,535 times 10 milliseconds, or 10 minutes, 55.35 seconds.

14-12

VersaMax PLC Users Manual January 2006

GFK-1503D

14 PID Algorithm Selection (PIDISA or PIDIND) and Gain Calculations


The PID function supports both the Independent Term (PID_IND) and ISA standard (PID_ISA) forms of the PID algorithm. The Independent Term form takes its name from the fact that the coefficients for the proportional, integral and derivative terms act independently. The ISA algorithm is named for the Instrument Society of America (now the International Society for Measurement and Control), which standardized and promoted it. The two algorithms differ in how words 6 through 8 of the reference array are used and in how the PID output (CV) is calculated. The Independent term PID (PID_IND) algorithm calculates the output as:
PID Output = Kp * Error + Ki * Error * dt + Kd * Derivative + CV Bias where Kp is the proportional gain, Ki is the integral rate, Kd is the derivative time, and dt is the time interval since the last solution.

The ISA (PID_ISA) algorithm has different coefficients for the terms:
PID Output = Kc * (Error + Error * dt/Ti + Td * Derivative) + CV Bias where Kc is the controller gain, Ti is the Integral time and Td is the Derivative

time. The advantage of PID_ISA is that adjusting Kc changes the contribution for the integral and derivative terms as well as the proportional term, which can simplify loop tuning. If you have the PID_ISA Kc, Ti and Td values, use the following equations to convert them to use as:PID_IND parameters: Kp = Kc, Ki = Kc/Ti, and Kd = Kc * Td The following diagram shows how the PID_IND algorithm works:
SP Error Term Sign +/Dead Band -/+ PV Deriv Action Integral Term = Previous Integ. Term + Ki * Error * Time Derivative Term = Value Kd * Time Proportional Term = Kp * Error CV Bias

Slew Limit

Upper / Lower Clamp

Polarity

CV

Value Time

The ISA Algorithm (PID_ISA) is similar except that its Kc gain coefficient is applied after the three terms are summed, so that the integral gain is Kc / Ti and the derivative gain is Kc * Td. Bits 0, 1 and 2 in the Config Word set the Error sign, Output Polarity and Derivative Action, respectively.
GFK-1503D Chapter 14 PID Built-in Function Block 14-13

14
Error Term
Both PID algorithms calculate the Error term as Error = (SP PV), which can be changed to Reverse Acting mode: Error = (PV SP) by setting the Error Term mode (bit 0) in the Config Word (word 13 of the reference array) to 1. Reverse -Acting mode is used if you want the CV output to move in the opposite direction from PV input changes (CV down for PV up) instead of the normal CV up for PV up. Bit 0 of Config Word (Word 13)
0 1

Error Term Mode


Normal Reverse Acting

Error Term
SP PV PV SP

Derivative Term
The Derivative Term is Kd (word 7 of the reference array) multiplied by the time rate of change of the Error term in the interval since the last PID solution. Derivative = Kd * Error / dt = Kd * (Error previous Error) / dt, where dt = Current PLC time PLC time at previous PID solution. Two bits in the Config Word (word 13 of the reference array) affect the calculation of Error. There are four cases to consider. In Normal mode, the change in the error term is: Error = (Error previous Error) = (SP PV) (previous SP previous PV) = (previous PV PV) (previous SP SP) = PV + SP = SP PV where PV = (PV previous PV), and SP = (SP previous SP).

14-14

VersaMax PLC Users Manual January 2006

GFK-1503D

14
However, in Reverse-Acting mode, the current error term is (PV SP), and the sign of the change in the error term is reversed: Error = (Error previous Error) = (PV SP) (previous PV previous SP) = (PV previous PV) (SP previous SP) =PV SP. The change in the error term depends on changes in both SP and PV. If SP is constant, SP = 0, and SP has no effect on the derivative term. When SP changes, however, it can cause large transient swings in the derivative term and hence the output. Loop stability may be improved by eliminating the effect of SP changes on the derivative term. To calculate the Derivative based only on the change in PV, set bit 2 of the Config Word to 1. This modifies the equations above by assuming SP is constant (SP = 0). For bit 2 set in normal mode (bit 0 = 0): Error = PV, = PV. For bit 2 set in Reverse-Acting mode (bit 0 = 1): Error

CV Bias Term
The CV Bias term (word 9 in the reference array) is an additive term separate from the PID inputs. It may be useful if you are using only Proportional gain (Kp) and you want the CV to be a non-zero value when the PV equals the SP and the Error is 0. In this case, set the CV Bias to the desired CV when the PV is at the SP. CV Bias can also be used for feed forward control where another PID loop or control algorithm is used to adjust the CV output of this PID loop. If a non-zero Integral rate is used, the CV Bias will normally be 0 as the integral term acts as an automatic bias or reset. Just start up in Manual mode and use the Manual Command word (word 14 of the reference array) to set the desired CV, and then switch to Automatic mode. This will immediately calculate the required value for the integral term.

CV Amplitude and Rate Limits


The PID block does not send the calculated Output directly to CV. Both PID algorithms can impose amplitude and rate of change limits on the output Control Variable. If the Minimum Slew Time (word 12 of the reference array) is non-zero, the rate of change (slew rate) limit is determined by dividing the maximum CV value (32,000) by the Minimum Slew Time. For example, if the Minimum Slew Time is 100 seconds, the rate limit will be 320 CV counts per second. If the solution interval was 50 milliseconds, the new CV output cannot change more than 320*50/1000 or 16 CV counts from the previous CV output.
GFK-1503D Chapter 14 PID Built-in Function Block 14-15

14
The CV output is then compared to the CV Upper Clamp and CV Lower Clamp values (words 10 and 11 of the reference array). If CV is outside either limit, the CV output is clamped to the appropriate limit value. When the CV output is modified to impose either slew rate or amplitude limits (or both) the stored integral term would normally accumulate a large value over time. This phenomenon is known as reset windup. Reset windup introduces errors in CV after the PID output no longer needs to be limited. For example, windup would prevent the CV output from moving off a clamp value immediately. There are two optional methods for preventing reset windup. If the Anti-resetwindup Action bit (bit 4) of Config Word (word 13 of the reference array) is zero (the default), the integral term is adjusted at each PID solution to match the error input and limited CV output exactly. When PV changes while CV is clamped, or when CV is both rate and amplitude limited in a particular PID solution, this option assures that a smooth transition will always occur after CV is no longer limited. If the Anti-reset-windup Action bit of Config Word is set, then the integral term stored on the previous PID solution is simply retained as long as CV is limited. This option was added to assure compatibility with existing PID applications when the default action described above was introduced. This option is not recommended for new applications. Finally, the PID block checks the Output Polarity (bit 2 of the Config Word ) and changes the sign of the output if the bit is 1. CV = Clamped PID Output if Output Polarity bit set, or Clamped PID Output if Output Polarity bit cleared. If the block is in Automatic mode, the final CV is placed in the Manual Command (word 14 of the reference array). If the block is in Manual mode, the PID equation is skipped because CV is set by the Manual Command, but the slew rate and amplitude limits are still checked. This assures that the Manual Command cannot change the output above the CV Upper Clamp or below the CV Lower Clamp, and the output cannot change faster than allowed by the Minimum Slew Time.

14-16

VersaMax PLC Users Manual January 2006

GFK-1503D

14
Sample Period and PID Function Block Scheduling
The PID function block is a digital implementation of an analog control function, so the dt sample time in the PID Output equation is not the infinitesimally small sample time available with analog controls. The majority of processes being controlled can be approximated as a gain with a first or second order lag, and (possibly) a pure time delay. The PID function block sets a CV output to the process and uses the process feedback PV to determine an Error to adjust the next CV output. A key process parameter is the total time constant, which is how fast the process can change PV when the CV is changed. As discussed in Determining the Process Characteristics on page 14-18, the total time constant, Tp+Tc, for a first order system is the time required for PV to reach 63% of its final value when CV is stepped. The PID function block will not be able to control a process unless its Sample Period is well under half the total time constant. Larger Sample Periods will make it unstable. The Sample Period should be no bigger than the total time constant divided by 10 (or down to 5 worst case). For example, if PV seems to reach about 2/3 of its final value in 2 seconds, the Sample Period should be less than 0.2 seconds, or 0.4 seconds worst case. On the other hand, the Sample Period should not be too small, such as less than the total time constant divided by 1000, or the Ki * Error * dt term for the PID integral term will round down to 0. For example, a very slow process that takes 10 hours or 36,000 seconds to reach the 63% level should have a Sample Period of 40 seconds or longer. Variations of the time interval between PID function solutions can have shortterm effects on the CV output. For example, if a step change to PV caused by measurement noise occurs between solutions, the value of the derivative term will be inversely proportional to the time interval. The performance of PID loops that are tuned for quick response may be improved when the solution interval is held constant by configuring the PLC CPU for constant sweep mode. Depending on the CPU model and the application, constant sweep times of 10 milliseconds, integer multiples of 10 milliseconds, or exact divisors of 10 milliseconds (1, 2 or 5 milliseconds) will be possible. The Sample Period can then be set for a suitable multiple of 10 milliseconds. If many PID loops are used, allowing the application to solve all the loops on the same sweep may lead to wide variations in CPU sweep time. If the loops have a common Sample Period that is at least equal to the number of PID loops times the sweep time, a simple solution is to sequence one or more 1 bits through an array of zero bits and to use these bits to enable power flow to individual PID function blocks. The logic should assure that each PID function block is enabled no more often than its Sample Period.
GFK-1503D Chapter 14 PID Built-in Function Block 14-17

14 Determining the Process Characteristics


The PID loop gains, Kp, Ki and Kd, are determined by the characteristics of the process being controlled. Two key questions when setting up a PID loop are: 1. 2. How big is the change in PV when CV is changed by a fixed amount, or what is the open loop gain of the process? How fast does the system respond, or how quickly does PV change after the CV output is stepped?

Many processes can be approximated by a process gain, first or second order lag and a pure time delay. In the frequency domain, the transfer function for a first order lag system with a pure time delay is:

PV (s ) CV (s )

G (s )

Ke

T p /(1+ Tc s )

Plotting the response to a step input at time t0 in the time domain provides an open-loop unit reaction curve:
CV Unit Step Output to Process 1 K 0.632K PV Unit Reaction Curve Input from Process

t0

t0 Tp

Tc

The following process model parameters can be determined from the PV unit reaction curve:
K Tp Tc Process open loop gain = final change in PV/change in CV at time t0 Process or pipeline time delay or dead time after t0 before the process output PV starts moving First order Process time constant, time required after Tp for PV to reach 63.2% of the final PV

One way to measure these parameters is by putting the PID function block in Manual mode, making a small step change in the CV output by changing the Manual Command (word 14 of the reference array), and then plotting the PV response over time. For slow processes this can be done manually, but for faster processes a chart recorder or computer graphic data-logging package will help. The CV step size should be large enough to cause an observable change in PV, but not so large that it disrupts the process being measured. A good step size may be from 2 to 10% of the difference between the CV Upper and CV Lower Clamp values.

14-18

VersaMax PLC Users Manual January 2006

GFK-1503D

14 Setting Tuning Loop Gains


Basic Iterative Tuning Approach
Because PID parameters are dependent on the process being controlled, there are no predetermined values that will work. However, a simple iterative process can be used to find acceptable values for Kp, Ki, and Kd gains. 1. Set all the reference array parameters to 0, then set the CV Upper and CV Lower Clamps to the highest and lowest CV expected. Set the Sample Period to a value within the range Tc/10 to Tc/100, where Tc is the estimated process time constant defined on page 14-18. 2. Put the PID function block in Manual mode and set the Manual Command (word 14 in the reference array) to different values to check if CV can be moved to Upper and Lower Clamp. Record the PV value at some CV point and load it into SP. 3. Set a small gain, such as 100 * Maximum CV/Maximum PV, into Kp and turn off Manual mode. Step SP by 2% to 10% of the Maximum PV range and observe PV response. Increase Kp if PV step response is too slow or reduce Kp if PV overshoots and oscillates without reaching a steady value. 4. Once a Kp is found, start increasing Ki to get overshooting that dampens out to a steady value in two to three cycles. This may require reducing Kp. Also try different SP step sizes and CV operating points. 5. After suitable Kp and Ki gains are found, try adding Kd to get quicker responses to input changes providing it doesn't cause oscillations. Kd is often not needed and will not work with noisy PV. 6. Check gains over different SP operating points and add Dead Band and Minimum Slew Time if needed. Some Reverse Acting processes may need setting of Config Word Error Term or Output Polarity bits.

GFK-1503D

Chapter 14 PID Built-in Function Block

14-19

14
Setting Loop Gains Using the Ziegler and Nichols Tuning Approach
This approach provides good response to system disturbances with gains producing an amplitude ratio of 1/4. The amplitude ratio is the ratio of the second peak over the first peak in the closed loop response. 1. Determine the three process model parameters, K, Tp and Tc for use in estimating initial PID loop gains. 2. Calculate the Reaction rate: R = K/Tc For Proportional control only, calculate Kp as: Kp = 1/(R * Tp) = Tc/(K * Tp) For Proportional and Integral control, use: Kp = 0.9/(R * Tp) = 0.9 * Tc/(K * Tp) Ki = 0.3 * Kp/Tp For Proportional, Integral and Derivative control, use: Kp = G/(R * Tp) where G is from 1.2 to 2.0 Ki = 0.5 * Kp/Tp Kd = 0.5 * Kp * Tp 3. Check that the Sample Period is in the range (Tp + Tc)/10 to (Tp + Tc)/1000

Ideal Tuning Method


The Ideal Tuning" procedure provides the best response to SP changes that are delayed only by the Tp process delay or dead time. 1. Determine the three process model parameters, K, Tp and Tc for use in estimating initial PID loop gains. 2. Calculate Kp, Ki, and Kd as follows: Kp = 2 * Tc/(3 * K * Tp) Ki = Tc Kd = Ki/4 if Derivative term is used 3. Once initial gains are determined, convert them to integers. 4. Calculate the Process gain, K, as a change in input PV Counts divided by the resulting output step change in CV Counts. (Not in process PV or CV engineering units.) Specify all times in seconds. 5. Once Kp, Ki and Kd are determined, Kp and Kd are multiplied by 100 while Ki is multiplied by 1000. The resulting values are entered into the corresponding reference array word locations.

14-20

VersaMax PLC Users Manual January 2006

GFK-1503D

14 Example
The following PID example has a sample period of 100 ms, a Kp gain of 4.00 and a Ki gain of 1.500. The set point is stored in %R0001, the control variable is output in %AQ0002, and the process variable is returned in %AI0003. CV Upper and CV Lower Clamps must be set, in this case to 20000 and 4000, and an optional small Dead Band of +5 and -5 is included. The 40-word reference array starts in %R0100. Normally, user parameters are set in the reference array, but %M0006 can be set to reinitialize the 14 words starting at %R0102 (word 3) from constants stored in logic (a useful technique). The block can be switched to Manual mode with %M1 so that the Manual Command, %R113, can be adjusted. Bits %M4 or %M5 can be used to increase or decrease %R113 and the PID CV by 1 every 100 ms solution. For faster manual operation, bits %M2 and %M3 can be used to add or subtract the value in %R2 to/from %R113 every CPU sweep. The %T1 output is on when the PID is OK.

Reference Array Initialization using %M00006


For details on the contents of the reference array, refer to page 14-3. Word
3 4 5 6 7 8 9 10 11 12 13 14 15 16

Function
Sample Period + Dead Band - Dead Band Kp Kd Ki CV Bias CV Upper Clamp CV Lower Clamp Minimum Slew Time Config Word Manual Command Control Word Internal SP

Address
%R102 %R103 %R104 %R105 %R106 %R107 %R108 %R109 %R110 %R111 %R112 %R113 %R114 %R115

Value
10 5 5 400 0 1500 0 2000 400 0 0 0 0 0

GFK-1503D

Chapter 14 PID Built-in Function Block

14-21

14

14-22

VersaMax PLC Users Manual January 2006

GFK-1503D

Chapter

15

The EZ Program Store Device

This chapter describes the VersaMax EZ Program Store device, which can be used to transfer program, configuration, and reference tables data from one PLC to one or more others of the same type.

IC200ACC003
PLC EZ PROGRAM STORE

Green OK Amber Active Blink Error

Contents of this chapter:

Description of the EZ Program Store device Details of Using the EZ Program Store device Read/Write/Verify Data with a Programmer Present Write Data to a PLC CPU without a Programmer Present

GFK-1503D

15-1

15

IC200ACC003: EZ Program Store Device


The EZ Program Store device (IC200ACC003) can be used to store and update the configuration, application program, and reference tables data of a VersaMax PLC. The update can include Ethernet Global Data and Advanced User Parameters for Ethernet. A programmer and PLC CPU are used to initially write data to the device. In addition to writing data to the device, the programmer can read data already stored on an EZ Program Store device, and compare that data with similar files already present in the programmer. Once the data is written to the EZ Program Store device, the data can be written to one or more other PLC CPUs of the same type, with no programmer needed.
Side Connector LED
Green OK Amber Active Blink Error

Pushbutton

Top

IC200ACC003
PLC EZ PROGRAM STORE

5.8cm 1.7 in

6.6cm 2.6 in

1.8cm 0.7 in

The EZ Program Store device and PLC must both have no OEM key password or the same OEM key password for an update to occur. The EZ Program Store device does not perform special processing for other types of passwords. The EZ Program Store device plugs directly into port 2 on a VersaMax PLC. No cables or connectors are required. Power for the device comes from port 2. Because the EZ Program Store device is not used during normal operation, it does not need to be screwed down to the PLC. The device can be hot inserted and hot removed without disrupting the system.

Features


15-2

2-Megabit Serial Data Flash for non-volatile storage Pushbutton initiates update from the device to a PLC Dual color status LED Configurable OEM key password protection Compatible with all VersaMax CPU models, release 2.10 and later.
VersaMax PLC Users Manual January 2006 GFK-1503D

15

EZ Program Store Device: IC200ACC003

Read/Write/Verify Data with a Programmer Present


With a programmer present, the PLC CPU can read, write, or verify a program, configuration and tables in the EZ Program Store device. When reading or verifying data, it is possible to select hardware configuration, logic, and/or reference tables data. However, when writing data to the EZ Program Store device, all three data types must be written. If the hardware configuration includes Ethernet Global Data and/or a file of Advanced User Parameters for Ethernet communications, they will also be included. The programmer must be using version 1.5 or later of the VersaPro programming software.
WARNING

Do not use the pushbutton on the EZ Program Store device to invoke an update while: 1. Loading program logic, configuration data, and/or reference tables from the PLC to the programmer. 2. Verifying program logic, configuration data, and/or reference tables in the PLC with the programmer. Doing so may corrupt the data being loaded or verified and produce unexpected results. You should power-cycle the PLC to restore normal operation.

Including All the Necessary Information


When the EZ Program Store device updates a PLC, it writes over existing configuration, program files and data in the target PLC. Therefore, it is important to be sure that the information placed on the EZ Program Store device is complete for proper operation of the PLC system. For example, if the EZ Program Store device contains an application program, but instead of a customized hardware configuration it contains the default PLC configuration, the update will overwrite any existing configuration data in a PLC being updated. If that happens, the modules in the PLC system will then use their default configuration, which may cause unexpected operation.

GFK-1503D

Chapter 15 The EZ Program Store Device

15-3

15

EZ Program Store Device: IC200ACC003 Matching OEM Protection


If the PLC(s) that will be updated by the EZ Program Store device are protected by an OEM key password, be sure the same OEM key password is present in the configuration stored to the EZ Program Store device, otherwise no update will be possible. If the PLC(s) being updated had no OEM key password assigned, the EZ Program Store device must also not have an OEM key password. The device does not use other system passwords. (See chapter 7, CPU Operation, for information about passwords and the OEM key).

Adjusting the Configuration Timeouts


Reading and writing large programs, hardware configurations, and reference tables to or from the EZ Program Store device may take 30 seconds or more to complete. To avoid possible disconnect errors or read/write errors, adjust the request timeouts in the configuration to 30 - 63 seconds (30,000 - 63,000mS).

Writing Data to RAM or Flash


Folder data is stored from the programmer to the EZ Program Store device in the same way data is stored to Flash memory. Writing to either Flash or to the EZ Program Store device always writes all folder data (regardless of what types are selected). Data stored to the EZ Program Store device is verified in the same manner as data stored in Flash memory is verified. Data can also be read from the device in the same manner as reading from Flash. The EZ Program Store device can be used to update data in a PLCs RAM memory only, or in both RAM and Flash memory. In the configuration data stored to the EZ Program Store device, be sure to specify which type of memory should be updated. Select RAM only to update only RAM memory in the target PLC. Select RAM & FLASH to update both.

15-4

VersaMax PLC Users Manual January 2006

GFK-1503D

15

IC200ACC003: EZ Program Store Device Using the EZ Program Store Device with the Programmer

Programmer

CPUE05

EZ Program Store Device

To read/write or verify some or all of the data, follow these steps: 1. Plug the EZ Program Store device into port 2 of the VersaMax PLC CPU. The devices LED turns green after about 2 seconds. The delay allows time for proper seating of the device.

GFK-1503D

Chapter 15 The EZ Program Store Device

15-5

15

EZ Program Store Device: IC200ACC003


2. If the PLC is in Run mode when the EZ Program Store device is connected, the Run LED on the PLC blinks at a 1 Hz rate.
CPUE05
PWR OK RUN FAULT FORCE PORT 1 PORT 2

Run LED

This blinking indicates that the Run/Stop switch is enabled, regardless of the configuration of the switch. 3. If the EZ Program Store devices LED is green and the PLCs Run LED is blinking, stop the PLC by moving the Run/Stop switch from the On/Run position to the Stop/Off position.
RUN/ON

STOP/OFF

If the switch is already on the Stop/Off position, move it to Run then back to Stop to affirm the change. After the mode is changed to Stop No I/O, the Run LED goes off. Note that to change the PLC mode from Run to Stop or from Stop to Run mode when an EZ Program Store device is attached, the PLCs Run/Stop switch must be used. If a programmer (computer) is also connected to the PLC at the same time, the programmer cannot be used to change the PLC mode. 4. Start the programming software and change the request timeout values as needed. 5. Connect the programmer to the PLC CPU. 6. Use the programming software to read, write, or verify the data. When performing an update with the programmer present, the pushbutton on the EZ Program Store device is not used.
15-6 VersaMax PLC Users Manual January 2006 GFK-1503D

15

IC200ACC003: EZ Program Store Device

Update a PLC CPU without a Programmer Present


With a program, configuration, tables, Ethernet Global Data, and Advanced User Parameters (if any) already stored in an EZ Program Store device, it can be used to update one or more other PLC CPUs of the same type. All the data stored in the EZ Program Store device will be updated in the PLC CPU. To update all of the data in a VersaMax PLC CPU, follow these steps: 1. Plug the EZ Program Store device into port 2 of the VersaMax PLC CPU.

EZ Program Store Device

If the PLC is in Run mode when the EZ Program Store device is connected, the Run LED on the PLC blinks at a 1 Hz rate. This blinking indicates that the Run/Stop switch is enabled, regardless of the configuration of the switch.
CPUE05
PWR OK RUN FAULT FORCE PORT 1 PORT 2

Run LED

Port 2 LED

GFK-1503D

Chapter 15 The EZ Program Store Device

15-7

15

EZ Program Store Device: IC200ACC003


2. If the PLCs Run LED is blinking and the LED on the device is green, stop the PLC by moving the Run/Stop switch from Run/On to Stop/Off position.
RUN/ON

STOP/OFF

If the switch is already on the Stop/Off position, move it from Run then back to Stop to affirm the change. After the mode is changed to Stop No I/O, the PLC Run LED goes off. 3. To start the update, press the pushbutton on the EZ Program Store device.
Pushbutton

The LED on the EZ Program Store device turns amber and the Port 2 LED on the PLC blinks.
Port 2 LED

EZ Program Store LED

4. Wait for the update to complete. Reading and writing large programs, hardware configurations, and reference tables to or from the EZ Program Store device may take 30 seconds or more to complete.
15-8 VersaMax PLC Users Manual January 2006 GFK-1503D

15

IC200ACC003: EZ Program Store Device


When the devices LED turns solid green and the CPUs Run LED starts blinking, the update has completed successfully.

EZ Program Store Device LED

When the PLC is placed into Run mode (by moving the Run/Stop switch from Stop/Off to Run/On position) it uses the new data immediately.

Error During Update


If the EZ Program Store devices LED is blinking green/amber and the CPUs Run LED is blinking, an error was detected before the old data was erased. When the PLC is placed into Run mode, it continues using the old data. If the devices LED is blinking green/amber and the CPUs Run LED is off, an error occurred during the transfer after the data in the PLC was erased. Try the update again by disconnecting and reconnecting the device and pressing the pushbutton. If the second update fails, contact the update provider for service. Update errors are reported as USD Flash Read faults in the PLC Fault Table. The first two bytes of extra fault data describe the fault.

GFK-1503D

Chapter 15 The EZ Program Store Device

15-9

15

15-10

VersaMax PLC Users Manual January 2006

GFK-1503D

Appendix

Performance Data

This section presents performance data collected on the VersaMax CPUs IC200CPU001, CPU002, CPU005, and CPUE05. The data includes base sweep time, sweep impact of boolean instructions, function block sweep impact times, function block sizes, and I/O module scan time data.

Base Sweep Time


The table below shows the base sweep time with the default program in Run mode, no I/O modules present or configured, and no serial connections to either serial port.
Model CPU001/002 CPU005 CPUE05 Time (in milliseconds) 1.605 1.039 1.910

Boolean Instruction Time


This table shows the typical sweep impact time for boolean instructions:
Model CPU001/002 CPU005/E05 Typical Time (in microseconds) 1.7 0.8

GFK-1503D

A-1

A Function Block Timing


The following tables show the sweep impact times and size information for all supported function blocks of the CPU.

Sweep Impact Times


The tables show two sweep impact times are shown for each function. An Increment time is shown for functions that can have variable length inputs (table functions):
Enabled Disabled Sweep impact time (in microseconds) when a function block has been enabled; power flow to the function block. Sweep impact time (in microseconds) when a function block has been disabled; no power-flow to function block and/or power-flow to reset of function block. Incremental time (in microseconds/input unit) to add to the base function time for each addition to the length of an input parameter. Only applies to table functions that can have varying input lengths (i.e. Search, Array Moves, etc.).

Increment

All timings represent typical execution time. Timings may vary with input and error conditions. Each timing includes the time to execute one contact, and normal overhead including a connection with a programmer. (Note: timings listed in previous versions of this manual did not include this overhead.)

For table functions, increment is in units of length specified. For bit operation functions, microseconds/bit. For data move functions, microseconds/number of bits or words. For functions that have an increment value, multiply the increment by (Length 1) and add that value to the base time to get total instruction time.

A-2

VersaMax PLC Users Manual January 2006

GFK-1503D

A
Sizes of Timers, Counters, Math Functions, Trig Functions, Log Functions
The size of a function is the number of bytes consumed in user logic space for each instance of the function in a ladder diagram application program.
Group Timers Function On-Delay Timer Timer Off-Delay Timer Up Counter Down Counter Addition (INT) Addition (DINT) Addition (REAL) Subtraction (INT) Subtraction (DINT) Subtraction (REAL) Multiplication (INT) Multiplication (DINT) Multiplication (REAL) Division (INT) Division (DINT) Division (REAL) Modulo Division (INT) Modulo Division (DINT) Square Root (INT) Square Root (DINT) Square Root (REAL) Scale (INT) Scale (WORD) SIN (REAL) COS (REAL) TAN (REAL) ASIN (REAL) ACOS (REAL) ATAN (REAL) LOG (REAL) LN (REAL) CPU001/002 CPU005/E05 Enabled Disabled Enabled Disabled 119 90 90 69 110 80 81 60 110 80 81 60 90 90 70 70 93 90 70 70 62 12 50 10 60 12 50 10 139 12 99 10 62 12 50 10 60 12 50 10 139 12 100 10 70 12 50 10 99 12 50 10 155 12 108 10 80 12 60 10 70 12 51 10 244 12 160 10 84 12 60 10 80 12 60 10 85 12 60 10 126 12 70 10 514 12 340 10 112 12 78 10 110 12 73 10 1432 12 945 10 1437 12 945 10 2135 20 1400 20 1838 12 1200 10 1793 12 1200 10 820 12 542 10 878 12 577 10 821 12 542 10 Increment Size 15 15 15 13 13 13 19 17 13 19 17 13 19 17 13 19 17 13 19 10 13 11 22 22 11 11 11 11 11 11 11 11

Counters Math

Trigonometric

Logarithmic

GFK-1503D

Appendix A Performance Data

A-3

A
Sizes of Exponential Functions, Radian Conversion, Relational Functions
The size of a function is the number of bytes consumed in user logic space for each instance of the function in a ladder diagram application program.
Group Exponential Radian Conversion Relational Function Power of e Power of X Convert RAD to DEG Convert DEG to RAD Equal (INT) Equal (DINT) Equal (REAL) Not Equal (INT) Not Equal (DINT) Not Equal (REAL) Greater Than (INT) Greater Than (DINT) Greater Than (REAL) Greater Than/Equal (INT) Greater Than/Equal (DINT) Greater Than/Equal (REAL) Less Than (INT) Less Than (DINT) Less Than (REAL) Less Than/Equal (INT) Less Than/Equal (DINT) Less Than/Equal (REAL) Range (INT) Range (DINT) Range (WORD) CPU001/002 Enabled Disabled 592 365 328 106 43 50 60 40 45 60 40 45 60 40 46 60 40 46 60 40 46 60 50 55 50 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 CPU005/E05 Enabled 393 249 214 70 30 37 41 30 30 40 30 30 40 30 30 40 30 30 40 30 30 40 33 40 33 Disabled 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 11 17 11 11 10 16 14 10 16 14 10 16 14 10 10 14 10 16 14 10 16 14 13 22 13 Increment Size

A-4

VersaMax PLC Users Manual January 2006

GFK-1503D

A
Sizes of Bit Operations, Data Move Functions
The size of a function is the number of bytes consumed in user logic space for each instance of the function in a ladder diagram application program.
Group Bit Operation Function CPU001/002 Enabled Disabled Logical AND 60 12 Logical OR 60 12 Logical Exclusive OR 60 12 Logical Invert, NOT 50 12 Shift Bit Left 134 12 Shift Bit Right 129 12 Rotate Bit Left 110 12 Rotate Bit Right 111 12 Bit Position 76 12 Bit Clear 70 12 Bit Test 60 12 Bit Set 70 12 Mask Compare (WORD) 158 12 Mask Compare (DWORD) 150 12 Bit Sequencer 150 109 Move (INT) 45 12 Move (BIT) 80 12 Move (WORD) 46 12 Move (REAL) 60 12 Block Move (INT) 60 12 Block Move (WORD) 60 12 Block Move (REAL) 113 12 Block Clear 100 12 Shift Register (BIT) 130 12 Shift Register (WORD) 120 12 COMM_REQ * 175 175 CPU005/E05 Enabled Disabled 50 10 50 10 50 10 40 10 80 10 80 10 70 10 70 10 57 10 56 10 44 10 56 10 110 10 100 10 101 77 32 10 60 10 32 10 47 10 50 10 50 10 94 10 83 10 94 10 100 10 120 120 Increment 14.78 16.31 18.45 18.41 0.24 2.83 10.76 2.82 2.75 4.63 0.45 2.76 Size 13 13 13 10 16 16 16 16 13 13 13 13 25 25 16 10 13 10 13 28 28 13 11 16 16 13

Data Move

* Commreq sent to HSC module.

GFK-1503D

Appendix A Performance Data

A-5

A
Sizes of Table Functions
The size of a function is the number of bytes consumed in user logic space for each instance of the function in a ladder diagram application program.
Group Table Function CPU001/002 Enabled Disabled 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 CPU005/E05 Enabled Disabled 90 80 92 80 90 70 60 60 70 78 81 57 78 80 70 69 76 70 60 60 70 60 80 56 60 60 60 54 60 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 Increment Size

Array Move INT 110 DINT 100 BIT 129 BYTE 109 WORD 110 Search Equal INT 90 DINT 90 BYTE 81 WORD 90 Search Not Equal INT 100 DINT 110 BYTE 74 WORD 100 Search Greater Than INT 100 DINT 94 BYTE 90 WORD 100 Search Greater Than/Equal INT 90 DINT 90 BYTE 81 WORD 90 Search Less Than INT 80 DINT 110 BYTE 73 WORD 80 Search Less Than/Equal INT 80 DINT 90 BYTE 72 WORD 80

5.50 2.76 1.08 4.75 5.50 6.59 7.14 2.58 6.59 6.66 7.14 2.56 6.66 6.69 7.12 2.58 6.69 6.79 7.15 2.56 6.79 6.59 7.13 2.58 6.66 6.66 7.13 2.59 6.66

22 22 22 22 22 19 22 19 19 19 22 19 19 19 22 19 19 19 22 19 19 19 22 19 19 19 22 19 19

A-6

VersaMax PLC Users Manual January 2006

GFK-1503D

A
Sizes of Conversion and Control Functions
The size of a function is the number of bytes consumed in user logic space for each instance of the function in a ladder diagram application program.
Group Function CPU001/002 CPU005/E05 Enabled Disabled Enabled Disabled 60 12 40 10 683 12 455 10 60 12 40 10 673 12 451 10 60 12 40 10 642 12 429 10 57 12 40 10 167 12 120 10 70 12 50 10 188 12 130 10 179 12 128 10 60 12 40 10 130 12 130 10 231 85 150 57 231 85 150 57 77 221 2610 169 100 110 346 377 912 72 31 267 12 12 12 12 12 12 12 12 12 12 33 222 60 173 2211 139 72 80 251 361 912 60 31 184 10 10 10 10 10 10 10 10 10 10 33 152 Increment Size 10 13 13 13 10 13 10 10 10 13 13 7 13 16 16 10 10 10 10 10 10 10 10 10 10 4 34

Conversion Convert INT to REAL Convert REAL to INT Convert DINT to REAL Convert REAL to DINT Convert WORD to REAL Convert REAL to WORD Convert BCD to INT Convert INT to BCD Convert BCD to REAL Truncate to INT Truncate to DINT Control Call a Subroutine Do I/O * PID ISA Algorithm PID IND Algorithm Service Request #6 #7 (Read) #7 (Set) #14 ** #15 #16 #18 #23 #26//30 *** #29 Nested MCR/ENDMCR Combined Drum Sequencer

* DO I/O timing is the time to output values to discrete output module. ** Service Request #14 (Clear Fault Table) timing was done when fault table contained no faults. *** Service Request #26/30 (Interrogate I/O) timing was done when I/O configuration was empty and both an MDL740 (16pt out) and MDL640 (16pt in) were physically present.
GFK-1503D Appendix A Performance Data A-7

A I/O Module Scan Times


The tables that follow show typical scan times for modules in a VersaMax PLC. Each module was configured with its default settings and user power was applied when applicable. Four tables are included:

Modules Located in Main Rack Modules Located in Local Single Rack Modules Located in Multiple Remote Rack Modules Located in Isolated Rack

Reference to Discrete Module Types in the Scan Time Tables


In the scan time tables, discrete modules are grouped by type: Module Type
Discrete Input Type 1 MDL140 MDL640 MDD846 Discrete Input Type 2 MDL240 MDL644 Discrete Output Type 1 MDL329 MDD843 MDD849 Discrete Output Type 2 MDL330 Discrete Output w/ ESCP Per Point Fault Reporting MDL730

Module Catalog Number, IC200:


MDL141 MDL643 MDD847 MDL241 MDL650 MDL331 MDD844 MDD850 MDL742 MD744 MDL750 MDL840 MDL940 MDL143 MDD842 MDD848 MDL243 MDD840 MDL740 MDD845 MDL741 MDD846 MDL743 MDD847 MDD842 MDD848 MDL144 MDD843 MDD849 MDL244 MDL631 MDD844 MDD850 MDL632 MDL635 MDD845 MDL930 MDL636

For additional information on VersaMax I/O Modules, please refer to VersaMax Modules, Power Supplies, and Carrier User's Manual GFK-1504.

A-8

VersaMax PLC Users Manual January 2006

GFK-1503D

A
Modules Located in Main PLC Rack
CPU005/CPUE05 Module Type
Discrete Input Type 1 * Discrete Input Type 2 * Discrete Output Type 1 * Discrete Output Type 2 * Discrete Output w/ ESCP Per Point Fault Reporting Intelligent Discrete Input 20 Points Intelligent Discrete Output 12 Points Analog Input 4 Channels Analog Input 8 Channels Analog Input 15 Channels Analog Output 2 Channels Analog Output 4 Channels Analog Output 8 Channels Analog Output 12 Channels Intelligent Analog Input 4 Channels Intelligent Analog Input 7 Channels Intelligent Analog Input 8 Channels Intelligent Analog Output 4 Channels PLC Network Comm Profibus-DP Slave DeviceNet Network Master/Slave 95 117 ------349 --160 239 377 --------237 261 272 --** **

CPU001/CPU002 Main Rack Input


158 189 ------389 --190 312 526 --------281 305 313 --** **

Main Rack Input Output


----84 101 116 --294 ------109 145 217 289 ------212 ** **

Output
----132 152 190 --369 ------161 202 285 367 ------264 ** **

Mixed modules have both and input and output scan time values.

** Network Communications Modules (NCM) Scan Impact Times vary depending upon the network configuration.

GFK-1503D

Appendix A Performance Data

A-9

A
Modules Located in Single-ended Expansion Rack
The table below shows timing for modules located in a single-ended expansion rack with a non-isolated Expansion Receiver module ((C200ERM002). This type of system does NOT have an Expansion Transmitter module (IC200ETM001) in the main rack. CPU005/CPUE05 Module Type
Discrete Input Type 1 * Discrete Input Type 2 * Discrete Output Type 1 * Discrete Output Type 2 * Discrete Output w/ ESCP Per Point Fault Reporting Intelligent Discrete Input 20 Points Intelligent Discrete Output 12 Points Analog Input 4 Channels Analog Input 8 Channels Analog Input 15 Channels Analog Output 2 Channels Analog Output 4 Channels Analog Output 8 Channels Analog Output 12 Channels Intelligent Analog Input 4 Channels Intelligent Analog Input 7 Channels Intelligent Analog Input 8 Channels Intelligent Analog Output 4 Channels PLC Network Comm Profibus-DP Slave DeviceNet Network Master/Slave 643 --317 527 896 --------438 479 493 --** ** --714 ------204 296 480 664 ------484 ** ** 763 --389 631 1054 --------533 580 596 --** ** --756 ------266 374 592 809 ------613 ** **

CPU001/CPU002 Local Single Rack Input


191 262 -------

Local Single Rack Input


127 179 -------

Output
----116 167 176

Output
----167 222 260

Mixed modules have both and input and output scan time values.

** Network Communications Modules (NCM) Scan Impact Times vary depending upon the network configuration.
A-10 VersaMax PLC Users Manual January 2006 GFK-1503D

A
Modules Located in Multiple Remote Expansion Rack
The table below shows timing for modules located in the expansion racks of a multiple-rack expansion system that uses only Isolated Expansion Receiver Modules (IC200ERM001). In this type of system, there is an Expansion Transmitter module (IC200ETM001) in the CPU rack. CPU005/CPUE05 Module Type
Discrete Input Type 1 * Discrete Input Type 2 * Discrete Output Type 1 * Discrete Output Type 2 * Discrete Output w/ ESCP Per Point Fault Reporting Intelligent Discrete Input 20 Points Intelligent Discrete Output 12 Points Analog Input 4 Channels Analog Input 8 Channels Analog Input 15 Channels Analog Output 2 Channels Analog Output 4 Channels Analog Output 8 Channels Analog Output 12 Channels Intelligent Analog Input 4 Channels Intelligent Analog Input 7 Channels Intelligent Analog Input 8 Channels Intelligent Analog Output 4 Channels PLC Network Comm Profibus-DP Slave DeviceNet Network Master/Slave

CPU001/CPU002 Multiple Remote Rack Input


193 258 ------766 --393 646 1087 --------535 582 598 --** **

Multiple Remote Rack Input


130 181 ------651 --324 541 920 --------442 484 497 --** **

Output
----118 165 177 --728 ------206 300 489 678 ------490 ** **

Output
----167 223 261 --757 ------267 377 596 815 ------615 ** **

Mixed modules have both and input and output scan time values.

** Network Communications Modules (NCM) Scan Impact Times vary depending upon the network configuration.
GFK-1503D Appendix A Performance Data A-11

A
Modules Located in Single-ended Isolated Expansion Rack
The table below shows timing for modules located in an expansion rack in a single-ended expansion system that has an Isolated Expansion Receiver Module (IC200ERM001) in the expansion rack and an Expansion Transmitter module (IC200ETM001) in the CPU rack. CPU005/CPUE05 Module Type
Discrete Input Type 1 * Discrete Input Type 2 * Discrete Output Type 1 * Discrete Output Type 2 * Discrete Output w/ ESCP Per Point Fault Reporting Intelligent Discrete Input 20 Points Intelligent Discrete Output 12 Points Analog Input 4 Channels Analog Input 8 Channels Analog Input 15 Channels Analog Output 2 Channels Analog Output 4 Channels Analog Output 8 Channels Analog Output 12 Channels Intelligent Analog Input 4 Channels Intelligent Analog Input 7 Channels Intelligent Analog Input 8 Channels Intelligent Analog Output 4 Channels PLC Network Comm Profibus-DP Slave DeviceNet Network Master/Slave Isolated Rack Input Output 466 --869 ----452 --837 --850 4050 --2054 3660 6471 --------3155 3401 3483 --** ** --5135 ------1221 1991 3531 5071 ------2751 ** **

CPU001/CPU002
Isolated Rack Input Output 524 --913 ----496 --875 --914 4086 --2093 3660 6471 --------3196 3444 3526 --** ** --5135 ------1251 2021 3560 5099 ------2811 ** **

Mixed modules have both and input and output scan time values.

** Network Communications Modules (NCM) Scan Impact Times vary depending upon the network configuration.

A-12

VersaMax PLC Users Manual January 2006

GFK-1503D

A Ethernet Global Data Sweep Impact


Depending on the relationship between the CPU sweep time and Ethernet Global Data (EGD) exchanges period, the exchange data may be transferred every sweep or periodically after some number of sweeps. Therefore, the sweep impact will vary based on the number of exchanges that are scheduled to be transferred during the sweep. However, at some point during the operation of the PLC, all of the exchanges will be scheduled to transfer data during the same sweep. Therefore, all exchanges must be considered when computing the worst case sweep impact. The Ethernet Global Data (EGD) sweep impact has two parts, Consumption Scan and Production Scan: EGD Sweep Impact = Consumption Scan Time + Production Scan Time Where the Consumption and Production Scans consist of two parts, exchange overhead and byte transfer time: Scan Time = Exchange Overhead + Byte Transfer Time

Exchange Overhead
Exchange overhead includes the setup time for each exchange that will be transferred during the sweep. This overhead varies depending on whether the exchange is consumed or produced and if the time-stamp for the exchange originates from the PLC itself or from a remote Network Time Protocol (NTP) server. When computing the sweep impact, include overhead time for each exchange.
Consumed Exchange Exchange Overhead* 80 Produced Exchange 110 (304**)

* Times are in microseconds. ** Represents overhead if the exchange is time-stamped with the PLC clock instead of a remote NTP server.

Byte Transfer Time


This is the time required to transfer data between the PLC CPU module and the Ethernet module. The byte transfer time is slightly greater if the PLC memory being written to could contain overrides due to additional overhead. The times shown in the following table represent the time to transfer one data byte.
Consumed Exchange Byte Transfer Time* 1 (3.6**) Produced Exchange 1

* Times are in microseconds. ** Represents transfer time if memory type supports overrides.
GFK-1503D Appendix A Performance Data A-13

A Support for Large Ethernet Global Data Configurations


The VersaMax CPUE05 Ethernet Global Data (EGD) feature supports a configuration of up to 32 exchanges, at periods as short as 10 ms, with data sizes as large as 1400 bytes. However, the CPUE05 cannot support a configuration in which every aspect of EGD is maximized. The chart below indicates the maximum number of EGD exchanges that the CPUE05 can realistically support of a certain size and data refresh period under BestCase conditions. These numbers will scale downwards based on the size of the user program, the presence of other Ethernet traffic, etc. The term Best-Case indicates the following setup parameters apply:

No user logic is present, so the logic sweep time is nearly 0 There are no modules present in the system. No other Ethernet traffic present on the network. Assumed data refresh timeout is 2 refresh period + 10ms

CPUE05 System Best-Case EGD Capacity


32 32 32 32 32 32 32 32 32 29 32 32 27 32 32 28 20 24 20 16 16 14 0 25 8 11 100 10 0 50 6 3 0 3 5
10
Period of Exchange (ms)
20

Number of Exchanges Supported

0 20

70

10

0 14 00

Size per Exchange (bytes)

A-14

VersaMax PLC Users Manual January 2006

GFK-1503D

Index
1
10BaseT, 13-3 10BaseT Port, 4-19 Cfg From configuration parameter, 5-7 Checksum, 7-3, 11-9 Change/read number of words, 11-2 read, 11-2 Checksum task state, 11-9 Coils, 10-65 continuation coil, 10-63 SET coil, 10-67 Color code on modules, 1-7 COMMREQ, 12-2 4300, 12-15 4301, 12-16 4302, 12-17 4303, 12-18 4304, 12-20 4399, 12-21 4400, 12-22 4401, 12-24 4402, 12-25 4403, 12-27 for Serial I/O, 12-2 Communication Request. See COMMREQ Communication window modes, 7-3 Communications Carrier, 1-15 Communications window, 7-3 Configuration, 5-6 Configuration and register data storing to flash memory, 7-6 Constant Sweep Time mode, 7-5 Constant Sweep Timer, 7-5 change/read, 11-2 Consumed Data Exchange Definition, 6-6, 6-7 Contacts Continuation contact, 10-63 normally closed contact, 10-63 normally open contact, 10-63 Continuation coil, 10-63 Continuation contact, 10-63 Control functions, 8-12 CALL, 7-7 END, 7-7 Conversion functions, 8-11 Cosine function, 10-54 Counters, 8-9 function block data, 10-74 CPU size, 2-3, 3-3 CPU sweep, 7-1 Current draw, 4-9

A
Addition of Module diagnostic, 5-13 Analog inputs, 9-2 Analog outputs, 9-2 application program, 8-1 Attachment of the Ethernet Interface to the LAN, 13-3 Autoconfiguration, 5-2, 5-12 Autodial, 12-22

B
Battery replacement, 4-11 Baud rates, 2-5, 3-5 BCLR, 10-12 Bit clear function, 10-12 Bit memory, 9-3 Bit Operation functions, 8-10 BCLR, 10-12 BPOS, 10-15 BSET, 10-12 BTST, 10-11 NOT, 10-7 ROL, 10-10 ROR, 10-10 SHL, 10-8 SHR, 10-8 XOR, 10-5 Bit position function, 10-15 Bit set function, 10-12 Bit test function, 10-11 BITSEQ memory required, 10-16 BPOS, 10-15 BSET, 10-12 BTST, 10-11

C
Cable lengths, 3-6 Call function, 7-7 Call levels, 8-4 CE Mark installation requirements, 4-20
GFK-1503D

Index-1

Index D
Data move functions, 8-11 Data retentiveness, 9-4 Data types BCD-4, 9-9 BIT, 9-9 BYTE, 9-9 DINT, 9-9 INT, 9-9 REAL, 9-9 WORD, 9-9 Diagnostics, 5-13 DIN rail, 4-2 Discrete references, 9-3 Documentation, 1-2 Fault Tables, read, 11-2 Field Power LED, 1-7 Flash memory Cfg From described, 5-7 operation, 7-6 Floating-point Numbers, 9-10 Folder name, read, 11-2 FTB protection CE Mark requirements, 4-20

G
Gateway IP Address, 6-3 Gateways, 13-5

E
Elapsed Time, read, 11-2 End function, 7-7 ESD protection CE Mark requirements, 4-20 Ethernet Global Data Consumed Data Exchange Definition, 6-6, 6-7 Effect of PLC modes and actions on, 13-11 Exchange Status Word, 13-22 Timestamping, 13-8 Ethernet Interface, 3-11, 13-2 Attachment to the LAN, 13-3 Ethernet LEDs, 3-9 Ethernet NIU User's Manual, 1-2 Ethernet Restart Pushbutton, 3-9 Ethernet Software, 3-11, 13-3 Exchange Status Word Ethernet Global Data, 13-22 Explanation, adding to program logic, 1028 Extra Module diagnostic, 5-13

Genius NIU User's Manual, 1-2 Global data references, 9-3

H
Hot insertion, 1-3 Humidity, 2-4, 3-4

I
I/O carriers, 1-7 installation, 4-2 I/O module installation, 4-10 I/O, interrogate, 11-2 IC200BEM104, 1-16 IC200CBL105, 1-11 IC200CBL110, 1-11 IC200CBL120, 1-11 IC200CBL230, 1-11 Initialize Port function, 12-15, 12-16 Input Buffer, Flush, 12-17 Input Buffer, Set Up, 12-16 Input references, 9-2, 9-3 Input Scan, 7-3 Instruction Set, 8-7 Internal references, 9-3 Inverse cosine function, 10-54 Inverse sine function, 10-54 Inverse tangent function, 10-54 IP address Configuration, 6-3 Isolated network, 6-3 IP Address, 6-3

F
Fast powerup effects, 5-7 Fault table, 13-19 Fault Tables, clear, 11-2

Index-2

VersaMax PLC

User's Manual January 2006

GFK-1503D

Index

IP addressing, 13-4

K
Keying dials on carrier, 1-7

Normally open contact, 10-63 Not a Number, 9-10 NOT function, 10-7

O
OK LED, 1-7 On-Delay Stopwatch Timer, 10-75 Output references, 9-2 Output references, discrete, 9-3 Output scan, 7-3 Override bits, 9-3 Override status, read, 11-2

L
Label instruction, 10-26 Ladder Diagram, 8-7 LAN OK bit, 13-21 LEDs, 2-7, 3-8, 13-15 Logic program storing to flash memory detailed explanation, 7-6 Logical NOT function, 10-7 Logical XOR function, 10-5 Loss of Module diagnostic, 5-13

P
Panel mounting, 4-2 PID function control block, 14-3 reference array, 14-3 time interval, 14-12 PLC configuring, 5-6 PLC Fault Table, 13-19 PLC ID, read, 11-2 PLC Sweep calls Serial I/O, 12-11 Point-to-point RS-422 connections, 4-13, 4-17 Port 1, 2-5 Port 2, 3-5 Port Status, read, 12-18 Ports 10BaseT, 4-19 Power Down Time, read, 11-2 Power flow and retentiveness, 10-64 Power supply, 1-15 Power supply installation, 4-9 Profibus NIU User's Manual, 1-2 Program checksum, 7-3 Program scan, 7-3 Programmer communications, 7-3 Programmer Communications Window change, 11-2 Protocol errors, 12-11

M
Main program, 8-3 Manuals, 1-2 Math functions, 8-9 ACOS, 10-54 ASIN, 10-54 ATAN, 10-54 COS, 10-54 SIN, 10-54 TAN, 10-54 Memory allocation, 9-2 Memory, bit, 9-3 Mode switch, 2-6, 3-8 Modem Hayes-compatible, 12-22 Module color code, 1-7 Module dimensions, 1-7 Module keying, 1-7 Module latch, 1-7 Module orientation on I/O carriers, 1-10 Modules per station, 1-3 Mounting holes, 4-10 Multidrop connections, 4-18

N
NaN, 9-10 Normally closed contact, 10-63

GFK-1503D

Index-3

Index R
R-422 point-to-point connections, 4-13 Rack configuring, 5-6 Read Bytes, 12-25 Read String, 12-27 Real Numbers, 9-10 Reference address assignment, 5-12 References, 9-2 Relational functions, 8-10 Relay functions, 8-8 coils, 10-65 continuation coil, 10-63 continuation contact, 10-63 normally closed contact, 10-63 normally open contact, 10-63 SET coil, 10-67 Resource problem bit, 13-21 Retentiveness, 10-64 Retentiveness of data, 9-4 ROL, 10-10 ROR, 10-10 Rotate left function, 10-10 Rotate right function, 10-10 RS-232, 1-4, 2-2, 3-2 RS-422 point-to-point connections, 4-17 RS-485, 1-4, 2-2, 3-2 RTU, 2-5, 3-5 RTU slave, 12-11 Clear fault tables, 11-20 function numbers, 11-2 Interrogate I/O, 11-26 Read elapsed power down time, 1127 Read elapsed time clock, 11-23 Read I/O override status, 11-24 Read last-logged fault table entry, 1121 Read master checksum, 11-25 Shut down (stop) PLC, 11-19 Service Request function, 11-3 SET coil, 10-67 Setting loop gains for PID Ideal tuning, 14-20 Ziegler and Nichols tuning, 14-20 Shift left function, 10-8 Shift right function, 10-8 SHL, 10-8 Shock, 2-4, 3-4 SHR, 10-8 Simple isolated network configuration, 6-3 Simple Network Time Protocol, 13-8 Sine function, 10-54 Size of a main program or subroutine, 8-3 Slots, 5-2, 5-12 SNP, 2-5, 3-5, 12-6 SNP master, 12-11 SNTP, 13-8 Specifications, 2-3, 3-3 System, 2-4, 3-4 Standard Sweep mode, 7-4 Station Manager software, 3-11, 13-3 Status address location, 6-3 Status references, 9-3, 9-5 Subnet mask, 6-3 Subroutines Call function, 7-7, 10-22 calling, 8-5 number of block declarations, 8-5 number of calls, 8-5 Surge protection, 4-20 SVCREQ, 11-2 Change programmer communications window (#3), 11-2 Change programmer communications window mode (#3), 11-7 Change system communications window (#4), 11-2

S
Sequential Function Chart overview, 8-6 Serial I/O Cancel Operation function, 12-21 Flush Input Buffer function, 12-17 Initialize Port function, 12-15 Input Buffer function, 12-16 Read Bytes function, 12-25 Read Port Status function, 12-18 Read String function, 12-27 Write Bytes function, 12-22, 12-24 Write Port Control function, 12-20 Serial port and cables, appendix C multidrop connections, 4-18 Service Request Change/read time-of-day clock, 11-11

Index-4

VersaMax PLC

User's Manual January 2006

GFK-1503D

Index

Change system communications window mode (#3), 11-8 Change/read checksum (#6), 11-2 Change/read checksum task state and number of words to checksum (#6), 11-9 Change/read constant sweep timer (#1), 11-2, 11-4 Change/read time of day clock (#7), 11-2 Clear Fault Tables (#14), 11-2 Fault Tables, read (#15), 11-2 Interrogate I/O (#26 or 30), 11-2 Read Elapsed Power Down Time (#29), 11-2 Read Elapsed Time Clock (#16), 11-2 Read folder name (#10), 11-2, 11-17 Read I/O Override (#18), 11-2 Read Master Checksum (#23), 11-2 Read PLC ID (#11), 11-2, 11-18 Read sweep time (#9), 11-2, 11-16 Read window values (#2), 11-2, 11-6 Reset watchdog timer (#8), 11-2, 1115 Shut Down the PLC (#13), 11-2 Sweep time, read, 11-2 Sweep, CPU, 7-1 Constant Sweep Time, 7-5 Standard Sweep, 7-4 System Communications Window, 7-3 change, 11-2

Using PLC Fault Table, 13-19

U
Unsupported Module diagnostic, 5-14 Up Counter, 10-81 User program storing to flash memory, 7-6

V
VersaMax Modules, Power Supplies, and Carriers Users Manual, 1-2
VersaMax Rack configuring, 5-6 Vibration, 2-4, 3-4 Vibration resistance, 4-10

W
Watchdog timer, 7-4 Watchdog timer, reset, 11-2 Window times read, 11-2 Write Bytes, 12-24

X
XOR function, 10-5

T
Table functions, 8-11 Tangent function, 10-54 Temperature, 2-4, 3-4

Z
Ziegler and Nichols tuning, 14-20

Temporary references, 9-3


Text, adding to program logic, 10-28 Time of day clock, 11-2 Timer, Constant Sweep, 7-5 Timer, Watchdog, 7-4 Timers, 8-9 function block data, 10-74 Timestamping EGD Exchanges, 13-8 Timestamping, Ethernet Global Data, 13-8 Time-tick contacts, 9-11, 10-73 Transition bits, 9-3 Troubleshooting

GFK-1503D

Index-5

You might also like