! Без рубрики

Usage COPC32 on Visual Basic.NET

This tutorial will lead you just how to make use of COPC32 on Visual Basic.NET. You need to mount COPC32 on your system prior to develop SCADA with Visual.NET as well as COPC32 ActiveX control. And we suppose that you have OPC Web server on your neighborhood system currently.

We will create the straightforward form to check out and also contact OPC server on neighborhood systems. However you would, like to link to remote OPC 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 kind we will create is received Number 1.

Figure 1

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

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

Number 2

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

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

Number 3

Then select COPC32 shown in Figure 4.

Number 4

Then click “& ldquo;

OK & rdquo; 3. Crate a button, a textbox as well as tag on form like displayed in Number 1
by link COPC32 Download for Windows website

. 4. Select in toolbox and drag on the type.

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

Number 5

Set upgrade price to 100 msec. As well as select OPC Web server name to preferred OPC Web server. You have to enter IP address or equipment name in ‘& lsquo; nodname ‘ textbox if you would love to connect to remote OPC web server over the network.

Number 6

6. Select OPC Tag you want to attach to.

Number 7

Click OK.

This OPC Tag could be Readable and also Writable. You can examine your OPC Web server like received Figure 8.

Number 8 OPC Tag residential or commercial properties.

Number 9 Configure OPC tag index number = 0

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

Keep in mind: You can configure linked OPC tags by import OPC tag listing from CSV data which export from OPC Server. Please refer to


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

rdquo;. 7. Dual click on the type to get in to Form_Load event code view.

8. Create the code to attach to OPC web server and obtain worth of OPC tag index 0 to reveal on Label1.

Personal Below Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Takes care of MyBase. Tons


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

End Below

Keep in mind: If you have set up 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;

event name from

dropdown. Number 10 As well as produce the code like complying with

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



End Below

Note: We utilize “& ldquo; Application.DoEvents()” & rdquo; to waiting other job to complete prior to detach from OPC Web server.

10. Back to develop sight. Double click on COPC32 control on the type to get in to “& ldquo; datChange & rdquo; event code view. Then create the code to display OPC tag value on Label1 when the vale of OPC tag we are connected has altered.

Private 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 form design view. Dual click on button ‘& lsquo; Write ‘. 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) Takes care of Button1.Click

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

End Sub

12. Examination program by click F5. Place the number into textbox as well as click ‘& lsquo; Write ‘. You can see the vale shown in tag is equal to your go into number.

Number 11

The overall related code is displayed in Figure 12.

Hammad Administrator
Sorry! The Author has not filled his profile.
Hammad Administrator
Sorry! The Author has not filled his profile.

Comment here