Cookies are important for this site to function properly, to guarantee your safety, and to provide you with the best experience. By clicking OK, you accept all cookies. For more information, please access our Privacy Policy.
Table of Contents
Tutorials / 
PLC Fault Finding | FOR Loop PLC Fault Diagnosis Troubleshooting in RSLogix 5000 Allen Bradley

PLC Fault Finding | FOR Loop PLC Fault Diagnosis Troubleshooting in RSLogix 5000 Allen Bradley

Allen Bradley
PLC Troubleshooting
Ladder Logic
RSLogix 5000
Studio 5000
Distributed I/O
Point IO


Knowing how to deal with PLC faults within an industrial environment is an invaluable skill. Although it’s not encouraged to introduce conditions which may result in faults, this is something which can be practiced and observed within a test environment.

There are many ways to fault out a PLC, but they are generally extremely reliable and operate without a problem. However, poor programming may cause a PLC to enter an undesired state which brings the entire system down and bring manufacturing to a halt. We will be exploring one of these conditions which are created by calling an element within an array which is undefined. We cover additional faults in Allen Bradley PLC Training tutorials from the main page.

Do note that the fault which we will be creating is common to other languages & isn’t something which you should expect only on a PLC. There are many ways to create this scenario, but we did want to demonstrate the flaw within the FOR Loop instruction especially due to the fact that this has occurred within our organization recently.

Building a FOR Loop Instruction in Ladder Logic

The FOR loop is an extremely useful instruction. It allows the user to cycle through multiple iterations of a program with a single rung. We often use it in our alarm & fault arrays as well as tag definitions & aliasing.

Here’s an implementation of the FOR loop instruction which will cycle from 0 to 30 with a step size of 1 through the routine “_06_FORloop”.

PLC Fault Finding | FOR Loop PLC Fault Diagnosis Troubleshooting in Studio 5000 Allen Bradley

The index variable is particularly important to pay attention to. Note that this PLC scoped tag will change with every iteration of the loop starting from 0 and going up to 30.

Undersizing a PLC Scoped Array for the FOR Loop

As mentioned above, the FOR loop has been specified with a terminal value of 30. This means that the instruction will continue executing until the “index” register has been set to the value 30. However, if from within the routine called by the FOR loop, we were to create a call which would reference an array without an element at this position, the Programmable Logic Controller would fault out. Here’s what this implementation looks like:

PLC Fault Finding | FOR Loop PLC Fault Diagnosis Troubleshooting in RSLogix 5000 Rockwell

Note that the Data, as well as the Data2 arrays, have been specified as arrays of 20 integers each. In other words, the tags are declared as INT[20] as their data type.

Studio 5000 PLC Fault

As soon as we compile the implementation described above, the PLC will enter a Faulted State. At this point, the logic will cease to execute, the PLC will display a flashing red status and will be waiting for an intervention from the program before moving forward. This state will be primarily indicated by the top left status bar in RSLogix / Studio 5000.

PLC Fault Finding | FOR Loop PLC Fault Diagnosis Troubleshooting in RSLogix 5000 Allen Bradley

In this state, you may choose to attempt a PLC reset. The PLC will enter into a “Program” state. However, as soon as you change it back to “Run”, the same logic will execute and fault out the PLC once again. The only solution is to fix the problem we’ve created in the software. You may either change the index range within the FOR loop or increase the size of the array which is being called by this variable.

Troubleshooting a PLC Fault in RSLogix

Once the PLC is faulted, it’s possible to get more information about the nature of the fault. By entering the PLC menu, the user will be able to navigate into the “Major Faults” and “Minor Faults” tabs which will list all the current faults on the controller. As mentioned previously, we’ve caused a major fault & thus it will be listed within the “Major Faults” tab.

The description of the fault will generally indicate the area of the program where the fault happened, the nature of the fault, as well as the date and time of it, ‘s last occurrence.

PLC Fault Finding | FOR Loop PLC Fault Diagnosis Troubleshooting in RSLogix 5000 Allen Bradley

The user may press the “Clear Majors” button in order to reset the fault.


Faulting a PLC isn’t an easy task. However, encountering a fault can be a very frustrating experience. The PLC will completely shut down the process, interrupt all the inputs & outputs as well as stop the execution of any logic which was executed. Although this scenario isn’t something any of us want to experience in a production environment, it’s important to acknowledge that it may occur and prepare for it by simulating it within a test environment.

A simple way to fault a CompactLogix PLC is to create a call which will reference a register outside of the bounds of an array. This will not happen likely in a normal situation, but can easily occur through a FOR instruction. In fact, the FOR instruction implementation doesn’t have an inherent way to prevent such a fault.

The first step in dealing with such a fault is to get more information by viewing the faults tabs of the PLC. This menu can be accessed by clicking the top menu item on the left-hand side in RSLogix or Studio Designer & navigating to the fault tabs. Once there, the user will be shown the faults, when they occurred, where they occurred & for what reason they occurred.

Once the issue is fixed, the PLC can be reset & put back into a “Run” state.