Anda di halaman 1dari 7

Ejemplo de interpretacin de funciones y tramas de datos

de cada una

Read Coil Status (FC=01)


Request
This command is requesting the ON/OFF status of discrete coils # 20 to 56
from the slave device with address 17.
11 01 0013 0025 0E84
11: The Slave Address (11 hex = address17 )
01: The Function Code 1 (read Coil Status)
0013: The Data Address of the first coil to read.
( 0013 hex = 19 , + 1 offset = coil #20 )
0025: The total number of coils requested. (25 hex = 37, inputs 20 to 56 )
0E84: The CRC (cyclic redundancy check) for error checking.
Response
11 01 05 CD6BB20E1B 45E6
11: The Slave Address (11 hex = address17 )
01: The Function Code 1 (read Coil Status)
05: The number of data bytes to follow (37 Coils / 8 bits per byte = 5 bytes)
CD: Coils 27 - 20 (1100 1101)
6B: Coils 35 - 28 (0110 1011)
B2: Coils 43 - 36 (1011 0010)
0E: Coils 51 - 44 (0000 1110)
1B: 3 space holders & Coils 56 - 52 (0001 1011)
45E6: The CRC (cyclic redundancy check).
The more significant bits contain the higher coil variables. This shows that coil 36 is off (0) and
43 is on (1). Due to the number of coils requested, the last data field1B contains the status of only
5 coils. The three most significant bits in this data field are filled in with zeroes.

Read Input Status (FC=02)


Request

This command is requesting the ON/OFF status of discrete inputs # 10197 to 10218
from the slave device with address 17.
11 02 00C4 0016 BAA9
11: The Slave Address (11 hex = address17 )
02: The Function Code 2 (read Input Status)
00C4: The Data Address of the first input to read.
( 00C4 hex = 196 , + 10001 offset = input #10197 )
0016: The total number of coils requested. (16 hex = 22, inputs 197 to 218 )
BAA9: The CRC (cyclic redundancy check) for error checking.
Response
11 02 03 ACDB35 2018
11: The Slave Address (11 hex = address17 )
02: The Function Code 2 (read Input Status)
03: The number of data bytes to follow (22 Inputs / 8 bits per byte = 3 bytes)
AC: Discrete Inputs 10204 -10197 (1010 1100)
DB: Discrete Inputs 10212 - 10205 (1101 1011)
35: 2 space holders & Discrete Inputs 10218 - 10213 (0011 0101)
2018: The CRC (cyclic redundancy check).
The more significant bits contain the higher Discrete inputs. This shows that input 10197 is off (0)
and 10204 is on (1). Due to the number of inputs requested, the last data field 35 contains the
status of only 6 inputs. The two most significant bits in this data field are filled in with zeroes.

Read Holding Registers (FC=03)


Request
This command is requesting the content of analog output holding registers # 40108 to
40110 from the slave device with address 17.
11 03 006B 0003 7687
11: The Slave Address (11 hex = address17 )
03: The Function Code 3 (read Analog Output Holding Registers)
006B: The Data Address of the first register requested.

( 006B hex = 107 , + 40001 offset = input #40108 )


0003: The total number of registers requested. (read 3 registers 40108 to 40110)
7687: The CRC (cyclic redundancy check) for error checking.
Response
11 03 06 AE41 5652 4340 49AD
11: The Slave Address (11 hex = address17 )
03: The Function Code 3 (read Analog Output Holding Registers)
06: The number of data bytes to follow (3 registers x 2 bytes each = 6 bytes)
AE41: The contents of register 40108
5652: The contents of register 40109
4340: The contents of register 40110
49AD: The CRC (cyclic redundancy check).

Read Input Registers (FC=04)


Request
This command is requesting the content of analog input register # 30009
from the slave device with address 17.
11 04 0008 0001 B298
11: The Slave Address (11 hex = address17 )
04: The Function Code 4 (read Analog Input Registers)
0008: The Data Address of the first register requested.
( 0008 hex = 8 , + 30001 offset = input register #30009 )
0001: The total number of registers requested. (read 1 register)
B298: The CRC (cyclic redundancy check) for error checking.
Response
11 04 02 000A F8F4
11: The Slave Address (11 hex = address17 )
04: The Function Code 4 (read Analog Input Registers)
02: The number of data bytes to follow (1 registers x 2 bytes each = 2 bytes)

000A: The contents of register 30009


F8F4: The CRC (cyclic redundancy check).

Force Single Coil (FC=05)


Request
This command is writing the contents of discrete coil # 173 to ON
in the slave device with address 17.
11 05 00AC FF00 4E8B
11: The Slave Address (11 hex = address17 )
05: The Function Code 5 (Force Single Coil)
00AC: The Data Address of the coil. (coil# 173 - 1 = 172 = AC hex).
( 00AC hex = 172 , + 1 offset = coil #173 )
FF00: The status to write ( FF00 = ON, 0000 = OFF )
4E8B: The CRC (cyclic redundancy check) for error checking.
Response
The normal response is an echo of the query, returned after the coil has been written.
11 05 00AC FF00 4E8B
11: The Slave Address (11 hex = address17 )
05: The Function Code 5 (Force Single Coil)
00AC: The Data Address of the coil. (coil# 173 - 1 = 172 = AC hex)
FF00: The status written ( FF00 = ON, 0000 = OFF )
4E8B: The CRC (cyclic redundancy check) for error checking.

Preset Single Register (FC=06)


Request
This command is writing the contents of analog output holding register # 40002
to the slave device with address 17.
11 06 0001 0003 9A9B

11: The Slave Address (11 hex = address17 )


06: The Function Code 6 (Preset Single Register)
0001: The Data Address of the register.
( 0001 hex = 1 , + 40001 offset = register #40002 )
0003: The value to write
9A9B: The CRC (cyclic redundancy check) for error checking.
Response
The normal response is an echo of the query, returned after the register contents have been written.
11 06 0001 0003 9A9B
11: The Slave Address (11 hex = address17 )
06: The Function Code 6 (Preset Single Register)
0001: The Data Address of the register. (# 40002 - 40001 = 1 )
0003: The value written
9A9B: The CRC (cyclic redundancy check) for error checking.

Force Multiple Coils (FC=15)


Request
This command is writing the contents of a series of 10 discrete coils from #20 to #29
to the slave device with address 17.
11 0F 0013 000A 02 CD01 BF0B
11: The Slave Address (11 hex = address17 )
0F: The Function Code 15 (Force Multiple Coils, 0F hex = 15 )
0013: The Data Address of the first coil.
( 0013 hex = 19 , + 1 offset = coil #20 )
000A: The number of coils to written ( 0A hex = 10 )
02: The number of data bytes to follow (10 Coils / 8 bits per byte = 2 bytes)
CD: Coils 27 - 20 (1100 1101)
01: 6 space holders & Coils 29 - 28 (0000 0001)
BF0B: The CRC (cyclic redundancy check) for error checking.

The more significant bits contain the higher coil variables. This shows that coil 20 is on (1) and 21
is off (0). Due to the number of coils requested, the last data field01 contains the status of only 2
coils. The unused bits in the last data byte are filled in with zeroes.
Response
11 0F 0013 000A 2699
11: The Slave Address (11 hex = address17 )
0F: The Function Code (Force Multiple Coils, 0F hex = 15 )
0013: The Data Address of the first coil.
( 0013 hex = 19 , + 1 offset = coil #20 )
000A: The number of coils to written ( 0A hex = 10 )
2699: The CRC (cyclic redundancy check) for error checking.

Preset Multiple Registers (FC=16)


Request
This command is writing the contents of two analog output holding registers # 40002 & 40003 to
the slave device with address 17.
11 10 0001 0002 04 000A 0102 C6F0
11: The Slave Address (11 hex = address17 )
10: The Function Code 16 (Preset Multiple Registers, 10 hex - 16 )
0001: The Data Address of the first register.
( 0001 hex = 1 , + 40001 offset = register #40002 )
0002: The number of registers to write
04: The number of data bytes to follow (2 registers x 2 bytes each = 4 bytes)
000A: The value to write to register 40002
0102: The value to write to register 40003
C6F0: The CRC (cyclic redundancy check) for error checking.
Response
11 10 0001 0002 1298
11: The Slave Address (17 = 11 hex)
10: The Function Code 16 (Preset Multiple Registers, 10 hex - 16 )

0001: The Data Address of the first register. (# 40002 - 40001 = 1 )


0002: The number of registers written.
1298: The CRC (cyclic redundancy check) for error checking.

Anda mungkin juga menyukai