gk2 & 1336-gm2 df1 messaging (full duplex / point-to

BULLETIN 1203-GD2, -GK2 & 1336-GM2
DF1 MESSAGING
(FULL DUPLEX / POINT-TO-POINT)
APPLICATION NOTE
OCTOBER 20, 1999
PURPOSE
The purpose of this document is to provide information on using the DF1 Full Duplex/Point-to-Point
protocol and Programmable Controller Communications Commands (PCCC) with the 1203-GD2, -GK2 or
1336-GM2. This document is provides information only. Users must ensure that installations using DF1
and PCCC meet applicable codes and are suitable for the existing conditions.
WHAT THIS NOTE CONTAINS
This document contains information on the DF1 Full Duplex/Point-to-Point protocol and PCCC
commands.
INTENDED AUDIENCE
This application note should be used by personnel familiar with the hardware components and
programming procedures necessary to operate SCANport devices. It is also assumed that the user has
some familiarity with serial communications and the programming required to implement serial protocols.
WHERE IT IS USED
The information contained in this application note is intended to address issues in many different
applications. Some changes by the user may be necessary to apply the concepts of this document to a
specific application.
APPLICATION CONSIDERATIONS
SCANport devices may assign different meanings to bits in the Logic Command and Status words. The
usage of the Reference and Feedback words may also vary. Consult the manual for your SCANport
device for more information.
FOR MORE INFORMATION
DF1 & PCCC
Data Highway/Data Highway Plus/DH-485 Communication Protocol and Command Set
Reference Manual
Publication 1770-6.5.16
1203-Gx2
Bulletin 1203 Serial Communications Module
RS232/422/485 (Using DF1 Protocol)
DH485
User Manual
Publication 1203-5.5
Faxback Document # 3301
http://www.ab.com/drives
Page 1 of 11
DEFINITIONS
1203-Gx2
A 1203-GD2 (120/230vac), 1203-GK2 (24vdc) or 1336-GM2 (internal mount) Serial
Communications Module.
DF1
A serial communications protocol defined in ANSI X3.28 subparagraphs D1 and F1.
Full Duplex
Two-way simultaneous transmission between two devices (sometimes referred to as
“Point-to-Point”)
Half Duplex
Two-way non-simultaneous transmission between two or more devices (sometimes
referred to as “Multi-Drop”)
PCCC
Programmable Controller Communications Commands -- the commands transmitted over
DF1 that are used to control Allen-Bradley PLC’s, SLC’s and other devices. Sometimes
referred to as “PC-Cubed”.
Sender
A device capable of sending a command message -- the device that transmits first in
each message transaction.
Responder
A device that replies to a command message.
DF1 -- SYMBOLS USED
DF1 uses 8-bit characters which may be transmitted over any serial communications medium. DF1 uses
certain ASCII characters to form symbols that are embedded in the serial data stream.
Control Characters
ASCII
Character
STX
ETX
ENQ
ACK
DLE
NAK
1
Hex Value
Symbol
Type
Meaning
02h
03h
05h
06h
10h
15h
data
DLE ACK
DLE DLE
DLE ENQ
1
DLE ETX BCC
DLE NAK
DLE STX
Data
Control
Data
Control
Control
Control
Control
Single byte data characters
Message received OK
Represents data of 10h
Retransmit ACK or NAK
End of a message
Bad message received
Start of a new message
May be an 8-bit Block Check Character (2’s complement modulo 256 checksum) or a 16-bit Cyclic
Redundancy Check (CRC-16). Refer to the section on checksum calculation.
Faxback Document # 3301
http://www.ab.com/drives
Page 2 of 11
Maximum Message Size
Minimum Message Size
Byte 1
Byte 2
Byte 3
Byte 4
DST SRC CMD STS
DLE
STX
Byte 5
Byte 6
TNS
Data (0-250 Bytes)
Message from Application Layer
DLE
ETX BCC
DF1 DATA LINK LAYER MESSAGE PACKET FIELDS
DLE STX
Start of message flag.
DST
Destination address -- where this message packet is going.
SRC
Source address -- where this message packet is from.
CMD
The command (or response to a command) this message packet contains.
STS
The status of the device this message packet is from.
TNS
Transaction ID number -- a response message will have the same transaction ID number as
the command message it is responding to.
FNC
Function Code -- an additional command code included in certain command messages. If
used, this is always the first byte in the data block.
EXT STS
Extended Status -- an additional status code included in response messages where the STS
byte’s upper nibble is set to Fh. If used, this is always the first byte in the data block.
ADDR
Data table address inside the 1203-Gx2. Refer to the 1203-Gx2 manual for more information.
The structure of the address fields within the data block varies depending on the message
type.
DLE ETX
End of message flag.
BCC
Checksum -- may be an 8-bit Block Check Character or a 16-bit Cyclic Redundancy Check.
Refer to the section on checksum calculation.
Faxback Document # 3301
http://www.ab.com/drives
Page 3 of 11
DLE STUFFING
When the control character DLE (10h) appears between the DLE STX and DLE ETX of a message it must
be replaced with DLE DLE before transmission. When decoding such a message only one of the DLE
bytes should be included in the BCC or CRC calculation.
CHECKSUM CALCULATION
BCC
Add all bytes between DLE STX (start of message) and DLE ETX (end of message) using modulo
256. Then perform a two’s complement. If DLE stuffing was used in the message data only one
of the two DLE’s should be included in the BCC.
CRC
A CRC-16 that includes all bytes between DLE STX (start of message) and DLE ETX (end of
message) and the ETX byte. If DLE stuffing was used in the message data only one of the two
DLE’s should be included in the CRC.
DF1 -- BASIC MESSAGE TRANSACTION
A DF1 message transaction begins when the sender transmits a command message:
1
DLE
STX
data
DLE
ETX
BCC
If the responder receives the message correctly it will transmit an ACK:
DLE
ACK
If the responder receives the message incorrectly it will transmit a NAK:
DLE
NAK
If the responder does not transmit ACK or NAK the sender may transmit an enquiry:
DLE
ENQ
The number of times the sender will transmit an enquiry before giving up is generally programmable with a
default value of three. When the responder receives an enquiry it transmits an ACK or NAK depending on
the status of the last message it received.
If the responder transmits a NAK it will take no further action on the sender’s message. The sender may
retransmit or go on to the next message.
If the responder transmits an ACK it continues processing the sender’s message and some time later will
transmit a response message:
1
DLE
STX
data
DLE
ETX
BCC
If the sender device receives the message correctly it will transmit an ACK:
DLE
ACK
If the sender device receives the message incorrectly it will transmit a NAK:
DLE
NAK
If the sender does not transmit ACK or NAK the responder may transmit an enquiry:
DLE
ENQ
The number of times the responder will transmit an enquiry before giving up is generally programmable
with a default value of three.
If the sender transmits a NAK the responder should resend (the number of retries is generally
programmable with a default of three retries).
After the responder receives an ACK message or reaches the enquiry or retry limit the message
transaction is complete.
The data contained in these messages is a PCCC command or response.
1
An 8-bit BCC or a 16-bit CRC may be used. Refer to the section on checksum calculation.
Faxback Document # 3301
http://www.ab.com/drives
Page 4 of 11
PCCC COMMAND LISTING AND EXAMPLES
The table below shows all of the PCCC messages supported by the 1203-Gx2. Examples showing the
structures of the message packets for some of these commands are shown on the following pages. For
more information about PCCC messages, refer to Publication 1770-6.5.16. For more information about
data table addresses inside the 1203-Gx2 refer to Publication 1203-5.5.
CMD
Code
01h
FNC
Code
n/a
Command Name
PLC Addressing Style
Unprotected Read
PLC-2
06h
00h
01h
02h
03h
n/a
PLC-2
n/a
n/a
04h
07h
09h
0Ah
Echo
Read Diagnostic Counters
Set Variables
Identify Host and Some
Status
Set Timeout
Reset Diagnostic Counters
Read Link Parameters
Set Link Parameters
n/a
n/a
Logical Address
Logical Address
08h
n/a
Unprotected Write
PLC-2
0Fh
00
*
Word Range Write
01
*
Word Range Read
PLC-2 System, Logical Binary, Logical ASCII
(Not Symbolic)
PLC-2 System, Logical Binary, Logical ASCII
(Not Symbolic)
PLC-2 System, Logical Binary, Logical ASCII
(Not Symbolic)
PLC-2 System, Logical Binary, Logical ASCII
(Not Symbolic)
SLC500
File/Type/Element
67h
Typed Write
68h
Typed Read
A1h
Protected Typed Logical
Read with Two Address
Fields
A2h Protected Typed Logical
Read with Three Address
Fields
A9h Protected Typed Logical
Write with Two Address
Fields
AAh Protected Typed Logical
Write with Three Address
Fields
ABh Protected Typed Logical
Write with Four Address
Fields
*
FRN2.02 and later firmware only
SLC500
File/Type/Element/Sub-element
SLC500
File/Type/Element
SLC500
File/Type/Element/Sub-element
SLC500
File/Type/Element/Sub-element/Bit Mask
Faxback Document # 3301
http://www.ab.com/drives
Page 5 of 11
DF1 PCCC Unprotected Read (CMD = 01h)
(Full Duplex/Point-to-Point)
Read Parameter 5 from the SCANport device connected to the Gx2 at address 1. (PLC = 0)
From Sender
10
DLE
02
STX
01
DST
00
SRC
01
CMD
00
STS
01
TNS lo
03
TNS hi
0A ADDR lo
04
ADDR hi
02
SIZE
10
DLE
03
ETX
BCC
10
06
1.
DLE
ACK
From Responder (1203-Gx2)
Start of
Message
Destination
Source
Command
Status
Unique Transaction
ID number
PLC-2
Address
Size in bytes
End of
Message
Checksum (or 2 byte CRC)
10
06
DLE
ACK
Message was
received correctly
10
02
00
01
41
00
01
03
05
00
10
03
DLE
STX
DST
SRC
CMD
STS
TNS lo
TNS hi
DATA lo
DATA hi
DLE
ETX
BCC
Start of
Message
Destination
Source
Command & 40h
Status (s/b 0)
(Same number as in
command message)
Two bytes of data
in Lo/Hi format
End of
Message
Checksum (or 2 byte CRC)
Message was
received correctly
All numbers shown in hexadecimal
Faxback Document # 3301
http://www.ab.com/drives
Page 6 of 11
DF1 PCCC Unprotected Write (CMD = 08h) (Full Duplex/Point-to-Point)
Write a value of 5 into Parameter 5 of the SCANport device connected to the Gx2 at address 1. (PLC = 0)
From Sender
10
DLE
02
STX
01
DST
00
SRC
08
CMD
00
STS
21
TNS lo
03
TNS hi
0A ADDR lo
04
ADDR hi
05
DATA lo
00
DATA hi
10
DLE
03
ETX
BCC
10
06
1.
DLE
ACK
From Responder (1203-Gx2)
Start of
Message
Destination
Source
Command
Status (s/b 0)
Unique Transaction
ID number
PLC-2
Address
Data in
Lo/Hi order
End of
Message
Checksum (or 2 byte CRC)
10
06
DLE
ACK
Message was
received correctly
10
02
00
01
48
00
21
03
10
03
DLE
STX
DST
SRC
CMD
STS
TNS lo
TNS hi
DLE
ETX
BCC
Start of
Message
Destination
Source
Command & 40h
Status (s/b 0)
(Same number as in
command message)
End of
Message
Checksum (or 2 byte CRC)
Message was
received correctly
All numbers shown in hexadecimal
Faxback Document # 3301
http://www.ab.com/drives
Page 7 of 11
DF1 PCCC Word Range Write (CMD = 0Fh, FNC = 00h)
(Full Duplex/Point-to-Point)
Write a value of 5 into Parameter 5 of the SCANport device connected to the Gx2 at address 1. (PLC = 0)
From Sender
10
DLE
02
STX
01
DST
00
SRC
0F
CMD
00
STS
E1 TNS lo
03
TNS hi
00
FNC
00
OFF
00
OFF
01
TRANS 2
00
TRANS 2
00
MASK
24
ADDR
4E ADDR
31
ADDR
30
ADDR
3A ADDR
35
ADDR
00
ADDR
05
DATA lo
00
DATA hi
10
DLE
03
ETX
BCC
10
06
1.
2.
DLE
ACK
From Responder (1203-Gx2)
Start of
Message
Destination
Source
Command
Status (s/b 0)
Unique Transaction
ID number
Function
Offset
Transaction Size
in words
Address Mask Byte
‘$’ - Logical ASCII
N
1
0
:
5
Null Terminator
Data in
Lo/Hi order
End of
Message
Checksum (or 2 byte CRC)
10
06
DLE
ACK
Message was
received correctly
10
02
00
01
4F
00
E1
03
10
03
DLE
STX
DST
SRC
CMD
STS
TNS lo
TNS hi
DLE
ETX
BCC
Start of
Message
Destination
Source
Command & 40h
Status (s/b 0)
(Same number as in
command message)
End of
Message
Checksum (or 2 byte CRC)
Message was
received correctly
All numbers shown in hexadecimal.
Transaction Size = Number of Words to write
Faxback Document # 3301
http://www.ab.com/drives
Page 8 of 11
DF1 PCCC Word Range Read (CMD = 0Fh, FNC = 01h)
(Full Duplex/Point-to-Point)
Read the value of Parameter 5 from the SCANport device connected to the Gx2 at address 1. (PLC = 0)
From Sender
10
DLE
02
STX
01
DST
00
SRC
0F
CMD
00
STS
01
TNS lo
04
TNS hi
01
FNC
00
OFF
00
OFF
01
TRANS 2
00
TRANS 2
00
MASK
24
ADDR
4E ADDR
31
ADDR
30
ADDR
3A ADDR
35
ADDR
00
ADDR
02
SIZE 3
10
DLE
03
ETX
BCC
10
06
1.
2.
3.
DLE
ACK
From Responder (1203-Gx2)
Start of
Message
Destination
Source
Command
Status (s/b 0)
Unique Transaction
ID number
Function
Offset
Transaction Size
in words
Address Mask Byte
‘$’ - Logical ASCII
N
1
0
:
5
Null Terminator
Size in bytes
End of
Message
Checksum (or 2 byte CRC)
10
06
DLE
ACK
Message was
received correctly
10
02
00
01
4F
00
01
04
05
00
10
03
DLE
STX
DST
SRC
CMD
STS
TNS lo
TNS hi
DATA
DATA
DLE
ETX
BCC
Start of
Message
Destination
Source
Command & 40h
Status (s/b 0)
(Same number as in
command message)
Data in Lo byte
/ Hi byte order
End of
Message
Checksum (or 2 byte CRC)
Message was
received correctly
All numbers shown in hexadecimal.
Transaction Size = Number of Words to read
Size = Number of bytes to read
Faxback Document # 3301
http://www.ab.com/drives
Page 9 of 11
DF1 PCCC Typed Write (CMD = 0Fh, FNC = 67h)
(Full Duplex/Point-to-Point)
Write a value of 5 into Parameter 5 of the SCANport device connected to the Gx2 at address 1. (PLC = 0)
From Sender
10
DLE
02
STX
01
DST
00
SRC
0F
CMD
00
STS
41
TNS lo
03
TNS hi
67
FNC
00
OFF
00
OFF
01
TRANS 2
00
TRANS 2
00
MASK
24
ADDR
4E ADDR
31
ADDR
30
ADDR
3A ADDR
35
ADDR
00
ADDR
99
TYPE
09
EXT
03
EXT 3
42
EXT
05
DATA lo
00
DATA hi
10
DLE
03
ETX
BCC
10
06
1.
2.
3.
DLE
ACK
From Responder (1203-Gx2)
Start of
Message
Destination
Source
Command
Status (s/b 0)
Unique Transaction
ID number
Function
Offset
Transaction Size
in words
Address Mask Byte
‘$’ - Logical ASCII
N
1
0
:
5
Null Terminator
Data Type - Extended
Data Type - Array
Data Type - Size
Data Type - Integer
Data in
Lo/Hi order
End of
Message
Checksum (or 2 byte CRC)
10
06
DLE
ACK
Message was
received correctly
10
02
00
01
4F
00
41
03
10
03
DLE
STX
DST
SRC
CMD
STS
TNS lo
TNS hi
DLE
ETX
BCC
Start of
Message
Destination
Source
Command & 40h
Status (s/b 0)
(Same number as in
command message)
End of
Message
Checksum (or 2 byte CRC)
Message was
received correctly
All numbers shown in hexadecimal.
Transaction Size = Number of Words to write
Data Type - Size = 1 + 2 * Transaction Size
Faxback Document # 3301
http://www.ab.com/drives
Page 10 of 11
DF1 PCCC Typed Read (CMD = 0Fh, FNC = 68h)
(Full Duplex/Point-to-Point)
Read the value of Parameter 5 from the SCANport device connected to the Gx2 at address 1. (PLC = 0)
From Sender
10
DLE
02
STX
01
DST
00
SRC
0F
CMD
00
STS
61
TNS lo
03
TNS hi
68
FNC
00
OFF
00
OFF
01
TRANS 2
00
TRANS 2
00
MASK
24
ADDR
4E ADDR
31
ADDR
30
ADDR
3A ADDR
35
ADDR
00
ADDR
01
SIZE lo 3
00
Size hi 3
10
DLE
03
ETX
BCC
10
06
1.
2.
3.
4.
DLE
ACK
From Responder (1203-Gx2)
Start of
Message
Destination
Source
Command
Status (s/b 0)
Unique Transaction
ID number
Function
Offset
Transaction Size
in words
Address Mask Byte
‘$’ - Logical ASCII
N
1
0
:
5
Null Terminator
Size in
Words
End of
Message
Checksum (or 2 byte CRC)
10
06
DLE
ACK
Message was
received correctly
10
02
00
01
4F
00
61
03
99
09
03
42
05
00
10
03
DLE
STX
DST
SRC
CMD
STS
TNS lo
TNS hi
TYPE
EXT
EXT 4
EXT
DATA
DATA
DLE
ETX
BCC
Start of
Message
Destination
Source
Command & 40h
Status (s/b 0)
(Same number as in
command message)
Data Type - Extended
Data Type - Array
Data Type - Size
Data Type - Integer
Data in Lo byte
/ Hi byte order
End of
Message
Checksum (or 2 byte CRC)
Message was
received correctly
All numbers shown in hexadecimal.
Transaction Size = Number of Words to read
Size = Number of Words to read
Data Type Size = 1 + 2 * Number of Words read
Faxback Document # 3301
http://www.ab.com/drives
Page 11 of 11