Nikola Gramatikov Posted August 17, 2023 Report Share Posted August 17, 2023 Hello, to all I have some issues with Modbus TCP Communication and P.H.R function - communication doesent work in this direction'. My PLC in V1210 - Modbus Master with ID1 connected for test porposes to Modbus Poll with ID2 witch is Slave (In real situation Slave is non Unitronics PLC) I send my setup to see the configuration: EEG-BB-ModBus.vlx In general I have some issues and questions aacording Modbuda TCP/IP communication: 1. Does it metter where is the communication net in main or in subroutine 2. How the modbus addressing in Unitornics Visilogic is organised When I use R.I.R function it works normaly and if i put 0 for Slave: Start of vector in RIR function it reads 30001 from Slave. There is offset from 1 between addresses..... When I use P.H.R function it doesnt work in this way, is there any issue when we talk abour writing holding registers to Slave .... 3. Is it Ok to use timers for startup condition for modbus functional blocks ot i should use some SB functions. My issue at all is that i cannot write to Slave: Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted August 17, 2023 MVP 2023 Report Share Posted August 17, 2023 I have to dash off or I would look at this in detail. For now, I'll say review the example projects that came with your VisiLogic installation and follow the programming form laid out there. 1 hour ago, Nikola Gramatikov said: 1. Does it metter where is the communication net in main or in subroutine No. 1 hour ago, Nikola Gramatikov said: When I use R.I.R function it works normaly and if i put 0 for Slave: Start of vector in RIR function it reads 30001 from Slave. There is offset from 1 between addresses.... This is common. Unitronics starts their addressing at zero, many other devices choose to start at one. Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted August 18, 2023 MVP 2023 Report Share Posted August 18, 2023 As I said, you need to review the example projects that came with your VisiLogic installation. You are using poor form for your MODBUS communications. That said, it appears your problem is MB 4010. It looks like that should be a direct contact, not inverted contact. Link to comment Share on other sites More sharing options...
MVP 2023 Joe Tauser Posted August 18, 2023 MVP 2023 Report Share Posted August 18, 2023 Just to be clear, are you reading registers 30001..30010 and writing registers 40001..40010 to the slave? Is MB 4010 your Modbus busy bit defined in your configuration? Can you upload your program? Joe T. 1 Link to comment Share on other sites More sharing options...
Nikola Gramatikov Posted August 18, 2023 Author Report Share Posted August 18, 2023 27 minutes ago, Joe Tauser said: Just to be clear, are you reading registers 30001..30010 and writing registers 40001..40010 to the slave? Yes Is MB 4010 your Modbus busy bit defined in your configuration? Yes Can you upload your program? Joe T. At all the reading part is working now, writing is not. As I assume tath 4010 is my status MB, it should be inverted or it will not work at all... Or maybe my logic is totally wrong... Link to comment Share on other sites More sharing options...
MVP 2023 kratmel Posted August 18, 2023 MVP 2023 Report Share Posted August 18, 2023 Hi, * Messages 6, 7, and 11mean that the master has found incompatible elements in the data sent between master and slave. Slave ID in modbus IP Configuration must be 255 Please use V280 Ethernet TCP Modbus IP sample code as Flex727 recommend. 1 Link to comment Share on other sites More sharing options...
Nikola Gramatikov Posted August 21, 2023 Author Report Share Posted August 21, 2023 Hello, gays i made the things exactly as they are in example file from website. We can say that manually everything is working, but i have following questions: When and how i should connect and disconnect the socket How the hell master and slave connect each other with the same ID ???? and why How to make a synchronised process of communication that everything can go continously with reading and writing on same time. I try with cycle timers but when read process is running, write is stuck.... with cycle timers is not OK ???? The example is good but doesent clearing th full communication process with this functional blocks.... For newbies in VIsiLogic Modbus to be clear: If some want to read from address (RIR) 40001 it shoud enter in Slave: start of vector: 0 If someone want to write (PHR) 30001 it shoud enter in Slavave: start of vector: 0 Project-DDE-BB-TDOR-30-DIF-0001-23-21.08.2023.vlp Link to comment Share on other sites More sharing options...
MVP 2023 kratmel Posted August 21, 2023 MVP 2023 Report Share Posted August 21, 2023 28 minutes ago, Nikola Gramatikov said: How the hell master and slave connect each other with the same ID ???? and why If we use Modbus over RS485 - slave ID must be different. In Modbus via Ethernet - different IP used for different slave (ID=255). Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted August 21, 2023 MVP 2023 Report Share Posted August 21, 2023 1 hour ago, Nikola Gramatikov said: When and how i should connect and disconnect the socket It would depend on the slave device. Normally there is no need to disconnect the socket ever when you are engaged in continuous transfer of data. 1 hour ago, Nikola Gramatikov said: How to make a synchronised process of communication that everything can go continously with reading and writing on same time. I try with cycle timers but when read process is running, write is stuck.... with cycle timers is not OK ???? That's because the logic you are using won't work (assuming the disabled rung 3 in the ModBus subroutine). You are Setting MB 4024 again immediately after it is Reset in rung4 which then attempts to perform the R.I.R function which will exclude the P.H.R. function later in Rung 6. Also: - Please do not have multiple logic threads in a single ladder rung. - Instead of dozens of Sets & Resets, use vector operations when addressing is sequential. Link to comment Share on other sites More sharing options...
Nikola Gramatikov Posted August 22, 2023 Author Report Share Posted August 22, 2023 Thanks guys finally it works 🙂 Link to comment Share on other sites More sharing options...
Nikola Gramatikov Posted August 24, 2023 Author Report Share Posted August 24, 2023 Hello, before i say that is OK i should check on site....it was not so OK The problem is how to connect socket automaticly on start up. It stucks and on moment it works or not. It's very strange With MB5001 is not working With Pushbuton MB5000 is working somethimes When i put SB13 for connecting condition everything is perfect and when PLC is restarted communication is also running The question is - is it Ok to use SB13 in this case or how you do it ???? Modbus.pdf ModBus.vlx Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted August 24, 2023 MVP 2023 Report Share Posted August 24, 2023 You need a RESET of MB 5001 immediately after the Connect FB. Link to comment Share on other sites More sharing options...
Gabriel Franco Posted August 24, 2023 Report Share Posted August 24, 2023 If you have only one slave, I don´t see the reason to connect/disconnect the socket. Remember to set SB 168 at power-up. Consider to use UDP, then you don´t need to worry about connection. Link to comment Share on other sites More sharing options...
Fernando Castro Posted August 25, 2023 Report Share Posted August 25, 2023 21 hours ago, Gabriel Franco said: If you have only one slave, I don´t see the reason to connect/disconnect the socket. Remember to set SB 168 at power-up. Consider to use UDP, then you don´t need to worry about connection. Hey @Gabriel Franco do you have an example of Modbus over UDP? I haven't been able to use Modbus like that, I am not sure if I am doing something wrong or if my devices just don't work over UDP. Is the same? should I Initialize the socket then connect to an IP and then need to use the Modbus functions just polling through my different devices changing IP and Modbus requests? or I need to connect toe each device first without disconnecting? or not use socket connect at all? I was able to use multiple Modbus devices but I have a sequence for disconnecting and reconnecting... I wish the connection time were not as slow as it is. ..other than that, it works. Link to comment Share on other sites More sharing options...
Gabriel Franco Posted August 25, 2023 Report Share Posted August 25, 2023 26 minutes ago, Fernando Castro said: I haven't been able to use Modbus like that, I am not sure if I am doing something wrong or if my devices just don't work over UDP. First of all, not all devices accept UPD. 28 minutes ago, Fernando Castro said: Is the same? should I Initialize the socket then connect to an IP and then need to use the Modbus functions just polling through my different devices changing IP and Modbus requests? or I need to connect toe each device first without disconnecting? or not use socket connect at all? Initialize Ethernet, Modbus and socket as usual. There is not need to connect/disconnect to/from each slave. As you mentioned, just select a slave index and use Modbus FB to poll trhough all slaves. It may be necessary to add a little delay between devices (in my experience, minimum 100 ms), because of the fact of not having all datagram control present in TCP. However, this delay compared with connect/disconnect times makes UDP by far better than TCP in the overall performance. Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted August 25, 2023 MVP 2023 Report Share Posted August 25, 2023 @Gabriel Franco I have been told that other devices using TCP on the same network presents no conflict and that both protocols can coexist simultaneously without problem. Can you confirm that to be true? Link to comment Share on other sites More sharing options...
Gabriel Franco Posted August 25, 2023 Report Share Posted August 25, 2023 33 minutes ago, Flex727 said: @Gabriel Franco I have been told that other devices using TCP on the same network presents no conflict and that both protocols can coexist simultaneously without problem. Can you confirm that to be true? Yes, but using a different socket Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted August 25, 2023 MVP 2023 Report Share Posted August 25, 2023 46 minutes ago, Gabriel Franco said: Yes, but using a different socket Yes, but I was referring specifically to this scenario: Two (or more) Vision PLCs communicating with each other using UDP. On that same network (and same subnet), other devices are communicating with each other using TCP. No problems or conflicts? Link to comment Share on other sites More sharing options...
Gabriel Franco Posted August 25, 2023 Report Share Posted August 25, 2023 I´ve had such scenario with no problems at all. Link to comment Share on other sites More sharing options...
MVP 2023 Flex727 Posted August 25, 2023 MVP 2023 Report Share Posted August 25, 2023 6 minutes ago, Gabriel Franco said: I´ve had such scenario with no problems at all. Thank you! Link to comment Share on other sites More sharing options...
Fernando Castro Posted October 4, 2023 Report Share Posted October 4, 2023 On 8/25/2023 at 10:58 AM, Gabriel Franco said: First of all, not all devices accept UPD. Initialize Ethernet, Modbus and socket as usual. There is not need to connect/disconnect to/from each slave. As you mentioned, just select a slave index and use Modbus FB to poll trhough all slaves. It may be necessary to add a little delay between devices (in my experience, minimum 100 ms), because of the fact of not having all datagram control present in TCP. However, this delay compared with connect/disconnect times makes UDP by far better than TCP in the overall performance. following up on this... unfortunately for me, it seems that the 2 devices that I use as slaves doesn't support UDP. So, I am stuck with my "Connection/Disconnection" routine.... I have a new challenge that I don't know how to solve. I need to implement a PID Loop which its Output will be linked to one of those MODBUS Slaves. the reconnection time of course will be a problem. I have 570 and V700 and I am trying so hard to maintain the same software for both so Stuck with 4 sockets (1 for data collection as Modbus Slave, 1 for remote operator, 1 software Download/Online view/SD file transfers and 1 for Modbus Master) I can't believe that the way Modbus master was implemented only allows you to talk to 1 slave in my opinion that defeats the purpose of an Industrial Network. Any other tricks under the Sleeve? Link to comment Share on other sites More sharing options...
MVP 2023 Ausman Posted October 4, 2023 MVP 2023 Report Share Posted October 4, 2023 Fernando, any chance in your systems of wiring up UniCan? You could possibly get simpler and better performance by using UniCan for simple fast comms b/n all your 570s and 700s, and then localised serial which your slaves may be able to do. cheers, Aus Link to comment Share on other sites More sharing options...
MVP 2023 kratmel Posted October 4, 2023 MVP 2023 Report Share Posted October 4, 2023 Unfortunately, I did not have the opportunity to experiment with the sockets in the V570, but I think that the ability to set the address of the slave device not by a constant but by MI in the Socket should allow changing the interlocutor on the fly. That is, an already open Socket should simply change the address without closing it. This is just a hypothesis, but if the IP address was only static here, I would understand the need for a constant switching process. I suspect that the 0.5s delay that Joe once described should be enough for the switching process to complete. Only an experiment can show whether such switching is possible in principle. Because in my opinion, as Fernando says, the idea of an Industrial Network loses its meaning for TCP. 8 hours ago, Fernando Castro said: I can't believe that the way Modbus master was implemented only allows you to talk to 1 slave in my opinion that defeats the purpose of an Industrial Network. Link to comment Share on other sites More sharing options...
Fernando Castro Posted October 5, 2023 Report Share Posted October 5, 2023 3 hours ago, Ausman said: Fernando, any chance in your systems of wiring up UniCan? You could possibly get simpler and better performance by using UniCan for simple fast comms b/n all your 570s and 700s, and then localised serial which your slaves may be able to do. cheers, Aus In this case No. All the PLCs as slaves to a Modbus Master works great (also V700 doesnt has CAN card ) and Ethernet Is easier because the physically network already exists. And for the PLC as Modbus Master the Modbus slaves are third party devices that only support ModbusTCP (Also I am already using serial port for other device) Link to comment Share on other sites More sharing options...
Fernando Castro Posted October 5, 2023 Report Share Posted October 5, 2023 2 hours ago, kratmel said: Unfortunately, I did not have the opportunity to experiment with the sockets in the V570, but I think that the ability to set the address of the slave device not by a constant but by MI in the Socket should allow changing the interlocutor on the fly. That is, an already open Socket should simply change the address without closing it. This is just a hypothesis, but if the IP address was only static here, I would understand the need for a constant switching process. I suspect that the 0.5s delay that Joe once described should be enough for the switching process to complete. Only an experiment can show whether such switching is possible in principle. Because in my opinion, as Fernando says, the idea of an Industrial Network loses its meaning for TCP. That is how I tried the very first time on the V700, and never made it work maybe I was missing something. ... I ended ussing another socket and later one I came out with the Connection/Disconnection method but the connection part is not as fast as one could Imagine, some times it gets out of sync (I have a sequence to detect enabled devices and poll one by one and if one fails to respond on a given time it restarts the entire connection), sure I can reconnect again but 2 to 3 secconds whitout a new value Is not going to make it for a PID Loop. 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