A-B PLC MQTT Gateway: Setup and Test Gateway, Broker, and Client

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everybody sean tierney here from the automation blog in school and today we're going to be testing out a brand new product from rta we're the first ones they've sent it to it's an allen bradley plc mqtt gateway and it's a pretty cool device and what we'll do is we'll see what comes in the box then we'll connect it all up and test it out here in the studio and see how it works and um we'll also talk about connecting it to both amazon and microsoft's cloud products as well so probably the biggest use case for this while it does a lot of things would be to get data from your plc's into the cloud and you know what else is in the cloud the tab store where you can find merch like coffee cups video collections and cool t-shirts like these okay so let's take a look at the uh unboxing you can see here on the side of the box it says it's an allen bradley plc to mqtt gateway and uh the part number is 460 etc qt-n2e-d and so once we get the box open inside the first thing we see is the blue side of this unit and actually looks really nice i like the blue and once we get it out of the box you'll see a couple things right away first off you notice there's a two terminal blocks there the one at the very bottom the two pin is for power and then you'll notice the two ports now the bottom port is port one and the top port is port two but look at this look at the indicator lights at the top there the top indicator light underneath power is one and the bottom is two so those are kind of reversed the ports and the indicator lights so keep that in mind now if we look at the side we can see the label and the specifications and whatnot and it also looks like here on the front like there's an sd slot now if we go back in and look in the box here we can see before we get to the stuff inside we can see there's a disk i actually copied that disk to my hard drive so we'll have access to those utilities and then we'll find on the other side of the box we have two terminal blocks we have a power cable which i'm not going to use we also have a cat5e cable which i will use and then we have this little toy here sticky toy and um we also have a manual you can see at the bottom of the box here they talk about collecting all five um of these prizes for a remote control helicopter and then of course you can see the manual and you know care and training of your gateway and all their gateways kind of share a very similar construction and internals so this is this covers all of those now if you want to see some of the other coverage we've had on rta just go to the automationblog.com forward slash rta and you'll see all our previous coverage including when they came on to tell us about their uh ethernet to ascii gateway and we also did that df1 to ethernet gateway and so on now here you can see the second terminal block it looks like it has some serial connections we're not going to use that we're going to strictly use the two ethernet ports one will be for our plc network the other will be for our connection to the cloud okay and so we're going to emulate that all in here internally and with that let's go over to the bench here and take a look at how we have everything set up now what i really wanted to test it with was a 5580 you know the l8 we've covered these over at the automationblog.com before you know they came out in 2015 they have the integral uh ethernet port but you know it's going on seven years and i can't find anybody in product marketing at rockwell who can sample us one and we just need a little one it's just going to be for tutorials and training and whatnot so um that's out of the question for us because it's like 3 500 so instead what we'll use is an l 30 that i picked up second hand so i'm recycling it uh for our videos here and you know it's actually a great option if you're just doing some testing on a bench or you know doing some training you know if it's not in a mission critical operation then you know recycling items is is good we've always done it i know a lot of users if they decommission a system they will go ahead and take all the equipment out put them in the store room with spears so um that's always a good option for that if you're looking for items you can also support us at the same time by using our affiliate links for ebay and amazon which i'll include in the description but we're going to use this l30 you know i was going to use the 5380 but that experience kit that we picked up for 1500 back uh for episode one of the automation show that's um that's been obsoleted so there's really no no way you can get your hands on one of those inexpensively these days so with that said we'll use the recycled l30 for this and what i'm going to do is i'm going to have two networks right one for just the plcs and then we'll have uh one for the cloud or for the our our server that we're going to use in this uh this example and so what we're going to do here is we're just going to install this guy on the din rail see if i can get that on there okay seems to go on and off pretty easily and i've already wired the terminal block here to this beautiful sci top power supply the guys over at siemens sympton thank you guys okay so that'll be that and now for my server i'm going to use port 2 that's the top port okay and i'm using these are just some industrial ethernet cables that seem and sent over and what i'm going to do is to ensure this is a totally separate network i'm actually using a usb to ethernet converter so this is a separate network and i've actually unplugged the switch that my plcs go into i've unplugged it from the the wider network so in any case i'll plug that in in a moment into the vmware pc then i'll take the uh orange cable that came with the system and i'll plug it into port one i'll plug that into my l30 i also have another wire coming out of the l30 to the um to the l306 erm so that's kind of my mini network there and at this point what i'll do is i'll plug this into the virtual machine i'll power everything on and i'll be right back okay i got everything wired up and powered on so we're ready to go let's go over to the computer here and here you can see the program i have in the l30 i'll put a link to the file bundle for season two here in the description but in any case you can see this is just a program with a bunch of timers and counters in it and we'll use these counter accumulates as the values will grab out of the plc using the gateway and then send to the broker via mqtt now before we leave let's go to who active here and we'll be able to see the addresses of each of our plcs we can see the l30 is 173 and the l306 is 174. okay so let's close that and we'll go over to our other computer our other virtual machine that's on the other network that is connected to the second ethernet port on the gateway and here what i want to do is open up the sheet for the gateway here and you can see it says hey this is an allen bradley plc to mqtt gateway and we can connect up to five allen bradley plc's to mqtt and they go on to talk about you know which plc's are supported control logics compact logics flex logics micrologix slick 500 and plc5es you can see there's a lot of other great information in here but what is mqtt right we really haven't discussed that yet so let's do that now i'm going to go over to a new tab here and we'll go to mqtt.org there's a lot of great information on this website there really is but i really just want to focus on the basics of what mqtt is and for that we'll use this image down here at the bottom of the screen and you can see here on the left i have an mqtt client and over here on the right i have mqtt clients and this one on the left here you can see that it is a temperature sensor and it's publishing a topic called temperature and it's also publishing a temperature value of 24 degrees c and on the right we can see over here that this client is a subscriber and it subscribed to a topic called temperature and it is getting the value of 24 degrees c now these two clients don't talk to each other directly they go through a broker so when this client publishes its temperature topic it publishes it to the broker and then when this client wants to subscribe to that data it subscribes to that topic from the broker so that's why you can see sometimes people will call the broker a server because it really takes care of giving the data that's being published to the clients that are subscribing to it now one thing this doesn't show you is that clients can both be a publisher and a subscriber they can both produce data and consume data and this gateway from rta supports doing that so you can not only read data out of the plc and publish it to the mqtt broker you can also subscribe to some data from the mqtt broker and send it back down to and write it to the plc in one instance i heard of a customer doing that by um you know they wanted to know how high the river was to know if they could draw water from it and so what they would do is they would get the river level from a publicly available data source and then send that to the plc so that's one example of what you could do with data from the real world inside your plc now there's all kinds of companies that make mqtt brokers right and even amazon and microsoft's cloud services offer mqtt brokers brokers but the problem with those is they require a credit card and even though they say they won't charge you if you don't use it too much or don't use it for a long time you know setting up an account with either of those big companies just to run a test just seems like a little overboard to me and if you do need to do that then inside the manual for the gateway you'll find all kinds of information on how to set it up to connect to those big services but today i really want to just focus on how you could test everything on your bench without having to subscribe and give somebody a credit card right and so what we're going to do is we're going to use a free broker that we can download install right on our windows 10 pc and to find what's available we're going to go to software here we're going to go to service brokers and the one we're going to use is probably the most popular one out there it's called mosquito there it is okay and then we would go to the download page and i want the windows x64 version because i'm running 64-bit windows 10. and so that's what we would download and i've already downloaded it i'll save it again but i've already downloaded it now that's the broker we also would like a client too right we want to be able to see the data that we're pulling out of the plc somewhere in a client right and a few months ago the guys over at pnf showed me this really cool client called the mqtt explorer so let's go ahead and grab that guy as well while we're here so i'll just search on mqtt explorer okay and we'll download this as well i'm going to download the installer and i'll save that as well okay so let's go ahead and minimize our browser and now let's go ahead and get our mosquito broker installed there's really no place for the gateway to send the data unless we have the broker set up so we'll go ahead and do that here and just double click it to install it yes i want to install it and a couple things i'm going to change here in the install routine first of all i'm not going to install it as a service because i use this vmware image for other things and i don't need mosquito running all the time every time i boot up the image so i'm going to uncheck that and because i'll be running the software manually whenever i need to use it i'm not going to put it into program files mosquito that's a lot of typing every time i have to get in there and issue a command so i'm just going to install it in c column backslash mos just to make things simpler and so it'll just take a moment to install and finish and that's great now while i'm here i'll go ahead and install the explorer as well so we'll have a client that can subscribe to our data okay so we're not going to use you yet okay so let's go ahead and open up a command prompt and i'm going to open this as an administrator okay let me resize it here okay and i know the let's see if we can make the text bigger so you guys can see it at home all right so i installed mosquito in the c colon backslash mos so let's go over there we'll do a directory see what we have for exes in there and you'll see the one we're going to want to run is mosquito that's pretty simple right and i'm going to do the dash v that's the verbose mode that means it's going to give us a lot of data on what's happening okay so here we are now there's one thing here it's using default config but look at this it says starting in local mode only connections will only be possible from clients running on this machine well i got a client that's actually on the network that's not going to be good so i'm going to change that you know what i'm going to do i'm going to open another command prompt here and i'm going to do a net stat dash a and let's see what that comes up with now if you've never used mqtt before the default port that it uses is 1883. and we can see here indeed it's set up for just our local machine here 127.001 that's our local machine it's not set up for all of tcp it's just set up for our local machine here so we're going to have to change that and i'll show you how to do it it's very easy so let me minimize this guy we're going to close this window which will stop the mosquito server from running and we're going to go into c drive and we're going to go into moss and we're going to look for the configuration file here you see it mosquito config and i'm going to open it with notepad okay let me see if i can zoom in on that i'm going to do two things in here the first thing i want to do is allow anonymous and i'll tell you the reason i'm doing that is because to keep this video at a reasonable length i don't want to have to set up a bunch of usernames and passwords so i'm going to allow anonymous and then the second thing i've got to do is i'm going to come down here to listeners there we go and here what i'm going to do is i'm going to set that up i want 1883 to work for zero zero zero zero or all the tcp addresses okay so those are the two things i have to do and that way i won't have to worry about addresses user names passwords and it will work not just in a local mode but globally so let's go ahead and save that excellent all right so let me open up another command prompt and i'll run it as administrator okay we'll zoom in i'll adjust the size here a little bit we'll change over to mls excellent and now i'm going to run mosquito again verbose but i have to tell it to use that configuration file dash c and then it was mosquito dot conf okay that way it will use those settings i just uh changed in the file okay you can see here i get a security alert do you want to let this guy access public and private networks yeah i need it to be able to talk to the network for sure excellent so it's running well you know what let's go check netstat here let's run that again to see if in fact 1883 is yes it is now you can see at this time it is now uh open for all the tcp addresses not just our local 127 zero zero one okay so that's good so we can close that guy now we've got our broker working right we might as well try connecting to it with our client here so let me come in here we'll create a new connection i'm just going to call it pc i'm not going to use any certificates because just to keep things simple and the address will be the address of this computer since that's what it's running on port 1883 i don't have to use username and password so let me save that okay and then let's connect to the broker with our client okay so we can we saw some things happen here and we can see we're reading in some system information from the broker and the broker is telling us what it's doing it's sending it to our client which is mqtt explorer all right so i'm going to disconnect it's really nothing to see yet and now we're ready to go and set up the gateway the thing with the gateway is rta wisely makes them come as dhcp both ethernet ports i set up for dhcp now on the computer network i do have a dhcp server so i can use this utility that comes onto disk let's go in here disk gateway tools it's called ip setup this is off the cd-rom that comes in the box so i'm going to run that and you're going to see that my dhcp server has given an address of dot 27 okay now if you didn't have a dhcp server you could use the free dhcp tool that rockwell ships with rs links right but um the other thing is if it doesn't get an address after a certain amount of time it'll go to the automatic configuration address of you know 169.254.randomnumber.random which is the same thing your computer would go to if it couldn't find the dhcp server so with that said though because it has an address let's go ahead and launch the webpage to connect to it so we can configure it and here we can see the configuration you can see i already gave it a name the automation show and uh the first thing we're going to do here is we're going to go to configuration mode okay it's running right now so we need to go to configuration mode take it out of run that means it will stop sending data it's not sending any data right now but if it was sending data you would have a a break in the data flow as you reconfigured the module okay and so i'm going to go to network configuration and let's see here we have port 1 and i don't want that to be dhcp i want that to be static and port 1 is the port i'm using for the plc network so i'm going to give it an address of 192 192.168.1.148. and 255.255.255.0 i don't need default gateway or dns because i'm not going to the internet with that okay now let's do port two uh static again for this port i'm gonna make it 192.168.1.98 and 255.255. not zero now if your mqtt broker was on the internet right and you were using ethernet port 2 to connect to it you would absolutely have to have your default gateway in dns okay so i know most of you already know that but i want to throw that out there for those who may not be experienced uh connecting their devices through multiple routers and whatnot okay so with that done the next thing we're going to do is set up our plc connection okay and this is really we want to get data out of our plc and up to mqtt up to the cloud right so this is where our real work is and um we're using port one and uh we're gonna say here we're not going to change any of that we're going to add a plc and you can have up to five right so we saw that in the data sheet so i'm going to add a generic plc and there it is okay and i'm going to go ahead and enable it i'm going to give it a name i'm going to call it l30 because we're going to be reading in from the l30 and as we saw earlier in rs links it was 173. control slot 0 all i'll update the type there that's compact logics you can see these are the ones we saw in the data sheet that you could use okay you notice the control logics rev 32 plus is down here separately that's interesting i'm going to leave this as class 3 explicit i'm not going to use an optimized trigger tag and you can see the read the read lines here okay you'll see the right okay we're not doing any writing i'm going to read from the plc so that's really what my interest is so let's make sure none of this got changed when i left the back and forth i did and so i will save let's save what we got okay so we'll come back in here and put our tags in later but so we have that done so now we'll go over to the mqtt client side this is what talks to the broker and let's see what i'm going to do i'm going to add a generic you can see there's aws and azure here we talked about those again if you want to test those you will have to use a credit card and sign up for those services they say they won't charge you anything initially anyways but uh something consider you will also have to have a connection to the internet of course so we're just going to use a generic mqtt here for our test and here it is i'm just going to call it pc because it's running on my pc we'll enable it uh we'll use part two the broker address well my device address was 98 and my pc address is 99 so 192.168.1.99 we'll keep the standard poor of 1883. i'm not going to play with the keep alive but i am going to give myself a client id of rta i want when this is published it'll be hey the client name is rta and here's where we didn't have to set up the users and passwords because we're allowing anonymous we're not going to subscribe to any topics we're not going to read any data back into the plc or read any data from broker to write to the plc but we are going to uh publish topics and um i don't know i think we're only going to have well we'll do let's do five we'll say we'll have five topics okay we'll generate them okay and so here we can see subscribe but not doing subscribe here we can see published okay so look at these topics right you can see i got five topics here and and swell we're using uh 32 bits right we're going to do the counters the accumulates for the counters so they're all 32-bit counters and the compact logics and control objects so we'll do in 32 and we're going to give them a name i don't know i'll just call it counter zero we'll do one two three and four okay that all looks good we'll save that so that's what will go out to the broker okay so those are published topics okay so i think i'm good there so let's go back to the plc oh i don't want this this was created automatically because of this setting here let's go ahead and change this to manual okay yes yes yes it has to delete everything okay so i'm going to delete this guy okay now i want to make five read scan lines and this is easy to get wrong because it sounds like the plc is reading but this is actually from the perspective of the gateway itself and you can see right here allen bradley 2 gateway so we want to definitely want to do read so let's go ahead and generate those okay we can see them down here and now i gotta put the tags in so if i go back to studio you can see my counters are counters bracket zero bracket counters bracket one bracket and i want to accumulate of those counters so let me come over here and we'll type in counters zero and then dot acc and go ahead and copy and paste that and we'll do one two three and four and because it's a compact logics these are going to be double integers okay save parameters excellent all right so we got our abplc tags in and the address of the controller we did the mqtt setup to the broker okay so now let's do some data mapping and i'm going to go ahead and map five okay and what do we want on this side counter 0 2 counter 0 excellent counter one two counter one okay counter two two count it two counter three two counter three and counter four two count of four excellent and i make sure they're all enabled okay and let me save these parameters excellent now let's do the display data here so we have these five counters go into these five items that will be sent over to the broker okay so at this point if everything's set up correctly we will go ahead and restart the unit to put it back in the run mode and we should start seeing data coming into our broker now this isn't going to auto connect because the address was 27 but now it's 98 so let me put that in there and while we're waiting on that let's bring up the broker again okay and look it's receiving data from our gateway and here we can see status connected and running connected and running if we go to diagnostics we can see here status connected how many times it's done read requests from the plc and here we can see how many published messages done to the mqtt broker excellent so now that the gateway is set up and pulling data out of the compact logix and sending it to our broker what we can do here is connect back up with our client okay we'll go here pc we'll do connect and now here you can see a lot more things happening here on the broker side and here on the rta right you can see we have five topics right those are the five items we mapped and we can explore them you can see the values here right and if i choose count of zero i can do some other things over here let me make this a little bit bigger i can actually look at the history and you'll see that counter keeps going up and up and up now i reset the counts when i go to program the run i use the first pass bit for scan bit to do that so let's see if that works i'm going to go to program i'm gonna go back to run yep see i went all the way back down to zero okay you can see all these values started counting again from scratch okay we can also see that over here so that is how you set up the brand new rta mqtt gateway that can read data from your plc or rate data to your plc up to five allen bradley plc's with this model and uh send it to and from an mqtt broker like mosquito that we're running on our computer here or it could be aws it could be azure or it could be you know some other um you know generic mqtt broker in the cloud but with that that's the end of this episode i know that was a lot to do in one episode but i'm hoping that you found this helpful and i'm hoping now you'll understand maybe mqtt a little bit better and how it all works as well as this excellent gateway which rta sent us to test out and try and with that i want to thank you for watching if you found this episode helpful please give us a like and a sub and if you're looking for any of the information i talked about you'll find all the links down in the description and don't forget you can follow me and join our community over at automation.locals.com with that said i want to wish you all a very happy safe and healthy week and until next time my friends peace
Info
Channel: Insights In Automation
Views: 2,351
Rating: undefined out of 5
Keywords: Shawn Tierney, Insights In Automation, The Automation Show, Season 2, Real Time Automation, MQTT, Gateway, 460ETCQT-N2E-D
Id: Zvz8LkQpyk0
Channel Id: undefined
Length: 31min 34sec (1894 seconds)
Published: Wed Dec 01 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.