Usage COPC32 on Visual Basic.NET

This tutorial will lead you how to make use of COPC32 on Visual Basic.NET. You need to mount COPC32 on your system prior to produce SCADA with Visual.NET and also COPC32 ActiveX control. And also we expect that you have OPC Server on your neighborhood system currently.

We will certainly create the straightforward type to review and contact OPC server on local systems. However you would certainly, like to connect to remote OPC web server. Please configure DCOM on both web server as well as customer side by describe tutorial of KEPWare at http://www.kepware.com/Support_Center/Viewlets/XP_sp2_viewlet_swf.html

The form we will certainly create is shown in Number 1.

Figure 1

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

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

Number 2

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

rdquo;. 2. Add COPC32 ActiveX control into toolbox by select menu Devices > > Add/Remove Toolbox Items & hellip;

Number 3

Then choose COPC32 displayed in Number 4.

Figure 4

Then click “& ldquo;

OK & rdquo; 3.by link COPC32 Download website Crate a switch, a textbox and tag on type like received Figure 1

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

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

Number 5

Set update rate to 100 msec. And also pick OPC Web server name to preferred OPC Web server. You have to enter IP address or maker name in ‘& lsquo; nodname ‘ textbox if you wish to attach to remote OPC server over the network.

Figure 6

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

Number 7

Click OK.

This OPC Tag could be Legible and Writable. You can check on your OPC Web server like received Number 8.

Number 8 OPC Tag residential or commercial properties.

Figure 9 Configure OPC tag index number = 0

As well as click OK to exit property web pages.

Note: You can set up connected OPC tags by import OPC tag list from CSV documents which export from OPC Web server. Please refer to

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

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

rdquo;. 7. Dual click on the kind to get in to Form_Load event code sight.

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

Exclusive Sub 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

Keep in mind: If you have set up other OPC tag such as OPC tag index number = 1. You can get its worth making use of ‘& lsquo

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

occasion name from

dropdown. Figure 10 And develop the code like following

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

Application.DoEvents()

Axcopc1.discnn()

End Below

Keep in mind: We use “& ldquo; Application.DoEvents()” & rdquo; to waiting various other task to finish before disconnect from OPC Server.

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

Private Sub Axcopc1_datChange(ByVal sender As Object, ByVal e As System.EventArgs) Deals with Axcopc1.datChange

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

End Below

11. Back to form style view. Dual click button ‘& lsquo; Compose ‘. Then develop code to create vale to OPC tag which has index number = 0.

Personal Sub 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. Examination program by click F5. Place the number right into textbox and also click ‘& lsquo; Write ‘. You could see the vale received label amounts to your enter number.

Number 11

The complete relevant code is shown in Figure 12.

Comments are closed.