0934.055.555

Usage COPC32 on Visual Basic.NET

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

We will certainly develop the easy type to review and also write to OPC server on local systems. But you would, like to attach to remote OPC server. Please configure DCOM on both web server and also client side by describe tutorial of KEPWare at http://www.kepware.com/Support_Center/Viewlets/XP_sp2_viewlet_swf.html

The form we will create is displayed in Number 1.

Figure 1

When customer insert numerical worth in textbox and also click button ‘& lsquo; Compose ‘, COPC32 will write to OPC tag as well as show its value on ‘& lsquo

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

Figure 2

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

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

Number 3

After that pick COPC32 displayed in Figure 4.

Number 4

After that click “& ldquo;

OK & rdquo; 3.More Here COPC32 Free At our site Crate a button, a textbox as well as label on kind like received Number 1

. 4. Select in tool kit and also drag out the form.

5. Right click on COPC32 control on the type and pick ActiveX properties.

Number 5

Establish upgrade rate to 100 msec. As well as choose OPC Web server name to wanted OPC Web server. You have to go into IP address or machine name in ‘& lsquo; nodname ‘ textbox if you wish to attach to remote OPC server over the network.

Number 6

6. Select OPC Tag you want to attach to.

Number 7

Click OK.

This OPC Tag could be Readable and also Writable. You can check on your OPC Server like shown in Number 8.

Number 8 OPC Tag buildings.

Number 9 Configure OPC tag index number = 0

And also click OK to exit home pages.

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

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

And see “& ldquo; Exactly how to fill OPC tags from CSV documents”&

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

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

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Takes care of MyBase. Lots

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 value utilizing ‘& lsquo

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

event name from

dropdown. Figure 10 And create the code like adhering to

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

Application.DoEvents()

Axcopc1.discnn()

End Sub

Keep in mind: We use “& ldquo; Application.DoEvents()” & rdquo; to waiting various other task to end up prior to separate from OPC Server.

10. Back to design sight. Double click COPC32 control on the kind to enter to “& ldquo; datChange & rdquo; event code view. After that produce the code to show OPC tag value on Label1 when the vale of OPC tag we are attached has actually transformed.

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

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

End Below

11. Back to develop style view. Dual click button ‘& lsquo; Compose ‘. After that produce code to compose vale to OPC tag which has index number = 0.

Exclusive 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 right into textbox and also click ‘& lsquo; Write ‘. You might see the vale received label amounts to your enter number.

Figure 11

The complete relevant code is received Figure 12.