AC500 PLC and Modbus RTU Communication

download AC500 PLC and Modbus RTU Communication

of 13

Transcript of AC500 PLC and Modbus RTU Communication

  • 8/10/2019 AC500 PLC and Modbus RTU Communication

    1/13

  • 8/10/2019 AC500 PLC and Modbus RTU Communication

    2/13

    AC500 PLC and Modbus RTU Communication

    1

    Table of Contents

    1. Introduction .......................................................................................................................................... 2

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

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

    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

    4. 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

  • 8/10/2019 AC500 PLC and Modbus RTU Communication

    3/13

    AC500 PLC and Modbus RTU Communication

    2

    1.

    Introduction

    PLCs have been in use since very long and have always had the

    advantage of being small and inexpensive. They are widelyused 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 AC500 PM573-ETH

    PLC - Device Protocol Modbus RTU (PLC as Master)

    PLC - DCS Protocol ProfiBus DP (PLC as Slave)MFM Model Schneider Conzerv EM6400

    PLC Configuration Software PS501 Control Builder Plus Rev 2.3.0

    PLC Programing Software 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.

  • 8/10/2019 AC500 PLC and Modbus RTU Communication

    4/13

    AC500 PLC and Modbus RTU Communication

    3

    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 Settingson 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.

  • 8/10/2019 AC500 PLC and Modbus RTU Communication

    5/13

    AC500 PLC and Modbus RTU Communication

    4

    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:

    RS-485 POSITVE RS-458 NEGATIVE

    COM 1 Pin 2 Pin 3

    COM 2 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.

  • 8/10/2019 AC500 PLC and Modbus RTU Communication

    6/13

    AC500 PLC and Modbus RTU Communication

    5

    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.

  • 8/10/2019 AC500 PLC and Modbus RTU Communication

    7/13

    AC500 PLC and Modbus RTU Communication

    6

    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, thepower 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.

  • 8/10/2019 AC500 PLC and Modbus RTU Communication

    8/13

    AC500 PLC and Modbus RTU Communication

    7

    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 inControl 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.1Creating 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.

  • 8/10/2019 AC500 PLC and Modbus RTU Communication

    9/13

    AC500 PLC and Modbus RTU Communication

    8

    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 ObjectFunction

    Block. This will call the function block for execution in a continuous loop.

  • 8/10/2019 AC500 PLC and Modbus RTU Communication

    10/13

    AC500 PLC and Modbus RTU Communication

    9

    4.2ModBus 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 Data Type Description

    EN BOOL EN pin is used to enable the communication

    COM BYTE COM pin is used to indicate whether its on COM1 or COM2

    SLAVE BYTE SLAVE pin is used to indicate the address of the slave

    FCT BYTEFCT pin is used to indicate the Function Code of the Slave,

    generally the Holding Register

    TIMEOUT WORD (in ms) TIMEOUT is used to give the maximum timeout before error

    ADDR WORDADDR is for the Slave register address from where the data is

    to be read

    NB WORD NB is the number of data registers to be read

    DATA DWORD DATA is the address / location where the data is to be stored

    DONE BOOL DONE indicates that the Read Cycle is completed

    ERR BOOL ERR indicates an error in communication

    ERNO WORD 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 Address1.

  • 8/10/2019 AC500 PLC and Modbus RTU Communication

    11/13

    AC500 PLC and Modbus RTU Communication

    10

    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.3Compiling 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.

  • 8/10/2019 AC500 PLC and Modbus RTU Communication

    12/13

    AC500 PLC and Modbus RTU Communication

    11

    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 thePLC 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 bygoing to Online menu --> Run.

    Once all configuration is completed, Logout and save the project in CodeSys and exit CodeSys.

    4.4Transmitting 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.

  • 8/10/2019 AC500 PLC and Modbus RTU Communication

    13/13

    AC500 PLC and Modbus RTU Communication

    12

    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.5Creating 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

    propertiesPriority / 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.