Author Topic: Reading and writing many tags with EthernetIPforCLXCom  (Read 3273 times)

scott.clark

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Reading and writing many tags with EthernetIPforCLXCom
« on: January 07, 2015, 08:58:37 PM »
using AdvancedHMI v3.83

I have been trying to read and write many tags to a plc, but when done in a group such as shown below, an exception will be generated.   I have set the poling rate as long as 5000, but still get the exception.  Ultimately I have about 50 tags to read and write, somewhat infrequently.  I am triggering the event to read and write the tags from a bit in the plc using the DataSubscriber component.


Private Sub DataSubscriber1_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged

        g_PLCReadValues.PLCStageCounterValue = EthernetIPforCLXCom_MainForm.Read("StepNumber")
        g_PLCReadValues.MCR = EthernetIPforCLXCom_MainForm.Read("DI_MCRStatus")
        g_PLCReadValues.HipotPass = EthernetIPforCLXCom_MainForm.Read("DI_HiPotPass")
        g_PLCReadValues.HipotFail = EthernetIPforCLXCom_MainForm.Read("DI_HiPotFail")
        g_PLCReadValues.AirPressureSwitch = EthernetIPforCLXCom_MainForm.Read("DI_AirPressureSwitch")
        g_PLCReadValues.RejectPB = EthernetIPforCLXCom_MainForm.Read("DI_RejectResetPB.InDbncd")
        g_PLCReadValues.PLCStageCounterValue = EthernetIPforCLXCom_MainForm.Read("StepNumber")
        g_PLCReadValues.MCR = EthernetIPforCLXCom_MainForm.Read("DI_MCRStatus")
        g_PLCReadValues.HipotPass = EthernetIPforCLXCom_MainForm.Read("DI_HiPotPass")
        g_PLCReadValues.HipotFail = EthernetIPforCLXCom_MainForm.Read("DI_HiPotFail")

        If g_PLCReadValues.RejectPB Then
            btnRejectPBInd.BackColor = System.Drawing.Color.LawnGreen
        Else
            btnRejectPBInd.BackColor = System.Drawing.Color.DarkGray
        End If

    End Sub

Thanks for any suggestions.

scott.clark

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Re: Reading and writing many tags with EthernetIPforCLXCom
« Reply #1 on: January 07, 2015, 09:00:08 PM »
A screen capture of the exception is attached below.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5306
    • View Profile
    • AdvancedHMI
Re: Reading and writing many tags with EthernetIPforCLXCom
« Reply #2 on: January 08, 2015, 03:46:36 AM »
This was a bug that should be fixed in 3.97.

KanHaz

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Reading and writing many tags with EthernetIPforCLXCom
« Reply #3 on: January 12, 2015, 07:43:04 AM »
using AdvancedHMI v3.83

I have been trying to read and write many tags to a plc, but when done in a group such as shown below, an exception will be generated.   I have set the poling rate as long as 5000, but still get the exception.  Ultimately I have about 50 tags to read and write, somewhat infrequently.  I am triggering the event to read and write the tags from a bit in the plc using the DataSubscriber component.


Private Sub DataSubscriber1_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged

        g_PLCReadValues.PLCStageCounterValue = EthernetIPforCLXCom_MainForm.Read("StepNumber")
        g_PLCReadValues.MCR = EthernetIPforCLXCom_MainForm.Read("DI_MCRStatus")
        g_PLCReadValues.HipotPass = EthernetIPforCLXCom_MainForm.Read("DI_HiPotPass")
        g_PLCReadValues.HipotFail = EthernetIPforCLXCom_MainForm.Read("DI_HiPotFail")
        g_PLCReadValues.AirPressureSwitch = EthernetIPforCLXCom_MainForm.Read("DI_AirPressureSwitch")
        g_PLCReadValues.RejectPB = EthernetIPforCLXCom_MainForm.Read("DI_RejectResetPB.InDbncd")
        g_PLCReadValues.PLCStageCounterValue = EthernetIPforCLXCom_MainForm.Read("StepNumber")
        g_PLCReadValues.MCR = EthernetIPforCLXCom_MainForm.Read("DI_MCRStatus")
        g_PLCReadValues.HipotPass = EthernetIPforCLXCom_MainForm.Read("DI_HiPotPass")
        g_PLCReadValues.HipotFail = EthernetIPforCLXCom_MainForm.Read("DI_HiPotFail")

        If g_PLCReadValues.RejectPB Then
            btnRejectPBInd.BackColor = System.Drawing.Color.LawnGreen
        Else
            btnRejectPBInd.BackColor = System.Drawing.Color.DarkGray
        End If

    End Sub

Thanks for any suggestions.

Might be the wrong place to ask this question but what is "g_PLCReadValues"? I'm trying to understand how to use the DataSubscriber.
If anyone could point me in the right direction it would be great appriciated.

Thanks in advance.

Noe

  • Full Member
  • ***
  • Posts: 205
    • View Profile
Re: Reading and writing many tags with EthernetIPforCLXCom
« Reply #4 on: January 12, 2015, 09:57:41 AM »
using AdvancedHMI v3.83

I have been trying to read and write many tags to a plc, but when done in a group such as shown below, an exception will be generated.   I have set the poling rate as long as 5000, but still get the exception.  Ultimately I have about 50 tags to read and write, somewhat infrequently.  I am triggering the event to read and write the tags from a bit in the plc using the DataSubscriber component.


Private Sub DataSubscriber1_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber1.DataChanged

        g_PLCReadValues.PLCStageCounterValue = EthernetIPforCLXCom_MainForm.Read("StepNumber")
        g_PLCReadValues.MCR = EthernetIPforCLXCom_MainForm.Read("DI_MCRStatus")
        g_PLCReadValues.HipotPass = EthernetIPforCLXCom_MainForm.Read("DI_HiPotPass")
        g_PLCReadValues.HipotFail = EthernetIPforCLXCom_MainForm.Read("DI_HiPotFail")
        g_PLCReadValues.AirPressureSwitch = EthernetIPforCLXCom_MainForm.Read("DI_AirPressureSwitch")
        g_PLCReadValues.RejectPB = EthernetIPforCLXCom_MainForm.Read("DI_RejectResetPB.InDbncd")
        g_PLCReadValues.PLCStageCounterValue = EthernetIPforCLXCom_MainForm.Read("StepNumber")
        g_PLCReadValues.MCR = EthernetIPforCLXCom_MainForm.Read("DI_MCRStatus")
        g_PLCReadValues.HipotPass = EthernetIPforCLXCom_MainForm.Read("DI_HiPotPass")
        g_PLCReadValues.HipotFail = EthernetIPforCLXCom_MainForm.Read("DI_HiPotFail")

        If g_PLCReadValues.RejectPB Then
            btnRejectPBInd.BackColor = System.Drawing.Color.LawnGreen
        Else
            btnRejectPBInd.BackColor = System.Drawing.Color.DarkGray
        End If

    End Sub

Thanks for any suggestions.

Might be the wrong place to ask this question but what is "g_PLCReadValues"? I'm trying to understand how to use the DataSubscriber.
If anyone could point me in the right direction it would be great appriciated.

Thanks in advance.

So far I use DataSubscriber control (the one in the toolbox) as a basic label that cannot be seen in a form. So use its events for your convenience, most useful is "data changed", to trigger your code. The advantage is that datasubscribers communication with PLC, as Archie has told in previous post, is far more efficient that using a code reading command, same as tha basic label, but without having a visual control onscreen.

Hope this helps.

scott.clark

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Re: Reading and writing many tags with EthernetIPforCLXCom
« Reply #5 on: January 12, 2015, 02:32:06 PM »
KanHaz, 

g_PLCReadValues is a public class created to store the results of the various tags read from the PLC.  The g_PLCReadValues Group of tag values is then passed to other procedures.   It's similar to a User-Defined data type in a ControLogix PLC.

SprungMonkey,
I suppose I could have created a DataSubscriber for each component of my gPLCReadValues.  I would have to create about 50 of them.  It may be the better way to do it, I am still trying to figure that out. 

What I couldn't figure out was how to use a DataSubscriber to write tags, since.  Does anybody have any examples?

Thanks

KanHaz

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Reading and writing many tags with EthernetIPforCLXCom
« Reply #6 on: January 12, 2015, 03:25:37 PM »
Ok, I finally understand what was going on. Thank you for the explanations. I don't need to read that many tags for this project but its nice to know what I can do.