The text of a manual · part 2 of 8
CDN060 Series DeviceNet Gateway User Manual, pages 10 to 18
Pages 10 to 18 of 71
The original document is the PDF (3.0 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the MKS CDN066
Page 10
CDN060 User Manual revision 1.00
DeviceNet Interface The CDN060 gateway operates as a DeviceNet slave. It supports Explicit Messages and Polled I/O Messages of the predefined master/slave connection set. The Explicit Unconnected Message Manager (UCMM) is not supported. There are four independent processes operating in a CDN060 gateway application. The first process is the exchange of input and output data between the user application program and the DeviceNet master. The second process is the exchange of input and output data between the gateway and DeviceNet master, using Polled I/O messaging. The third process is receiving serial messages and converting it to input data. The fourth process is converting output data and transmitting it as serial messages. The DeviceNet Polled I/O Message process consists of the DeviceNet master sending output data to the CDN060 in the form of a Poll Command message, and the CDN060 returning input data to the DeviceNet master in a Poll Response message. The output and input data bytes are typically mapped into data files inside the DeviceNet master. These data files are exchanged with the user application program. The application processes the received input data from the gateway and writes new output data to the DeviceNet master, which sends them to the gateway. The Polled I/O data exchange typically occurs at a faster rate than the serial transmit and receive operation, because the DeviceNet baud rate is much greater than the serial channel baud rate. The CDN060 has transmit and receive buffers to handle the slower serial processes. The gateway also provides synchronization features to ensure delivery of received messages to the application program, and transmission of application messages out the serial channel. Input File
Inputs Devicenet Poll Response input data
Receive Message Packet
Outputs Output File
DeviceNet Poll Command output data DeviceNet Master
Transmit Message Packet
Serial Device
Application Program CDN060 Gateway
DeviceNet network
MKS Instruments, Inc.
D.I.P. Products Group
10
Page 11
CDN060 User Manual revision 1.00
The CDN060 configuration defines the number of output bytes in a Poll Command message, and the number of input bytes in a Poll Response message. Each Poll Command and Poll Response message can contain up to 2 overhead bytes for CDN060 status and data synchronization information. The remaining bytes contain output data to be transmitted out the serial channel, or input data received by the serial channel. The following diagram shows how the input and output bytes map into the Poll Response and Poll Command messages. The gateway supports a maximum of 67 output bytes in a Poll Command message, and a maximum of 67 input bytes in a Poll Response message. DeviceNet Master Mapping of DeviceNet Poll Command and Poll Response Data DeviceNet Master Outputs output bytes
DeviceNet Poll Command Message Data Status Clear (if enabled)
TX Sequence Number (if enabled)
Other Output Bytes (1-65 bytes)
output byte output byte output byte output byte output byte output byte output byte output byte output byte output byte output byte output bytes
DeviceNet Master Inputs input bytes
DeviceNet Poll Response Message Data Status (if enabled)
RX Sequence Number (if enabled)
Other Input Bytes (1-65 bytes)
input byte input byte input byte input byte input byte input byte input byte input byte input byte input byte input byte input bytes
Serial Channel Interface The CDN060 serial channel consists of an asynchronous serial transmitter and receiver. The serial interface is configured and controlled by the Serial Stream Object. The Serial Stream Object attributes configure the serial channel baud rate, parity, and flow control. This configuration applies to both the serial transmitter and receiver. The CDN060 gateway has separate 64-byte serial transmit and receive FIFO buffers, allowing full duplex operation when supported by the physical layer media. MKS Instruments, Inc.
D.I.P. Products Group
11
Page 12
CDN060 User Manual revision 1.00
Asynchronous Serial Communictaion Devices communicating on an asynchronous serial link exchange information one bit at a time. Each bit is transmitted for a specific period of time, defined by the baud rate. Devices use internal timing circuitry to generate the baud rate. There is no clocking signal between devices to synchronize the serial data flow, hence the term asynchronous serial communications. Serial data bits are organized into bytes. When a data byte is asynchronously transmitted, it is preceded by a start bit, followed by the data bits, an optional parity bit, and one or more stop bits. There can be a variable transmission delay between successive data bytes, since each byte is framed by its own start and stop bits. The receiver starts saving bits after is receives a valid start bit (0), and stops when it receives the expected number of stop bits (1). The data byte’s leastsignificant bit is transmitted first (data bit 0), and the most-significant bit is last (data bit N). [ start bit ] [ data bit 0 ] [ data bit 1 ] … [ data bit N ] [ optional parity bit ] [ stop bit(s) ]
The parity bit detects single-bit errors in the transmission. The parity bit is calculated and inserted by the transmitter. The receiver calculates the parity of an incoming byte, and compares it to the parity bit sent by the transmitter. If the two bit values do not match, then at least one serial bit value was corrupted during transmission. Flow control enables the receiving device to regulate the rate of incoming data. Hardware flow control uses RTS/CTS signals between the devices to control the rate of transmission. Software flow control uses serial characters XON/OFF to control the rate. CTS Detect Mode uses the CTS signal to enable serial communications. Flow control helps prevent data loss, if the receiving device cannot store incoming data fast enough, or if its Receive Buffer is full and cannot accept more data until existing data is processed. The CDN060 supports baud rates from 300 to 19200 bits per second. It supports 8 data bits with no parity, 7 data bits with parity, and 1 stop bit. The CDN067 model supports XON/XOFF flow control. The CDN066 model supports RTS/CTS, XON/XOFF, and CTS Detect Mode flow control options. Status Information The gateway can be configured to return serial channel status information in the Poll Response message, and receive error-clearing commands in the Poll Command message. When enabled, the Status byte is returned as an input byte, and the Status Clear byte is received as an output byte. These bytes contain 8 status bits, defined below. Each bit represents either an error or state condition for the serial transmitter and receiver. Clearing the associated error bit in the Status Clear output byte will reset Receive Parity Error, Receive Buffer Overflow, Framing Error, and Transmit Buffer Overflow error conditions.
MKS Instruments, Inc.
D.I.P. Products Group
12
Page 13
CDN060 User Manual revision 1.00 Status / Status Clear Bytes
Bit 0 1 2 3 4 5 6 7
Status (1st input byte) Transmit Channel Blocked Transmit Buffer Empty Receive Parity Error Receive Buffer Empty Receive Buffer Overflow Framing Error Transmit Buffer Overflow CTS Signal State (1 = asserted)
Status Clear (1st output byte) not used not used Set = 0 to clear Receive Parity Error condition not used Set = 0 to clear Receive Buffer Overflow condition Set = 0 to clear Framing Error condition Set = 0 to clear Transmit Buffer Overflow condition not used
A user application can use the Transmit Buffer Empty and Receive Buffer Empty status bits to monitor the transmitter and receiver states. However, the CDN060 gateway also has three data synchronization features (Receive Sequence Number, Transmit Sequence Number, Handshake Protocol) that an application can use to better monitor the serial operations. Receiving Messages The CDN060 gateway has two modes for receiving serial data: Stream Mode and Block Mode. Stream Mode is best suited for applications with fixed-length serial messages, but it can also be used to capture any stream of serial data. Block Mode is intended for both fixed and variablelength message applications, where a Delimiter byte denotes the beginning or end of a message. Stream Mode Stream Mode saves all received message bytes in the Receive Buffer. There is no defined beginning or end to the message stream. The only limitation is the gateway must send bytes from the Receive Buffer to the DeviceNet master (Poll Response message) faster than it saves new message bytes in the Receive Buffer, or the 64-byte buffer may eventually overflow. Incoming data stream
0x45 0x62 0x02 0x31 0x32 0x32 0x42 0x45 0x02 0x42 0x43 0x44 …
Stream Mode
0x45 0x62 0x02 0x31 0x32 0x32 0x42 0x45 0x02 0x42 0x43 0x44 … Message Bytes
Block Mode Block Mode uses a configurable Delimiter byte to signal the start or end of a new message packet. The Delimiter cannot be used in any other part of the message, or it would be incorrectly interpreted as the start or end of a message. The gateway can be configured to save the Delimiter byte in the Receive Buffer, or discard it. In Block Mode, the gateway does not return any new message data to the DeviceNet master until the entire serial message has been received. The Pre-Delimiter Block Mode configuration expects the Delimiter at the start of a message. When a Delimiter byte is received, the gateway saves all subsequent bytes in the Receive Buffer until another Delimiter is received (signaling the start of another message), or until the Maximum Receive Size number of bytes has been saved. All bytes received after the Maximum Receive Size and before the next Delimiter are discarded. In this mode, the maximum number of bytes in a single message is defined by the Maximum Receive Size attribute.
MKS Instruments, Inc.
D.I.P. Products Group
13
Page 14
CDN060 User Manual
Incoming data stream Pre-Delimiter Mode Delimiter = 0x02 revision 1.00
0x45 0x62 0x02 0x31 0x32 0x32 0x42 0x45 0x02 0x42 0x43 0x44 …
0x02 Delimiter
0x31 0x32 0x32 0x42 0x45 Message Bytes
0x02 Delimiter
0x42 0x43 0x44 … Message Bytes
The Post-Delimiter Block Mode configuration expects the Delimiter at the end of a message. The gateway saves all received bytes in the Receive Buffer until a Delimiter is received. In this mode, the maximum number of bytes in a single message is limited by the Receive Buffer size (64 bytes), not the Maximum Receive Size attribute.
Incoming data stream
Post-Delimiter Mode Delimiter = 0x02
0x45 0x62 0x02 0x31 0x32 0x32 0x42 0x45 0x02 0x42 0x43 0x44 …
0x45 0x62
0x02
Message Bytes
Delimiter
0x31 0x32 0x32 0x42 0x45 Message Bytes
0x02 Delimiter
0x42 0x43 0x44 … Message Bytes
Returning Received Data When the gateway receives a Poll Command message, it removes some or all of the bytes currently in the Receive Buffer and returns them as input bytes in a Poll Response message. The Maximum Receive Size attribute defines the maximum number of bytes that can be returned in a single Poll Response message. If the Receive Buffer contains more bytes than can fit into one Poll Response message, the remaining bytes are returned in subsequent Poll Response messages. RX Message is the string of valid message bytes returned in a single Poll Response message. The RX Message byte string can be formatted as either a Short_String (byte array with 1st byte = length) or a Byte Array (no length byte). The number of bytes in an RX Message string can be less than or equal to the Maximum Receive Size, but never larger. When the number is less, the remaining Poll Response input bytes are either padded or undefined. In Stream Mode, the gateway will always try to fill Poll Response message with bytes from the Receive Buffer. The only time the RX Message size is less than the Maximum Receive Size is when there are no more bytes in the Receive Buffer. In Block Mode, the gateway will not return any data in a Poll Response message unless it has a complete serial message saved in the Receive Buffer. If the message sizes are small, the gateway may have several messages saved in the Receive Buffer, depending upon how fast the DeviceNet master polls the gateway for data. The messages are returned one at a time in a Poll Response message, regardless of their size. If the message is large, then it is returned in multiple Poll Response messages.
MKS Instruments, Inc.
D.I.P. Products Group
14
Page 15
CDN060 User Manual revision 1.00
Padding Message Data If the number of RX Message bytes currently in the Receive Buffer is less than the Maximum Receive Size number, then the remaining input bytes are undefined. The gateway can optionally fill the unused input bytes with a Pad character. The Pad characters can be added at the beginning or end of the message. Poll Response Message Data Status
Receive Sequence Number other input bytes
1. The are enough message bytes in Receive Buffer to fill Poll Response.
RX Message bytes
2. The are not enough message bytes in Receive Buffer to fill Poll Response. Unused input bytes are undefined.
RX Message bytes undefined
3. The are not enough message bytes in Receive Buffer to fill Poll Response. Pad bytes are added after message bytes.
RX Message bytes
Pad Bytes
4. The are not enough message bytes in Receive Buffer to fill Poll Response. Pad bytes are added before message bytes.
Pad Bytes
RX Message Bytes
If configured for Pre-Delimiter Block Mode and the Delimiter byte is saved, the Pad characters are added either after the last valid message byte (right justification) or before the Delimiter byte (left justification). If configured for Post-Delimiter Block Mode and the Delimiter byte is saved, the Pad characters are added either before the first valid message byte (left justification), or after the last valid message byte but before the Delimiter byte (right justification). Resending Received Data The CDN060 gateway can be configured to return received message bytes only once in a Poll Response message, and return no data (null value) in subsequent Poll Response messages until new message bytes are received. For the Short_String data type, a null value consists of the length byte = 0. For the Byte Array data type, a null value consists of no data. The gateway can also be configured to always return received message bytes in a Poll Response message. If no new bytes in the Receive Buffer, then the last received bytes are returned. If new bytes are in the Receive Buffer, then they are returned. The gateway provides Receive Sequence Number or Handshake Protocol synchronization options to indicate whether the returned bytes represent old or new data.
MKS Instruments, Inc.
D.I.P. Products Group
15
Page 16
CDN060 User Manual revision 1.00
Transmitting Messages The Serial Stream Object receives output bytes (TX Message) from the DeviceNet master in a Poll Command message. It saves the output bytes in the Transmit Buffer, to be transmitted when the serial channel is available. The maximum number of bytes that can be sent in one Poll Command message is defined by the Maximum Transmit Size attribute. The Transmit Buffer can hold up to 64 bytes. Because the DeviceNet Polled I/O data exchange may occur many times faster than the transmission of serial data, the application may need to synchronize the transmit data exchange with the gateway. The number of output bytes in the Poll Command message is fixed. The Status Clear and Transmit Sequence Number bytes are always sent, if enabled. The remaining number of bytes in the Poll Command is defined by the Maximum Transmit Size attribute. If the number of TX Message bytes sent is less than the Maximum Transmit Size number, then the remaining output bytes are undefined. The gateway uses the Short_String length to determine the valid number of bytes to transmit. If Byte Array format is used, all the bytes are transmitted. Poll Command Message Data Status Clear
Transmit Sequence Number
1. TX Message bytes fill Poll Command message.
2. TX Message is smaller than Poll Command message. Unused output bytes are undefined.
other output bytes
TX Message bytes
TX Message bytes undefined
Synchronization To ensure that no information is lost between the gateway’s serial channel and the user application program, the CDN060 has three synchronization options: Receive Sequence Number, Transmit Sequence Number, and Handshake Protocol. Receive Sequence Number When enabled, the gateway returns a Receive Sequence Number input byte in the DeviceNet Poll Response message. The 8-bit Receive Sequence Number is incremented by the gateway whenever it returns new data in the input bytes. The user application uses the Receive Sequence Number to signal the receipt of new message data. Valid numbers are 0-255. Transmit Sequence Number When enabled, the gateway receives a Transmit Sequence Number output byte in the DeviceNet Poll Command message. The gateway will not send the TX Message bytes out the serial channel unless the 8-bit Transmit Sequence Number is different than the last received value. Valid numbers are 0-255.
MKS Instruments, Inc.
D.I.P. Products Group
16
Page 17
CDN060 User Manual revision 1.00
Synchronous Handshake Protocol The gateway can be configured with a more robust transmit and receive synchronization process. The Handshake protocol requires the user application to acknowledge the receipt of new RX Message input bytes. The protocol also requires the gateway to acknowledge the transmission of the last TX Message output bytes. When enabled, both the Receive Sequence Number input byte and Transmit Sequence Number output byte are used. They are segmented into four 4-bit numbers, shown below. Valid numbers are 1 to 15, with 0 reserved to reset the gateway’s numbers. Transmit Sequence Number byte Receive Acknowledge Number Bits 4-7 (upper nibble)
Transmit Request Number Bits 0-3 (lower nibble)
Receive Sequence Number byte Receive Request Number
Transmit Acknowledge Number
Bits 4-7 (upper nibble)
Bits 0-3 (lower nibble)
The Receive Request Number is incremented by the gateway when it returns new RX Message input bytes in the Poll Response Message. The gateway will increment from 15 to 1, skipping 0. The user application acknowledges receipt of this RX Message by setting the Receive Acknowledge Number equal to the Receive Request Number. The updated Receive Acknowledge Number is sent back to the gateway in the next Poll Command Message. When the Receive Acknowledge Number equals the Receive Request Number, the gateway can return the next set of RX Message. If the user application sends 0 as the Receive Acknowledge Number, the gateway resets its Receive Request Number to 0. The following ladder-logic rung shows how the user application program can monitor the gateway’s Receive Request Number (RX Rqst Num), save the new RX Message bytes, and set Receive Acknowledge Number (RX Ack Num) equal to Receive Request Number (RX Rqst Num). Did gateway increment the RX Rqst Num, indicating new data?
Save the RX Message bytes.
Compare Function: RX Rqst Num <> RX Ack Num
Copy Function: <byte array> = RX Message
Acknowledge receipt of new data. Copy Function: RX Ack Num = RX Rqst Num
MKS Instruments, Inc.
D.I.P. Products Group
17
Page 18
CDN060 User Manual revision 1.00
The Transmit Request Number is incremented by the user application when it sends new TX Message output bytes in the Poll Command Message. After the gateway transmits these TX Message bytes, it sets the Transmit Acknowledge Number equal to the Transmit Request Number, acknowledging the transmission. The updated Transmit Acknowledge Number is returned in the next Poll Response Message. If the user application sends 0 as the Transmit Request Number, the gateway ignores the TX Message output bytes and resets its Transmit Acknowledge Number to 0. The following ladder-logic rungs show how the user application program writes a new TX Message value, increments the Transmit Request Number (TX Rqst Num), and waits for the Transmit Acknowledge Number (TX Ack Num) to equal the Transmit Request Number (TX Rqst Num). Note the application must wrap the Transmit Request Number from 15 to 1. Did gateway finish (acknowledge) transmitting the last message? Compare Function: TX Ack Num == TX Rqst Num
Write next output bytes to transmit. Copy Function: TX Message = <byte array>
Increment TX Rqst Num (new data) Addition Function: TX Rqst Num = TX Rqst Num + 1 If TX Rqst Number greater than 15, then reset number to 1 (1-15 range) Compare Function: TX Rqst Num == 16
MKS Instruments, Inc.
Write Function: TX Rqst Num = 1
D.I.P. Products Group
18