Creating String Data Types For Use In Ladder Logic

StringsA string is a User-Defined data Type or UDT with two members.

The two members or elements of the data type consist of a DINT used to store the length of the string and an array of SINT’s that store the individual characters of the string. By default the ladder programming software has a Pre-Defined String type named STRING. The default STRING data type cannot be changed, however you are welcome to make as many different User-Defined Strings as you need. The only variables that can be changed when creating a User-Defined String are the name and size of the array that holds the individual characters.



Member                              Data Type                            Style
STRING.LEN                        DINT                                Decimal
STRING.SINT                      SINT[82]                        ASCII


As an example I need a string data type that stores 10 maximum characters. Rather than using the default STRING Data Type, I created a new String Data Type which holds 10 characters. This new User-Defined String uses far less memory than the default STRING Data Type.

String Data Type



Name:  STRING_10

Member                              Data Type                            Style

STRING_10.LEN                 DINT                                Decimal
STRING_10.SINT               SINT[10]                         ASCII


As seen in the screen shot I created a new String data type that holds 10 characters. Note that spaces are characters and the length of the string is 9 characters long as stored in the member .LEN.

 Strings Data