How would I get Last_Fault_Code?

I have an integer faults tag:

image

I used getBit against the integer tag:

image

I seen a template that had LastFaultCode on there and I think that would be very useful. Does anyone have an idea of how to go about this or a resource they can point me to?

Hello,

You could use a tag change script on the fault code, reference the previousValue and store it in another tag.

Frank

I think the reason I am having a hard time wrapping my head around this is because my integer fault tag accumulates. To get the last fault code, would I have to take the previousValue tag you helped guide me on making and subtract from my integer Fault tag to get the real last fault?

I did get the previousValue tag working from your suggestion so thank you for helping me with that.

So when your fault code changes is the difference between old and new values the fault code number? Also eventually this number will overflow and roll over, you will have to account for this as well.

Frank