Use COPC32 on Visual Basic.NET

This tutorial will certainly guide 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 COPC32 ActiveX control. And we mean that you have OPC Web server on your neighborhood system currently.

We will certainly create the simple type to read as well as contact OPC server on local systems. However you would, like to attach to remote OPC server. Please configure DCOM on both web 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 develop is received Number 1.

Number 1

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

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

Figure 2

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

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

Figure 3

Then select COPC32 displayed in Figure 4.

Number 4

After that click “& ldquo;

OK & rdquo; 3. Crate a button, a textbox and also tag on kind like received Number 1
read about it COPC32 free download from Our Articles

. 4. Select in toolbox as well as drag out the type.

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

Figure 5

Establish update price to 100 msec. And also select OPC Web server name to desired OPC Web server. You need to go into IP address or device name in ‘& lsquo; nodname ‘ textbox if you would like to link to remote OPC server over the network.

Figure 6

6. Select OPC Tag you wish to link to.

Figure 7

Click OK.

This OPC Tag could be Understandable and also Writable. You can check on your OPC Server like received Figure 8.

Figure 8 OPC Tag residential or commercial properties.

Figure 9 Configure OPC tag index number = 0

As well as click OK to leave property pages.

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

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

And see “& ldquo; Just how to load OPC tags from CSV file”&

rdquo;. 7. Double click on the kind to go into to Form_Load event code view.

8. Develop the code to connect to OPC server and also get worth of OPC tag index 0 to show on Label1.

Personal Below Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Manages 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. Number 10 And also produce the code like following

Personal Below Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase. Closing

Application.DoEvents()

Axcopc1.discnn()

End Below

Note: We use “& ldquo; Application.DoEvents()” & rdquo; to waiting other task to complete prior to separate from OPC Web server.

10. Back to create sight. Dual click COPC32 control on the form to go into to “& ldquo; datChange & rdquo; event code sight. Then develop the code to display OPC tag worth on Label1 when the vale of OPC tag we are connected has altered.

Exclusive 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 create layout view. Dual click button ‘& lsquo; Create ‘. Then create code to write vale to OPC tag which has index number = 0.

Private Sub 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. Place the number right into textbox as well as click ‘& lsquo; Write ‘. You could see the vale received tag is equal to your go into number.

Figure 11

The total related code is displayed in Figure 12.

اترك تعليقا

لن يتم نشر عنوان بريدك الإلكتروني. الحقول الإلزامية مشار إليها بـ *