Author Topic: OPC Connection to CoDeSys OPC Server  (Read 5075 times)

Filibilli

  • Newbie
  • *
  • Posts: 4
    • View Profile
OPC Connection to CoDeSys OPC Server
« on: December 08, 2014, 06:50:36 AM »
Hi,
first of all thanks for this work; I feel that this is a great new approach to doing HMI!

I just got everything downloaded and tried to get connected to a CoDeSys setup in a Turck unit. I can access all variables fine from a Matrikon client.

I've currently only got one button on my form and want to set this output
.qxGeneralOut_1

The form loads in Debug OK but as soon as I press the button, I get an error message in OpcDaCom
ReadSubscription = DLL.CreateSubscription(ReadSubscriptionState)

The Variable ReadSubscription  seems to havbe no value ("Nothing" although it seems to be initialized
   Private ReadSubscription As Opc.Da.ISubscription

I've tried setting the CPU to x86 as suggested in the forums (I was getting other errors) but still get this one every time.

Thanks in advance for your help here.

Cheers

Phil



Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: OPC Connection to CoDeSys OPC Server
« Reply #1 on: December 08, 2014, 08:54:14 AM »
The OPC can be difficult to figure out. What are you using for the OPC Server name?

What Turck contoller are you using? I haven't tried Turck with AdvancedHMI, but I remember seeing that ModbusTCP was an option also.

Filibilli

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: OPC Connection to CoDeSys OPC Server
« Reply #2 on: December 08, 2014, 08:59:34 AM »
Hi Archie,

thanks for the fast reply!

The Turck (my employer) device is a CoDeSys 2.3 device so I have CoDeSys.OPC.DA as the server.

I used to work for Modicon so ModbusTCP is OK for me too but I have many customers who would like to use OPC so I have to be active in this direction after many years of being able to avoid it :-)

Any help you could give me would be well appreciated.

Cheers

Phil

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: OPC Connection to CoDeSys OPC Server
« Reply #3 on: December 08, 2014, 09:12:48 AM »
The last OPC Server based on CodeSys that I worked was Bosch and it required a very long variable name. You had to go into an OPC Test Client, then browse the server to get the full variable name. Do you have anything like that?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: OPC Connection to CoDeSys OPC Server
« Reply #4 on: December 08, 2014, 09:26:54 AM »
I've done a little bit of digging around, but haven't found much. I do have the CodeSys software from a project I had to help debug a couple months ago. When I go into that OPC Config, it shows me the server name being:

CoDeSys.OPC.02


Filibilli

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: OPC Connection to CoDeSys OPC Server
« Reply #5 on: December 08, 2014, 10:18:01 AM »
Hi Archie,

thanks for that! It seems that I may have to add another part to the name and I'll try that tomorrow morning (nearly done for today) and give you feedback.

I can also see the OPC.02 thing in the Matrikon client but I'm usin the data access there (DA) and want to keep with that route if possible. If not then I'll try the 02 tomorrow as well.

Thanks for your help.

Cheers

Phil

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: OPC Connection to CoDeSys OPC Server
« Reply #6 on: December 08, 2014, 12:09:03 PM »
See this last post in this thread, it sounds like someone had it working:

http://advancedhmi.com/forum/index.php?topic=250.new;topicseen#new

Filibilli

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: OPC Connection to CoDeSys OPC Server
« Reply #7 on: December 09, 2014, 03:16:54 AM »
Hi Archie,
thanks to your help and some playing around I'm now sort of up an running.

For others who may want to do the same thing, here are a couple of stumbling points:
1. OPCServer in the OpcDaComx is CoDeSys.OPC.DA (for me: the .02 doesn't work at all)
2. The PLC address on the components has the following format:
     PLC_NAME..ItemName
     PLC_NAME is the name you give to a PLC when using Edit=>Append PLC in the CODESYS OPCConfig editor
     Item name is the variable name in the CODESYS PLC
     The two full stops .. between are necessary here as well.

I also have a couple of points which I haven't yet cleared up:

1. If I only have a button on the form i.e. write and no read elements (light...) then the problem I was having yesterday   
    always happens. As soon as I add a light to the form then all's well.
2. Whe using a button, I can only get the momentary actions to work properly. If I use the toggle mode then it dies on me
    saying that there's no source code available. I checked the forums here but didn't find anything.

Thanks for your help.

Cheers

Phil