Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Captcha Click on image to update the captcha .

Login

Register Now

register content

Create Controller Fault Routine

Check for a Specific Fault

In this article,  we will learn how to clear fault on Allen Bradley PLCs.  Which is the continuation of our previous article. We will examine the automatic cleaning of the fault types that we have determined specifically, and error notifications at prescan time.
You can find our previous article at the link below.

PLC Controller Fault Routine

Let’s continue with an example on Control Logix PLC with Studio 5000.

plc programming clear major fault plc

1. The first EQU instruction checks for a specific type of fault, such as program, Input/Output In Source B, enter the value for the type of fault that you want to clear.

2. The second EQU instruction checks for a specific fault code. In Source B, enter the value for the code that you want to clear.

3. The first CLR instruction sets to zero the value of the fault type in the Major_Fault_Record tag.

Clear Fault

plc programming SSV instruction plc

1. The SSV instruction writes new values to system attribute of this program.

2. The SSV instruction writes the values contained in the Major_Fault_Record tag. Since the Type and Code members are set to zero, the fault clears and the controller resumes execution.

Clear a Major Fault During Prescan

If the controller faults immediately after you switch it to the Run mode, then examine the prescan operation for the fault. Depending on the revision of your controller, an array subscript that is beyond the range of the array (out of range) during prescan may or may not produce a fault:

If your controller is revision:

11.x or earlier: During prescan, an array subscript that is beyond the range of the array (out of range) produces a major fault.
13.0 or later: During prescan, the controller automatically clears any faults due to an array subscript that is beyond the range of the array (out of range).

To clear a major fault that occurs during prescan:

  • Identify When the Controller is in Prescan
  • Get the Fault Type and Code
  • Check for a Specific Fault
  • Clear the Fault

It is a good programming practice to check for a specific fault before clearing the fault.

Identify When the Controller is in Prescan

 In the main routine of your program, enter this rung as the first rung in the main routine of the program:

plc programming CPU Scan Tag plc

The fault routine of this program uses the status of this bit to determine if the fault occurred during prescan or normal scan of the logic:

  • During prescan, this bit is off. (During prescan, the controller resets all bits that are referenced by OTE )
  • Once the controller begins to execute the logic, the CPU_scanning bit is always

Check for a Specific Fault

Let’s add the codes of the error we want to catch to this routine we created earlier. We previously explained what the Type: 4 Code: 20 fault is. You can find it in our previous article.

 Enter this rung in the fault routine for the program:

plc programming PLCMajor Faults plc

 

1. During prescan the bits of all OTE instructions are off and this instruction is true. Once the controller begins to execute the logic, this instruction is always false.

2. The first EQU instruction checks for a fault of type 4, which means that instruction in this program caused the fault.

3. The second EQU instruction checks for a fault of code 20, which means that either an array subscript is too large, or a POS or LEN value of a CONTROL structure is invalid.

4. The first CLR instruction sets to zero the value of the fault type in the Major_Fault_Record tag.

5. The second CLR instruction sets to zero the value of the fault code in the Major_Fault_Record tag.

Clear the Fault

Now let’s put the CPU_Scanning tag in front of the SSV command we created earlier.

 Enter this rung in the fault routine for the program:

plc programming Fault Ladder plc

1. During prescan the bits of all OTE instructions are off and this instruction is true. Once the controller begins to execute the logic, this instruction is always false.

2. The SSV instruction writes new values to the system attribute of this program.

3. The SSV instruction writes the values contained in the Major_Fault_Record tag. Since the Type and Code members are set to zero, the fault clears and the controller resumes execution.

Test a Fault Routine

You can use a JSR instruction to test the fault routine of a program without creating an error (i.e., simulate a fault):

1. Create a BOOL tag that you will use to initiate the fault.

2. In the main routine or a subroutine of the program, enter this rung:

Create Fault routine in MainProgram.

plc programming gotofault plc

Jump_to_Fault : Tag that you will use to initiate the fault

Add to JSR instruction for CreateFault routine.

plc programming Create Fault jsr plc

After writing your codes to the plc as in the picture, when you toggle the Jump_to_Fault tag, your PLC will fall into a major error.

plc programming PLC Fault plc

plc programming plc Major fault plc

Create a User-Defined Major Fault

If you want to suspend (shut down) the controller based on conditions in your application, create a user-defined major fault. With a user-defined major fault:
• The fault type = 4.
• You define a value for the fault code. Choose a value between 990 to 999. These codes are reserved for user-defined faults.
• The controller handles the fault the same as other major faults:
– The controller changes to the faulted mode (major fault) and stops executing the logic.
– Outputs are set to their configured state or value for faulted mode.

To create a user-defined major fault:

  • Create a Fault Routine for the Program
  • Configure the Program to Use the Fault Routine
  • Jump to the Fault Routine

Create a Fault Routine for the Program

if your answer is No,

  1. In the controller organizer, right-click the program and choose New Routine.
  2. In the name box, type a name for the fault routine.
  3. From the Type drop-down list, choose Ladder.
  4. Click OK.

Configure the Program to Use the Fault Routine

1. In the controller organizer, right-click the program and choose New Routine.

2. Select the Configuration tab.

3. From the Fault drop-down list, choose the fault routine.

4. Click OK.

plc programming plc Fault conditions plc

If the input parameter is not visible in the JSR command, you can right-click the command and add input with the Add Input Parameter option.

plc programming JSR add input par plc

FaultRoutine: name of the fault routine for the program
999: value for the fault code

As a result, when the error conditions you want are met, you can generate a code 999 error as follows.
plc programming Code999 UDT fault 1 plc

To see the fault and clear fault,  you can use the Clear Major button to clear the PLC error. plc programming Gotofaults plc