Академический Документы
Профессиональный Документы
Культура Документы
Topic:
Author:
Ralf Eden
Issued:
09.01.02
File name:
326990659.doc
PC based Automation
326990659.doc
Copyright (C) Siemens AG 2001 All Rights Reserved.
09.01.02
Page: 1 / 13
Contents
1
326990659.doc
Copyright (C) Siemens AG 2001 All Rights Reserved.
09.01.02
Page: 2 / 13
Component
3.1
Starting VB OPC-Client
326990659.doc
Copyright (C) Siemens AG 2001 All Rights Reserved.
09.01.02
Page: 3 / 13
The program enters the server name of the WinAC OPC server in the output field
Connect to OPC Server. An input via this edit box is not possible.
The current values for Temperature and Niveau [Level] are automatically updated in the
output boxes Niveau and Temperature. An input of values via the user interface is not
possible.
The current binary states for the Mixer, Cooler, Heater, Inlet_Valve_1, Inlet_Valve_2 and
Outlet_Valve are illustrated in check boxes. For the binary state 1, the corresponding
CheckBox appears as follows:
. It is not possible for the user to activate the
check boxes.
The Start Process button starts the process and Stop Process button ends the process.
326990659.doc
Copyright (C) Siemens AG 2001 All Rights Reserved.
09.01.02
Page: 4 / 13
Operating the Connect OPC Server button creates the connection to the OPC server.
Operating the Write Niveau Settings button writes the defined set-point values of
Niveau_1 and Niveau_2 to the OPC server.
Write Temperature Settings writes the defined set-point values for Temperature_Out and
Temperature_Max to the OPC server.
3.2
326990659.doc
Copyright (C) Siemens AG 2001 All Rights Reserved.
09.01.02
Page: 5 / 13
For using OPC in VB, the correct Dynamic Link Library (Dll) must first be defined.
The menu Project > References opens a dialog box in which all registered COM
servers are listed. In this dialog (Figure 2) Siemens OPC DAAutomation 2.0 must be
selected and acknowledged with OK.
The integration of control elements and the integration of OPC functionality is
described below by means of a selected configuration step.
3.3
Sample Configuration
326990659.doc
Copyright (C) Siemens AG 2001 All Rights Reserved.
09.01.02
Page: 6 / 13
First a new project must be created in Visual Basic via the menu File > New Project and
selecting Standard Exe. A new Visual Basic Form opens. The project name can be
changed in VBDemo, the name of the form in FormProcess and the caption of the form
in SIEMENS PC based Automation Visual Basic OPC Client. The form will look as
follows (Figure 4).
A Command button must now be inserted in this Form via the control elements ToolBox
(menu View > Toolbox) by means of drag&drop.
326990659.doc
Copyright (C) Siemens AG 2001 All Rights Reserved.
09.01.02
Page: 7 / 13
Name:
cmdConnect
Caption:
Font:
Arial bold 10
Enable:
TRUE
Caption:
Font
Enable:
This property defines whether the button can trigger a function when
starting Visual Basic Runtime. At the beginning this only makes sense with the
Connect OPC Server button, as this button is used for creating a connection to the
OPC server.
After creating the user interface (button) the code view of Visual Basic must be
changed. There the OPC functionality must now be implemented with Visual Basic.
326990659.doc
Copyright (C) Siemens AG 2001 All Rights Reserved.
09.01.02
Page: 8 / 13
Further recommendations:
Inserting the Option Explicit, to avoid creating new variables due to input errors, and
thus using wrong variables. Variables must be created with Dim. In addition to that, two
further variables for server name and boolean variables must be created for the
connection status.
The event Form_Load is executed when starting the VB program. The function
Form_Unload at the end of the program. In Form_Load the variables should be
initialised and in Form_Unload the existing connections to the OPC Server be released.
Creating and deleting of objects should always be performed together to ensure
releasing the objects to an OPC server.
A Connect function must be created for the connection to the OPC server, and a
Disconnect function for the release.
326990659.doc
Copyright (C) Siemens AG 2001 All Rights Reserved.
09.01.02
Page: 9 / 13
326990659.doc
Copyright (C) Siemens AG 2001 All Rights Reserved.
09.01.02
Page: 10 / 13
326990659.doc
Copyright (C) Siemens AG 2001 All Rights Reserved.
09.01.02
Page: 11 / 13
A server object must be created in the function Connect by means of Set MyOPCServer
= New OPCServer. Calling MyOPCServer.Connect(ServerName) calls the OPC function
Connect of the OPC Data Access Automation user interface for connecting the OPC
server.
In
the
Disconnect
function
the
OPC
server
must
be
released
with
Set
326990659.doc
Copyright (C) Siemens AG 2001 All Rights Reserved.
09.01.02
Page: 12 / 13
326990659.doc
Copyright (C) Siemens AG 2001 All Rights Reserved.
09.01.02
Page: 13 / 13