Communications
Communications
" #
$ " "
!!! " # %
& ' (
))*** + %
, -
.*))/012023*
/$ 4.*))/0120(01
5 . $$" 6 " #
.7 .//!!! " #
Communications in
Control Component
Version 1.0
12th July 1999
Overall Contents
SECTION 1
Introduction
1-1 Communications in Control and Component........................................................................2
1-2 What is Serial............................................................................................................................2
1-3 What is RS-232? .......................................................................................................................3
1-4 What is RS-422? .......................................................................................................................3
1-5 What is RS-485? .......................................................................................................................3
1-6 What is handshaking?..............................................................................................................4
SECTION 2
Basic Formats and Commands
2-1 The Protocol - ISO Communications Model Layer 2 ...........................................................6
2-2 Basic Frame Formats ...............................................................................................................6
2-3 Omron Connection ...................................................................................................................7
2-4 C-mode Commands..................................................................................................................8
2-4-1 Command/Response Formats.................................................................................................................. 9
2-5 CompoWay/F Command....................................................................................................... 14
2-5-1 Data Format ............................................................................................................................................. 19
2-6 Protocol Tester........................................................................................................................ 23
2-7 Program Description..............................................................................................................25
SECTION 3
ASCII Codes
3-1 ASCII Character Code Chart for Header and Terminator ............................................... 27
i
SECTION 1
Introduction
1
Communication in Control and Component Section 1-1
And finally Protocol tests program for you to send message to test or check response for the
Control Component and PLC.
The concept of serial communication is simple. The serial port sends and receives bytes of
information one bit at a time. Although this is slower than parallel communication, which
allows the transmission of an entire byte at once, it is simpler and can be used over longer
distances. For example, the IEEE 488 specifications for parallel communication state that the
cabling between equipment can be no more than 20 meters total, with no more than 2 meters
between any two devices; serial, however, can extend as much as 1200 meters.
• Baud rate: a speed measurement for communication. It indicates the number of bit
transfers per second. For example, 300 baud is 300 bits per second. When we refer to a
clock cycle we mean the baud rate. For example, if the protocol calls for a 4800-baud rate,
then the clock is running at 4800Hz. This means that the serial port is sampling the data
line at 4800Hz. Common baud rates for telephone lines are 14400, 28800, and 33600.
Baud rates greater than these are possible, but these rates reduce the distance by which
devices can be separated. These high baud rates are used for device communication where
the devices are located together.
• data bits: a measurement of the actual data bits in a transmission. When the computer
sends a packet of information, the amount of actual data may not be full 8 bits. Standard
values for the data packets are 5, 7, and 8 bits. Which setting you choose depend on what
information you are transferring. For example, standard ASCII has values from 0 to 127
(7 bits). Extended ASCII uses 0 to 255 (8 bits). If the data being transferred is simple text
(standard ASCII), then sending 7 bits of data per packet is sufficient for communication.
A packet refers to a single byte transfer, including start/stop bits, data bits, and parity.
Since the number of actual bits depend on the protocol selected, the term packet is used to
cover all instances.
• Stop bits: used to signal the end of communication for a single packet. Typical values are
1, 1.5, and 2 bits. Since the data is clocked across the lines and each device has its own
clock, it is possible for the two devices to become slightly out of sync. Therefore, the stop
2
Communication in Control and Component Section 1-3
bits not only indicate the end of transmission but also give the computers some room for
error in the clock speeds. The more bits that are used for stop bits the greater the lenience
in synchronizing the different clocks, but the slower the data transmission rate.
• Parity: a simple form of error checking that is used in serial communication. There are
four types of parity: even, odd, marked, and spaced. Of course, the option of using no
parity is also available. For even and odd parity, the serial port will set the parity bit (the
last bit after the data bits) to a value to ensure that the transmission has an even or odd
number of logic high bits. For example, if the data were 011, then for even parity, the
parity bit would be 0 to keep the number of logic high bits even. If the parity was odd, and
then the parity bit would be 1, resulting in 3 logic high bits. Marked and spaced parity
does not actually check the data bits, but simply sets the parity bit high for marked parity
or low for spaced parity. This allows the receiving device to know the state of a bit so as
to enable the device to determine if noise is corrupting the data or if the transmitting and
receiving devices' clocks are out of sync.
3
Communication in Control and Component Section 1-6
where serial handshaking can help. In this section we will discuss three of the most popular
forms of handshaking with RS-232: Software Handshaking and Hardware Handshaking.
Software Handshaking:
The first form of handshaking we will discuss is software handshaking. This style uses actual
data bytes as control characters. The lines necessary are still the simple three-line set of Tx,
Rx, and ground since the control characters are sent over the transmission line like regular
data. The XON and XOFF characters are sent by the receiver of the data to pause the
transmitter during communication.
As an example, assume that the transmitter begins to transmit data at a high baud rate. During
the transmission, the receiver finds that the input buffer is becoming full due to the CPU being
busy with other duties. To temporarily pause the transmission, the receiver sends XOFF,
typically decimal 19 or hex 13, until the input buffer has been emptied. Once the receiver is
ready for more data it sends XON, typically decimal 17 or hex 11, to resume communication.
Obviously, the transmitter must also be following this protocol for it to succeed.
The biggest drawback to this method is also the most important fact to keep in mind: decimal
17 and 19 are now off limits for data values. In ASCII transmissions this typically does not
matter since these values are non-character values; however, if the data is being transmitted via
binary, it is very likely that these values could be transmitted as data and the transmission
would fail.
Hardware Handshaking:
The second method of handshaking is to use actual hardware lines. Like the Tx and Rx lines,
the RTS/CTS and DTR/DSR lines work together with one being the output and the other the
input. The first set of lines is RTS (Request to Send) and CTS (Clear to Send). When a
receiver is ready for data, it will assert the RTS line indicating it is ready to receive data. The
sender at the CTS input, indicating it is clear to send the data then reads this. The next set of
lines are DTR (Data Terminal Ready) and DSR (Data Set Ready). These lines are used mainly
for modem communication. They allow the serial port and the modem to communicate their
status. For example, when the modem is ready for data to be sent from the PC, it will assert the
DTR line indicating that a connection has been made across the phone line. This is read in
through the DSR line and the PC can begin to send data. The general rule of thumb is that the
DTR/DSR lines are used to indicate that the system is ready for communication where the
RTS/CTS lines are used for individual packets of data.
4
SECTION 2
Basic Formats and Commands
5
The Protocol-ISO Communications Model Layer 2 Section 2-1
In information technology, a protocol is the special set of rules for communicating that the end
points in a telecommunication connection use when they send signals back and forth.
Protocols exist at several levels in a telecommunication connection.
There are hardware telephone protocols. There are protocols between the end points in
communicating programs within the same computer or at different locations. Both end points
must recognize and observe the protocol.
Think of it as a language. If two computers don't use the same network protocol, then they
cannot communicate.
Every message frame in a transmission, minimum must consist of the following items
Header
A code for the receiver to recognized that a new message is started to arrive. No Header means
missing data at beginning of message.
Data
The data that required to send.
Terminator
A code for the receiver to recognized that the new message has finished arriving. No
Terminator means frame incomplete possible sending computer crash.
6
Omron Connection Section 2-3
4 ID Sensor V700
The following 2 examples are based on CS1 PLC and E5CN Temperature Controller using
Host Link Protocol.
7
C-mode Commands Section 2-4
Response Response
C-mode command
C-mode command
• • •
C-mode (Host Link) commands can be sent from a host computer connected to a PLC Host
Link Unit. Up to 32 PCs (Host Link Units) can be connected to a single host computer. For
identification, each Host Link Unit is assigned a unit number from 0 to 31.
The length of a single unit of a command or response exchange is called a “frame.” A single
frame contains a maximum of 131 characters of data. Characters are sent and received as
ASCII.
8
C-mode Commands Section 2-4
2-4-1 Command/Response Formats
Single-frame Commands
If a command is not more than 131 characters long, communications can be completed by
sending a single command frame. This is called a “single-frame command.”
@ 10¹ 10º * CR
Single-frame Response
If a response is not more than 131 characters long, the communications can be completed by
returning one response frame. This is called a “single-frame response.”
9
C-mode Commands Section 2-4
FCS
Command code End code(hexadecimal) Terminator
Unit number(BCD)
Partitioned Commands
If a command is longer than 131 characters, the command’s text is partitioned by sending a
delimiter [CR code, CHR$(13)] instead of a terminator at the end of each command frame
until the last one. A terminator is sent at the end of the last frame. The procedure is given
below for three command frames.
Note When sending command frames for writing (WR, WL, WC, WD, etc.), be careful not to
partition into separate frames data that is to be written into the same word.
1, 2, 3... 1. From the host computer, attach a delimiter (CR) at the end of command frame 1
and send the frame.
2. When the PC receives this delimiter (CR), it will return only a delimiter (CR) to the
host computer.
3. From the host computer, attach a delimiter (CR) at the end of command frame 2 and
send the frame.
4. When the PC receives this delimiter (CR), it will return only a delimiter (CR) to the
host computer.
5. From the host computer, attach a terminator (*CR) at the end of command frame 3
and send the frame.
6. When the PC receives this terminator (*CR), it will return the response format with a
terminator (*CR) attached to the end.
The following diagram shows the command format when there are more than 131
characters.
10
C-mode Commands Section 2-4
Host computer
Header code
@unit number
Delimiter
Delimiter
Delimiter
Text
Text
Text
FCS
FCS
FCS
128 characters max. 128 characters max.
PC
@unit number
Header code
Delimiter
Delimiter
Delimiter
End code
Text
FCS
Note A “delimiter” is a CR code [CHR$(13)] sent as a single character to indicate the middle of a
command or response.
Partitioned Responses
If a response is more than 131 characters long, the response from the PC is partitioned by
returning a delimiter (CR code, CHR$(13)) instead of a terminator at the end of each frame
until the last one. A terminator is returned at the end of the last frame.
In the following example procedure, the response is partitioned into three frames.
1, 2, 3... 1. When the PC receives the command frame from the host computer, it re-turns
response frame 1 with a delimiter (CR) at the end to the host computer.
2. Only a delimiter (CR) is sent from the host computer to the PC.
3. When the PC receives this delimiter (CR), it returns response frame 2 with a delimiter
(CR) at the end to the host computer.
4. Only a delimiter (CR) is sent from the host computer to the PC.
5. When the PC receives this delimiter (CR), it returns response frame 3 with a
terminator (*CR) at the end to the host computer.
The following diagram shows the response format when there are more than 131 characters.
11
C-mode Commands Section 2-4
Host computer
Header code
@unit number
Delimiter
Delimiter
Delimiter
Text
FCS
PC
@unit number
Header code
Delimiter
Delimiter
Delimiter
End code
Text
Text
Text
FCS
FCS
FCS
128 characters max. 128 characters max.
Note 1. Frames in partitioned commands or responses must have not more than 128 characters
including the delimiter/terminator.
2. Delimiters from the host computer are detected by the presence of a CR code. The
delimiter will be detected even if there is data in front of it.
FCS Calculations
The PC calculates the FCS (Frame Check Sequence) value for each command frame it
receives, and it checks for errors by comparing that value with the FCS value sent with the
12
C-mode Commands Section 2-4
command frame. The host computer must calculate the FCS value when sending a command
frame.
Also, when checking for errors in response frames, the host computer must calculate the FCS
value for each response frame it receives and compare that value to the FCS value sent in the
response frame.
~~
@ 1 0 R R 0 0 0 1 4 2 * CR
ASCII
Code
@ 40 0100 0000
EOR
1 31 0011 0001
0 30 0011 0000
EOR
R 52 0101 0010
1 31 0011 0001
Calculation result 0100 0010 The value is converted to
(see note.) Hexadecimal and handled
4Hex 2 Hex as ASCII
Note The FCS is an 8-bit value converted into two ASCII characters. The 8-bit value is the result of
an exclusive OR sequentially performed between each character in a transmission, from the
first character in the frame to the last character of the text in that frame. Non-ASCII data,
however, may sometimes be sent in the text data. If the data length is 7 bits, the leftmost bit of
each character is masked before the FCS is calculated.
13
CompoWay/F-Command Section 2-5
PC
Temperature
RS-232/RS-485 Controller
Converter
CompoWay/F
PC Temperature
RS-232/RS-485 Controller
Converter
CompoWay/F
Up to 32 TC
14
CompoWay/F-Command Section 2-5
The program for the communications functions is created on the host computer, and the
E5CN/GN’s parameters are monitored or set from the host computer. So, the description
provided here is from the viewpoint of the host computer.
• Reading/writing of parameters
• Operation instructions
• Selection of setup levels
Communications with the E5CN/GNare subject to the following condition:
• Parameters can be written only when the “communications writing” parameter
on the E5CN/GN is set to ON (enabled).
• Communications specifications
* Communications speed, data bits, stop bits and vertical parity can each be set
independently in the communications setting level. Highlighted characters in the table
above indicate defaults.
Transmission procedure
15
CompoWay/F-Command Section 2-5
When the host computer transmits a command frame, the 5CN/GN transmits a response frame
that corresponds to the command frame. A single response frame is returned for each
command frame. The following diagram shows the operation of the command x and response
frames.
Command frame
Host computer
E5CN/GN
Response frame
Allow a wait time of at least 2ms until the next command is sent after the host computer
receives the response from the E5CN/GN.
• Interface
Communications with the host computer are carried out through a standard RS-485 interface.
• Wiring
RS-485
Match the communications specifications of theE5CN/GN and the host computer. If a one-to-
N system is being used, be sure that the communications specifications of all devices in the
system (except individual unit numbers) are the same. This section explains how to set the
16
CompoWay/F-Command Section 2-5
E5CN/GN’s communications specifications. For details on the host computer, refer to the
User’s Manual provided with the host computer.
• Communications parameters
The E5CN/GN’s communications specifications are set in the communications setting level.
These parameters are set on the E5CN/GN’s front panel.
The following table shows the communications parameters and their setting ranges.
(1) Hold down the ~ key for at least three seconds to move from the “operation level” to
the “initial setting level.”
(2) Press the ~ key for less than one second to move from the “initial setting level” to
the “communications setting level.”
(3) Select the parameters as shown below by pressing the M key.
(4) Press the D or U keys to change the parameter set values.
L
L
u-no Communication
L Unit No
L L
L L 1
M
L
L
Bps Baud rate
L
L L
L L 9.6
M
L
L
len Communication
L Data length
L L
L L 7
M
L
L
sbit Communication
L Stop bit
L L
L L 2
M
L
L
prty Communication
L party
L L
L L euen
17
CompoWay/F-Command Section 2-5
LLL
L u-no 1
M
LLL
L bps 9 6
M
LLL
L len 7
M
LLL
L sbit 2
M
LLL
L prty eVen
18
Data Format Section 2-5
Unless otherwise indicated, numbers in this manual are expressed in hexadecimal. Values in
double quotation marks, such as “00”, are ASCII.
The number underneath each delimiter in a frame indicates the number of bytes.
• Command frame
Text
1 2 2 1 1 1
STX This code (02) indicates the beginning of the communications frame (text).
Always set this character in the first byte.
When STX is received again during reception, reception is carried out again
from the point where STX was received.
Sub-address This is not used on the E5CN/GN. Be sure to set the sub-address to “00”.
SID (service ID) This is not used on the E5CN/GN. Be sure to set the sub-address to “00”.
Command text Command text area. For details, see “2.2 Structure of Command text.”
• BCC calculation
19
Data Format Section 2-5
Example
The BCC is formed by converting the 8-bit value obtained by converting the exclusive OR of
the node No. up to ETX into two ASCII characters, and setting this to the BCC area.
BCC=30H + 30H + 30H + 30H + 30H + 30H + 35H + 30H + 33H + 03H =35H
• Response frame
1 2 2 2 1 1
• The end code is returned to receive command frames addresses to the self-node.
• No response will be returned if all the items in the response frame are incomplete up to
the ETX and BCC.
• “Error Detection Priority” indicates the priority when two or more errors occur
simultaneously.
• Communications data
20
Data Format Section 2-5
CompoWay/F 8 digits (Hex) 2’s complement Decimal point is removed and
the result is converted
to hexadecimal.
Example) 105.0 1050
000041A
The following examples show an end code when a command did not end normally.
Command Format
Response Format
Command Format
Response Format
BCC
STX ETX
Response Format
No response
21
Data Format Section 2-5
Command Format
Node No BCC
STX ETX Err
Response Format
22
Protocol Tester Section 2-6
23
Protocol Tester Section 2-6
24
Program Description Section 2-7
Note: a) Refer to ASCII Character Code Chart for Header and Terminator.
b) use capital letter for the data field
The sources are also included. For those wanted to modify them to be included into other
applications are welcome.
25
SECTION 3
ASCII Codes
3-1 ASCII Character Code Chart for Header and Terminator ............................................... 27
26
ASCII Codes Section 3-1
27