Usage COPC32 on Visual Basic.NET

This tutorial will guide you just how to use COPC32 on Visual Basic.NET. You need to install COPC32 on your system prior to produce SCADA with Visual.NET and COPC32 ActiveX control. As well as we suppose that you have OPC Server on your neighborhood system already.

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

The kind we will certainly develop is shown in Figure 1.

Figure 1

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

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

Figure 2

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

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

Figure 3

After that pick COPC32 displayed in Figure 4.

Number 4

After that click “& ldquo;

OK & rdquo; 3. Crate a button, a textbox and also label on type like displayed in Figure 1
Read here freewindows10download.com At our site

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

5. Right click COPC32 control on the form and also choose ActiveX residential or commercial properties.

Figure 5

Establish upgrade price to 100 msec. And select OPC Server name to desired OPC Web server. You need to get in IP address or maker name in ‘& lsquo; nodname ‘ textbox if you want to connect to remote OPC server over the network.

Number 6

6. Select OPC Tag you want to attach to.

Figure 7

Click OK.

This OPC Tag could be Readable and Writable. You can check on your OPC Server like displayed in Figure 8.

Number 8 OPC Tag properties.

Number 9 Configure OPC tag index number = 0

And click OK to exit home pages.

Note: You can set up 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 see “& ldquo; Exactly how to pack OPC tags from CSV file”&

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

8. Produce the code to connect to OPC server as well as get value 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. Load

Axcopc1.cnnec()

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

End Sub

Note: If you have configure 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. Number 10 And also create the code like following

Exclusive Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Deals with 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 finish before separate from OPC Server.

10. Back to design sight. Double click COPC32 control on the form to enter to “& ldquo; datChange & rdquo; event code sight. After that develop the code to present OPC tag value on Label1 when the vale of OPC tag we are connected 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 form style sight. Double click switch ‘& lsquo; Compose ‘. After that create 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) Handles Button1.Click

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

End Sub

12. Examination program by click F5. Place the number into textbox and click ‘& lsquo; Write ‘. You might see the vale displayed in label amounts to your get in number.

Number 11

The complete relevant code is received Figure 12.