This tutorial will certainly assist you exactly how to utilize COPC32 on Visual Basic.NET. You have to install COPC32 on your system before develop SCADA with Visual.NET as well as COPC32 ActiveX control. And also we intend that you have OPC Server on your neighborhood system already.

We will certainly develop the straightforward type to read and also contact OPC server on neighborhood systems. But you would, like to connect to remote OPC web server. Please set up DCOM on both 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 produce is received Figure 1.

Figure 1

When customer insert numerical worth in textbox as well as click button ‘& lsquo; Write ‘, COPC32 will certainly write to OPC tag as well as reveal its value on ‘& lsquo

  1. ; Label1 ‘. Open Up Visual Studio.NET and crate new project with VB.NET

Figure 2

Type the name of this project as “& ldquo; TestCOPC32VBNET &

rdquo;. 2. Include COPC32 ActiveX control into tool kit by choose food selection Tools > > Add/Remove Tool kit Things & hellip;

Number 3

After that select COPC32 shown in Number 4.

Figure 4

After that click “& ldquo;

OK & rdquo; 3.read about it COPC32 free download from Our Articles Crate a button, a textbox and also label on form like received Number 1

. 4. Select in toolbox as well as drag on the type.

5. Right click on COPC32 control on the type and also pick ActiveX buildings.

Number 5

Set upgrade rate to 100 msec. And choose OPC Web server name to wanted OPC Server. You need to go into IP address or maker name in ‘& lsquo; nodname ‘ textbox if you want to attach to remote OPC web server over the network.

Figure 6

6. Select OPC Tag you would love to connect to.

Figure 7

Click OK.

This OPC Tag could be Legible and Writable. You can examine your OPC Server like shown in Number 8.

Figure 8 OPC Tag properties.

Number 9 Configure OPC tag index number = 0

As well as click OK to exit property web pages.

Note: You can set up connected OPC tags by import OPC tag listing from CSV data which export from OPC Server. Please refer to

http://www.scadathai.com/COPC/COPCEng/tutorials.htm

And also see “& ldquo; Just how to pack OPC tags from CSV file”&

rdquo;. 7. Double click the form to go into to Form_Load event code sight.

8. Create the code to attach to OPC web server and get worth 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. 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 value utilizing ‘& lsquo

; GetVl( “1)’”. 9. Select & ldquo; Closing & rdquo;

occasion name from

dropdown. Figure 10 As well as 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 utilize “& ldquo; Application.DoEvents()” & rdquo; to waiting other task to end up before detach from OPC Server.

10. Back to make view. Double click on COPC32 control on the kind to enter to “& ldquo; datChange & rdquo; occasion code view. Then develop the code to show OPC tag value on Label1 when the vale of OPC tag we are attached has transformed.

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 create design view. Dual click on button ‘& lsquo; Create ‘. Then create code to compose 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 Sub

12. Examination program by click F5. Put the number into textbox and also click ‘& lsquo; Write ‘. You might see the vale shown in label amounts to your enter number.

Number 11

The overall associated code is shown in Number 12.