- 25 -
8-4. Method of creating a message
Message is made up of
①
Slave address,
②
Function code,
③
Data division,
and ④
Error check
code. (See section 8-3.)
Message that can be read and written once is within the following range.
Number of data units
Function
code
ASCII mode
RTU mode
02
64 64
03
32 64
04
32 64
16
32 64
Note) Number of units of data is the request from high order
Method of creating a message is explained in the following example.
Example) Reading the ‘PTN (selecting pattern No.)’ and ‘STP (executing step No.)’ of 'Slave
address 02' of KP.
8-4-1. Message in RTU mode
①
Slave address: 02 [02H]
②
Function code: 04 [04H]
Becomes 'Reading analog input data (Reading contents of input register)'. When function code is
'04' specify 'Relative number of data 2 bytes' and 'number of units of data 2 bytes' that is to be read
in data division. (See section 8-5. For 'Function code: 04', see section 8-5-4.)
Ú
It is necessary to confirm the number of bytes of data.
③
Data division: Starting relative number 125([00H] [7DH]), Number of units 2 ([00H] [02H])
PTN (selecting pattern No.) and STP (executing step No.) are stored in reference number '30103 to
30014' (See section 8-3-4. table 3). From the reference table, it is understood that PTN is stored in
'30126' and STP is stored in '30127'. (See section 8-7. For details on reading the PTN see section
8-7-2.) Relative number of the beginning 'Reference number 30126' is 30126-30001=125 and if
displayed in 2 bytes it becomes '[00H] [7DH]' (See section 8-3-4 table 3).
Number of units of data to be read is '2 units' of PTN and STP, hence when displayed in 2 bytes,
it becomes [00H] [02H].
④
Error check: Calculate using CRC-16 E0E1H ([E1H] [E0H])
Error check in RTU mode is calculated using CRC-16. (See section 8-3-5.
①
) Data of message
basic division becomes [02H] [04H] [00H] [7DH] [00H] [02H] according to
①
to
③
and CRC-16
becomes E0E1H. Thus error check data becomes [E1H] [E0H].
⑤
Message: [02H] [04H] [00H] [7DH] [00H] [02H] [E1H] [E0H]
Create message depending on the configuration of the message. (See section 8-3)