Author Topic: MicroLogix/RSLogix500 with timer .PRE and ACC  (Read 2458 times)

makulais

  • Newbie
  • *
  • Posts: 6
    • View Profile
MicroLogix/RSLogix500 with timer .PRE and ACC
« on: October 23, 2013, 04:41:11 PM »
I keep getting errors in the ExtractData function when attempting to read from timer files at line 1507, Index out of Range.
I am attempting to retrieve the PRE value from a single timer.
Dim RFTimePre As Integer = Main.PLCNet.Read("T4:13.PRE")

in your code, AllenBradleyPCCC.vb, lines 1499-1507
ReturnedData has a length of 2, but j is a value of 2 when it can only have a maximum value of 1?  I'm not sure what you are doing to determine the start index but I believe something is incorrect.  If I attempt to read the ACC register, I also get an error where j is 4.

'* If a sub element is designated then read the same sub element for all timers
                Dim j As Integer
                For i As Integer = 0 To ParsedResult.NumberOfElements - 1
                    If ParsedResult.SubElement > 0 Then
                        j = i * 6 + (ParsedResult.SubElement) * 2
                    Else
                        j = i * 2
                    End If
                    result(i) = BitConverter.ToInt16(ReturnedData, j)

makulais

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: MicroLogix/RSLogix500 with timer .PRE and ACC
« Reply #1 on: October 23, 2013, 05:07:02 PM »
Not sure, but it looks like you were attempting to parse through the retained data and pull out the ACC from what you thought was an array of ACC and PRE values, but it does only return either the ACC or the PRE, not both.  Therefore it looks like this should just be simplified to

For i As Integer = 0 To ParsedResult.NumberOfElements - 1
        j = i * 2
       result(i) = BitConverter.ToInt16(ReturnedData, j)
Next

this worked with both single reads, and array reads.

makulais

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: MicroLogix/RSLogix500 with timer .PRE and ACC
« Reply #2 on: October 23, 2013, 05:26:47 PM »
forgot to state my version number, I'm using 3.58

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: MicroLogix/RSLogix500 with timer .PRE and ACC
« Reply #3 on: October 23, 2013, 05:34:20 PM »
I need to double check, but the code would read all 3 elements and parse them out when it came back with the values. The reasoning for this was to be able to read multiple timers in a single read.

makulais

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: MicroLogix/RSLogix500 with timer .PRE and ACC
« Reply #4 on: October 24, 2013, 07:27:50 AM »
My 'fix' is probably not good then.  Looks like the issue is probably with the data being returned.  It appeared to me that it returned only the data requested.  If I requested a PRE, it returned a PRE, if I requested an ACC, it returned an ACC.  I didn't delve into the multiples too much, but it did appear that if my request was for PRE and 4 data points, it would return an array of 8 bytes, I assumed this was 4 PRE's?  If that's not what you were going for, then my 'fix' doesn't work.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: MicroLogix/RSLogix500 with timer .PRE and ACC
« Reply #5 on: November 03, 2013, 05:59:04 PM »
Try out version 3.60 to see if this resolves the issue.