Ignition -- MQTT Demo with Pi, Arduino and Kepserver

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi there my name is Walker Reynolds I'm the President and Managing Partner of atelic integration we're a full-service systems integrator based in Dallas Texas we have offices in San Antonio and Ithaca New York and we're also an ignition by inductive automation subject matter expert the purpose of this video is we built a mqtt demo I'm not going to be real formal here we're just going to kind of go through it get into the nuts and bolts and kind of explain what mqtt is how does it work and and and for the developers that are watching this video kind of show you how you can get started using mqtt with ignition for the end users who are considering MQTT or have bandwidth issues or i want to you know want a new way of doing things you know this is maybe a you know a thought of experiment or some food for thought for those folks there will be a full explanation step-by-step on our blog you can get to the blog by going to blog telic integration com or just go into our website and clicking on the blog link with that we'll go ahead and get started so the demo here basically was a five step process and I'm going to take you through that on our fabricator and but we're going to start by kind of going over what you know what is MQTT so MQTT is a communications protocol it is the communications protocol that facebook Messenger is built on I mean it's a a robust very very lightweight protocol that essentially sits on top of our communications stack and doesn't really care what's underneath it doesn't care what the format of the messages are that it's going to be sending back and forth superlightweight it it reports by exception so if you think of all of the tags or all of the messages or as MQTT electric column all of the topics that exist within the mqtt space it only reports back the edge devices or the publishers only report back to the broker the values that have changed the Delta so it's reporting by exception mqtt is really the centerpiece of what we refer to as a IOT the industrial Internet of Things right Internet of Things is all big hullabaloo and everyone is all excited about it and we read about it all the time but not many of us have seen a lot of real-world applications in industry and the reason why is because you know in my talks with developers end users and and even the software and hardware developers that are that are building MQTT compliant software and hardware you know I think there's a disconnect between you know the excitement that n kids MQTT bears and people and and there's a disconnect between that end and the application in the field how can I use mqtt to make my my business more efficient and you know how can I do more with less which is ultimately the you know the core of innovation right so so MQTT of is a is a protocol and in and in this demo we're going to basically compare it to OPC UA it you know NQ TT is a sister of of OPC UA although they handle messaging completely differently so Y MQTT the first piece is mqtt super lightweight that means the packets are super super small the second piece of it is is that MQTT reports by exception rather than having a server polling all of your edge devices and getting all the tags at some set rate so we get to eliminate a lot of the overhead and a lot of the consumption of bandwidth on tags that never changed on values that never changed in the field ok so what we're looking at the top here is this is a traditional polling model now here in the center this would be something like top server kept server or matric on OPC or any other of a million OPC UA servers down here on the bottom you got all your PLC's and all your heart instruments and devices in the field and you know how does the OPC server what is the OPC server PLC relationship now what is the OPC server client relationship like right you got your OPC server here in the center I do some configuration and my server I establish a connection with my PLC I tell it how often I want it to go get my tag updates do I want to respect the client scan rate do I want to scan at my own rate based on the server and then I call out hey PLC send me all your tags and the PLC says oh here you go here are all my tags and then I go to the next PLC and send me all your tags send me all your tags and the speed at which we can communicate to the the various plcs I have in the field is going to be a function of you know how many how many threads are available on the on the server that are running what communications protocol am I using here is a serial is it Ethernet is it Modbus TCP what is it right so if that's going to play a lot of factors in terms of how quickly we get around all our PLC's there's a lot of limitations here obviously right so I mean in first office it's incredibly inefficient to to do a round-robin polling to all the PLC's we have in the field also I got to do configuration everywhere so if I want to get tags up here in my clients so whether this is one to wear or ignition or factory talk doesn't matter what we're using up here right I've got to do some configuration here for my tags unless were you know my tags are browsable and I can drag and drop them from my OPC server browse my server and drop them in but I've got to configure my tags up here hey these are the tags I want make sure I get all my my address string correct here I got to configure my tags inside my server or do an explicit OPC read through the server and then I've obviously got to write a PLC program out here in the field right so the the way that the server calls out to the PLC's is very much the same way that the client calls the you know in a in a round robin fashion the server can only respond so quickly right so that that's traditional polling where the the server sitting in the middle is the most important thing MQTT uses a pub/sub architecture which is completely different essentially what's happening is all of the data is being pushed to the broker the only thing that the broker does is it sends the updated values of the topics and think of a topic as a tag all the broker does is it keeps a list of all the people of all the topics that are being published though all the tags that are being published to it and all the people who are subscribing to those topics okay so up here what I've got is I have a I have a device that's just a subscriber so in this case let's think that this is a a web application that is connected to the broker in it and his told the broker I'm subscribing to three tags temperature humidity and you know sunlight and the broker just keeps track of those three topics maybe they come from instruments out here and then when they change the broker just pushes those that they get pushed from the instrument to the broker and the broker pushes up to the subscriber only the values that changed okay this is a stateful connection so any of the devices out here that are connected to the broker they're the MQTT is set up so that it's a stateful connection we know that the instrument is connected to the broker in this case we have a pub/sub so this could be something like ignition where ignition is able to publish values to a topic so let's say I have a topic that is hello hello world okay and the value of my hello world is test so if I'm looking at my tag browser inside of ignition and I never get to the tag world in the directory hello and it says test then I change it and I change the value to say well what it does is it public ignition will publish that update to the broker and then the broker will the broker will push that updated value to anyone else who is subscribing to hello world so in our case the architecture that we're using for our demo I'm using I have my broker here in the middle which is a Raspberry Pi 3 I've got ignition running on a server which is out here and in this case I'm not using ignition as a broker although that's very common I'm using it as just an agent I have a arduino that is connected to a temperature instrument a temperature sensor I have MQTT spy running on another server which is just a utility that gives us the ability to talk in PTT and subscribe to topics and update the tags and all kind of stuff and then I have a kept server IOT gateway that's running on another server and I'm going to show you how you can use kept server and MQTT to send tags via mqtt in this case to ignition so the advantage here is that the only thing that's getting sent are the the header itself or the the packets that gets sent over the network are already inherently smaller with mqtt than they are with other protocols much much smaller and the fundamental differences is that we are only the agents the edge devices are only sending the updated values they're only publishing the values that change so let's say that my this is a an r2 you i've got in the field let's say this is a wogo PLC because wogo now has n QT t compliant plcs our team and in telic work with wah go to to use spark plugs to get their their PLC's up and running with mqtt but let's say i've got 100 tags ok and out in my r2 you and three of them just changed so essentially what happens is our agent says hey mister broker I've got hello I've got hello world I have hello all and I have hello mom those three values just changed and I'm going to send the updated values and new value all the way up all three of those get published only three of 100 on a with a package size that's much much tinier than a stand then most packets that you see in industrial communications and then the broker does the same thing only sends those three updated topics out to the subscriber all right so I'm going to want to go over my architecture a little better okay so what I've got is I've got a Raspberry Pi 3 and I've got an Arduino esp8266 with an lm35 temperature sensor at the at the center of my demo here so what I've got on the desk over here you'll have to trust me is I've got my Raspberry Pi I have my Arduino and I have my temperature sensor and they're what and the temperature sensors wired into the analog in on the arduino the arduino i wrote some c code where it connects to the Wi-Fi network and then through the Wi-Fi network it is publishing the updated values it's publishing two topics the first one is a tag called out topic and then the second one is a tag called intel ik forward slash pyramid forward slash temperature or temp and it's and it's publishing those topics to this broker okay which is the raspberry pi the raspberry pi i is publishing all of the topics it's subscribing to some of the topics that we're publishing but it's also publishing the topics out to all of the other agents that are connected to it that are subscribing to those topics so we have ignition we have mqtt spy and we have kept server via kept server IOT gateway now the kept server I only have publishing data to the Raspberry Pi that's all it's doing it's just going to and I'm going to show you how that all works here second down here below is I'm going to show how this translates into an industrial implementation in a moment okay so how did we our project there were basically five steps to build my demo okay and the demo that's running inside of ignition is basically this window that is monitoring this temperature sensor my out topic which is hello world and then it's incrementing and then I've got my kept server IOT gateway tags I down here is the MQTT spy so these are the topics that are being published by the MQTT spy and a topic think of a topic as a tag so over here inside of my MQTT engine this is the mqtt module written by cirrus link I've got my IOT gateway JSON that's coming from kept where I've got my out topic tag I've got my Intel ik pyramid temperature tag and I have my hello world my hello world tags okay so this is this in a nutshell is is the is the demo and I'm going to show you how it's all built and how it works and kind of you know the neatness of it in addition to that I've got I've got ignition is also talking to kept server via OPC UA so if I come down here and I turn on my kep server gateway so if I start the runtime service now I'm I'm also viewing kep server over OPC UA okay so in these tags it's ok see you a and down here the same values of those tags are coming over via MQTT ok and right now I've got a little timer running in every three seconds at updates I'm essentially parsing the JSON and then and then writing those values into a data set and then putting that data set into this tape for now I'm going to go ahead and turn the kep server runtime service off because I keep getting a notification ok right so it was basically five steps got to install mosquito on a Raspberry Pi and NCTC spy on Windows so I've got my Raspberry Pi right here so what I've got running on the Raspberry Pi is mosquito and it's the only thing that's running on here I'm explaining what all these windows are here in a second to install raspberry or to install mosquito I went to switch comm and all this will be and this is the best tutorial I found to install mosquito on a Raspberry Pi was it was a piece of cake once mosquitos up and running there are basically two commands you need to learn mosquitos sub and mosquito pub very very simple to publish to a topic and to also subscribe to a topic and I'm going to show you how that works in a second so I installed mosquito now I just got to stop the server I do a quick update to the mosquito comm I had to restart the server I subscribe to a topic in a new terminal I'm gonna show you that in a minute and publish a topic in any terminal so what we're viewing here is right here this this window right here is where I'm doing all my publishing these three terminals are monitoring subscriptions okay so in this case this terminal right here is monitoring the temperature probe and are the temperature sensor the lm35 so every time it's updating the arduino is publishing to the broker which is the pi and then this terminal is subscribe has subscribed to that topic and so every time the value changes it's going to you'll see a change in this you'll see a change in this sum window and what i'm going to do is i'm going to go ahead and breathe on this temperature sensor and you'll watch the the temperature increase ready alright so the temperature went up to 250 degree or 200 and it's actually 25 degrees centigrade in addition to the QTE spy want to watch into CT spy don't see looking for where is that jar maybe the Downloads sorry it is not okay okay so I'm going to okay so I'm going to create a new connection little B PI and one ninety two dot one sixty eight dot 0.33 okay I'm going to open that connection okay what I'm going to do here is I'm going to put in a hashtag what that means is I want to subscribe to all of the topics that are being published that are all all of the topics that are being published to the broker okay so right now I'm looking at the temperature topic but also I have this out topic that is being published by the Arduino so one of the other things I can do here I'm going to go into my in devine see here is I'm going to go ahead and I'm going to publish an update to a couple of other topics so I'm going to publish Yankees I'm going to publish update to world and I'm going to publish hello all telic and hello mom is another one one of the things you'll notice is that you will not see a new value when when you establish a subscription you won't see a new value until the value changes that there's no there isn't a stateful the broker doesn't send you the the old value it sends you the next change hello mom and we'll just put water in there okay so now if I go back now all I'm subscribing to all I'm receiving the updates from all those tags okay I've also got ignition running and ignition is also subscribing to those tags so you'll see that we received all of these other updates oh the Chicago one that's the other one I need to send the update to so let me go back here all right so this is the mqtt spy which is acting as an agent I've got ignition which is also acting as an agent I have the Raspberry Pi which is acting as a broker and I have the Arduino which is acting as an agent now the broker can also so from within the Raspberry Pi I can create new topics or I can create new topics in MQTT spy so if you look at our ignition our ignition demo here yeah so if you look at our demo here I've got my temperature sensor value and if I heat this up we'll watch that value go up I've got my out topic which is hello world 10:59 which is coming from the Arduino I'm gonna show you that code in a second and then I also have all of the topics that I'm bringing from MQTT spy so right now I've got all Chicago mom New York Texas world so what I'm going to do is I'm going to add a new a new topic and that topic is going to be hello let's do Colorado and we'll put Denver in there so what I'm doing is all I'm doing is I'm creating a new topic inside of hello so once I fire it you'll notice instantaneously ignition is since an ignition we're subscribing to all the topics as well I've got Denver Colorado and if I come here and I run my window and I update here what I've done is I've dynamically updated that object in in my window so think of that topic think of that tag as an instrument the beauty of MQTT is that if MQTT gives us the ability to create self-aware SCADA system so as I plug new agents into the network so as I I have a total flow that now talks mqtt or I have a wah go PLC where I've written a new program and inside my program I am I've defined all my topics which are my tags and I'm and I've configured it to publish to my broker as soon as I plug that PLC in it's going to start publishing the tags to the broker and if I'm subscribing to that broker those tags are going to show up automatically okay so let me let me explain a little kind of a little deeper what I mean here all right so what does a publish look like and actually be easier to show this in the PI so if I want to publish to a new topic so I'm going to create a new topic in the Hello directory from here as well so this is the raspberry pi is also acting as an agent even though it's my broker so I can go a mosquito pub I want to publish debugs I want to publish a new topic it's going to be hello and it's going to be a Florida and I'm the message that I want to publish to that topic is Marlins okay oops need to learn type all right so I just published a new topic and so now obviously it's going to show up in my agents hello Florida Marlins and in my ignition application hello Florida Marlins and if I update here now we've got the Florida Marlins inside of my like my template repeater the point is is that the Florida Marlins could be a device that I plugged in and underneath it it doesn't have to be just a single tag it could be hundreds of tags and I could be I could create a SCADA system that is is staple that is I know that I'm talking I'm talking to all my devices in the field it uses a fraction of the bandwidth that all other protocols use because we're reporting by exception and we're using much much smaller packet sizes and it is self aware it's dynamic and I mean that on the fundamentally that's a game-changer so what it what are the what are the the downfalls right the shortcomings are not everything talks mqtt there's tons and tons of legacy hardware out there that doesn't talk in PTT so right now what we have to do is we have to create gateways and fortunately companies like Alexis so these are the guys that we use primarily know on like it's Alexis Corp so Alexis creates a produces gateways that so we want the ready Gate 400 is what I use so the ready GAE 400 is what we use here so what this what these gateways do is these gateways will convert existing protocols into MQTT and there's basically a an XML configuration file that sits on top of there so think of that XML configuration file as similar to our my code that I've got running in my Raspberry Pi or the code I've got running inside my Arduino which we'll go through in a second the ready gate has a configuration file in there that will consume what we've got in the field coming from our PLC's are to use and instruments and then convert it into MQTT and then the ready gate becomes our edge device not the PLC but companies like WAGO and Red Lion and and you know a bunch of other folks who are in the process moxa and all edges they are producing hardware there is it that is MQTT compliant right out of the box so that means your PLC not only is it going to talk OPC UA or you know or CIP or whatever other protocol it's going to talk but it's also going to talk MQTT and and that is that is that is a game changer I mean that's big big deal so with you'll notice in my notes down below here that's what this looks like ok so right now our demo is is here right it's it's just these five agents all together but with using wah go with em TTT Alexis ready gate with PLC SR to use and instruments on the other side of the ignition edge which is a new release by inductive automation which is a much it's a stripped down version of ignition where you can purchase the mqtt modules so that you can have an ignition HMI out on the edge ignition can be talking to your instruments via various protocols and then it can act as the edge device and publish your tags back up to your central ignition broker that is a these are the three implementation so you know just three of lots of different styles and implementations that we could we could implement to get systems on on to mqtt alright back to our demo alright so we install mosquito on a Raspberry Pi then we set up our arduino this is pretty simple I showed you the picture of you know we basically just have a single sensor going into that Arduino and then I wrote some code the combination of some code I found in some existing projects and and then some custom C code that I wrote but that code is here I'll put this in the blog post as well first thing we do is we connect to the Wi-Fi then we create a es or we SD client a pub/sub client we start all of our mqtt stuff down here the first thing we do is we're going to print to the serial we are going to publish out topic which is we created a topic called out topic and we're publishing hello world to it and then we create I created this topic called Intel ik pyramid temp then I write a 0 into it ok and then down here in the loop all we're doing is reading the sensor reading the sensor right here converting that to a a string and then publishing the value of the sensor to this topic in the loop that's all we're doing it it only updates when the value changes so if I wanted to I could add another topic in here and and run it over and over and over again okay the next step is I install and setup the Cirrus link and PTT modules and ignition so first thing I would do is I went here and downloaded ignition seven nine one and installed it and then I downloaded the Cirrus link modules I did download all four of them but I'm really only using the engine for this demo serious links got great documentation on their website and I use the mdc-t module installation and configuration pieces to get this done I downloaded nqt teespy which is an open source java application that just gave me the ability to create another agent where i could publish and subscribe and do any debug it turned out there wasn't any debug I got that here this was an explanation on how to use it then the last piece I did was I went to kep we're not just to install the cap server IOT gateway so the IOT gateway is an add-on I think this this came out last year I think right before the conference anyways this essentially what this does is this allows kept server to publish tags via an qtt to a broker that's what it does now in in my case I'm consuming those tags in a JSON and I'm going to kind of show you how that that all works that they're kept servers not publishing them as tags into ignition they're publishing them as a single tag and then all the tags are in one JSON and then I'm parsing them there's a couple you would you've got some choices when you're configuring the manual is here and then this is our ignition gateway so when I install the mqtt module from lexus I just went into the MT see Tianjin I set up my Raspberry Pi as a as a broker and then inside my PI I went to namespaces and I created a custom namespace and all it is is a hash tag and what that means is I want to subscribe to all the tags that are on the broker one of the I could put in a filter in here where I could say I only want to subscribe to everything that's in the hello directory or I only want to subscribe to everything that's in the intellect directory but in this case I put hash tag so that I could subscribe to every topic that so anytime the broker receives an update I'm getting that in in my I have a subscription to it and that's literally yes that was that was all I had to do to setup ignition and then as soon as I did that any any topic that's published to the Gateway is I'm going to receive an update on it okay yes I'm going to receive an update not go back here on the ignant kept where I got sidetracked there all right so I'm gonna I'm going to start our run time service I leave it off primarily because I don't have my systems integrator license on this so it it it gives those little annoying pop outs alright so I'm going to go to my configuration it's very very simple to setup the IOT gateway you go you're going to create a new agent ok and then in that agent you're going to identify some some properties so all again all I did was put in the IP address and the port to my Raspberry Pi which is my broker and then under my message I decided to select the advanced template so all this is saying is is what is the format that the message is going to be sent to me one of the beautiful things about a NQ TT is that NCT does not care what your messages there's none it it literally does not care I can send a blob file for sequel through it I can send a sequel query through it I can I can send a JSON that's got you know hundreds of tags inside of them I can send image files if I want to binaries I could send binaries via over the as a payload it doesn't matter what the payload is it and it literally is just you know if there's no authentication like right now I have on anonymous authentication set up so I don't have to put in a username and password every time I try to publish because I'm this is a demo but if there's a no authentication whatsoever then all you have to do is put in the IP address and the and the port and then the topic name and publish to it boom that's simple what so once I did this I once I set up the IOT gateway this this IOT gateway is publishing to the Raspberry Pi and there's no connection direct connection between kept server and ignition ignition receives that IOT gateway from the broker itself because I'm subscribing to everything okay then what I'm doing and I'll kind of show you what I'm doing here so then what I do is there is a the IOT gateway returns control C very annoying cancel so this is what the JSON looks like so the JSON that kept server sending back to me is the timestamp and then values ID is your tag name value is your value this is quality and then this is the timestamp in and I think unix time a cron time I'm a coder but not that much for coder and that's it then that ignition is receiving receiving those tags what I'm doing here is I am then saying go read these tags go read the name of this tag and then I'm parsing the dictionary I'm building a new data set and then I'm updating the tags in this table so what you see here is channel one device one tag one and then the values I have it updating every three seconds or so the thing that excites me the most about this whole process is this whole idea of a self-aware SCADA system that's the piece that really makes me that really gets me excited because in Eden telic we work with we we do the most difficult projects where oftentimes we're coming in behind other integrators that couldn't quite figure it out and we're taking on these massive projects with you know hundreds and thousands of PLC's and you know scores of different integrators worked on the development scores of different integrators and OEMs worked on the development and we have to figure out a way to normalize unnormalized tags you know on nor you know and and and what M TTT will give us the ability to do is essentially create our objects out at the edge on brownfield implementations but more importantly I can take you know with the other ignition modules the other MQTT modules here I could actually read tags from OPC and then use MQTT to turn them into common objects that I can then consume in my in my skater mes and ohyeah implementation okay I'm going to go ahead and shut off kept server because it's driving me crazy okay no stop so I'm going to add a couple more topics in here hello let's use a hello DC and the value will be Congress and we'll do one more hello Ohio and it will be brown all right back to ignition go ahead and update these boom and that is that is the the extent of the demo let me make sure that I covered everything I want to cover kind of close out what I mean here okay yeah so we did cap server and then I configure the ignition window in the template and that's that's the extent of the demo again I'm going to put it I'll do a complete blog post that takes you kind of step-by-step how to pull this off this is at a minimum this will get you started playing with M TTT and I would love to hear from other folks you know how they how they might implement this again you know our our architecture was designed the architecture I did here was really designed to kind of show off how quickly a how quickly mttc responds but also how really we're able to we'll be able to plug instruments in plug hardware in and and have it meet and have it be immediately available the tags will be immediately available for consumption by other applications and this isn't going to be just SCADA at mes oh no EE this is going to be ERP systems and and accounting software and you know the days of you know having you know in oil and gas applications right having roomful of people who are doing nothing but just managing polling rates so that they can rob Peter to pay Paul again I need to rob some bandwidth from over here so that I can update this you know I can pull this casing pressure every five five minutes as opposed to every five hours I mean those days will be long long gone will be able to appropriate those people into places that are in into positions that are you know can help innovate and improve a company's operations so that being said I'm going to make there'll be another demo where I'm going to show you how to use the the ready gate and how to configure the ready gate to end in that implementation I'm going to use ignition as the broker instead of the Raspberry Pi in this case I use the PI because I wanted to use something that had very little horsepower but showed how functional it was but that video will be coming in a couple of weeks again I'm I'm Walker Reynolds with Intel ik integration if you got any questions please don't be afraid to caller my email addresses on the blog page and my cell number and you can find us on Twitter and Facebook and LinkedIn and all those other places all right thanks for watching
Info
Channel: Walker Reynolds
Views: 7,255
Rating: undefined out of 5
Keywords:
Id: 76eJrUGrkIc
Channel Id: undefined
Length: 42min 14sec (2534 seconds)
Published: Wed Mar 15 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.