Usage COPC32 on Visual Basic.NET

This tutorial will certainly lead you how to utilize COPC32 on Aesthetic Basic.NET. You have to set up COPC32 on your system prior to create SCADA with Visual.NET as well as COPC32 ActiveX control. And also we mean that you have OPC Server on your neighborhood system currently.

We will certainly create the basic kind to read as well as contact OPC server on regional systems. But you would certainly, like to attach to remote OPC server. Please configure DCOM on both web server and also client side by refer to tutorial of KEPWare at http://www.kepware.com/Support_Center/Viewlets/XP_sp2_viewlet_swf.html

The kind we will produce is received Number 1.

Figure 1

When customer insert numerical worth in textbox and click button ‘& lsquo; Compose ‘, COPC32 will certainly contact OPC tag and reveal its worth 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 project as “& ldquo; TestCOPC32VBNET &

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

Number 3

Then pick COPC32 shown in Number 4.

Figure 4

After that click “& ldquo;

OK & rdquo; 3. Crate a switch, a textbox and label on form like received Number 1
Read more COPC32 Free At website Articles

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

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

Number 5

Set upgrade rate to 100 msec. As well as select OPC Server name to preferred OPC Web server. You have to go into IP address or machine name in ‘& lsquo; nodname ‘ textbox if you would love to connect to remote OPC web server over the network.

Figure 6

6. Select OPC Tag you want 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 displayed in Number 8.

Figure 8 OPC Tag properties.

Number 9 Configure OPC tag index number = 0

As well as click OK to exit property pages.

Note: You can configure linked OPC tags by import OPC tag checklist from CSV documents which export from OPC Server. Please describe

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

And also see “& ldquo; Exactly how to load OPC tags from CSV file”&

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

8. Produce the code to connect to OPC web server and also get worth of OPC tag index 0 to show on Label1.

Private Below Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Manages MyBase. Load

Axcopc1.cnnec()

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

End Sub

Keep in mind: If you have configure various other OPC tag such as OPC tag index number = 1. You can obtain its value using ‘& lsquo

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

event name from

dropdown. Number 10 And also produce the code like adhering to

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

Application.DoEvents()

Axcopc1.discnn()

End Below

Note: We make use of “& ldquo; Application.DoEvents()” & rdquo; to waiting various other task to end up prior to separate from OPC Web server.

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

Private 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 create layout sight. Double click on button ‘& lsquo; Create ‘. After that create 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) Manages Button1.Click

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

End Below

12. Examination program by click F5. Place the number right into textbox and click ‘& lsquo; Compose ‘. You could see the vale shown in tag amounts to your get in number.

Number 11

The complete associated code is displayed in Figure 12.