欢迎图片

MODBUS

Last modified by Leo Wei on 2024/06/27 16:54

MODBUS

MODBUS RTU Master

Supported Series: MODBUS RTU CONTROLLER

HMI works as MODBUS SLAVE connecting with MASTER

12.PLC Protocol_html_44425b313b0a6b96.png

12.PLC Protocol_html_b56b9da32c3caaa.png

12.PLC Protocol_html_67cd25458b9c72a6.png

HMI Settings

ItemsSettingsNote
ProtocolMODBUS RTU Master 
ConnectionRS485/RS232 
Baud rate2400~187500 
Data bit8 
ParityEven/ Odd/ None 
Stop bit1/2 
Station No.0~255 

Address List

TypeHMI addressMODBUS codeRange
BitHDX3000.0~HDX3499.1500~7999
WordHDW3500~HDW799940~4499

Cable Wiring

  • RS485

12.PLC Protocol_html_68dfb6d383f0edd9.png

12.PLC Protocol_html_cbeb90cb4faaa8bc.png

  • RS232

12.PLC Protocol_html_9030ba679545793b.png

✎Note: COM3 only available in PI8000/PI9000 series.

MODBUS RTU Slave (All function)/(All function OneBaseAddress)

Supported Series: MODBUS RTU CONTROLLER

HMI works as MODBUS MASTER connecting with SLAVE.

The addresses in [All function] start from 0, while the addresses in [All function OneBaseAddress] start from 1 (offset 1).

12.PLC Protocol_html_7236139c887defad.png

12.PLC Protocol_html_de80207f2b495c17.png

12.PLC Protocol_html_4e9e8eff81c7ff8b.png

HMI Settings

ItemsSettingsNote
ProtocolMODBUS RTU Slave (All function)/( All function OneBaseAddress) 
ConnectionRS485/RS232 
Baud rate2400~187500 
Data bit8 
ParityEven/ Odd/ None 
Stop bit1/2 
PLC station No.0~255 

Address List

TypeAddress TypeFunction code & Description
Word304 (read input register: read current binary value in one or more input registers)
06 (write single register: write a binary value to a holding register)
10 (write values to multiple addresses )
403 (read holding register: read current binary value in one or more holding registers)
06 (write single register: write a binary value to a holding register)
10 (write values to multiple addresses )
W603 (read holding register: read current binary value in one or more holding registers)
06 (write single register: write a binary value to a holding register)
10 (write values to multiple addresses )
W1603 (read holding register: read current binary value in one or more holding registers)
10 (write values to multiple addresses )
Bit001 (Read coil state)
05 (Force a single coil to force the on/off state of a logic coil)
0F (Write multiple bits, ie write continuously)
102 (Read the input state)
05 (Force a single coil to force the on/off state of a logic coil)
0F (Write multiple bits)
W501 (Read coil state to obtain the current state of a set of logic coils)
05 (Force a single coil to force the on/off state of a logic coil)
0F (Write multiple bits)
W1501 (Read coil state to obtain the current state of a set of logic coils)
0F (Write multiple bits)

✎Note:

  • Modbus can also support getting bit from the word, which could access the address such as 100.1 and other formats.
  • The function codes sent out are the same as those that read and write words.

Station number for more than one slaves

If there are more than one slaves connected to HMI, please set slave station number during editing address, as below shows.

12.PLC Protocol_html_31f028c6d80be344.png

Cable Wiring

  • RS485

12.PLC Protocol_html_68dfb6d383f0edd9.png

12.PLC Protocol_html_cbeb90cb4faaa8bc.png

  • RS232

12.PLC Protocol_html_9030ba679545793b.png

✎Note: COM3 only available in PI8000/PI9000 series.

Modbus Meter

The following example is using the Linfee meter LNF96EY to demonstrate how to set up the Modbus communication.

1. Wiring the RS485 cable first. Because the pin 58 is A, the pin 59 is B for meter. Here we use the COM1 to connect. So the diagram like follows:

LinfeeDiagram.png

2. Check the specific Modbus parameter in the communication menu from LED display.

So from the following pictures, we can know the Meter Address is 85, Baud rate is 9600, CRC None.

✎Note: Meter address usually corresponding to the Device No. in the PIStudio Communication settings.

MeterModbusAllView.png

3. Create new project and change the Communication settings.

Set the protocol as MODBUS RTU Slave (All Function), set Device No. as 85. And COM port setting as 9600, 1, 8, NONE.

PIStudioSetupMeterModbusPara.png

4. Drag the numeric input into screen, and fill in the Modbus Address we want to read according to manual

The following table is intercept part of the manual for Linfee Modbus manual.

0x03/0x04 command data register address:

AddressDescriptionData FormatData Length(Word)Remark
 HEXDEC    
0x000Reserved   
0x022Reserved   
0x044Reserved   
0x066Uafloat2Phase Voltage data, Unit V
0x088Ubfloat2Phase Voltage data, Unit V
0x0A10Ucfloat2Phase Voltage data, Unit V
0x0C12Uabfloat2Line Voltage data, Unit V
0x0E14Ubcfloat2Line Voltage data, Unit V
0x1016Ucafloat2Line Voltage data, Unit V
0x1218Iafloat2Phase Current data, Unit A
0x1420Ibfloat2Phase Current data, Unit A
0x1622Icfloat2Phase Current data, Unit A

✎Note: We usually use the Address Type 4 for read the Modbus registers(Function Code 03)

For example, here we want to read the Phase Voltage Ua (Modbus offset 0006), the Address No. requires input decimal number, and check whether the actual address has one address offset, so the address set like the following screenshot:

MeterModbusPInumericSet.png

Set the Read-Write type for address, because meter only to measuring the data, so set it as read-only, and floating data format.

MeterModbusNumericInputFormat.png

Then download into HMI, if the HMI COM led is blinking and no timeout message show, which means the communication is setup successfully.

ActualHMIModbusResult.jpg

MODBUS TCP Slave (All function)

Supported series: MODBUS TCP controller

Note: Although the protocol selected for the HMI is MODBUS TCP Slave, the HMI is working as a MODBUS TCP Master connected to TCP SLAVE.

12.PLC Protocol_html_8877cb7f39c2b607.png

12.PLC Protocol_html_e7e1f06f127a9175.png

12.PLC Protocol_html_60bbfe5de79417a6.png

HMI Setting

ItemsSettingsNote
ProtocolMODBUS TCP Slave (All function) 
ConnectionEthernet 
Port No.502 
PLC station No.1 

Address List

TypeRegisterFunction code & Description
Word304 (read input register: read current binary value in one or more input registers)
06 (write single register: write a binary value to a holding register)
10 (write values to multiple addresses )
403 (read holding register: read current binary value in one or more holding registers)
06 (write single register: write a binary value to a holding register)
10 (write values to multiple addresses )
W603 (read holding register: read current binary value in one or more holding registers)
06 (write single register: write a binary value to a holding register)
10 (write values to multiple addresses )
W1603 (read holding register: read current binary value in one or more holding registers)
10 (write values to multiple addresses )
Bit001 (Read coil state)
05 (Force a single coil to force the on/off state of a logic coil)
0F (Write multiple bits, ie write continuously)
102 (Read the input state)
05 (Force a single coil to force the on/off state of a logic coil)
0F (Write multiple bits)
W501 (Read coil state to obtain the current state of a set of logic coils)
05 (Force a single coil to force the on/off state of a logic coil)
0F (Write multiple bits)
W1501 (Read coil state to obtain the current state of a set of logic coils)
0F (Write multiple bits)

Communication Settings

Enable HMI Ethernet in [Project Settings];

12.PLC Protocol_html_43b671f18153910d.png

Set PLC IP in [Device IP] settings;

12.PLC Protocol_html_4bd3cc8348adecf8.png

Cable Wiring

12.PLC Protocol_html_2297240b57346b2a.png