Author Topic: Compact Logix Index Outside Bounds Of Array  (Read 2075 times)

ceidson

  • Newbie
  • *
  • Posts: 6
    • View Profile
Compact Logix Index Outside Bounds Of Array
« on: January 06, 2016, 11:24:14 AM »
I am using the EthernetIPforCLXCom object to communicate with a CompactLogix PLC.  I am using BasicButtons, but I am also reading PLC information and storing into variables.  To do this I am using a Timer that runs every 100ms.  The timer goes through and reads items from the PLC and stores them into variables.  As part of my window navigation I minimize my Main window while showing other "pop-up" windows.  I disable my Timer while the Main window is minimized.  When I close the popup window, and maximize my Main window, I receive an exception "Index was outside the bounds of the array." during the first read from the PLC.  As a test I added an event for ConnectionClosed for the EthernetIPforCLXCom object.  While my popup is open and my Main window is minimized, the ConnectionClosed event is sometimes fired.  If this happens, I get my exception on the first read. 

First, what would be causing the connection to close?  Second, how can I recover, in order to keep running?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Compact Logix Index Outside Bounds Of Array
« Reply #1 on: January 06, 2016, 04:39:40 PM »
When you get the exception can you look at the details to see what file and line number the exception occurs on?

The connectionClosed occurs whenever a response is not received from the PLC or there are no read or writes within about 20 seconds.

ceidson

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Compact Logix Index Outside Bounds Of Array
« Reply #2 on: January 06, 2016, 05:47:53 PM »
The exception always occurs on the first of a series of PLC.Read() statements, where PLC is my EthernetIPforCLXCom object.  This only happens after the ConnectionClosed event has taken place.

It is very likely that there are now read or writes within 20 seconds when the popup window is opened.  Is there a way to ensure the connection is restored before executing the first PLC.Read() command, or do I need to keep the connection alive?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Compact Logix Index Outside Bounds Of Array
« Reply #3 on: January 06, 2016, 09:04:02 PM »
When you get the exception, what file and line number does it show for where the exception occurred?

If the 20 second timeout closes the connection, the very next read will re-open the connection.

ceidson

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Compact Logix Index Outside Bounds Of Array
« Reply #4 on: January 07, 2016, 07:42:09 AM »
The exception stops in function BeginRead() in EthernetIPforCLXCom.  Line 445 is where it ends up, but line 441 is the culprit.

I don't know if it could be related, but if I step through my PLC.Read() statements and sit in a "paused" state to allow the connection to close, when I continue I get "No response from PLC.", and it stops on line 427 of EthernetIPforCLXCom.

FYI, I have version 3.98 of AdvancedHMI, and I am connecting to a CompactLogix L30ERM, firmware version 27.11.  I am running VS express 2013.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Compact Logix Index Outside Bounds Of Array
« Reply #5 on: January 07, 2016, 08:45:28 AM »
You may want to try version 3.99a. There were some changes to the CLX driver and plus that version is significantly faster.
« Last Edit: January 07, 2016, 09:09:56 AM by Archie »

ceidson

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Compact Logix Index Outside Bounds Of Array
« Reply #6 on: January 07, 2016, 08:55:41 AM »
Great, thanks.  I will give that a try later today.  I am now able to prevent the issue by keeping the connection alive.

ceidson

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Compact Logix Index Outside Bounds Of Array
« Reply #7 on: January 11, 2016, 10:37:01 AM »
I downloaded version 3.99 of AdvancedHMI.  It did change the errors I am getting a little.  When I am running, and I quit all PLC reads so that I eventually get the ConnectionClosed event to occur, I now get the exception "No response from PLC".  It stops in EthernetIPforCLXCom, line 444.

If I step through my program and stop just prior to a Read, and wait for the 20+ seconds, I get "Read Failed. No Response from PLC(22), Status Code=-22".

I have found a way to work around this by keeping the connection open, so as far as I am concerned it is a closed issue.  If you are interested in looking into this further, you can create your default application and add an EthernetIPforCLXCom object, a Timer, and a Button.  Have the button toggle Timer1.Enable.  In the Timer logic, add a read to a PLC tag.  Enable the timer, and then disable it.  Leave the timer disabled until the ConnectionClosed event is fired.  If you enable right away, it seems to recover.   If you wait a while before enabling the timer after the ConnectionClosed event, it will sometimes fail.  It is not nearly as consistent as my project, but it will eventually happen.

Thanks for all of the help.