Uploaded by mayil azhagan

Convert char to string TIA Portal how to do it and use it » tecnoplc

advertisement
5/13/23, 5:29 PM
Convert char to string TIA Portal how to do it and use it » tecnoplc
CA TEGORIES
HOME
PROGRAMACIÓN 
CONTACTO
TECNOLOGÍA 
EJEMPLOS 
DESCARGAS 
choose TIENDA
the category
PROYECTOS
0
CONVERTIR CHAR A STRING TIA
PORTAL CÓMO HACERLO Y
UTILIZARLO
Publicado por tecnoplc.com | DATOS,
PROGRAMACIÓN | 0  |     

https://www.tecnoplc.com/convertir-char-a-string-tia-portal-como-hacerlo-y-utilizarlo/
1/13
5/13/23, 5:29 PM
Convert char to string TIA Portal how to do it and use it » tecnoplc
|
CA TEGORIES
How to convert CHAR to STRING in TIA Portal
through a function and allow to transform all the
characters that we have in different positions of an
Array in a single String variable that will allow us to
have all those characters together and make
comparisons with other variables.
Item Content:
1. Why do we want to convert CHAR to STRING in the
TIA Portal?
2. Everything we are going to learn today.
2.1 Data array of type CHAR.
2.2 STRING type variables.
2.3 Chars_TO_Strg function.
2.4 Application example of converting CHAR to
STRING.
3. You have to create a data DB with an Array to
convert CHAR to STRING TIA Portal.
4. How do we put the characters in the Array?
5. What function do we use to convert CHAR to
STRING TIA Portal?
5.1 CHARS parameter.
5.2 PCHARS parameter.
5.3 CNT parameter to convert CHAR to STRING
TIA Portal.
5.4 STRG parameter.
https://www.tecnoplc.com/convertir-char-a-string-tia-portal-como-hacerlo-y-utilizarlo/
LA TEST
DOCUMEN TS
Connection
s between
functions
LOGO
Siemens
connection
between
the blocks
May 12, 2023
Basic
functions
LOGO
Siemens
knows all
your
details

May 10, 2023
2/13
5/13/23, 5:29 PM
Convert char to string TIA Portal how to do it and use it » tecnoplc
6. We went online to see how to convert CHAR to
STRING.
WHY DO WE WANT TO CONVERT CHAR TO
STRING IN THE TIA PORTAL?
First of all, we are going to specify that we are going to
transform several CHAR characters defined in a data array
into a single variable of type STRING. Therefore, all the
CHAR variables inside the Array will be combined into a
single variable of type STRING. Therefore, with a single
variable, we can make, for example, comparisons with
other variables that contain characters.
No.
We have all the characters in a single variable.
No.
It will be easier to use the STRING to compare
with other text in another variable.
No.
We avoid having to compare each position of
an Array one by one.
Addressing
of PLC
Inputs and
CA TEGORIES
Outputs in
the TIA
Portal
May 9, 2023
Create new
project
LOGO
Siemens
step by
step from
scratch
May 5, 2023
LOOK FOR …
YOU HAVE TO CREATE A DATA DB WITH AN
ARRAY TO CONVERT CHAR TO STRING TIA
PORTAL.
First of all, we are going to create a data DB in TIA Portal
, which will allow us to create variables inside it of the type
we need. Therefore, once the DB is created we will have
enough space to create our CHAR type Array.

https://www.tecnoplc.com/convertir-char-a-string-tia-portal-como-hacerlo-y-utilizarlo/
3/13
5/13/23, 5:29 PM
Convert char to string TIA Portal how to do it and use it » tecnoplc
CA TEGORIES
For this reason, we have to continue creating a variable that
we will call for example “ Array_CHAR ” and in the data type
we have to select “ Array[0..1] of ”. As a consequence of
this, a drop-down list appears where we can select the type
of all the variables within the Array. In our case, we select “
Array[0..1] of Char ”.
Also, the next step is to set the length of the Array.
Therefore, where we have the “ [0..1] ” we can set the
length. Therefore, we are going to establish an Array of 20
for example.

HOW DO WE PUT THE CHARACTERS IN THE
ARRAY?
https://www.tecnoplc.com/convertir-char-a-string-tia-portal-como-hacerlo-y-utilizarlo/
4/13
5/13/23, 5:29 PM
Convert char to string TIA Portal how to do it and use it » tecnoplc
Meanwhile, once the Array is created, we can set default
characters at each position in the Array. Therefore, we can
insert the characters one by one into the “ Start Value ”
of the DB in the TIA Portal .
CA TEGORIES
It seems that we already have some characters established
and, if we now read the positions of the array one by one,
we will get the phrase “ PLC SIEMENS ”. As a consequence
of this, it seems that it would be a bit expensive to read the
Array positions one by one in order to display the message,
right? So what if we turned all these separate characters
into a single variable so that we could work with a single
variable? Yes, we are going to transform it to a STRING.
WHAT FUNCTION DO WE USE TO CONVERT
CHAR TO STRING TIA PORTAL?
Due to what we have commented, we have to open a block
where we are going to work, for example, an FC. Once
inside, we have to go to the tree on the right of the TIA
Portal and access the “ Instructions ” and within “
Advanced Instructions ” look for the “ String + Char ”
folder. Therefore, a series of functions will appear here to
work with these types of data and we will select the
function called “ Chars_TO_Strg “. Therefore, we select it
and drag it to the segment where we are going to work.
https://www.tecnoplc.com/convertir-char-a-string-tia-portal-como-hacerlo-y-utilizarlo/

5/13
5/13/23, 5:29 PM
Convert char to string TIA Portal how to do it and use it » tecnoplc
CA TEGORIES
Once the function is inserted, the function parameters
appear in red to insert the necessary variables and data.
Now we will describe them one by one.
CHARS PARAMETER.
First of all, we have the parameter called “ CHARS ” where
we have to insert the data Array where the characters are
separated one by one in each position of the Array. That is
to say, here we place the Array that we have previously
created in the DB.
https://www.tecnoplc.com/convertir-char-a-string-tia-portal-como-hacerlo-y-utilizarlo/

6/13
5/13/23, 5:29 PM
Convert char to string TIA Portal how to do it and use it » tecnoplc
CA TEGORIES
PCHARS PARAMETER.
Also, in the next parameter we have to indicate the position
within the Array from which it will take the characters to
convert them. Therefore, if we put a 10 here, the conversion
will start from position 10 of the Array onwards, that is,
from position 0 to 9 it would not be converted. In our case,
we want it to count from position 0 of the Array.
CNT PARAMETER TO CONVERT CHAR TO STRING
TIA PORTAL.
Finally we have the input parameter CNT, where we have to
insert the number of elements of the Array that we want to
convert. Therefore, in our case, if we look at the Array
inside the DB, we want to use data 0 of the Array up to data
10 of the Array, that is, we have to insert an 11.
https://www.tecnoplc.com/convertir-char-a-string-tia-portal-como-hacerlo-y-utilizarlo/

7/13
5/13/23, 5:29 PM
Convert char to string TIA Portal how to do it and use it » tecnoplc
CA TEGORIES
STRG PARAMETER.
Also, we need to insert one last output parameter of the
function, where we are going to store the data converted
from CHAR to STRING. Therefore, in this parameter we have
to place a variable of type “ STRING ” that we have not yet
created. It seems that, taking advantage of the data DB that
we created earlier, we are going to create another variable
in the DB of type STRING. For this reason, in a new line of
the DB, we give a name to a variable called “
VAR_convertida ”.
Once the variable is created inside the DB, we have to
insert the variable in the function to complete the structure
of the function and not give us any error when compiling.
https://www.tecnoplc.com/convertir-char-a-string-tia-portal-como-hacerlo-y-utilizarlo/

8/13
5/13/23, 5:29 PM
Convert char to string TIA Portal how to do it and use it » tecnoplc
CA TEGORIES
WE WENT ONLINE TO SEE HOW TO CONVERT
CHAR TO STRING.
It seems that we have everything ready and now we have to
transfer the program to the PLC and test how the
conversion is done. Once transferred, we go Online in the
FC where we have the function and we check how the
function has been executed and, consequently, in the
STRING variable we will have all the characters that we have
selected in a single variable. Better see it in the picture.
Likewise, if we now modify the characters in the data DB in
each position of the Array, we will observe how CHAR will
automatically be converted to STRING TIA Portal and we will
check it in the STRING variable of the function output.
https://www.tecnoplc.com/convertir-char-a-string-tia-portal-como-hacerlo-y-utilizarlo/

9/13
5/13/23, 5:29 PM
Convert char to string TIA Portal how to do it and use it » tecnoplc
CA TEGORIES
Finally, I show you how you can force the value of
a variable when you connect Online to the PLC or
you are simulating it. Whenever we make a
change in the program, we need to test those
changes, see how the variables behave when we
put some values ​or others, etc. Therefore, I show
you a very easy way to introduce a value to a
variable without having to enter a table of
variables and force it into the table. Quick and
easy, it will save you time for sure:
Force Online Value of TIA Portal
Variables
|
By the way, if possible, leave me a comment and tell
me what you think about the article: good or bad, if
you think something is missing, if it has helped you,
whatever. In this way, I will be able to improve it and
it will serve us all. I will answer you in less than 24
hours. Thank you so much.
https://www.tecnoplc.com/convertir-char-a-string-tia-portal-como-hacerlo-y-utilizarlo/

10/13
5/13/23, 5:29 PM
Convert char to string TIA Portal how to do it and use it » tecnoplc
Developed and published by www.tecnoplc.com . Creative
Commons 4.0 license.
SHARE:






CA TEGORIES

CLASSIFICATION

FORMER
FOLLOWING 
Mesh Wifi or Wifi Mesh what
it is for and how to use it
Step7 simulator how to
activate PLCSIM and
configure communication
ABOUT THE AUTHOR...
technoplc.com
Programming day by day. Experience in
PLC programming and Siemens HMI.
Specialty in programming TIA Portal,
Step7, LOGO!Soft, MicroWin and WinCC
Flexible. TIA Portal programming projects
for students and companies.
Documenting everything I can.






RELATED POSTS
https://www.tecnoplc.com/convertir-char-a-string-tia-portal-como-hacerlo-y-utilizarlo/



11/13
5/13/23, 5:29 PM
Convert char to string TIA Portal how to do it and use it » tecnoplc
Memory types
in PLC in the
Step 7
software.
TIA Portal PLC
communication
definitive guide
to not fail
WinCC Flexible
connections for
PLC and HMI
communication
01/09/2019
03/04/2021
02/22/2021
SCL insert data
into DB by
incrementing
all positions in
the DB
CA TEGORIES
06/11/2018
LEAVE A REPLY
Your email address will not be published. Mandatory fields are
marked with *
COMENTARIO
NOMBRE *
CORREO ELECTRÓN
WEB
POST COMMENT
This site uses Akismet to reduce spam. Learn how your comment
data is processed .
TECHN OPLC
Legal
Privacy
Data Protection
Cookies
Author
https://www.tecnoplc.com/convertir-char-a-string-tia-portal-como-hacerlo-y-utilizarlo/

12/13
5/13/23, 5:29 PM
Convert char to string TIA Portal how to do it and use it » tecnoplc
N EWSLETTER
CA TEGORIES
Subscribe to the Newsletter and receive the News every week. New articles, new examples to download.
Designed by Elegant Themes | Powered by WordPress




https://www.tecnoplc.com/convertir-char-a-string-tia-portal-como-hacerlo-y-utilizarlo/
13/13
Download