Store PLCnext CommunityPLCnext on LinkedInPLCnext on Instagram  PLCnext on YouTube Github PLCnext CommunityStore PLCnext Community

  1. goodman7499
  2. PLCnext Engineer
  3. Wednesday, 07 April 2021
Hello!

I'm trying to communicate two PLCs through a Modbus communication. One of them is an old PLC and acts as the Server of the Modbus TCP comm. while the PLCnext (AXC F 2152) carries out the function of the Client. I tried to implement the read and write operations with the use of two FC23 blocks, but currently I'm not able to make it work since the Client FB is not becoming active.

Do you have any ideas of what might be wrong with this? Also I'm not sure if it is correct to use the FC23 block. I figured out it would be best since I can program the whole communication from both sides and I'm not trying to read some specific registers but the whole set of variables.

Thank you very much in advance
Regards

Guzman
Attachments (1)
Accepted Answer
goodman7499 Accepted Answer Pending Moderation
0
Votes
Undo
Hello Martin,

The connection to the Modbus Server (old PLC) has already been checked with the use of the Modbus Poll tool. However, the old PLC is currently not connected to the client (PLCnext) because I'm trying to verify the programming of the PLCnext through a Modbus tool in my PC. Currently the only connection made is between the PLCnext and my personal laptop, which has to act as the Modbus Server to test the Client FB in the PLCnext.

I have good news. I tried with several Modbus tools and finally got it working. I saw in another post of yours that Modbus Poll can't act as a Modbus Server so I guess that might be the reason it didn't work. Now I'm using a tool called EasyModbusTCP Server Simulator (https://sourceforge.net/projects/easymodbustcpserver/) and the connection has been established with no problems.

I have just one question left regarding the use of Modbus. Since I'm programming both sides of the communication, is it necessary for me to differentiate between Coils, Discrete Inputs, etc.? I thought that it may be possible for me to just send the array of WORDs from the old PLC (Server) and receive that array in the same order in the client (PLCnext) without having to worry about Coil Register Offset or anything like that. I say that specially because as you can see in the image together with this post, although I modify the content of the adresses, the only that sent to the PLCnext after the client asks for it are zeros.

Thank you very much again!
Regards

Guzmán
Attachments (1)
Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo
Hi Guzman.
As you point out, I would also expect to see the xACTIVE output on the TCP_Client FB, otherwise the other calls will not work.
Can you ping the Modbus Server from a shell on the PLC? That will indicate that the server is reachable from the PLC.
Can you connect to the server using a PC-based Modbus client? That will show that the Modbus server is listening on the expected port (502).
~ Martin.
Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support
  1. one week ago
  2. PLCnext Engineer
  3. # 1
goodman7499 Accepted Answer Pending Moderation
0
Votes
Undo
Hello Martin, thanks for the quick answer first of all!

I tried pinging the PLC on its 502 port and the device is not reachable. It looks as if the PLC isn't opening the port but that may also be caused by the Client FB not going Active. I'm not sure if the FB going Active would mean that the client is ready to receive or that the client has already connected. By the way, the PLC is reachable if I try to ping without specifying any port and the Modbus connection I'm trying so far is between the PLC and my PC with a Modbus tool, so we know that the connection exists between both sides since I'm connected to the PLC through PLCnext Engineer.

Do you have any idea of what may be the cause of the 502 port not opening?

Regards
Guzmán
Attachments (1)
  1. one week ago
  2. PLCnext Engineer
  3. # 2
Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo
Hi Guzmán,
The server (not the client) should be listening on port 502 - that's the server port number that you specified on the Client FB.
Please try to connect to the Server using a Modbus TCP Client tool on the PC - that will confirm that the Modbus Server is listing on the expected port (502) and that you can connect to the server from the PC. Then, when you have confirmed that the Modbus server is set up correctly, you can try connecting to the server with the PLC again.
Can you ping the Modbus Server from a shell on the PLC (not the PC)? That will indicate that the server is reachable from the PLC.
~ Martin.
Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support
  1. one week ago
  2. PLCnext Engineer
  3. # 3
Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo
I may have been confused by the term "PLC". If by "PLC" you mean the "old PLC" you mentioned in the original post ... then you can ignore my previous answer (sorry).
Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support
  1. one week ago
  2. PLCnext Engineer
  3. # 4
Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo
If the Old PLC is not listening on port 502, and if that is the port that the PC is connecting to, then perhaps the old PLC only allows one client connection on that port?

To remove the PLCnext Engineer project from the equation, you can use the 32-bit Linux version of this Modbus client tool on the New (PLCnext) PLC:
https://www.modbusdriver.com/modpoll.html
You should be able to copy the relevant modpoll binary to the PLC, and execute it from the command line. If you can get a connection to the server (old PLC) from modpoll, then the PLCnext Engineer Client FB should also be able to connect.
Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support
  1. one week ago
  2. PLCnext Engineer
  3. # 5
Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo
Are you able to read the values of the holding registers using FC03 ?
Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support
  1. one week ago
  2. PLCnext Engineer
  3. # 6
goodman7499 Accepted Answer Pending Moderation
0
Votes
Undo
Hello Martin,

I've testing the application using the FC3 block after the developers of the Modbus_TCP library advised me to do so. Everything is working fine now in terms of reading and I only have to implement an FC16 block to start writing from the client to the server.

Thank you very much for your help again, problem solved!
Best regards

Guzman
  1. one week ago
  2. PLCnext Engineer
  3. # 7
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.