This tutorial will direct you exactly how to utilize COPC32 on Aesthetic Basic.NET. You have to mount COPC32 on your system before produce SCADA with Visual.NET and COPC32 ActiveX control. And we mean that you have OPC Web server on your local system already.
We will certainly create the straightforward type to read and contact OPC web server on local systems. But you would certainly, like to attach to remote OPC web server. Please configure DCOM on both web server and also client side by describe tutorial of KEPWare at http://www.kepware.com/Support_Center/Viewlets/XP_sp2_viewlet_swf.html
The kind we will produce is received Number 1.
Figure 1
When individual insert numerical value in textbox and also click switch ‘& lsquo; Create ‘, COPC32 will write to OPC tag and also reveal its worth on ‘& lsquo
- ; Label1 ‘. Open Visual Studio.NET and also crate brand-new task with VB.NET
Number 2
Type the name of this job as “& ldquo; TestCOPC32VBNET &
rdquo;. 2. Add COPC32 ActiveX control right into toolbox by select menu Devices > > Add/Remove Toolbox Products & hellip;
Number 3
Then pick COPC32 displayed in Number 4.
Number 4
Then click “& ldquo;
OK & rdquo; 3. Crate a switch, a textbox and tag on kind like received Figure 1
Join Us COPC32 website
. 4. Select in toolbox and drag on the type.
5. Right click on COPC32 control on the type as well as pick ActiveX homes.
Number 5
Establish upgrade rate to 100 msec. As well as select OPC Server name to desired OPC Server. You need to go into IP address or machine name in ‘& lsquo; nodname ‘ textbox if you would like to link to remote OPC server over the network.
Figure 6
6. Select OPC Tag you wish to link to.
Figure 7
Click OK.
This OPC Tag could be Legible as well as Writable. You can check on your OPC Web server like shown in Number 8.
Number 8 OPC Tag buildings.
Number 9 Configure OPC tag index number = 0
And also click OK to exit residential or commercial property pages.
Keep in mind: You can set up linked OPC tags by import OPC tag listing from CSV data which export from OPC Web server. Please refer to
http://www.scadathai.com/COPC/COPCEng/tutorials.htm
And see “& ldquo; How to load OPC tags from CSV file”&
rdquo;. 7. Dual click on the form to get in to Form_Load event code view.
8. Develop the code to connect to OPC web server as well as get worth of OPC tag index 0 to reveal on Label1.
Exclusive Below Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Deals with MyBase. Tons
Axcopc1.cnnec()
Label1.Text = Convert.ToString(Axcopc1.GetVl( 0 ))
End Sub
Note: If you have configure other OPC tag such as OPC tag index number = 1. You can get its worth utilizing ‘& lsquo
; GetVl( “1)’”. 9. Select & ldquo; Closing & rdquo;
event name from
dropdown. Figure 10 And develop the code like complying with
Personal Below Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Deals with MyBase. Closing
Application.DoEvents()
Axcopc1.discnn()
End Sub
Keep in mind: We use “& ldquo; Application.DoEvents()” & rdquo; to waiting other job to complete prior to disconnect from OPC Web server.
10. Back to develop view. Dual click COPC32 control on the form to get in to “& ldquo; datChange & rdquo; event code sight. After that create the code to show OPC tag worth on Label1 when the vale of OPC tag we are connected has actually 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 Below
11. Back to develop style view. Dual click on switch ‘& lsquo; Create ‘. Then produce 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) Takes care of Button1.Click
Axcopc1.opcWrt(0, Convert.ToDouble(TextBox1.Text))
End Below
12. Test program by click F5. Insert the number into textbox and also click ‘& lsquo; Write ‘. You might see the vale received tag is equal to your enter number.
Number 11
The complete relevant code is received Number 12.
