Instruction Manual
MICRO CONTROLLER X COMMUNICATION FUNCTIONS
(RS-485 MODBUS)
TYPE: PXR
INP-TN512642a-E
NOTICE
1.Exemption items from responsibility
The contents of this document may be changed in the future without prior notice.
We paid the utmost care for the accuracy of the contents. However, we are not liable for direct and indirect damages resulting from incorrect descriptions, omission of information, and use of information in this document.
1.COMMUNICATION FUNCTIONS 1
1.1General 1
2.SPECIFICATIONS 2
2.1Communication Specifications 2
3.CONNECTION 3
3.1Terminal Allocation 3
3.2Wiring 4
4.SETTING OF COMMUNICATION CONDITION 5
4.1Set Items 5
4.2Setting Operation Method 6
5.MODBUS COMMUNICATION PROTOCOL 7
5.1General 7
5.2Composition of Message 8
5.3Response of Slave Station 10
5.4Function Code 11
5.5Calculation of Error Check Code (CRC-16) 12
5.6Transmission Control Procedure 13
5.7FIX Processing (Cautions at write-in of data) 15
6.DETAILS OF MESSAGE 16
6.1Read-out of Bit Data Function code:01H 16
6.2 |
Read-out of Read-out Only Bit Data |
[Function code:02H] 17 |
6.3 |
Read-out of Word Data [Function code:03H] 19 |
|
6.4 |
Read-out of Read-out Only Word Data [Function code:04H] 22 |
|
6.5 |
Write-in of Bit Data (1 bit) [Function code:05H] 24 |
|
6.6 |
Write-in of Word Data (1 word) [Function code:06H] 25 |
|
6.7 |
Write-in of Continuous Word Data |
[Function code:10H] 26 |
7.ADDRESS MAP AND DATA FORMAT 28
7.1Data Format 28
7.2Address Map of Internal Calculation Value Data 31
7.3Address Map of Engineering Unit Data 36
7.4Additional Explanation of Address Map 41
8.SAMPLE PROGRAM 44
9.TROUBLESHOOTING 49
i
•PXR provides a communication function by RS-485 interface, by which it can transmit and receive data to and from host computer, programmable controller, graphic display panel, etc.
•The communication system consists of master station and slave stations. Up to 31 slave stations (PXR) can be connected per master station.
Note that, because the master station can communicate with only one slave station at a time, a party to communicate with must be specified by the "Station No." set at each slave station.
•In order that the master station and slave station can communicate, the format of the transmit/receive data must coincide. For the PXR, the format of the communication data is determined by the MODBUS protocol.
•Please use an RS-232C↔RS-485 converter in case of designating a personal computer or other devices which have an RS-232C interface as a master station.
[RS-232C↔RS-485 converter] (recommended article)
Type: KS-485 (non-isolated type)/SYSTEM SACOM Corp. Type: SI-30A (isolated type)/SEKISUI ELECTRONICS Co., Ltd.
Programmable |
|
Personal |
|||
|
computer |
||||
controller |
|||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RS-485
RS-232C
RS-232C RS-485 converter
RS-485
[Note] MODBUS® is the registered trade mark of Gould Modicon.
1
Item |
|
Specification |
Electrical specification |
Based on EIA RS-485 |
|
Transmission system |
2-wire, semi-duplicate |
|
Synchronizing system |
Start-stop synchronous system |
|
Connection format |
1 : N |
|
Number connectable units |
Up to 31 units |
|
Transmission distance |
500m max. (total extension distance) |
|
Transmission speed |
9600bps |
|
Data format |
Data length |
8 bits |
|
Stop bit |
1 bit |
|
Parity |
none, even, odd (selectable) |
Transmission code |
HEX value (MODBUS RTU mode) |
|
Error detection |
CRC-16 |
|
Isolation |
Functional isolation between transmission circuit |
|
|
and others (withstand voltage : 500V AC) |
2
WARNING
For avoiding electric shock and malfunctions, do not turn on the power supply untill all wiring have been completed.
Terminal number |
Signal name |
7 |
+ |
8 |
- |
3
•Use twisted pair cables with shield. Recommended cable: UL2464, UL2448, etc.
•The total extension length of the cable is up to 500 m. A master station and up to 31 units of the PXR can be connected per line.
•Both ends of the cable should be terminate with terminating resistors 100Ω1/2W.
•The shield wire of the cable should be grounded at one place on the master station unit side.
•If the PXR is to be installed where the level of noise applied to the PXR may exceed 1000 V, it is recommended to install a noise filter in the master station side as below.
Recommended noise filter: ZRAC2203-11/TDK
Master station |
|
|
|
|
|
|
|
|
RS-232C RS-485 |
|
Noise filter |
Transmission |
PXR |
||
|
|
||||||
|
PC, etc. |
|
|
cable |
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
Master station side |
Slave station (PXR) |
|
Twisted pair cable with shield |
|
|
7 |
|
|
8 |
|
FG |
|
|
|
Terminating resistor |
|
|
100Ω1/2W |
|
Slave station (PXR)
RS-485 interface
or 7RS-485 side of the RS-232CRS-485 converter
8
Slave station (PXR)
7
8
Terminating resistor 100Ω1/2W
4
In order that the master station and instrument (PXR) can correctly communicate, following settings are required.
•All communication condition settings of the master station are the same as those of instruments (PXR).
•All instruments (PXR) connected on a line are set to "Station Nos. (STno)" which are different from each other. (Any "Station No." is not shared by more than one instrument.)
The parameters to be set are shown in the following table. Set them by operating the front panel keys.
Parameter |
Item |
Value at |
Setting range |
Remarks |
|
symbol |
delivery |
||||
|
|
|
|||
――― |
Transmission speed |
9600bps |
Fixed (can not be changed) |
Set the same |
|
――― |
Data length |
8 bits |
Fixed (can not be changed) |
||
communication |
|||||
――― |
Stop bit |
1 bit |
Fixed (can not be changed) |
||
condition to the master |
|||||
|
|
|
0: odd parity |
||
|
|
|
station and all slave |
||
CoM |
Parity setting |
0 |
1: even parity |
stations. |
|
|
|
|
2: none parity |
|
|
STno |
Station No. |
1 |
0 to 255 |
Set a different value to |
|
(0:communication function stop) |
each station. |
||||
|
|
|
5
The following example shows how to set the communication conditions.
Example: Selecting an even parity and “STno=18” on a station.
Key |
|
Indication |
|
|
Description |
|
operation |
|
|
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
|
Running state (PV/SV indication) |
||
|
|
200 |
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
||
SEL |
|
|
|
Press the SEL key for approximately 6 seconds. P-n1 appears and |
||
|
P-n1 |
|
||||
(6 seconds) |
|
0 |
|
No. 3 block parameter is selected. |
||
|
|
|
|
|
||
|
|
|
|
Operate the key repeatedly until STno parameter appears. (If |
||
|
|
STno |
|
|||
|
0 |
|
past over, operate the key to return.) |
|||
|
|
|
||||
|
|
|
|
|
|
|
|
|
|
|
Press the SEL key. |
The |
numeric value on the lower indicator |
SEL |
|
STno |
|
|||
|
0 |
|
blinks and the setting mode is selected. |
|||
|
|
|
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
STno |
|
Operate the or key to change the numeric value to 18. |
||
|
18 |
|
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Press the SEL key again. |
The numeric value stops blinking and |
|
SEL |
|
STno |
|
|||
|
18 |
|
the setting is registered. |
|
||
|
|
|
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CoM |
|
Press the key to display the CoM parameter. |
||
|
0 |
|
||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Press the SEL key. |
The |
numeric value on the lower indicator |
SEL |
|
CoM |
|
|||
|
0 |
|
blinks and the setting mode is selected. |
|||
|
|
|
||||
|
|
|
|
|
||
|
|
|
|
Operate the or key until the numeric value changes to 1 (even |
||
|
|
CoM |
|
|||
|
1 |
|
parity). |
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
Press the SEL key again. |
The numeric value stops blinking and |
|
SEL |
|
CoM |
|
|||
|
1 |
|
the setting is registered. |
|
||
|
|
|
|
|||
|
|
|
|
|
||
SEL |
|
|
|
Press the SEL key for 3 seconds to resume the running indication |
||
|
200 |
|
||||
(3 seconds) |
|
200 |
|
(PV/SV indication). |
|
|
|
|
|
|
|
|
|
6
The communication system by the MODBUS protocol is that the communication is always started from the master station and a slave station responds to the received message.
Transmission procedures is as shown below.
1 The master station sends a command message to a slave station.
2 The slave station checks that the station No. in the received message matches with the own station No. or not.
3 If matched, the slave station executes the command and sends back the response message.
4)If mismatched, the slave station leaves the command message and wait for the next command message.
a)In case when the station No. in the received command message matches with the own slave station No.
Master to slave Command message |
|
Data on |
Slave to master |
Response message |
the line |
b)In case when the station No. in the received command message mismatches with the own slave station No.
Master to slave Command message |
|
Data on |
Slave to master |
(Not respond) |
the line |
The master station can individually communicate with any one of slave stations connected on the same line upon setting the station No. in the command message.
7
Command message and response message consist of 4 fields ; Station No., Function code, Data and Error check code. And these are send in this order.
Station No. (1 byte)
Function code (1 byte)
Data (2 to 125 bytes)
Error check code (CRC-16) (2 bytes)
Fig. 5-1 Composition of message
In the following, each field is explained.
(1)Station No.
Station No. is the number specifiing a slave station. The command message is received and operated only by the slave station whose station No. matches with the No. set in the parameter "STno".
For details of setting the parameter "STno", refer to chapter 4.
(2)Function code
This is a code to designate the function executed at a slave station.
For details, refer to section 5.4.
(3)Data
Data are the data required for executing function codes. The composition of data varies with function codes. For details, refer to chapter 6.
A coil number or a register number is assigned to each data in the temperature controller. For reading/writing the data by communication, designate the coil number or register number.
Note that the coil number or register number transmitted on message is expressed as its relative address. The relative address is calculated by the following expression.
|
|
|
|
Relative address |
The lower 4 digits of the |
Coil number or register number |
– 1 |
|
|
|
|
For example, when the resister number designated by a function code is 40003, Relative address = (lower 4 digits of 40003) – 1
= 0002
is used on the message.
8
(4)Error check code
This is the code to detect message errors (change in bit) in the signal transmission.
On the MODUBUS protocol (RTU mode), CRC-16 (Cycric Redundancy Check) is applied. For CRC calculation method, refer to section 5.5.
9
(1)Response for normal command
To a relevant message, the slave station creates and sends back a response message which corresponds to the command message. The composition of message in this case is the same as in section 5.2.
Contents of the data field depend on the function code. For details, refer to Chapter 6.
(2)Response for abnormal command
If contents of a command message have an abnormality (for example, non-actual function code is designated) other than transmission error, the slave station does not execute that command but creates and sends back a response message at error detection.
The composition of response message at error detection is as shown in Fig. 5-2 The value used for function code field is function code of command message plus 80H.
Table 5-1 gives error codes.
Station No.
Function code + 80H
Error code
Error check CRC-16
Fig. 5-2 Response message at error detection
|
Table 5-1 |
Error code |
|
|
|
Error code |
Contents |
Description |
01H |
Illegal function |
Non-actual function code is designated. |
|
|
Check for the function code. |
02H |
Illegal data address |
A relative address of a coil number or resister |
|
|
number to which the designated function code can |
|
|
not be used. |
03H |
Illegal data value |
Because the designation of number is too much, |
|
|
the area where coil numbers or resister numbers do |
|
|
not exist is designated. |
(3)No response
Under any of the following items, the slave station takes no action of the command message and sends back no response.
A station number transmitted in the command message differs from the station number specified to the slave station.
A error check code is not matched, or a transmission error (parity error, etc.) is detected.
The time interval between the composition data of the message becomes longer than the time corresponding to 24 bits. (Refer to section 5.6 Transmission Control Procedure)
While the data is being written in non-volatile memory after write via communication, the next write is attempted.
10
5.4Function Code
According to MODBUS protocol, coil numbers and register numbers are assigned by function codes. Each function code acts on specific coil number and register number.
This correspondence is shown in Table 5-2, and the message length by function is shown in Table 5-3.
Table 5-2 Correspondence between function codes and objective address
No. |
Function |
Object |
01H |
Read-out |
Coil |
|
(continuously) |
|
02H |
Read-out |
Input relay |
|
(continuously) |
|
03H |
Read-out |
Holding register |
|
(continuously) |
|
04H |
Read-out |
Input register |
|
(continuously) |
|
05H |
Write-in |
Coil |
06H |
Write-in |
Holding register |
10H |
Write-in |
Holding register |
|
(continuously) |
|
Coil No. and resister No.
No. |
Contents |
|
0xxxx |
Read-out/write-in |
bit data |
|
|
|
1xxxx |
Read-out |
bit data |
|
|
|
4xxxx |
Read-out/write-in |
word data |
|
|
|
3xxxx |
Read-out |
word data |
|
|
|
0xxxx |
Read-out/write-in |
bit data |
4xxxx |
Read-out/write-in |
word data |
4xxxx |
Read-out/write-in |
word data |
|
|
|
Table 5-3 Function code and message length
|
|
|
|
|
|
[Unit:byte] |
Function |
Contents |
Number of |
Command message |
Response message |
||
code |
|
designatable |
Minimum Maximum |
Minimum Maximum |
||
|
|
data |
|
|
|
|
|
|
|
|
|
|
|
01H |
Read-out of bit data |
1bit*1 |
8 |
8 |
6 |
6 |
02H |
Read-out of bit data (read-out only) |
8 bits*1 |
8 |
8 |
6 |
6 |
03H |
Read-out of word data |
60 words*1 |
8 |
8 |
7 |
125 |
04H |
Read-out of word data |
15 words*1 |
8 |
8 |
7 |
35 |
|
(read-out only) |
|
|
|
|
|
05H |
Write-in of bit data |
1 bit |
8 |
8 |
8 |
8 |
06H |
Write-in of word data |
1 word |
8 |
8 |
8 |
8 |
10H |
Write-in of continuous word data |
60 words *1 |
11 |
129 |
8 |
8 |
*1) The "Number of designatable data" given above is the limit due to the number of data which the instrument assigns to coil number and register number (except function codes 05H, 06H).
11
5.5Calculation of Error Check Code (CRC-16)
CRC-16 is the 2-byte (16-bits) error check code. From the top of the message (station No.) to the end of the data field are calculated.
The slave station calculates the CRC of the received message, and does not respond if the calculated CRC is different from the contents of the received CRC code.
Fig. 5-3 shows the flow of the CRC-16 calculation system.
Start
Set FFFFH (hexadecimal number) in CR.
Set 1 in J.
Exclusive logical sum (XOR) is executed with CR and one character (1 byte) of the I characters, and its results is set in CR.
Explanation of variables
CR:CRC error check data (2 bytes) I:Digits of calculation characters
in command message
J:Check on the number of times of CR calculation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Set 1 in J. |
|
|
|
|
|
|
|||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bit at right end |
NO |
|
|
|
|
||||
|
|
|
|
|
of CR is 1? |
|
|
|
|
|
|
|||
|
|
|
|
|
|
|
|
|
|
|||||
|
|
|
|
|
|
|
YES |
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
Shift CR to right by 1 bit, and A001H and |
|
Shift CR to right |
|
|||||||||
|
|
exclusive logical sum (XOR) are executed |
|
by 1 bit. |
|
|||||||||
|
|
and its result is set in CR. |
|
|
|
|
|
|||||||
|
|
|
|
|
|
|
||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
Add 1 to J. |
|
|
|
|
|
|
|||
|
NO |
|
|
|
|
|
|
|
|
|
|
|||
|
|
|
Calculation |
(8 times) is |
|
|
|
|
|
|||||
|
|
|
|
finished? |
|
|
|
|
|
|
|
|||
|
|
|
|
|
|
|
|
|
||||||
|
|
|
|
|
|
J>8 |
|
|
|
|
|
|||
|
|
|
|
|
|
|
YES |
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
|
|
|
Add 1 to J. |
|
|
|
|
|
|
|||
|
NO |
|
|
|
|
|
|
|
|
|
|
|||
|
|
|
Calculation of |
all characters is |
|
(Calculation is executed in the order of |
||||||||
|
|
|
|
|
completed? |
|
||||||||
|
|
|
|
|
|
command message station No., function |
||||||||
|
|
|
|
|
I>All characters |
|
||||||||
|
|
|
|
|
|
code and data.) |
||||||||
|
|
|
|
|
|
|
|
|
|
|
||||
|
|
|
|
|
|
|
YES |
|
CR calculation result shall be added to |
|||||
|
|
|
|
|
|
|
|
the last command message in the order |
||||||
|
|
|
|
|
|
|
|
|
|
|
||||
|
|
|
|
|
End |
|
of LOW byte and HIGH byte. |
Fig. 5-3 Flow of CRC-16 calculation
12
(1)Transmission procedure of master station
The master station must proceed to a communication upon conforming to the following items. (1-1) Before sending a command message, provide 48 bits time or more vacant status. (1-2) For sending, the interval between bytes of a command message is below 24 bits time. (1-3) Within 24 bits time after sending a command message, the receiving status is posted.
(1-4) Provide 48 bits time or more vacant status between the end of response message reception and beginning of next command message sending [same as in (1-1)].
(1-5) For ensuring the safety, make a confirmation of the response message and make an arrangement so as to provide 3 or more retries in case of no response, error occurrence, etc.
Note) The above definition is for most unfavorable value. For ensuring the safety, it’s recommended the program of the master to work with safety factors of 2 to 3. Concretely, it is advised to arrange the program for 9600 bps with 10 ms or more for vacant status (1-1), and within 1 ms for byte interval (1-2) and changeover from sending to receiving (1-3).
(2)Description
1) Detection of the message frame
Since the communication system uses the 2-wire RS-485 interface, there may be 2 statuses on a line below.
(a)Vacant status (no data on line)
(b)Communication status (data is existing)
Instruments connected on the line are initially at a receiving status and monitoring the line. When 24 bits time or more vacant status has appeared on the line, the end of preceding frame is assumed and, within following 24 bits time, a receiving status is posted. When data appears on the line, instruments receive it while 24 bits time or more vacant status is detected again, and the end of that frame is assumed. I.e., data which appeared on the line from the first 24 bits time or more vacant status to the next 24 bits time or more vacant status is fetched as one frame.
Therefore, one frame (command message) must be sent upon confirming the following. (1-1) 48 bits time or more vacant status precedes the command message sending. (1-2) Interval between bytes of 1 command message is smaller than 24 bits time.
2) Response of this instrument (PXR)
After a frame detection (24 bits time or more vacant status), this instrument carries out processing with that frame as a command message. If the command message is destined to the own station, a response message is returned. Its processing time is 1 to 30 ms (depends on contents of command message). After sending a command message, therefore, the master station must observe the following.
(1-3) Receiving status is posted within 24 bits time after sending a command message.
13