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 2022

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

  • MVP 2022

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

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

  • MVP 2022

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.

 

 

 

  • Like 1
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 2022
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

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

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