Author Topic: Connect to Red Lion OpcWorx Server Tags?  (Read 7776 times)

sarclimber

  • Newbie
  • *
  • Posts: 20
    • View Profile
Connect to Red Lion OpcWorx Server Tags?
« on: August 14, 2016, 06:41:10 PM »
I am trying to use OPCDACom in Visual Studio Community to read the tags I have set up in Red Lion's OPCWorx OPC Server.  When I run the application the connection to the OPC server is working, or at least it does not show an error in Visual Studio once I figured out the OPC server address.  My question is the what to put into the PLCAddressValue field.  I am not currently connected to a PLC, only a Red Lion G3 HMI with tags resident in the HMI.  I tried putting the HMI tag name in the address field and a cannot connect error occurred.  My ultimate goal is to have an application which monitors data from multiple HMI's and will change button colors based on tag values.  The HMI's will be connected to IDEC PLC's and the tags will be mapped to the HMI's.  The tag name in the PLC is the same as the mapped tag name in the HMI so I am not sure it will have an effect when I am actually connected to the PLC.  All hardware will be connected via a wireless network.  Any suggestions would be very appreciated.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Connect to Red Lion OpcWorx Server Tags?
« Reply #1 on: August 15, 2016, 08:15:39 AM »
Since there are so many variations in the different OPC servers specify address, the technique I use is to use an OPC Browser or OPC Test Client to let it browse the available addresses, then copy that into the PLCAddressValue property.

sarclimber

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Connect to Red Lion OpcWorx Server Tags?
« Reply #2 on: August 15, 2016, 04:12:55 PM »
Thanks......used an OPC test client and found the tags in the HMI.  Example address is "HMI1.test".  Now getting an OPC connect error whenever I put a tag address in the PLC address field and run the application.  I am not sure the server path is correct as none of the test clients show me what I understand to be a path.  I have tried the complete path to where the OPCWorx config file is located with no change.  Is there a particular format or a way to find the server path? 

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Connect to Red Lion OpcWorx Server Tags?
« Reply #3 on: August 15, 2016, 04:59:21 PM »
The Server Name is specific to the vendor and can be the most difficult to find. The OPC browser may give you a list of available servers and the specific name. If the server is on the same PC, then the OPCServerPath should remain at its default of opcda://localhost

Some OPC servers also require a topic.

sarclimber

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Connect to Red Lion OpcWorx Server Tags?
« Reply #4 on: August 15, 2016, 05:15:17 PM »
OK, changed path to opcda://localhost.  This did change when I get the connect error.  I am using a pilot light connected to a Boolean tag in the HMI.  As soon as I launch the application a message appears in the pilot light that says cannot connect to OPC server and it gives the specific server name I was able to find in several different opc test clients.  I am beginning to think I am missing something that Visual Studio requires?  Do you know if Red Lion OPCWorx server requires a topic?  Tanks again for all your help.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Connect to Red Lion OpcWorx Server Tags?
« Reply #5 on: August 15, 2016, 06:32:09 PM »
I have never used OPCWorx, so I will take a stab in the dark. I found this in a reference manual:

"You will find the OPCWorx servers listed as RedLionControls.name, where name is the type of server(s) you’ve configured, and have set active"

The AdvancedHMI is already setup for OPC, so it is just a matter of getting the ServerName and Topic (if needed) correct.

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: Connect to Red Lion OpcWorx Server Tags?
« Reply #6 on: August 15, 2016, 07:26:39 PM »
It's unclear to me how it's connected. Can you ping from your laptop to PC and PLC?
Is the RedLion OPC server running on the PC?
If that is the case, see the pic in this msg :http://advancedhmi.com/forum/index.php?topic=598.msg5723#msg5723
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

sarclimber

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Connect to Red Lion OpcWorx Server Tags?
« Reply #7 on: August 16, 2016, 08:40:24 AM »
You nailed it Archie.  I had been using cut and paste to enter the server name after browsing it in several OPC test clients.  After reading your post I saw the lack of spaces in "RedLionControls".  The test clients had spaces and so did my entry in Visual Studio.  Removed spaces and all is talking.  Just for info bachphi, yes the OPC server is running on the PC and the pc is on the same network as the HMI, no plc is connected yet.  Now the real fun begins.  Thanks for all the help.

sarclimber

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Connect to Red Lion OpcWorx Server Tags?
« Reply #8 on: November 15, 2016, 01:07:42 PM »
Finally getting back to this project and I am having what I believe to be a problem with Visual Basic (maybe??)  but maybe someone can point out my error.  For instance when I drop a BasicIndicator onto my form and assign a plc tag to "PLCAddressSelectColor2" I get a "Object reference not set to an instance of an object" displaying in the indicator when the project is run.  I am using the Red Lion OPCWorx server and verified that the tag I am using is available via a OPC explorer program.  I have the OpcDaCom component in my form with the OPCserver set to what the explorer program is using and the path set to opcda://localhost as the Red Lion server is on the same pc that runs the program.  All my internet forum searching points to trying to set a value into something that is "nothing" which I do not understand as I am not writing any code for this BasicIndicator...just trying to set the background color based on a plc tag value.  Once again I have confirmed that the tag value is available via the OPC explorer.

I am in new territory here so any ideas would be appreciated.

sarclimber

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Connect to Red Lion OpcWorx Server Tags?
« Reply #9 on: November 15, 2016, 04:35:05 PM »
More info on above question...

There are two exceptions being thrown when I debug the application.

'Opc.NotConnectedException'
'System.NullReferenceException'

Since I can see the OPC server tags with an OPC explorer I believe the problem to be in my OpcDaCom configuration.

OPCGroup is blank, I tried setting a group based on the OPC explorer with no change, red Lion OPCWorx does not show any groups
OPCServer is RedLionControls.G3OPCServer.1  this matches the OPC explorer
OPCServerPath is opcda://localhost  application and server are on same pc
OPCTopic is blank

Thanks for any thoughts.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Connect to Red Lion OpcWorx Server Tags?
« Reply #10 on: November 15, 2016, 05:49:36 PM »
This is sounding like an OPC and OpcDaCom problem which can be quite difficult to troubleshoot. We need to figure out where the exception is coming from. What version of Visual Studio are you using?

This might be a good place to start:

- In Solution Explorer, expand down the AdvancedHMIDrivers project
- Look for OpcDaCom.vb , right click and select View Code
- Go to line 524 and look for this code:

    Private Sub DataChangedCallBack(ByVal clientHandle As Object, ByVal requestHandle As Object, ByVal values() As Opc.Da.ItemValueResult)
        For i = 0 To values.Length - 1


- To the left of line 525, click in the left margin to insert a break point
- Run the application
- When and if it stops at the breakpoint, use F10 to step through the code and see how far it gets

sarclimber

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Connect to Red Lion OpcWorx Server Tags?
« Reply #11 on: November 15, 2016, 06:06:10 PM »
Visual Studio Community 2015  Ver 14.0.25425.01 Update 3

Did not stop at the breakpoint

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Connect to Red Lion OpcWorx Server Tags?
« Reply #12 on: November 15, 2016, 06:21:21 PM »
Ctrl+Alt+E will open an Exception Setting window which will probably be at the bottom. Add a check to the box Common Language Runtime exception. Then run the application again

sarclimber

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Connect to Red Lion OpcWorx Server Tags?
« Reply #13 on: November 16, 2016, 04:15:50 PM »
OK, tried that with no change.  Just for grins I reinstalled AdvancedHMI in a different location and built a very simple program using only a basic indicator.  The PLCAddressVisible property was set to a plc address Boolean tag that I can browse with an opc explorer.  When I first ran the program I got a "CoCreateInstanceEx: Class Not registered" error in the basic indicator and then it went to "Object reference not set to an instance of an object" error.

Tried debugging this simple program and it did not get to the breakpoint either.

Thanks for your time.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Connect to Red Lion OpcWorx Server Tags?
« Reply #14 on: November 16, 2016, 04:33:17 PM »
Your issue might also be related to DCOM permissions.

If you search this forum for "dcom" you will find several OPC related topics mentioning those.

And bunch of resources on the Internet for the same.

Could you post pictures of your OPC explorer and server tags and anything else related?
« Last Edit: November 16, 2016, 04:37:00 PM by Godra »