Blogブログ

Lumiere Hair&Spa お知らせや日々のブログページです♪

Use COPC32 on Visual Basic.NET

This tutorial will certainly assist you how to utilize COPC32 on Aesthetic Basic.NET. You need to set up COPC32 on your system prior to produce SCADA with Visual.NET and also COPC32 ActiveX control. And also we expect that you have OPC Web server on your neighborhood system already.

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

The type we will certainly develop is shown in Number 1.

Figure 1

When customer insert numerical worth in textbox and also click switch ‘& lsquo; Create ‘, COPC32 will certainly contact OPC tag and also reveal 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. Add COPC32 ActiveX control into toolbox by pick food selection Tools > > Add/Remove Tool kit Products & hellip;

Number 3

Then choose COPC32 received Number 4.

Number 4

Then click “& ldquo;

OK & rdquo; 3. Crate a switch, a textbox as well as tag on kind like displayed in Figure 1
Join Us bitCOPC32 Download website

. 4. Select in tool kit and also drag out the kind.

5. Right click on COPC32 control on the form as well as pick ActiveX properties.

Number 5

Establish update price to 100 msec. As well as choose OPC Web server name to wanted OPC Web server. You need to go into IP address or machine name in ‘& lsquo; nodname ‘ textbox if you wish to link to remote OPC web server over the network.

Number 6

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

Number 7

Click OK.

This OPC Tag could be Readable and also Writable. You can check on your OPC Web server like displayed in Number 8.

Figure 8 OPC Tag residential properties.

Figure 9 Configure OPC tag index number = 0

And also click OK to exit home pages.

Keep in mind: You can configure connected OPC tags by import OPC tag listing from CSV documents which export from OPC Web server. Please refer to

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

As well as see “& ldquo; Just how to load OPC tags from CSV documents”&

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

8. Produce the code to connect to OPC web server and also obtain 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 configure other OPC tag such as OPC tag index number = 1. You can get its worth making use of ‘& lsquo

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

occasion name from

dropdown. Number 10 As well as produce the code like adhering to

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

10. Back to design sight. Dual click COPC32 control on the kind to enter 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 connected has actually changed.

Private Sub 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 create design view. Double click switch ‘& lsquo; Create ‘. After that 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. Examination program by click F5. Insert the number right into textbox and click ‘& lsquo; Create ‘. You might see the vale shown in tag amounts to your get in number.

Number 11

The complete associated code is received Number 12.

  1. この記事へのコメントはありません。

  1. この記事へのトラックバックはありません。

関連記事

%d人のブロガーが「いいね」をつけました。