Vous êtes sur la page 1sur 4

Modbus Protocol

Page 1 of 4

Modbus Protocol
Kingfisher RTUs can be configured to behave as a Modbus master or slave. The following examples outline both configurations.

Setting up an RTU to be a Modbus Slave

Add the Modbus RTU protocol to the RTU (RTU Configuration - Protocols). Alternatively Modbus TCP can be used an Ethernet port. Add serial port 2 to the RTU configuration (RTU Configuration - Ports) Edit serial port 2 (RTU Configuration - Ports). From the Settings tab of port 2, set Bits per second to 9600 and enable the Modbus RTU protocol. Create local Modbus variables to be polled by the Modbus Master device (Dictionary - New Variables). Example: MODH71 - Modbus Holding register 71 (40,071). Please see the appendix RTU Data - Protocols, Modbus Data for Modbus variable formats and addressing details. Add an ISaGRAFTM logic program to copy data into the Modbus variables as required (RTU Configuration - Programs). Note: an Initial Value can be configured and an IO channel can be mapped to each Modbus variable. Download the Configuration and Logic (even if not using a logic program) to the RTU.

mk:@MSITStore:C:\PROGRA~1\KINGFI~1\TOOLBO~1\help.chm::/_105.htm

16/02/2012

Modbus Protocol

Page 2 of 4

Setting up an RTU to be a Modbus Master

Add the Modbus RTU protocol to the RTU (RTU Configuration - Protocols). Alternatively Modbus TCP can be used on an Ethernet port. Add serial port 2 to the RTU configuration (RTU Configuration - Ports). Edit serial port 2 (RTU Configuration - Ports). From the Settings tab of port 2, set Bits per second to 9600 and enable the Modbus RTU protocol. Create Modbus Variables to store the data polled from the Modbus Slave device (Dictionary - New Variables). Example: MOD7H1001 to MOD7H1005 (Modbus device 7, Holding Registers 1001 to 1005). Note: Local Registers (#Rx) polled from a PC-1, LP-x or CP11/21 RTU start at 1001. Therefore to poll #R10, Modbus holding register 1010 would be polled. Create local Modbus variables that correspond to the registers to be written to the Modbus Slave device. Example: MODH1014 to MODH1016 (Modbus Holding registers 1014 to 1016). Please see the appendix RTU Data - Protocols, Modbus Data for Modbus variable formats and addressing details. To read or write floating point values using the Modbus protocol, please see the FPACK and FUNPACK function blocks. Configure a Modbus function block in an ISaGRAFTM logic program, using the appropriate variables or constants for the inputs and output. An example is shown below. Download the Configuration and Logic to the RTU. The logic below polls Local Registers R1 and R2 (Modbus holding registers 1001 and 1002 respectively) from CP-11 RTU7 using the Modbus protocol every 10 seconds. The data is stored in MOD7H1001 and MOD7H1002. ErrorStatus, MsgWaiting and PollRTU are BOOL variables. ModbusStatus is a DINT variable.

Note 1: by changing the DST setting above to 1, Local Registers R1 and R2 from RTU7 could be stored in MOD7H1 and MOD7H2 instead of MOD7H1001 and MOD7H1002.

mk:@MSITStore:C:\PROGRA~1\KINGFI~1\TOOLBO~1\help.chm::/_105.htm

16/02/2012

Modbus Protocol

Page 3 of 4

Note 2: When writing data to a PC-1, LP-x or CP-11/21 RTU using the Modbus protocol, data is stored in Local Registers of the destination PC-1, LP-x or CP-11/21 RTU. The logic below writes the value from the local MODH1 variable to #R10 [Modbus address 41010] in CP-11 RTU7.

mk:@MSITStore:C:\PROGRA~1\KINGFI~1\TOOLBO~1\help.chm::/_105.htm

16/02/2012

Modbus Protocol

Page 4 of 4

Related Topics ISaGRAFTM - Logic Examples

mk:@MSITStore:C:\PROGRA~1\KINGFI~1\TOOLBO~1\help.chm::/_105.htm

16/02/2012

Vous aimerez peut-être aussi