Home / FactoryTalk Optix / Optix for Edge
Description
This video demonstrates how to use the NetLogic script, VariableSynchronizer to pass data from one CommStation to another when running FactoryTalk Optix as a service, or “headless.” As an example, this video is using FactoryTalk Optix to send a tag from a ControlLogix controller to a Micro800 controller as a gateway.
To save bandwidth, controller tag values update at runtime only when FactoryTalk Optix Applications display the tag values. If running “headless” this presents a problem to reading and writing to PLC tags.
ModbusTCPToRAEthernetIp from Rockwell’s Public Github repository: https://github.com/FactoryTalk-Optix/ModbusTCPToRAEthernetIp
Transcript
(00:01) in this video I want to spend a few moments showing another method to synchronize variables in vector talk optics if we’re going to go between two different comm stations and in a previous video when I did an example of using optics as a headless unit uh we used a method that was basically creating an an event um like a change event so if there was a change in the value of the variable it would trigger moving the value to another tag um I want to show a different method um in this example so here um from the
(00:38) previous video I was kind of moving data from the micro 800 to the control logics and this time I’m going to go in reverse and just to show you what I’ve got set up here um simply have a Logix program running in my Echo emulator and all it’s doing is creating a sine wave um a period of 10 so um uh and I’m taking the absolute value of that and passing I’m going to pass that basically value or that tag to the micro 800 on the micro 800 I’m basically going to be taking in um I got a value called real01 where I will use optics to move
(01:24) that sine wave into real 01 and then just to show you that something’s actually happening I have my simulator running and I have an analog output card here that will actually show a number so I’m going to take this value and move it into this output right just to kind of show now um so if we go into um optics to make this work I’ve already kind of brought in the tag so all I’ve done is created two um let me collapse some of this here so I’ve created two uh comm stations one is my uh micro controller driver and one is my RA
(02:06) Ethernet IP driver and I went ahead and brought in the tags already there’s not a lot of tags in this program but I have a tag called sine abs which is basically the absolute value of that sine wave if I click on that is a floating point number now what I want to show is I want to take this value and simply move it to the micro 800 and I have my tag here called real01 right now if I click on this it just says zero so if I want to simply move this tag to this tag well I’m I’m I have the real01 highlighted and the properties for
(02:49) real01 the micro 800 tag is is right here i’m just going to take this um sign abs and just drag it and move it up up here so essentially this is saying that hey real 01 is going to be equal to whatever the value of sin abs is now one little other thing to note here to make this work and I want to click on the dynamic link i want to go to advanced and I want to change this direction because right now uh this is showing as a birectional method so basically real 01 can write to the control objects as well as the control objects can write to the
(03:33) real 01 i want to change that to where it’s really only one direction so just by clicking on that little arrow I’m showing the arrow going from here to real 01 and I say close now in the previous video around headless or optics as a service uh what I wound up doing is I w up creating an event down here i went up to um to the plus symbol and I said changed event so that was the previous method and you know that’s that method works fine um just that you would have to do that for each individual tag separately so depending on how many tags
(04:13) you’re trying to move that could become a bit of work now what I want to show is basically how this works so um if you recall from that previous video if you watch that um what we found out is that this this only works um if there are tags on scan on the screen so right now just to to do it I have um I have a screen created and I’m basically showing my control logic’s sine wave value and I’m showing you you know basically what is getting copied over to the micro 800 and to show you that the micro 800 is actually receiving
(04:58) it I’m getting a number here in the emulator but if I move to a screen that doesn’t have the that sign tag on scan well the it no longer moves the current value to the micro 800 so only when the tags are on scan does that actually happen all right so I just wanted to show that now um one thing you could do you know so so one one thing possibly if you’re trying to do this situation again so if you’re running headless you would have no tags on scan essentially so um you know one way to kind of do this was to use that you know changed event
(05:43) method um also I want to just note that if you were kind of data logging then that would actually move the tag as well i do you know basically this the tag is getting read and and data logged so I just want to show this real quick if I create a new data logger and then if I create a new database and it doesn’t matter if I use the embedded or if I use the local influx DB i’m just going to stick with the embedded for right now um and then you know I’m going to go essentially log the control logics tag the tag the sine
(06:21) wave tag that’s getting you know generated in the control logics so I’m going to come here to tags controller tags and I’m just going to log simply this sign abs tag say next now um one thing I want to note too is that the the data logger is going to be logging at a rate of 1 second now if I come back here to my native presentation engine click on that and show the properties um d the dynamic variables are set to 100 milliseconds so if you so uh so I just want to note that here because what you’re going to see
(07:00) happen next is going to be kind of interesting so um so all I’ve done is created a data logger and an embedded database and I’m logging that control objects tag so let’s go ahead and bring the emulator back online and again it goes the other window so right now you know we’re we’re tags on scan things are updating now if I were to switch to screen two you’re going to see that it is continuing to update to the micro 800 but at a much slower rate and that is because it’s because it’s being um logged at once per second whereas
(07:47) here we were updating our our tags at um 100 milliseconds right so if I’m logging a value then it will be getting updated uh even if it’s working as a headless device uh and it will pass you know the values on to the to the other comm station now um next what I want to show you is kind of you know uh the the uh the other method and I’m going to go ahead and delete these um going to go ahead and delete the the data logger and the embedded uh database because we’re not going to really need that at this point now um what I want to
(08:31) show you is something that came out of the GitHub sample code library um so if you go to you know Rockwell has a public GitHub repository with a lot of optics examples so one of those examples is a Modbus Ethernet IP example and the reason why this is um significant and I know we’re not doing Modbus here we’re doing you know basically control objects to micro 800 but what this sample project does is it has a um right here uh it has a a net logic or a C script that’s called variable synchronizer and essentially this this
(09:18) is a a C script that will run in the background that will basically synchronize the tags and the beauty of it is there’s really nothing for you to do to that logic to the to the code or the script so if you are not familiar with GitHub you can come here to this green code button and if you are using the free version of Optics Studio then you could just simply download the zip file unzip the folder and then just open it up right in Optic Studio if you’re using the pro version of Optics Studio then you can copy and
(09:59) paste this link and open this up as a remote repository basically so I’ve already got that open and I have it in another program here another optics session so just to kind of I’m going to minimize some of this stuff to uh to kind of avoid the confusion now this what this example program does is it already had set up two con drivers one is a Modbus driver and one’s an Ethernet IP driver and all they did was they they had some tags here you know bool zero bool one bool two uh double integer 012 and then in the mod bus they have um
(10:41) modbus station and tags and they had a couple of tags here now if I clicked on like say the if I go to the control objects station and I click on bool zero we just see that it’s false and you know it’s basically reading the values from the control objects if I click on the bool zero here under the mod bus station it’s essentially linked back to this bool zero so what they’re doing is they’re taking this value here and copying it or moving it into the modbus tag so the that’s the same thing we had just did basically um going from the
(11:22) control objects of the micro 800 uh but what’s new down here is this net logic and that is uh right here this variable synchronizer um script and if I just click on this to get the properties the way how this works is it’s kind of a parameterized uh C uh program and all it wants to know is where are the tags that I’m going to synchronize coming from and so it’s basically tags to sync that’s what this little identifier here is called and then uh if I click on the dynamic link just to show you where this is linked to it’s
(12:04) actually linked right to the Modbus driver in the tags folder and again those are the tags in the tags folder now what’s kind of nice about this is I can take this this C script right out of this sample program if I can just copy this I’m just going to say copy now I’m going to go back to my other optics application so this is my um this is the one I was just working with so I’m going to come to my net logic folder i’m just going to rightclick and I’m going to say paste and now my variable synchronizer is here now note that the tags to sync
(12:51) is unresolved so to resolve that I’m going to essentially point this to the tag folder of the tags that I want to sync and that’s basically going to be the micro800 tag right because again I’m taking I want to take the value from the control objects and move it to the micro 800 so I’m going to use this tag folder right here so I can take this tag folder and essentially drag it to right there and that’s actually all I have to do now if you do want to see what this script looks like if you have um you know if you if you do have uh like Visual Studio
(13:36) Code on your computer you can click that little button there and that’ll open up this code editor and this is uh this variable synchronizer.cs CS and it’s basically some C# scripting and again um you don’t have to do anything to the code here which is good because I can’t claim to be really anybody who’s really strong with C um so but we don’t need to have uh we don’t need to change anything here and we can go ahead and close that down so um just to refresh where we’re at we have um you know we we got rid of the
(14:16) data logger and the embedded database and we’re still moving sign abs into real01 and we now have our net logic that is going to be basically taking the tags out of the micro 800 and synchronizing them all right so we go ahead and we can go ahead and run the emulator and we can watch this work all right emulator is open now again um this is the tags on scan page so everything is working great if I go to screen two my tags are continuing to update at the 100 millisecond um sample rate so again that was pretty nice i
(15:07) didn’t have to do anything now um we did say originally you know about the idea of being headless to be a headless uh version of Optics we wouldn’t have a native presentation engine at all so if I go ahead and delete this native presentation engine just get rid of that all together so now when I run the emulator there will be no screen to show and we can see once it gets running that now it’s updating so basically the control logics tags are being passed right into the micro800 i don’t have any HMI component here at all
(15:49) it’s acting completely as a headless gateway or um acting as optics as they say optics as a service uh another way they they kind of call that so um stop the emulator and you can see that we have stopped updating our tags so just wanted to show that um so we can you know a couple ways we can do this we can you know one use that you know change the vent method which essentially means we have to go configure each tag separately um we if we are logging data to our database then we don’t have to really do it either uh we could you know
(16:28) because it’s actually the tag is getting updated and logged um that also works if you’re going to be passing it on to like an MQTT or into um you know OPCUA as well um or we can go and use that variable synchronizer C script uh that comes out of the uh sample code library um off of GitHub all right hope this was helpful um you know if you have some other methods that you’ve learned you know one question might be you know which one’s the better way to go um you know change on event versus this variable synchronizer um I honestly
(17:08) don’t know if I know the answer to that so perhaps you know out there in the community if you guys are um kind of experimenting with this maybe you can determine which method is the better way to go and share your comments
