0% found this document useful (0 votes)
240 views31 pages

AC500 V3 Modbus TCP User Manual

Uploaded by

fsm.intersur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
240 views31 pages

AC500 V3 Modbus TCP User Manual

Uploaded by

fsm.intersur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 31

SCALABLE PLC AC500

AC500 V3
Modbus TCP communication
3ADR010226, 3,en_US

Modbus TCP – International standard bus


AC500 V3 and Modbus TCP
Configuration and parameterization
Modbus library

December 12, 20 Slide 2 AC500 V3


24

Modbus TCP – International standard bus


AC500 V3 and Modbus TCP
Configuration and parameterization
Modbus library

December 12, 20 Slide 3 AC500 V3


24

Modbus TCP – International standard bus

Basics
- Open industrial Ethernet network specified by the Modbus-IDA user
Modbus application organization in co-operation with the Internet Engineering Task Force (IETF)
layer as an RFC Internet standard
- Modbus TCP protocol is implemented on top of Ethernet-TCP/IP layers
Modbus on TCP

TCP

IP

Ethernet II/802.3.
physical layer

December 12, 20 Slide 4 AC500 V3


24

Data transmission
Principle client - server

A client is always initiating the data


exchange
Preconditions:
– IP addresses are set
client server server server/client
– Client and server functionality are
device 1 device 2 device 3 device 4
configured
Firmware Firmware Firmware Firmware
Example for 4 devices and one telegram:
1. Client’s ‘device 1’ request frame:
Frame Filter Frame Filter Frame Filter Frame Filter
• ‘Data read’ from server ‘device 3’ or
• ‘Data write’ to server ‘device 3’
Ethernet / Modbus TCP
2. Server’s ‘device 3’ response: A frame
with:
• Requested data or
• Positive response of receiving data or
• Error message

December 12, 20 Slide 5 AC500 V3


24

Modbus TCP – International standard bus


AC500 V3 and Modbus TCP
Configuration and parameterization
Modbus library

December 12, 20 Slide 6 AC500 V3


24

Modbus TCP Communication
AC500 V3 as server and/or client

Data exchange between AC500 CPUs or AC500 and other devices


– Via one ETH port an AC500 CPU can act as:
• Client (master)
• Server (slave)
• Both: Client and server

Data exchange between AC500 CPUs and CP600 HMI


– AC500 is server. It exchanges data on client’s request.
– CP600 is the client. It initiates the communication.

December 12, 20 Slide 7 AC500 V3


24

Modbus connection capability

Protocol PM5630-2ETH PM5650-2ETH PM5670-2ETH PM5675-2ETH As of CPU


FW
version
Modbus TCP server 30 100 100 100 3.0.3
40 40 40 40 3.1.0
15 25 50 50 3.1.3
Modbus TCP client with POU n/a 100 n/a n/a 3.0.1
ETHx_MOD_MAST 40 40 40 40 3.1.0
30 50 120 120 3.1.3

Modbus TCP client with POU 30 100 100 100 3.1.0


ETHx_MOD_MAST or ModTcpMast (PLCopen
30 50 120 120 3.1.3
style)

December 12, 20 Slide 8 AC500 V3


24

Sockets and ports

Protocol Port Sockets

1 socket listen + 1 socket per server connection,


Modbus TCP server 502 or configurable
number of server connections is configurable in AB

Modbus TCP client with POU


Random 1 socket per connection with POU ETHx_MOD_MAST
ETHx_MOD_MAST

Modbus TCP client with POU


1 socket per connection with POU ETHx_MOD_MAST
ETHx_MOD_MAST or ModTcpMast Random
or ModTcpMast
(PLCopen style)

December 12, 20 Slide 9 AC500 V3


24

Function codes supported by AC500

Function code
Max. length Description
DEC HEX

01 or 02 01 or 02 2000 bits Read n bits

03 or 04 03 or 04 125 words / 62 double words Read n words

05 05 1 bit Write one bit (encoded in one word)

06 06 1 word Write one word

15 0F 2000 bits Write n bits (encoded in one byte)

16 10 123 words / 61 double words Write n words

22 16 Write: 1 word Mask write


Read: 125 words / 62 double words
23 17 Read/write multiple words in one telegram
Write: 123 words / 61 double words

December 12, 20 Slide 10 AC500 V3


24

Addressable %M area: Access bit-, byte-, word-, and double-word
wise
Byte order: Little endian

Example 1: Example 2:

%MX0.0 := TRUE %MX3.0 := TRUE


%MB0 := 16#01 := 1 %MB3 := 16#01 := 1
%MW.0 := 16#0001 := 1 (Bit 0) %MW1 := 16#0100 := 256 (Bit 8)
%MD0 := 16#00000001 := 1 (Bit 0) %MD0 := 16#01000000 := 16777216

Bits 31 … 24 23 … 16 15 … 8 7…0
BOOL %MX3.7- %MX3.0 %MX2.7- %MX2.0 %MX1.7- %MX1.0 %MX0.7- %MX0.0
Byte %MB3 %MB2 %MB1 %MB0
Word %MW1 %MW0
Double word %MD0

December 12, 20 Slide 11 AC500 V3


24

Modbus address table: Word access
A WORD in the %M area is assigned to each Modbus address 0000hex .. FFFFhex

December 12, 20 Slide 12 AC500 V3


24

Modbus address table: Bit access (1)
Bit addresses 0000hex .. FFFFhex are contained in the word range %MW0 .. %MW4095

December 12, 20 Slide 13 AC500 V3


24

Modbus address table: Bit access (2)
Bit addresses 0000hex .. FFFFhex are contained in the word range %MW0 .. %MW4095

December 12, 20 Slide 14 AC500 V3


24

Modbus address calculation

%M bit variable address out of a hexadecimal Hexadecimal address out of a %M bit variable
address address
Calculation example: Calculation example:

Modbus bit address hexadecimal = 16#2002 Bit variable = %MX6666.2


Modbus bit address decimal = 8194
Modbus bit address decimal = 6666 * 8 + 2 =
BYTE = 8194 / 8 = 1024 53330
BIT = 8194 mod 8 = 2 Modbus bit address hexadecimal =
16#D052
Bit variable: %MX1024.2
Byte variable: %MB1024
Word variable: %MW512
Double-word variable %MD256

December 12, 20 Slide 15 AC500 V3


24

Modbus Retain Persistent variables

– Pragma attribute 'no_init' is used for a %M variable to define its behavior as RETAIN PERSISTENT
– Syntax:
{attribute 'no_init'}
– Insertion position: In the declaration part, above the declaration line of a particular variable

December 12, 20 Slide 16 AC500 V3


24

Modbus TCP – International standard bus


AC500 V3 and Modbus TCP
Configuration and parameterization
Modbus library

December 12, 20 Slide 17 AC500 V3


24

Configure Modbus TCP server

Add object to ‘ETHx’ Select protocol Object is visible in the tree

December 12, 20 Slide 18 AC500 V3


24

Modbus TCP server: Parameter settings

– Define byte order for Modbus data as ‘Big Endian’ (byte swapping) or ‘Little endian’ depending of required order by a
counterpart
– The default port number for Modbus TCP protocol is 502. The port number can also be configured.
– You can define the behavior on start-up and in state inactive
– With ‘Disable write’ and ’Disable read’ you can protect the server data buffers from access by client

December 12, 20 Slide 19 AC500 V3


24

Online status indication of TCP server in the device tree

Status ‘Active’ Status ‘Inactive’

December 12, 20 Slide 20 AC500 V3


24

Configure Modbus TCP client

Add object to ‘Protocols’ Select protocol Object is visible in the tree

December 12, 20 Slide 21 AC500 V3


24

Modbus TCP – International standard bus


AC500 V3 and Modbus TCP
Configuration and parameterization
Modbus library

December 12, 20 Slide 22 AC500 V3


24

AC500 Modbus TCP library

– AC500 Modbus TCP library is available with Automation


Builder
– No license is required

– The library contains two types of function blocks:


• Compatible V23 – function blocks which are used by
conversion of projects implemented for CPUs of type V2
into version for CPUs of type V3
• Function blocks to be used by implementing of a project
for CPU of type V3. The function blocks are used for:
o Configuration of Modbus parameters (client
configuration)
o Communication purposes
o Diagnostics
o Server control

December 12, 20 Slide 23 AC500 V3


24

Client FB: ModTcpConfig
Configuring Modbus TCP client parameters

Execute: A rising edge starts the operation


RespTimeout: Server response timeout in milliseconds.
Maximum time waiting for a response after
having sent a request
KeepAlive: Open Modbus Time in milliseconds. A
connection to a server stays open after sending
a request until the time is expired. If there is
another request within this time, the timer is
restarted
ByteOrder: Little or big endian. Modbus standard is big
endian
Port: Modbus server TCP port
ErrorID: Error code describing error condition:
NO_ERROR: Execution successfully completed
ERR_ENDIANESS_NOT_SUPPORTED: Byte order
not supported
ERR_UNKNOWN: Undefined error

December 12, 20 Slide 24 AC500 V3


24

Evaluation of status information

General consideration for ‘ModTcpConfig’ and following Modbus function blocks

Done: Operation is completed without error, while outputs ‘Busy’ and ‘Error’ are FALSE.
This output is TRUE for at least one cycle or until input ‘Execute’ is set to FALSE
Busy: Operation is running, while outputs ‘Done’ and ‘Error’ are FALSE
Error: Operation is stopped with error, while outputs ‘Done’ and ‘Busy’ are FALSE.
This output is TRUE for at least one cycle or until input ‘Execute’ is set to FALSE
The output ‘ErrorID’ gives more details about the error.

ErrorID: Error code describing error condition. Please refer to library documentation

December 12, 20 Slide 25 AC500 V3


24

Client FB: ModTcpMast
Configuring Modbus TCP client for communication

Execute: A rising edge starts the operation


Eth: Index number of the assigned interface
IPAdr: IP Address of the remote Modbus TCP server
UnitID: Unit Identifier for the Modbus TCP frame
Fct: Function Code as specified in Modbus
Protocol Specification
Addr: Operand/Register address in remote
Modbus TCP server
Nb: Amount of data units to be sent or
received
Data: Address of local buffer for data to be
sent or received
ErrorID: Error code describing error condition. Please refer
to the online help or library documentation

December 12, 20 Slide 26 AC500 V3


24

Client FB: ModTcpMast2
Configuring Modbus TCP client for communication – extended FB in comparison to ModTcpMast

Addr: Operand/register address in remote Modbus


TCP server
Nb: Amount of data units to be sent or received
Data: Address of local buffer for data to be sent or
received
RespTimeout: Slave response timeout in ms
KeepAlive: Open Modbus Time in ms.
ByteOrder: Little or big endian; Modbus Standard is big
endian
Execute: A rising edge starts the operation
Port: TCP Port
Eth: Index number of the assigned interface
ResetOnClose: Reset connection when closing it (TRUE) or
IPAdr: IP address of the remote Modbus TCP server close (FALSE) like ModTcpMast
UnitID: Unit Identifier for the Modbus TCP frame ErrorID: Error code describing error condition.
Fct: Function code as specified in Modbus Protocol
Specification

December 12, 20 Slide 27 AC500 V3


24

Client FB: ModTcpInfo

ERR_INTERNAL_ILLEGAL_ARGUMENT: Stack reports


illegal argument (internal error)
ERR_UNKNOWN: Undefined error

NumSrv: Maximum number of supported server connections


(PLC as Modbus TCP server)

Rdy: OpenModbus on TCP/IP processing ready

Stat: Status of OpenModbus on TCP/IP processing. Set to


0 in any case, output left for compatibility reasons
Execute: A rising edge starts the operation only
Eth: Index number of the assigned interface. Input is NumErrs: Number of errors occurred. Does not cover TCP/IP
ignored, existing for compatibility reasons only issues like ‘failed to connect’, Modbus errors on
established connections only
ErrorID: Code of error occurred during execution
LastErr: Code of last error occurred. Set to 0 in any case,
NO_ERROR: Execution successfully completed
output left for compatibility reasons only
ERR_NOT_CONFIGURED: Modbus TCP not
configured

December 12, 20 Slide 28 AC500 V3


24

Server FB: ModTcpServOnOff (1)
Setting Modbus TCP server to active/passive mode

ErrorID: Error code describing error condition:


NO_ERROR: Execution successfully completed
ERR_INVALID_INTERFACE: Invalid Ethernet interface or
no server configured on Ethernet interface
ERR_ALREADY_IN_STATE: Server already in requested
state
ERR_SIMULTANEOUS_ACCESS: Server already
accessed by other FB instance, try again later on
ERR_FAILED_SET_STATE: Failed to set server to
requested state
ERR_INTERNAL_UNEXPECTED_STATE: Unexpected
state. Fatal internal error
Execute: A rising edge starts the operation
ERR_UNKNOWN: Undefined error
Eth: Index number of the assigned interface
On: Switch on (TRUE) or off (FALSE) server

December 12, 20 Slide 29 AC500 V3


24

Server FB: ModTcpServOnOff (2)
Setting Modbus TCP server to active/passive mode

Set the parameter ‘Start behavior’ to ‘Inactive’

ErrorID: Error code describing error condition:


NO_ERROR: Execution successfully completed
ERR_INVALID_INTERFACE: Invalid Ethernet interface or
no server configured on Ethernet interface
Define server behavior in state ‘Inactive’
ERR_ALREADY_IN_STATE: Server already in requested
state
ERR_SIMULTANEOUS_ACCESS: Server already
accessed by other FB instance, try again later on
ERR_FAILED_SET_STATE: Failed to set server to
requested state
ERR_INTERNAL_UNEXPECTED_STATE: Unexpected
state. Fatal internal error
ERR_UNKNOWN: Undefined error

December 12, 20 Slide 30 AC500 V3


24
December 12, 20 Slide 31 AC500 V3
24

You might also like