Use COPC32 on Visual Basic.NET
This tutorial will certainly lead you just how to make use of COPC32 on Aesthetic Basic.NET. You have to mount COPC32 on your system before develop SCADA with Visual.NET and also COPC32 ActiveX control. And we mean that you have OPC Server on your neighborhood system already.
We will create the easy kind to review and also write to OPC server on neighborhood systems. However you would certainly, like to connect to remote OPC web server. Please set up DCOM on both server and client side by describe tutorial of KEPWare at http://www.kepware.com/Support_Center/Viewlets/XP_sp2_viewlet_swf.html
The kind we will create is displayed in Figure 1.
Figure 1
When user insert numerical value in textbox as well as click switch ‘& lsquo; Compose ‘, COPC32 will certainly write to OPC tag as well as reveal its worth on ‘& lsquo
- ; Label1 ‘. Open Visual Studio.NET and also crate new project with VB.NET
Number 2
Kind the name of this project as “& ldquo; TestCOPC32VBNET &
rdquo;. 2. Include COPC32 ActiveX control into toolbox by select food selection Devices > > Add/Remove Tool kit Products & hellip;
Figure 3
After that choose COPC32 shown in Figure 4.
Figure 4
Then click “& ldquo;
OK & rdquo; 3.At site COPC32 for windows from Our Articles Crate a switch, a textbox and tag on type like displayed in Number 1
. 4. Select in tool kit and also drag out the form.
5. Right click COPC32 control on the type and choose ActiveX buildings.
Figure 5
Set upgrade rate to 100 msec. As well as pick OPC Web server name to desired OPC Server. You need to enter IP address or machine name in ‘& lsquo; nodname ‘ textbox if you would love to link to remote OPC web 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 look at your OPC Web server like received Number 8.
Figure 8 OPC Tag residential properties.
Figure 9 Configure OPC tag index number = 0
As well as click OK to exit residential property pages.
Note: You can set up connected OPC tags by import OPC tag listing from CSV documents which export from OPC Web server. Please describe
http://www.scadathai.com/COPC/COPCEng/tutorials.htm
And also see “& ldquo; Exactly how to load OPC tags from CSV documents”&
rdquo;. 7. Dual click the type to get in to Form_Load occasion code sight.
8. Develop the code to link to OPC web server and obtain value of OPC tag index 0 to show on Label1.
Exclusive Below Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Takes care of MyBase. Load
Axcopc1.cnnec()
Label1.Text = Convert.ToString(Axcopc1.GetVl( 0 ))
End Below
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 As well as produce the code like following
Personal 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 make use of “& ldquo; Application.DoEvents()” & rdquo; to waiting other job to end up before detach from OPC Web server.
10. Back to create sight. Double click COPC32 control on the kind to get in to “& ldquo; datChange & rdquo; occasion code view. Then produce the code to present OPC tag worth on Label1 when the vale of OPC tag we are connected has transformed.
Exclusive Below Axcopc1_datChange(ByVal sender As Object, ByVal e As System.EventArgs) Takes care of Axcopc1.datChange
Label1.Text = Convert.ToString(Axcopc1.GetVl( 0 ))
End Sub
11. Back to develop design view. Double click on button ‘& lsquo; Compose ‘. Then produce code to create vale to OPC tag which has index number = 0.
Personal Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Deals with Button1.Click
Axcopc1.opcWrt(0, Convert.ToDouble(TextBox1.Text))
End Sub
12. Examination program by click F5. Put the number right into textbox and also click ‘& lsquo; Write ‘. You can see the vale shown in tag amounts to your enter number.
Number 11
The total relevant code is received Figure 12.