Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with Modbus on CK3M
We currently use Modbus successfully with our PowerBricks. We have a PLC that issues commands like

cmd"ModbusHoldingRead ..."

and it works. Now I'm trying the same thing on the CK3M. The only difference is that since the CK3M only has one Ethernet interface, I'm using it for both Modbus and normal communication.

Currently I only have one Modbus client enabled. I am able to connect to the Modbus client and issue the same Modbus commands from the terminal. However whenever I enable the PLC, it disconnects with a "Send" error in ModbusSocketError. When I look at ModbusLinuxError, I get different errors such as "Socket operation on non-socket," "Bad file descriptor," and "Destination address required".

Is there some problem with using the same interface for both Ethernet and Modbus? Should I get a USB Ethernet adapter? Or is there some other workaround?
I don't remember all the details, but I know there is a problem with connecting in the Terminal Window versus in a PLC and mixing operations. The Terminal Window and PLCs operate in different threads, and that can cause conflict. Try doing everything in one or the other, and we can go from there.
I did a little research and found this info:

Thread is a communication channel. For example, a socket can connect to a server from the command in a terminal window, or in a PLC. A terminal window is a communication thread, and a PLC is another one. Several sockets can be opened from a single thread.
In principle, a socket should be opened and closed within the same thread.

I did a little testing with a Power PMAC client to a Power PMAC server:

I found that I could use the same socket with the Terminal Window and a PLC. I could connect to the server with either thread and then send commands thru both. Your issue was reproduced when I connected with the Terminal Window and sent a command from there before enabling the PLC. In that case, the PLC failed to send commands, and the connection closed (Modbus[i].State=0).
Ah, that gives a clue. Does that mean I have to use the same PLC to send all commands? At present we are connecting with a different PLC than the one that sends the read/write commands.
Ok, I moved all of the Modbus commands to the same PLC and now things seem to work. Thanks for the help.

Forum Jump:

Users browsing this thread: 1 Guest(s)