Reading char array from Siemens PLCs and assigning it as a string or char array

I want read char array as a string or as an array of char in ignition. For now I can not do it with 1 line code. I have to do it by reading chars as byte per byte then convert them and come together etc. so it is huge job for me. is there any easy way to do that ?

You could store the values in the plc as String instead of array of char. Then you can read it as a string in Ignition.
Of course this only works, if your data is a readable string and not binary data.

in our standard PLC programs it is set like this way and it is impossible to convert them string. another way is that we can create another value as string but in those time, I need to define it into all our PLCs so it is another work load and I really do not want to do that changes in PLC side. so I think there should be a way to do that with a simple way. in ignition, among all definitions, I can see array types (string array, int array etc.) so there should be a way to read totally an char array from PLC and assign them in ignition. If there is no, it is really hard missing…

That is possible if you are not using the legacy S7 driver that comes with Ignition. That driver is rather outdated and does not fully support modern S7-15x0 plcs or arrays.
Switch to the plc’s embedded OPC-UA server or use a third party server.

@chi is right here as usual :slight_smile:

Ignition’s Siemens driver is a bit limited and dated.

oh no. so thanks to all for helps. at least I can read data byte per byte and use python to cast data to string and use this way.

@Kevin.Herron, Is there any better way of doing this ?
I mean maybe create a UDT with expressions to define number of bytes and it figures out how many tags to create and read ?
I have got one PLC which is all bytes when it comes to string.


UDTs can’t have a dynamic number of tags inside them at runtime, but if you only have one or a few known string lengths you could make one or more “S7_STRING_N” UDTs that have all the byte tags + an expression tag that smashes them all together or something.

Maybe someone else has a better idea. Nothing has changed re: the driver.

1 Like

Since we don’t have the in-built expression function for chr and ord (I saw another post that says its coming out in 8.1.8 but our standard right now is 8.0.17), what is the best way to smash them all together ?

Yikes… not sure, maybe something with runScript? Performance is going to drop off a cliff if you go that route though :frowning:

If you’re connected to a 1500 you’d be better off using its built in OPC UA server.

Wow, running with crazy bad luck today. I’m with S7-300

Here’s what I found as the easiest solution for now,

Create UDT as you mentioned and then create a integer tag to sum all the byte decimal values. Put a tag event script on this tag which evaluates character by python and puts onto another string memory tag.


1 Like