Opc Matrikon Tutorial
Opc Matrikon Tutorial
Opc Matrikon Tutorial
for
Industrial Agility
Introduction to OPCTutorial
This manual is a product of Matrikon Inc Matrikon Inc.
#1800, 10405 Jasper Avenue Edmonton, Alberta T5J 3N4 Canada
Revision History:
Date 2002-10-31 2002-11-08 Version 1.0 1.1 Description Initial Document Revised & reformatted Author Initials LE
The information contained herein is confidential and proprietary to Matrikon Inc. It may not be disclosed or transferred, directly or indirectly, to any third party without the explicit written permission of Matrikon Inc. All rights reserved. No part of this document may be reproduced, stored in a retrieval system, translated, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without prior written permission of Matrikon Inc.
Table of Contents
1 Introduction.................................................................................................................................................................... 1 1.1 1.2 1.3 2 3 4 Overview of Matrikon OPC Tools................................................................................................................................ 1 Downloading and Installing Matrikon OPC Tools ...................................................................................................... 2 Tutorial Overview....................................................................................................................................................... 2
Step 1: Creating Sample Data in Excel............................................................................................................................ 3 Step 2: Configuring the DDE Server................................................................................................................................ 4 Step 3: Connecting OPC Explorer .................................................................................................................................... 8 4.1 4.2 4.3 4.4 Configuring OPC Explorer .......................................................................................................................................... 8 Creating a Share Group ............................................................................................................................................. 9 Adding and Validating Tags..................................................................................................................................... 10 Testing the Connection Between OPC Explorer and the DDE Server ........................................................................ 13 Configuring OPC Data Manager............................................................................................................................... 16 Configuring OPC Simulation Server......................................................................................................................... 18 Testing the Server Configuration.............................................................................................................................. 22 Problems and Solutions ........................................................................................................................................... 24 Questions and Answers............................................................................................................................................. 27
Step 4: Linking Data Between OPC Servers .................................................................................................................. 16 5.1 5.2 5.3
1 Introduction
Matrikon OPC is the name given by Matrikon to its OPC-compliant components, which include OPC servers and OPC clients.
This tutorial is designed to guide you through the use of the following Matrikon OPC tools, which must all be installed on your computer:
OPC Server for DDE OPC Explorer OPC Simulation Server OPC Data Manager
The Matrikon OPC applications listed above are all available for download for evaluation purposes (see section 1.2). In addition to the Matrikon OPC tools listed above, you must have Microsoft Excel installed on your computer in order to complete this tutorial.
1.1
1 Excel
In Figure 1-1, the process control system is arranged as follows: 1. Microsoft Excel acts as the data source. All of the process control data is read from and written to Microsoft Excel. 2. The OPC Server for DDE connects Microsoft Excel to the OPC client.
1 TutorialIntroduction to OPC 11/19/2002
3. OPC Explorer acts as the data sink. It reads data and commands, and writes data back to Microsoft Excel. 4. The OPC Simulation Server connects to a sample device or sample application. It transfers random data that will be read by OPC Explorer:. 5. OPC Data Manager connects the two OPC servers. Sample tag values are be shared between these two servers.
1.2
OPC Explorer: http://www.matrikon.com/drivers/opc/explorer.asp OPC Server for DDE: http://www.matrikon.com/drivers/Details.asp?NameListID=732 OPC Simulation Server: http://www.matrikon.com/drivers/opc/simulation.asp OPC Data Manager: http://www.matrikon.com/drivers/opc/datamanager.asp
To install these each software package, follow the instructions that accompanies each download. All of these downloads are meant for demonstration purposes only and so will only work on you computer for a limited time. After the demonstration period has expired, the software will cease to operate until a registered version is installed.
1.3
Tutorial Overview
The exercises in this tutorial describe the function of each Matrikon OPC application while guiding you the process of configuring OPC Server for DDE. Working through this tutorial will help you troubleshoot software installation by highlighting where problems may occur when connecting OPC software applications. This tutorial show you how to configure the OPC Server for DDE using the following steps: 1. Use Microsoft Excel to create sample data (see section 2). 2. Configure the connection between the DDE Server (using OPC Server for DDE) and Microsoft Excel (see section 3). 3. Configure OPC Explorer to read and write values to and from Microsoft Excel using the DDE Server (section 4). 4. Connect the OPC Simulation Server to OPC Explorer and connect the two OPC servers using OPC Data Manager (section 5).
In the sample data, this represents simulated values as follows: FIC101 represents the Flow Controller 101 PIC204 represents the Pressure Controller 204 TIC306 represents Temperature Controller 306.
The values in the second column represent sample values in the plant. When you have entered the values, your spreadsheet should look like the one shown in Figure 2-1.
Matrikon icon and select Configure from the shortcut menu that is 2. Right-click the displayed (Figure 3-1).
The Matrikon OPC Server for DDE Configuration screen appears (Figure 3-2).
3. In the Current Configuration list of the Configuration screen, select Alias Configuration. When you do this, the contents pane on the right of the window appears, indicating that no aliases have been created. 4. From the Edit menu, select Insert Alias Group. Alternatively, you can right-click Alias Configuration and select Insert Alias Group from the shortcut menu that is displayed, as shown in Figure 3-3.
An alias group folder called New Alias 1 appears beneath Alias Configuration in the Configuration screen (Figure 3-4). The contents of the new alias group, currently blank, is shown on the contents pane at the right of the window.
5. Select the new alias group (New Alias 1). From the Edit menu, select Insert New Alias as shown in Figure 3-3. Alternatively, you can right-click in the contents pane at the right of the window and select Insert Alias Group from the shortcut menu that is displayed.
The Insert New Alias dialog box allows you to reference specific values in the Microsoft Excel file with the DDE Server. 7. For each tag value in Book1.xls, insert a new alias as follows: Name: Tag name (e.g., FIC101). Item Path: The Excel cell reference (e.g., excel|[book1.xls]sheet1!r1c2 for the value). In Excel, the pipe (|) is used to separate the file name (book1.xls).
Note: This text is formatted according to Microsoft Excel requirements, not Matrikon requirements, and
may be different for other DDE applications. Make sure that you have spelled the file name and item path correctly or they will not be found.
Leave the rest of the fields with their default settings. The Insert New Alias dialog box should now look like Figure 3-7.
Figure 3-7. The Insert New Alias dialog box with a file referenced.
8. Click Save to save the alias, or Save & Create New to save the alias and enter another alias. When you have entered all the aliases, the Configuration screen should look like Figure 3-8.
The OPC Server for DDE is now configured properly and is now connected to Excel. This means that any OPC client, such as OPC Explorer, can connect with the DDE server using OPC.
OPC Explorer is Matrikons full-featured OPC client designed to help with the installation, testing,
This section shows you how to use OPC Explorer to interface with the DDE server. You will start off by opening OPC Explorer and connecting to the DDE server (section 4.1). Then, youll create a share group in which you will create tags to hold the data (section 4.2). Once the share group has been created, youll create and validate the tags (section 4.3). Finally, youll check the connection by changing the tag value in OPC Explorer and seeing the change appear in the Excel workbook, Book1.xls (section 4.4).
4.1
OPC Explorer starts (Figure 4-1), showing the file names of the OPC servers successfully installed to your computer on the left side of the window. The DDE server you installed in section 3 should now appear on your list (Matrikon.OPC.DDE.1). If it does not, contact Matrikon support (www.matrikon.com/support).
2. Right-click Matrikon.OPC.DDE.1 and select Connect from the shortcut menu that is displayed (Figure 4-2).
8 TutorialIntroduction to OPC 11/19/2002
You can confirm that the connection has been established by comparing your OPC Explorer window with Figure 4-3. In the bottom pane, Connected should be followed by Yes.
4.2
Figure 4-4. Right-click the DDE server and select Add Group.
9 TutorialIntroduction to OPC 11/19/2002
The Add Group dialog box appears (Figure 4-5). 2. In the Group Name text box, enter group1, and then click OK.
The OPC Explorer window now displays the group you created for the DDE server.
4.3
Figure 4-7. Right-click the DDE server and select Add Item.
10 TutorialIntroduction to OPC 11/19/2002
2. In the Available Items list, double-click the Configured Aliases folder to open it and view the New Alias 1 folder it contains. 3. Click the New Alias 1 folder. Note that the Excel tags, for which you created aliases in section 3, now appear in the Available
Tags list.
4. Double-click the top tag. The tag name appears in the Item ID field near the top of the window (Figure 4-9).
5. Click
to transfer the tag name to the Tags To Be Added list (Figure 4-10).
6. Select the tag in the Tags To Be Added list and then, from the File menu, select Validate Tags (or click ).
If OPC Explorer can read the tag from Excel, the blue question mark checkmark (Figure 4-12).
changes to a green
12
TutorialIntroduction to OPC
11/19/2002
If OPC Explorer cannot read the tag from Excel, the blue question mark changes to a red X . If this happens, check that you have entered the correct Item Path when creating the alias in section 3. 7. Repeat steps 4 to 6 for the remaining tags. 8. Click to close Matrikon OPC Tag Studio and update Matrikon OPC Explorer.
Matrikon OPC Explorer now shows the tags as Active, with the sample values you originally entered in Excel.
4.4
Testing the Connection Between OPC Explorer and the DDE Server
To test the connection between OPC Explorer and the DDE server:
1. In Matrikon OPC Explorer, right-click the top tag (.FIC101) and select Write Values from the shortcut menu that is displayed (Figure 4-1).
2. Click the New Value box and change the tag value from 1550 to 1600. Then click OK. The value displayed in OPC Explorer and in the Excel workbook (Book1.xls), is now 1600 (Figure 4-16).
OPC Data Manager is a software application that transfers data from one OPC server to another. OPC Simulation Server generates random, ramped, and stepped values, as well as a unique bucket
First, you will configure the OPC Data Manager (section 5.1) and the OPC Simulation Server (section 5.2). Then, youll test the server configuration to ensure that data read and written to and from the OPC Data Manager appears in Excel (section 5.3).
5.1
2. Right-click the Data Manager icon and select Configure from the shortcut menu that is displayed (Figure 3-1). Note: It may take a few seconds for the Data Manager to start and for the icon to appear. If you click the icon again, a second Data Manager instance will start. If this happens, make sure that you close one of the windows or the Data Manager server will not function properly.
The Matrikon OPC Data Manager Configuration screen appears (Figure 3-2).
3. In the Data Manager Groups pane, right-click and select Add Group from the shortcut menu that is displayed (Figure 3-1).
The Add Data Manager Group dialog box appears (Figure 5-4).
4. In the Group Name box, type group1, and then click OK. The group, group1, now appears in the Data Manager Group box (Figure 5-5).
5.2
Matrikon icon appears in your system tray at The OPC Simulation Server starts and the the bottom left of your screen. The Simulation Items folder appears nested within the OPC Simulation Server.
18 TutorialIntroduction to OPC 11/19/2002
2. Click the Simulation Items folder to open it, and then click the Bucket Brigade folder nested within it. The Bucket Brigade folder opens, displaying numerous tags (Figure 5-6).
3. In the upper left pane of the Data Manager window, click Matrikon.OPC.DDE to open the folder, and then click to open the Configured Aliases folder and the New Alias 1 folder nested within. The tags created in section 4.3 are displayed within the New Alias 1 folder (Figure 5-7).
4. Drag the first tag, FIC101, and drop it in the Bucket Brigade folder (Figure 5-8).
5. In the Input OPC Server area, type the name of your input server (e.g., Localhost \Matrikon.OPC.DDE) in the Server Name box. 6. In the Output OPC Server area, type the name of your output server (e.g., Localhost \Matrikon.OPC.Simulation) in the Server Name box. 7. In the Output OPC Server area, type the name of a tag that allows read and write (e.g., to browse the tags (Figure 5-8). Bucket Brigade.Int1) in the OPC Item box, or click
Figure 5-10. Define the OPC Item in the Add Shared Point dialog box
8. Click the Options tab to display the Add Shared Point Options window. 9. Select Bidirectional to allow data values to be written from one server to the other (Figure 5-11)
10. Click OK to save the settings. The tag values are now shared between the DDE server and the OPC Simulation Server (Figure 5-12).
Figure 5-12. The tag values are now shared between the two servers.
5.3
2. In the Value box, type 1550, and then click Apply. The tag value in Excel has changed (Figure 5-15).
6 Troubleshooting
This section addresses common problems and questions you may encounter while doing this tutorial or using Matrikons OPC tools. The section is divided into Problems and Solutions and Questions and Answers. Please check this section before contacting Matrikons Technical Support.
6.1
OPC Server Stops Updating Client After Two Hours Problem: Solution:
The OPC server stops updating the client with item values after two hours. The OPC server is licensed with a hardware key, and the demonstration period for the server has expired. Check that the correct HASP hardware key is securely fastened to the parallel port. If it is, run the HINSTALL program that is located in the MATRIKON\COMMON directory under Program files with the /I parameter.
HKEY_CLASSES_ROOT\PSTCFGMatrikon.OPC.{server name}.1\CLSID\
and create a string value named LockServer. To create a new value, select the Options key, and then select Edit\New\String Value from the Registry menu. Set the value of the LockServer entry to 1. To edit the value, select the entry and select Edit\Modify from the Registry menu.
Matrikon technical support (www.matrikon.com/support) to obtain a HASP key containing the combined codes of all installed Matrikon OPC servers.
HASP keys from the same vendor cannot be chained together. Send an email to
Microsoft Internet Explorer 4.01 (or later) must be installed to use the .XML format. If you do not have this software, you can still save the configuration in .PXC format, which is the original Matrikon format.
OPC Server Does Not Appear in OPC Client Application Problem: Solution:
The OPC server does not show up in a list of locally available program IDs in the OPC client application Make certain that a user with local administrative rights installs the OPC server so that it can make the necessary entries in the registry. Also, especially for older OPC clients that do not use the OPC Server Browser, ensure that the client is running as a user that has read access to the registry. The OPC server does not show up in a list of remotely available program IDs in the OPC client application Follow the steps found in section B.1 (in Appendix B) to copy the program ID from the server machine to the client machine.
Problem: Solution:
Solution:
Either set the identity for the OPC server to the interactive user, or consider running the server as an NT service. See section A.2 (in Appendix A) for more information..
6.2
Table 6-1. Command Line Parameters for Matrikons OPC Server for DDE
Description Registers the OPC server to run as a local executable, uninstalling the NT service if necessary. Registers the OPC server to run as an NT service. By default, the service is set to run as the System account as an interactive process. Removes all registry entries for the OPC server, uninstalling the NT service if necessary. Starts an instance of the OPC server as a local executable. It is preferable to start the server up from the configuration utility or another OPC client instead of from the command line.
Does the server need to be started manually when it is installed as a service? Answer:
No: the first OPC client that tries to connect will start the OPC server.
How can I get OPC data into Microsoft Excel, Microsoft Word, or another application with support for Visual Basic, VBA, or VB Script? Answer:
Use the Matrikon OPC Automation Component to create a Visual Basic script that connects to a server, creates groups and items, and receives data change updates. See the installed files for examples of how to do this in Excel, Visual Basic, or an HTML document.
Note: The following steps are suggestions only. Ask your Windows NT System Administrator for more
information about the settings that you should use, especially between different domains.
Note: DCOM settings are stored in the registry and loaded by COM (and OPC) servers at start-up.
You must shut down and restart server processes in order for these changes to take effect.
3. Click the Security tab to set the security for the server. The Security window appears.
The Access Permissions contains an Access Control List of principals that are allowed to interact with objects supplied by a server. The Launch Permissions contains an Access Control List of principals that are allowed to start up a server process or service.
These permissions should include the names of users or user groups from trusted domains that you wish to be able to access or start the OPC server on this machine, and the Everyone group if you want to allow all users on a particular domain to access or start the OPC on this machine. 4. To set the Access permissions, click Use custom access permissions , and then click Edit. The Registry Value Permissions dialog box appears.
5. To add users to the list, click Add. The Add Users and Groups dialog box appears.
6. To add a user to the list, click the user, and then click Add. If the user you want to add does not appear, then click Show Users. 7. When you are done adding users, click OK. You can then allow or deny access for each user by selecting each user and choosing Allow Access or Deny Access from the Type of Access drop-down list box. 8. Repeat steps 4 to 7 to set the launch permissions, choosing Use custom access permissions in step 4 and Allow Launch in step 7. The Configuration Permissions contains an Access Control List of principals that are allowed to modify the configuration information for a server. In other words, it indicates who is allowed to alter the registry entries for installed servers, as well as who is able to access the registry to install new servers. It is usually simpler to install and configure servers as a user with local administrative rights.
31 TutorialIntroduction to OPC 11/19/2002
To connect to an OPC server from outside of the domain, create a local user account on both the server and the client machine with identical username and password. Then add the local user on the OPC server to the DCOM permissions. Use the local account on the client machine to connect to the OPC server.
Note: UDP/IP protocol does not work correctly for DCOM and should be removed from the list.
The more protocols that appear in the list, the better the chances of connecting to an OPC server on an unknown remote machine (such as at an OPC Interoperability Workshop). However, it may also take longer for DCOM to time out if a server machine is not present, since it has to try each protocol in turn. For most situations it is best to remove all unused protocols from the list and only include those that are necessary for your network. For example, on a TCP/IP network one would include the Connection-oriented TCP/IP protocol. Contact your IT personnel for more information about your network. Evidence indicates that there are problems with the datagram-oriented protocols that can cause memory leaks in DCOM. Therefore, we strongly recommended that these protocols not be used in the list of default protocols. Datagram-oriented protocols are not supported under Windows 2000 (although the DCOM configuration utility allows you to configure them).
6. Copy the exported REG files to the client machine. 7. Merge the REG files into the registry of the client machine. This should be a matter of double-clicking the file from the desktop of the client machine. Alternatively, run REGEDIT on the client machine and choose Import Registry File from the Registry menu, selecting each file in turn. This must be done as a user who has write access to the local registry. 8. Use REGEDIT to check that the program IDs have in fact been copied. 9. Delete the REG files, since they are no longer needed.