Jump to content

ModBus TCP/IP Questions and Problems (VisiLogic, V1210, PLC Master)


Recommended Posts

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:

mb01.png.cdaf4d09262e5a287c1d1a3068c598da.png

mb02.png.5c7251aa92dbef7976dfad538812a81d.png

mb03.png.c78d2e7ec45dcf93af6fc1ac80c3f281.png

 

Link to comment
Share on other sites

  • MVP 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

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...

mb04.thumb.png.265f162b3eba3469109943aef70246f7.png

Link to comment
Share on other sites

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

  • MVP 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

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

mb05.png.148f8cfbbc9bbc30547cce900b0729c1.png

  • 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

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

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.

image.png.f64e8bb7f380bc91e40400eb15033ad9.pngimage.png.b84d8f7ff94cb1bda7d9e5f1b7f19512.png

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

  • MVP 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

  • 1 month later...
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.

image.png.f64e8bb7f380bc91e40400eb15033ad9.pngimage.png.b84d8f7ff94cb1bda7d9e5f1b7f19512.png

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

  • MVP 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

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

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...