Author Topic: OPC Server  (Read 3580 times)

NerdyMinded

  • Newbie
  • *
  • Posts: 8
    • View Profile
OPC Server
« on: March 14, 2018, 06:40:51 PM »
The problem:

I am currently using Pi (Osisoft) to pull data from a Phoenix Contact OPC Server. This works great with the exception that while the Pi client is running no other clients can connect. I have tested Pi with RSLinx OPC Server and multiple clients are not an issue. Additionally, I have tested the Phoenic Contact OPC Server with multiple clients again with no issues. Both software packages play nice with everybody but each other. Now that we are adding an AllenBradley PLC to interface with the Phoenix Contact PLCs, this is a real problem.

As a quick solution, I thought I would just replicate the server with RSLinx. Although it sounds easy enough, I have tried every option in RSLinx Gateway with 0 results. Currently, I am looking at writing the values directly to an Allen Bradley PLC then using Pi to interface with the AB PLC leaving my OPC Server free for multiple clients.

This is a slightly modified version of the code provided on the "Subscribing to PLC data via code" page on the AHMI Wiki page. I'm sure there is a better way to make multiple tag calls of even an entirely different solution that doesn't involve a sacrificial PLC. Any help would be greatly appreciated!

Imports MfgControl.AdvancedHMI

Public Class Form1

    Private SubscriptionID1 As Integer
    Private SubscriptionID2 As Boolean

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        SubscriptionID1 = OpcDaCom1.Subscribe("One.TestWord", 1, 500, AddressOf Subscription_DataReceived)
        SubscriptionID2 = OpcDaCom1.Subscribe("One.ONBOARD_INPUT_BIT0", 1, 500, AddressOf Subscription_DataReceived2)
    End Sub

    Private Sub Subscription_DataReceived(sender As Object, e As Drivers.Common.PlcComEventArgs)
        If e.ErrorId = 0 AndAlso e.Values IsNot Nothing AndAlso e.Values.Count > 0 Then
            Label1.Text = e.Values(0)
            EthernetIPforCLXCom1.Write("Word", e.Values(0))
        End If
    End Sub
    Private Sub Subscription_DataReceived2(sender As Object, e As Drivers.Common.PlcComEventArgs)
        If e.ErrorId = 0 AndAlso e.Values IsNot Nothing AndAlso e.Values.Count > 0 Then
            Label2.Text = e.Values(0)
            If e.Values(0) = "True" Then EthernetIPforCLXCom1.Write("ZZ", 1) Else EthernetIPforCLXCom1.Write("ZZ", 0)
        End If
    End Sub

    Private Sub MainForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
        OpcDaCom1.UnSubscribe(SubscriptionID1)
        OpcDaCom1.UnSubscribe(SubscriptionID2)
    End Sub


End Class

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: OPC Server
« Reply #1 on: March 14, 2018, 07:20:25 PM »
What PLC or configuratin are you using that requires you to use OPC as opposed to the native AdvancedHMI drivers?

NerdyMinded

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: OPC Server
« Reply #2 on: March 14, 2018, 09:17:18 PM »
We're using Phoenix Contact PLCs (ILC 350 ETH/M - 2985819). There may be a driver that will do the job, but if there is, I don't know which one or how to configure it. I have included the data interfaces section below. We have a few of these which communicate via ethernet. I have looked into this code to try to understand how exactly it works but it is written in Structured Text and I'm still pretty new to it. Again, your help is greatly appreciated.


Data Interfaces
Interface                  INTERBUS local bus (master)
Number                   1
Connection method   Inline data jumper
Transmission speed   500 kBaud / 2 MBaud (can be switched)
Interface                  Parameterization/programming/diagnostics
Connection method   6-pos. MINI DIN socket (PS/2)
Transmission speed   max. 38.4 kbps
Interface                  Ethernet 10Base-T/100Base-TX
Number                   1
Connection method   RJ45 socket
Transmission speed   10/100 Mbps

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: OPC Server
« Reply #3 on: March 14, 2018, 09:43:49 PM »
Where does RSLinx come into play?

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: OPC Server
« Reply #4 on: March 14, 2018, 10:21:37 PM »
Just to throw this out there, shouldn't these both be declared as Integer (not that it wouldn't subscribe because of it but it might not unsubscribe properly):

    Private SubscriptionID1 As Integer
    Private SubscriptionID2 As Boolean

Also, even though I don't really understand your setup, shouldn't you be able to use the AdvancedHMI to pull data from the Phoenix Contact OPC Server and possibly communicate with your PLCs (via this same server, if the server is already communicating with your Phoenix PLCs)?

NerdyMinded

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: OPC Server
« Reply #5 on: March 15, 2018, 12:50:47 PM »
Where does RSLinx come into play?

Due to the issues between Phoenix Contact OPC Server and Pi, I Tried to use RSLinx to clone the Phoenix server as Linx doesn't have the same issue.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: OPC Server
« Reply #6 on: March 15, 2018, 01:09:12 PM »
Sorry for all the questions, I'm just tryingto make sure I have somewhat of an understanding of the system. I watched the intro video to the Pi software which made things a little more clear.

On the approach you are using, there is a component called the ComBridge that encapsulates this functionality so you do not have to write the code.

NerdyMinded

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: OPC Server
« Reply #7 on: March 15, 2018, 01:30:54 PM »
Just to throw this out there, shouldn't these both be declared as Integer (not that it wouldn't subscribe because of it but it might not unsubscribe properly):

    Private SubscriptionID1 As Integer
    Private SubscriptionID2 As Boolean

Also, even though I don't really understand your setup, shouldn't you be able to use the AdvancedHMI to pull data from the Phoenix Contact OPC Server and possibly communicate with your PLCs (via this same server, if the server is already communicating with your Phoenix PLCs)?

The Boolean was changed as an attempt to the issues fixed by the following IF statement. I should have changed it back before posting.

If e.Values(0) = "True" Then EthernetIPforCLXCom1.Write("ZZ", 1) Else EthernetIPforCLXCom1.Write("ZZ", 0)

As for the second question:

We have a network of Phoenix Contact PLCs that communicate via Ethernet.  I was asked to help integrate this with Pi so I setup the Phoenix Contact OPC Server. This works fine. We have been tracking data on these PLCs for a while now. I was then asked to add an AB PLC to the mix. The issue happens here. While the Pi OPC Interface is running, no other clients can connect effective blocking Phoenix/AB connection.


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: OPC Server
« Reply #8 on: March 15, 2018, 01:38:55 PM »
While the Pi OPC Interface is running, no other clients can connect effective blocking Phoenix/AB connection.
This is the part that I guess I am not clear on. Does the Pi software have an OPC server that you can start and stop, which then interferes with other OPC servers? Or does it just block communication between Pi and the PLCs?

NerdyMinded

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: OPC Server
« Reply #9 on: March 15, 2018, 01:52:50 PM »
Sorry for all the questions, I'm just tryingto make sure I have somewhat of an understanding of the system. I watched the intro video to the Pi software which made things a little more clear.

On the approach you are using, there is a component called the ComBridge that encapsulates this functionality so you do not have to write the code.

Although I have read many forums, I have never posted in one so ask me all the questions you can muster! I am more than willing to do what I can to describe the issue in greater detail.

I've actually used the ComBridge for testing but only for one tag at a time. Is there a way to use it for multiple tags? (I have hundreds)

NerdyMinded

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: OPC Server
« Reply #10 on: March 15, 2018, 03:08:01 PM »
While the Pi OPC Interface is running, no other clients can connect effective blocking Phoenix/AB connection.
This is the part that I guess I am not clear on. Does the Pi software have an OPC server that you can start and stop, which then interferes with other OPC servers? Or does it just block communication between Pi and the PLCs?

Sorry for the slow responses. Today's been rather hectic. 

Phoenix PLCs communicate with each other via TCP/IP. This works regardless of any OPC congifuration.
The Pi client reads from the Phoenix OPC Server but while it is connected, no other clients can connect giving an error "Server already started". When I stop the Pi Client, I can connect with Phoenix, RSLinx and AHMI clients simultaneously. If I then try to restart the Pi client while the others are running it doesn't show an error, but it doesn't pull data either. Osisoft says that their software is not designed to behave in this manner. After speaking with them I decided to try the RSLinx cloning idea as Pi and RSLinx work together better and allows multiple clients. After failing this, I took to AHMI to develop a work around by subscribing to the Phoenix Server and writing values to the AB PLC as Pi can pull data directly from the Processor of an AB PLC.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: OPC Server
« Reply #11 on: March 15, 2018, 07:16:44 PM »
From everything you stated, it appears that your culprits are both the Pi and the Phoenix OPC Server.
If RSLinx doesn't have those issues then neither should the Phoenix OPC Server.

It might be that this server is just way too busy serving the Pi to respond to other clients or it somehow allows the Pi the exclusive connection which no other client can join (which could be a consequence of the Pi issuing some weird request that locked the server to it or it could be a bug in the server code).

Is the Pi capable of reading from a database file or csv file or excel file or... something other than a PLC or OPC server?

The question above could suggest to possibly have the server either create a file of the sort or just write all the data to it (or have some other software, including AdvancedHMI, get it from the server and serve it to the Pi).

These are just wild suggestions of mine.
« Last Edit: March 18, 2018, 10:48:55 PM by Godra »

bachphi

  • Hero Member
  • *****
  • Posts: 671
    • View Profile
Re: OPC Server
« Reply #12 on: March 18, 2018, 10:21:53 PM »
Great, so the Pi you are referring to is not really a "Pi". Maybe a sketch would be helpfull
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

NerdyMinded

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: OPC Server
« Reply #13 on: March 21, 2018, 12:58:48 PM »
Sorry I have been away for a few days, but I had to focus my efforts on other projects. We have found a resolution by using KEPServerEX to interface between the Phoenix OPC Server and the Pi Client. Doing this eliminates the single client anomaly between Pi and Phoenix Contact.

I just wanted to say thanks for all your guys' help. I really do appreciate it!

NerdyMinded

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: OPC Server
« Reply #14 on: March 21, 2018, 01:00:50 PM »
Great, so the Pi you are referring to is not really a "Pi". Maybe a sketch would be helpfull

This is the Pi I have been referring to:
https://www.osisoft.com/pi-system/