As we all know that LabView is a software which is used for designing and development environment for a visual programming language and is from National Instruments. LabView has found its use in many places and many of the engineers are making their design on LabView. In Automation industry we use different-different devices and software to implement or projects and OPC server (OLE for Process Control) is one such very useful software or protocol which is widely used. In this tutorial we will guide you how you can communicate LabView and PLC through an OPC server. Subscribe to Automation-Talk by Email.
1. PLC [we are using Allen Bradley Micrologix 1000 PLC here]
2. LabView 2012
3. OPC server [Kepware]
4. Communication cables.
Let me tell you that we can use LabVIEW as an OPC client by connecting to an OPC server through a DataSocket connection and we done same and communicated OPC server and LabView through DataSocket VI. In this tutorial we are using Kepware OPC server for communication.
The DataSocket palette in LabVIEW:
Below is the picture of DataSocket palette in LabView which shows you different buttons for performing different task as explained below.
DataSocket Display URL: Displays a dialog box for the user to select a data source and returns the URL to that data.
DataSocket Open: Opens a data connection you specify in URL.
DataSocket Read: De queues the next available data value from the client-side buffer associated with the connection you specify in connection in and returns the data.
DataSocket Write: Writes data to the connection you specify in connection in.
DataSocket Close: Closes a data connection you specify in connection id.
LabView and PLC communication through OPC Server
Now lets start with communicating PLC and LabView through Kepware OPC server. OPC has some standard URL format which looks like opc://machine_name/server_name/item_name.
Here in following we use KEPware.KEPServerEx.V4 OPC Server and channel name is a; device name is b; and tag name is t0. So; OPC URL is as following;
If you know URL in advance, then you can directly use that URL with DATASOCKET OPEN VI. This VI opens a data connection we specify in the input URL as below.
Read OPC Data
Use DataSocket Read in order to get data from a specific Item in the OPC server as below.
We can also read by using URL directly like below.
WRITE in to OPC Data
You can use DataSocket Write in order to write data to a specific Item in the OPC server. In order to write data to an OPC Item it must have the Write property set.
We can also write using the specific URL directly like this:
Now after making all the setting you can test your PLC and LabView, below is the video of same. You can write a simple ON-OFF program for PLC.
This communication is done by one of our Facebook Fan page Vijaysinh Rahevar and we are very thankful to him. If you also want to submit your tutorial, just get in touch with us on Facebook.