Using String as a Tag Siemens PLC

Jacenty

Member
Join Date
May 2018
Location
Wroclaw
Posts
6
Hi to all,
I have a quick ask. Is it possible to use a String as a PLC Tag?
At input of FB I want to put a String. Lets say the value will be "Test". In system constants there are tags with name "Test_1", "Test_2" etc. So is it possible to read this tags in FB using the input string?
PLC -> Siemens S7-1200/1500
Thanks in advance.
 
Yes you can setup an FB input as a string.

Not sure what are the system constants you mention. Maybe you mean hardware identifiers. These are of type HW_IO, and the names you see are the symbols for these hardware identifiers.

Without knowing what you want to achieve I cannot say what type the FB input should be.
 
So I meant to use the string input as identifier to read the hardware identifiers.
For example:
At string input of FB I put "Test". In system constans I have a hardware identifier which name is "Test" and his value is for example 250.
Now the main part. I want to use string with value "Test" to read the value 250 from hardware identifier. Is there any way to achieve this?
 
Am I to understand that the string is not specified in code, but comes from somewhere else, like an HMI input ?

If you just want to specify the string in code, it makes no sense to attempt convert to a STRING that contains the symbolic name to the hardware identifier because that is what the compiler does for you automatically.

What do you want to achieve ?
 
I have a device with I am communicating by profinet. This device has a lot of submodule which I have to read and putting this profinet addresses at input of FB. It can be really annoying. In fact it is really easy to change one address in PLC addresses (or add some new one), and then all addresses at inputs have to be also changed.
But I saw that in HW identifier the names have some scheme. At the beginning of each name of submodule there is a name of this device.
So that what I want to achieve is change all this integer inputs at FB to one string input, and with this string read all this hardware identifier, that have a similar name to input string.
I hope I have made it clear.
 
You can definitely pass strings around a PLC.

I am not aware of any way to dynamically read a different tag value based on the tag name stored in the text in a string.

However, if you just type the name of the HW identifier you want ("IOdevice7.head" or whatever) at the HW_IO input, the PLC compiler will automatically translate that into the corresponding number. This concept is called a constant; for programming purposes it is a read-only tag, but it is actually substituted when you compile.
 
Isn't what you describe a kind of glorified absolute addressing ? Yuck !

In TIA, you can define inputs and outputs as structures of data types. You simply sepcify only the 1st address (i.e. I202.0 and all the other addresses are then assumed to follw the structure in the data type i.e. I202.0, I202.1, I202.2, IW204, IW206 etc.).
And these same data types can be places on for example the in/out pins on FBs. So in this way you can easily change a complete input or output structure in one go. In stead of editing the PLC tags or the FBs, you simply change the data type and all the data and code that uses the data type is automatically updated.
I have never used this feature myself, but it does sound as the solution you are looking for.
 
Last edited:
I know this method with structure, but unfortunately it isnt solving my problem. I think I have to figure out something else or at least leave it as it looks now.
Thank you for help and advices!
 
I know this method with structure, but unfortunately it isnt solving my problem. I think I have to figure out something else or at least leave it as it looks now.
Thank you for help and advices!

I'm still a bit confused on what you're trying to do and why this doesn't help, but good luck!
 
Because the same effect I can achieve with POKE_BOOL/WORD/etc. using only offset. I did it first. But if in some other project I will use this function, and the Profinet addresses will be not continuos after insert the device, then it generates a problem, because it requires changing all addresses. Thats why it doesnt help me at all.
 
Have you looked into RD_REC and WR_REC. With these you can achieve what you wish, creating a fully dynamic FB with dynamic configuration possibility for connected devices. With this you shouldn't care about absolute addresses, you just need to make sure the order is correct.
 

Similar Topics

Long story short, I am creating a display to display an array of Strings from PLC [topic]VarStrA_RPHD.Desc[VarStrB] totally 100 strings...
Replies
1
Views
1,399
Hi all, I have a customer that is asking for a recipe of 200 recipes to be sorted. I'm trying to do this by way of a bubble sort. Basically my...
Replies
18
Views
3,458
FactoryTalk ME- Using a"String Input Enable" for Password Entry.How can I place X's Good Morning , FactoryTalk View ME ...... I'm...
Replies
2
Views
2,662
So, I am a beginner-slightly intermediate level programmer, and I am looking for a way to access specific data, and pull it out of a larger...
Replies
11
Views
3,409
Hello guys, i want to use string data type in plc m221 by Schneider electric. to transmit data from software scada expert vijeo citect to plc...
Replies
0
Views
2,434
Back
Top Bottom