Nikola Gramatikov Posted August 17 Report Share Posted August 17 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: Quote Link to comment Share on other sites More sharing options...
MVP 2022 Flex727 Posted August 17 MVP 2022 Report Share Posted August 17 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. Quote Link to comment Share on other sites More sharing options...
MVP 2022 Flex727 Posted August 18 MVP 2022 Report Share Posted August 18 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. Quote Link to comment Share on other sites More sharing options...
MVP 2022 Joe Tauser Posted August 18 MVP 2022 Report Share Posted August 18 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 Quote Link to comment Share on other sites More sharing options...
Nikola Gramatikov Posted August 18 Author Report Share Posted August 18 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... Quote Link to comment Share on other sites More sharing options...
MVP 2022 kratmel Posted August 18 MVP 2022 Report Share Posted August 18 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 Quote Link to comment Share on other sites More sharing options...
Nikola Gramatikov Posted August 21 Author Report Share Posted August 21 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 Quote Link to comment Share on other sites More sharing options...
MVP 2022 kratmel Posted August 21 MVP 2022 Report Share Posted August 21 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). Quote Link to comment Share on other sites More sharing options...
MVP 2022 Flex727 Posted August 21 MVP 2022 Report Share Posted August 21 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. Quote Link to comment Share on other sites More sharing options...
Nikola Gramatikov Posted August 22 Author Report Share Posted August 22 Thanks guys finally it works 🙂 Quote Link to comment Share on other sites More sharing options...
Nikola Gramatikov Posted August 24 Author Report Share Posted August 24 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 Quote Link to comment Share on other sites More sharing options...
MVP 2022 Flex727 Posted August 24 MVP 2022 Report Share Posted August 24 You need a RESET of MB 5001 immediately after the Connect FB. Quote Link to comment Share on other sites More sharing options...
Gabriel Franco Posted August 24 Report Share Posted August 24 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. Quote Link to comment Share on other sites More sharing options...
Fernando Castro Posted August 25 Report Share Posted August 25 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. Quote Link to comment Share on other sites More sharing options...
Gabriel Franco Posted August 25 Report Share Posted August 25 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. Quote Link to comment Share on other sites More sharing options...
MVP 2022 Flex727 Posted August 25 MVP 2022 Report Share Posted August 25 @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? Quote Link to comment Share on other sites More sharing options...
Gabriel Franco Posted August 25 Report Share Posted August 25 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 Quote Link to comment Share on other sites More sharing options...
MVP 2022 Flex727 Posted August 25 MVP 2022 Report Share Posted August 25 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? Quote Link to comment Share on other sites More sharing options...
Gabriel Franco Posted August 25 Report Share Posted August 25 I´ve had such scenario with no problems at all. Quote Link to comment Share on other sites More sharing options...
MVP 2022 Flex727 Posted August 25 MVP 2022 Report Share Posted August 25 6 minutes ago, Gabriel Franco said: I´ve had such scenario with no problems at all. Thank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.