Use COPC32 on Visual Basic.NET Leave a comment

This tutorial will direct you exactly how to use COPC32 on Aesthetic Basic.NET. You need to mount COPC32 on your system before create SCADA with Visual.NET as well as COPC32 ActiveX control. And also we mean that you have OPC Web server on your neighborhood system already.

We will certainly produce the straightforward kind to read and also write to OPC web server on regional systems. But you would certainly, like to link to remote OPC web server. Please set up DCOM on both web server as well as client side by refer to tutorial of KEPWare at

The type we will certainly develop is received Figure 1.

Figure 1

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

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

Figure 2

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

rdquo;. 2. Include COPC32 ActiveX control into toolbox by select menu Tools > > Add/Remove Tool kit Items & hellip;

Number 3

After that choose COPC32 displayed in Figure 4.

Number 4

After that click “& ldquo;

OK & rdquo; 3.Read about bitCOPC32 Download At website Crate a switch, a textbox and tag on type like received Figure 1

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

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

Number 5

Establish update price to 100 msec. And choose OPC Web server name to desired OPC Server. You have to go into IP address or machine name in ‘& lsquo; nodname ‘ textbox if you would love to link to remote OPC web server over the network.

Number 6

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

Figure 7

Click OK.

This OPC Tag could be Legible as well as Writable. You can check on your OPC Server like received Number 8.

Figure 8 OPC Tag homes.

Number 9 Configure OPC tag index number = 0

And also click OK to leave building web pages.

Keep in mind: You can set up connected OPC tags by import OPC tag list from CSV file which export from OPC Web server. Please refer to

And also see “& ldquo; How to fill OPC tags from CSV file”&

rdquo;. 7. Dual click the type to go into to Form_Load occasion code view.

8. Develop the code to attach to OPC server and obtain value 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. Lots


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 worth using ‘& lsquo

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

event name from

dropdown. Number 10 As well as create the code like following

Private Below Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Takes care of MyBase. Closing



End Sub

Note: We use “& ldquo; Application.DoEvents()” & rdquo; to waiting other task to complete before separate from OPC Server.

10. Back to develop sight. Dual click COPC32 control on the type to enter to “& ldquo; datChange & rdquo; event code sight. After that produce the code to present OPC tag value on Label1 when the vale of OPC tag we are attached has actually altered.

Personal Sub 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 create design sight. Dual click on button ‘& lsquo; Write ‘. After that develop code to write vale to OPC tag which has index number = 0.

Exclusive Below Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Takes care of Button1.Click

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

End Below

12. Test program by click F5. Place the number into textbox and also click ‘& lsquo; Create ‘. You can see the vale shown in label is equal to your go into number.

Figure 11

The overall associated code is displayed in Figure 12.

Tinggalkan Balasan