Codesys 3.5 Modbus TCP Slave illegal data address

gerber
2022-04-14
2022-04-27
  • gerber - 2022-04-14

    Hi,

    I’m trying to establisch communicate with a Modbus TCP slave.
    I need to reed address 3201 by using FC3. For some reason I always get error β€œillegal data address”.
    I have double checked the addressing (Unit ID = 0, FC3, offset 3201) with an external Modbus TCP tool and this works.

    Do I miss something within the Codesys configuration

     
  • TimvH

    TimvH - 2022-04-26

    Keep in mind that Modbus starts with address 1, but this is actually register 0. CODESYS uses a 0 based offset. So what you can try is to read 3200, because maybe your device uses a 1 based offset.

    Additionally maybe you can set the length to only one register just to see if this works.

     
  • dFx

    dFx - 2022-04-27

    Unit ID feels wrong also, even if it seems to work.
    Recall that serial Modbus uses addresses 1 to 247 decimal, and reserves 0 as a broadcast address.

    Even if some modbus TCP devices just ignore the address and echoes it back, 255 is generally used for a single device.
    So if this device is a gateway, 1-247 is generally used with a gateway(TCP/SL) to point a device on SL.

    Exception
    Code MODBUS name Comments
    01 - Illegal Function Code - The function code is unknown by the server
    02 - Illegal Data Address - Dependant on the request
    03 - Illegal Data Value - Dependant on the request
    04 - Server Failure - The server failed during the execution
    05 - Acknowledge - The server accepted the service invocation but the service requires a relatively long time to execute. The server therefore returns only an acknowledgement of the service invocation receipt.
    06 Server Busy - The server was unable to accept the MB Request PDU. The client application has the responsibility of deciding if and when to re-send the request.
    0A Gateway problem - Gateway paths not available.
    * 0B Gateway problem - The targeted device failed to respond. The gateway generates this exception.

     

Log in to post a comment.