You are on page 1of 41

How to connect an Modbus TCP Master to

Mitsubishi PLC FX-5U with GX Works3

How To – Connect Modbus TCP Masters to Mitsubishi


Equipment: AL1940, Mitsubishi PLC FX-5U, GX Works3

1 Inhalt
2 Set Ethernet and Ethernet/IP settings with LR Device ................................................................................................................................................................... 3
3 Open Mitsubishi Development Tool GX Works3 then Configure network with “Connection Destination” .................................................................................. 5
3.1 First time configuration .......................................................................................................................................................................................................... 5
3.2 Edit Parameter of PLC ............................................................................................................................................................................................................. 9
3.3 Add new External Device ......................................................................................................................................................................................................11
3.4 Write to PLC .......................................................................................................................................................................................................................... 15
4 Configuration in Predefined Protocol Support Function ..............................................................................................................................................................17
4.1 Protocol settings ................................................................................................................................................................................................................... 17
4.2 Packet Setting ....................................................................................................................................................................................................................... 21
4.3 Write the Predefined Protocol Function to PLC built-in Memory ........................................................................................................................................ 26
5 Configuration the Program of GX-Works3 ................................................................................................................................................................................... 28
5.1 MODBUS TCP communication procedure ............................................................................................................................................................................ 28
1. Establishes a connection ...................................................................................................................................................................................................... 28
2. Executes the protocols .........................................................................................................................................................................................................29
3. Closes a connection .............................................................................................................................................................................................................. 30
4. Error handling ....................................................................................................................................................................................................................... 31
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

5. Result: Monitoring the ......................................................................................................................................................................................................... 32


6 MODBUS TCP Communication Tool – Modbus Poll .....................................................................................................................................................................34
6.1 Connect to Modbus TCP Server ............................................................................................................................................................................................ 34
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

2 Set Ethernet settings with LR Device

Connect PC with LR Device to IoT port X23 of the IO-Link Master and press the button “Read from device (1)”
In case that the device is not in the same network segment, it is only possible to change the IP settings. You will only see the MAC address of the
device (2).
Choose an IP-Address for the IoT port (3) and download the configuration (4). After the download, the parameters are read again, and you have
full access to all parameters.
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Modify the fieldbus settings to the desired values and “Write to device (3)”
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

3 Open Mitsubishi Development Tool GX Works3 then Configure network with “Connection Destination”
3.1 First time configuration

Open GX-Works3 “Connection Destination” then choose “Other Connection Method” and press it, Please make sure the connection PC with IoT
port either X21 or X22 and the PC, PLC and AL1940 should be connect to a switch hub is better
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Select Interface  PC side I/F, PLC side I/F and Other Station setting as below picture then press the button “Connection Channel List”
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Please choose your connection channel and press the button “OK“
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Back to below screen then press the button „ Connection Test“, you will see the Sucessfully connection meessage if the setting is correct, After
please press the „OK“ button, to confiure the
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

3.2 Edit Parameter of PLC

Edit System parameters


Open the Navigation Window then click the System Parameter, Please check your correct module of CPU you have, then press the button “OK”
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Edit Ethernet Port

Open the Navigation Window then click the Module Parameter, Please enter the PLC IP address and Subnet Mask what you’re setting Basic
Setting of PLC
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

3.3 Add new External Device

Double Click the Detail Setting of External Device Configure as described below
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

"Navigation window"  [Parameter ]  [FX5UCPU]  [Module Parameter]  [Ethernet Port]  [Basic Settings]  [External Device
Configuration]  double click <Detailed Setting> of "External Device Configuration", “Drag and drop the "Active Connection Module" from
"Module List" to the left side on the window. Execute the settings as described below.
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Please full fill IP address and port number into PLC and Sensor/Device (Modbus TCP server, AL1940) column as your environment
MODBUS TCP Port (Set the IP Address of slave station) : 502, PLC Port is not fixed (Set the port No. of master station).
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Please choose the „predefined Protocol“ in column name which „Communication Method“ as described below. Finally please press the
button “Apply” to confirm all your setting.
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

3.4 Write to PLC

After done your configuration, Please write the configuration to your PLC as described below
Please click the submenu “write to PLC” in Online of Menu bar
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Please check the module or Data name to write to PLC what you have done. If everything is ok press the button “Execute” to download
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

4 Configuration in Predefined Protocol Support Function


4.1 Protocol settings
Send the request message from the master station to the slave station through the predefined protocol support function. Create the protocol
data of MODBUS function requesting to the slave station.
[Tool] [Predefined Protocol Support Function]  Choose the CPU(Ethernet) [File]  [New]  "Protocol setting" screen  [Edit]  [Add
Protocol]
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Use Module Type “CPU (Ethernet)”


How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Please add new Protocol


How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Please use the protocol setting as below, Because AL1940 used function code 03 Holding Registers for process value
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

4.2 Packet Setting

Setting Data Storage Area for each element name to compile the message of AL1940 for request packet
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Please set the Send Data Storage Area of transaction ID


How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Please set the Send Data Storage Area of module ID


How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Please set the Send Data Storage Area of Head holding register number
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Please set the Send Data Storage Area of Read points


How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

4.3 Write the Predefined Protocol Function to PLC built-in Memory

Please click the “Write to Module” function under the Online of Menu bar
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Please click the button “Execute” to download the predefined protocol function
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

5 Configuration the Program of GX-Works3


5.1 MODBUS TCP communication procedure
The flow of the program performing the MODBUS/TCP communication by the FX5 master station is shown below. Now we connect a
O5D150 to port 1 of AL1940.
Note: Please change the instruction name to ZP.OPEN If you use development tool is GX Works2.
1. Establishes a connection
Open a connection of the slave station for communication by SP.SOCOPEN instruction.
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

2. Executes the protocols


Execute the protocol (MODBUS standard function) set to the slave station for communication by SP.ECPRTCL instruction.
Note: Please change the instruction name to GP.ECPRTCL If you use development tool is GX Works2.
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

3. Closes a connection
Close a connection of the slave station for communication by SP.SOCCLOSE instruction.
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Note: Please change the instruction name to ZP.CLOSE If you use development tool is GX Works2.

4. Error handling
Check close status and error handling
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

5. Result: Monitoring the


Check close status and error handling
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Remember: Please noted, because we connect a O5D150 to port 1 and here we only show how to get the process value from AL1940, but the about
the information of distance still need to divide into switch status and distance value as below IODD file described.

The Data storage D2 length is 1 word = 2 bytes = 16 bits


How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

6 MODBUS TCP Communication Tool – Modbus Poll


6.1 Connect to Modbus TCP Server
Please fill AL1940’s IP address in and check your firewall setting in your Laptop.(Important: firewall will block this port : 502)
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Create a New document for testing


How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Click the Read/Write Definition as below picture


How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Please choose the Function code: 03 Read Holding Registers (4x)


How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Please fill the address 1000 (Port 1 used 1000, Port used 2000, etc.)
How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Everything is chosen, Please click the button “OK”

The result will show in address “410002” as following table


How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

You can change the display type to binary as below


How to connect an Modbus TCP Master to
Mitsubishi PLC FX-5U with GX Works3

Happy a nice day!

You might also like