Data Exchange from Allen–Bradley PLC–Based Systems to
EPICS at the Advanced Photon Source *S. J. Stein, C.L. Seaver
Experimental Facilities Division

G. J. Nawrocki, M.R. Kraimer
Accelerator Systems Division

Argonne National Laboratory
9700 S. Cass Ave. Argonne, IL, 60439 USA
ABSTRACTThe Advanced Photon Source (APS) uses Allen–Bradley Programmable Logic Controllers (PLCs)
in a number of applications including equipment protection and personnel safety systems. It is necessary toreport the operating status of these systems to the main control system, designed using the EPICS tool kit.
This paper discusses the method used at the APS to transfer data from a PLC–based subsystem to theEPICS–based control system.

I. INTRODUCTION
Traditionally an EPICS database communicates with the outside world via a number of interfaces one being the Allen–Bradley Remote I/O link. This link consists of an Allen–Bradley VME scanner card
(SV-6008) that resides in a slot in the Input–Output Controller (IOC) and is connected via “Blue Hose”(twinax cable) to a “Remote I/O Adapter”. The Remote I/O Adapter resides in slot zero of the Allen–Bradley
1771 backplane and functions as a bus arbiter but contains no user code. All of the intelligence is contained
within the IOC (usually a MVME167 processor running an EPICS database). With proper configuration, anEPICS database can access a variety of Allen–Bradley 1771 I/O cards including binary, analog and a few
special cards (thermocouple, strain gauge, etc.). This method was used for many years as it was a costeffective way of adding many remote I/O points to an IOC with little effort.
Within the last few years, however, it was determined that another method of acquiring data froman Allen–Bradley system was needed – a passive method that would grant an EPICS database the ability toview the status and I/O map of an autonomous PLC–based system. This was born from the need to monitor
the status of two large safety systems at the Advanced Photon Source (APS) which use PLC processors
running ladder logic (a graphical–based control language). Since the PLC processor resides in slot zero of
the Allen–Bradley backplane, the remote I/O adapter is not an option. This paper discusses the hardware andsoftware used to communicate information from a PLC control/interlock system into EPICS.

II. OVERVIEWAs mentioned in the introduction, the standard connection from an IOC to a Remote I/O adapter isnot valid. Instead, the use of the Allen–Bradley Direct Communication Module (DCM) is appropriate. The
DCM is meant to be used as a method of data transfer from one PLC system to another. The DCM resides
in any open slot in the Allen–Bradley crate, and the main processor controls reading and writing to it via thebackplane. Typically, the DCM is connected to another processor (in a different system) using blue hose.
The remote processor believes it is talking to a remote I/O adapter - the communication over the blue hosetakes place using the same protocol as the Remote I/O link.
If we replace the remote processor with the VME scanner, we now have the ability to read thestatus of a PLC system via an EPICS database. Previously it was necessary to “fool” the EPICS device
support into reading from the DCM as no specific code was written to talk to the DCM [1]. With the latest*

Supported by the U.S. Department of Energy, BES-Materials Sciences, under contract W-31-109-ENG-38

revision of EPICS however, a specific hybrid record type was included for configuring and communicatingwith the DCM.

III. EPICS PROGRAMMING
As stated above, the latest versions of EPICS support communication with the DCM via somespecial record types and device support. A new record type (“abDcm”) was created that is used to specify
such items as the Link, Rack and Slot address of the DCM, the scan rate and the number of messages thatare to be sent from the DCM (1 message = 64 short words) (see figure 1). The Allen–Bradley driver (drvAb)
was modified slightly to allow for arbitrary block transfer requests (instead of tying the block transfer tospecific I/O modules). Processing of the abDcm record causes a read from the DCM - if a word from any ofthe messages has changed, a Channel Access monitor is triggered. Typically records are created as INST_IO
pointing to the abDcm record and specifying the message number, word number, and bit number (if needed).
An example bi (binary input) record is given below (figure 2):record(abDcm, “TestDCM:SJS”){
field(SCAN, “1 second”)
field(UT0, “YES”)
field(UT1, “YES”)
field(LINK, “x”)
field(RACK, ”y”)
field(SLOT, “z”)}•••

The first field specifies that this record be scanned periodically - once persecond. Note that the scan rate can be increased or decreased depending on theresolution desired versus the processor load that can be tolerated.
The second and third fields specify that the DCM will be sending twomessages (there are actually six of these fields UT0 through UT5 - if the UT
field is not specified, it is assumed to be “NO”).
The last three fields specify the address of the DCM in Allen–Bradley “Link,Rack and Slot” notation.

Figure 1 - Example of abDcm record
record(bi, “TestBi:SJS”){field(SCAN, “I/O Intr”)
field(DTYP, “Ab Dcm”)
field(INP , “@TestDCM:SJS.Tx[y,z]”)}•••The first field specifies that this binary input record be I/O Interrupt scanned this record will only process if the word (specified in the INP field) changes.
The second field specifies that the device type is the AB DCM.
The last field points to the record name of the DCM record and specifies themessage number (the “x”), the word number (the “y”) and the bit number(“z”). Note that specifying the bit position within the word is valid only for abinary input record, other record types (namely mbbi and longin) would only
specify down to the word number.

Figure 2 - Example of binary input record

The abDcm device support expects to receive at least two messages per data transfer. Each message
may consist of up to 64 short words (16 bits), however the first eight words are reserved as described below(see figure 3). The first word is used by the DCM to send status information including buffer state, lasttransmission success, etc. The second and third words are reserved for future use and the fourth word (word3) contains an integer value corresponding to the message number (this is the number specified in the Tx
parameter in the Param field of the database record). The last four words are also reserved for future
expansion. Note that this configuration makes the ninth word the first one available for user data.

Word 0(DCM Status Word 0)
Words 1 and 2(Future Use)
Word 3(Message Number (0-5))
Words 4-7
(Future use)
Word 8(User data)
Word 64(User data)

Figure 3 - Message structure from DCM to EPICS
IV. ALLEN–BRADLEY PROGRAMMINGThe Allen–Bradley PLC system must be modified slightly to add the monitoring capability.
Firstly, the messages are constructed in a certain sequence that is known to both the EPICS and PLC
programmer. The messages are then transferred to the DCM via the Block Transfer statement within theladder logic program. Each message is identified by a unique descriptor (an integer value) which is placed inthe fourth word. Each different message is sent in sequence, one at a time. After a message is received in theDCM, block transfers into the DCM are blocked until the message is transmitted over the blue hose. This
process is continuous.

V. SYSTEMS IN USE
A variety of subsystems of the APS use the Allen–Bradley series 5 processors for control andinterlock functions. In general it is important to be able to monitor the status of these systems from many
locations including the Main Control Room (MCR). Below is a short description of three currently
implemented monitoring packages at the APS.

V.1 ACIS
The purpose of the Access Control Interlock System (ACIS) is to guarantee that no one
is in the APS accelerator tunnels while the accelerator is in operation. Since the APS is
composed of several accelerators, there are actually four separate ACIS systems. This allows
portions of the APS to be in operation while people have access to other parts. Each ACIS
system consists of two redundant Allen–Bradley PLC–5 systems.

EPICS currently is used to display the status of two of the ACIS systems with plans toinclude the other two systems. For the two systems currently monitored, the EPICS databaseconsists of approximately 1700 records, most of which are binary input records.
In building the EPICS database and the MEDM (an EPICS GUI) displays, extensive use
was made of the macro expansion capabilities of dbLoadTemplates and MEDM. The 1700
records are generated from just a couple hundred record templates. Over 100 MEDM displays
are available but are generated from just a few medm template displays.
Although the EPICS database has > 1700 records, the CPU utilization is less than 5%.
This is because the DCM support provides the ability to process records only when the word
containing the records signal changes.

V.2 PSSThe Personnel Safety System (PSS) for the beamlines at the APS is used toprovide access interlock and control along an experimental beamline. Each system consists of
two independent chains – one of which is based on the Allen–Bradley series 5 processor.
Currently the PSS for the Sector 3 Insertion–Device beamline has a completely
functional PSS monitoring package installed. It has been used for a variety of tasks including
initial software and hardware debugging, software and hardware verification, on-line
diagnostics and fault tracing. At present, the Allen–Bradley chain of the PSS sends twomessages at each transfer. Each message consists of a variety of values including the entire
input and output image tables, PLC status information (including the current time and date of
the PLC clock) and a time–ordered stack showing the first ten PSS faults [1].
A database was constructed that consists almost entirely of binary input records (see figure1) corresponding to the input and output table of the PLC. Macro substitution was used (viathe dbLoadTemplates command) due to the extremely consistent nature of the I/O map. Ingeneral each bi record is named in a method that correlates easily to the Allen–Bradleyaddressing scheme.
Another database was constructed that is used to store “static” records that do not fit into
the macro substitution mold. These include a few longin records used to pass time and date,ten records that correspond to a fault stack, and a variety of “analog” PLC status values (scantime, battery status, etc.)
Finally a third database is used solely to service the DCM. It contains one abDcm record(see figure 2) that is periodically scanned once per second [2].

V.3 METASYS
Metasys is a distributed system of intelligent I/O processors used for control andmonitoring of environmental and HVAC parameters at the APS. The Metasys Network port
is a device that allows monitoring and controlling of the Metasys Facilities Management
System from a third party computer system. The Metasys Network Port emulates thecommunication of a PLC-5 and communicates with other PLC-5 processors via RS232
using the Allen–Bradley Full-Duplex Data Link Layer Protocol (DF/1). An Allen–Bradley
1771 KF2 converts the Network Port RS232 signal to a Data Highway Peer
Communication Interface to complete the Network Port to PLC-5 link. This dedicated PLC-5module is then programmed to act as bridge between the Metasys Network port and EPICS
utilizing the DCM device and record support.
Currently, at the APS, a small set of binary and analog Metasys values are passed toEPICS as a proof of concept. This number will increase as more environmental data isincorporated into EPICS displays, alarm handling applications, and data acquisition
techniques familiar to the operators and accelerator physicists [3].

VI. CONCLUSION
The additions and modifications to allow communication via the DCM have proven to beinvaluable for monitoring PLC–based systems at the APS. The ability to view the I/O and status of thesesystems has made debugging, diagnostics and fault tracing much easier than previous methods.

Currently there are three systems in place at the APS which use the DCM as a bridge into EPICS.
The Accelerator Control Interlock System (ACIS) uses a very large number of records to convey the statusof a large system to operators throughout the ring. The Personnel Safety System (PSS) also consists of alarge number of records used to report status to operators and, in the near future, APS users. Finally, theMetasys system also reports (indirectly) through a DCM to the main control system a variety ofenvironmental system parameters.

VII. REFERENCES
1. Stein, J. “One-Way Data Transfer for PLC to VME Status Reporting at the Advanced Photon Source,”
Nuclear Instruments & Methods in Physics Research - A 253 (1994) 210-212.
2. Stein, J. “Personnel Safety System Status Reporting via EPICS at the Advanced Photon Source,”
ICALEPCS Proceedings, 1995.
3. Nawrocki, G. Seaver, C. and Kowalkowski, J., “Monitoring Commercial Conventional Facilities
Control with the APS Control System – The Metasys to EPICS Interface,” ICALEPCS Proceedings,1995.