Usage COPC32 on Visual Basic.NET

This tutorial will certainly lead you just how to utilize COPC32 on Aesthetic Basic.NET. You need to install COPC32 on your system before create SCADA with Visual.NET as well as COPC32 ActiveX control. And we intend that you have OPC Server on your neighborhood system already.

We will create the basic kind to review as well as contact OPC server on neighborhood systems. Yet you would, like to connect to remote OPC web server. Please set up DCOM on both server as well as customer 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 shown in Number 1.

Number 1

When customer insert numeric worth in textbox and also click button ‘& lsquo; Compose ‘, COPC32 will certainly contact OPC tag and reveal its worth on ‘& lsquo

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

Number 2

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

rdquo;. 2. Add COPC32 ActiveX control into toolbox by select menu Devices > > Add/Remove Toolbox Products & hellip;

Number 3

After that choose COPC32 received Figure 4.

Number 4

Then click “& ldquo;

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

. 4. Select in toolbox and also drag on the form.

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

Number 5

Establish update price to 100 msec. And also choose OPC Web server name to desired OPC Server. You have to enter IP address or equipment name in ‘& lsquo; nodname ‘ textbox if you want to connect to remote OPC server over the network.

Figure 6

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

Figure 7

Click OK.

This OPC Tag could be Readable and also Writable. You can examine your OPC Server like displayed in Number 8.

Figure 8 OPC Tag properties.

Number 9 Configure OPC tag index number = 0

And click OK to leave residential or commercial property pages.

Note: You can configure linked OPC tags by import OPC tag checklist from CSV data 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 documents”&

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

8. Produce the code to link to OPC web server and obtain value of OPC tag index 0 to reveal on Label1.

Exclusive Below Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Manages MyBase. Tons

Axcopc1.cnnec()

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

End Below

Keep in mind: If you have set up various other OPC tag such as OPC tag index number = 1. You can get its worth utilizing ‘& lsquo

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

occasion name from

dropdown. Figure 10 And produce 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 make use of “& ldquo; Application.DoEvents()” & rdquo; to waiting various other job to end up prior to separate from OPC Web server.

10. Back to make sight. Dual click on COPC32 control on the form to get in to “& ldquo; datChange & rdquo; event code view. After that develop the code to display OPC tag value on Label1 when the vale of OPC tag we are linked has actually altered.

Personal 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 view. Dual click button ‘& lsquo; Compose ‘. Then produce code to write 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 Sub

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

Number 11

The overall related code is shown in Figure 12.

Leave a Reply

Your email address will not be published. Required fields are marked *