Milosh Posted April 6, 2020 Report Share Posted April 6, 2020 Hello all. Can we use Ethernet card for Modbus communication and for PC connection? How to achieve that? Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted April 6, 2020 MVP 2023 Report Share Posted April 6, 2020 Yes. There are example projects that came with your VisiLogic installation and there are YouTube tutorials and webinars available. Review those and make an attempt at what you're trying to do. If you still have difficulty or questions, drop back by and someone will help you. Link to comment Share on other sites More sharing options...
Milosh Posted April 6, 2020 Author Report Share Posted April 6, 2020 Thanks a lot, I already watch and read that. I mean to enable both communication PC access and Modbus TCP communication at the same time. Modbus slave is on Unitronics PLC and Master on Siemens PLC. On start-up bit I set PLC NAME and TCP CARD INIT. For Unitronics, as I understand I should use Socket 3 for non-unitronics PLC in Fb MODBUS_IP CONFIG. Right? Can I use Socket 2? What I should to put in other parameters especially to Network ID, and how to populate Slaves table? Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted April 6, 2020 MVP 2023 Report Share Posted April 6, 2020 Yes, you have 4 sockets available to you for Ethernet communication in the Vision line of PLCs (8 if you are using a V700). Simply initialize any sockets you wish to use if you want the sockets to be a protocol or port number different than the default. Here is the default (available in the Help file): Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted April 6, 2020 MVP 2023 Report Share Posted April 6, 2020 11 minutes ago, Milosh said: For Unitronics, as I understand I should use Socket 3 for non-unitronics PLC in Fb MODBUS_IP CONFIG. Right? Can I use Socket 2? You can use any socket for any purpose. Those are just the defaults, but don't inadvertently assign the same port number to two different sockets. Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted April 6, 2020 MVP 2023 Report Share Posted April 6, 2020 9 minutes ago, Milosh said: What I should to put in other parameters especially to Network ID, and how to populate Slaves table? Network ID is usually not important for TCP (but may depend on what device you're communicating with). The slaves table is only needed if the PLC is the master. Link to comment Share on other sites More sharing options...
Milosh Posted April 6, 2020 Author Report Share Posted April 6, 2020 So I need to do call for two TCP/IP SOCKET (Socket 1 and Socket 3) and than call MODBUS_IP_CONFIG (Socket 3)? Or I need just to use TCP/IP SOCKET (Socket 1) and MODBUS_IP_CONFIG (Socket 3) Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted April 6, 2020 MVP 2023 Report Share Posted April 6, 2020 Not sure I understand your question. You must use a socket initialization FB anytime you wish to assign a different configuration to the socket than the default assignment. Many programmers initialize all the sockets anyway just to have visibility into each socket's assignment and to help make sure there is no duplication of port numbers. Any socket that will be used for MODBUS communications (whether master or slave) must also have a MODBUS configuration FB. All the initializations, configurations, etc, should be activated by SB 2. Link to comment Share on other sites More sharing options...
Milosh Posted April 6, 2020 Author Report Share Posted April 6, 2020 Ok, thanks a lot I think that I understand. I will try and inform you. Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted April 6, 2020 MVP 2023 Report Share Posted April 6, 2020 Don't forget that you also need a Scan_EX FB for the MODBUS slave and addressing from the Siemens PLC will likely be "off by one" since Unitronics addressing starts at address zero and MODBUS addressing starts at one. Link to comment Share on other sites More sharing options...
Milosh Posted April 6, 2020 Author Report Share Posted April 6, 2020 I use configuration like attached. I have online connection with PLC via VPN. I change Network ID for modbus_ip_config block. After that I can't connect to plc I can ping but cannot connect to it anymore. Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted April 6, 2020 MVP 2023 Report Share Posted April 6, 2020 You'll need to post your program here. I need to see inside all the function blocks in order to help you. Link to comment Share on other sites More sharing options...
Milosh Posted April 6, 2020 Author Report Share Posted April 6, 2020 bunari.vlp Here it is... Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted April 6, 2020 MVP 2023 Report Share Posted April 6, 2020 2 hours ago, Milosh said: I change Network ID for modbus_ip_config block. After that I can't connect to plc Can you explain this in more detail? Where did you change Network ID? From what to what? What are you using to connect to the PLC? Are you within the local network or outside? All these details are important. Link to comment Share on other sites More sharing options...
Milosh Posted April 7, 2020 Author Report Share Posted April 7, 2020 Sorry I have parrallel contact with SB2. When I was online I changed Network ID, and than Set that Contact. After it I lost connection... Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted April 7, 2020 MVP 2023 Report Share Posted April 7, 2020 8 hours ago, Milosh said: When I was online I changed Network ID Exactly where and how did you do this. Also, please answer my other questions if you want help. Link to comment Share on other sites More sharing options...
Milosh Posted April 7, 2020 Author Report Share Posted April 7, 2020 Sorry, I change Network ID in MODBUS_IP_CONFIG from number 255 to number 1. I am outside from the local network, connected via VPN, and to Unitronics ethernet card. I put parallel contac with SB2, and set it. After taht can not establish connection. I can ping PLC but can't go online. Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted April 7, 2020 MVP 2023 Report Share Posted April 7, 2020 What are your connection settings in VisiLogic? I recommend that you be local to the PLC when trying to set up and troubleshoot communications. Communications between VisiLogic and the PLC do not use MODBUS. The MODBUS settings should have no effect on your connection using VisiLogic unless you are stepping on port 20256 inadvertently. Link to comment Share on other sites More sharing options...
Milosh Posted April 7, 2020 Author Report Share Posted April 7, 2020 Connection Settings. TCP/IP, Valid IP address, PLC Name And port 20256. I will try local, THANKS A LOT Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted April 7, 2020 MVP 2023 Report Share Posted April 7, 2020 When you're local you can connect to it with a USB or serial cable and avoid all the Ethernet issues. That makes troubleshooting much easier. 1 Link to comment Share on other sites More sharing options...
Milosh Posted April 10, 2020 Author Report Share Posted April 10, 2020 Thanks a lot. I tried localy and everithing works great. What is the general practice for realizing MODBUS TCP? What if I have to do multiple read/write to several devices? At the same time to send request for read/write is not possible as I know? So the sequencing is the key. Possibly solutions: 1. Realize read / write for several devices in sequence. 1. read 1st dev -> 2. write 1st device -> 3. read 2nd device etc. 2. Realize read for several devices in sequence. Write will be done on request. Sample: 1. read 1st -> read 2nd -> read 3rd -> write request for 6th device generated -> stop reading -> write to 6th device -> read 4th -> read 5th Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted April 10, 2020 MVP 2023 Report Share Posted April 10, 2020 Unless you're using a V700, the most devices you can communicate with by MODBUS TCP is 4 (without socket sharing, which I won't get into here). Yes, if your data exchange ladder rungs are set up properly you can communicate with up to 4 devices simultaneously. I'm just showing 2 of the 4 here. Just make sure your timer is long enough to make it through all 4 devices you're communicating with. If you're both reading AND writing to non-Unitronics devices, I would do it a bit differently. Instead of the timer Setting the comm requests, I would have the timer toggle another bit and use a positive transition of the bit to initiate all the reads and a negative transition to initiate all the writes. If you're communicating with other Unitronics PLCs, there is a handy Read/Write Mixed Data FB that will do both the reads and writes in one operation. Link to comment Share on other sites More sharing options...
Milosh Posted April 10, 2020 Author Report Share Posted April 10, 2020 Great... Thanks a lot for explanation. When you say all the reads and all writes, you mean for 4 device or more?! What if we need read/write from different locations addresses which is not in seqence? Can we call more RHR whit different addresses in one requst? And what is the situation with MODBUS RTU, is the rule same as here or sequencing is required?! Link to comment Share on other sites More sharing options...
MVP 2023 Joe Tauser Posted April 10, 2020 MVP 2023 Report Share Posted April 10, 2020 Only one Modbus conversation can be active at a time, but if you have both a serial (Modbus RTU) and an Ethernet connection (Modbus TCP) you can treat them separately. 1 hour ago, Milosh said: Can we call more RHR whit different addresses in one requst? Go back and read Flex's response - look at the Help on the Read/Write Mixed Data block. THIS ONLY WORKS WITH UNITRONICS PLCs! If you are talking Modbus to something other than a Unitronics PLC then ignore this block and suggestion. I'm getting the impression from reading your post that you may be thinking faster than you're coding and testing. Try adding one Modbus read at a time to your sequence and see how it works. Also add a little "cool down" time between reads to allow the port to breathe. If you're using Modbus TCP, allow about 0.25 seconds between operations. You can speed it up later if everything works. Always post your PLC program if you have operational questions regarding Modbus. There are so many things involved that simply posting screenshots will not give us what we need. Joe T. Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted April 10, 2020 MVP 2023 Report Share Posted April 10, 2020 2 hours ago, Milosh said: What if we need read/write from different locations addresses which is not in seqence? Can we call more RHR whit different addresses in one requst? Each interaction would be a different conversation. As Joe Tauser said, only one can be active at a time. Just as I said you would have to separate reads and writes, if you want multiple reads or writes, they are each separate conversations. Every MODBUS TCP interaction through a single socket must be dealt with independently. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now