! Без рубрики

Usage COPC32 on Visual Basic.NET

This tutorial will certainly assist you how to utilize COPC32 on Visual 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 mean that you have OPC Web server on your regional system already.

We will produce the simple form to check out and contact OPC server on neighborhood systems. But you would, like to link to remote OPC web server. Please configure DCOM on both web server and also customer side by describe tutorial of KEPWare at

The form we will create is displayed in Number 1.

Number 1

When individual insert numeric value in textbox as well as click switch ‘& lsquo; Write ‘, COPC32 will certainly contact OPC tag and also show its value on ‘& lsquo

  1. ; Label1 ‘. Open Up Visual Studio.NET as well as crate new job with VB.NET

Number 2

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

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

Figure 3

Then choose COPC32 received Figure 4.

Number 4

After that click “& ldquo;

OK & rdquo; 3. Crate a button, a textbox and also tag on form like displayed in Number 1
you can find more here COPC32 Download from Our Articles

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

5. Right click on COPC32 control on the form as well as choose ActiveX buildings.

Number 5

Establish upgrade rate to 100 msec. And also choose OPC Server name to preferred OPC Web server. You need to enter IP address or maker 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 want to connect to.

Number 7

Click OK.

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

Figure 8 OPC Tag residential properties.

Figure 9 Configure OPC tag index number = 0

And click OK to leave residential property web pages.

Note: You can configure connected OPC tags by import OPC tag list from CSV data which export from OPC Web server. Please describe

And also see “& ldquo; Just how to load OPC tags from CSV data”&

rdquo;. 7. Double click on the form to enter to Form_Load occasion code sight.

8. Create the code to link 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. Tons


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

End Sub

Note: If you have configure other OPC tag such as OPC tag index number = 1. You can get its worth using ‘& lsquo

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

occasion name from

dropdown. Figure 10 And also create the code like following

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



End Below

Keep in mind: We utilize “& ldquo; Application.DoEvents()” & rdquo; to waiting other task to finish before detach from OPC Web server.

10. Back to create view. Double click on COPC32 control on the type to get in to “& ldquo; datChange & rdquo; event code sight. Then develop the code to present OPC tag worth on Label1 when the vale of OPC tag we are linked has actually changed.

Exclusive 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 develop design view. Double click switch ‘& 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 Below

12. Examination program by click F5. Insert the number right into textbox and click ‘& lsquo; Compose ‘. You can see the vale displayed in tag is equal to your enter number.

Number 11

The total relevant code is shown in Figure 12.

Leave a Reply

Your email address will not be published. Required fields are marked *