Use COPC32 on Visual Basic.NET

This tutorial will certainly lead you exactly how to use COPC32 on Aesthetic Basic.NET. You have to mount COPC32 on your system before produce SCADA with Visual.NET as well as COPC32 ActiveX control. And also we expect that you have OPC Web server on your regional system already.

We will certainly develop the simple kind to read and contact OPC web server on regional systems. Yet you would, like to connect to remote OPC server. Please set up DCOM on both web server as well as client side by describe tutorial of KEPWare at http://www.kepware.com/Support_Center/Viewlets/XP_sp2_viewlet_swf.html

The type we will create is shown in Number 1.

Figure 1

When user insert numerical value in textbox and also click switch ‘& lsquo; Create ‘, COPC32 will contact OPC tag as well as reveal its value on ‘& lsquo

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

Figure 2

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

rdquo;. 2. Include COPC32 ActiveX control right into toolbox by choose food selection Tools > > Add/Remove Toolbox Things & hellip;

Number 3

After that choose COPC32 displayed in Number 4.

Number 4

Then click “& ldquo;

OK & rdquo; 3. Crate a button, a textbox and also tag on form like displayed in Number 1
follow the link COPC32 Free At our site

. 4. Select in toolbox and also drag on the kind.

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

Number 5

Set upgrade price to 100 msec. And also pick OPC Server name to preferred OPC Web server. You need to get in IP address or maker name in ‘& lsquo; nodname ‘ textbox if you would love to attach to remote OPC server over the network.

Figure 6

6. Select OPC Tag you want to attach to.

Figure 7

Click OK.

This OPC Tag could be Legible and also Writable. You can look at your OPC Web server like shown in Figure 8.

Figure 8 OPC Tag homes.

Number 9 Configure OPC tag index number = 0

As well as click OK to exit residential property web pages.

Keep in mind: You can set up connected OPC tags by import OPC tag list from CSV data 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 data”&

rdquo;. 7. Double click the kind to enter 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.

Exclusive 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

Note: If you have set up various other OPC tag such as OPC tag index number = 1. You can obtain its value making use of ‘& lsquo

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

event name from

dropdown. Figure 10 As well as create the code like complying with

Exclusive Below Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Manages MyBase. Closing

Application.DoEvents()

Axcopc1.discnn()

End Sub

Keep in mind: We make use of “& ldquo; Application.DoEvents()” & rdquo; to waiting other task to end up before disconnect from OPC Web server.

10. Back to make sight. Dual click COPC32 control on the kind to enter to “& ldquo; datChange & rdquo; event code sight. After that create the code to show OPC tag worth on Label1 when the vale of OPC tag we are attached 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 Sub

11. Back to create style sight. Double click on switch ‘& lsquo; Create ‘. Then develop code to compose vale to OPC tag which has index number = 0.

Exclusive 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. Test program by click F5. Put the number into textbox as well as click ‘& lsquo; Create ‘. You might see the vale shown in label is equal to your go into number.

Figure 11

The complete associated code is displayed in Number 12.