Node-RED Modbus RTU / TCP Communication

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone today we're going to be looking at the node-red modbus communication detailed information contained in video can be found at acc automation.ca the link has been put in description below if you have not watched the other videos yet there'll be links in the description below that will start your video one there'll be links to the rest of the videos and series as well so node-red can easily connect to industrial controls using modbus communication now bodmus modbus is a master slave type communication masters will always send the commands to read or write to the slave on the network and the slave will then respond if the communication is directed at them so you have multiple slaves back to your master now we will be using node-red contrib modbus pallet and this will allow us to communicate modbus serial which through rs485 and it's a modbus rtu communication to a solo process temperature controller and we'll also use modbus ethernet tcp to communicate to a click plc now when you use a tcp ethernet the master is referred to as the client and the slave is referred to as a server so in a series using red node we have previously installed the windows software we will now continue today to connect our industrial equipment to the modbus protocol so we understood from last time that red node is used to create a single modbus flow and we will be communicating to our solo process temperature controller using modbus rtu on a serial rs485 network the present and set values of the controller will be red then these values will be written to our click plc using an ethernet modbus tcp network a set value from the analog input on a click will be used then to write to the solo and this will happen every 200 milliseconds or five times a second so let's get started and what you'll see on my screen here is we have our node-red program already in here and we've already started our node-red by going to our dos prompt and entering node red you can see here we're actually started and our flows have started so you can see here this is my flow and it's actually active right now we have one simple flow and that has a injection which will cause our timing to happen and if we just look at it we go over here to our data and you can see here when i double click it you'll see that we have our payload and it will inject every point two seconds so every point two seconds it actually then activates this uh flow in order to get the information back and forth then what we're using is the modbus flex getter and flex right to order to get the information in and out so let's just move this back again so we can see the whole thing and this modbus is is used or the modbus tribute is used on our palette by installing it so if we go up here to these lash lines we go to the manage palette and you can see my node red contrib uh modbus is right here and it's already in use which it is we know that and if you go to the install if you just type in modbus you'll see that it comes right up here and if it wasn't installed then you can just hit install and it will install that and bring it back to your palette itself let's just close that down and once you've got it installed you will see that we now have a whole series on a modbus here that we can bring these nodes into our palette we have modbus reads and writes but for multiple ones and the most flexible one we use the modbus flex together and flex right so read and write to our modbus [Music] so like i said we have the one flow here so the the first one we're doing here is our function and we have a function node which is coming right here that allows us to set the parameters up in order to use the mod block's flex getter so if we double click it we can see that we have fc or function code number three which is in the modbus [Music] read and our unit id is one our address is 4096 which is the modbus address that we're looking for and the quantity is two then we return this part to our message so those of you familiar with um modbus will know those parameters quite well and if you'd not then we have links on the website to actually get you to where that actually is so that's what our function block will do before our modbus flex getter if we look at it on the flex getter what you will see is it will actually set up the modbus pro our process capture controller so if we hit this in our server you will actually see we're actually using com port number eight we're using the serial type rtu buffer our baud rate 9600 data bits is 8 stop bits 1 and we have even parity so this is set up according to what we set are going to be setting or showing on our solo process temperature controller so once we have that server set up on our system then we can use in multiple nodes as we use red node or node red so let's cancel out that and if we want to what we can do is in order to get this function block let me just call back up my data here and we hit we look at the flux getter if we look at the help file and go down to the bottom of the help file it will actually show you what that message payload or what that's function block is actually supposed to be reading so here's my function code 3 our unit id our address and the quantity that we're receiving if we want to do multiple reads which we are in this case that is how we uh read that then we go to once we read the present value and set value out of our solo we go to our function key again and we're going to write those into the click plc and again we can take a look at our function code and again here we have fc16 we're using unit number one we're going to do address 0 and our quantity is going to be 2. [Music] so and then we go to our flex right and our flex right again we're going to set up the click plc we look at the server settings and we have our type is tcp our host is 192.168.1 130. the default port is one five or 502 which is the default four modbus tcp and then we have a unit ideas one and our maximum timeout is 1 000 milliseconds or one second so we'll just cancel that and again what we do is we look at the modbus flex in the help file and you will look down here and you will see the actual example for a multiple payload that gives us the format in which we have our function before this flex getter so once we have so we've read our from our solo we've written the two parameters to our click then what we have to do is then read from the click the value to put in the set value so again function block we set our parameters up then we do a flex getter so we're actually reading now from the click and we're reading um the third address when you see that right here [Music] so address number two so zero one two which is the third one over let's cancel that and then we so we're reading that value and then once we read that value we're actually going to then write this back to our solo so again we set the parameters up our address 4097 one address and then we use our right to break back into our solo process temperature controller so that is our node-red program or our flow to get the information and move it over so now what we'll do is take a look at our actual solo and actually before we actually we'll take a look at solo and in solo we've covered this and how to there's the wiring so our wiring is 485 and we will go into the address and set up so that we can do online and view these baud rates parity even or length parity and the stop bits so these must match what we have set up in node red as well and like i said we were running the back of the solo process temperature controller has an rs485 so we're using a usb to 485 communication adapter which we've done a post on in order to install that unit once we have installed that unit what you will see is that we have um the device manager let me go down here and we can actually see that we're on com number eight if i call up.com we will see the port settings which will match what we have in our communication settings for our solo and for uh node red so we have that all set then we so let's take a look quickly at the actual hardware that we have here and we will call this up okay here we go and what you'll notice is that we have here is our click plc we have an ethernet based unit it's the c0-11 d-r-e-d with an analog card analog in and out and then we have our solo process temperature controller it's the model 4096 and that's showing us our present value and our set value here then we have our usb so this is our usb-485m which converts our usb to i rs45 so it's our serial converter which will allow us to connect our computer back to our solo process temp controller we also have a j type thermocouple that will show us our present value of our temperature ambient room temperature here then our set value set right now here and we also have our um [Music] analog input going into our first analog signal of our card which will then allow us to set through our click plc program the actual set value here so that is our actual hardware and we do have a post on creating the analog input signal for you as well as well as collecting or connecting that back to the click plc and how to do that so the next uh thing we should look at is actually the click plc program so if we look at it up the first thing we'll do is look under setup we'll go to our port settings and we'll look at our setup of our ethernet port and that's located right here you'll see that we have the same ip setting as we set in our node red flow so which is 192.168.1 130. now it's important to set a static ip address or set manually in order to make sure that every time this unit powers up we have the same location or address and then we configure it as our variation as our our client or the master which was is not in this case but we have a slave again the tcpi port is 502 which is default maximum current sessions so we can have three so three different devices can be talking to this unit at the same time and the client inactivity timeout would be 60 seconds so it doesn't receive something we have a signal in the plc telling us there's something wrong here so that is our com port settings if we look under the setup we can do the systems configuration just to show you the analog and here is our power supply cpu and then our analog card we go down to our configuration [Music] and you can see here we've scaled the input going from zero to ten volts in our case zero to nine volts it's going to zero to uh one thousand and that's going to be placed in df1 now the 1000 is because our decimal point is already present in there so 1000 represent 100.00 so let's hit okay and okay from there and then what we'll do is we'll go to um where we get the information from in our unit so address picker so in our address picker we look at their ds values and we can look at our modbus communication addresses and you will see that we have 40 thousand and one forty thousand two and three are going to be my solo uh present value my set value and my right value so that's how we get our addresses in here and you can also see in the in the code here you see our function codes that we can use for these addresses hit ok on that and then we can use our data view in our click plc in order to view these parameters so currently right now you can see that our present value is two two six our set value is three six four and our right value is three six four here as well and our scaled value looking at the program is very simple all it's doing is it is taking our scaled analog input on df1 so here's my number now remember this is in a floating point and it's converting that floating point into an integer and it's just taking the upper part there so 364 and putting in a ds3 so that is the entire program so if i take a look at my reading if i grab a hold of my probe and hold on to it what you'll see is that probe will start increasing and you will see that the node red actually starts increasing that data or that value up to whatever i'm talking about or whatever i'm holding it to so very quick and easy we also notices if i take my analog and we will just turn this pot you will see that the set point now increases decreases according to my pot as i turn it so the program works uh quite well and quite quickly again we have um 200 milliseconds which is five times a second that we're updating that data so let's go just go right back to that flow again if we look at the flow you'll also see that as indication we can actually see in our modbus response which is part of the the palette that we brought in from modbus this is a great idea or a great way to actually see the values coming in so 273 and 4477 are the present value and set value of the solo process controller then what we're doing is we write those in so it's just saying that we've written two and then we're going to actually read so it's actually tell us that we're reading that four seven seven let's do that down here so that 477 here [Music] and so just to move that make sure that it is we'll just increase that a little bit more and you can see that's now up to [Music] 50.9 then we write that back in to the address to make sure it appears on our solo so if you enjoyed this video please hit the like button below if you have any questions about the video please leave a comment below and i'll do my best to answer it if you want more information about us or you want our free ebooks on numbering systems or robust data logging please click on the link in description below to get it a new video is put every monday so you make sure you hit the subscribe button to get more videos like this in the future remember to click the bell beside your subscription to actually receive those notifications thanks so much for watching i'll see you next time stay safe [Music] you
Info
Channel: ACC Automation
Views: 38,419
Rating: undefined out of 5
Keywords: acc automation, node red, node-red plc communication, node-red plc modbus, node-red modbus rtu tcp communication, node-red modbus, modbus, node-red, iot, plc, nodered modbus, node red modbus plc, nodered plc modbus, nodered, node red modbus, node red modbus to temp, node red modbus communication, node-red modbus communication, node, plc node-red communication, plc programming, modbus node communiation, modbus tcp, tutorial, plc node red, iot tutorial, node red iot, iiot, modbus pi
Id: yX1w5vcV6cc
Channel Id: undefined
Length: 18min 35sec (1115 seconds)
Published: Mon Mar 29 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.