Usage COPC32 on Visual Basic.NET

This tutorial will certainly direct you exactly how to make use of COPC32 on Aesthetic Basic.NET. You have to mount COPC32 on your system before develop SCADA with Visual.NET as well as COPC32 ActiveX control. And we expect that you have OPC Server on your local system already.

We will certainly produce the straightforward type to review and contact OPC web server on neighborhood systems. Yet you would, like to link to remote OPC server. Please set up DCOM on both web server and also customer side by refer to tutorial of KEPWare at http://www.kepware.com/Support_Center/Viewlets/XP_sp2_viewlet_swf.html

The type we will certainly produce is displayed in Number 1.

Figure 1

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

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

Figure 2

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

rdquo;. 2. Add COPC32 ActiveX control right into toolbox by select food selection Devices > > Add/Remove Tool kit Items & hellip;

Figure 3

Then choose COPC32 shown in Number 4.

Figure 4

Then click “& ldquo;

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

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

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

Number 5

Set upgrade rate to 100 msec. And select OPC Web server name to desired OPC Web server. You have to get in IP address or device name in ‘& lsquo; nodname ‘ textbox if you want to connect to remote OPC web server over the network.

Figure 6

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

Number 7

Click OK.

This OPC Tag could be Understandable and also Writable. You can examine your OPC Web server like displayed in Figure 8.

Number 8 OPC Tag buildings.

Number 9 Configure OPC tag index number = 0

As well as click OK to leave residential or commercial property web pages.

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

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

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

rdquo;. 7. Double click on the form to enter to Form_Load event code view.

8. Develop the code to attach to OPC server and get value of OPC tag index 0 to reveal on Label1.

Private Below Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase. Tons

Axcopc1.cnnec()

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

End Below

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

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

occasion name from

dropdown. Figure 10 And create the code like following

Personal Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Deals with MyBase. Closing

Application.DoEvents()

Axcopc1.discnn()

End Below

Note: We use “& ldquo; Application.DoEvents()” & rdquo; to waiting various other job to finish prior to separate from OPC Server.

10. Back to make view. Dual click COPC32 control on the kind to go into to “& ldquo; datChange & rdquo; occasion code sight. After that produce the code to present OPC tag value on Label1 when the vale of OPC tag we are attached has altered.

Personal 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 form layout sight. Double click on button ‘& lsquo; Write ‘. Then produce code to write vale to OPC tag which has index number = 0.

Exclusive Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

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

End Sub

12. Examination program by click F5. Insert the number right into textbox and also click ‘& lsquo; Create ‘. You might see the vale received label is equal to your enter number.

Number 11

The overall relevant code is displayed in Number 12.