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. 

3replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • 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. 

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

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

      Like 1
print this pagePrint this page
Like Follow
  • Status Answered
  • 2 yrs agoLast active
  • 3Replies
  • 64Views
  • 2 Following