0

Converting tag value like Excel could do with HEX2DEC

This is probably not very common and I intend to review further but in case someone has a quick solution......

We have 4 tags that combine together for the style ID. Each tag gives 2 letters of the style. It isn't just a matter of concatenating though. Maybe there is a better way than the calculation the plant currently uses, but right now they have this formula for example in Excel to transform each of the tags into that 2 characters of the style ID (where A11=the tag of the 2 characters in question):

=CONCAT(CHAR(HEX2DEC((LEFT(DEC2HEX(A11),2)))),CHAR(HEX2DEC((RIGHT(DEC2HEX(A11),2)))))

To get the full style ID, they combine 4 tags that they transform:

17999    21069    22351    21067
FO        RM        WO        RK

So, style ID = FORMWORK

There could be a few different points where we do this transformation/conversion such as the below or something else:

1) These tags are coming from Kepware initially. I MIGHT be able to do some processing of them there

2) We pull them into Canary from the Kepware OPC DA "server" via Canary Logger Administrator (maybe "data transform" option but I am not sure)

3) I'm open to using a calculator in Canary for this. I haven't investigated/tried that possibility yet. 

4) Perhaps using the ValueTransform property in Axiom. 

3 replies

null
    • smason
    • 3 yrs ago
    • Reported - view

    Hi James Wise ! I think we can do this in a calculation similarly to how you're doing it in your Excel sheet. We just don't have a concise way of transforming the ASCII code into a character. In order to do that, I am utilizing the Switch() function in my screenshot. The first expression does a bitwise shift to return "70" (46 hex). The second expression uses a bitwise AND to return "79" (4F hex). Once we have those, we use the Switch function to match the decimal value to the appropriate character. I didn't list all of the letters out, and maybe you don't need them all, but you can see how you could. The final expression concatenates the string together.

    I hard-coded 17999 as an example, but you would want to use the actual tag name in place of 17999. Hope this will work for you. 

    • wise_james
    • 3 yrs ago
    • Reported - view

    Steve - Thank you so much! This was a huge help and got me what I needed.

      • smason
      • 3 yrs ago
      • Reported - view

      You're welcome James Wise ! Glad we could help.

Content aside

print this pagePrint this page
  • Status Answered
  • 3 yrs agoLast active
  • 3Replies
  • 82Views
  • 2 Following