Author Topic: ReadUDT Size  (Read 1187 times)

Kramrellim

  • Newbie
  • *
  • Posts: 12
    • View Profile
ReadUDT Size
« on: November 15, 2023, 09:06:08 AM »
Is there a size limit to a UDT?
I have a UDT that is 14244 bytes

bachphi

  • Hero Member
  • *****
  • Posts: 642
    • View Profile
Re: ReadUDT Size
« Reply #1 on: November 15, 2023, 04:16:10 PM »
Can you share the UDT to see If I can read it.?
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Kramrellim

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: ReadUDT Size
« Reply #2 on: November 15, 2023, 04:46:52 PM »
Here it is in L5X format.

bachphi

  • Hero Member
  • *****
  • Posts: 642
    • View Profile
Re: ReadUDT Size
« Reply #3 on: November 19, 2023, 08:12:39 PM »
No good , wont import.

Error: Object does not exist.
Import failed - 1 error(s), 0 warning(s) - No changes were made to the project

STRING_16 is built in. No need to include
« Last Edit: November 19, 2023, 08:18:05 PM by bachphi »
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Kramrellim

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: ReadUDT Size
« Reply #4 on: November 22, 2023, 08:25:32 AM »
Thank you for trying. This UDT was supplied to me by Rockwell.
The controller is a Compact GuardLogix 5380  5069-L330ERMS2

bachphi

  • Hero Member
  • *****
  • Posts: 642
    • View Profile
Re: ReadUDT Size
« Reply #5 on: November 23, 2023, 10:37:26 AM »
That's probably why.  My PLC is a 5370.
Such messy string definition , for ex. STRING_8 can contains up to 24 chars.

I was able to import it into a L330ERMS2, rework the UDT to v2.  then import to my PLC.
It took less than a second to read all tags.
see picture & attached v2.


« Last Edit: November 23, 2023, 11:52:10 AM by bachphi »
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Kramrellim

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: ReadUDT Size
« Reply #6 on: November 28, 2023, 07:08:07 PM »
Thank you

Kramrellim

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: ReadUDT Size
« Reply #7 on: December 01, 2023, 03:04:19 PM »
That's probably why.  My PLC is a 5370.
Such messy string definition , for ex. STRING_8 can contains up to 24 chars.

I was able to import it into a L330ERMS2, rework the UDT to v2.  then import to my PLC.
It took less than a second to read all tags.
see picture & attached v2.



Yes, I can read the UDT structure with the tag reader. I'm trying now to read the data with ReadUDT.
Here is what I have as the structure.


Module HMI_UDT_Class

    Public completeData As UDT_HMI_StationStatus

    Public Class STR0004
        Public len1 As Int32
        Public STR4(4) As SByte
    End Class

    Public Class STR0016
        Public len2 As Int32
        Public STR16(16) As SByte
    End Class


    Public Class STR0024
        Public len3 As Int32
        Public STR0024(24) As SByte
    End Class

    Public Class String_24
        Public len4 As Int32
        Public Str24(24) As SByte
    End Class

    Public Class String_8
        Public len5 As Int32
        Public Str_8(24) As SByte

    End Class






    Public Class UDT_HMI_ActivePartProgram
        Public Program(19) As String
        Public SubProgram(9) As String
        Public ProgramName As String
        Public SubProgramName As String
        Public ProgramNumber As Int32
        Public SubProgramNumber As Int32
        Public ProgramLineNumber(19) As Int32
        Public SubProgramLineNumber(9) As Int32
        Public SubActive As Boolean
    End Class

    Public Class UDT_HMI_AngleOffset
        Public angleOffsetReq As Boolean
        Public angleOffsetVal As Single
    End Class

    Public Class UDT_HMI_Axis
        Public Enabled As Boolean
        Public InPos As Boolean
        Public Homed As Boolean
        Public Returned As Boolean
        Public Faulted As Boolean
        Public CmdPos As Single
        Public AbsPos As Single
        Public Speed As Single
        Public SpeedUnits As String
        Public Present As Boolean
        Public InhibitStatusButs As Int32
        Public CurrentFaultCode As Int32
        Public jogPos As Boolean
        Public jogNeg As Boolean
        Public jogEnabled As Boolean
        Public Name As STR0004
        Public MtrCurr As Single
        Public MtrCap As Single
        Public InvCap As Single
        Public PosErr As Single
    End Class

    Public Class UDT_HMI_AxisJog
        Public pos As Boolean
        Public neg As Boolean
        Public enabled As Boolean
        Public incChange As Boolean
        Public speed(5) As Single
        Public unit As String_8
        Public incSel As SByte
        Public spdSel As SByte
        Public increment(4) As Single
        Public mode As Boolean
        Public axisSelect As SByte
        Public axisPresent(32) As Boolean
        Public axisType As Int16
        Public axisName(6) As STR0004

    End Class

    Public Class UDT_HMI_Button
        Public Target As Boolean
        Public Active As Boolean
    End Class

    Public Class UDT_HMI_Coordinates
        Public X(500) As Single
        Public Y(500) As Single
        Public Angle(500) As Single
        Public Dist(500) As Single
        Public Active(500) As SByte

    End Class
    Public Class UDT_HMI_FeedrateOverride
        Public spdUnits As String_8
        Public Feedrate As Single
        Public overrideFeedrate As Single
        Public overrideEnabled As Boolean
        Public feedratePct As Single
        Public RapidPct As Int32

    End Class

    Public Class UDT_HMI_MachineStatus
        Public gStop As STR0016
        Public mStop As STR0016
        Public activeMcode(7) As STR0024
        Public activeGcode(7) As STR0024
        Public registers(15) As STR0024
        Public gBlink As Boolean
        Public mBlink As Boolean

    End Class

    Public Class UDT_HMI_Parameters
        Public Number(5) As Int32
        Public Value(5) As Single
        Public Name(5) As String_24

    End Class

    Public Class UDT_HMI_Spindle
        Public AtSpeed As Boolean
        Public Enabled As Boolean
        Public Faulted As Boolean
        Public CmdSpeed As Single
        Public ActSpeed As Single
        Public SpeedUnits As String
        Public Present As Boolean
        Public Direction As Boolean  ' 0=CW 1= CCW
        Public Name As STR0004
        Public MotorCap As Single


    End Class

    Public Class UDT_HMI_StateModle
        Public State As SByte
        Public notComplete As Boolean
        Public notCpEM As SByte

    End Class

    Public Class UDT_HMI_toolPathGraph
        Public inchMode As Boolean
        Public metricMode As Boolean
        Public SampleActive As Boolean
        Public Coordinates As UDT_HMI_Coordinates
        Public GraphClear As UDT_HMI_Button
        Public SampleRate As Single
        Public PosX As Single
        Public PosY As Single
        Public PosZ As Single
        Public UserPosX As Single
        Public UserPosY As Single
        Public UserPosZ As Single
        Public UserMaxX As Single
        Public UserMinX As Single
        Public UserMaxY As Single
        Public UserMinY As Single
        Public UserMaxZ As Single
        Public UserMinZ As Single
        Public DistThreshold As Single
        Public Units As String
        Public zoomPct As Single

    End Class



    Public Class UDT_HMI_StationStatus
        Public btnAuto As UDT_HMI_Button
        Public btnContinous As UDT_HMI_Button
        Public btnSingleStep As UDT_HMI_Button
        Public btnCycleStart As UDT_HMI_Button
        Public btnCycleStop As UDT_HMI_Button
        Public btnCycleAbort As UDT_HMI_Button
        Public btnTestMode As UDT_HMI_Button
        Public btnMode As UDT_HMI_Button
        Public btnManual As UDT_HMI_Button
        Public btnoptionalStop As UDT_HMI_Button
        Public btnBlockDelete As UDT_HMI_Button
        Public btnEmergencyReturn As UDT_HMI_Button
        Public btnControlReset As UDT_HMI_Button
        Public btnFaultReset As UDT_HMI_Button
        Public Axis01 As UDT_HMI_Axis
        Public Axis02 As UDT_HMI_Axis
        Public Axis03 As UDT_HMI_Axis
        Public Axis04 As UDT_HMI_Axis
        Public Axis05 As UDT_HMI_Axis
        Public Axis06 As UDT_HMI_Axis
        Public Axis07 As UDT_HMI_Axis
        Public Spindle01 As UDT_HMI_Spindle
        Public Spindle02 As UDT_HMI_Spindle
        Public Spindle03 As UDT_HMI_Spindle
        Public Spindle04 As UDT_HMI_Spindle
        Public Spindle05 As UDT_HMI_Spindle
        Public ActivePartProgram As UDT_HMI_ActivePartProgram
        Public AxisFault As Boolean
        Public State As Int32
        Public Mode As Int32
        Public ToolPathGraph As UDT_HMI_toolPathGraph
        Public MachineStatus As UDT_HMI_MachineStatus
        Public FeedRateOverride As UDT_HMI_FeedrateOverride
        Public stopIndicate As Boolean
        Public AxisJog As UDT_HMI_AxisJog
        Public Parameters As UDT_HMI_Spindle
        Public StateModel As UDT_HMI_StateModle
        Public AngleOffset As UDT_HMI_AngleOffset

    End Class




End Module

Read

        completeData = EthernetIPforCLXCom1.ReadUDT(Of HMI_UDT_Class.UDT_HMI_StationStatus)("Test_UDT")


I get this fault
IndexOutOfRangeException: Index was outside the bounds of the array.

bachphi

  • Hero Member
  • *****
  • Posts: 642
    • View Profile
Re: ReadUDT Size
« Reply #8 on: December 01, 2023, 06:36:26 PM »
I normally approach the issue by simplifying,  dividing and conquering.

Can you verify that you can read a simple tag with your custom length of 4?
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Kramrellim

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: ReadUDT Size
« Reply #9 on: December 02, 2023, 09:19:45 AM »
Looks like its the custom length strings.
I get a "Index was outside the bounds of the array."

My example:

    Public Class STR0004
        Public len1 As Int32
        Public STR4(4) As SByte
    End Class

The custom string in the controller

STR004
      Len           DINT
      DATA         SINT[4]   
« Last Edit: December 02, 2023, 09:49:11 AM by Kramrellim »

bachphi

  • Hero Member
  • *****
  • Posts: 642
    • View Profile
Re: ReadUDT Size
« Reply #10 on: December 02, 2023, 01:53:32 PM »
Aye, your issue was not about the size of the UDT, but rather in the string tag.  Now you can concentrate on finding the fix for it.
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Kramrellim

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: ReadUDT Size
« Reply #11 on: December 02, 2023, 02:34:26 PM »
I've tried everything I can think of.
No luck.

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: ReadUDT Size
« Reply #12 on: December 02, 2023, 03:15:31 PM »
If your SINT[4] is 4 elements then your declaration should be Public STR4(3) As SByte.

See this link: https://kcwebprogrammers.blogspot.com/2011/01/vb-arrays-vs-c-arrays-in-aspnet.html

bachphi

  • Hero Member
  • *****
  • Posts: 642
    • View Profile
Re: ReadUDT Size
« Reply #13 on: December 02, 2023, 03:40:37 PM »
If you look at the tag in the PLC, you will see that that the data array index start at 0. So If a custom string length of 20, then you need to have 20-1=19.

Another thing you need to look at is the data type in the PLC is SINT. What is SINT?  is it really equivalent to SByte?
SINT is short integer(0 to255) not signed integer, a SByte is Signed Byte(-128 to 127)
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Godra

  • Hero Member
  • *****
  • Posts: 1438
    • View Profile
Re: ReadUDT Size
« Reply #14 on: December 02, 2023, 08:07:24 PM »
bachphi, your statement seems incorrect to me.

SINT, INT, DINT, LINT should be signed integers and USINT, UINT, UDINT, ULINT should be unsigned.

Check the following link:  https://help.codesys.com/api-content/2/codesys/3.5.12.0/en/_cds_datatype_integer/