# Reading ControlLogix Strings

**URL:** <https://forum.inductiveautomation.com/t/reading-controllogix-strings/26273>\
**Category:** Ignition\
**Created:** [July 3, 2019, 5:29pm UTC](https://forum.inductiveautomation.com/t/reading-controllogix-strings/26273 "2019-07-03T17:29:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paullys50](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paullys50/32/3324_2.png) [@Paullys50](https://forum.inductiveautomation.com/u/Paullys50)\
**Post date:** [July 3, 2019, 5:29pm UTC](https://forum.inductiveautomation.com/t/reading-controllogix-strings/26273/1 "2019-07-03T17:29:04Z")

</div>

Using Ignition 8 and RSEmulate v32 for some testing. Trying to get a string tag from my PLC program into Ignition. When using OPC browser I’ll get StringTag.DATA, StringTag.LEN and can pull those into Ignition, however .DATA is just the array of ASCII character codes. I want the Ignition tag to display the string text. How do I configure the tag?

Previously, I could point to StringTag.STRING and Ignition put it all together, but that was Ignition 7 with the legacy ControlLogix driver.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 3, 2019, 5:33pm UTC](https://forum.inductiveautomation.com/t/reading-controllogix-strings/26273/2 "2019-07-03T17:33:05Z")

</div>

You have an OPC(UA?) connection to it or are you using one of the drivers?

---

<div class="post-metadata">

**Author:** ![Paullys50](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paullys50/32/3324_2.png) [@Paullys50](https://forum.inductiveautomation.com/u/Paullys50)\
**Post date:** [July 3, 2019, 5:39pm UTC](https://forum.inductiveautomation.com/t/reading-controllogix-strings/26273/3 "2019-07-03T17:39:43Z")

</div>

OPC-Com through RSLinx Gateway since I’m testing with RSEmulate

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 3, 2019, 5:45pm UTC](https://forum.inductiveautomation.com/t/reading-controllogix-strings/26273/4 "2019-07-03T17:45:42Z")

</div>

Okay, nothing you can do on the Ignition side then. The server is choosing to show you a folder containing a LEN and DATA tag.

I don’t think you’re the first person to run into this issue/bug, but it’s not on our side.

edit: you might be able to reassemble then DATA bytes into a string using a runScript expression and some Jython trickery, though.

---

<div class="post-metadata">

**Author:** ![Paullys50](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paullys50/32/3324_2.png) [@Paullys50](https://forum.inductiveautomation.com/u/Paullys50)\
**Post date:** [July 3, 2019, 5:49pm UTC](https://forum.inductiveautomation.com/t/reading-controllogix-strings/26273/5 "2019-07-03T17:49:17Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![Paullys50](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paullys50/32/3324_2.png) [@Paullys50](https://forum.inductiveautomation.com/u/Paullys50)\
**Post date:** [July 3, 2019, 6:21pm UTC](https://forum.inductiveautomation.com/t/reading-controllogix-strings/26273/6 "2019-07-03T18:21:05Z")

</div>

FYI for future readers, I just created a tag to store an ASCII Lookup table, then used an expression to create the string I required.

```auto
# Create the tag "ASII Lookup", and run this script once to build the lookup table.

header = ['code','char']
data = []

for i in range(128):
	string_value = chr(i)
	data.append([i, string_value])
	
newDS = system.dataset.toDataSet(header, data)

# Write to ascii lookup tag
system.tag.write('[default]PLC/ASCII Lookup', newDS)

```

Then create an expression tag “sourceUUID”. For my purposes, I’m reading a 36 character UUID from the PLC, so my tag has the following expression to get the character from the DATA element and concatenate the result. This is all I need for my RSEmulate test environment.

```auto
concat(
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_0_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_1_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_2_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_3_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_4_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_5_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_6_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_7_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_8_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_9_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_10_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_11_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_12_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_13_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_14_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_15_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_16_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_17_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_18_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_19_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_20_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_21_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_22_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_23_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_24_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_25_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_26_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_27_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_28_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_29_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_30_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_31_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_32_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_33_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_34_},'',0,1),
lookup({[.]../../ASCII Lookup},{[.]DATA/sourceUUID_DATA_35_},'',0,1)
)

```

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [July 4, 2019, 3:22am UTC](https://forum.inductiveautomation.com/t/reading-controllogix-strings/26273/7 "2019-07-04T03:22:09Z")

</div>

You could also do the following, assuming you are bringing the data back as a list:  
In a shared script somewhere (I put it in my shared script project, in a script called “ascii”):

```auto
def asciiToString(asciiList):
	return "".join([chr(o) for o in asciiList])
	
def stringToAsciiList(value):
	return [ord(o) for o in value]

```

Now in an expression tag, put the following:

```auto
runScript("ascii.asciiToString",0,{[~]ascii data})

```

You could also use a derived tag, to get read and write capabilities  
For the read expression:

```auto
runScript("ascii.asciiToString",0,{source})

```

For the write expression,

```auto
runScript("ascii.stringToAsciiList",0,{value})

```

This script will run whenever the ascii data tag changes.

---

<div class="post-metadata">

**Author:** ![kevin.sinclair](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kevin.sinclair](https://forum.inductiveautomation.com/u/kevin.sinclair)\
**Post date:** [October 8, 2019, 2:29am UTC](https://forum.inductiveautomation.com/t/reading-controllogix-strings/26273/8 "2019-10-08T02:29:18Z")

</div>

To access the string version of the tag you simply remove the dot and anything that follows it.

---

<div class="post-metadata">

**Author:** ![Paullys50](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paullys50/32/3324_2.png) [@Paullys50](https://forum.inductiveautomation.com/u/Paullys50)\
**Post date:** [October 8, 2019, 3:01am UTC](https://forum.inductiveautomation.com/t/reading-controllogix-strings/26273/9 "2019-10-08T03:01:58Z")

</div>

> [@kevin.sinclair](#):
>
> To access the string version of the tag you simply remove the dot and anything that follows it.

> [@Paullys50](#):
>
> RSEmulate v32

It's different.
