Which functions and IEC standard functions exist in STEP 7 for converting and comparing string variables?
There is a series of functions and IEC standard functions available in STEP 7 for converting and comparing string variables. You can find the IEC standard functions in the block editor catalog under "Libraries / Standard Library / IEC Function Blocks", and the technical description of the functions and on how to parameterize the variables are available via the STEP 7 Online Help (F1 key).
IEC standard functions for converting and comparing string variables:
|1||FC5 DI_STRNG: Conversion of a DINT-type variable into a STRING-type variable.|
|2||FC10 EQ_STRNG: Compares the content of two STRING-type variables to see if they are "equal".|
|3||FC13 GE_STRNG: Compares the content of two STRING-type variables to see if they are "greater than or equal to".|
|4||FC15 GT_STRNG: Compares the content of two STRING-type variables to see if they are "greater than".|
|5||FC16 I_STRNG: Conversion of an INT-type variable into a STRING-type variable.|
|6||FC19 LE_STRNG: Compares the content of two STRING-type variables to see if they are "less than or equal to".|
|7||FC24 LT_STRNG: Compares the content of two STRING-type variables to see if they are "less than".|
|8||FC29 NE_STRNG: Compares the content of two STRING-type variables to see if they are "not equal".|
|9||FC30 R_STRNG: Conversion of a REAL-type variable into a STRING-type variable.|
|10||FC37 STRNG_DI: Conversion of a STRING variable into a DINT-type variable.|
|11||FC38 STRNG_I: Conversion of a STRING variable into an INT-type variable.|
|12||FC39 STRNG_R: Conversion of a STRING variable into a REAL-type variable.|
IEC standard functions for editing string variables:
FC2 CONCAT: Concatenating STRINGs.
|2||FC4 DELETE: Deleting a STRING.|
FC17 INSERT: Inserting a STRING.
|4||FC20 LEFT: Left part of a STRING.|
|5||FC21 LEN: Length of a STRING.|
|6||FC26 MID: Middle part of a STRING.|
|7||FC31 REPLACE: Replacing a STRING.|
|8||FC32 RIGHT: Right part of a string.|
Sample programs for converting string variables:
|1||Conversion of a string variable into a floating point number|
The download "String_R" contains FC104 for converting a string into a floating point number. In contrast to the IEC function FC39, the string can appear here in simplified format, e.g. '+''1''2''.''3''4' or '-''1''2''.''3''4'. In the case of calls in the OB1, for instance, the following input and output variables (Fig. 21) must be parameterized:
The variables for the string are contained as a "CHAR" data type in the DB100 data block. The start of the string (here, from data byte 1) is defined by the parameter "Str_DBB_NO", and the length of the string (here, 5 bytes) is defined by the parameter "LEN".
The parameter "ERROR" contains the value 'True' if the first byte of the string is not "+" or "-", if the values are outside the range 0 to 9 (Fig. 22), or if there is more than one point within the string.
String_R.zip ( 32 KB )
The attached download contains a STEP 7 project with the blocks described above. Copy the ZIP file into a separate folder and then start the file with a double-click. The STEP 7 project is now unpacked automatically with all the associated subdirectories. You can use the SIMATIC Manager to open and process the extracted project.
Note on billable software:
We also recommend the sample programs listed below, which you can find on the Internet under the Entry ID specified. You can pay with your SIMATIC Card / Automation Value Card AVC.
The three length dimensions (length, width, thickness) are read into the CP340 via RS232 in order to evaluate the values in the S7-300 and display them on an OP. Entry ID 8797119. This sample program enables you to evaluate an ASCII string (e.g. with length details), which is sent to a CP340 via RS232, in your SIMATIC controller.
Conversion of a "CHAR field" into a "string variable". Entry ID 25629271. An "ARRAY of character" is converted into a "string variable" in this example.
Conversion of an integer into ASCII characters without using the STRING data type. Entry ID 25629271. In the attached sample program, an integer is broken down into individual ASCII characters via a function.
Conversion of a DATE_AND_TIME variable into a string variable. Entry ID 25629271
ASCII code, Data evaluation, Strings, Data transfer
- You have a technical question / problem: Ask the Technical Support
- You want to discuss in our forum and exchange experiences with other users
- You want to create CAx data for one or more products
- You would like to send us feedback on this Entry