Previously, we create My OPC Client project, the latest is version 5, with some advanced feature. But some friends need more simple application, so we create this project. The purpose of the application is to connect to OPC Server, Read data and Write data. So here is MySimpleOPCClient..
For testing, we use Matrikon OPC Explorer, you can download from here.
Please download MySimpleOPCClient project source code from here.
The steps:
1. Run Matrikon OPC Explorer
2. Create group, and add some items to monitor, ie "Bucket Brigade.Int1"
4. Run MySimpleOPCClient
5. Write "Matrikon.OPC.Simulation.1" on OPC Server Name textbox
6. Click Connect button
7. On OPC Item textbox, write "Bucket Brigade.Int1"
8. Click on Add Item button
9. The value of item is automatically loaded to the Read Value textbox
10. Try to write new value on Write Value textbox, then click on Write button
Note:
Before opening the project, please make sure you have OPCDAAuto.dll installed/registered on your system. Please follow these steps to register the DLL:
> download DLL from here
> copy file to /System32 folder
> open CMD (command prompt)
> write this command: "regsvr32 OPCDAAuto.dll"
We create this project with MS Visual Studio Express 2010, and we targeted to .NET Framework 4. If you get some problem, please let us know.
See you next time.. Thank you...
Wow! Thanks a lot!
ReplyDeleteSo simple and functionally ;)
Thank you..
Deletehello,can you help me Mister hadi hidayat,i went to send data from c# to labview so i will use ni opc server from national instrument and in c# i need to build opc client how can communicacat with ni opc server,please i need a help
ReplyDeletei need a code of opc client in c# witch i can send data to ni opc server im sorry im not native speaker
ReplyDeleteHi,
Deleteyou can convert the source code here from VB to C using this tool:
http://www.developerfusion.com/tools/convert/vb-to-csharp/
Thanks.
Hi
ReplyDeleteI can't install the OPCDAAuto.dll
I'm always getting "The specified module can not be found"
I must say that I'm using a 64-bit WIN7 operating system
Can you help me out?
Hi..
Deletetry:
> copy OPCDAAuto.dll to folder C:\windows\syswow64
> open Command Prompt with "Run as Administrator"
> type: "cd \windows\syswow64"
> type: "regsvr32 OPCDAAuto.dll"
Thanks.
Thanks! Now going to try to communicate with Simatic NET OPC Server.
DeleteHello Hadi,
ReplyDeleteYour blogs are wonderful and very much supportive for me.
I need documentation of the dlls (OPCDAAuto.dll and Interop.OPCAutomation.dll) you used in the project.
Thanks.
Regards,
Fahad
Hello,
DeleteThanks for your appreciation.
Please visit OPC Foundation website here:
https://opcfoundation.org/developer-tools/developer-kits-classic/core-components
or you can ask to OPC Foundation support by email.
Hi Hadi, thank you for the codes, they are very useful and precious.
ReplyDeleteHi Mateus... You are welcome.
DeleteThanks, I'm a benginner in VB.net, do you know if is possible to convert your code to a console aplication?
DeleteI'm trying but if this not possible I will stop to try it.
Hi..
DeleteSorry, I dont know about that. But I think, it's better for you to try.. so you will know the answer..
Good luck!
This comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteHello Hadi and thank you for your work. I have tested your applicaiton My OPCClientC on window 7 64 bit SP1 and it doesn't work. When click on List OPC servers, there is an unhandeled exception HRESULT E_FAIL has been returned from a call to a COM component.
ReplyDeleteI have previously successfully registered OPCDAAuto.dll in syswow64 folder.
maybe you can open the VB project, then you can do debugging, find out where is the error occurs.
DeleteThanks.
Hello Hadi, Does your software also work with the OPC UA standard? Ho installato il Prosys OPC UA Simulation Server e purtroppo col tuo sofware non riesco a connettermi ... riesci ad aiutarmi? Maurizio Romerio (ITALIA, Arona -NO)
ReplyDeleteHello Hadi, Does your software also work with the OPC UA standard? I installed the Prosys OPC UA Simulation Server and unfortunately with your software I can't connect ... can you help me? Maurizio Romerio (ITALIA, Arona -NO) studium@progettoleonardo.it
ReplyDeletemy OPC project not yet support OPC UA.
Deletethanks..
hello hadi, your code works perfectly with the opc im trying to connect, thank you for sharing it with the world... however i would like to ask for your help, im trying to read more than one item form an opc server but cant manage to create a working code to do so, could you share with me an example or some documentation for me to understand the codes, ... best regars!
ReplyDeleteplease try https://hadiscada.blogspot.com/2013/07/my-opc-client.html
Deleteini dll nya udh full kah om??
ReplyDeletemaksudnya tanpa ada batas waktu nya??
iya
DeleteHi , can you say this client use which port to connect to opc, i try connect to opc in another pc . But get ACCESS DENIED ERROR.
ReplyDeleteHi..
Deleteit use default OPC port (502)..
to access OPC Server in another PC, you must set/config DCOM first.
Thanks.
Hi Hadi,
ReplyDeletePlease could you help. How do you browse the OPC server for all tags?
you can use MyOPCClient project, here: https://hadiscada.blogspot.com/2013/07/my-opc-client.html
DeleteHi Hadi,
ReplyDeleteHope u r doing well.
U did great work by writing above code for learners.
Well, I want to ask you that I need to add more items in same group to read more value from PLC, so how can i do this ?
Should I add below lines
AddHandler MyOPCGroup.DataChange, AddressOf
MyOPCGroup_Datachange1
AddHandler MyOPCGroup.AsyncReadComplete, AddressOf MyOPCGroup_AsyncReadComplete1
Private Sub MyOPCGroup_Datachange1(ByVal TransactionID As Integer, ByVal NumItems As Integer, ByRef ClientHandles As System.Array, ByRef ItemValues1 As System.Array, ByRef Qualities As System.Array, ByRef TimeStamps As System.Array)
TextBoxReadOUT.Text = ItemValues1(1)
End Sub
OR
Kindly tell about code which I should write to get more values.
Thanks
HK
i think you can see in My OPC Client article.
DeleteHI this is really good, exactly what I'm looking for. Unfortunately I get an error caught by the try when clicking on Connect. It doesn't matter what I enter into the server name box, I get the same error regardless. The error message is 'Invalid Class String' (Exception from HRESULT 0x800401F3 (CO_E_CLASSSTRING)
ReplyDeleteAny help would be greatly appreciated , thanks a lot.
i think you have problem with OPCDAAuto.dll, please check is it already successfully registered in your PC.
Deleteproject file is not accessible. please see link
ReplyDeleteSorry. I already update the link, please try again. Thanks.
Delete