Sie sind auf Seite 1von 13

AC500 PLC and

Modbus RTU Communication

Gundeep Singh Saini


gundeep.saini@in.abb.com
INPA-CT
10 November 2014

AC500 PLC and Modbus RTU Communication

Table of Contents
1.

Introduction .......................................................................................................................................... 2

2.

Device Details ....................................................................................................................................... 2

3.

Procedure to Configure ........................................................................................................................ 3

4.

3.1

Creating a Project ......................................................................................................................... 3

3.2

PLC IP Address .............................................................................................................................. 3

3.3

PLC COM Port ............................................................................................................................... 4

3.4

PLC FBP Port.................................................................................................................................. 5

3.5

800xA Profibus Configuration ...................................................................................................... 6

Procedure to Program .......................................................................................................................... 7


4.1

Creating a Function Block............................................................................................................. 7

4.2

ModBus Communication.............................................................................................................. 9

4.3

Compiling and Downloading ...................................................................................................... 10

4.4

Transmitting Data to DCS ........................................................................................................... 11

4.5

Creating a Task for the Program ................................................................................................ 12

AC500 PLC and Modbus RTU Communication

1. Introduction

PLCs have been in use since very long and have always had the
advantage of being small and inexpensive. They are widely
used in small scale independent operations. The use of PLCs as
an intermediary communication device is also fast growing
because of the cost advantages.
A PLC can communicate in various protocols like Ethernet,
ModBus, Profibus, DeviceNet, CAN, etc.
This document describes the process to configure a PLC to
communicate with Multi-Function Meters (MFM) used for
Energy Monitoring over Modbus RTU and Profibus to
communicate with 800xA DCS.

2. Device Details
The details of the Hardware, Communication Protocols and the Software used during this document is
as follows:
PLC
PLC - Device Protocol
PLC - DCS Protocol
MFM Model
PLC Configuration Software
PLC Programing Software

AC500 PM573-ETH
Modbus RTU
(PLC as Master)
ProfiBus DP
(PLC as Slave)
Schneider Conzerv EM6400
PS501 Control Builder Plus Rev 2.3.0
CodeSys Rev 2.3.9.40

PS501 Control Builder Plus is the complete software suite and automatically installs CodeSys and the
Gateway OPC.
Control Builder Plus is used to configure the PLC and the connected hardware modules whereas CodeSys
is used for configuring the software. It is worthwhile to mention that CodeSys is completely integrated
into Control Builder Plus.

AC500 PLC and Modbus RTU Communication

3. Procedure to Configure
Install PS501 Control Builder Plus from the installation media or by downloading the setup from Solution
Bank.

3.1 Creating a Project


Open Control Builder Plus. Go to File --> New Project --> Select AC500 Project from Templates and give
your project a Name and Location and press OK.
This will open a new window where you can select the PLC model. Once selected, press Add Device.

This will create a project with the AC500 PLC selected and its associated modules.

3.2 PLC IP Address


If the PLC is not previously configured, you will have to configure its IP Address. Connect a LAN Cable
from your PC to the PLC. On your PC, go to the LAN Network Adapter IPv4 Settings and select Obtain an
IP address automatically.
Now come back to Control Builder Plus and double click on IP Settings on the left. This will open the
properties. Select IP-Configuration on the right. This will open a Device Scanner. Press Scan to find
the PLCs IP address.

AC500 PLC and Modbus RTU Communication

Once the PLC is found, click on it and scroll down to enter the new IP Address of the PLC. Click on send
to set the IP address. Make sure the PLC is in STOP mode before sending the new IP address.

3.3 PLC COM Port


The PLC has two COM Ports, both of which can be configured to communicate independently on the
same or different protocol.
For the purpose of this document, we will configure COM Port 1 for ModBus. The hardware connection
details are as follows for COM Port:

COM 1
COM 2

RS-485 POSITVE
Pin 2
Pin 3

RS-458 NEGATIVE
Pin 3
Pin 8

To configure, go to Interfaces --> right click on COM 1 --> Plug Device. Now select COM 1
ModBus and select Plug Device and close.
Double click on the configured COM Port to open properties. Select RTS Control as Telegram and
Operation Mode as Client. This is done to configure the PLC as ModBus Master. Other parameters can
also be changed if required by the Slave Device.

AC500 PLC and Modbus RTU Communication

3.4 PLC FBP Port


The PLC supports FBP which stands for Field Bus Plug. FPB
offers fieldbus neutral device connection and can connect to
any device, protocol or sensor module directly.
For our use, we connect to a ProfiBus DP Network with PLC
acting as a ProfiBus Slave to pass data onto the 800xA
System.
To configure, go to Interfaces --> right click on FBP Online
Access --> Plug Device.
Now select FBP Slave (Profibus) and click on Plug Device and then
Close.
This will configure the FBP Port as Profibus Slave. Now Double click on
configured Port to open properties. The Device Address can be set here.

Now that the PLC is configured as a ProfiBus Slave, the I/O Modules need to be added. Right click on the
FBP Port and select Add Device. In the new window, select 16 Word Input (IEC Output) to add a
module.
This single module can send 16 words of data to the ProfiBus Master (DCS). If more data needs to be
sent, add more modules. In case some data is to be received from DCS, add an appropriate module.
5

AC500 PLC and Modbus RTU Communication

Please note the maximum data a ProfiBus Slave can send/receive is limited to 246 bytes. So the addition
of these modules should also be limited to stay within the threshold.
For the hardware connection, a PDP22 type FBP connects to the PLC. It has an IN port and an OUT port.
If the ProfiBus loop is terminating at the PLC, a terminating resistor, PDR11 must be used at the OUT
port. The PDP22 module requires +24V DC supply to be connected in order to work. Once powered, the
power LED starts glowing on the PDP22. For more details on FBP, refer ABB FBP Documentation.

3.5 800xA Profibus Configuration


Import the GSD of the PLC in Control Builder.
Insert the PDP22-FBP Module under CI854.
Assign the node number and name.
Insert the same number of I/O Modules under
the PDP22-FPB module as done in the PLC. For a
single 16 Word Input (IEC Output) module in
PLC, add a single 16 word input module under the PDP22-FBP module.
Declare the variables on the channels in the module just assigned and use as per requirement.

AC500 PLC and Modbus RTU Communication

4. Procedure to Program
Once the PLC has been configured, it has to be programed.
Save your project in Control Builder Plus. Double click on AC500 to open CodeSys. This uploads all
configuration data to CodeSys and opens the program editor. Make sure any configuration changes in
Control Builder Plus that you do are done only when CodeSys is closed.

CodeSys will open with only a single program: PLC_PRG. This is the main program which is executed
continuously. Any other functions / programs / code blocks must be called in this program for execution.

4.1 Creating a Function Block


The code which needs to be run may be defined in a Function Block (or another program). This function
block can then be called multiple times for execution.
To create a Function Block, right click on POUs --> Add Object --> Select Function Block and the
programing language. Give it a name and click OK. This will create an instance of the Function Block and
open the editor.

The editor is divided into Lines (in FBD). Multiple lines can be added and each line can have multiple
functions. These functions are called as Box. These lines are referred to as Network.

AC500 PLC and Modbus RTU Communication

Right click on the first line --> select Box. This will insert a function (AND block
by default). Other options include Network (after), Network (before), Assign,
Jump, Comment and others.
Network (before/after) will add a new line.
Assign will open a dialog box to assign new variable.
Jump can be used to jump to a different code block.
Once the AND Block is inserted, the function can be changed by manually
entering the name of the desired function in place of AND.

The function block pins will change depending on the selected function. The ???
symbol stays till some variable is assigned to the pin. Click on ??? and enter the
variable name, if it is not declared, a dialog box will open to declare that variable
by selecting the data type and memory address.
In certain cases, the function block itself needs to be declared. Such blocks will have ??? on top of them
to declare a name for the function block. Simply enter a name and it will be declared.
This way multiple functions / function blocks can be added. If the language needs to be changed, right
click on the Function Block on the left and select Convert Object.
To execute these Function Blocks, go to PLC_PRG Program and enter the name of the Object Function
Block. This will call the function block for execution in a continuous loop.

AC500 PLC and Modbus RTU Communication

4.2 ModBus Communication


The inbuilt function block for ModBus RTU is COM_MOD_MAST and that for ModBus TCP is
ETH_MOD_MAST. These can be used to communicate with the Modbus Slaves.

Parameter
EN
COM
SLAVE

Data Type
BOOL
BYTE
BYTE

FCT

BYTE

TIMEOUT

WORD (in ms)

ADDR

WORD

NB
DATA
DONE
ERR
ERNO

WORD
DWORD
BOOL
BOOL
WORD

Description
EN pin is used to enable the communication
COM pin is used to indicate whether its on COM1 or COM2
SLAVE pin is used to indicate the address of the slave
FCT pin is used to indicate the Function Code of the Slave,
generally the Holding Register
TIMEOUT is used to give the maximum timeout before error
ADDR is for the Slave register address from where the data is
to be read
NB is the number of data registers to be read
DATA is the address / location where the data is to be stored
DONE indicates that the Read Cycle is completed
ERR indicates an error in communication
ERNO indicates the error code.

In case of multiple slaves, multiple COM_MOD_MAST blocks must be used. In such a case, the EN of
succeeding block should be connected to the previous blocks DONE bit. This will allow a successive
execution, block after block.
Also important to note here is that the ADDR should be entered as Slave Data Address 1.

AC500 PLC and Modbus RTU Communication

A Conzerv EM6400 MFM Slave can be configured as follows:


MFM on COM 1 and Slave ID 11. The FCT is 03 for Holding Registers. The Data Register at 3001 has a
set of 20 registers with the data as shown (from EM6400 Manual). These registers have to be read in a
single cycle. Therefore, NB will be 20. The DATA pin expects the address of a memory location. This can
be given by using the Function ADR.

The function block to communicate will therefore be as shown below:

This way the data can be read from the slave device.

4.3 Compiling and Downloading


Once the code is ready, compile the code to check for any errors. This can be done by going to Project
menu on the top --> Rebuild All. This will compile all the programs / function blocks and list the errors
in the window below.
Once the code is free of any errors, download the project onto the PLC. But before downloading, the
communication parameters need to be defined.

10

AC500 PLC and Modbus RTU Communication

Go to Online menu on the top --> select Communication Parameters. In the new window, press
Gateway and select TCP/IP and other properties as
default.
Now select New --> TCP/IP and give a name to the
connection. In the address field, enter the IP address of the
PLC which has been set previously.
Once these parameters have been set, connect a LAN cable
from your PC to the PLC. Go to Online menu and select
Login. This will download the project. Login is similar to
the Download and go Online option in AC800M. To go offline, go to Online --> Logout.
Once the download is complete, go to Online menu and select Create Boot Project. This will save the
program to EEPROM. Make sure you are in Login/ Online mode when you Create a Boot Project.
To start the execution of the code, a RUN command has to be given to the PLC. This can be done by
going to Online menu --> Run.
Once all configuration is completed, Logout and save the project in CodeSys and exit CodeSys.

4.4 Transmitting Data to DCS


Once the ModBus Data is received at the PLC, it needs to be sent to DCS via ProfiBus. To do this we need
to declare Global Variables.
Close CodeSys and go back to Control Builder Plus. Expand the FBP Slave Module declared previously and
double click on the 16 Word Input (IEC Output) module. On the right assign new variables on the desired
channels. If the new variable is a WORD then assign it directly in the word channel or else merge two BYTE
type variables and assign them on a single channel as HIGH BYTE / LOW BYTE.

11

AC500 PLC and Modbus RTU Communication

Once you have declared these variables, save the project and open CodeSys again. The variables
assigned in Control Builder Plus become Global Variables and can now be used in the Program to send
values.

4.5 Creating a Task for the Program


The PLC will executes only those Programs / functions which are assigned a Task. To do this, open
CodeSys and navigate to Resources from the bottom menu.
In Resources go to Task Configuration. By
default, the Task Configuration will have
only System Events.
Right click on Task and select Append
Task. Give a name to the task and set the
properties Priority / Interval / Watchdog.
Right click on this new Task and select
Append Program Call. Select the PLC_PRG(); program and save.
Its is advisable to assign task to a single program, preferably PLC_PRG() and call all other function blocks
from PLC_PRG itself.

12

Das könnte Ihnen auch gefallen