KC controller communication protocol(MODBUS-RTU)

2016/11/18

the master controls communication between master and slave. A typical message consists of a request(query message) sent from the master followed by an answer(response message) from the slave. When master begins data transmission, a set of data is sent to the slave in a fixed sequence. When it is received, theslave decodes it, takes the necessary action, and returns data to the master.

1.Communication Mode:

Signal transmission between the master and slaves is conducted in RTU mode.
Data bit length 8-bit(Binary)
Start bit 1
Stop bits 1,2
Parity bit NONE
Error check  CRC-16
When sending a command message from the master, set intervals of data configuring message to time longer than the 200ms time. if time intervals become time less than the 200ms time, the slave does not make a response.
1.Read instrument parameters’  value: Measured value, control output value, etc.
Read holding registers function code(03H)  query message(8bytes) response message(7bytes)
2.Setting the instrument parameters’  value :set value, PID constants, etc.
Preset single register function code(06H)

query message length(8bytes) response message length(8bytes)

2.Read instrument parameters’  value: Measured value, control output value, etc.

KCM-9 KCM-8 KCM-9P Temperature Controller
Example:The contents of a single holding register 1001H(Measured value) is the read out from slave address 1
Query message: 010310010001D10A
explain: 01(slave address)03(function Code)1001(register address)0001(quantity. The setting must be 1)D10A(CRC16)
Response message: 01030200FD79C5
explain: 01(slave address)03(function Code) 02(Number of holding registers*2) 00 FD(holding register contents) 79 C5 (CRC 16)
Response value: Measured value(SV) have one decimal place:00FD=253,is processed as 25.3
The position of the decimal point changes depending on the input range type Because the Modbus protocol does not recognize data with decimal points during communication
KCM-XJ4 XJ2 XJ16 Multi-Loop Temperature Controller
Example: The contents of the four holding registers from 1001H T0 1004H(four channels’ SV) are the read out from slave address 1
Query message: 010310010004D10A
explain: 01(slave address)03(function Code)1001(frist registers address)0004(quantity. The setting must be between 1 and 4)D10A(CRC16)
Response message: 01 030800 FD 00 FA 00 FC 00 FE20 BC
explain 01(slave address)03(function Code) 02(Number of holding registers*2) 00 FD 00 FA 00 FC 00 FE(holding register contents,channel1~4)20 BC(CRC16)
Response value: Channel 1SV:00FD(H)=>253 is processed as 25.3 ; Channel 2 SV: 00FA(H)=>250 as 25.0; Channel 3 SV 00FC(H)=>252 as 25.2 ;Channel 4 SV:00FE(H)=>254 as 25.4

3.Preset single register(Setting the instrument parameters’  value :set value, PID constants, etc.)

1.Data is written into the holding register 0000H (set value address)of slave address 1
Query message: 106000000FA0989
explain: 01(slave address) 06((function Code) 00 00(register address) FF38(wite data) C9 E8(CRC 16)
Response message 106000000FA0989
  When input set value(SV) is -20.0,-20.0 is processed as -200,-200=0000H-00C8H=FF38H
2.Data is written into the holding register 0001H (ALM value address)of slave address 1
Query message: 01 06 00 01 0B B8 DF 48
explain: 01(slave address) 06((function Code) 00 01(register address) 0BB8(wite data) DF 48(CRC 16)
Response message: 01 06 00 01 0B B8 DF 48
  When input ALM set value(SV) is 300.0,300.0 is processed as 3000,3000=0BB8H

4.Example of a CRC calculation in the ‘c++’ language

void CRC16_S(byte[] data, int len)
{
byte CRC16Lo;
byte CRC16Hi; //CRC
byte CL; byte CH; //多项式码&HA001
byte SaveHi; byte SaveLo;
int Flag;
CRC16Lo = 0xFF;
CRC16Hi = 0xFF;
CL = 0x01;
CH = 0xA0;
for (int i = 0; i < len; i++)
{
CRC16Lo = (byte)(CRC16Lo ^ data[i]); /
for (Flag = 0; Flag <= 7; Flag++)
{
SaveHi = CRC16Hi;
SaveLo = CRC16Lo;
CRC16Hi = (byte)(CRC16Hi >> 1); //
CRC16Lo = (byte)(CRC16Lo >> 1); //
if ((SaveHi & 0x01) == 0x01) //1
{
CRC16Lo = (byte)(CRC16Lo | 0x80); //1
} //否则自动补0
if ((SaveLo & 0x01) == 0x01) //,
{
CRC16Hi = (byte)(CRC16Hi ^ CH);
CRC16Lo = (byte)(CRC16Lo ^ CL);
}
}
}
data[len++] = CRC16Lo; //CRC low
data[len] = CRC16Hi; //CRC hight
}

5.Connection to the RS-485 port for the PLC

Trade Manager