Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

modbus over TcpIp


AmnonS Feb 9, 2022 06:50 PM

can cr1000 with Nl121 work with modbus over TcpIp? I have sensor that work with modbus protocol, connect to network with rs485 to lan, with a simple test program like modbus poll  with modbus RTU\Ascii over tcp/ip its work but with cr1000 with nl121 and modbusmaster it's not workink, any idea?


JDavis Feb 10, 2022 12:01 AM

TCPOpen() needs to be in the program to open the IP connection. It will return a socket number into a variable.

Use that variable with the socket number for for Comport of ModbusMaster().

Other software that was connecting to the sensor must be closed. RS485 to LAN adapters allow only one connection. Also, the adapter must have Mobus gateway funtionality. Modbus TCP and Modbus RTU are different. A gateway converts.


AmnonS Feb 10, 2022 07:02 AM

JDavis

Thank you for your answer , i did TCPOpen() but i didn't use the socket no.  as a comport but the cr1000 connect and send the commands of the modbus but if i use the sniffer on the tcpip i see that there are some "numbers" before the command and that cause the sensor not to answer to the command

here is an exmple of what i get in the sniffer:

{00}{00}{00}{06}{01}{04}{00}{00}{00}{0A}

the real command is 

{01}{04}{00}{00}{00}{0A}


Sam Feb 14, 2022 12:48 AM

Anytime the communications port is TCP/IP, the CR1000 should be sending Modbus/TCP according to the Modbus Messaging on TCP/IP Implementation Guide. There should be qty 7 bytes preceding the Modbus/TCP PDU, called the MBAP header. The example you show from the "sniffer" seems a few bytes short. I would have expected something like

{00}{01}{00}{00}{00}{06}{01}{04}{00}{00}{00}{0A}

where

{00}{01} is the transaction ID

{00}{00} is the protocol ID

{00}{06} is the length, i.e the number of bytes that follow

{01} is the unit identifier, i.e. the modbus device address

I do not believe the CR1000 has a ModbusSlave / ModbusClient mode that allows for Modbus RTU over a raw TCP connection. Again, anytime the communication port is TCP/IP the CR1000 will use the Modbus/TCP implementation and not a Modbus RTU over TCP implementation.

Because of that, your "rs485 to lan" device needs to be able to operate as a Modbus TCP / RTU Gateway.

The NL201 from Campbell Sci is an example of a device that can operate as a Modbus TCP / RTU Gateway, converting Modbus/TCP to Modbus RTU and keeping track of the RTU transactions against the Modbus/TCP transaction IDs.

Log in or register to post/reply in the forum.