Author Topic: EthernetIPforCLX - writing to arrays?  (Read 5158 times)

thirdeye73

  • Newbie
  • *
  • Posts: 22
    • View Profile
EthernetIPforCLX - writing to arrays?
« on: January 26, 2015, 01:33:30 PM »
I have been trying to write values in an array out to an array in the PLC, with little success.  Here is what I have tried so far:

Code: [Select]
mEIPCLX.Write("DINTArray",100,VBarray)
mEIPCLX.Write("DINTArray[0]",100,VBarray)
mEIPCLX.Write("DINTArray,VBArray)
mEIPCLX.Write("DINTArray[0],VBArray)

Each time I get a "no response from PLC getting tag information" error.

I can write a single value from the VB array to any single element of the PLC array with no issue.

thirdeye73

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: EthernetIPforCLX - writing to arrays?
« Reply #1 on: January 26, 2015, 01:40:17 PM »
More info:  I added a call to GetTagInformation, and tried the tag name with and without the "
  • " appended.  Both times I get the following result in the CLXTag object:


AbbreviatedType = 196
ArrayElements = 0
BitNumber = -1
Instance = 0
TagName = "SYSTEMSTATUS_TOTALCOUNT"

I am running with version 3.97d plus the patch Archie provided for UDT array access.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: EthernetIPforCLX - writing to arrays?
« Reply #2 on: January 26, 2015, 01:48:57 PM »
Just prior to trying to do the Write, try to perform a read on element 0 of the array to see what happens.

mEIPCLX.Read("DINTArray[0]")
mEIPCLX.write("DINTArray[0]",VBarray)

thirdeye73

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: EthernetIPforCLX - writing to arrays?
« Reply #3 on: January 26, 2015, 01:56:03 PM »
That had no effect.  But I do notice that when the exception hits, my application code is on the line *after* the write, but the data did not get written to the PLC.  Stepping through the code, the actual write routine executes with no visible errors (I am stepping over the Write() routine).

thirdeye73

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: EthernetIPforCLX - writing to arrays?
« Reply #4 on: January 26, 2015, 02:04:37 PM »
Here's my workaround, but I'm afraid it may be wasteful of network bandwidth:

Code: [Select]
For i as Integer = 0 to VBArray.GetUpperBound(0)
  mEIPCLX.Write("DINTArray[" & i & "]", VBArray[i])
Next

I have about ten separate arrays that need to be written to inside that for loop, and each one contains roughly 100 elements.  But I have verified all the data appears in the PLC when I do that.  And to make things worse, I need to execute this code repeatedly, at a frequency of once per second ideally.  As for data types, there will be several DINT arrays, a couple of BOOL arrays, and several STRING arrays.

Oh, and one more piece of info.  I mentioned I was using the UDT patch--I have tried reverting to the unmodified 3.97d DLL file as well, and the problem still happens, so it's not anything the patch introduced.

thirdeye73

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: EthernetIPforCLX - writing to arrays?
« Reply #5 on: January 26, 2015, 03:59:48 PM »
I think I've narrowed down my problem somewhat.  The issue is not that the driver is not writing to the array.  The issue is that the driver is taking a *long* time to write to the array.  If I change my code from this:

Code: [Select]
mEIPCLX.Write("DINTArray[0]", VBArray)

(where DINTArray and VBArray both have 105 elements) to this:

Code: [Select]
mEIPCLX.Write("DINTArray[0]", 10, VBArray)

my problems magically disappear.

So it looks like to maintain app responsiveness and avoid latency issues (for lack of a better term), I'll need to multiplex my array writes.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: EthernetIPforCLX - writing to arrays?
« Reply #6 on: January 26, 2015, 05:20:00 PM »
I tried this out and what I found was that I could write 60 DINTs with no problem, but when I tried 80, the PLC would not even send a response. I am guessing somewhere over 60, it reaches the packet size limit and the PLC just throws it away.

The driver currently does no implement partial packet writes, it only supports partial packets when reading. So you have the right solution, just break it up into 2 or 3 writes.

thirdeye73

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: EthernetIPforCLX - writing to arrays?
« Reply #7 on: January 27, 2015, 12:00:33 PM »
Okay, I'm making some headway, but have run into another issue, this time with string arrays.  I put the following code in a background worker thread:

Code: [Select]
                ' barcode
                range_str = ss.Barcode.Take(40).ToArray
                frmMain_EIPCLX.Write("SystemStatus_Barcode[1]", 40, range_str)
                System.Threading.Thread.Sleep(5000)

                range_str = ss.Barcode.Skip(40).Take(40).ToArray
                frmMain_EIPCLX.Write("SystemStatus_Barcode[41]", 40, range_str)
                System.Threading.Thread.Sleep(5000)

                range_str = ss.Barcode.Skip(80).Take(25).ToArray
                frmMain_EIPCLX.Write("SystemStatus_Barcode[81]", 25, range_str)
                System.Threading.Thread.Sleep(5000)

The above works without any problems on several DINT arrays (Int32 in VB), but I'm getting index out of bounds errors on the string arrays.  I have verified that all the arrays are dimensioned the same (105 elements in VB and 106 in the PLC--PLC index 0 is not used).

Here is the stack trace of the exception:

   at MfgControl.AdvancedHMI.Drivers.CIP.ForwardOpen(Int32 sendSequence)
   at MfgControl.AdvancedHMI.Drivers.CIP.WriteTagValue(CLXAddress tag, String[] value, Int32 numberOfElements, Int32 sequenceNumber, Int64 OwnerObjectID)
   at AdvancedHMIDrivers.EthernetIPforCLXCom.Write(String startAddress, Int32 numberOfElements, String[] dataToWrite) in C:\Amtec\jobs\_C00645 - TOTO Robotic Storage and Retrieval System\Controls\Programs\AdvancedHMI\AdvancedHMIBetaV397c\AdvancedHMIDrivers\AllenBradley\EthernetIPforCLXCom.vb:line 548
   at TOTO_DataServer.frmMain.GetSystemStatus_DoWork(Object sender, DoWorkEventArgs e) in C:\Amtec\jobs\_C00645 - TOTO Robotic Storage and Retrieval System\Controls\Programs\VB.NET\TOTO_DataServer\TOTO_DataServer\frmMain.vb:line 906




thirdeye73

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: EthernetIPforCLX - writing to arrays?
« Reply #8 on: January 27, 2015, 01:26:30 PM »
I gave up for the time being on writing string arrays, and insterad am writing them individually as follows:

Code: [Select]
                For i As Integer = 0 To ss.Timestamp.GetUpperBound(0)
                    frmMain_EIPCLX.Write("SystemStatus_TimeStamp[" & i + 1 & "]", ss.Timestamp(i))
                    System.Threading.Thread.Sleep(100)
                Next

The drawback is that it takes about 45 seconds for all the writes to complete.  Granted there's a good bit of data being sent, but I'd like to make it faster.  First place to start obviously is my Sleep(100) statement.

Ultimately I'd like to get the array writes to work, but I've got something functional now.

Thanks,
Scott

thirdeye73

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: EthernetIPforCLX - writing to arrays?
« Reply #9 on: January 27, 2015, 01:29:04 PM »
Changed my sleep time to 10ms, down to 17 seconds.  That I can live with.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: EthernetIPforCLX - writing to arrays?
« Reply #10 on: January 27, 2015, 02:07:05 PM »
Writing a string takes 80+ bytes of data, so you figure it's the equivalent of writing 20+ DINTs. I haven't tried it, but I would guess that writing more than 2 strings at a time in a array would produce the same result as writing over 60 DINTs