Jump to content

Recommended Posts

Hello,

I'm looking at a small simple project with a Samba SM70-J. I'm running into quite an issue trying to figure out a modbus tcp connection. I'm able to see the device in modscan, and other PLC's as well. But I can't seem to get my configuration right in Visilogic. Would anyone happen to be available to help me troubleshoot this?

The remote device is a Turck TBEN-S2-4IOL

PLC is a Samba SM70-J with an ethernet adapter added.

https://drive.google.com/file/d/1Zd_C7z2hyUnq0MS6XPUwR9KVwzaY_2A5/view?usp=sharing

 

Link to comment
Share on other sites

  • MVP 2023

You can't hang the Modbus Read block on the rail.  It's initiating a communication every scan and not giving it time to respond.  In Modbus TCP land you also have to connect the socket first.  If you lose the connection you'll have to trigger your connect logic again.  If your application is continuous data transfer, you can leave it connected to the socket.  If it's periodic or you change to a different Modbus slave, you'll have to disconnect first before you connect to the new slave.

There's an example at  Help->Examples->Version 900->Project Examples->Communications->Ethernet->Ethernet MODBUS IP->V280_Ethernet_TCP_MODBUS_IP_Master.vlp.

Unfortunately you can't convert a V280 to an SM70, so I did a little hacking and made it into an SM70 for you.  I don't know what your IP addresses are so you'll have to go into the blocks and edit those.

Don't be confused by the V700 examples.  That's a different animal with a built-in Ethernet port and the port numbers and system bits are different.

Joe T.

Modbus TCP Master.vlp

  • Upvote 1
Link to comment
Share on other sites

Thanks a lot for your time, Joe. I am only using one device as a slave, and at the end of the project, the goal is to not even need a switch in this panel. I only ever look to read values from the remote IO unit that I'm using.
I hadn't yet encountered the connect/close FB in any of the documentation I had been looking over, thanks for including that with clear instructions. I'm a bit of a millennial and spoiled by the niceties of using autonomous configuration for things like this :D.  

I did some experimentation with the example files, and found that it wasn't quite what I needed, but wasn't sure why. Thanks for clarifying the difference in parameters between those models.

 

I don't have access to this PLC currently, but I will this afternoon. I'm really jazzed to try this program out and see how it does. After working at this for a few days, I really appreciate the rapid response to my question and you taking the time to modify this file to show me what I was doing wrong.

 

Could I ask you a couple of more questions just for curiosity's sake? This line in the comments says "Below, both Ethernet card initialization and MODBUS Configuration are done as Power-up tasks.
Note that Socket 2 must be initialized, via the Socket Init FB, to function as a TCP Master. Network ID number MUST be 255!"

I noticed that it is set to socket 3 in the demo file, and also set to client, along with the MODBUS IP CONFIG function block socket is set to 3. I had seen in some prior documentation that some were using different socket numbers there in the initialization rung. I was highly confused about how that could ever possibly work? Is that perhaps because they were using the USB port as MODBUS RTU coms potentially?

 

According to this datasheet, am I using the correct MODBUS address to access the holding register that I can see in modscan? Turck TBEN-S2-4IOL

I'm a bit confused as to how the hex conversion in Visilogic works, if I enter a 3 into the Start of vector box, and set to hex, it doesn't appear to be giving me the actual value for 3(0x0003.) Although I don't suspect this matters whether I enter it there as hex or decimal?

 

Thanks again for your time, Joe. I appreciate your information and help.

Link to comment
Share on other sites

  • MVP 2023
27 minutes ago, Jreese37 said:

This line in the comments says "Below, both Ethernet card initialization and MODBUS Configuration are done as Power-up tasks.
Note that Socket 2 must be initialized, via the Socket Init FB, to function as a TCP Master. Network ID number MUST be 255!"

I noticed that it is set to socket 3 in the demo file, and also set to client, along with the MODBUS IP CONFIG function block socket is set to 3. I had seen in some prior documentation that some were using different socket numbers there in the initialization rung. I was highly confused about how that could ever possibly work?

Sockets are just defined pathways to specific ports. You can use any of the 4 sockets interchangeably as long as you have initialized them correctly and don't have 2 with identical settings. Each of the 4 sockets have a default initialization, but can be changed at any time (normally at start-up) with a socket initialization function block. The fact that the rung comment and the following ladder rung don't match is just a typo in the comment. Of course, the socket number must match in the initialization FB, MODBUS configuration FB, TCP connect FB, and the  MODBUS read or write FB.

 

33 minutes ago, Jreese37 said:

I'm a bit confused as to how the hex conversion in Visilogic works, if I enter a 3 into the Start of vector box, and set to hex, it doesn't appear to be giving me the actual value for 3(0x0003.) Although I don't suspect this matters whether I enter it there as hex or decimal?

I'm not sure what you're expecting here, 3 is the same in both hex and decimal. Enter a number greater than 9 if you want to see a conversion.

Link to comment
Share on other sites

Thanks for the prompt response, Flex727. 

 

So, after testing this file out, I never can get the IP to connect. I'm not sure what I could be doing wrong here. I've looked at this for hours today, and I'm not getting anywhere. I did go through and change the IP's and PLC name to what it should be.

https://drive.google.com/file/d/1RxLUDuVis55Xx2KwndrEnFNHEZGELVv-/view?usp=sharing

Does anyone happen to see what I'm doing wrong?

 

Modbus TCP Master.vlp

Link to comment
Share on other sites

  • MVP 2023

I don't see anything wrong here. Are you able to connect to the PLC from a PC? Are you able to connect to your peripheral from a PC? Have you double-checked all IP addresses and port numbers? I see that you are using port 502 in the PLC and the peripheral. Nothing wrong with that, but just checking. Are you sure the peripheral is set up to be a MODBUS slave on port 502?

I see in the comment that the slave ID MUST be 255. In my experience I haven't found that to make a difference, but you have ID 254.

What happens when you try to connect? When you're online does SB 150 come on, even briefly? Does MB 0 come on briefly? Does MB 4 immediately reset?

Just this morning I was fighting with a PLC that wouldn't connect with MODBUS. I was ready to pull my hair out until I replaced the Ethernet cable. The cable was relatively new and was just recently working. Make sure you troubleshoot the ENTIRE connection, including cables, hub, etc. If you're not using a hub, are you using a crossover cable or adapter?

Link to comment
Share on other sites

They're all on the same subnet for sure.

I was able to connect to the PLC on ethernet before I dropped this program in. I'm just now realizing that no matter what I do with this program, I can't reestablish ethernet coms PC to PLC, I have to use USB.

 

I'm not necessarily sure what I did differently, but I started from scratch with the file Joe uploaded earlier, and set things one at a time to see which FB or INIT was bugging out, but this time, everything seems to be working but the connection to the remote IO device through modbus.

Link to comment
Share on other sites

Here is the last configuration I came up with that would at least show the "connected" bit and allow Ethernet access from my PC. I get a 7, 4, and then 5 from MODBUS error status when trying to read the address.  I'll keep trying to play with the start of vector to see if I can get lucky, but it appears to be the case that it just doesn't want to read. I had this set up with a Productivity, and Codesys PLC last night, and neither of them gave me any problems. I'm not necessarily ready to give up,  but this is day three on this for me and it's driving me nuts! I appreciate all of the help from everyone who has looked into this with me.

Modbus TCP Master.vlp

Link to comment
Share on other sites

  • MVP 2023

First let's get our Visilogic versions straight here.  I created the example in 9.8.65, but I was unable to open what you re-posted.  I'm guessing you have the latest version of Visilogic (9.8.96) so I'm downloading that.   Unitronics changes the database revision from time to time and older versions can't open something saved with newer stuff.  Usually an O/S update in the PLC accompanies this.  They have a really nifty tool called the Version Swapper that lets you manage different programs on different machines created at different times, but that discussion can be found elsewhere on the forum.

Also, it's good programming practice to modify the name of a program any time you change and save it.  Add the date to the end or something.

Let's list out the basics-

1.  The PLC is set to IP 192.168.1.110.   If you're on a network with a router that has DHCP turned on make sure this address hasn't already been assigned.  Don't ask how I know to check for this.  You can tell by pinging that address from your PC with the PLC disconnected.

2.  Socket 3 is set to TCP Master at port 502.  I put this in my example but it may be a problem, as Socket 2 defaults to a  Modbus Slave also at port 502.  I changed the port for Socket 3 to 503.  It is perfectly fine to use port 503 on the Master to talk to port 502 on the Slave.  Yes, this is confusing.

3.  The Turck data sheet doesn't tell us what the Slave ID is, so I'm guessing it's 1.  Is there a web interface for it that allows you to set this?  It may not matter, but then again it might.

Have a go at it with this program.

Joe T.

 

 

Modbus TCP Master JT 1.19.23.vlp

Link to comment
Share on other sites

 

Some edits I did:

- Added socket 0 init to communicate with Visilogic.

- Change slave ID to 255, it´s the most common address for devices using Modbus TCP.

- Change port number for socket 3, to 502.

- Change start of vector to read values from slave, from 40004 to 4.

 

Try using a modbus simulator to communicate with the slave to get relevant parameters such as ID and register addresses.

 

 

Modbus TCP Master.vlp

Link to comment
Share on other sites

YAHTZEE!!! That program did it Joe!!! The only difference I can see right away is perhaps the Slave ID being 1 instead of 254 or 255? It is most certainly working with that program now :D. Thank you to everyone who took time out of their day to help troubleshoot this. I'm not the brightest crayon in the box, so lord knows I needed the help. Your help is truly appreciated!!!

 

Oh, and the port # 503 for the local port?

Link to comment
Share on other sites

  • MVP 2023

It was the port number.  I didn't even think of that when I was putting the example program together.  By default, Unitronics assigns port 502 to socket 2 and sets it as a TCP Modbus slave.  By also assigning port 502 to socket 3  without manually assigning something else to socket 2 we left the PLC in a position where it didn't know whether to shit or go blind.

It was late at night and I didn't have test hardware in front of me.  

Joe T.

Link to comment
Share on other sites

  • MVP 2023
1 hour ago, Joe Tauser said:

By also assigning port 502 to socket 3  without manually assigning something else to socket 2 we left the PLC in a position where it didn't know whether to shit or go blind.

Unitronics support always recommends initializing all 4 sockets at power-up even if only 1 or 2 are going to be used. This helps focus your attention on making sure there is no duplicate assignment. Do I do that? Rarely, but having all 4 default socket assignments memorized helps avoid the screwups.

Link to comment
Share on other sites

  • 11 months later...

Hi flex727 and Joe

I have been working on the communication of an i/olink Baumer with a SAMBA HMI. The Holding records are divided into 4 parts, 41001 + 10, 42001+10, 43001+10, 44001. For this, I was able to carry out the program that I attached.

The program works but what is causing me problems is that the SB150 disconnects from time to time. and stop reading the logs.

SAMBA = master and BAUMER = slave.

I need communication to be continuous. Can you help me?

Luis

Luis_REV_11.vlp

Link to comment
Share on other sites

  • MVP 2023

Hi Luis - 

Thank you for attaching your program.  I opened this using Visilogic 9.8.94.

For starters, your PLC ID and your Slave ID are the same.  That's generally a no-no.

The PLC is the Master.  You have a SCAN_EX block tied to Socket 2, which by default will also be port 502.  This makes the PLC into a Slave as well as a Master.  That's OK, but if you want both you need a second MODBUS IP CONFIG block using a different socket and a different port.  Will this unit be a Slave to a SCADA system or something like that?

If Socket 3 disconnects you can just re-trigger the Connect block.  You can also put a value into SI 110 for Socket 3.  Take a look at the Help for "System Operands" for a detailed explanation.

Your MI 150 pointer is incremented by a 0.01 sec timer that doesn't take into account whether the Modbus function is busy (MB 32).  That's probably too fast.

Your RHR blocks also don't consider whether the Modbus function is busy.  It's like you're screaming at the "I don't care if the last function isn't done yet!  Do this NOW!!"

Anyway, I hacked on it a bit.  Program attached.  Let us know how it goes.

Joe T.

 

 

Luis_REV_11_JT.vlp

Link to comment
Share on other sites

Hi Joe, thanks for your response. When I uploaded the file, I continued working and deleted the modbus scan block.

The problem I have is that the program works as a master. I already fixed the differences with socket 3. But it disconnects when the SB150 drops. and when it appears again it reconnects. What I cannot achieve is that the modbus connection is maintained.

I'm going to investigate a little what you wrote to me in the previous response. and then I comment again

I leave the program a little more advanced. 

Luis

Luis_REV_10.vlp

Link to comment
Share on other sites

Hi Joe and Flex. First of all, thank you very much for the time you spend on this. Secondly, I give you the program running. Where I apply many of your instructions. Which led me to be able to connect a SAMBA SM70 HMI to a BAUMER i/olink.

As Joe indicated, the RHR issue had to be resolved. and the initialization of the square so that it connects automatically. See the clock I set with SB150 in lines 2 and 3.

I leave you the application in case it is useful to you.

Luis

Luis_REV_22.vlp

Link to comment
Share on other sites

  • 4 weeks later...

Hello!

Tell me, do I understand correctly that the Unitronics v570 controller, configured to communicate via Modbus with SCADA as a “Slave”, can connect via Modbus to only one server (SCADA - WinCC v7.3)?
We use two redundant servers (master) in SCADA. The configuration of the device connected via Modbus on both servers must be the same, the connection state on both must be the same, otherwise the redundancy of the servers is lost, which is unacceptable.
At the same time, many other controllers integrated into SCADA via Modbus successfully connect to both servers, only Unitronics v570 connects to the one that polls first.

Link to comment
Share on other sites

Redundant servers (upper level of process control systems, SCADA - WinCC 7.3, Modbus TCP/IP) must have the same configuration for each integrated device (IP-address, Port), otherwise the redundancy is lost.

I tried both on port 502 and 20257 - the same.

At the moment, so that the servers do not lose redundancy, the controllers are integrated into the upper level through the OPC servers, and only one of the servers receives the data. I would like to integrate them in a standard way using Modbus TCP/IP.

PLC: E236456 V570-57-T20B-GR
Modul: E214119 V200-18-E5B-H
--- from PLC: ----
V570-57-T20 / V290-19-T20(E)
O/S: 4.2(01)
BOOT: 2.2(11)
BINLIB: 1-1.10(01)
FACTORY BOOT: 1.3(07)

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