ADDM
: Convert a String into an Address
The ADDM
function block converts a destination address that is represented as a string to an ADDRESS structure. You can use the ADDRESS structure as an entry in a communication function block.
ADDM
- Specific Parameter Description
Input/Output |
Type |
Comment |
---|---|---|
|
ADDRESS |
This is the ADDRESS structure to be filled by the function block. |
Input |
Type |
Comment |
---|---|---|
|
BOOL |
Executes the function at the rising edge. |
|
STRING |
Address in STRING type to be converted in ADDRESS type (see details below). |
Output |
Type |
Comment |
---|---|---|
|
BOOL |
NOTE: When the operation is aborted with the Abort input, Done is not set to 1 (only
Aborted ).
|
|
BOOL |
|
|
BYTE |
|
Execute
input executes the conversion and returns an immediate update of AddrTable
. However, AddrTable
retains the last value when an error is detected (that is when the Addr
string is not correct).
Function blocks require a rising edge in order to be initiated. The function block needs to first see the Execute
input as FALSE
in order to detect a subsequent rising edge.
WARNING | |
---|---|
For ASCII addressing, only the communication port number is requested:
'<communication port number>'
For example, to send a user-defined message on serial line 2, use the string '2'
.
This table defines the fields in the ADDM output for the ASCII address format:
Field |
Type |
Value |
Example |
---|---|---|---|
|
BYTE |
Reserved |
Not used |
|
BYTE |
Reserved |
Not used |
|
BYTE |
Rack number (always 0) |
0 |
|
BYTE |
Module number (always 0) |
0 |
|
|
2 |
|
|
BYTE |
Not used |
Not used |
|
BYTE |
0 |
0 |
|
BYTE |
Not used |
Not used |
|
ADDR_EXT |
Not used |
Not used |
Address of a Modbus TCP Standard Slave
For the Modbus TCP standard slave address format, the communication port number (3 for the embedded Ethernet port) and the destination IP address are requested:
'<communication port number>{<IP address>}'
UnitId
default value). However, a Modbus TCP device may have different value (for example, a TeSys has Modbus address 1). In this case, add the UnitId
value:
'<communication port number>{<IP address>}<UnitId>'
TCP port 502 is used by default. It is possible to use a non-standard port by adding the requested port number to the IP address:
'<communication port number>{<IP address>:<port>}'
For example, to send a message at Modbus TCP slave IP address 192.168.1.2 using standard TCP port 502, use this string: '3{192.168.1.2}'
The ADDM
function fills the AddrTable
input/output with these values:
Field |
Type |
Value |
Example |
---|---|---|---|
|
BYTE |
Reserved |
Not used |
|
BYTE |
Reserved |
Not used |
|
BYTE |
Rack number |
0 |
|
BYTE |
Module number |
0 |
|
|
3 |
|
|
BYTE |
0 for Modbus |
0 |
|
BYTE |
|
7 |
|
BYTE |
Modbus address (255 by default) |
255 |
|
TCP_ADDR_EXT |
A |
192 |
B |
168 |
||
C |
1 |
||
D |
2 |
||
<port> (default = 502) |
502 |
Address of a Modbus Serial Slave Through Ethernet/Serial Line Gateway
It is also possible to address a Modbus slave through an Ethernet/serial line gateway:
The request includes the communication port number, gateway IP address with or without TCP port), and the Modbus serial slave address (UnitId parameter):
'<communication port number>{<IP address>}<slave address>'
For example, to send a message at Modbus Serial slave address 5 through a Ethernet/serial line gateway at IP address 192.168.1.2 using standard TCP port 502, use this string: '3{192.168.1.2}5'
The ADDM
function fills the AddrTable
input/output with these values:
Field |
Size |
Value |
Example |
---|---|---|---|
|
BYTE |
Reserved |
Not used |
|
BYTE |
Reserved |
Not used |
|
BYTE |
Rack number |
0 |
|
BYTE |
Module number |
0 |
|
|
3 |
|
|
BYTE |
0 for Modbus |
0 |
|
BYTE |
|
7 |
|
BYTE |
<Slave address> |
5 |
|
TCP_ADDR_EXT |
A |
192 |
B |
168 |
||
C |
1 |
||
D |
2 |
||
TCP port number (default = 502) |
502 |
This example shows the implementation of the ADDM
function block in conjunction with the SINGLE_WRITE
function block. The ADDM
function block converts the given STRING '1.8' to the variable stSlave8OnSL1
of type ADDRESS
. If the conversion was successful the input Execute
of subsequent function block SINGLE_WRITE
is triggered.