FX3G Modbus

May 2021

How to setup MODBUS Serial and/or TCP communications with the Mitsubishi FX3G PLC, an overview.

For more information on MODBUS, and why it's the popular out of brand protocol between branded devices, visit Modbus.org

We'll look at setting up Serial or Ethernet TCP communications in the PLC, then look at communication to them using the free EasyModbus.NET driver.

The FX3G has a couple of options, we can add a Serial RS-232 or RS-485 ADP Card to the left hand bus, or an ENET Card to the right hand bus, or even both.

Note! The FX3G-E PLC and FX3U-ADP module do not support MODBUS - you'll need an ENET or ENET-P502 module.

You'll also need a relevant code library from Mitsubishi... download these from the Factory Automation portal in your country, in the UK that would be; https://gb.mitsubishielectric.com/fa

Serial Setup

Firstly, we'll look at the Serial RTU Slave driver using RS-232.

Unzip the downloaded folder, then install the GXWorks2 "GWZ" library and Helpfile contained within.

Once installed, open the program...

The first observation is the available range of devices - 3839 Coils, and 3999 Data registers. How the Data registers are formatted, Word or Float for example doesn't matter, the app that will collect this data over MODBUS will format it accordingly later on.

Importantly, the code deals with the Serial Communications - we DO NOT set the Serial communications in the PLC Parameters setup! So leave blank as shown...

Now attempt to compile the program using Menu > Compile > Build (F4).

You may get this error...

Error Fix

If required, not enough stores are available for automatic assignment of the compiler.

Go to Menu > Tool > Device/Label Automatic Assignment Setting...

Just increase the Word Range (*) D upper value to say 1140 (which seemed to be sufficient) and try again.

Assuming you're clear now, the program should compile correctly.

Go online and download the program.

Be sure to cycle the power to the PLC for all changes to take effect.

Use a Serial adapter/Null Modem arrangement to hook up the RS-232 DB9 on the Serial Card of the PLC in preparation for communications over MODBUS.

TCP Server Setup

Next, we'll look at the TCP Server setup using Ethernet as the medium.

To be clear here, in Mitsubishi world, a slave TCP device is a Server. So this will be a device that waits for requests from a Master Station.

Unzip the downloaded folder, then install the GXWorks2 "GWZ" library and Helpfile contained within.

Once installed, open the program...

Again, the first observation is the available range of devices - 3839 Coils, and 3999 Data registers. Only now we also have access to R stores, these are Extension Registers in the FX3G. However, these are mutually exclusive device ranges - you can either access the D stores OR the R stores - we'll see later how that works.

Modbus Port 502

This is where things get a little funky, traditionally the port used over Ethernet for MODBUS is 502.

If you're using the Mitsubishi FX3U-ENET adapter it states that all ports under 1024 are reserved for proprietary usage, and so setting 502 is not allowed. So, Mitsubishi resolved this with the introduction of FX3U-ENET-P502 which makes that port available to use...

(Note! If you download a configuration to an ENET (non P502 version) with port 502 specified it will seem to be Ok - until you cycle the power, then it will go into Error.)

Not to worry, we can still use the regular ENET module, just not port 502 - so we change it to something else, for example 1502, and as long as our Master Station can cope with an address change we're golden...

As an aside, when your Modbus Master requests numerical data, you may chose whether it's getting data from D or R stores.

To change the source set the "RegisterTypeDorR" to TRUE for D stores or FALSE for R Stores...

Finally, compile and download the program into your FX3G PLC.

Next, as we're not using a FX3G-E, but an ENET module, we'll need to setup the ENET module using FX-Configurator-EN...

Our important settings are Module 0 - assuming you only have one ENET module attached on the right hand bus of the PLC.

Then Operational Settings, to include the IP address (being sure to set an address that works with your particular network) of the ENET module...

All other settings are default, apart from Ethernet Open Settings.

Here we can set our port as 1502... (Note! 8. MELSOFT Connection just gives us a means to program the PLC over Ethernet also.)

Once configured, download this into your target FX3G PLC ENET module using USB...

To finish, cycle the power to the whole PLC/ENET setup to make sure all changes take effect.

Communication Testing

You may already have a software tool that can be used test the communications setup above, so try it out!

For the following example we'll "home brew" using the free Microsoft Visual Studio, and the free EasyModbus.Net driver.

Example Visual Basic.Net code with the EasyModbus driver in Ethernet mode...

Example output...

Summary

The Mitsubishi FX3G series offers various MODBUS interface solutions.

However, if you're using the FX3G-E or FX3U-ENET-ADP then MC Protocol is your only actual option, however Desktop.DASH can connect with MC Protocol.

So, if your project can stretch to an ENET module, then MODBUS becomes an additional option also.

That's all for now!