02 Dec 2020
December 2, 2020

Usage COPC32 on Visual Basic.NET

0 Comment

This tutorial will direct you just how to use COPC32 on Visual Basic.NET. You have to install COPC32 on your system before produce SCADA with Visual.NET and also COPC32 ActiveX control. And we intend that you have OPC Web server on your regional system already.

We will create the basic form to review and also contact OPC web server on local systems. But you would, like to connect to remote OPC server. Please configure DCOM on both server and client side by refer to 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 value in textbox and also click button ‘& lsquo; Write ‘, COPC32 will write to OPC tag and also reveal its worth on ‘& lsquo

  1. ; Label1 ‘. Open Up Visual Studio.NET and crate new task with VB.NET

Number 2

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

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

Number 3

Then pick COPC32 displayed in Number 4.

Number 4

Then click “& ldquo;

OK & rdquo; 3. Crate a button, a textbox as well as label on type like displayed in Number 1
Read more bitCOPC32 Download At website Articles

. 4. Select in toolbox and drag out the form.

5. Right click on COPC32 control on the form as well as choose ActiveX homes.

Number 5

Set upgrade price to 100 msec. And pick OPC Web server name to preferred OPC Server. You need to go into IP address or maker name in ‘& lsquo; nodname ‘ textbox if you would like to attach to remote OPC server over the network.

Figure 6

6. Select OPC Tag you would love to attach to.

Number 7

Click OK.

This OPC Tag could be Legible and also Writable. You can check on your OPC Web server like shown in Figure 8.

Figure 8 OPC Tag residential or commercial properties.

Number 9 Configure OPC tag index number = 0

And click OK to leave home pages.

Note: You can configure connected 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

As well as see “& ldquo; How to load OPC tags from CSV file”&

rdquo;. 7. Dual click the form to go into to Form_Load event code sight.

8. Create the code to attach to OPC web server and obtain worth of OPC tag index 0 to reveal on Label1.

Exclusive Below Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase. Lots

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 obtain its worth utilizing ‘& lsquo

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

occasion name from

dropdown. Number 10 And also develop the code like following

Exclusive Sub 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 make use of “& ldquo; Application.DoEvents()” & rdquo; to waiting various other job to end up prior to separate from OPC Server.

10. Back to develop view. Dual click COPC32 control on the kind to get in to “& ldquo; datChange & rdquo; occasion code view. Then create the code to display OPC tag value on Label1 when the vale of OPC tag we are connected has actually changed.

Exclusive Below Axcopc1_datChange(ByVal sender As Object, ByVal e As System.EventArgs) Deals with Axcopc1.datChange

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

End Sub

11. Back to develop design view. Dual click button ‘& lsquo; Write ‘. After that create code to create vale to OPC tag which has index number = 0.

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

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

End Below

12. Examination program by click F5. Put the number right into textbox as well as click ‘& lsquo; Write ‘. You could see the vale shown in label amounts to your go into number.

Number 11

The complete relevant code is shown in Number 12.