Author Topic: Cannot read values from a PLC-5 on v398 (working in v397)  (Read 1687 times)

jsorah

  • Newbie
  • *
  • Posts: 10
    • View Profile
Cannot read values from a PLC-5 on v398 (working in v397)
« on: May 06, 2015, 10:39:02 AM »
I am currently unable to read values from a PLC-5 via Ethernet - using the EthernetIPforPLCSLCMicroCom driver.

The error is a -20 (no data returned/no response), but I haven't looked too deeply at what's going on myself.  My program works and reads values from the PLC-5 without issue when reverted to v397f (with a ControlLogix patch).

A few sample tags I'm trying to read in case that is useful:

N7:101
O:033/1
B13:8/13

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5266
    • View Profile
    • AdvancedHMI
Re: Cannot read values from a PLC-5 on v398 (working in v397)
« Reply #1 on: May 06, 2015, 01:37:01 PM »
The SLC/Micro/PLC5 drivers was recently rewritten to bring it up to the most recent architecture. In the process, PLC5 support was dropped. Not sure if it will be put back in since the demand for PLC5 has dropped significantly.

jsorah

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Cannot read values from a PLC-5 on v398 (working in v397)
« Reply #2 on: May 06, 2015, 01:55:37 PM »
Thanks for the response Archie.

Is it possible that someone (i.e. myself) could write a driver to support PLC5 on the newest version or would that require modification of the MfgControl.AdvancedHMI.Drivers binary provided in the project?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5266
    • View Profile
    • AdvancedHMI
Re: Cannot read values from a PLC-5 on v398 (working in v397)
« Reply #3 on: May 06, 2015, 06:19:18 PM »
If you look in AllenBradleySLCMicro.vb at line 1773, you can see where it checks to see if it is a PLC5. A few lines later, it always uses a ProtectedTypeLogicalRead. Based on the DF1 Protocol and Command Set Manual, the PLC5 does not support that command. The code would have to be modified to use a command the PLC5 supports. The PLC5 command may also have to be implemented in AllenBradleyPCCC.vb


jsorah

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Cannot read values from a PLC-5 on v398 (working in v397)
« Reply #4 on: May 08, 2015, 08:46:58 AM »
Thanks for the tips, I got the read working with some fairly simple changes. 

In case it may be useful to anyone else -

Added this function to AllenBradleyPCCC.vb
Code: [Select]
    '* Word range read
    '* Reference : Page 7-34
    '* Supported by PLC-3 and PLC-5 only.
    Public Function WordRangeRead(ByVal byteSize As Byte, ByVal address As MfgControl.AdvancedHMI.Drivers.PCCCAddress, ByVal TNS As Integer) As Integer

        Dim pck As New MfgControl.AdvancedHMI.Drivers.PCCCCommandPacket()
        pck.Command = &HF
        pck.FunctionCode = &H1
        pck.TransactionNumber = TNS

        'This is basically what happened in version 397e, except the command, function and TNS were manually packed.
        For Each val As Byte In address.ByteStream
            pck.EncapsulatedData.Add(val)
        Next

        SendPacket(pck, TNS)
        Return TNS
    End Function


And replaced code between lines 1772 - 1783 in AllenBradleySLCMicro.vb with this

Code: [Select]
                '* A PLC specifies the number of bytes at the end of the stream
                If MfgControl.AdvancedHMI.Drivers.PCCCAddress.IsPLC5(ProcessorType) Then
                    PAddress.ByteStream(PAddress.ByteStream.Length - 1) = CByte(NumberOfBytesToRead)
                    WordRangeRead(Convert.ToByte(NumberOfBytesToRead), PAddress, TNS)

                Else
                    PAddress.ByteStream(0) = CByte(NumberOfBytesToRead)
                    ProtectedTypeLogicalRead(Convert.ToByte(NumberOfBytesToRead), Convert.ToByte(PAddress.FileNumber), Convert.ToByte(PAddress.FileType), _
                                               Convert.ToByte(PAddress.Element), Convert.ToByte(PAddress.SubElement), TNS)
                End If

               

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5266
    • View Profile
    • AdvancedHMI
Re: Cannot read values from a PLC-5 on v398 (working in v397)
« Reply #5 on: May 08, 2015, 09:00:04 AM »
Nice work! Impressive that you figured that out rather fast. Modifying those drivers can get quite complicated.