Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - danm

Pages: [1]
1
Support Questions / Re: Basic help with Allen Bradley UDT
« on: September 01, 2023, 05:02:39 PM »
Minimum size of a UDT is 4 bytes.  A single bool is 4 bytes  UDT's are packed in 4 byte chunks.  A simple 2 INT UDT will be 4 bytes.  A simple UDT with a INT and BOOL will be 4 bytes.

A string takes 88 bytes of memory.  82 for the characters, 4 for the length and 2 pad bytes.

That INT will be in its own 4 byte chunk.  Take the example STRING/INT/STRING.

STRING = bytes [0-87]
INT = bytes [88-91] (2 pad bytes because next STRING won't fit in the 2 available bytes)
STRING = bytes [92-179]

Similarly, that BOOL Quarantine will occupy its own 4 byte chunk.

I bet if you reorganized your UDT to be strings first, then INTs then BOOLs, you'll see a size change.

I will talk to the PLC guys!  I don't do any PLC work myself just tasked with connecting them to our other systems.

2
Support Questions / Re: Basic help with Allen Bradley UDT
« on: September 01, 2023, 04:59:48 PM »
Any reason for not using the latest version which supports the ReadUDT?
The ReleaseNotes399.txt says it is the version 3.99x however as I mentioned when I try and use the ReadUDT method it highlights that line with the error "ReadUDT is not a member of EthernetIPforCLXCom".  I am not sure why because that was my first thought to try.

3
Support Questions / Basic help with Allen Bradley UDT
« on: September 01, 2023, 09:53:38 AM »
I have a UDT in a Allen Bradly PLC.  I am using version 3.99x.  I have tried 'READUDT' but it returns "'ReadUDT' is not a member of 'EthernetIPforCLXCom1'"?  I am having issue understanding how to determine where to start each tag and how many bytes to read.  All strings are 82 long and the format of the UDT is:
Code: [Select]
Public Class CDS 'Common Data Structure
  Public PalletNumber As String
  Public ProductionOrderID As String
  Public InternalOrderID As String
  Public ItemNumber As String
  Public ItemName As String
  Public LotCode As String
  Public ItemGroup As String
  Public Barcode As String
  Public CasesPerPallet As Int16
  Public ProductType As String
  Public Quarantine As Boolean
  Public QuarantineOrderID As String
  Public TimeStamp As String
  Public PartialCaseCount As Int16
  Public PartialP As Boolean
  Public MoverClassification As String
  Public ReservedSalesOrderID As String
  Public Destination As String
  Public Location As String
  Public State As String
  Public Notes As String
End Class

I am using the following to read and display the UDT for testing but some of them come back as gibberish.  I am sure it is in my not understanding what bytes belong to each tag.  As the control works amazing for reading the tags separately.  Can someone help give me a basic understanding of the byte offsets and how to calculate them?

Code: [Select]
  Private Function ReadWO(ByVal tag As String) As String
    Dim bytes As Byte() = EthernetIPforCLXCom1.ReadRaw(tag)
    Dim CommonData As CDS = New CDS With {
    .PalletNumber = ExtractStringField(bytes, 4, 82),
    .ProductionOrderID = ExtractStringField(bytes, 90, 82),
    .InternalOrderID = ExtractStringField(bytes, 176, 82),
    .ItemNumber = ExtractStringField(bytes, 268, 82),
    .ItemName = ExtractStringField(bytes, 354, 82),
    .LotCode = ExtractStringField(bytes, 440, 82),
    .ItemGroup = ExtractStringField(bytes, 529, 82),
    .Barcode = ExtractStringField(bytes, 612, 82),
    .CasesPerPallet = BitConverter.ToInt16(bytes, 698),
    .ProductType = ExtractStringField(bytes, 710, 82),
    .Quarantine = BitConverter.ToBoolean(bytes, 744),
    .QuarantineOrderID = ExtractStringField(bytes, 746, 82),
    .TimeStamp = ExtractStringField(bytes, 890, 82),
    .PartialCaseCount = BitConverter.ToInt16(bytes, 976),
    .PartialP = BitConverter.ToBoolean(bytes, 912),
    .MoverClassification = ExtractStringField(bytes, 914, 82),
    .ReservedSalesOrderID = ExtractStringField(bytes, 996, 82),
    .Destination = ExtractStringField(bytes, 1078, 82),
    .Location = ExtractStringField(bytes, 1160, 82),
    .State = ExtractStringField(bytes, 1242, 82),
    .Notes = ExtractStringField(bytes, 1324, 82)
}
    PrintClassFields(CommonData)
    ' Dim MyUDT As DateTimeUDT = EthernetIPforCLXCom1.ReadUDT("MyUDT", GetType(DateTimeUDT))
  End Function

  Private Function ExtractStringField(bytes As Byte(), offset As Integer, length As Integer) As String
    Dim fieldBytes(length - 1) As Byte
    Array.Copy(bytes, offset, fieldBytes, 0, length)
    Return Encoding.Default.GetString(fieldBytes).Trim().Replace(Convert.ToChar(0), "")
  End Function

 Sub PrintClassFields(obj As Object)
   Dim type As Type = obj.GetType()
   For Each fieldInfo As FieldInfo In type.GetFields()
     Dim fieldName As String = fieldInfo.Name
     Dim fieldValue As Object = fieldInfo.GetValue(obj)
     Debug.WriteLine(fieldName & " : " & fieldValue)
   Next
 End Sub


4
Support Questions / Re: issue with strings / Allen Bradley
« on: September 22, 2022, 03:37:50 PM »
Thank You!! That tag browser works wonderfully.  I found the tag needed for my example.  What would be the correct syntax to use in the 'PLCAddressValue' field to display it? I tried "Robot1LineABUILD(Pallet_Data)PALLETID.data","Robot1LineABUILD("Pallet_Data")PALLETID.data","Robot1LineABUILD.Pallet_Data.PALLETID.data" also the same without the '.data' suffix.

5
Support Questions / Re: issue with strings / Allen Bradley
« on: September 22, 2022, 09:09:03 AM »
  I tried to compile the CLXTagList_ComboBox and CLXTagList_TreeView they both create errors "'ArrayElements1' is not a member of 'CLXTag'" and repeat for ArrayElements2/3? I also get a error "'UDTStructure' is not a member of 'CLXTag'"? I downloaded "AdvancedHMIv399xR1.zip" from the site here and have only made changes to it as instructed. I placed them under the AdvancedHMIControls/Controls and did a 'clean solution' followed by 'rebuild solution' using Visual Studio 2022 Enterprise ver 17.3.2
  I also found while searching reference to "ReadUDT" (https://advancedhmi.com/documentation/index.php/ReadUDT) and tried using it but it returns "'ReadUDT' is not a member of 'EthernetIPforCLXCom1'"?
  My end goal is to be able to display some of the factory data live using a projector/large screen connected to a PC


Code: [Select]
Private Sub BasicButton3_Click(sender As Object, e As EventArgs) Handles BasicButton3.Click
        Dim MyStructureInstance As CDS
        MyStructureInstance = EthernetIPforCLXCom1.ReadUDT(Of CDS)("Robot1LineABUILD", 1)
    End Sub

    Public Class CDS 'Common Data Structure
        Public PTS_PalletID As Int32
        Public PTS_ProductionOrderID As String
        Public PTS_InternalOrderID As String
        Public PTS_ItemNumber As String
        Public PTS_ItemName As String
        Public PTS_LotCode As String
        Public PTS_ItemGroup As String
        Public PTS_Barcode As String
        Public PTS_CasesPerPallet As Int32
        Public PTS_ProductType As String
        Public PTS_Quarantine As Boolean
        Public PTS_QuarantineOrderID As String
        Public PTS_TimeStamp As String
        Public PTS_PartialCaseCount As Int32
        Public PTS_Partial As Boolean
        Public PTS_MoverClassification As String
        Public PTS_ReservedSalesOrderID As String
        Public PTS_Destination As String
        Public PTS_Location As String
        Public PTS_State As String
        Public PTS_Notes As String
        Public STP_PalletID As String
        Public STP_Destination As String
        Public STP_ACK As Boolean
        Public STP_NACK As Boolean
    End Class

6
Support Questions / Re: issue with strings / Allen Bradley
« on: September 21, 2022, 12:12:51 PM »
Again Thank you for the fast response!  I was able to call up our PLC coder and he says they are "Program Scoped" tags. He also said the strings are just 'standard AB strings". I added "Program:" as suggested and the label shows "Path Segment Error (Invald Tag Name)".  I did some searching and found a old code snippet that loops through the tags (posted below) but only shows the 'upper level' tags ('Robot1LineABuild').  Is there a similar snippet that can show all 'levels' of the tags ('Robot1LineABuild.PRODUCTIONORDERID') and help me identify the correct tag name?

Code: [Select]
        Dim t() As MfgControl.AdvancedHMI.Drivers.CLXTag
        t = EthernetIPforCLXCom1.GetTagList(60000)
        Using sw As New System.IO.StreamWriter(".\TagList.txt")
            For i = 0 To t.Length - 1
                sw.WriteLine(t(i).TagName)
            Next
        End Using

7
Support Questions / Re: issue with strings / Allen Bradley
« on: September 21, 2022, 07:26:59 AM »
Hello
  Thanks for the quick response!  I ma not a PLC programmer, I code around them.  I believe they would be considered custom length as they are  defined as "String (char limit 82)" in the documentation I was given.  The format is shown as "ROBOT1LINEABUILD.PRODUCTIONORDERID.DATA/82". I have tried putting it in as "ROBOT1LINEABUILD.PRODUCTIONORDERID.DATA", "ROBOT1LINEABUILD.PRODUCTIONORDERID" and "ROBOT1LINEABUILD.PRODUCTIONORDERID.DATA(82)"  The non strings are displaying fine.  What is the format needed and what control is best to display these inside?  Is there any downloadable help files/system?

8
Support Questions / issue with strings / Allen Bradley
« on: September 20, 2022, 03:44:49 PM »
Hello, very new here just downloaded and began playing with this.  I am sure it is something simple but I can not get strings to display using 'basic labels'.  I am connected to an Allen Bradley PLC (control logix) and able to display Booleans and number values but text/strings show nothing? I use KEPWareEX 6 also and can see the tags do have a value by using their client.  I get no errors or "Path Destination Unknown" just no display in the label?
Thank You

Pages: [1]