This tutorial will guide you exactly how to use COPC32 on Visual Basic.NET. You have to mount COPC32 on your system prior to develop SCADA with Visual.NET and also COPC32 ActiveX control. And we mean that you have OPC Web server on your regional system already.

We will create the simple form to review as well as contact OPC server on neighborhood systems. However you would certainly, like to attach to remote OPC 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 create is received Number 1.

Number 1

When user insert numeric worth in textbox and click button ‘& lsquo; Create ‘, COPC32 will contact OPC tag as well as show its worth on ‘& lsquo

  1. ; 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 tool kit by choose menu Tools > > Add/Remove Toolbox Items & hellip;

Number 3

Then choose COPC32 shown in Number 4.

Figure 4

Then click “& ldquo;

OK & rdquo; 3. Crate a button, a textbox and label on type like received Number 1
follow the link bitCOPC32 Download At our site

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

5. Right click COPC32 control on the form and also select ActiveX properties.

Number 5

Set upgrade price to 100 msec. As well as choose OPC Server name to wanted OPC Web server. You need to enter IP address or maker name in ‘& lsquo; nodname ‘ textbox if you wish to link to remote OPC server over the network.

Number 6

6. Select OPC Tag you wish to connect to.

Figure 7

Click OK.

This OPC Tag could be Understandable as well as Writable. You can look at your OPC Server like received Figure 8.

Figure 8 OPC Tag residential properties.

Number 9 Configure OPC tag index number = 0

And also click OK to leave home web pages.

Keep in mind: You can set up linked OPC tags by import OPC tag list from CSV documents which export from OPC Server. Please refer to

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

As well as see “& ldquo; Just how to pack OPC tags from CSV file”&

rdquo;. 7. Dual click on the type to get in to Form_Load occasion code sight.

8. Produce the code to connect to OPC server and get worth of OPC tag index 0 to show on Label1.

Private Below 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

Keep in mind: If you have configure various other OPC tag such as OPC tag index number = 1. You can obtain its worth using ‘& lsquo

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

occasion name from

dropdown. Figure 10 And also develop the code like following

Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase. Closing

Application.DoEvents()

Axcopc1.discnn()

End Sub

Keep in mind: We make use of “& ldquo; Application.DoEvents()” & rdquo; to waiting other task to finish before detach from OPC Server.

10. Back to make view. Double click on COPC32 control on the type to get in to “& ldquo; datChange & rdquo; event code sight. After that produce the code to show OPC tag worth on Label1 when the vale of OPC tag we are connected has changed.

Private 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 Below

11. Back to form layout sight. Double click on button ‘& lsquo; Compose ‘. After that develop code to create vale to OPC tag which has index number = 0.

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Manages Button1.Click

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

End Below

12. Examination program by click F5. Put the number right into textbox and click ‘& lsquo; Write ‘. You could see the vale received label amounts to your enter number.

Figure 11

The complete related code is displayed in Number 12.