VB .NET OPC Client to poll values -- needs speed boost

FSEIPEL

Member
Join Date
Nov 2013
Location
cOLUMBUS OHIO
Posts
27
I still have a 1756-eWEB but I want to upgrade to an IIS server so I have faster screen redraws; with it, I can cache values. This provides read-only access to plant operating values.

To do this, I copied all the web pages over to IIS. Now, I just need a simple VB .NET program to write out the present values to XML files continuously at intervals -- this will give me a 'virtual' eWEB card, since the pages will render live data with operator graphics.

I have RSLINX Gateway, and can get it to read values in concert with a short VB .NET program below. I have referenced RSIOPCAUTO.DLL and all went well.

My problem is simple -- it is slow as can be. I think I need to do ASYNCREAD but I don't understand how to do so. I want to read around 200 tags every couple of seconds.

If I can have some assistance with altering this to scan quickly, I can easily make the changes to write out the data files to the web pages.

Also, a link to documentation of RSIOPCAUTO.DLL's properties and methods would also be helpful -- I can't seem to find, even on Tech Connect.

-Frank


Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Note: YOU MUST add C:\Program Files (x86)\Common Files\Rockwell\RsiOPCAuto.dll as a reference
' to read ControlLogix tags. If immediate window not present press control + g to display it.


Dim OpcServer As New RsiOPCAuto_OPCServer
Dim OpcGroup As RsiOPCAuto_OPCGroup
Dim OpcItem As RsiOPCAuto_OPCItem
Dim vItem As String = ""

Try


OpcServer.Connect("RSLinx OPC Server", "192.168.9.200")

' Add this group to the shared topic
OpcGroup = OpcServer.OPCGroups.Add("INDEC")
OpcGroup.IsSubscribed = True
OpcGroup.IsActive = True
OpcGroup.UpdateRate = 1000

OpcGroup.OPCItems.DefaultAccessPath = "Controller"
OpcGroup.OPCItems.AddItem("TE_500", 1)
OpcGroup.OPCItems.AddItem("TE_501", 1)
OpcGroup.OPCItems.AddItem("TE_502", 1)
OpcGroup.OPCItems.AddItem("TE_503", 1)
OpcGroup.OPCItems.AddItem("TE_506", 1)
OpcGroup.OPCItems.AddItem("TE_505", 1)



For I = 1 To 10
For J = 1 To 6
OpcItem = OpcGroup.OPCItems.Item(J)
OpcItem.Read(2, vItem)

System.Diagnostics.Debug.WriteLine(I & "," & J & "," & vItem & ";" & DateTime.Now)
Next J

Next I

OpcItem = Nothing
OpcServer.OPCGroups.RemoveAll()
OpcGroup = Nothing
OpcServer.Disconnect()
OpcServer = Nothing

'Add and Error the list box
Catch ex As PlatformNotSupportedException
MsgBox("Error In Get Plc Data: " & ex.Message)
End Try


End Sub
End Class
 
I can give you an alternative that may make your life easier. AdvancedHMI has both a native ControlLogix driver (no need for RSLinx) and an OPC DA wrapper that tremendously simplifies using OPC in .NET. For example, this is how you can get PLC data via native driver:

- After downloading and extracting the AdvancedHMI solution, open is Visual Studio
- Build the solution
- From the Toolbox add an EthernetIPforCLXCom driver to the form
- In the properties, set the IP address of your PLC
- From the Toolbox, Add a button to the form
- Double click the button to get back to the code
- Add this code:

Dim MyValue as string=EthernetIPforCLXCom1.Read("MyTag")
msgbox "The value is " & MyValue


If you want to use RSLinx, it is a very similar process, except you will add an OpcDaCom driver to the form, set the OPCServerName and OPCTopic

The code will then be:

Dim MyValue as string=OpcDaCom1.Read("MyTag")
msgbox "The value is " & MyValue


Of course AdvancedHMI's main purpose is to be able to build HMI's without writing a single line of code by using the controls from the Toolbox and PLCAddress properties, but it gives you full flexibility of using the drivers within code.
 
AdvancedHMI

Thanks, I've been reading the forum, and actually downloaded AdvancedHMI, but I was having trouble understanding how to establish a link to the OPC Server, I will try what you have outlined. Thanks for producing such a wonderful, open source HMI solution... It seems like an ideal solution that users could just double click to view data. I also want to look into what sort of plotting capabilities it has -- I've implemented a fairly decent plotting solution that works via a browser, using the RSView32 datalogs as written to a SQL server, coupled to the open source Dygraphs library (which allows zooming), but it is also giving me problems... The SQL Express chokes with an 'out of buffers' error, when I try to index the 'Tagindex' field -- indexing it would greatly speed up queries and thus plotting. I'm thinking I just need to move floattable to a MySQL database which seems less restrictive on its indexing capabilities.
 
In the AdancedHMI\Documents foldwe is a pdf named OPCCommUsage that goes through step by step on using RSLinx as an OPC server. That document is slightly old, so the driver name in the latest OpcDaCom.

If the PC you are running the application can directly connect to the PLC, I would recommend the EthernetIPforCLXCom driver. It is easier to use and faster than OPC.

If your OPC server is on a remote PC, you will need to modify the driver code. This is discussed in this thread:

http://advancedhmi.com/forum/index.php?topic=626.msg2880#msg2880
 
Last edited:
Archie, Thanks for your assistance, this is an amazing program! I am able to read about 20 tags per second, with the CLX driver -- that is a pretty healthy rate! This is with the CLX driver you recommended. The 3rd party native TCP/IP driver -- just amazing! I'll also try to give OPC a try, though I imagine it will be slow as molasses. I'm upgrading the PLC cpu soon (L55 to L75). Will CPU, or an EN2T make a bigger difference in speed? We have 1756-ENBT's presently. Since most of the computers aren't on the control network, but do have access to the OPC server, that may still be a good option if we want something we can double click from our desktops, though I'm thinking of keeping it on the web. I'll review the Advanced HMI manual to learn more about features.
 

Similar Topics

The company I work for sells equipment which is controlled by software running on a PC. In cases where the end-user wants to integrate our...
Replies
3
Views
3,098
Hi, A customer has a custom in-house QA system, that we need to link into a PLC or 2. There is already a SCADA system in place, with IO Servers...
Replies
2
Views
1,429
Hey, I'm wondering if anyone has a sample program or any idea how I would go about extracting data from an opc client in vb.net The program will...
Replies
2
Views
2,327
Hi All, Have you ever used the new OPC UA that Siemens give with the cd with the Simatic NET V8.0? What about this new OPC from OPC Foundation ...
Replies
0
Views
3,534
Hello, I've been wrestling for two days with an issue and wanted to see if any of you gurus had any insight. I have Cognex OPC Server 4.5...
Replies
3
Views
5,779
Back
Top Bottom