Sign in to follow this  
Followers 0
atal

FX3U- TCP Client Configuration for Multiple Servers

20 posts in this topic

Hello, I am currently working on a project that uses FX3U-ENET connected to a FX3G PLC and implementing MODBUS TCP communication between a PLC(Client) and multiple RTUs(Server). For the FX3U-ENET configuration I am using FX_Configurator EN. I have successfully been able to poll a single server. When I tried polling multiple servers the same data was observed in all the RTUs. I found out that the TCP Client does not end(close) the communication after a request/reply cycle.So,I tried to close the connection after polling a server using the "TO" command to write to the BFM directly and reopen the connection for the next server and so on. This method proved to work but for the fact that though I am able to receive valid data from the servers, still I am getting a ResponseTimeOut error even though I have increased the timeout and the number of retries values for the communication considerably. Could anyone please tell me why I am getting that error??? It would really be helpful to me if somebody could explain to me how to get a MODBUS TCP communication between a PLC(Client) and multiple servers(2 in my case) correctly.

Share this post


Link to post
Share on other sites
If you only have two servers I would strongly recommend to just set up two ModbusTCP blocks (open up four connections, two for each). That way you can have full communication between the client and server, without having to poll each server for data, close connection, change IP then open a new connection. You would also save a lot of time and processing, and work on your side...

Share this post


Link to post
Share on other sites
Thanks for your suggestion. As per your suggestion I have set up two ModbusTCP blocks in GXworks. Could you please help me out with the configuration of Fx configurator EN. Currently, I am using 4 connections, 2 for each in the open settings as you suggested. Connection 1-2: Active, RX/TX,No procedure,pairing enable, existence check confirm, local port: 1283, destination port:1502, destination ip: 192.168.0.226 Connection 3-4: Active, RX/TX,No procedure,pairing enable, existence check confirm, local port: 1282, destination port:1502, destination ip: 192.168.0.227 Though I am getting the communication to work in my previous connection(connection 3-4)....but,I am not getting any data in my new connection(Connection 1-2)

Share this post


Link to post
Share on other sites
Did you remember to change the connection number input on the first/second ModbusTCP block so that they use one (two) each? Could you post a screenshot?

Share this post


Link to post
Share on other sites
Yes, I have changed the Connection Number input on the first and the second ModbusTCP blocks. Edited by atal

Share this post


Link to post
Share on other sites
You need to rename all the outputs on the FB number 2 so that you have unique names for each FB. Preferrably rename both inputs and outputs to differentiate between them in the same way you've renamed the instance (FB) name itself.

Share this post


Link to post
Share on other sites
I have set all the variable names only in their local scope, so i don't think it will make any difference if I have used the same input and the output names for both the block.

Share this post


Link to post
Share on other sites
Did you remember to power cycle the PLC after sending new config to the FX3U-ENET module?

Share this post


Link to post
Share on other sites
I just stopped the PLC remotely and had it run again. My PLC is at a remote location right now so I can't physically power on/off the PLC at this moment in time.Do, we have to Power Reset the PLC for the changes to take place?

Share this post


Link to post
Share on other sites
RUN/STOP won't work. You could try to re-initialize the ENET module using a TO instruction to a specific BFM (don't remember but search the manual for re-initialize). You need to do that in order to have the module initialized when using FX-Configurator-EN. If you have a sequence program that automatically sets up and configures the ports/port settings you can also re-initialize the module using the TO instruction (or maybe even GW2 has a dedicated command...!!??).

Share this post


Link to post
Share on other sites
OK...I will try to re-initialize the ENET using TO command.

Share this post


Link to post
Share on other sites
I had the PLC reset manually in the remote location and now the communication is working fine for both the servers!!!Thanks for all the help...really appreciated it.Thanks!

Share this post


Link to post
Share on other sites
Thanks!!And a happy new year to you too!!

Share this post


Link to post
Share on other sites
Hey..I still got further problems in my communication for my new connection. I am getting a lot of timeout errors in my new connection(almost 1 timeout error for every two correct communications).I have polled the server used in the connection with the modbus poll software and I am getting valid data every time.So, the problem must be in my ENET module configuration. Do you have any ideas to what am i doing wrong?

Share this post


Link to post
Share on other sites
Could you post/screenshot your complete Modbus POU's to see the logic around the FBs? Do you get any Modbus Error Response code? Do you get any PLC and/or ENET error code (in the diagnostics in the EN software you can see error codes for each connection)?

Share this post


Link to post
Share on other sites
I think I have found the problem and have already solved it.My TCP client blocks were working properly for my test program.But,my complete project also had a ModbusTCP server block which I has assigned connection no.1 and I made the careless error of assigning connection 1 to my new ModbusTCP client as well. Now, that I have assigned Connection 5 to my new TCP client block, everything seems to be working fine and i am getting data without any timeout errors. But, just to make sure that I have correct logic around my FBs so that I don't get any errors in the future,I have also a attached the screenshots that you asked for.

Share this post


Link to post
Share on other sites
Am I wrong, or shouldn't the remote port be 502 when using modbus TCP ?

Share this post


Link to post
Share on other sites
You are correct, standard ModbusTCP uses port 502, however the topic starter has already indicated that he is able to use 1502 for his device (some devices have customized selectable ports even when running standard protocols). As he's already indicated the communication works so I would guess that the topic starter knows about this limitation, and have worked around this "problem" by customizing the port number in the server devices and on the client. In other words; if the server supports customized port numbers the standard FX3U-ENET module will work by using a different port number. The ModbusTCP standard opens for customized port numbers, but the do have a predefined and legal, approved registered port number 502. Further on just to inform; ModbusTCP can also use UDP if supported by the both the server and slave. Actually, in my optinion this would actually be preferrable since Modbus is a polled protocol there would be no issue running UDP. The advantage is less traffic (fewer bytes to transfer in one telegram (TCP) or datagram (UDP)). UDP is more efficient but is connectionless, however as mentioned when using polled protocols there's nothing wrong with UDP. So all in all; you are correct but in this case 1502 port number is not a problem.

Share this post


Link to post
Share on other sites
Your code seems to be just fine.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0