Siemens String Tag

I am replacing an existing iFix4.0 system with a new Ignition 8.1 platform. The existing iFix system has a text (TX) tag with address DB103.DBB 4U and the value of that tag is “Vz”.

I am trying to create a string tag in Ignition to give me the same value. I initially tried the item path [L1_Master]DB103,STRING4.2 and I get the value of “Bu VzVzSmVz BuRmRfRfP1RfBuRfC|C|P1BuP1P6P1P6”.

With a length of 2 I would only expect 2 characters. However, when I change the length to 1 there is no change in the value. Anyone run into this issue? Thanks

Our driver expects strings to be in the S7 string format, which is something like this:

[MaxLen][ActualLen][Remaining Bytes...]

Is the data laid out in that format or is it just a null terminated (or not) character sequence?

Looking into the PLC data block it looks like the structure is actually a word with two ascii characters in hex. The value of the memory address is “567A” which translates to “Vz” in ascii. It looks like I may have to do some conversion on the value to get the text I need.

If there aren’t a bunch of these and the length won’t vary it might be easiest to just pull in the individual bytes/characters and smash them together in an expression tag.

Thanks. I have tried your suggestion. The problem I have now is the values of the individual byte tags are coming in as decimal (ie. 86 and 122). There is no way to convert these values from decimal to ascii text that I can find using an Ignition expression. I’m assuming I need to use a python script at this point. Any suggestions?

Hmm, I feel like I’ve come to the conclusion that we really need some new expressions more than once now: Read byte to ascii characters - #10 by Kevin.Herron

FWIW something like this also works:

runScript("chr("+{[~]C1}+")") + runScript("chr("+{[~]C2}+")") 

where C1 and C2 are tags holding the decimal characters.

Works great! I tried to create my own script and was just going to call the script for each character in an expression tag. The script looks like this

def myfunc(decVal):
valHex = hex(decVal)[2:]
valText = (valHex).decode(‘hex’)
return valText

Then the plan was to use runscript() for each character.

I like your way better. Since I’m dealing with UDTs and parameters it’s a bit cleaner. Runs great and looks like this

runScript(“chr(”+tag("[default]Line “+{Line}+”/Master/MasterTags/Mission/R"+{RNum}+"/TipodData1")+")") + runScript(“chr(”+tag("[default]Line “+{Line}+”/Master/MasterTags/Mission/R"+{RNum}+"/TipodData2")+")")

Also, I agree it would be nice to have a couple of extra expression functions to handle the conversion. Thanks for the help!

You’ll find the new expression functions in the nightlies now and in 8.1.8 when it comes out.