Author Topic: Connecting to OPC server- help!  (Read 4695 times)

daveyh

  • Newbie
  • *
  • Posts: 23
    • View Profile
Connecting to OPC server- help!
« on: June 03, 2015, 02:09:30 PM »
I'm new to AdvancedHMI and sort of new to OPC. I'm trying to write a simple app that will read values from an OPC server and display them using a gauge or other control.

Is there a demo or sample application?

I read the OPCDaCom pdf that came with AdvancedHMI but it's not very clear. For example what is it looking for in the  OPCServer, OPCTopic, and PLCAddressValue values and in what format? Any screenshots of typical values?

The OPC server is from http://www.opcsystems.com/

Any help is appreciated!


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Connecting to OPC server- help!
« Reply #1 on: June 03, 2015, 02:40:34 PM »
Using OPC is the most difficult driver because there are so many variations in OPC Servers. The first most important thing to figure out is the EXACT name of the OPC server. If you have an OPC Browser, that is usually the easiest way to find the name of your server. If not, then you will have to browse the OPC server's documentation to find the name.

To my knowledge, RSLinx is the only OPC server that uses the OPCTopic, so you may not have to worry about that.

Addresses can also be difficult because every OPC server will do it slightly different. Once again, that should be in the documentation of the OPC server.

Once you figure out the correct address, you can simply add a BasicLabel to the form and set the PLCAddressValue to the address. Then run the application to see if everything is correct.

daveyh

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Connecting to OPC server- help!
« Reply #2 on: June 03, 2015, 04:58:55 PM »
Here's what the OPC client sees but I don't know what part of this I should enter for the server name and PLCAddressValue.

Thanks!

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Connecting to OPC server- help!
« Reply #3 on: June 03, 2015, 05:52:40 PM »
It looks like OPCSystems.NET is the server name

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Connecting to OPC server- help!
« Reply #4 on: June 03, 2015, 08:02:04 PM »
For PLCAddressValue I would first try the complete item name. If that doesn't work, then start removing elements from the beginning.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Connecting to OPC server- help!
« Reply #5 on: June 03, 2015, 08:21:54 PM »
« Last Edit: May 20, 2019, 01:06:56 AM by Godra »

daveyh

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Connecting to OPC server- help!
« Reply #6 on: June 04, 2015, 04:51:59 PM »
We're making progress! With some experimentation and looking at other OPC clients, I worked out the servername to be OPCSystems.NET and the path to be opcda://localhost/ At least it runs without any more connection errors.

I tried reading data like the OPCDaCom.pdf demonstrated. First it failed because the data type I was reading was string. So I changed to read a type 'double' address but now get an "INVALID VALUE RETURNED!" The value read by another client is 0 (zero)

I also set up a basic label and pointed it at a string value but the label goes blank at runtime. Another client returns "Input Power = 13" for the same address.

Purely by guesswork, I tried reading the value using this code but it also returned nothing. also tried 0 on place of the 1 for 'numberofelements' as I don't know what they wanted.

OPCTextBox1.Text = OpcDaCom1.Read("RACO.3.3061.Channel Status.Battery Power ChannelMessage.Value", 1).ToString

Thoughts???

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Connecting to OPC server- help!
« Reply #7 on: June 04, 2015, 06:00:44 PM »
If the BasicLabel is blanking, then it sounds like something is coming back, but the driver is not handling it properly. Try this to get a look at the data coming back:

- Set up like you had with the BasicLabel
- Open OPCDaCom.vb and go to line 528
- Insert a break point by clicking in the left margin
- Run the application
- When it stops at the break point, hover over ReturnedValues to see what the values are
- Also hover over values.Length to see how many values are coming back

daveyh

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Connecting to OPC server- help!
« Reply #8 on: June 05, 2015, 02:34:11 PM »
I poked around and it turned out that the address wasn't correct. I'd assumed it was correct as it didn't generate an error.

While the first OPC client I tried was happy with "RACO.ChannelMessage.Value", Factorytalk wanted "Network.53.133.146.195.RACO.ChannelMessage.Value" I tried that in AdvancedHMI and it worked! (IP changed to a random value in this posting)

I have a couple of other issues but i'll google before asking them.

Thanks for all the advice :-)

Davey