ControlLogix Integer To Hexadecimal String

I was recently involved in a project that required me to convert a ControlLogix integer to hexadecimal string. The rationale behind a hexadecimal string representation was so it could be written as a hexadecimal fault code that correlated with the fault codes in the Rockwell user manual for the instruction(s) I was using.

The specific application involved the implementation of press safety “Metal Form” instructions to control a full-revolution mechanical press. If you have any experience using these “press control” instructions in a GuardLogix safety controller, then you are well aware of the fault code format in the Rockwell user documentation, namely hexadecimal.

To be honest, I thought to myself, no problem…I’ll simply convert the Radix of the integer fault and diagnostic codes being read back from the various press motion instructions, and then write that hexadecimal fault code to the HMI along with a descriptive message. This way if maintenance personnel needed additional information they could reference the fault code in the Rockwell user manual. As it turns out this would not be that simple…

The Problem With What I’m Suggesting

The problem is that irregardless of the format of the number represented in the controller, when written to a Panelview Plus HMI it will always be expressed as an integer number.  I learned this the hard way, and perhaps someone out there knows a way to change this.

Obviously that wasn’t acceptable. I needed to figure out a way to express the fault and diagnostic codes being annunciated from the various safety metal forming instructions in hexadecimal format. It was important because annunciating a decimal number would be meaningless to maintenance staff.

Below is a snapshot from the Rockwell GuardLogix Safety Instruction Reference Manual. You can see in the image below that this is a snippet of the CPM (Crankshaft Position Monitor) instruction fault and diagnostic codes.

ControlLogix integer to hexadecimal string

Annunciating a fault code of 4103 (DEC) would not be overly meaningful to the operator or maintenance personnel when the actual fault code in the user manual is 1007 (HEX). Sure, you’re probably thinking they could simply do the conversion themselves, however, the whole point is to mitigate downtime, and this would be an extra step and perhaps an insurmountable one for those operators and maintenance personnel who are not math savvy.

ControlLogix Integer To Hexadecimal String

So now the issue I’m confronted with is how to take an integer value, convert it to a hexadecimal value and then take that hexadecimal value and convert it to a string. Not an impossible task, however, this seemed to be a perfect fit for a ControlLogix Addon Instruction (AOI).

Now there were probably a couple of different ways to tackle this problem, but what I decided to do was pass in the integer value to the “IntToHexString_AOI” and continue to parse that value using a BTD (Bit Field Distribute) Instruction natively available in the controller.

Once I have the the integer values parsed out into their respective “Nibbles”, four characters in length, I can proceed to build the hexadecimal string. Check out the image below of the ControlLogix integer to hexadecimal string in an actual production environment.

ControlLogix integer to hexadecimal string

You can see very clearly that the ControlLogix Integer to Hexadecimal String AOI will accept any 16-bit integer value and convert that value into a 4 character hexadecimal string. At the time this image was taken the integer value being passed into the instruction is 32, and you can see clearly the hexadecimal output is ‘0020’ which is precisely the hexadecimal equivalent of 32 decimal.

Watch The YouTube Video Now

In this YouTube video I walk you through all the steps needed to import and use the ControlLogix Integer to Hexadecimal String AOI instruction.

Exclusive Offer!

I am making this ControlLogix Integer to Hexadecimal String AOI instruction available for download over in our Digital Downloads Store. Get it today!

Conclusion

I hope you enjoyed this short article, and I do encourage you to become a member of our growing community of professional engineers, technicians and technologists, Register Here!

Also, check out our YouTube Channel to see some great videos…and don’t forget to like and subscribe to our channel!

If you enjoyed this article be sure to check out some of these good reads too:

Lastly, if you run  into any problems in your day-to-day engineering activities please be sure to check out our Live and Interactive PLC Forum!

And if you so desire, assist other community members by replying or offering helpful information to the questions or challenges they may be facing right now!

 

Fred Graham

Author: Fred Graham

Hi, Fred here, I am the founding member and site moderator here at PLCGurus.NET. I’d like to be the first to welcome you to the site. I have over 20 years in the Industrial Automation and Control Systems field. Be sure to Register Today!

This site uses Akismet to reduce spam. Learn how your comment data is processed.