Hello and welcome to today's video in which we're going to look at a connection between two PLCs, right? It could not just be PLCs, it could actually be any device, that's perfect. Of course, one of them wants to be a PLC because that's what the video is about, but the second device could be anything else that is capable of TCP, ISO or UDP, which are network protocols, right?
Pretty standard network protocols. Every PC can speak TCP, almost everything can speak TCP nowadays. For this, we are going to use a tcon block. I have prepared two PLCs here, two PLCs, and they should communicate today.
We are only going to look at how are they going to connect. We're not sending any data yet. That's the next video. We're just going to look how do they connect.
And for this connection, we are going to need a tcon transmission connection or connect block. Goal. Bottom right, in our instructions, we have the communication blocks.
And there we have the so-called open user communication. In contrast to the S7 communication, S7 indicates, hey, it's for S7 only. That's correct. And open user communication is open for every device, basically. So not just for S7, for the SIMATIC, Siemens PLCs, but for all other devices.
So you can communicate to printers, to PCs, to servers. To everything that has a network port, basically. Usually, you would use the tSendC and tReceiveC. Those are compact blocks. They have a lot of functionality integrated.
As I want to explain, I would go to others, and there are actually more blocks. Those more blocks are somehow integrated into those, right? So, those are more detailed, better for explanation.
The first thing that we want to do is we want to make a connection. We want to just... connect two devices, two PLCs.
Therefore, I have those two prepared. And I will now use a T-Con block, transmission connection, right? We're connecting, establish communication connection.
I want to use this block. I put it here in my program. Here I go. It asked me for a data block for an instance data block. Of course, we need that.
If you don't know why, check out my video on function blocks. Here we go. So I now have my connection block. My connection block.
And this is very, very simple, very easy to use, actually. There is this little toolbox. You see it? This little toolbox. If you click on it, click, a window down here should open.
And this is our parameterization window. On parameterization, this is where we configure the block. We have first the connection parameters, and we have second the block parameters.
Connection parameters are the first important thing. This is... I'm a little in the way. Let me... That's better.
This is the connection parameters are important for the way also I can do this somehow I think. Sorry, I'm pushing around a little bit. Here we go. Yeah, the connection parameters. They are important for connecting.
So right now I have my t con block. And it doesn't have anything configured here on the left and on the right. It just has this data block.
which can be found out that so that was a mistake actually making it this small because i need for explanation i need the left side i can find in system blocks program resources i can find this data block the tcon block if i go in here i will see all the parameters that are here to the left and to the right are inside this data block right so all the data is hold held in there in the instance data block let's see why this will get important Here, in this parameterization, we need to choose a partner. I can choose a broadcast, meaning everything in my network, everything that can be reached, right, until the next router here, will be communicated to. We can have a multicast, which is I can multiple targets, multiple specific targets, not every one, but also not just one. And I can have an unspecified or a single partner.
I have the second PSC I could just select, but I want an unspecified one. unspecified means hey one single partner and i will give you the address of it right the thing we need to do here now we have the so-called connection data if we look at the block we have this connect here and it's question mark question mark question mark a whole data block needs to go there this data block for every new connection that you want to do you will have to create a new one it's actually very simple you click on the drop down and you have new you click on new New data block is created, you see? PLC1 connection data block and this is automatically also connected to our tcon block. If I double click in here, you see there's a lot of data in here.
For example, hey, the remote address. What's the IP address of our partner? Or what's the port?
And so on. There's a lot of information in there. So this database is now here. It's connected. No need to care about it more.
The only thing we need to put in there is also, hey, what is the IP address I want to send data to? In my case, I know the IP address of... the partner here 0102 right the other plc has exactly this ip address and i want to send data to that of course we can here also choose now it actually makes sense to go a little bit bigger we can here also choose now the connection type tcp iso whatever that is and udp whatever that is maybe i'll make a video explaining what those are But right now, I want to choose TCP because that's the most stable and most useful one in my case.
Maybe not the fastest, but most stable. TCP, every new connection that you make, like if you have a second PLC, if you have a third, if you have a fourth, that's all new connections. Every connection has to have an ID. Because if you send data later on, you just have to say, hey, send data to the connection with the ID 1 or with ID 2, with ID 3, with ID 4, and so All right.
The next is the database, right, that we created the data block here with all the connection data in there. And then we have active connection establishment. There's always one passive partner, which I want to be right now.
The second PLC here is the passive partner. So it's not the active one. And always one active one, which is my PLC1 here.
Whatever that means. You see, I can only select one. I can only select one. Good. And then we see down here the local port or the port.
We'll get to that in a moment. So all this data I have to make and now my block already kind of works. It already kind of works.
The next thing that I need to do is I need to do that also on the other PLC or on the other device. If you want to make a connection with the Windows PC, you could run a C. sharp script or visual basic or whatever script there's many many out there many tutorials maybe i'll make a video on that but not now i want to because i want to just connect to another plc so on my second plc i will also have the main block i also want a communication block open user communication tcon in here new data block yes of course zoom in a little bit and we also have to parameterize down here The partner should also be unspecified because I also want to put in the data manually.
I will have to create a new data block because it's a new PLC, right? It could be in a completely different project or a completely different device. It needs its own data block here.
Data block. I need to put in the IP address, of course. And I do 1680101. That's the IP of my PLC.
And now we have this active connection establishment, right? The active connection establishment. It's the other PLC because that's what I chose.
One of them has to be the active one. And now the port becomes important. What is a port?
What is a port? We can just leave it as it is, but short explanation on this. We have those two PLCs, right?
Of course we have PLC1 and we have PLC2. Those two should have a connection. Therefore, each PLC only has one network connection, right?
This is where you plug in the cable. This is where you plug in the cable. This is your Ethernet connection.
Inside the Ethernet connection, there's data. Of course, there's some data. There's stuff. One important stuff here is the so-called port, right?
Inside every... It's inside. Inside every one of those, you have many, many so-called ports. A port comes from the word port from an airport or a harbor where you have ships. If you are on an airport, you have to go to a specific gate.
Those you could also say are the gates. and each communication that we have right has to go whoops yeah that's okay that's also okay has to go to one specific gate right so let's see i have gates this is yeah come on gate one which is not gate of course it is port one right then i have port two this is all digital you can't really touch them also this is all just digital manipulation here and then we have port 2000 That's the one I chose, right? Port 2000, this is the one I chose.
How can I scroll? Does anyone know how to scroll in? Port 2000, that's what we have, right?
That's what we have. And this is also what we need to open. This port needs to be opened. If you do not have any connection or so, the ports are, of course, from the beginning on. closed of safety reasons right so all of those are closed right and what we need to do of course is we need to open a port right and we open port 2000 here right we say hey port 2000 is actually for this communication so we open this port we only need to do this in the plc that is not the active establishment part.
The active establishment part will search, will just choose one of its ports. It will send this port number to the opened port of the other PLC, right? This port number automatically and the other PLC has the information now because the port is open, it can receive information and it can send information also back to the other port. This is all coded. You don't need to take care about.
But this is the reason why you only need to choose the port for the not active partner. The not active partner will open this port and the active partner will use this port to establish the connection. And it will choose any other port that's free in its own harbor, in its own airport for this connection.
It will choose automatically. That's why you can leave it open. If you want, you can also put a number here.
Then it will always choose this specific number, but you don't need to. and no need no need right so that much for ports yeah got this right got this block and let's go back to our first plc because enough explanation on this part so on our first plc we still have some stuff read here block parameters and you see as soon as i click hey they are green everything is green because we have the data block every requirement is fulfilled that we need the only thing is we need a request We need to do a request. When do you want to connect? I will just choose a memory bit here. I will just choose a memory bit and I will call it connect.
Whenever this memory bit is active we are going to connect to the other PLC and the same here. I can also choose M00 because it's on the other PLC. They both have their own storage and it's connect.
right now when i download this both plc's individually and this becomes active it's just looking at the edge so it has its edge triggered inside whenever i press on connect i can right click and manipulate it they will try to connect all right so let's see how that looks like therefore i will download both plc's i hope they're on yes they're on Already 30 minutes I tried to make it fast. Sorry there's a lot of explanation on this. Here we go.
So now this is the program from my second PLC. This is the program from my first PLC. Here we go. First PLC and second PLC. So on the left my first PLC, on the right my second PLC.
If I want to do the following, I go in my first PLC and I right click, I want to modify, I want to connect. Nothing is happening because what we need to do first, before we can establish the connection, what we want to do first is the following. We need to open this port.
That's the first thing. This port needs to be opened. So what we need to do is on the second PLC, we need to connect here first.
So right click, modify, modify to one. I'm trying to connect and what you see now is this connection block here is busy. And we have a status of 7002, which means waiting for the partner, right?
So this one has its port open and it's waiting for the other one. Even if I now say zero, it's trying to keep it open because we only have this request once. And if I, so this is the second PLC, it will now automatically react. If I right click here on the first PLC and I now say connect, modify to one, pay attention to the second PLC, right? I modify to one.
And you see, this goes back to 7000 and it's not busy anymore. We have made a connection. We now have a connection. We saw, as soon as I pressed connect on the first PLC, we saw a reaction on the second PLC. So we know there is some kind of connection here.
Very good. The problem right now is I can't really see that we have this active connection. That's a little bit stupid. It's there. Well, great.
but I can't really see it. Therefore, what I usually do is on the second network here, I just have a simple set instruction, right? A simple, well, other way around. A set instruction, and I say whenever the T-con, right? I can say T-con whenever this is done.
I want to set a memory bit, and I say M0.1. I would call connected. All right, and this I can just simply copy to my other, to my other PLC, right, M0.1 and connect it.
And now I can actually see that they have a connection. So let's see. Here we go.
And also downloading the second one. Here we go. It's already 16 minutes.
I thought I would be faster with this, but nope. Almost done. That's just a little gimmick that I usually build.
So I have my... I am in the way, my face is in the way, I'm sorry. So we have the first PLC and the second one.
The second one I go again here with modify. You see it's still 7000 because it is still active. I can't do that. I still have an active connection.
So what I would need to do is I will do that very, very quick. I will need to make a quick... quick memory reset oops so if you ever test your program or so and you want to reset all the data just go there to go there you need to be online you can click here on mres which means memory reset which will reset all the data yep gone that was the second plc and i also need the first this video is heading to be 20 minutes i'm sorry let me push my face the world yeah i'm back again good so that's the second plc is reset and i also want to reset the first plc here memory reset yeah i know what i'm doing this doesn't delete the program it just resets all the data all the connections that i made i just look at the plc yeah yeah it's really it's booting it's booting it's booting i can see that with the leds the leds are flashing and it's almost done five four three two one done good Now I can go online. The only thing is right now the PLC is actually in stop.
I have to run it again. I have to go online and run the PLC. Now I have PLC 2 and I have PLC 1. And now if I click on the connect on the PLC 2 again, you see it goes back to 7002, which means, hey, I want to make a connection.
And I do the same on my first PLC here. And what we can see then is that those set blocks, they should be set. So let's see. And you see this variable is now one.
This variable is one, meaning we have a connection. In the next video, we will go deeper with more blocks. But that's the Tcon.
Very simple for now. This one here, the 7000. is an error um is an error code and if you hit on tcon and you hit f1 it will display you hey what does this error code actually mean because there's a lot in this a lot of data here if i scroll down i can see 7000 is no drop processing active uh 7002 means connection is being established what we saw right it tried to connect but there was no other part that said that hey and then afterwards it was done So there's a lot of error scenarios that could have here. Good.
Long explanation, long video, 20 minutes. If you have any comments, if you have any questions, just leave them in the box below. This is, by the way, my preferred method of communication between two PLCs because TCP is just a very good and stable protocol.
Yeah, leave a comment, leave a like, don't forget to subscribe and I will see you in the next video. Bye!