Use COPC32 on Visual Basic.NET

This tutorial will direct you just how to use COPC32 on Aesthetic Basic.NET. You need to mount COPC32 on your system prior to produce SCADA with Visual.NET and also COPC32 ActiveX control. As well as we expect that you have OPC Web server on your regional system currently.

We will create the simple form to read and also contact OPC web server on neighborhood systems. But you would certainly, like to attach 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 Number 1.

Number 1

When user insert numeric worth in textbox and click switch ‘& lsquo; Compose ‘, COPC32 will certainly write to OPC tag and reveal its value on ‘& lsquo

  1. ; Label1 ‘. Open Visual Studio.NET and crate brand-new job with VB.NET

Number 2

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

rdquo;. 2. Add COPC32 ActiveX control into toolbox by pick food selection Devices > > Add/Remove Toolbox Items & hellip;

Figure 3

After that select COPC32 shown in Figure 4.

Number 4

After that click “& ldquo;

OK & rdquo; 3. Crate a button, a textbox and tag on type like displayed in Number 1
Read here COPC32 Free At our site

. 4. Select in tool kit and also drag on the type.

5. Right click on COPC32 control on the form and pick ActiveX residential properties.

Number 5

Set update price to 100 msec. And also pick OPC Web server name to desired OPC Web server. You have to get in IP address or machine name in ‘& lsquo; nodname ‘ textbox if you wish to link to remote OPC web server over the network.

Figure 6

6. Select OPC Tag you would like 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.

Number 8 OPC Tag residential properties.

Number 9 Configure OPC tag index number = 0

And also click OK to exit residential or commercial property pages.

Note: You can configure linked OPC tags by import OPC tag list from CSV file which export from OPC Web server. Please refer to

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

As well as see “& ldquo; How to fill OPC tags from CSV file”&

rdquo;. 7. Dual click the form to enter to Form_Load occasion code view.

8. Develop the code to link to OPC server and also 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) Takes care of MyBase. Tons

Axcopc1.cnnec()

Label1.Text = Convert.ToString(Axcopc1.GetVl( 0 ))

End Sub

Keep in mind: If you have configure various 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 And also develop the code like adhering to

Personal Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Deals with MyBase. Closing

Application.DoEvents()

Axcopc1.discnn()

End Sub

Note: We use “& ldquo; Application.DoEvents()” & rdquo; to waiting other job to finish prior to separate from OPC Server.

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

Personal Below Axcopc1_datChange(ByVal sender As Object, ByVal e As System.EventArgs) Deals with Axcopc1.datChange

Label1.Text = Convert.ToString(Axcopc1.GetVl( 0 ))

End Below

11. Back to form layout sight. Double click switch ‘& lsquo; Write ‘. Then create code to compose vale to OPC tag which has index number = 0.

Private Below Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Deals with Button1.Click

Axcopc1.opcWrt(0, Convert.ToDouble(TextBox1.Text))

End Below

12. Examination program by click F5. Put the number into textbox and click ‘& lsquo; Write ‘. You could see the vale shown in label is equal to your go into number.

Number 11

The total relevant code is shown in Number 12.