Blog

Posted by Julie Gruenholz

How Do I Set Up Modbus Communication In My Modicon Unity PLC?

October 5, 2017

In my blog post, Why, In 2017, Are We Still Using Modbus? I outlined the common ways PLCs communicate with 3rd party devices using Modbus.

This can fall into one of three categories:

  • Modbus RTU on a 3rd party device, from a PLC serial port
  • Modbus RTU on a 3rd party device, through an Ethernet Gateway, from an Ethernet PLC port
  • Modbus TCP on a 3rd party device, or another PLC, from an Ethernet PLC port

In a Modicon PLC, you can communicate 2 ways:

  • Use communication block(s) inside the PLC codeCan communicate from PLC Ethernet or Serial port
  1. Can transmit all 4 data types (400001, 300001, 000001, 100001)
  2. Has a limit on how many communication tasks can be active at a single time
  3. Is more cumbersome to use than IO Scanner because it is part of the PLC code
  4. Can be changed while PLC is running
  • Use IO Scanner
  1. Can only communicate from PLC Ethernet port
  2. Can only transmit read/write words (400001 through 465535)
  3. Cannot be changed without stopping the PLC
  4. Is recommended to use, when possible, because it becomes part of the PLC overhead and is not reliant on PLC code

My colleague, Jon McClain, has a blog called “3 Easy Steps to Share Data Between Modicon Quantum PLCs Using Schneider Electric Unity Pro XL”. Jon describes how to communicate using Modbus TCP and IO Scanner.

In this blog I will show how to communicate using Modbus RTU from a serial port, or an Ethernet port (through an Ethernet Gateway), using communication block(s) inside the PLC code.

Modbus RTU from a Modicon Unity PLC serial port:

  • Step 1 – Configure the PLC Serial port

Configure the PLC serial hardware port to match the 3rd party device. In this example I am using the RS-232 port on the PLC and going through an RS-232 to half-duplex RS-485 converter to an ABB VFD and a Trane Chiller. This example assumes that both require the same number of data and stop bits, parity, and baud rate. It is possible to skip the converter and go straight RS-485 from the PLC port, but using a converter can eliminate some headaches at startup. I find that RS-232 is simpler for the PLC to handle and the converter can handle the switching of the transmit and receive signals on the half-duplex RS-485 network. As in all serial communication, the number of data and stop bits, the parity, and the baud rate match what the 3rd party device manufacturer requires.Serial PortConfiguration

Step 2 – Enter the code in the PLC program

  • Example 1, Read kW data from VFD 1 for Cooling Tower Fan 1:Step 2
  • Example 2, Read Run Status data from Chiller 2:Step 2.2
  • Example 3, Write Glycol Chilled Water Setpoint to Chiller 2:Step 3

Modbus RTU from a Modicon Unity PLC Ethernet port (through an Ethernet Gateway):

  • Step 1 – Configure the PLC Ethernet port

See steps 1 and 2 of Jon McClain’s blog.

  • Step 2 – Enter the code in the PLC program

The code will be the same as above, except the “ADDM()” command will be different. If you are reading or writing the same register to Chiller 2 as in the above code, but using the PLC Ethernet port to Modbus RTU RS-485 on the other side of an Ethernet Gateway, your read and write commands would be this:

READ_VAR(ADDM('PLC{192.168.10.92}2'),'%MW',5,1,READ_GEST,READ_DATA);

- Or -

WRITE_VAR(ADDM('PLC{192.168.10.92}2'),'%MW',5,1, WRITE_DATA,WRITE_GEST);

Breaking apart the ADDM('PLC{192.168.10.92}2') command you get:

  • The Ethernet network is named “PLC”PLC
  • In this case our Ethernet Gateway is address 192.168.10.92.
  • The Chiller is Modbus address 2, on the RS-485 network, on the other side of the Ethernet Gateway.

About the Author

Julie Gruenholz is a Senior Control Systems Engineer for Hallam-ICS. As an Electrical Engineer, she has been designing, installing, modifying and programming control systems since 1991.

Read   My Hallam Story  

About Hallam-ICS

Hallam-ICS is an engineering and automation company that designs MEP systems for facilities and plants, engineers control and automation solutions, and ensures safety and regulatory compliance through arc flash studies, commissioning, and validation. Our offices are located in Massachusetts, Connecticut, New York, Vermont and North Carolina and our projects take us world-wide.

Contact Us

Topics: Process Control and Plant Automation

Julie Gruenholz

By Julie Gruenholz

Find me on:

October 5, 2017

Next Blog Post Previous Blog Post