Modbus TCP Communications

Home / FactoryTalk Optix / PLC Communications

Description
This video walks through the steps to configure Modbus TCP communications between FactoryTalk Optix and a Micro820 PLC.


Transcript
(00:01) this video I’m going to show how we can connect Factory talk Optics to a micro 800 PLC such as the micro 820 using the modbuz TCP driver at the time of this video being recorded the latest version of Optics is what’s shown here on the screen uh 1.2.0 one that supports ethernet is using the modbus TCP driver um for our Logics controllers such as the control Logics and compact Logics we can use the native ethernet IP driver and connect uh to the ethernet port that way but in the micro 800 or if we’re going to use a micr Logics 1400
(00:50) modus TCP is our current method of doing it in a future release um of fect talk Optics you know Rockwell will plan to have a more native communication uh directly to the micro 800 plc’s but again in our current current release it is only going to be modbus TCP available to us so with that said let’s kind of show how we would do this so first I want to go to my micro H20 uh CCW software so I actually have a real micro 820 PLC sitting here on a desk um I’ve shown like the logic Echo emulator in some other videos it should
(01:29) be noted that the micro 800 simulator which is the micro 850 Sim does not support modbus Communications to the simulator so I have a real micro 820 PLC that I’ll be connecting to and running this logic in and and treating it as a modbus tcv server so if you’re not familiar with the CCW software and for the micro2 PLC the main thing we have to configure is we have to tell it so under the ethernet settings here I need to check the modbus TCP server State as enabled so that’ll enable the modbus tcv server uh I do give it an IP address the
(02:16) same IP address that I’m using to connect to the controller and then the other thing I need to do is I need to map my modbus addresses so there’s another setting another tab here called modbus mapping and I just basically we’ll choose add and then I can pick the tag out of the list out of out of all the uh the tags available I can pick the tag and add it to the modbus mapping table so I already kind of pre-built it so I have several different types of tags here I’ve got a couple Boolean tags that are um using the uh the zero function code I
(03:00) got uh the um basically I’m going to be able to write these are coils so I’m going to be able to write to these and turn on and turn off this pump remotely using Optics I have a a discret input coil uh register I should say that’s pump motor that’s my one1 and then I have a couple of holding registers here with integer values and just going to kind of generate some random uh flow data and temperature data just kind of create some numbers randomly and let them be read by Optics so uh so I’ve got some basic logic here uh real simple uh latch
(03:48) circuit that just has the remote start and the remote stop so my Optics application will control the start and the stop um bits and then we’ll be able to monitor the status of the pump running U coil here and then uh I have my test flow rate my test temperature I’ll be reading these um back in Optics through those holding registers so I’m going to go ahead and get connect it to my controller and uh have that way I can kind of watch this logic here in a little bit so while that gets connected we’ll come back here to Optics so I’ve gone
(04:32) ahead and created some of the structure required uh to save a few minutes and mainly in the uh in the UI or user interface I’ve kind of created the the main window um and I’ve created a couple of pages one called pump one and one called micro 820 so under my pages I have microw 20 I’ve pre-built this one just to kind of be a little bit of a reference sheet for us that we can pull up in in the project again I’m looking at what registers mod registers are available to me uh zero for coils one for discrete inputs three
(05:10) for input registers and four for holding registers I’ve got the IP address of my uh microw 20 PLC as a reference here 1010111 and we will um need to tell it what port which is 502 which is the port for modbus TCP and then here are those tags that I’ve mapped I just kind of took a little snippet of what I had there in CCW and just put it here as a reference so this is nice because it gives us our addresses for each of these um each of these variable names all right page and then the other page we have here is called pump one
(05:49) pump one will be where we’ll kind of add some some objects to to interface with our micro early 20 so what we need to do of course is we need to configure the communications driver we haven’t done that yet so again there’s two ways to do that I can right click oncom drivers and say new and then add a modbus driver or I could go back to my dashboard and use the wizard but I haven’t shown this method so let me go ahead and right click I’m going to say new modbus driver now uh nothing happens here in in this dashboard area but underneath the
(06:30) com driver I I have the modbus driver one was added so now I need to right click on this say new I’m going to say add a new modbus station so modbus station one so over here in the properties for modb station one I have the name which I can change I could call it micro2 um to make it a little bit uh easier to uh to keep track of and I think I’ll go ahead and do that I’ll just put a TCP behind it we have a couple options here for things like tag optimization swap bites swap words swap double words and each one of these gives
(07:12) you a little bit of a help explodes out according to Rockwell’s knowledge base they do suggest that you you change the swap words to false so I’m going to go ahead and do that um based on their advice and the only other thing I need to do here is I need to make sure that I give the IP address for the the uh microa 20 so I’m going to type in that 1010111 and the port was uh defaulted to 502 and that is good we don’t need to change that so I’ve just set up my uh my mod bus station next step is we need to add the
(07:55) tags so if I were to expand this we’ll see there’s a tags folder types folder there are no tags now when we’re doing the Logics uh driver and in some other videos when we when we were able to create um an ethernet IP driver we were able to automatically import tags from the controller uh in this case being it’s modbus there is no import of tags either offline or online so we’ll have to create each tag individually so we’ll right click on tags we’ll say new and modbus tag now we can change our names up here so the name of the tag by default
(08:43) was modbus tag one if you recall if I come back to my CCW project uh we had five tags or so here we had a remote start remote stop pump motor basically the uh motor’s running the pump’s running we had a flow rate and a temperature so let’s go ahead and create um let’s go ahead and create the um the start tag so I’m going to say start and we need to tell it you know what is its data type so in this case start is a bit so it’s a Boolean and we’re going to we’re going to select Boolean and hit uh and there the other thing we going to do is
(09:32) you got to tell it what’s the memory area so these are our options again holding register coil input register or discrete input in this case I’m going to send the right command to this start bit in the controller so I’m going to choose coil the only other thing I need to do this this point is give it the coil number now this is where it gets uh just slightly tricky um here in the microw 20 I have uh my start at 0 01 now microwave 20 you you one is the is the the starting point there is no zero but in Optics it’s zero so we’re going to be
(10:22) kind of offset by one basically so we’re going to leave this set to zero in order to read that 0 01 register the only other option here is element U or the array so if it’s an element or if it’s an array this is not an array so we’re going to leave it at element so start is created I’m going to right click say new tag this time we’re going to call this one stop once again I need to make sure that this is a Boolean I need to change this to coil and this time I’m going to make this a one because once again I’m going to be
(11:03) reading 00002 our next one is pump motor or pump running basically and this time we’re going to be reading the discreete input which is the uh the register one here so we come back to Optics we’ll create another [Music] tag oops uh pump running and one more time this needs to be a Boolean we H select and this time we’re going to choose a discrete input so discrete input um that that’s going to be our function code one we can leave our dis discrete input uh Reg register at zero because again we’re starting at 1 01 so we can leave this as a zero and we
(12:05) can leave element the way it is that leaves two more um two more tags to create flow rate and temperature both of these are integers and both of these are tied to our holding registers 40000 1 400002 so we’ll right click on tags we’ll say new modbus tag this time I’ll call this one the flow rate I need to change this from an integer 32 to an integer 16 so integer 16 is basically an integer whereas integer 32 would be a double int or double integer so I want to make sure we pick integer because back here in our micro2
(12:55) it is an integer and not a dent not a DT it is an integer so integer 16 holding register is the right selection here and now our register number same thing with the offset so we’re going to stay with zero now that we’re a holding register we also have a bit offset we don’t need to worry about that and then we’re going to leave this as element and one more to create that is new modbus tag this time we’ll call it temperature make sure we make this an integer 16 keep it holding register and this time we will be offset by
(13:44) one because again our temperature is 4002 all right so that’s all we have need to do to set up the modbus driver and the tags so now we can come back to our pump one the display and we’ll start to put some objects on here to interface with our controller we’re going to uh right click on that pump one we will say new base controls and we’re going to add uh first thing we’ll do is We’ll add a switch we’ll use a switch for this all right so this kind of this will be our start so let me go ahead and add a label just so
(14:26) um we can keep track of this so this will be our pump start misspell that and then I’ll go ahead and copy this paste it and we’ll have our we’ll call this one pump stop now most likely you wouldn’t use a slider for your start and stop but it’ll serve its purpose for demonstrating one other thing we’ll do is we’ll go ahead and add a an LED display that way we’ll just get a visual indication that our pump is running I’ll copy this label paste it and we’ll just call this pump running
(15:31) all right so all we going to do now is we need to tie these elements to their various tags so we’ll start with the LED first since that one’s fairly uh easy to do and what we need to do is we basically need to tie it to um we’re going to tie it to the element active here you can see we have uh lots of options you know come to properties such as uh changing the color and the size and the appearance we can go from circular we can make it rectangular as well if we if we want um but active basically means that you know when it’s
(16:08) when it’s on or off so we’re going to tie this to the dynamic link we’re going to scroll down we’re going to find our com drivers our modbus driver one our tags and pump running all right so then we’ll come to our first slider this will be our start slider the one that will turn on the start um what we’re going to do is we’re going to we need to add a uh an event since it’s a you know it’s an actionable uh you know device just like a push button we’re going to uh hit the plus symbol there we’re going to say commands
(16:53) variable commands we’re going to do a toggle and then the variable to modify we’ll hit Dynamic link we’ll scroll down we’ll find com drivers modbus TCP tags start and then the stop will’ll do the same thing commands variable toggle variables to modify scroll down com drivers mod bus tags stop and then if we want to just display the values of our flow and our temperature we can do that by right clicking saying a new base controls label and we we can tie our
(18:01) label we get the text of the label we can tie it to the dynamic link and the dynamic link can be once again our under our com drivers tags this time we’ll do flow rate and then I’ll copy this and paste it and this time I’ll just update the dynamic link to be temperature all right so we have our base um kind of our base elements here our driver set so we’re ready to test this out now so um I’ll save my project and we’re going to use the emulator once again here so I’m going to start my emulator so there’s my emulator are
(18:59) running um I have my two screens here so the micro820 screen is all the details of the project the pump one screen is the things I just created I’m going to go ahead and uh bring my project CCW project backup I’ll come here to the live logic so as you can see already that I’m getting uh numbers updating for my flow rate and my temperature I didn’t label these but we see 97 998 784 792 so these are updating properly so if I were to now toggle my pump start bit and there it actually started so this is a maintain slider so I need to
(19:49) kind of turn it back off and that it just dropped out uh my pump is running because I have it latched in and now if I were to slide my pump stop and that now toggle and I need to go ahead and toggle it back off in order to bring it back to the uh to the initial state so that’s it modbus fairly straightforward and simple to set up and use with the micro 820 PC