gk2 & 1336-gm2 df1 messaging (half duplex / multi

BULLETIN 1203-GD2, -GK2 & 1336-GM2
DF1 MESSAGING
(HALF DUPLEX / MULTI-DROP)
APPLICATION NOTE
OCTOBER 20, 1999
PURPOSE
The purpose of this document is to provide information on using the DF1 Half Duplex/Multi-Drop protocol
and Programmable Controller Communications Commands (PCCC) with the 1203-GD2, -GK2 or 1336GM2. 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 Half Duplex 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 # 3318
http://www.ab.com/drives
Page 1 of 12
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.
DLE Stuffing
DF1 uses a sequence of two DLE characters (10h) to represent a data value or station
address of 10h. This is also known as “Data Transparency”.
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”)
Master
The device that sends command messages, poll messages and controls message
transmissions.
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”).
Responder
A device replying to a message.
Sender
A device sending a message.
Slave
A device that replies to command messages and is polled by a master.
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
SOH
STX
ETX
EOT
ENQ
ACK
DLE
NAK
Hex
Value
01h
02h
03h
04h
05h
06h
10h
15h
Symbol
1
data
DLE ACK
DLE DLE
DLE ENQ
DLE EOT
2
DLE ETX BCC
DLE NAK
DLE SOH
DLE STX
2
STN
Sent
By:
Either
Slave
Either
Master
Slave
Either
Master
Master
Either
Master
Type
Meaning
Data
Control
Data
Control
Control
Control
Control
Control
Control
Data
Single byte data characters
Message received OK
Represents data or STN = 10h
Start of Polling message
No message available
End of message
Reset communications.
Start of master message packet
Start of message
Station number of a responder
1
may include DLE Stuffing
2
May be an 8-bit Block Check Character (2’s complement modulo 256 checksum) or a 16-bit Cyclic
Redundancy Check (CRC-16). A polling message must use BCC. Refer to the section on checksum
calculation.
Faxback Document # 3318
http://www.ab.com/drives
Page 2 of 12
Maximum Message Size
Minimum Message Size
Byte 1
Byte 2
Byte 3
Byte 4
Byte 5
DST SRC CMD STS
DLE SOH STN
DLE
STX
Byte 6
TNS
Data (0-250 Bytes)
Message from Sender Application Layer
DLE
ETX BCC
1) Master Message Packet
Maximum Message Size
Minimum Message Size
Byte 1
Byte 2
Byte 3
Byte 4
Byte 5
DST SRC CMD STS
DLE
STX
Byte 6
TNS
Data (0-250 Bytes)
Message from Responder Application Layer
DLE
ETX BCC
2) Slave Message Packet
DLE ENQ STN BCC
3) Polling Packet
DF1 HALF DUPLEX DATA LINK LAYER MESSAGE PACKET FIELDS
DLE ENQ STN BCC
A polling packet -- the master is requesting a message from the slave at station
number STN. The slave will respond with a slave message packet or DLE EOT (no
messages). This packet always ends with a BCC and never a CRC.
DLE SOH Start of a master message packet.
STN
Station Number of the destination node for this packet.
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.
Faxback Document # 3318
http://www.ab.com/drives
Page 3 of 12
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 in
all messages except a polling message. Refer to the section on checksum calculation.
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 the STN byte and 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 the STN byte, all bytes between DLE STX (start of message) and DLE
ETX (end of message) and the ETX byte. On a message from the master device the calculation
also includes the STX byte. If DLE stuffing was used in the message data only one of the two
DLE’s should be included in the CRC.
Faxback Document # 3318
http://www.ab.com/drives
Page 4 of 12
DF1 HALF DUPLEX/MULTI-DROP -- BASIC MESSAGE TRANSACTION
A DF1 message transaction begins when the master transmits a command message:
1
DLE
SOH STN
DLE
STX
data
DLE
ETX
BCC
If the slave receives the message correctly and has memory available to buffer the message it will
transmit an ACK:
DLE
ACK
If the slave receives the message incorrectly or is out of buffer space it will not transmit any reply. If the
slave does not transmit ACK the master may retransmit the message or go on to polling routine. The
number of times the master will retransmit a message is generally programmable with a default value of
three.
Some time later the master transmits a polling message to the slave:
DLE
STN
DLE
BCC
If the slave has no messages for the master it responds:
DLE
EOT
If the master receives a DLE EOT message it continues on to the next message or station. The next time
the master communicates with this station the slave may have completed processing the message and
will transmit the response message.
If the slave has a message for the master it sends that message:
1
DLE
STX
data
DLE
ETX
BCC
If the master receives the message incorrectly it may repeat the poll. The number of times the master will
retransmit the poll message is generally programmable with a default value of three. If the slave does not
receive an ACK from the master it will keep the response message available and respond to poll
messages with it until it is successfully received and ACK’ed by the master.
If the master receives the message correctly it will transmit an ACK:
DLE
ACK
The message transaction is now 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.
Faxback Document # 3318
http://www.ab.com/drives
Page 5 of 12
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 # 3318
http://www.ab.com/drives
Page 6 of 12
UNPROTECTED READ (CMD = 01H)
(HALF DUPLEX/MULTI-DROP)
Read Parameter 5 from the SCANport device connected to the Gx2 module at address 1 (PLC = 0).
From Master Device
10
DLE
Start of Master
01
SOH
Message Header
01
STN
Station Address
10
DLE
Start of
02
STX
Message
01
DST
Destination
00
SRC
Source
01
CMD
Command
00
STS
Status
01
TNS lo
Unique Transaction
03
TNS hi
ID number
0A
ADD lo
PLC-2
04
ADD hi
Address
02
SIZE
Size in bytes
10
DLE
End of
03
ETX
Message
E9
BCC
Checksum (or 2 byte CRC)
10
05
01
FF
10
06
1.
DLE
ENQ
STN
BCC
DLE
ACK
From Slave Device
10
06
DLE
ACK
Message was
received correctly
10
02
00
01
41
00
01
03
05
00
10
03
B5
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)
Data in
Lo/Hi order
End of
Message
Checksum (or 2 byte CRC)
Start of
Polling Message
Destination Station Number
Checksum (Always BCC -- Never CRC)
Message was
received correctly
All numbers shown in hexadecimal.
Faxback Document # 3318
http://www.ab.com/drives
Page 7 of 12
UNPROTECTED WRITE (CMD = 08H)
(HALF DUPLEX/MULTI-DROP)
Write a value of 5 into Parameter 5 of the SCANport device connected to the Gx2 at address 1. (PLC = 0)
From Master Device
10
DLE
Start of Master
01
SOH
Message Header
01
STN
Station Address
10
DLE
Start of
02
STX
Message
01
DST
Destination
00
SRC
Source
08
CMD
Command
00
STS
Status (s/b 0)
21
TNS lo
Unique Transaction
03
TNS hi
ID number
0A
ADD lo
PLC-2
04
ADD hi
Address
05
DATA lo
Data in
00
DATA hi
Lo/Hi order
10
DLE
End of
03
ETX
Message
BF
BCC
Checksum (or 2 byte CRC)
10
05
01
FF
10
06
1.
DLE
ENQ
STN
BCC
DLE
ACK
From Slave Device
10
06
DLE
ACK
Message was
received correctly
10
02
00
01
48
00
21
03
10
03
93
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)
Start of
Polling Message
Destination Station Number
Checksum (Always BCC -- Never CRC)
Message was
received correctly
All numbers shown in hexadecimal.
Faxback Document # 3318
http://www.ab.com/drives
Page 8 of 12
WORD RANGE WRITE (CMD = 0FH, FNC = 00H)
(HALF DUPLEX/MULTI-DROP)
Write a value of 5 into Parameter 5 of the SCANport device connected to the Gx2 at address 1. (PLC = 0)
From Master Device
10
DLE
Start of Master
01
SOH
Message Header
01
STN
Station Address
10
DLE
Start of
02
STX
Message
01
DST
Destination
00
SRC
Source
0F
CMD
Command
00
STS
Status (s/b 0)
E1
TNS lo
Unique Transaction
03
TNS hi
ID number
00
FNC
Function
00
OFF
Offset
00
OFF
01
TRANS 2 Transaction Size
00
TRANS 2 in words
00
MASK
Address Mask Byte
24
ADD
‘$’ - Logical ASCII
4E
ADD
N
31
ADD
1
30
ADD
0
3A
ADD
:
35
ADD
5
00
ADD
Null Terminator
05
DATA lo
Data in
00
DATA hi
Lo/Hi order
10
DLE
End of
03
ETX
Message
C3
BCC
Checksum (or 2 byte CRC)
10
05
01
FF
10
06
1.
2.
DLE
ENQ
STN
BCC
DLE
ACK
From Slave Device
10
06
DLE
ACK
Message was
received correctly
10
02
00
01
4F
00
E1
03
10
03
CC
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)
Start of
Polling Message
Destination Station Number
Checksum (Always BCC -- Never CRC)
Message was
received correctly
All numbers shown in hexadecimal.
Transaction Size = Number of Words to write
Faxback Document # 3318
http://www.ab.com/drives
Page 9 of 12
WORD RANGE READ (CMD = 0FH, FNC = 01H)
(HALF DUPLEX/MULTI-DROP)
Read the value of Parameter 5 from the SCANport device connected to the Gx2 at address 1. (PLC = 0)
From Master Device
10
DLE
Start of Master
01
SOH
Message Header
01
STN
Station Address
10
DLE
Start of
02
STX
Message
01
DST
Destination
00
SRC
Source
0F
CMD
Command
00
STS
Status (s/b 0)
01
TNS lo
Unique Transaction
04
TNS hi
ID number
01
FNC
Function
00
OFF
Offset
00
OFF
01
TRANS 2 Transaction Size
00
TRANS 2 in words
00
MASK
Address Mask Byte
24
ADD
‘$’ - Logical ASCII
4E
ADD
N
31
ADD
1
30
ADD
0
3A
ADD
:
35
ADD
5
00
ADD
Null Terminator
02
SIZE 3
Size in bytes
10
DLE
End of
03
ETX
Message
A4
BCC
Checksum (or 2 byte CRC)
10
05
01
FF
10
06
1.
2.
3.
DLE
ENQ
STN
BCC
DLE
ACK
From Slave Device
10
06
DLE
ACK
Message was
received correctly
10
02
00
01
4F
00
01
04
05
00
10
03
A6
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)
Start of
Polling Message
Destination Station Number
Checksum (Always BCC -- Never 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 # 3318
http://www.ab.com/drives
Page 10 of 12
TYPED WRITE (CMD = 0FH, FNC = 67H)
(HALF DUPLEX/MULTI-DROP)
Write a value of 5 into Parameter 5 of the SCANport device connected to the Gx2 module at address 1. (PLC = 0)
From Master Device
10
DLE
Start of Master
01
SOH
Message Header
01
STN
Station Address
10
DLE
Start of
02
STX
Message
01
DST
Destination
00
SRC
Source
0F
CMD
Command
00
STS
Status (s/b 0)
41
TNS lo
Unique Transaction
03
TNS hi
ID number
67
FNC
Function
00
OFF
Offset
00
OFF
01
TRANS 2 Transaction Size
00
TRANS 2 in words
00
MASK
Address Mask Byte
24
ADD
‘$’ - Logical ASCII
4E
ADD
N
31
ADD
1
30
ADD
0
3A
ADD
:
35
ADD
5
00
ADD
Null Terminator
99
TYPE
Data Type - Extended
09
EXT
Data Type - Array
03
EXT 3
Data Type - Size
42
EXT
Data Type - Integer
05
DATA lo
Data in
00
DATA hi
Lo/Hi order
10
DLE
End of
03
ETX
Message
15
BCC
Checksum (or 2 byte CRC)
10
05
01
FF
10
06
1.
2.
3.
DLE
ENQ
STN
BCC
DLE
ACK
From Slave Device
10
06
DLE
ACK
Message was
received correctly
10
02
00
01
4F
00
41
03
10
03
6C
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)
Start of
Polling Message
Destination Station Number
Checksum (Always BCC -- Never 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 # 3318
http://www.ab.com/drives
Page 11 of 12
TYPED READ (CMD = 0FH, FNC = 68H)
(HALF DUPLEX/MULTI-DROP)
Read the value of Parameter 5 from the SCANport device connected to the Gx2 at address 1. (PLC = 0)
From Master Device
10
DLE
Start of Master
01
SOH
Message Header
01
STN
Station Address
10
DLE
Start of
02
STX
Message
01
DST
Destination
00
SRC
Source
0F
CMD
Command
00
STS
Status (s/b 0)
61
TNS lo
Unique Transaction
03
TNS hi
ID number
68
FNC
Function
00
OFF
Offset
00
OFF
01
TRANS 2 Transaction Size
00
TRANS 2 in words
00
MASK
Address Mask Byte
24
ADD
‘$’ - Logical ASCII
4E ADD
N
31
ADD
1
30
ADD
0
3A ADD
:
35
ADD
5
00
ADD
Null Terminator
01
SIZE lo 3 Size in
00
SIZE hi 3 Words
10
DLE
End of
03
ETX
Message
DF BCC
Checksum (or 2 byte CRC)
10
05
01
FF
10
06
1.
2.
3.
4.
DLE
ENQ
STN
BCC
From Slave Device
10
06
DLE
ACK
Message was
received correctly
10
02
00
01
4F
00
61
03
99
09
03
42
05
00
10
03
60
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)
Start of
Polling Message
Destination Station Number
Checksum (Always BCC -- Never CRC)
DLE
Message was
ACK
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 # 3318
http://www.ab.com/drives
Page 12 of 12