TIA Portal: OPC UA Methods Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in the previous video from this series about OPC UA in an S7 1500 PLC we discussed OPC UA clients and how they can be useful for controlling an OPC UA server in this video we will offer how an S7 1500 OPC UA client can be used to interact with an OPC UA server that contains methods Siemens offers the OPC UA communication protocol for standardized communication of an S7 control system across all platforms and manufacturers as a firmware version 2.5 and tia portal v15 the somatic S7 1500 control system can now offer OPC UA methods to clients via its integrated OPC UA server this means that you can not only read and write OPC UA variables of the control system but you can also start complex functional sequences via OPC UA this enables almost complete machine to machine communication through the use of OPC UA which can be used for plant networking or plant control from an erp's mes level here is a more detailed explanation of the steps involved one the OPC UA client calls the OPC UA method 2. the OPC UA server receives the call and calls the system function OPC UA server method pre 3. the OPC UA server method pre-system function makes the input parameters available to the user program four the user program runs its custom function code 5. the user program sets the interface parameter to indicate that the code has been executed 6. the user program calls the system function OPC UA server method post 7. the OPC UA server method post system function transmits the output parameters in the status code to the OPC UA client if you find any of this content interesting or beneficial please take the time to like the video but more importantly please subscribe to stay informed of any new updates to this channel to get started create a function Block in several networks to house the OPC UA method code requirements this will allow you to separate the OPC UA code from the rest of your program making it easier to maintain and troubleshoot you will see how to create networks for initialization calling the method pre the actual functionality with error handling and the method post this will allow you to create a complete OPC UA method with all of the necessary space for full functionality OPC UA methods on a somatic S7 controller are simply conventional S7 instructions that can be found in the instruction Library however in addition to the normal program code two instructions must be called within an S7 function Block in order to implement the OPC UA functionality proceed by calling both the method pre and Method post instructions and instantiate them within the function block as multi-instance calls here what you are seeing is a setup of the basic framework of the OPC UA method the sequence of functions follows an initialization server method pre the function area and error handling messages and finally server method post to begin the initialization includes resetting State handling bits along with a status code for OPC UA working with the block interface temporary tags are generated for handling the state of the method creating a structured data type allows the nesting of tags within the block interface but isn't wholly necessary for this purpose go ahead and declare two Boolean tags and one double word for the state handling these are named called finished and result drag the tags to the instructions or find them using the intellisense by typing for the move command use the OPC UA status tags located in the tag table these constants were previously imported into the tag table and are now available for use in code to get these constants visit the OPC UA method application example by Siemens and import the XML file into the tag table this initialization routine is a best practice for any OPC UA method construct and the user constants as shown are based on the OPC UA standard and required for status indication back to the OPC UA client calling the method do note that there are specific requirements on naming for the block instructions and parameter space these are required to generate the necessary components for the OPC UA server to house the method for example the name of the multi-instance must be OPC UA server method post instance for the method to be created in the address space likewise UA method and parameters must be statically declared with this specific tag name and cannot deviate this tag can be composed of a data type or a structure as you see fit after declaring the necessary tags for input parameters go ahead and declare the static area tag with the structure for the output parameters drag these tag structures to align the UA method and parameters with the server method pre also align the UA method out parameters with the server method post moving on we can now create a group of static variables for tracking the server method instruction status and states with a structured tag done busy error and Status are created and used repeating the process create a separate structure for the status of the method post instruction simply copy and paste the tags from one structure to the other the next step is to just align the status tags with the appropriate instruction block while also keeping in mind the temporary tags created previously for the overall handling of the method speed clip here finally it's time to execute the logic of the actual method itself first use the status of the method pre-block being done along with being called this prevents the logic from executing unless the method is actively being called and has received the parameters from the client following this perform an addition of the two parameters and place the summation into the output parameter tag the next step is to perform a move command to the instance for the method pre-status this lets the OPC UA client know the method was called and the parameters have been received the final step is to set the Finish bit to inform the instruction for method post to know when to execute this completes the logical function and Status posting of the method so that's it for the method configuration because we already configured the instruction for method post the last thing left to do is to call the actual function block itself back to the main program ob1 in the previous video we demonstrated how to use the custom server interface for the server so for testing purposes turn on again the cymatic serve interface so the new OPC UA method can be found without any extra effort in later steps we will configure the custom server interface which will demonstrate both interfaces in practice compile the program and assure there are no errors download to the PLC and go online previous videos have already demonstrated the use of the free to download xiaomi application xiaomi is short for the Siemens OPC UA modeling editor the next steps are used to build the connection to the OPC UA server here we will use the xiaomi application to test the functionality of the OPC UA method outside of the Tia portal software demonstrating this proves the method is fully operating before proceeding to program the OPC UA client in a PLC to call the method depending on the size of the PLC and tag quantity structure this can take some time to load the full node set once loaded open the root folder and drive to the objects folder there the folder called Data blocks instance will have the instance data block for the OPC UA method add open this data block instance and find the method notice the green block providing some symbology for differentiating the method itself right-click on the green method object and call it once called a pop-up window will appear showing the input and output arguments edit the values and then call the method to get the response if the arguments do not appear as planned then recheck the naming provided in the static area of the function block the UA parameters in and out must be specifically named so there it's now visible to see the method is functioning as expected and the status code is being returned as good we just demonstrated the use of the cymatic server interface for a brief and easy test now we will deactivate the cymatic server interface previous videos from this series helped to create the custom server interface now we will revisit the existing server interface and add the method to this interface drag and drop is possible but note when you expand the newly attached method there are argument errors this is a known issue in Tia portal v18 this doesn't happen and will generate the arguments without error to remedy this save your work and close the custom server interface window reopen the server interface to see that the error is now resolved adjust the access level of the parameters and download the changes to the plc now for the next portion using a PLC as the OPC UA client to call the method in the OPC UA server we will be building off of the previous video examples find the OPC UA client open the main program and add a new network for the logic to call the OPC UA method open the OPC UA client interface that was previously generated and build the online access to connect to the OPC UA server when the connection is successfully established you will be able to see the server interface table fill with display names within the object type expand to find the server interfaces object and expand again finding the method is easy as it appears in green again with the symbol declare a new method list on the left side of the interface window then drag the OPC UA method instance to this new method list in the client interface the next step is to check the interface for errors and then compile the client plc the client interface DB is shown in the project structure becomes updated with the new method list and Associated elements to begin with a global data block is created to house the required tags for triggering and working with the values needed for the method call here we require two integer tags for moving the added values and one integer tag for The Returned method summation applying start values helps to create values quickly the last thing to add is a trigger for the method call now it is time to set up the logical code that will trigger the routine for aligning the values to the client interface as well as calling the method in the server first set up the trigger followed by two move commands to push values from the global data block into the client interface data space for the method to call a method in the OPC UA server from a PLC client you can use the OPC UA method call C instruction this instruction is located in the OPC UA client folder under the communication tab of the instruction area the C at the end of the instruction name stands for compact compact instructions are easy to use and provide a user interface that helps you quickly configure them for OPC UA integration move the trigger and instructions that were previously on the rung to the same rung as the request so that the request will be triggered by the same event as the previous instructions before we jump into the OPC UA method call instruction we should align the output summation from the client interface to the correct global data block tag now it is time to configure the compact instruction click on the toolbox icon in the top right corner to populate the work area of the method call instruction under the configuration tab go through the list of red circles and use the drop down menu highlighted in pink Chiffon to fix the errors the client interface should be aligned with the previously created client interface 1. then under data access select method list 1 followed by the method inst OPC method add DB note that the connection parameters are already filled in along with the security settings that are assumed by the client interface configuration area finally we made it let's download and test out the full functionality once the PLC is online we can trigger The Logical code to execute first let's see the final summation value before it is updated with the returned value from the method call this value is currently zero modify the trigger to true and check the return summation now it is 30 which checks out as a success if you found this demonstration about OPC UA methods in an OPC UA server helpful I encourage you to check out the application example where more OPC methods are available I found the method for setting PLC time to be particularly useful a link for example 109756885 can be found in the description of this video please join the next and final video in this series which demonstrates the available tools and notes that help with the optimizations of both OPC UA clients and servers
Info
Channel: System-Restored
Views: 5,947
Rating: undefined out of 5
Keywords: OPC UA, TIA Portal, server method, PLC, automation, Siemens, S7-1500, S7-1200, OPC, v17, v18, Wincc, Industrial, Tia, Tutorials, Tutorial
Id: _lO9WrAUCEg
Channel Id: undefined
Length: 22min 30sec (1350 seconds)
Published: Mon Aug 21 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.