Use COPC32 on Visual Basic.NET

Use COPC32 on Visual Basic.NET

This tutorial will certainly assist you exactly how to make use of COPC32 on Visual Basic.NET. You need to install COPC32 on your system prior to create SCADA with Visual.NET and COPC32 ActiveX control. As well as we mean that you have OPC Server on your regional system currently.

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

The type we will certainly develop is displayed in Figure 1.

Number 1

When customer insert numerical worth in textbox as well as click switch ‘& lsquo; Compose ‘, COPC32 will contact OPC tag as well as reveal its value on ‘& lsquo

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

Figure 2

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

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

Figure 3

Then choose COPC32 displayed in Figure 4.

Number 4

Then click “& ldquo;

OK & rdquo; 3. Crate a button, a textbox and tag on type like displayed in Number 1
More Here COPC32 Download for Windows At our site

. 4. Select in tool kit and drag out the type.

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

Figure 5

Set update rate to 100 msec. And pick OPC Server name to preferred OPC Web server. You need to enter IP address or machine name in ‘& lsquo; nodname ‘ textbox if you wish to connect to remote OPC web server over the network.

Number 6

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

Figure 7

Click OK.

This OPC Tag could be Understandable and also Writable. You can look at your OPC Server like displayed in Figure 8.

Figure 8 OPC Tag residential properties.

Figure 9 Configure OPC tag index number = 0

As well as click OK to leave building web pages.

Note: You can set up linked OPC tags by import OPC tag listing from CSV documents which export from OPC Web server. Please describe

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

And also see “& ldquo; How to pack OPC tags from CSV data”&

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

8. Produce the code to connect to OPC web server as well as get value of OPC tag index 0 to show on Label1.

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

Axcopc1.cnnec()

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

End Below

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;

occasion name from

dropdown. Number 10 And create the code like complying with

Personal Below 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 utilize “& ldquo; Application.DoEvents()” & rdquo; to waiting other job to complete prior to separate from OPC Web server.

10. Back to design sight. Double click COPC32 control on the form to get in to “& ldquo; datChange & rdquo; event code sight. Then produce the code to present OPC tag worth on Label1 when the vale of OPC tag we are connected has actually changed.

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

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

End Below

11. Back to form style sight. Double click switch ‘& lsquo; Write ‘. After that develop code to create vale to OPC tag which has index number = 0.

Exclusive Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

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

End Below

12. Examination program by click F5. Put the number into textbox and click ‘& lsquo; Compose ‘. You might see the vale displayed in label is equal to your get in number.

Figure 11

The total associated code is shown in Figure 12.