MODBUS TCP Client Mode Configuration

This section lists the CLI configuration steps for TCP Client Configuration for MODBUS connection.

Note:
Server MODBUS Application disconnects sometimes. Ensure that messages are sent to the server when it is connected.
Configure VLAN 1.

Type the following:

  • Enter the Global Configuration Mode.
Phoenix_Contact# configure terminal
  • Enter the Interface Configuration Mode.
Phoenix_Contact(config)# interface vlan 1
  • Configure VLAN 1.
Phoenix_Contact(config-if)# no shutdown
Phoenix_Contact(config-if)# ip address 192.168.0.40 255.255.255.0
Phoenix_Contact (config-if)# end

  • Enter the Global Configuration Mode.
Phoenix_Contact# configure terminal
  • Enter the Interface Configuration Mode for 0/9.
Phoenix_Contact(config)# interface serial 0/9
  • For example, configure the baud rate.
Phoenix_Contact(config-serial-if)# baud-rate 115200
Phoenix_Contact (config-serial-if)# no shutdown
Phoenix_Contact (config-serial-if)# end

Reconnecting

  1. Map the client without preparing the server for connection.

    Type the following:

    • Enter the Global Configuration Mode.
    Phoenix_Contact# configure terminal
    • Configure profile PROF_10_MOD_CLIENT.
    Phoenix_Contact(config)# serial connection-type modbus profile PROF_10_MOD_CLIENT
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT)# role client
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# local server port modbus
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# remote ipv4 address 192.168.0.100 port modbus
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# connection-map interface serial 0/10
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# end
  2. Run one of the commands "show serial profile all" or "show serial profile name YOUR_PROFILE_NAME" or "show serial profile interface serial 0/YOUR_INT_NUM" to verify the connection status (it should be not connected).

    Type the following:

    Phoenix_Contact# show serial profile interface serial 0/10
    Profile : PROF_10_MOD_CLIENT
    Protocol : Modbus
    Role                    : TCP Client
    Serial interface        : 10
    Slaves ID               :
    Remote Server IP        : 192.168.0.100
    Remote Server Port      : 502
    Local Client Port       : 502
    Serial byte counter     : 0
    Server byte counter     : 0
    Connection to server    : NO
    Reconnect Timeout (sec) : 15
    KeepAlive interval (sec): 240
    Forward exceptions      : 1
    Response time (msec)    : 1000
    RXed from master msg    : 0
    TXed to master messages : 0
    RXed from slave msg    : 0
    TXed to slave msg : 0
    Exceptions created      : 0
    DSCP                    : 0
    Turnaround delay(msec)  : 0
    Hold time(msec)         : 0
    Rx-to-Tx delay          : 0
  3. Verify default parameters.
  4. Use WireShark to verify the connection attempts done within the configured reconnect timer interval. Actual attempts in software are done every “Reconnect timer (sec)” seconds, and can be seen when “debug serial critical” is configured; Wireshark shows only those attempts which are executed only when TCP stack is ready to execute them, so if the reconnect timeout is lenghty, the Wireshark attempts are executed with the “reconnect timer” attempts.

Connecting to Server

  1. Start Server (Modbus Slave App) to accept connection from the client. The default Slave ID will be 1.

    Perform the following:

    Figure 1. Modbus Slave App - Connection Setup


  2. Run one of the commands "show serial profile all" or "show serial profile name YOUR_PROFILE_NAME" or "show serial profile interface serial 0/YOUR_INT_NUM" to verify the connection status (it should be connected).

    Type the following:

    Phoenix_Contact# show serial profile interface serial 0/10
    Profile : PROF_10_MOD_CLIENT
    Protocol : Modbus
    Role                    : TCP Client
    Serial interface        : 10
    Slaves ID               :
    Remote Server IP        : 192.168.0.100
    Remote Server Port      : 502
    Local Client Port       : 502
    Serial byte counter     : 0
    Server byte counter     : 0
    Connection to server    : YES
    Reconnect Timeout (sec) : 15
    KeepAlive interval (sec): 240
    Forward exceptions      : 1
    Response time (msec)    : 1000
    RXed from master msg    : 0
    TXed to master messages : 0
    RXed from slave msg    : 0
    TXed to slave msg : 0
    Exceptions created      : 0
    DSCP                    : 0
    Turnaround delay(msec)  : 0
    Hold time(msec)         : 0
    Rx-to-Tx delay          : 0

Disconnecting from Server

  1. Close the server.
  2. Run one of the commands "show serial profile all" or "show serial profile name YOUR_PROFILE_NAME" or "show serial profile interface serial 0/YOUR_INT_NUM" to verify the connection status (it should be connected).

    Type the following:

    Phoenix_Contact# show serial profile interface serial 0/10
    Profile : PROF_10_MOD_CLIENT
    Protocol : Modbus
    Role                    : TCP Client
    Serial interface        : 10
    Slaves ID               :
    Remote Server IP        : 192.168.0.100
    Remote Server Port      : 502
    Local Client Port       : 502
    Serial byte counter     : 0
    Server byte counter     : 0
    Connection to server    : NO
    Reconnect Timeout (sec) : 15
    KeepAlive interval (sec): 240
    Forward exceptions      : 1
    Response time (msec)    : 1000
    RXed from master msg    : 0
    TXed to master messages : 0
    RXed from slave msg    : 0
    TXed to slave msg : 0
    Exceptions created      : 0
    DSCP                    : 0
    Turnaround delay(msec)  : 0
    Hold time(msec)         : 0
    Rx-to-Tx delay          : 0
  3. Verify that Packetizing is disabled - turnaround, hold, and rx-to-tx timers are 0, serial counters are 0.
  4. Use WireShark to verify connection attempts done within the configured reconnect timer interval.

Connecting to not Native Modbus Port

  1. Disconnect the server.
  2. In the Connection tab, change the listen server port number 15010.
  3. Connect the server.
  4. Change back remote and local port number by.

    Type the following:

    • Enter the Global Configuration Mode.
    Phoenix_Contact# configure terminal
    • Configure profile PROF_10_MOD_CLIENT.
    Phoenix_Contact(config)# serial connection-type modbus profile PROF_10_MOD_CLIENT
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT)# role client
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# remote ipv4 address 192.168.0.100 port 15010
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# local server port 15010
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# connection-map interface serial 0/10
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# end
  5. Run one of the commands "show serial profile all" or "show serial profile name YOUR_PROFILE_NAME" or "show serial profile interface serial 0/YOUR_INT_NUM" to verify the connection status (it should be connected).

    Type the following:

    Phoenix_Contact# show serial profile interface serial 0/10
    Profile : PROF_10_MOD_CLIENT
    Protocol : Modbus
    Role                    : TCP Client
    Serial interface        : 10
    Slaves ID : 1 2 4 5 6 7 8 9
    Remote Server IP        : 192.168.0.100
    Remote Server Port      : 15010
    Local Client Port       : 15010
    Serial byte counter     : 0
    Server byte counter     : 0
    Connection to server    : YES
    Reconnect Timeout (sec) : 15
    KeepAlive interval (sec): 60
    Forward exceptions      : 1
    Response time (msec)    : 1000
    RXed from master msg    : 0
    TXed to master messages : 0
    RXed from slave msg    : 0
    TXed to slave msg : 0
    Exceptions created      : 0
    DSCP                    : 0
    Turnaround delay(msec)  : 0
    Hold time(msec)         : 0
    Rx-to-Tx delay          : 0
  6. Change back remote and local port number.

    Type the following:

    • Enter the Global Configuration Mode.
    Phoenix_Contact# configure terminal
    • Configure profile PROF_10_MOD_CLIENT.
    Phoenix_Contact(config)# serial connection-type modbus profile PROF_10_MOD_CLIENT
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT)# role client
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# remote ipv4 address 192.168.0.100 port change back remote and local port number by
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# local server port change back remote and local port number by
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# connection-map interface serial 0/10
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# end
  7. Disconnect the server.
  8. In the Connection tab, change the listen server port number 502.
  9. Connect the server.
  10. Run one of the commands "show serial profile all" or "show serial profile name YOUR_PROFILE_NAME" or "show serial profile interface serial 0/YOUR_INT_NUM" to verify the connection status (it should be connected).

    Type the following:

    Phoenix_Contact# show serial profile interface serial 0/10
    Profile : PROF_10_MOD_CLIENT
    Protocol : Modbus
    Role                    : TCP Client
    Serial interface        : 10
    Slaves ID : 1 2 4 5 6 7 8 9
    Remote Server IP        : 192.168.0.100
    Remote Server Port      : 502
    Local Client Port       : 502
    Serial byte counter     : 0
    Server byte counter     : 0
    Connection to server    : YES
    Reconnect Timeout (sec) : 15
    KeepAlive interval (sec): 60
    Forward exceptions      : 1
    Response time (msec)    : 50
    RXed from master msg    : 0
    TXed to master messages : 0
    RXed from slave msg    : 0
    TXed to slave msg : 0
    Exceptions created      : 0
    DSCP                    : 29
    Turnaround delay(msec)  : 0
    Hold time(msec)         : 0
    Rx-to-Tx delay          : 0

Configuring keep-alive

  1. Use Wireshark to verify that keep-alive messages are sent according to keep-alive interval.
  2. Unmap the profile, change the keepalive interval to different one. Map the profile. Connect with previously connected server.

    Type the following:

    • Enter the Global Configuration Mode.
    Phoenix_Contact# configure terminal
    • Configure profile PROF_10_MOD_CLIENT.
    Phoenix_Contact(config)# serial connection-type modbus profile PROF_10_MOD_CLIENT
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT)# role client
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# no connection-map
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# keep-alive timeout 60
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# connection-map interface serial 0/10
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# end
  3. Use Wireshark to verify that keep-alive messages are sent according to keep-alive interval.
  4. Run “show serial interface serial 0/10” and verify the keep-alive value.

    Type the following:

    Phoenix_Contact# show serial profile interface serial 0/10
    Profile : PROF_10_MOD_CLIENT
    Protocol : Modbus
    Role                    : TCP Client
    Serial interface        : 10
    Slaves ID : 1 2 4 5 6 7 8 9
    Remote Server IP        : 192.168.0.100
    Remote Server Port      : 502
    Local Client Port       : 502
    Serial byte counter     : 0
    Server byte counter     : 0
    Connection to server    : YES
    Reconnect Timeout (sec) : 4
    KeepAlive interval (sec): 60
    Forward exceptions      : 1
    Response time (msec)    : 2000
    RXed from master msg    : 0
    TXed to master messages : 0
    RXed from slave msg    : 0
    TXed to slave msg : 0
    Exceptions created      : 0
    DSCP                    : 0
    Turnaround delay(msec)  : 0
    Hold time(msec)         : 0
    Rx-to-Tx delay          : 0

Reconnecting to the Server

  1. Close connection in the slave (the server) - click Disconnect.

    Type the following:

    Figure 2. Modbus Slave App - Disconnecting


  2. Run "show serial profile all" or "show serial profile name YOUR_PROFILE_NAME" or "show serial profile interface serial 0/YOUR_INT_NUM" to verify the connection status (not connected).

    Type the following:

    Phoenix_Contact# show serial profile interface serial 0/10
    Profile : PROF_10_MOD_CLIENT
    Protocol : Modbus
    Role                    : TCP Client
    Serial interface        : 10
    Slaves ID : 1 2 4 5 6 7 8 9
    Remote Server IP        : 192.168.0.100
    Remote Server Port      : 15010
    Local Client Port       : 15010
    Serial byte counter     : 0
    Server byte counter     : 0
    Connection to server    : NO
    Reconnect Timeout (sec) : 4
    KeepAlive interval (sec): 60
    Forward exceptions      : 1
    Response time (msec)    : 2000
    RXed from master msg    : 0
    TXed to master messages : 0
    RXed from slave msg    : 0
    TXed to slave msg : 0
    Exceptions created      : 0
    DSCP                    : 0
    Turnaround delay(msec)  : 0
    Hold time(msec)         : 0
    Rx-to-Tx delay          : 0
  3. Connect the server in the same way as was disconnected.
  4. Run "show serial profile all" or "show serial profile name YOUR_PROFILE_NAME" or "show serial profile interface serial 0/YOUR_INT_NUM" to verify the connection status (connected).

Connecting to the Master

  1. Open Master Application.
  2. Go to Read/Write Definition tab and select Read/Write disable and clickOK.

    Type the following:

    Figure 3. Modbus Slave App - Read / Write


    Definition
  3. Go to Connection tab and connect to the client running on the device through a serial port.

    Type the following:

    Figure 4. Modbus Slave App - Connection through a serial port


Not Configured Slave Polling (Exception by Client)

  1. Go to Display and click Communication.

    Type the following:

    Figure 5. Modbus Slave App - Communication


  2. In the Slave Application, in the same way as in Master, go to Display and click Communication.
  3. Go to Read/Write definition and clickRead/Write Once with the default parameters.

    Type the following:

    Figure 6. Modbus Slave App - Read / Write


    Definition
  4. Verify that master receives exception “Gateway path unavailable” because the Slave 1 is not configured at the Client.
  5. Run "show serial profile all" or "show serial profile name YOUR_PROFILE_NAME" or "show serial profile interface serial 0/YOUR_INT_NUM" to verify that slaves were added.

    Type the following:

    Phoenix_Contact# show serial profile interface serial 0/10
    Profile : PROF_10_MOD_CLIENT
    Protocol : Modbus
    Role                    : TCP Client
    Serial interface        : 10
    Slaves ID : 
    Remote Server IP        : 192.168.0.100
    Remote Server Port      : 502
    Local Client Port       : 502
    Serial byte counter     : 0
    Server byte counter     : 0
    Connection to server    : YES
    Reconnect Timeout (sec) : 15
    KeepAlive interval (sec): 240
    Forward exceptions      : 1
    Response time (msec)    : 1000
    RXed from master msg    : 0
    TXed to master messages : 0
    RXed from slave msg    : 0
    TXed to slave msg : 0
    Exceptions created      : 1
    DSCP                    : 0
    Turnaround delay(msec)  : 0
    Hold time(msec)         : 0
    Rx-to-Tx delay          : 0

Adding Slaves to Client

  1. Unmap the profile. Add multiple slaves (not more then 10 in a single command). Map the profile back.

    Type the following:

    • Enter the Global Configuration Mode.
    Phoenix_Contact# configure terminal
    • Configure profile PROF_10_MOD_CLIENT.
    Phoenix_Contact(config)# serial connection-type modbus profile PROF_10_MOD_CLIENT
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT)# role client
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# no connection-map
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# add slave-id 1,2,3,4,5,6,7,8,9,247
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# connection-map interface serial 0/10
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# end
  2. Run one of the commands "show serial profile all" or "show serial profile name YOUR_PROFILE_NAME" or "show serial profile interface serial 0/YOUR_INT_NUM" to verify that slaves were added.

    Type the following:

    Phoenix_Contact# show serial profile interface serial 0/10
    Profile : PROF_10_MOD_CLIENT
    Protocol : Modbus
    Role                    : TCP Client
    Serial interface        : 10
    Slaves ID : 1 2 3 4 5 6 7 8 9 247
    Remote Server IP        : 192.168.0.100
    Remote Server Port      : 502
    Local Client Port       : 502
    Serial byte counter     : 0
    Server byte counter     : 0
    Connection to server    : NO
    Reconnect Timeout (sec) : 15
    KeepAlive interval (sec): 240
    Forward exceptions      : 1
    Response time (msec)    : 1000
    RXed from master msg    : 0
    TXed to master messages : 0
    RXed from slave msg    : 0
    TXed to slave msg : 0
    Exceptions created      : 0
    DSCP                    : 0
    Turnaround delay(msec)  : 0
    Hold time(msec)         : 0
    Rx-to-Tx delay          : 0
  3. Verify default parameters.
  4. Use WireShark to verify the connection attempts done within the configured reconnect timer interval. Actual attempts in software are done every “Reconnect timer (sec)” seconds, and can be seen when “debug serial critical” is configured; Wireshark shows only those attempts which are executed only when TCP stack is ready to execute them, so if the reconnect timeout is lenghty, the Wireshark attempts are executed with the “reconnect timer” attempts.

Reading Holding Registers from Slave

  1. Put any values in 10 slave’s holding registers to see them read and updated in the Master Application after the reading. Double-click the field and update the value.

    Perform the following.

    Figure 7. Modbus Slave - Edit Register


  2. Send read command from the Master to Slave 1. Quantity of 5 read registers.

    Perform the following.

    Figure 8. Modbus Slave - 5 Read


  3. Verify by looking into the Communication Traffic screen, that the request is sent, received in the Slave, and answered; if the answer is accepted in the Master’s Communication Traffic screen, and the data has been updated in the Master Holding Registers to be equal to the five first registers of Slave’s register.

    Perform the following.

    Figure 9. Modbus Slave - Communication Traffic


  4. Run one of the commands "show serial profile all" or "show serial profile name YOUR_PROFILE_NAME" or "show serial profile interface serial 0/YOUR_INT_NUM" to verify counters were incremented with 1.

    Type the following:

    Phoenix_Contact# show serial profile interface serial 0/10
    Profile : PROF_10_MOD_CLIENT
    Protocol : Modbus
    Role                    : TCP Client
    Serial interface        : 10
    Slaves ID : 1 2 3 4 5 6 7 8 9 247
    Remote Server IP        : 192.168.0.100
    Remote Server Port      : 502
    Local Client Port       : 502
    Serial byte counter     : 0
    Server byte counter     : 0
    Connection to server    : YES
    Reconnect Timeout (sec) : 4
    KeepAlive interval (sec): 240
    Forward exceptions      : 1
    Response time (msec)    : 2000
    RXed from master msg    : 1
    TXed to master messages : 1
    RXed from slave msg    : 1
    TXed to slave msg : 1
    Exceptions created      : 0
    DSCP                    : 0
    Turnaround delay(msec)  : 0
    Hold time(msec)         : 0
    Rx-to-Tx delay          : 0

Writing to Holding Registers from Slave

  1. In the Read/Write Definition dialog box, go to Function field and select 16 Write Multiple Registers. Then, in the Address field, type 1, and in Quantity, type 5. ClickOK.

    Perform the following.

    Figure 10. Modbus Slave - Writing Multiple Registers


  2. Enter any values in the 10 master’s holding registers to see them written and updated in the Slave Application after the write. To update the value, double click the field and click OK.

    Perform the following.

    Figure 11. Modbus Slave - Enter Value


  3. Send write command from the Master to Slave 1. Write 5 registers from 1 to 6.

    Perform the following.

    Figure 12. Modbus Slave - Enter Value


  4. Verify by looking into the Communication Traffic screen, that the request is sent, received in the Slave, and acknowledged; Slave's registers 1 to 6 are written with received data and the answer is accepted in the Master’s Communication Traffic screen. No exception should be observed.

    Perform the following.

    Figure 13. Modbus Slave - Enter Value


  5. Run one of the commands "show serial profile all" or "show serial profile name YOUR_PROFILE_NAME" or "show serial profile interface serial 0/YOUR_INT_NUM" to verify counters were incremented with 1 and now have value 2.

    Type the following:

    Phoenix_Contact# show serial profile interface serial 0/10
    Profile : PROF_10_MOD_CLIENT
    Protocol : Modbus
    Role                    : TCP Client
    Serial interface        : 10
    Slaves ID : 1 2 3 4 5 6 7 8 9 247
    Remote Server IP        : 192.168.0.100
    Remote Server Port      : 502
    Local Client Port       : 502
    Serial byte counter     : 0
    Server byte counter     : 0
    Connection to server    : YES
    Reconnect Timeout (sec) : 4
    KeepAlive interval (sec): 240
    Forward exceptions      : 1
    Response time (msec)    : 2000
    RXed from master msg    : 2
    TXed to master messages : 2
    RXed from slave msg    : 2
    TXed to slave msg : 2
    Exceptions created      : 0
    DSCP                    : 0
    Turnaround delay(msec)  : 0
    Hold time(msec)         : 0
    Rx-to-Tx delay          : 0

Reading Not Supported Number of Holding Registers from Slave (Exception by Slave)

  1. Put any values in 10 slave’s holding registers to see them read and updated in the Master Application after the reading. Double-click the field and update the value. Or leave them as is, since they should not be sent to the master)

    Perform the following.

    Figure 14. Modbus Slave - Edit Register


  2. In the Read/Write Definition dialog box, go to Function field and select 03 Read Holding Registers. Then, in Address field, type 1, and in Quantity, type 15. ClickOK.

    Perform the following.

    Figure 15. Modbus Slave - Read Holding Registers


  3. Verify by looking into the Communication Traffic screen, that the request is sent, received in the Slave, and answered with exception; the answer is accepted in the Master’s Communication Traffic screen has been shown in red color in the Master Application.

    Perform the following.

    Figure 16. Modbus Slave - Enter Value


  4. Run one of the commands "show serial profile all" or "show serial profile name YOUR_PROFILE_NAME" or "show serial profile interface serial 0/YOUR_INT_NUM" to verify counters were incremented with 1 (now at 3).

    Type the following:

    Phoenix_Contact# show serial profile interface serial 0/10
    Profile : PROF_10_MOD_CLIENT
    Protocol : Modbus
    Role                    : TCP Client
    Serial interface        : 10
    Slaves ID : 1 2 3 4 5 6 7 8 9 247
    Remote Server IP        : 192.168.0.100
    Remote Server Port      : 502
    Local Client Port       : 502
    Serial byte counter     : 0
    Server byte counter     : 0
    Connection to server    : YES
    Reconnect Timeout (sec) : 4
    KeepAlive interval (sec): 240
    Forward exceptions      : 1
    Response time (msec)    : 2000
    RXed from master msg    : 3
    TXed to master messages : 3
    RXed from slave msg    : 3
    TXed to slave msg : 3
    Exceptions created      : 1
    DSCP                    : 0
    Turnaround delay(msec)  : 0
    Hold time(msec)         : 0
    Rx-to-Tx delay          : 0

Reading Holding Registers with Wrong CRC

  1. Perform a normal reading and verify that it worked properly.
  2. In the Communication Traffic screen of the Master, click Copy.

    Perform the following.

    Figure 17. Modbus Slave - Communication Traffic


    - Master
  3. After that, in the Communication Traffic screen of the Master, click Continue.
  4. Open the Test Center screen from the Functions tab. Copy the message (only the message part) to the Test Center screen. Click Send.

    Perform the following.

    Figure 18. Modbus Slave - Communication Traffic - Master and Slave


  5. In the Communication Traffic screen of the Master, verify that message sent from master and received answer are the same as in “Reading Holding Registers from the Slave” chapter. Same about Slave Communication Traffic screen.
  6. Change any number inside the message sent fromTest Center screen.
  7. Use the command “debug serial critical” to enable debugging.
  8. Send the message again.
  9. Verify detection of CRC mismatch in the debug messages.

    The following appears:

    [SER_IP_DBG] : SerialIpModbusValidateSerialMsg(), CRC missmatch, received: 0xd408, calculated: 0xd409

    [SER_IP_DBG] : SerialIpModbusTcpClientSerialFdProc(): request serial message at serial 10 is invalid, ignoring

  10. Use the command “debug serial none” to disable debugging.
  11. Verify that there is no response received on the master side (no response should be sent upon CRC error).
  12. Close the Test Center screen.

Reading Holding Registers from Disconnected Slave

  1. Go to Connection and disconnect a Slave.
  2. Execute read command. Use “Reading Holding Registers from the Slave” chapter as example.
  3. Verify the master received “Gateway path unavailable” exception like in NOT CONFIGURED SLAVE POLLING chapter.
  4. Connect back the slave.
  5. Execute read command again.
  6. Verify master red the slave’s registers properly.

Disabling forward-exception

  1. Disable forward-exception.

    Type the following:

    • Enter the Global Configuration Mode.
    Phoenix_Contact# configure terminal
    • Configure profile PROF_10_MOD_CLIENT.
    Phoenix_Contact(config)# serial connection-type modbus profile PROF_10_MOD_CLIENT
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT)# role client
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# no connection-map
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# forward-exception disable
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# connection-map interface serial 0/10
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# end
  2. Run one of the commands "show serial profile all" or "show serial profile name YOUR_PROFILE_NAME" or "show serial profile interface serial 0/YOUR_INT_NUM" to verify that forwarding is disabled.

    Type the following:

    Phoenix_Contact# show serial profile interface serial 0/10
    Profile : PROF_10_MOD_CLIENT
    Protocol : Modbus
    Role                    : TCP Client
    Serial interface        : 10
    Slaves ID : 1 2 3 4 5 6 7 8 9 247
    Remote Server IP        : 192.168.0.100
    Remote Server Port      : 502
    Local Client Port       : 502
    Serial byte counter     : 0
    Server byte counter     : 0
    Connection to server    : NO
    Reconnect Timeout (sec) : 4
    KeepAlive interval (sec): 60
    Forward exceptions      : NO
    Response time (msec)    : 2000
    RXed from master msg    : 0
    TXed to master messages : 0
    RXed from slave msg    : 0
    TXed to slave msg : 0
    Exceptions created      : 0
    DSCP                    : 0
    Turnaround delay(msec)  : 0
    Hold time(msec)         : 0
    Rx-to-Tx delay          : 0
  3. Perform all steps from chapter “Reading Holding Registers from Disconnected Slave”.
  4. Verify the client is not responding to the master when the slave is disconnected.
  5. Verify the “Timeout error” in the master application.

Enabling forward-exception

  1. Enable forward-exception.

    Perform the following:

    • Enter the Global Configuration Mode.
    Phoenix_Contact# configure terminal
    • Configure profile PROF_10_MOD_CLIENT.
    Phoenix_Contact(config)# serial connection-type modbus profile PROF_10_MOD_CLIENT
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT)# role client
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# no connection-map
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# forward-exception enable
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# connection-map interface serial 0/10
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# end
  2. Run one of the commands "show serial profile all" or "show serial profile name YOUR_PROFILE_NAME" or "show serial profile interface serial 0/YOUR_INT_NUM" to verify that forwarding is enabled.

Configuring DSCP

  1. Change Differentiated Services Field Codepoints (DSCP) value.

    Perform the following:

    • Enter the Global Configuration Mode.
    Phoenix_Contact# configure terminal
    • Configure profile PROF_10_MOD_CLIENT.
    Phoenix_Contact(config)# serial connection-type modbus profile PROF_10_MOD_CLIENT
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT)# role client
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# no connection-map
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# DSCP 28
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# connection-map interface serial 0/10
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# end
  2. Run one of the commands "show serial profile all" or "show serial profile name YOUR_PROFILE_NAME" or "show serial profile interface serial 0/YOUR_INT_NUM" to verify the DSCP value.

    Type the following:

    Phoenix_Contact# show serial profile interface serial 0/10
    Profile : PROF_10_MOD_CLIENT
    Protocol : Modbus
    Role                    : TCP Client
    Serial interface        : 10
    Slaves ID : 1 2 3 4 5 6 7 8 9 247
    Remote Server IP        : 192.168.0.100
    Remote Server Port      : 502
    Local Client Port       : 502
    Serial byte counter     : 0
    Server byte counter     : 0
    Connection to server    : NO
    Reconnect Timeout (sec) : 4
    KeepAlive interval (sec): 60
    Forward exceptions      : NO
    Response time (msec)    : 2000
    RXed from master msg    : 0
    TXed to master messages : 0
    RXed from slave msg    : 0
    TXed to slave msg : 0
    Exceptions created      : 0
    DSCP                    : 28
    Turnaround delay(msec)  : 0
    Hold time(msec)         : 0
    Rx-to-Tx delay          : 0
  3. Open Wireshark.
  4. Send any message to the Slave.
  5. Use Wireshark to verify that the DSCP level is 28.

    Figure 19. Wireshark Showing DSCP of 28


Removing Slaves

  1. Remove the slaves.

    Perform the following:

    • Enter the Global Configuration Mode.
    Phoenix_Contact# configure terminal
    • Configure profile PROF_10_MOD_CLIENT.
    Phoenix_Contact(config)# serial connection-type modbus profile PROF_10_MOD_CLIENT
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT)# role client
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# no connection-map
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# remove slave-id 1,3,247
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# connection-map interface serial 0/10
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# end
  2. Run one of the commands "show serial profile all" or "show serial profile name YOUR_PROFILE_NAME" or "show serial profile interface serial 0/YOUR_INT_NUM" to verify the that the specified slaves were removed.

    Type the following:

    Phoenix_Contact# show serial profile interface serial 0/10
    Profile : PROF_10_MOD_CLIENT
    Protocol : Modbus
    Role                    : TCP Client
    Serial interface        : 10
    Slaves ID : 2 4 5 6 7 8 9
    Remote Server IP        : 192.168.0.100
    Remote Server Port      : 502
    Local Client Port       : 502
    Serial byte counter     : 0
    Server byte counter     : 0
    Connection to server    : NO
    Reconnect Timeout (sec) : 4
    KeepAlive interval (sec): 60
    Forward exceptions      : NO
    Response time (msec)    : 2000
    RXed from master msg    : 0
    TXed to master messages : 0
    RXed from slave msg    : 0
    TXed to slave msg : 0
    Exceptions created      : 0
    DSCP                    : 28
    Turnaround delay(msec)  : 0
    Hold time(msec)         : 0
    Rx-to-Tx delay          : 0
  3. Execute chapter “Not Configured Slave Polling (Exception by Client)” and verify receiving exception.
  4. Add a slave ID of 1.

    Perform the following:

    • Enter the Global Configuration Mode.
    Phoenix_Contact# configure terminal
    • Configure profile PROF_10_MOD_CLIENT.
    Phoenix_Contact(config)# serial connection-type modbus profile PROF_10_MOD_CLIENT
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT)# role client
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# no connection-map
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# add slave-id 1
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# connection-map interface serial 0/10
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# end
  5. Run one of the commands "show serial profile all" or "show serial profile name YOUR_PROFILE_NAME" or "show serial profile interface serial 0/YOUR_INT_NUM" to verify that a slave was added.

    Type the following:

    Phoenix_Contact# show serial profile interface serial 0/10
    Profile : PROF_10_MOD_CLIENT
    Protocol : Modbus
    Role                    : TCP Client
    Serial interface        : 10
    Slaves ID : 1 2 4 5 6 7 8 9
    Remote Server IP        : 192.168.0.100
    Remote Server Port      : 502
    Local Client Port       : 502
    Serial byte counter     : 0
    Server byte counter     : 0
    Connection to server    : NO
    Reconnect Timeout (sec) : 4
    KeepAlive interval (sec): 60
    Forward exceptions      : NO
    Response time (msec)    : 2000
    RXed from master msg    : 0
    TXed to master messages : 0
    RXed from slave msg    : 0
    TXed to slave msg : 0
    Exceptions created      : 0
    DSCP                    : 28
    Turnaround delay(msec)  : 0
    Hold time(msec)         : 0
    Rx-to-Tx delay          : 0

Writing to Slave Using Slave ID 0

  1. Configure the master for writing and set wanted values in its registers.
  2. Select Slave ID 0 in the Read/Write Definition screen.
  3. Write to the client.
  4. Verify that there is no response to the request, but the data was written.

    Perform the following.

    Figure 20. Writing to Slave Using Slave ID 0


Reading from Slave Using Slave ID 0

  1. Configure the master for reading and set wanted values in the registers of the master and slave.
  2. Select Slave ID 0 in the Read/Write Definition screen.
  3. Read from the client.
  4. Verify that the master is receiving exception.

    Perform the following.

    Figure 21. Reading from Slave Using Slave ID 0


Changing response-timeout

  1. Change the response time.

    Type the following:

    • Enter the Global Configuration Mode.
    Phoenix_Contact# configure terminal
    • Configure profile PROF_10_MOD_CLIENT.
    Phoenix_Contact(config)# serial connection-type modbus profile PROF_10_MOD_CLIENT
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT)# role client
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# no connection-map
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# response-timeout 50
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# connection-map interface serial 0/10
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# end
  2. Run one of the commands "show serial profile all" or "show serial profile name YOUR_PROFILE_NAME" or "show serial profile interface serial 0/YOUR_INT_NUM" to verify that response-timeout was changed.

    Type the following:

    Phoenix_Contact# show serial profile interface serial 0/10
    Profile : PROF_10_MOD_CLIENT
    Protocol : Modbus
    Role                    : TCP Client
    Serial interface        : 10
    Slaves ID : 1 2 4 5 6 7 8 9
    Remote Server IP        : 192.168.0.100
    Remote Server Port      : 502
    Local Client Port       : 502
    Serial byte counter     : 0
    Server byte counter     : 0
    Connection to server    : NO
    Reconnect Timeout (sec) : 4
    KeepAlive interval (sec): 60
    Forward exceptions      : NO
    Response time (msec)    : 50
    RXed from master msg    : 0
    TXed to master messages : 0
    RXed from slave msg    : 0
    TXed to slave msg : 0
    Exceptions created      : 0
    DSCP                    : 0
    Turnaround delay(msec)  : 0
    Hold time(msec)         : 0
    Rx-to-Tx delay          : 0
  3. In the Read/Write Definition. screen, select Slave ID of 1.
  4. Read the Holding Registers from the Slave.
  5. If the response from the slave arrives after 50 msec, the master should get the “device failed to respond” exception, even if the slave responded with a proper data.

Configuring Turnaround Delay

  1. Unmap the profile. Set the turnaround delay to 1000 msec. Map the profile. Connect to the server (slave).

    Type the following:

    • Enter the Global Configuration Mode.
    Phoenix_Contact# configure terminal
    • Configure profile PROF_10_MOD_CLIENT.
    Phoenix_Contact(config)# serial connection-type modbus profile PROF_10_MOD_CLIENT
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT)# role client
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# no connection-map
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# end

    Phoenix_Contact # configure terminal
    Phoenix_Contact(config)# interface serial 0/10
    Phoenix_Contact(config-serial-if)# turnaround delay 1000
    Phoenix_Contact(config-serial-if)# no shutdown
    Phoenix_Contact(config-serial-if)# end

    Phoenix_Contact # configure terminal
    Phoenix_Contact(config)# serial connection-type modbus profile PROF_10_MOD_CLIENT
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT)# role client
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# connection-map interface serial 0/10
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# end
  2. Run one of the commands "show serial profile all" or "show serial profile name YOUR_PROFILE_NAME" or "show serial profile interface serial 0/YOUR_INT_NUM" to verify that turnaround delay is 1000 msec.

    Type the following:

    Phoenix_Contact# show serial profile interface serial 0/10
    Profile : PROF_10_MOD_CLIENT
    Protocol : Modbus
    Role                    : TCP Client
    Serial interface        : 10
    Slaves ID : 1 2 4 5 6 7 8 9 
    Remote Server IP        : 192.168.0.100
    Remote Server Port      : 502
    Local Client Port       : 502
    Serial byte counter     : 0
    Server byte counter     : 0
    Connection to server    : NO
    Reconnect Timeout (sec) : 4
    KeepAlive interval (sec): 60
    Forward exceptions      : NO
    Response time (msec)    : 50
    RXed from master msg    : 0
    TXed to master messages : 0
    RXed from slave msg    : 0
    TXed to slave msg : 0
    Exceptions created      : 0
    DSCP                    : 0
    Turnaround delay(msec)  : 1000
    Hold time(msec)         : 0
    Rx-to-Tx delay          : 0
  3. Read the Holding Registers from the Slave.
  4. Verify that response arrives to the master immediately by looking into the Communication Traffic screen. In Master and Slave the response appear right after the request.
  5. Read holding registers twice. The second reading should be done immediately after the first time.
  6. Verify that the second response in the Slave’s Communication Traffic screen appears immediately after request; however, in the Master’s Communication Traffic screen, the response appears approximately after 1 second.

Configuring hold-time Delay

  1. Unmap the profile. Set the hold-time delay to 100 msec. Map the profile. Connect to the server (slave).

    Type the following:

    • Enter the Global Configuration Mode.
    Phoenix_Contact# configure terminal
    • Configure profile PROF_10_MOD_CLIENT.
    Phoenix_Contact(config)# serial connection-type modbus profile PROF_10_MOD_CLIENT
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT)# role client
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# no connection-map
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# end

    Phoenix_Contact# configure terminal
    Phoenix_Contact(config)# interface serial 0/10
    Phoenix_Contact(config-serial-if)# hold-time 100
    Phoenix_Contact(config-serial-if)# no shutdown
    Phoenix_Contact(config-serial-if)# end

    Phoenix_Contact# configure terminal
    Phoenix_Contact(config)# serial connection-type modbus profile PROF_10_MOD_CLIENT
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT)# role client
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# connection-map interface serial 0/10
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# end
  2. Run one of the commands "show serial profile all" or "show serial profile name YOUR_PROFILE_NAME" or "show serial profile interface serial 0/YOUR_INT_NUM" to verify that hold-time delay is 100 msec.

    Type the following:

    Phoenix_Contact# show serial profile interface serial 0/10
    Profile : PROF_10_MOD_CLIENT
    Protocol : Modbus
    Role                    : TCP Client
    Serial interface        : 10
    Slaves ID : 1 2 4 5 6 7 8 9 
    Remote Server IP        : 192.168.0.100
    Remote Server Port      : 502
    Local Client Port       : 502
    Serial byte counter     : 0
    Server byte counter     : 0
    Connection to server    : NO
    Reconnect Timeout (sec) : 4
    KeepAlive interval (sec): 60
    Forward exceptions      : NO
    Response time (msec)    : 50
    RXed from master msg    : 0
    TXed to master messages : 0
    RXed from slave msg    : 0
    TXed to slave msg : 0
    Exceptions created      : 0
    DSCP                    : 0
    Turnaround delay(msec)  : 1000
    Hold time(msec)         : 100
    Rx-to-Tx delay          : 0
  3. Read the Holding Registers from the Slave.
  4. Verify that response arrives to the master immediately by looking into the Communication Traffic screen. In Master and Slave the response appear right after the request.
  5. Read holding registers twice. The second read should be done immediately after the first time.
  6. Verify that the second response in the Slave’s Communication Traffic screen appears immediately after request; however, in the Master’s Communication Traffic screen, the response appears approximately after 100 msecs. Actually, it is time_of_Rxed_response - time_of_Rxed_request + 100 msec). It can be visually distinguished from 1 sec.

Configuring rx-to-tx Delay

  1. Unmap the profile. Set the turnaround delay and hold-time to 0, and the rx-to-tx delay to 1000 msec. Map the profile. Connect to the server (slave).

    Type the following:

    • Enter the Global Configuration Mode.
    Phoenix_Contact# configure terminal
    • Configure profile PROF_10_MOD_CLIENT.
    Phoenix_Contact(config)# serial connection-type modbus profile PROF_10_MOD_CLIENT
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT)# role client
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# no connection-map
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# end

    Phoenix_Contact# configure terminal
    Phoenix_Contact(config)# interface serial 0/10
    Phoenix_Contact(config-serial-if)# hold-time 100
    Phoenix_Contact(config-serial-if)# turnaround delay 0
    Phoenix_Contact(config-serial-if)# rx-to-tx delay 1000
    Phoenix_Contact(config-serial-if)# no shutdown
    Phoenix_Contact(config-serial-if)# end

    Phoenix_Contact# configure terminal
    Phoenix_Contact(config)# serial connection-type modbus profile PROF_10_MOD_CLIENT
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT)# role client
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# connection-map interface serial 0/10
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# end
  2. Run one of the commands "show serial profile all" or "show serial profile name YOUR_PROFILE_NAME" or "show serial profile interface serial 0/YOUR_INT_NUM" to verify that rx-to-tx delay is 1000 msec.

    Type the following:

    Phoenix_Contact# show serial profile interface serial 0/10
    Profile : PROF_10_MOD_CLIENT
    Protocol : Modbus
    Role                    : TCP Client
    Serial interface        : 10
    Slaves ID : 1 2 4 5 6 7 8 9 
    Remote Server IP        : 192.168.0.100
    Remote Server Port      : 502
    Local Client Port       : 502
    Serial byte counter     : 0
    Server byte counter     : 0
    Connection to server    : NO
    Reconnect Timeout (sec) : 4
    KeepAlive interval (sec): 60
    Forward exceptions      : NO
    Response time (msec)    : 50
    RXed from master msg    : 0
    TXed to master messages : 0
    RXed from slave msg    : 0
    TXed to slave msg : 0
    Exceptions created      : 0
    DSCP                    : 0
    Turnaround delay(msec)  : 0
    Hold time(msec)         : 0
    Rx-to-Tx delay          : 1000
  3. Read the Holding Registers from the Slave.
  4. Verify that the response in the Slave’s Communication Traffic screen appears approximately after 1 second.

Clearing Serial Configuration and Deleting Profile

  1. Delete the profile. Set Rx-to-Tx delay to 0.

    Type the following:

    • Enter the Global Configuration Mode.
    Phoenix_Contact# configure terminal
    • Configure profile PROF_10_MOD_CLIENT.
    Phoenix_Contact(config)# no serial profile PROF_10_MOD_CLIENT
    Phoenix_Contact(modbus-PROF_10_MOD_CLIENT-client)# end

    Phoenix_Contact# configure terminal
    Phoenix_Contact(config)# interface serial 0/10
    Phoenix_Contact(config-serial-if)# shutdown
    Phoenix_Contact(config-serial-if)# rx-to-tx delay 0
    Phoenix_Contact(config-serial-if)# no shutdown
    Phoenix_Contact(config-serial-if)# end
  2. Run “show serial profile interface serial 0/10” to verify that profile is not mapped.