Modbus configuration example for an Allen Bradley Micrologix 1400

Share Button

The latest PLC Allen Bradley Micrologix 1400 is provided with Modbus TCP and RTU. This is a powerful feature and with this post i explain how to enable and how to use it.

To configure the Modbus communication you need to know at least the basic information about Modbus protocol.

Quick overview of Modbus protocol

Modbus protocol can be used with serial cables (Modbus RTU: RS232 or RS485) or with ethernet cable(Modbus TCP).
Modbus TCP architecture is client – server (like for websites, you with the browser are the client that ask information to the server, and the server reply). Modbus TCP devices can be both client-server and the protocol is multi-master, so every device can start the communication.
Modbus RTU architecture is master – slave (master is the client, slave is the server). The only device that can start a communication is the master and there can be only one master (usually a supervisor) and as many slave as you want. Every slave has a “Node address”, so the master can send packet to a single slave. Master does not have the Node address.

The registers

You have 4 types of registers:

  • 2 are read-only (for bits and integers)
  • 2 are readable and writable (for bits and integers)

Boolean block es. B3:
Read Only registers are called Contacts.
Read/Write registers are called Coils.

Numeric block es. N7:
Read Only registers are called Input Registers.
Read/Write registers are called Holding Registers.

Enabling Modbus TCP:

Important note: once you flag Modbus TCP and save the configuration, you should powerup the PLC again.

Enabling Modbus RTU Slave

To enable Modbus RTU you have to configure channel 2 as Modbus RTU Slave.

Block configuration:

With this configuration i have:
B9: read-only
B10: r/w
N7: read-only
N15: r/w

Expanded flag: this flag permit to use 4 more N registers contigous to N15 in order to expand the holding registers area.
To enable expanded registers you need to declare N15 – N16 – N17 – N18 – N19 and to set all the registers words to 256.

Sample code

You can download a sample application from here.
The program has been tested with the Modbus TCP tester that you can find at http://www.codeproject.com/Articles/16260/Modbus-TCP-class .

Share Button

, , ,

22 Responses to Modbus configuration example for an Allen Bradley Micrologix 1400

  1. gray September 18, 2012 at 00:01 #

    Hi Mesta
    Thanks for the notes much appreciated.
    What version of RSLogix500 are you running? I am running 8.10.00 and noticed that the Modbus selection is not available. I havent installed a modbus software driver into the PLC, not sure if I have to.
    Regards
    Gray

    • mesta September 18, 2012 at 21:26 #

      I was running RsLogix 500 version 8.40.00.
      Please note that Modbus protocol is available only on Micrologix 1400 Ser. B.
      Micrologix 1400 Ser. A doesn’t provide Modbus communication.

    • shridhar November 20, 2013 at 07:05 #

      8.3 r later

  2. ducsi September 9, 2013 at 12:35 #

    Hello Mesta,
    Do you know how many client connections a Micrologix 1400 Ser. B. can handle?
    I try to connect to a PLC from a 2nd PC and it does not work.

    • mesta September 9, 2013 at 13:56 #

      It depends if it’s Modbus TCP or RTU.
      For Modbus TCP i connected up to 3 computers time ago, but i never tried with more.
      For Modbus RTU it depends if the Micrologis is set as master or slave.

  3. sarang September 17, 2013 at 08:24 #

    Hi mesta,

    I have Micrologix 1400 Ser B PLC.I have to establish a communication with Modbus TCP & RTU.How to use RSLinx Classic to configure driver for the same?

    • mesta September 17, 2013 at 16:01 #

      RsLinx can’t communicate in Modbus, it uses the proprietary protocols of RA.
      The ethernet port of Micrologix can communicate with 2 or 3 protocols simultaneously, and the simil-Ethernet/IP is the default, and you can choose what other protocol you want to communicate with, in your case Modbus.
      So with RsLinx you set Ethernet Devices (not Ethernet/IP, it will not work) and you can communicate with RsLogix, while with your applications and other plcs you communicate in Modbus.

      • sarang October 16, 2013 at 10:07 #

        Hi Mesta,
        What about Modbus RTU???What I am supposed to select in Rs-Linx while configuring ML1400 Ser B through Modbus-RTU?I have done channel configuration through RS-Logix 500.But it is unable to establish a communication link.

        Kindly revert back.

        • mesta October 16, 2013 at 12:25 #

          I don’t remember if the serial port of Micrologix can talk 2 different protocols. If it does, then you have to select DF1 in RsLinx. If it can communicate only Modbus RTU, you have to use the other serial port or connect through the ethernet port.

  4. krishna September 19, 2013 at 06:00 #

    Hi Mesta,

    Iam an newbie in .net,basically from PLC,SCADA domain.
    Big fan of ADVHMI, Now can some one share me a project where the real time data from PLC can be logged to sql server.
    I want to make a screen for data and another one for reports.

    Does someone have done this in advanced hmi.

    Thanks
    Krishnamoorthy

  5. Hector Quiroz October 22, 2013 at 17:37 #

    Hello Mesta:

    I’m working with web server embed on Micrologix 1400 PLC and RSLogix 8.40.

    I monitored directory enabled and N7: 0, (eg)

    Using codes <ABDRT-xxx) but only for reading, my question is:

    Is there any code with which I can now write to that block (N7: 0)?

    Thank you.

    • mesta October 22, 2013 at 19:11 #

      I have no experience of working with embedded webserver of Micrologix 1400. In the projects based on ML-1400 was using Ethernet/IP, OPC client or Modbus TCP protocols; with all of them i was using C# or ANSI-C compilers.

  6. shridhar November 20, 2013 at 07:11 #

    HI mesta
    do you have a sample rslogix500 plc program for modbus TCP/IP communication pls send me on shridharhanamannavar@gmail.com

    • mesta November 20, 2013 at 10:56 #

      Actually i don’t have a working sample, but you can test that if your program works by using the Modbus client that you can find on http://www.plcsimulator.org/

    • Rohan August 18, 2014 at 09:09 #

      Have you got solution for your above said question? i am working on the same…if you have any details please share with me also….

      Thankx…

      • mesta August 26, 2014 at 10:56 #

        Actually I don’t have the hardware needed to make tests, so i can’t make a program and assure you 100% it works. At the time that i wrote the article, i was working on a project where the ML1400 was connected via Modbus TCP with other PLCs and it was working.

    • Rohan August 18, 2014 at 09:10 #

      My mail address is rohan_984@yahoo.com

  7. padmaraj April 25, 2014 at 02:23 #

    I make. All the configuration as you said but there is connection timeout by a network this message is coming out

  8. padmaraj April 25, 2014 at 02:26 #

    Is this possible the Chanel 0 make mod bus RTU and Chanel 1 make mod bus TCP in same plc

  9. Anonymous April 30, 2014 at 16:52 #

    Mesta, same question as pdmaraj: is it possible to use both Channel 0 (Modbus RTU) and Channel 1 (Modbus TCP) at the same time? My goal is to read/write data on both channels as I do have a RS485 network and the PLC communicates with the scada using modbus TCP… THANKS!

    • mesta May 2, 2014 at 13:22 #

      According to RsLogix, it seems that you can use Modbus RTU on channel 0. At least in my version you can set Modbus on the protocol instead of DF1.

  10. Phill McKie May 20, 2014 at 11:28 #

    Hi, do you have any examples showing the use of Modbus RTU Master? I have an A series 1400 and I’m trying to configure a RTU master

Leave a Reply