Back to tutorials
Intermediate

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

By
Vladimir Romanov
|
May 31, 2019
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

PLC Programming Example Project - Batching Tank Ladder Logic PLC and HMI Tutorial

Generally speaking, there are two types of processes in manufacturing: discrete and analog. A discrete process is a manufacturing methodology that will produce separate widgets. In other words, a production line may output one item, two items, three items, etc. An analog production process is where the plant will create a quantity of product that is quantifiable by weight. Examples include the production of beverages, sauces, raw ingredients, etc. Although it is possible to design a flow that will continuously output the product, such production is often managed in batches. It is important to note that although batches are considered to be analog or continuous flow, most of them end up being packaged for consumption which converts them into a discrete manufacturing process.

September 14, 2020
|
By
Vladimir Romanov
PLC Programming Career

PLC Programming Certification - Complete Guide

You may choose to pursue a traditional college degree, learn through online tutorials, or take a course that will issue a plc programming certification upon completion. However, what is the best option, and what are the best PLC programming certifications?

August 6, 2020
|
By
Vladimir Romanov
Beginner

Opto 22 groov RIO Getting Started

The groov RIO module from Opto 22 has been released only a few months ago. The groov RIO is a feature packed piece of hardware that is easy to install, configure and deploy for many different field applications. The module comes pre-loaded with an array of software tools used across the industry and is ready to hit the floor running out of the box. Furthermore, the module is equipped with user configurable input and output nodes that have the capability unlike anything else on the market.

August 2, 2020
|
By
Vladimir Romanov