Usage COPC32 on Visual Basic.NET
This tutorial will certainly assist you exactly how to use COPC32 on Visual Basic.NET. You need to set up COPC32 on your system prior to produce SCADA with Visual.NET as well as COPC32 ActiveX control. And also we expect that you have OPC Server on your regional system currently.
We will develop the simple kind to read and also contact OPC web server on regional systems. Yet you would certainly, like to attach to remote OPC server. Please configure DCOM on both web server as well as client side by refer to tutorial of KEPWare at http://www.kepware.com/Support_Center/Viewlets/XP_sp2_viewlet_swf.html
The form we will certainly create is received Number 1.
Figure 1
When customer insert numeric worth in textbox and click button ‘& lsquo; Create ‘, COPC32 will certainly contact OPC tag as well as reveal its value on ‘& lsquo
- ; Label1 ‘. Open Visual Studio.NET as well as crate brand-new task with VB.NET
Number 2
Type the name of this task as “& ldquo; TestCOPC32VBNET &
rdquo;. 2. Add COPC32 ActiveX control into toolbox by pick food selection Devices > > Add/Remove Toolbox Items & hellip;
Figure 3
After that choose COPC32 received Number 4.
Number 4
Then click “& ldquo;
OK & rdquo; 3.More Here free COPC32 download At our site Crate a button, a textbox as well as tag on kind like shown in Figure 1
. 4. Select in toolbox and also drag out the kind.
5. Right click on COPC32 control on the type and also select ActiveX residential or commercial properties.
Number 5
Set update rate to 100 msec. As well as pick OPC Web server name to wanted OPC Web server. You need to go into IP address or machine name in ‘& lsquo; nodname ‘ textbox if you would like to attach to remote OPC web server over the network.
Number 6
6. Select OPC Tag you would like to connect to.
Figure 7
Click OK.
This OPC Tag could be Legible and Writable. You can look at your OPC Web server like received Figure 8.
Figure 8 OPC Tag residential or commercial properties.
Number 9 Configure OPC tag index number = 0
And click OK to exit residential or commercial property web pages.
Note: You can set up linked OPC tags by import OPC tag checklist from CSV data which export from OPC Web server. Please refer to
http://www.scadathai.com/COPC/COPCEng/tutorials.htm
As well as see “& ldquo; Exactly how to fill OPC tags from CSV documents”&
rdquo;. 7. Double click on the form to get in to Form_Load event code sight.
8. Create the code to attach to OPC web server as well as get value of OPC tag index 0 to reveal on Label1.
Personal Below Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Takes care of MyBase. Lots
Axcopc1.cnnec()
Label1.Text = Convert.ToString(Axcopc1.GetVl( 0 ))
End Below
Note: If you have set up other OPC tag such as OPC tag index number = 1. You can get its worth using ‘& lsquo
; GetVl( “1)’”. 9. Select & ldquo; Closing & rdquo;
occasion name from
dropdown. Figure 10 As well as create the code like following
Private Below Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Takes care of MyBase. Closing
Application.DoEvents()
Axcopc1.discnn()
End Below
Keep in mind: We use “& ldquo; Application.DoEvents()” & rdquo; to waiting other job to finish before detach from OPC Server.
10. Back to create view. Dual click on COPC32 control on the form to go into to “& ldquo; datChange & rdquo; occasion code view. Then produce the code to display OPC tag worth on Label1 when the vale of OPC tag we are attached has altered.
Personal Sub Axcopc1_datChange(ByVal sender As Object, ByVal e As System.EventArgs) Manages Axcopc1.datChange
Label1.Text = Convert.ToString(Axcopc1.GetVl( 0 ))
End Sub
11. Back to develop style view. Dual click switch ‘& lsquo; Create ‘. After that develop code to create vale to OPC tag which has index number = 0.
Exclusive Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Axcopc1.opcWrt(0, Convert.ToDouble(TextBox1.Text))
End Below
12. Examination program by click F5. Insert the number into textbox and click ‘& lsquo; Write ‘. You could see the vale received label amounts to your go into number.
Number 11
The total related code is shown in Figure 12.