Back to tutorials
Intermediate

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

By
Vladimir Romanov
Table of Contents

Introduction

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.

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.

Conclusion

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.

Video Tutorial

Back to tutorials

Related Tutorials

Intermediate

MicroLogix 1100 RSLogix 500 External IO PLC Programming Tutorial

The MicroLogix 1100 PLC is still heavily used in the industry and is one of the most recommended PLCs for learning PLC programming. The MicroLogix 1100 PLC is compact, offers a variety of I/O configurations and is inexpensive relative to other Rockwell options. Furthermore, the MicroLogix 1100 PLC is programmable using the free version of RSLogix 500 that can be downloaded from the official Rockwell website.

By
Vladimir Romanov
Beginner

PLC Simulator - PLC Programming & Testing within a Simulated Environment

A PLC Simulator is an excellent avenue to practice PLC ladder logic programming. Although the software environment is not the perfect substitute for hands on experience on an actual PLC, the simulation delivers a very accurate representation of ladder logic execution.

By
Vladimir Romanov
Intermediate

HMI Software - Different Tools, Applications and Solutions to Meet Your Needs

HMI Software is commonly referred to as the development application that will be used to create the runtime application for an HMI terminal. It’s important to understand this distinction as we will be going over the HMI development environments used by PLC and HMI programmers to create the screens rather than the end-user applications you will see at the plant level.Numerous HMI programming software solutions are found on the market. Although they aim to achieve the same result, different packages have a distinct advantage over others in terms of price, reliability, ease-of-use and technical capability. It is therefore possible to find the right solution that will fit your specific application if you spend the time to research all options.

By
Vladimir Romanov