Use COPC32 on Visual Basic.NET
This tutorial will certainly direct you how to utilize COPC32 on Aesthetic Basic.NET. You have to install COPC32 on your system prior to create SCADA with Visual.NET as well as COPC32 ActiveX control. And we suppose that you have OPC Server on your regional system currently.
We will produce the easy type to review as well as contact OPC server on local systems. But you would, like to connect to remote OPC web server. Please set up 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 type we will certainly develop is displayed in Figure 1.
Figure 1
When individual insert numeric worth in textbox as well as click switch ‘& lsquo; Compose ‘, COPC32 will contact OPC tag and also show its worth on ‘& lsquo
- ; Label1 ‘. Open Visual Studio.NET and crate brand-new project with VB.NET
Figure 2
Type the name of this job as “& ldquo; TestCOPC32VBNET &
rdquo;. 2. Add COPC32 ActiveX control right into toolbox by choose menu Tools > > Add/Remove Toolbox Products & hellip;
Number 3
After that pick COPC32 shown in Figure 4.
Number 4
After that click “& ldquo;
OK & rdquo; 3. Crate a button, a textbox and tag on type like received Figure 1
More Here free COPC32 download At our site
. 4. Select in tool kit and drag out the type.
5. Right click COPC32 control on the kind as well as choose ActiveX residential properties.
Number 5
Set upgrade rate to 100 msec. As well as choose OPC Web server name to desired OPC Web server. You need to enter IP address or equipment name in ‘& lsquo; nodname ‘ textbox if you would love to link to remote OPC web server over the network.
Number 6
6. Select OPC Tag you would love to connect to.
Figure 7
Click OK.
This OPC Tag could be Understandable as well as Writable. You can look at your OPC Web server like received Number 8.
Number 8 OPC Tag residential or commercial properties.
Figure 9 Configure OPC tag index number = 0
And click OK to leave home pages.
Keep in mind: You can configure linked OPC tags by import OPC tag listing from CSV file which export from OPC Server. Please describe
http://www.scadathai.com/COPC/COPCEng/tutorials.htm
And see “& ldquo; How to pack OPC tags from CSV documents”&
rdquo;. 7. Double click the kind to enter to Form_Load event code view.
8. Develop the code to connect to OPC web server and also obtain value of OPC tag index 0 to show on Label1.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Deals with MyBase. Lots
Axcopc1.cnnec()
Label1.Text = Convert.ToString(Axcopc1.GetVl( 0 ))
End Sub
Note: If you have set up various other OPC tag such as OPC tag index number = 1. You can obtain its value utilizing ‘& lsquo
; GetVl( “1)’”. 9. Select & ldquo; Closing & rdquo;
occasion name from
dropdown. Figure 10 And also produce the code like complying with
Exclusive 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 various other task to end up prior to separate from OPC Web server.
10. Back to make view. Double click on COPC32 control on the type to get in to “& ldquo; datChange & rdquo; occasion code sight. After that create the code to present OPC tag value on Label1 when the vale of OPC tag we are connected has actually changed.
Personal Below Axcopc1_datChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles Axcopc1.datChange
Label1.Text = Convert.ToString(Axcopc1.GetVl( 0 ))
End Below
11. Back to form style sight. Double click on button ‘& lsquo; Compose ‘. After that create code to write vale to OPC tag which has index number = 0.
Private Below Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Axcopc1.opcWrt(0, Convert.ToDouble(TextBox1.Text))
End Below
12. Test program by click F5. Insert the number right into textbox as well as click ‘& lsquo; Compose ‘. You might see the vale received label amounts to your enter number.
Figure 11
The overall associated code is received Number 12.