APM403 ModbusTCP EN
APM403 ModbusTCP EN
APM403 ModbusTCP EN
Controller
APM403
Communication in Modbus TCP
10/19/2018 33530066901_0_1
NDF_ 33530066901
CONTENTS
1 Introduction ................................................................................................................................................................................. 2
2 Communication in Modbus TCP ................................................................................................................................................. 2
2.1 Ethernet network ................................................................................................................................................................ 2
2.2 Computer equipped with an Ethernet port .......................................................................................................................... 2
2.3 Connection APM403 side - single electrical generating set ................................................................................................ 2
2.4 Connection APM403 side - power plant generating sets .................................................................................................... 3
2.5 Configuration of the Modbus TCP interfaces ...................................................................................................................... 3
2.6 Connection port .................................................................................................................................................................. 3
2.7 IP address and mask .......................................................................................................................................................... 3
2.7.1 Modbus client interface .................................................................................................................................................. 3
2.7.2 Modbus server interface ................................................................................................................................................ 4
2.7.3 Fixed IP addresses ........................................................................................................................................................ 4
3 Definitions ................................................................................................................................................................................... 4
3.1 Introduction......................................................................................................................................................................... 4
3.2 Physical link and protocol ................................................................................................................................................... 4
4 Modbus protocol ......................................................................................................................................................................... 5
4.1 General presentation .......................................................................................................................................................... 5
4.2 Modbus exchanges ............................................................................................................................................................ 5
4.3 Modbus frames and functions ............................................................................................................................................ 5
4.3.1 Description of a Modbus TCP frame .............................................................................................................................. 5
4.3.2 Modbus functions ........................................................................................................................................................... 6
4.3.2.1 Function 01 (0x01): Read Coils ................................................................................................................................. 6
4.3.2.2 Function 02 (0x02): read binary inputs (Read Discrete Inputs).................................................................................. 7
4.3.2.3 Function 03 (0x03): Read Holding Registers ............................................................................................................. 7
4.3.2.4 Function 04 (0x04): read multiple registers (Read Input Registers) ........................................................................... 7
4.3.2.5 Function 06 (0x06): Write Single Register ................................................................................................................. 8
4.3.2.6 Function 10 (0x016): Write Multiple Registers ........................................................................................................... 8
4.3.2.7 Length of frames ........................................................................................................................................................ 8
4.3.2.8 Error codes and exception codes .............................................................................................................................. 8
5 CM-Ethernet card - Installation, settings and use ....................................................................................................................... 9
5.1 Installation .......................................................................................................................................................................... 9
5.2 Settings .............................................................................................................................................................................. 9
5.2.1 Accessing settings ......................................................................................................................................................... 9
5.2.2 Parameters .................................................................................................................................................................. 10
5.3 Power-on and check ......................................................................................................................................................... 11
6 Information available ................................................................................................................................................................. 11
6.1 Dynamic assignment ........................................................................................................................................................ 11
6.2 Access to the Modbus table ............................................................................................................................................. 12
6.3 Examples ......................................................................................................................................................................... 13
7 Modifying the computer's IP address ........................................................................................................................................ 15
List of figures
figure 1 - star architecture .................................................................................................................................................................... 2
figure 2 - ring architecture .................................................................................................................................................................... 2
figure 3 - crossover Ethernet cable ...................................................................................................................................................... 2
figure 4 - straight Ethernet cable .......................................................................................................................................................... 2
figure 5 - Ethernet TCP/single electrical generating set ....................................................................................................................... 2
figure 6 - power plant electrical generating sets/star pattern................................................................................................................ 3
figure 7 - client/server link .................................................................................................................................................................... 5
figure 8 - Modbus TCP frame............................................................................................................................................................... 5
figure 9 - removing the rear cover ........................................................................................................................................................ 9
figure 10 - fastening pins...................................................................................................................................................................... 9
figure 11 - installed module .................................................................................................................................................................. 9
figure 12 - extract from the Modbus table - ".txt" file .......................................................................................................................... 12
Note: use a minimum category 5e Ethernet cable with a maximum length of 100 m, compatible with the IEC 8802-3, 100 BASE-TX
standard.
For point to point connection (of one device to another device), For network connection, connect a straight Ethernet cable
connect a crossover type Ethernet cable (figure 3) to the RJ45 (figure 4) to the RJ45 port on the computer.
port on the computer.
Ethernet switch:
- make and model: Phoenix Contact,
2891001,
- 5 points for a maximum of four electrical
generating sets,
- 8 points for a maximum of seven
electrical generating sets.
Each byte is a number between 0 and 255 (decimal notation). Given the large number of existing IP addresses throughout the
world, 4-byte coding has reached saturation. There is now a 6-byte code (IP version 6).
The IP address is associated with a subnetwork mask (also 4 bytes) which is used to more easily identify the IP address of a
system. Thus a series of APM403s (power plant of n electrical generating sets) will constitute a subnet, accessible from a larger
network. The value of the bytes making up the mask therefore defines the possible size of the subnet.
The table opposite shows whether two APM403s can communicate APM403 #1 APM403 #2 mask
on a network, according to the subnetwork mask. 192.168.1.1 192.168.1.2 255.255.255.0
192.168.10.1 192.168.1.3 255.255.0.0
192.56.72.90 192.63.75.17 255.0.0.0
In practice, the subnetwork mask will be: 255.255.255.0; which means that all the APM403s in a network will have three identical
bytes. Only the last byte distinguishes between the two APM403s.
In our case, we will use the following addresses on the computer or PLC side:
mask 255.255.255.0 therefore allows IP addresses to be assigned for the APM403s. Bytes no. 4 of each
address must be different ()
Example: the computer (client) may adopt the following IP address: 192.168.1.1
Opposite, the table of addresses used by the APM403 equipment IP address mask
(to be verified depending on the installation). GS #1 192.168.1.254 255.255.255.0
GS #2 192.168.1.253 255.255.255.0
The server (or APM403) number for the first electrical GS #3 192.168.1.252 255.255.255.0
generating set is 254 by default. GS #4 192.168.1.251 255.255.255.0
This value can be modified by accessing its GS #5 192.168.1.250 255.255.255.0
configuration mode (see paragraph 5.2.2). GS #6 192.168.1.249 255.255.255.0
GS #7 192.168.1.248 255.255.255.0
GS is the abbreviation for Generating Set.
GS #8 192.168.1.247 255.255.255.0
table 1 - IP addresses on APM403
The fixed IP address is used where the user wants to customize the installation, by using their own IP addresses.
The APM403 is not compatible with fixed IP addresses. Bytes 1, 2 and 3 cannot be modified for insertion in the existing network.
3 Definitions
3.1 Introduction
This paragraph recaps some concepts in information encoding.
Bit : the smallest elementary unit of information representation, the bit has a value of 0 or 1
byte : equals 8 bits
word : is equal to 2 bytes or 16 bits
long : is equal to 2 words or 4 bytes or 32 bits
baud : unit of measurement of data transmission speed, also expressed in bits/second ()
() In our case, speeds expressed in bauds or bits/s (bps) are equal because the signal is bivalent (2 values: 0 or 1).
A byte is a sequence of 8 bits, and is written as follows: 1001 0001 (where each bit has the value 0 or 1). For each byte, this gives
256 different combinations (in binary format: 1111 1111). A word is a series of 16 bits, i.e. 65536 possible values.
In this document, when values or addresses are expressed in hexadecimal, they are always preceded by the symbol "0x". Values
not preceded by any symbol are expressed in decimal.
Data is exchanged in the form of 0s and 1s. The hardware component defines how a 0 and a 1 are represented.
Hardware
The Ethernet link is the medium.
The organization of the 0s and 1s received indicates what message one machine wants to send to another
Software
machine. This "organization" is known as a protocol. In our case, it is the Modbus TCP protocol.
Originally developed using serial transmission interfaces (RS232, RS485), Modbus has become "Modbus TCP" (or "encapsulated
Modbus") for TCP/IP media ()). It is now considered a standard, due to its ease of implementation.
() IP: Internet Protocol
The Modbus protocol is very widely used in the field of industrial communications, in particular in PLCs. The following are the
essential characteristics of the protocol:
- in a network, there are one or more clients (computer, PLC, etc.) and one or more servers (APM403),
- the client always initiates the communication,
- the reading and writing operations between devices are known as "functions".
The APM403 comprises a single server. It transmits data over the network only if requested by the client.
The Modbus protocol first defines a PDU (Protocol Data Unit) which consists of a function code and all the data to be exchanged.
To form a complete frame, the PDU is complemented by a prefix known as the MBAP header (ModBus Application Protocol
header) which contains the address to be queried and a check to verify correct data transmission (figure 8).
In the explanations provided in the following paragraphs, only the PDU bytes are described in detail.
There are 21 Modbus functions. The following functions are implemented in the APM403:
() These terms are used in the document "Modbus application protocol specification", version V1.1b3, available at
www.modbus.org/.
The frame sent by the client to request the value of one or more "coils" is as follows:
MBAP number of coils to
read request information function coil start address
header read [1]
frame
encoded as … 7 bytes 1 byte 2 bytes 2 bytes
[1] The maximum number of coils that can be read is 2000 (0x7D0).
example: read the status of 10 coils, integer part of [10/8] = 1 and remainder not zero, N = N+1 = 2 bytes
read the status of 32 coils, integer part of [32/8] = 4 and remainder not zero, N = 4 bytes
read the status of 1 coil, integer part of [1/8] = 0 and remainder not zero, N = N+1=1 byte
The frame sent by the client to request the value of one or more binary inputs is as follows:
MBAP number of inputs
read request information function input start address
header to read [1]
frame
encoded as … 7 bytes 1 byte 2 bytes 2 bytes
[1] The maximum number of inputs that can be read is 2000 (0x7D0).
example: read the status of 10 inputs, integer part of [10/8] = 1 and remainder not zero, N = N+1 = 2 bytes
read the status of 32 inputs, integer part of [32/8] = 5 and remainder not zero, N = 4 bytes
read the status of 1 coil, integer part of [1/8] = 0 and remainder not zero, N = N+1 = 1 byte
The frame sent by the client to request the value of one or more registers is as follows:
MBAP start address number N of
read request information function
header of the registers registers to read [1]
frame
encoded as … 7 bytes 1 byte 2 bytes 2 bytes
[1] The maximum number of registers that can be read is 125 (0x7D).
note: 1 register = 1 word = 2 bytes
The frame sent by the client to request the value of one or more registers is as follows:
MBAP start address number N of
read request information function
header of the registers registers to read [1]
frame
encoded as … 1 byte 1 byte 2 bytes 2 bytes
[1] The maximum number of registers that can be read is 125 (0x7D).
note: 1 register = 1 word = 2 bytes
The frame sent by the client to write in a finite number of registers is as follows:
write MBAP register start number N of registers value to write in the
information function
request header address to write to [1] N registers
frame encoded as … 7 bytes 1 byte 2 bytes 2 bytes N x 2 bytes
[1] The maximum number of registers that can be read is 123 (0x7B).
The length of this frame depends on the number N of registers to be written to.
For all Modbus functions implemented in the APM403, the frame lengths are as follows:
frame type function frame length in bytes (not including the header)
01 5
02 5
read request
03 5
04 5
06 5
write request
16 variable (depends on number N)
01 variable (depends on number of bytes sent)
02 variable (depends on number of bytes sent)
03 variable (depends on number of bytes sent)
response
04 variable (depends on number of bytes sent)
06 5
16 5
In case of an error in the frame, the server issues an error code and an exception code.
server error exception
error information
address code code
frame
encoded as … 1 byte 1 byte 1 byte
The table opposite describes the meaning of the exception exception code meaning
codes: 01 Incorrect function code
02 incorrect address
04 processing error
The CM-Ethernet module (reference 31613811902) is supplied non-assembled in a plastic bag, to reduce the effects of electrostatic
discharges.
Please observe the general advice on handling electronic cards (see appendix to APM403 user manual).
5.1 Installation
The CM-Ethernet module will be installed in APM403 slot B.
1. Remove the rear cover by pressing on the four clips as per the sketch opposite (figure 9).
2. Slide the Ethernet module under the pins (figure 10).
3. Press gently on the Ethernet module, at the black connector, until it locks onto the pins with an audible "click" (figure 11).
figure 9 - removing the rear cover figure 10 - fastening pins figure 11 - installed module
4. Refit the rear cover and remove the small plate marked (slot B side) (figure 9).
5. Connect the Ethernet cable to the RJ45 connector (see paragraphs 2.3 and 2.4).
5.2 Settings
To modify one of the parameters of the CM-Ethernet module, the APM403 must be in "Advanced" mode.
1. From the main screen, press ; the "main menu" screen will appear and "Password" is selected.
2. Press as many times as required until "CM-Ethernet" appears.
3. Press to access the menu content.
If it is necessary to enter a password, or to access and modify one or more parameters, refer to paragraph 11 of the APM403
user manual.
SMTP User Name User name in SMTP mode, to be entered in full () -
SMTP User Password Password in SMTP mode, to be entered in full () -
SMTP Server Address Server address in SMTP mode: airgate.comap.cz:9925 -
SMTP Sender Address Address to be entered in full: donotreply@sdmo.com -
IP Address Mode IP address operation mode: Fixed, Automatic Fixed
IP Address Module IP address 192.168.1.20
Subnetwork mask Subnetwork mask 255.255.255.0
Gateway IP Gateway IP address 192.168.1.1
DNS IP Address 1 ? 8.8.8.8
DNS IP Address 2 ? 4.4.4.4
Modbus Server Activating Modbus server (APM403); Enabled, Disabled Disabled
SNMP Agent Activation ?…. ; Enabled, Disabled Disabled
SNMP RD Community public
-
String
SNMP WR Community private
-
String
SNMP Traps IP ?
Address 1
SNMP Traps IP ?
Address 2
AirGate Connection AirGate connection activation: Enabled, Disabled Enabled
Address of server providing access to Airgate, to be entered in full:
AirGate Address -
airgate.comap.cz
ComAp TCP Port TCP communication port number 23
Please correctly enter the parameters from the table above, except for the three parameters shaded gray, which must not be
modified. Parameters marked with the () symbol should not be entered.
4. After correctly entering the parameters, press to go back to the main menu.
5. Press twice to go back to the main screen.
2. Check that slot B has been declared "occupied". From the main screen, press twice to
bring up the "Plug-in Modules" screen. The display must agree with the figure opposite (for
slot B).
Otherwise, slot B must be declared in the "Plug-In Modules" menu (see user manual in
paragraph 11).
green: all OK
red: one or more faults
flashing every
in operation - Ethernet cable not connected
1 second
- the module cannot connect to Airgate
- the module cannot obtain an IP address from DHCP
flashing every green: programming is in progress
programming
0.1 second red: program absent in the Ethernet module
6 Information available
This paragraph contains information available over the Ethernet link. The data is classified by category:
Examples:
Address 0006 = logic input for the oil pressure sensor, terminal 7 of the APM403 (read)
Address 1054 = analog value for the battery voltage (read)
Address 3008 = nominal power of the GS in kW (read and write)
For a specific case, the user must log in with the "Configurator" software (see next paragraph).
3 - Open "Configurator" and click on "Connect to controller". 4 - Select the APM403 connected to the PC and click
on "Open".
5 - In the top bar, select "Tools" and click on "Generate Configuration Image".
The "Save As" window opens.
6 - Select the download location (on the computer) for the Modbus table and click on "Save".
The file format is: "cfgmodbus.txt". Once created, the text file (Modbus table) opens automatically (figure 12).
The Modbus table is created in the language selected in the "Controller" tab. If necessary, change the language in the "Language"
tab in the top bar.
This result shows that the input queried is at status 1 ("Oil Pressure" is active). The other bits of the byte containing the input status
are at 0.