I’m trying parse ascii from a decimal value into some form I can display (I have accomplished this by using “lookup” and adding all the characters together in a label),and archive for our operations team.
I can’t find a built in function to do this. It looks like there is a function in version 8, but I don’t know when we will be upgrading.
The data resides in Hex in a Siemens 400 PLC data block. The data is a recipe number (8 bytes) and a recipe name (16 bytes).
I have a Power Table with the decimal to ASCII equivalents. My thought is to use the tag value (for each byte), comparing the value from the tag to the table (using lookup) and return the ASCII character. Add the characters to form a string in a tag that can be archived. I’m struggling with getting the 8/16 ASCII characters into a tag that can be archived as a string.
Example: Recipe # = 50
Datablock hex value =3500 (bytes 1 and 2)
Recipe name = Test
Datablock hex value =5465 7374 (bytes 1 thru 4)
Sorry, #3530h = ASCII 50
Q1, Label has expression binding using “lookup” to add all the characters together. The task of getting that String of characters into a tag I can archive is what I am looking for help with. I don’t know the path to script that function whatever that solution is.
Q2, the data in the PLC is at the base hex. Ignition can read the data byte as decimal in a tag configured as an Integer or byte. Right now the hex vale is 53h, Ignition tag displays this as 83d, label dispalys the "lookup from my table as “S”.
Is there any chance you could modify the PLC to include the standard string type header before these registers? (One byte maximun string length, one byte current string length.) Then you could use the standard string type.
My scripting ability is limited. I’m not sure understand what defines the “struct” as it relates to the Power Table or the tags I have reading each of the hex values in the PLC.
It’s been a while and I don’t actually remember but I don’t think that project scripts are available in tags, you would need it to be in a gateway shared script.
In the expression you showed you were sending the path to the tag and not the value of the tag.
If you’re going to need this enough then perhaps putting it in a gateway script is a good idea.
I would probably use an expression binding on the label.
I’m going to try to put a screenshot in here to show what I have so far. Maybe make more sense.
I have labels populated with the ASCII characters. What I want to do (if possible) is to place that ASCII string into a tag, as a string, so I can archive it in a tag. All the tags I’m using from the PLC are shown. One tag for reference for configuration.