This tutorial will certainly lead you just how to utilize COPC32 on Aesthetic Basic.NET. You need to install COPC32 on your system before create SCADA with Visual.NET and COPC32 ActiveX control. As well as we suppose that you have OPC Web server on your regional system already.
We will develop the straightforward type to read and write to OPC web server on neighborhood systems. But you would, like to link to remote OPC server. Please set up DCOM on both web server and also customer side by refer to tutorial of KEPWare at http://www.kepware.com/Support_Center/Viewlets/XP_sp2_viewlet_swf.html
The kind we will produce is displayed in Number 1.
Figure 1
When customer insert numerical value in textbox and also click button ‘& lsquo; Create ‘, COPC32 will write to OPC tag and show 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. Include COPC32 ActiveX control into toolbox by select menu Tools > > Add/Remove Tool kit Things & hellip;
Number 3
Then pick COPC32 displayed in Figure 4.
Number 4
After that click “& ldquo;
OK & rdquo; 3. Crate a button, a textbox and tag on form like received Figure 1
At site bitCOPC32 Download from Our Articles
. 4. Select in tool kit and drag on the kind.
5. Right click on COPC32 control on the type as well as choose ActiveX buildings.
Figure 5
Establish update rate to 100 msec. As well as pick OPC Web server name to preferred OPC Server. You need to get in IP address or machine name in ‘& lsquo; nodname ‘ textbox if you want to attach to remote OPC web server over the network.
Number 6
6. Select OPC Tag you would love to attach to.
Figure 7
Click OK.
This OPC Tag could be Readable and Writable. You can check on your OPC Server like displayed in Number 8.
Figure 8 OPC Tag buildings.
Figure 9 Configure OPC tag index number = 0
As well as click OK to leave building pages.
Note: You can configure connected OPC tags by import OPC tag checklist from CSV file which export from OPC Server. Please describe
http://www.scadathai.com/COPC/COPCEng/tutorials.htm
As well as see “& ldquo; Exactly how to fill OPC tags from CSV file”&
rdquo;. 7. Double click the kind to get in to Form_Load occasion code sight.
8. Develop the code to connect to OPC web server as well as obtain worth of OPC tag index 0 to reveal on Label1.
Private Sub 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
Keep in mind: If you have set up 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. Number 10 And also develop the code like following
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Takes care of MyBase. Closing
Application.DoEvents()
Axcopc1.discnn()
End Sub
Note: We make use of “& ldquo; Application.DoEvents()” & rdquo; to waiting various other job to finish before separate from OPC Web server.
10. Back to create sight. Dual click on COPC32 control on the form to go into to “& ldquo; datChange & rdquo; event code sight. Then develop the code to show OPC tag value on Label1 when the vale of OPC tag we are connected has actually transformed.
Exclusive Below Axcopc1_datChange(ByVal sender As Object, ByVal e As System.EventArgs) Deals with Axcopc1.datChange
Label1.Text = Convert.ToString(Axcopc1.GetVl( 0 ))
End Sub
11. Back to create design sight. Double click on switch ‘& lsquo; Compose ‘. Then develop 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) Handles Button1.Click
Axcopc1.opcWrt(0, Convert.ToDouble(TextBox1.Text))
End Below
12. Test program by click F5. Put the number into textbox and also click ‘& lsquo; Write ‘. You could see the vale displayed in label amounts to your enter number.
Number 11
The overall relevant code is shown in Number 12.