Usage COPC32 on Visual Basic.NET

This tutorial will certainly assist you how to use COPC32 on Visual Basic.NET. You need to set up COPC32 on your system before develop SCADA with Visual.NET and COPC32 ActiveX control. And also we mean that you have OPC Server on your neighborhood system already.

We will certainly produce the basic form to read as well as write to OPC web server on regional systems. However you would certainly, like to attach to remote OPC server. Please set up 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 type we will develop is shown in Number 1.

Number 1

When customer insert numeric worth in textbox and click switch ‘& lsquo; Create ‘, COPC32 will certainly write to OPC tag and also show its value on ‘& lsquo

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

Number 2

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

rdquo;. 2. Include COPC32 ActiveX control into toolbox by pick menu Devices > > Add/Remove Tool kit Items & hellip;

Number 3

After that choose COPC32 displayed in Number 4.

Figure 4

After that click “& ldquo;

OK & rdquo; 3. Crate a button, a textbox and tag on form like shown in Figure 1
Join Us COPC32 free download website

. 4. Select in tool kit and also drag on the type.

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

Figure 5

Set update price to 100 msec. And also select OPC Web server name to desired OPC Server. You have to get in IP address or device name in ‘& lsquo; nodname ‘ textbox if you want to link to remote OPC server over the network.

Figure 6

6. Select OPC Tag you want to connect to.

Figure 7

Click OK.

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

Figure 8 OPC Tag buildings.

Number 9 Configure OPC tag index number = 0

And also click OK to exit building web pages.

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

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

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

rdquo;. 7. Double click on the type to enter to Form_Load event code sight.

8. Create 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) Takes care of MyBase. Tons

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

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

event name from

dropdown. Figure 10 As well as develop the code like following

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 utilize “& ldquo; Application.DoEvents()” & rdquo; to waiting various other job to end up before detach from OPC Web server.

10. Back to make sight. Dual click COPC32 control on the form to go into to “& ldquo; datChange & rdquo; occasion code view. Then create the code to display OPC tag worth 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) Manages Axcopc1.datChange

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

End Sub

11. Back to create design sight. Dual click button ‘& lsquo; Compose ‘. After that create 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) Handles Button1.Click

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

End Sub

12. Examination program by click F5. Place the number right into textbox as well as click ‘& lsquo; Create ‘. You might see the vale shown in label is equal to your get in number.

Number 11

The overall relevant code is displayed in Number 12.