This tutorial will guide you how to make use of COPC32 on Aesthetic Basic.NET. You have to set up COPC32 on your system prior to produce SCADA with Visual.NET and COPC32 ActiveX control. And we expect that you have OPC Server on your regional system currently.

We will develop the basic kind to read and also contact OPC server on neighborhood systems. However you would, like to attach to remote OPC server. Please configure DCOM on both 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 type we will certainly produce is displayed in Number 1.

Figure 1

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

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

Number 2

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

rdquo;. 2. Add COPC32 ActiveX control right into tool kit by choose menu Tools > > Add/Remove Toolbox Products & hellip;

Figure 3

After that choose COPC32 received Figure 4.

Number 4

After that click “& ldquo;

OK & rdquo; 3. Crate a switch, a textbox and also label on kind like displayed in Number 1
by link free COPC32 download website

. 4. Select in toolbox as well as drag on the form.

5. Right click on COPC32 control on the type as well as select ActiveX homes.

Number 5

Establish upgrade rate to 100 msec. As well as choose OPC Server name to desired OPC Web server. You have to get in IP address or machine name in ‘& lsquo; nodname ‚ textbox if you wish to link to remote OPC server over the network.

Figure 6

6. Select OPC Tag you want to attach to.

Number 7

Click OK.

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

Figure 8 OPC Tag properties.

Number 9 Configure OPC tag index number = 0

And also click OK to exit residential property pages.

Note: You can set up linked OPC tags by import OPC tag checklist from CSV documents which export from OPC Web server. Please describe

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

As well as see “& ldquo; How to pack OPC tags from CSV documents”&

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

8. Produce the code to connect to OPC server as well as get value of OPC tag index 0 to show on Label1.

Personal Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Manages MyBase. Tons

Axcopc1.cnnec()

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

End Below

Keep in mind: If you have configure various 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 And also create the code like complying with

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

Application.DoEvents()

Axcopc1.discnn()

End Sub

Keep in mind: We make use of “& ldquo; Application.DoEvents()” & rdquo; to waiting various other job to complete prior to detach from OPC Server.

10. Back to design view. Dual click on COPC32 control on the kind to enter to “& ldquo; datChange & rdquo; occasion code view. After that produce the code to display OPC tag worth on Label1 when the vale of OPC tag we are connected has altered.

Exclusive 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 develop layout view. Double click button ‘& lsquo; Create ‚. After that develop code to write vale to OPC tag which has index number = 0.

Private Below Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Deals with Button1.Click

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

End Sub

12. Test program by click F5. Put the number into textbox and click ‘& lsquo; Compose ‚. You could see the vale displayed in label is equal to your enter number.

Figure 11

The overall related code is displayed in Number 12.