All about Add-On Instructions


Add-on instructions are generally a small, tested, pocket of code that the user wants to reuse multiple times in program(s). This tutorial will go into best practices of add-on instructions, how the add-on instructions work, and it will go through creating a custom add-on instruction.

Best Practices

There are some best practices for add-on instructions, which are listed below.

Testing: Add-on instructions cannot be changed online so make sure whatever instruction the program is using is tested and will work in a production environment. Again, add-on instructions cannot be changed online.

Single Level: It is good practice to write only a single level of add-on instructions, meaning that you should not have add-on instructions within add-on instructions, even though it is possible.

Naming: It is good practice to name add-on instructions with a consistent prefix. For example, “ao_IO_DigitalOutput” would be an add-on instruction for a digital output. When add-on instructions have a consistent prefix, it is easy to distinguish them against other data types. For example, there also might be a User Defined Datatype (UDT) named “IO_DigitalOutput”.

Building your First Add-on Instruction – Digital Output

Creating New Add-On Instruction
Figure 1: Creating New Add-On Instruction

To add a new add-on instruction into the program, right click on the add-on instruction in the project explorer, and click “New Add-On”. A popup will come up asking to specify the name of the add-on instruction. For this tutorial, it will be named “ao_IO_DigitalOutput”.

After the name is specified, click ok, then the “Add-On Instruction Definition” window will come up as seen in Figure 2 below.

Add-On Instruction Definition Window
Figure 2: Add-On Instruction Definition Window

General Tab

This holds a lot of “metadata” for the add-on instruction like name and description. The add-on instruction can also be configured for a different type of program, for example, a function block diagram. There is also revision information for the add-on instructions.

Parameters Tab

The parameter tab is the most important window when creating an add-on instruction. In this window, the input and output values are created for the add-on instruction. In Figure 3 below, “EnableIn” and “EnableOut” tag were already in there, and the other parameters were created.

Parameters Tab
Figure 3: Parameters Tab

Each of the parameters will be an attribute inside of the add-on instruction data structure. Each instance of the add-on instruction will have the exact same data structure. To inspect the columns of the parameters:

Name – The name of the parameter

Data Type – The data type for the parameter. Depending on what the usage is, the types will be limited. Input and output parameters have to be basic data types. InOut parameters can be virtually any valid data type.

Alias For – This is for specifying an alias for the parameter. The alias has to be a local tag within the add-on instruction. Local tags will be discussed later.

Default – This is for specifying a default value that will be set for each instance creation. This is especially useful if you have a lot of instances. If a parameter is usually “10” other than a couple of instances, the user can specify the default and only change the instances that are unlike the rest. It is not very useful if the parameter is required because the user will have to supply a tag other than a constant value.

Style – The style that the user wants this data in.

Required (Req) – If checked, a tag is required to specify this parameter in each instance. If not checked, the tag will be a constant value in the instance. If a parameter is not required, the user can still access the tag in preceding or succeeding logic. Basically, the unrequired parameter is still inside the instance data structure so it can be read or written at any point in the logic.

Visible (Vis) – If checked, the parameter will be visible in the add-on instruction block. If left unchecked, it will be hidden. If the user doesn’t absolutely need the parameter to be visible in the add-on instruction, it is best practice to have it invisible (unchecked). If a parameter is an output parameter and is a Boolean type, the parameter will show up as a little output flag next to the add-on instruction instance.

Description – The description of the parameter. These descriptions as visible inside the add-on instruction logic. It is very good practice to put text in for descriptions unless the tag name is all that is needed to describe the parameter; it rarely is.

External Access – This is almost always set automatically through the set of other attributes of the parameter. Selection options are Read Only and Read / Write.

Usage – There are three types of usage parameters: input, output, and InOut

Input – Must be basic data types (BOOL, INT, or DINT). Input parameters can be read-only or read/write and they can be accessed from the outside of each instruction instance. Input parameters are how the rest of the program interacts with the instances of the add-on instructions.

Output – Must be basic data types (BOOL, INT, or DINT). Output parameters are Read Only. They can be accessed outside the add-on instruction but can only be written inside of the add-on instruction. Output parameters are usually what the add-on instruction is calculating, or logically controlling.

InOut -These are tag references ONLY. They are required to be required meaning an external tag must be referenced for these parameters. They can be of any valid data type. They can be read and written only internally in the add-on instruction. The InOut parameters do not show up within the add-on instruction instance data structure. This is an important concept to grasp because most people do not use this usage type correctly.

For our first add-on instruction, create the add-on instruction as shown in figure 3.

Local Tags Tab

Local Tags Tab
Figure 4: Local Tags Tab

The local tags tab as seen in Figure 4 is to specify local tags for the add-on instruction, and they can be of any valid data type. These tags are only available to be accessed inside the add-on instruction logic. These local tags are great for temporary data registers the add-on needs to complete the logic. For example, if an add-on instruction needs a one-shot instruction, which would be a great local tag application.

For our first add-on instruction, we will just be using the input and output parameters in our logic, so no need for local tags this time.

Scan Modes Tab
Figure 5: Scan Modes Tab

Figure 5 above shows the Scan Modes tab, and there are three “modes” that each add-on instance can be in. Each mode can have a separate routine and has access to all the local tags and parameters inside the add-on instruction. The prescan and post-scan routines are outside the scope of this tutorial and are rarely used. The EnableInFalse routines are commonly used when the add-on instruction instance has logic in front of it. This is because the some of the data may need to be cleared when the logic in front of the instruction yields false.

For our instruction, we will not have any of these supplemental mode routines.

Signature Tab

Signature Tab
Figure 6: Signature Tab

This tab is used to generate a signature for the add-on instruction. The ID is a checksum of the entire instruction, so if anything changes down the road the id will change with it. It also keeps a signature history of the add-on instruction for additional revision control.

Change History Tab

This simply tracks the changes detected in the add-on instruction. No picture needed.

Help Tab

Help Tab
Figure 7: Help Tab

In the help tab seen above in Figure 7, the user can specify additional text to help his or her predecessors. The help file will be visible if the instruction is highlighted in the program and the user presses the F1 key.

Add on Routine

Add-On Routine
Figure 8: Add-On Routine

This is a simple but useful routine. When the automatic command comes in if the output is not in manual override by the force bits, the output will come on. When the force INT is a value of 1, the output is forced off, and when the output is 2 the output is forced on.

If you’re following along with your first add-on instruction, make sure your logic looks like the one seen in Figure 8.


Instances of the New Add-On Instruction
Figure 9: Instances of the New Add-On Instruction

Seen in Figure 9 above, in the main routine, two instances of the new add-on instruction were created. As seen in the figure, Output1. Cmd is True and the add-on instruction Output parameter is also True. If the force parameter is changed from zero to 1, Output1.output is off, and so on. It is working exactly as expected.

Instance troubleshooting

To see what is happening inside the add-on instruction. Highlight the instruction, right click on it, and click “Open Instruction Logic” as seen in Figure 10 below.

 Instance Viewing
Figure 10: Instance Viewing

Once that is clicked the user is taken inside of the instance and the user can view what is taking place. The background is gray meaning that the user cannot edit the rungs online as seen in figure 11 below.

Instance Viewing Logic
Figure 11: Instance Viewing Logic


Hopefully, this gives you a nice jump on creating some of your own add-on instructions and see the value and power in reusable code. I encourage you to start small and build small building blocks – eventually, they will turn into a beautiful “house” of code. Make sure you test along the way.


Differences Between PLC Programming Languages

There are a few different methods of programming for a Control Logix processor, listed here in the order of most common to least common:

  • Ladder Logic (Most common, Preferred)
  • Function Block Diagram
  • Sequential Function Charts
  • Structured Text

In this tutorial, I will go over the different methods and describe how they work. Hopefully, the differences between programming methods will be clear.

First Things First

Each method has its own instruction set. Some are very similar between methods but some instructions are only available in one method versus the other. For example, the PIDE instruction, which is called “Enhanced PID” is only available inside the function block diagram method.

In a Control Logix PLC, combinations CAN be used in conjunction with each other. The different routines can access the same tags regardless of method, meaning that a function block diagram can access the same tags as a ladder routine. It is good practice to use one method of programming, but if a different instruction is only available in the other method and it needs to be used it is possible to have two or three methods.


For this tutorial, a routine was created in each method that does the exact same thing. The routine takes in a “Trigger” tag and outputs a “Output” tag. The “Output” tag turns on for ten seconds, then off for ten seconds, then repeats until the “Trigger” tag it cleared.


Ladder Logic
Figure 1: Ladder Logic

With ladder logic, you place different instructions on what are called “rungs”. Each rung has input instructions and output instructions. The input instructions are on the left and the output instructions are on the right. It simulates a “circuit”, with the left side being the power rail and the right side being the common rail. If the simulated “power” gets through the input instructions, it executes the output instructions. These routines are scanned from top to bottom, left to right. To elaborate, rung 1 will complete in entirety before rung 2 input instructions are evaluated.

In the case of the example above, the input instructions are normally open (XIC) and normally closed contacts (XIO). XIC and XIO are the formal names of the instructions. The output instructions are TON and OTE instructions. The TON is a “Timer On Delay” instruction and the OTE is an “Output Energize” instruction. As described above, when the trigger tag (LAD_TRIGGER in this case), the output will come on for ten seconds then off for ten seconds. The output tag, in this case, is “LAD_OUTPUT”.

Ladder Logic is the foundation of programmable logic controllers, and the most widely used. People argue that anything can be programmed using this method and the other methods are not needed, which I support, although I will go over the other methods.

Ladder Logic Pros:

  • Well-organized code on rungs
  • Supports online changes well
  • Comments are visible and organized
  • Instructions take up little memory.

Ladder Logic Cons:

  • Some process control instructions are not available
  • Scanning issues can be created
  • Difficult for motion programming
  • Difficult for batch programming

Function Block Diagrams

Function Block Diagram
Figure 2: Function Block Diagram

The above image shows an example of the exact same program written in a function block diagram. With the function block diagrams, the user places instructions on a “sheet”, and one routine can have multiple sheets. Input instructions and output instructions can be anywhere on the sheet. To connect the input and output instructions the user places wires between terminals. The sheet is scanned “continuously”, meaning there is no discernable start and end, but that sheet 1 is scanned before sheet 2 and so on. The user must keep this in mind when using this method.

In the case of Figure 2, the input instructions Input Reference (IREF), and the output instructions are TONR (Timer On with Reset) instructions. TONR instructions are available in Function Block and Structured Text, but not available within the Ladder or Sequential Function Chart.

This is a good method to program motion controls. The user can setup ramps and s-curves for a VFD or servo motor.

Function Block Pros:

  • Good for motion controls
  • Good for low level signal processing
  • Visual method may be easier for some users
  • Wide instruction set

Function Block Cons:

  • Code gets disorganized
  • Sheets stack up and it gets tough to debug
  • Instructions take up more memory than in Ladder

Structured Text

Structured Text
Figure 3: Structured Text

This image shows the exact same program but written in structured text. The user writes every line of the routine(s) by hand. The keywords and instructions are blue, and the tags are colored red. The routine is scanned from top to bottom, left to right. The instruction set is similar to the instruction set for the function block diagram. As seen in Figure 3, the TONR instruction is used. Like function block, tags can be “wired” up to instructions by setting them equal. For example, in the above image, “ST_OFF_TIMER.TimerEnable” is wired to “ST_ON_TIMER.DN”. When this executes, that line of code will start “ST_OFF_TIMER” after “ST_ON_TIMER” is complete.

Structured text is only useful for a large amount of calculations. It is not recommended for anything other than setting tags to values. Sometimes, when editing online, the edits do not take and the user must download again.

If the user is familiar with programming languages such as Matlab, then they should be comfortable within this environment. Like in Matlab, the “:=” is to set “something” equal to “something”, and the plain equal sign is to compare a variable equal to a different variable or a constant.

Structured Text Pros:

  • Code is organized
  • User controls operations
  • Good for large calculations

Structured Text Cons:

  • Very abstract
  • Difficult syntax
  • Hard to debug
  • Hard to edit online

Sequential Function Charts (SFC)

Sequential Function Chart
Figure 4: Sequential Function Chart

The next figure shows an example of a sequential function chart. This is the same concept as a traditional flow chart. There are conditional objects (in this case called transitions), and action objects (in this case called steps). The transition objects appear like so:

Transition Objects
Transition Objects

and the steps like so:



The user places these at any point on the chart, and the chart size is variable unlike the fixed sheet size in function block diagrams. Each step can have a set of actions, which looks like this:

Step Actions
Step Actions

In that case, there is only one action, but each step can have multiple conditions. The user can split the sequence using branches of steps or transitions. The user wires the steps and actions using wire similar to the method in function block diagrams. A step HAS to be wired to a transition and vise-versa. Steps can’t be wired together in series neither can transitions. Steps and transitions can be wired in parallel to split sequence.

Each transition is a statement, not just a tag, and will allow the sequence to the next step when the transition yields true. Here are some examples:

Example 1
Example 1
Example 2
Example 2

The steps have built in timers using the configuration for each step. Look at the example here:

SFC Step Properties Window
Figure 5: SFC Step Properties Window

During online mode, the SFC shows the position of the sequence by putting a green box around the step that is executing. As seen in figure 4, step_000 is active.

The SFC in figure 4 does the exact same thing as the other programs do: it turns on and off the output tag for ten seconds if the trigger is pressed.

If the user is familiar with OPTO-22 programming, then they would be comfortable in this environment, as it is the same flowchart style programming.

SFC Pros:

  • Online mode offers easy debugging
  • Built-in timers for steps
  • Actions attached to steps in user specified order

SFC Cons:

  • Abstract code can get disorganized
  • Syntax can be difficult
  • Complex sequence to do simple tasks
  • Online editing is a challenge


Each method has their application and their strengths. Ultimately, the user must decide what environment they want to be in for the task they want to accomplish. It will depend on the user, and it will depend on the task. Luckily, AB controllers support all three.


For more information or to purchase a PLC module, please visit our home page here.

Wrapping Your Head Around Ladder Logic

The most important thing about learning to program PLCs is understanding ladder logic. Unlike other computer languages, ladder logic is graphical, meaning that the program is literally drawn out rather than typed. This can be confusing to programmers who come from a background in traditional languages, such as C or C++. You don’t get anything too fancy with ladder logic; rather, the graphical program is meant to represent a facsimile of a wiring diagram for traditional relay logic. Relays were used, and still are, to control various systems and these control systems are often very complicated. Engineers needed a way to represent the complicated arrangements and relationships in a relay control system, so the ladder logic representation was developed to make things clear. You will find schematic diagrams for relay racks written out using ladder logic notation to this day.

A relay is simply a switch that can be electrically actuated. So, before the days of PLCs, all control systems consisted of large racks of relays all wired to turn each other off and on according to the design of the system. Essentially the program was hard-wired into the physical relays themselves, and this approach is still preferred for some special applications. However, a giant rack of relays is not practical for most control systems, which is why the PLC was first developed as a direct replacement. Instead of opening up a panel to rewire a bunch of contracts, a PLC program can be altered simply and easily by a programmer, and then deployed to the device. The fundamental notation has not changed since the days of relay logic, but many new symbols and capabilities have been introduced, and PLCs have evolved.

PLC example
PLC example

At its heart, a PLC is a small, rugged computer, designed to replace giant banks of impractical relays. The program for a PLC can be thought of as a fully customizable relay rack contained entirely inside the device. It’s best to imagine relay logic in physical terms as if it were an actual schematic. The basic elements of ladder logic are designed to resemble an actual electrical circuit.

To begin, a PLC program is read from left to right and top to bottom. It resembles a ladder where the left rail is the high side, where the power comes from, and the right rail is essentially ground. In between are the rungs of the ladder, which represent the individual instructions of the PLC program. The two most basic symbols in ladder logic are the contact symbol and the coil symbol.


The contact symbol (Left), and coil symbol (Right)
The contact symbol (Left), and coil symbol (Right)

The amazing thing about relay logic is that very complex systems can be created with just these two simple elements. The contact’s job is to complete the circuit from high to ground. There are two types of contact, normally open, meaning that it behaves like a switch that is off by default, and normally closed, which is on by default. They behave as inputs and can be instructed to open or close in many ways such as a button, sensor, timer, counter, or most importantly by a coil. The coil is responsible for opening or closing contacts elsewhere in the circuit or at the outputs of the system. When energized, any contacts that are paired with the coil will be actuated.

The first and simplest program that everyone learns when starting out with PLC programming is the start and stop button example. Momentary switches are made to make contact only while the switch is pressed, they are most commonly found in the form of a button. Say we want to send power to a motor and we would like to start the motor using a switch. Ideally, we would like to have one big green button to start the motor and another big red button to stop it. But these buttons are momentary switches and they only send power while the buttons are held down, so how can we keep the motor running after we release the button? This is where relays come in. The great thing about relays is their ability to take momentary electric signals and turn that into all kinds of useful actions. Now we should mention, there are no actual relays inside a PLC, but the device is instead made to emulate the same capabilities as a traditional relay control system.

To begin the example, from left to right, two contacts are placed in series on the first rung, the first is normally open followed by a normally closed contact. The normally open contact is tied to an input connected to a momentary button that will serve as the start button. Likewise, the normally closed contact will be tied to the stop button. A coil is then placed after the two contacts which actuate the output to our motor. Finally, and this is the most important part, a third contact is placed in parallel with the start button and this contact is also actuated by the motor coil.

PLC Programming Example
PLC Programming Example

So now when the start button is pressed, power will go to the motor coil across the stop button, since that is normally closed. The motor coil will energize and send power to the motor, but at the same time the parallel motor contact will close and bypass the start button to keep the power flowing. The motor will stay on until the stop button is pressed which breaks the connection to the motor coil and releases the motor contact. This is the first example of what is known as a latching and unlatching system. The start button triggers the latching contact, and the stop button unlatches it. This is such a common configuration that specialized latching and unlatching coils are actually included.

Those familiar with traditional programming might recognize that contacts are a bit like “IF” statements. Placing them in a series is the equivalent of a logical “AND” statement while placing them in parallel is the equivalent of an “OR” statement. If a contact is normally closed, that could be thought of as equivalent to NOT normally open. So, if we were to read this rung as a traditional logical program it would sound something like this: “IF (start button OR motor contact) AND NOT stop button THEN motor coil.” So now we see why this is known as ladder logic. The contacts themselves are Boolean values and their arrangement forms the Boolean operators.

There are many more features and symbols of Allen Bradley PLCs that go well beyond simple contact and coil programs. There are tons of specialized modules for timers, counters, and analog sensors, which can add tremendous capabilities to your automation system. These are just the basics. Allen Bradley PLCs also include support for remote communication and other advanced features. Once you master the basics of ladder logic, you will be able to integrate more and more complexity into your automation systems and take full advantage of the features that modern PLCs have to offer.


For more information or to purchase a PLC, please visit our homepage here.

Importing UDT and Add-On Instructions From Later Versions of RSLogix 5000 to Earlier Versions

This procedure is not easily completed, however, there is a workaround that can be set up so that the UDT’s and Add-ON instructions do not have to be created from scratch all over again.

The problem usually arises when the user tries to export the objects in the later version of Logix, as these objects will not be compatible with the previous versions of Logix. If the source file was the same version as the target file, anything could be exported/imported between the programs; this is what will we will discuss in this tutorial.

With that being said, the first and most tricky step is to convert the program containing the required UTDs and AOIs to the targeted version of RSLogix. The final step will then be to export the objects and import them into the new program.

Back Converting The Source Program

For this tutorial, we will be converting a version 30 program back down to version 16.

Starting Project (version 30)
Starting Project (version 30)

The image above displays the starting source project. As seen in the figure, the version for this program is 30; this program also includes one add-on instruction and three user-defined tags within the project. The objective for this step is to have this program reverted all the way back to our target version of 16. The next steps are outlined below.

  • Backing up the source file: It is good practice to back up the source file. This would be the file that the needed add-on instructions and UDTs are in.
  • Saving the source project as an L5K file: For conversion, the project needs to be saved as an L5K file instead of the default ACD file version. To do this, click File -> Save As. When the file dialog box comes up make sure that you change the “Save as Type” to Logix Designer Import / Export File (*.L5K) as seen in Figure 2 below.

    Save-As File Dialog Box
    Save-As File Dialog Box
  • Editing the L5K file: Once the source file is saved as an L5K file it will need to be edited. There are only a few things that need to be changed in the file. The images below show the text that needs to be changed within the file.
L5K File Changes (1 of 2)
L5K File Changes (1 of 2)
L5K File Changes (2 of 2)
L5K File Changes (2 of 2)

IE_VER depends on the target version of RSLogix. When the targeted version is v16, then this needs to be changed to 2.7. See the table at the end of this tutorial for each version of RSLogix IE_VER variable. The rest of the changes are pretty self-explanatory; change the version numbers to the target version and change the processor to the target PLC.

  • Save the L5K file after you are finished editing it: Open up RSLogix 5000 (not Studio 5000) and click Open, then point the file picker dialog to the L5K file that was just changed.
Save As For Import
“Save As” for Import

After the L5K file is selected, a popup will show up, asking you what you want to save the newly converted project to. Verify that the Revision on the lower left of the popup is the correct target version. If it is not, the steps above will have to be repeated. If it looks good, click the import button.



This back-converting is not an exact science; you may encounter the above error, which involves a bit of know-how that is beyond the scope of this tutorial. The fix for this issue was to go to the Line number where the error happened and to delete the following two lines in the below figure.

Cleanup of Errors
Cleanup of Errors

Keep in mind that this L5K file is a backup of the source code, so don’t be upset or afraid to break it. A new copy can always be regenerated again using the source ACD file. That is why I had no trouble trying the idea of deleting these two lines; in my case, it worked.

Back-Converted Source Code
Back-Converted Source Code

As seen in the image above, the source is now at Version 16. At this point, the add-on instructions and the user-defined tags can be successfully exported and imported inside the target program by the usual means.

Exporting and Importing

Right-click the add-on instruction, export, and save the file. Then open up the target program and right-click on the folder where you want to drop the object (UDT or Add-ON) as seen in the images below. Complete this step for all of the objects that you want to export/import

Import Add On Instruction.
Import Add-On Instructions.
Import UDT
Import UDT


Import/Export Version Table

RSLogix 5000 Version Import Export Version
31.xx  2.22
30.xx  2.21
29.xx  2.20
28.xx  2.19
27.xx  2.18
26.xx  2.17
24.xx  2.15
23.xx  2.14
21.xx  2.12
20.xx  2.11
19.xx  2.10
18.xx 2.9
17.xx 2.8
16.xx 2.7
15.xx  2.6
14.xx  2.5
13.xx  2.4
12.xx  2.3
11.xx  2.2
10.xx  2.1
9.xx  2.0
5.xx  1.2
2.xx, 6.xx, 7.xx, 8.xx  1.1
1.21, 1.23  1.0
1.10, 1.11  0.4


Rockwell Technical ID: 33852
Converting a Project to a Previous Version


For more information or to purchase a unit, go to our homepage here.

Selecting the Right PLC for a Job

Anytime automation is required in any system or process, a Programmable Logic Controller (PLC) is often the most ideal solution. There are many things to consider when selecting a PLC for a given task or tasks. PLCs are best suited to rugged environments where there may be excessive dust, metal swarf, or moisture that could cause other types of control equipment to fail.

The most common task for PLC is taking input from sensors and activating or deactivating the outputs according to the inputs. They are also well suited for timing control, for systems like lights or motors. Allen-Bradley offers PLCs in all shapes and sizes from the MicroLogix series for small applications to systems like the ControlLogix for high-performance applications.


PLCs are generally housed in an enclosure to further protect the devices. When designing the control system you should pay attention to the dimensions of the PLC and how it is properly mounted. All Allen-Bradley PLCs offer convenient rack or rail mounting so they can be easily incorporated into a panel with other devices. It’s important to check the mounting style to ensure that the PLC will fit into your existing system. If you’re designing the panel around the PLC(s) then this is less of an issue, but it is more likely that you will need to integrate the PLC into an existing system, so it is worthwhile to ensure that it will fit.

MicroLogix 1000
MicroLogix 1000


One of the most important things to consider is how many inputs and outputs you will require to implement the control system. In general, the more I/O (Inputs/Outputs) a PLC offers, the more costly it can be. You don’t want to go out and get the largest PLC on the shelf and try to make it do all the work. PLCs are made to exist within a larger system and cooperate to achieve the goal of the larger system.

Having multiple PLCs is also important for reliability, as you don’t want multiple processes to be stalled because of a single point of failure. That said, you should still maximize the capabilities of each device and avoid leaving unused I/O.

The discrete inputs for a PLC are rated for a specific voltage range for either AC or DC voltages. Be certain which type of voltage you will need to register and that they are in the rated range of the inputs. PLCs can also offer analog inputs for things like thermocouples, RTDs, scales, and any other sensor device that provides an analog signal.

The PLC outputs are either relays or transistors that actuate or energize when instructed by the program. The relay type outputs can handle greater loads then the transistor type outputs however they have slower switching speeds. Systems like the CompactLogix or ControlLogix series offer many different input and output modules for your specific needs.


Allen-Bradley offers three different sizes of PLC; large, small, and micro. The ControlLogix series offers the most I/O and expandability for big jobs, while the CompactLogix series offers many of the same capabilities in for the medium sized jobs; finally, the MicroLogix series is sufficient for small jobs that only require simple I/O.


There is definitely a balance between reliability, redundancy, capability, and cost. As you design your system or process, think about how many PLCs you will require and where you feel comfortable dividing things into subsystems, each with their own PLC. Bear in mind that the largest PLCs typically offer up to a dozen or so inputs and outputs.

There are also modular PLC systems, such as the CompactLogix and ControlLogix series, that offer modules to add additional I/O or features. Most Allen-Bradley PLCs also include support for Ethernet and other forms of wireless communication. This can dramatically increase the versatility of the system and allow for remote control.

ControlLogix Series
ControlLogix Series

Performance and capability are also very important factors when selecting a PLC. You want to be certain that it has enough memory and speed to perform the given task. This can be tough to assess without a very good idea of what the program will be required to do. Here are some good questions to ask when assessing performance and capability requirements.

  • Does your application require a lot of floating point math?
  • Is PID control a requirement of the system?
  • Will the PLC be taking data inputs such as ASCII from things like bar codes or other alphanumeric sources?
  • Does the PLC need high-speed counters for things like encoders?
  • Will the PLC be controlling motor positioning or servo stepping?

Some PLC systems include modules that can increase the performance, memory and other capabilities. If you are not certain just how much performance and what capabilities you will require, it is a good idea to select a modular PLC system, such as the CompactLogix system or the ControlLogix system, as they can expand to meet your needs.

Environmental Factors

Environmental concerns are very important when selecting the right PLC for the job. If the PLC is expected to perform in environments with lots of dust, water, or metallic shavings, you may require a PLC rated for such conditions. If the PLC is operating in volatile environments, such as Class I, Division II, the PLC enclosure will need to be rated for explosion proof conditions.

Temperature is another major concern when selecting a PLC. Each PLC will include a specified temperature rating that the PLC is capable of operating over. If the environment temperature exceeds this range the PLC will not function properly and may be damaged. When the temperatures are expected to be very extreme a heater or cooling system may be required for the enclosure.

Most Allen-Bradley PLCs are rugged enough to endure temperatures from freezing conditions to those found on the hottest job sites. Finally, when designing your system, be certain that it complies with local and national electrical codes. Make sure to contact your local authorities to find out what codes you must comply with. Many PLCs are geared specifically to meet the needs of harsh environments and extreme temperatures.

CompactLogix Series
CompactLogix Series


There are several methods for programming a PLC. A PC computer is the most common method, however, most PLC systems offer handheld programmers that can be used on site without a computer. If you expect to be making modifications to the program in the field, make sure that your PLC supports handheld programmers. A computer is recommended for complex programs, and many technicians prefer to use a PC when implementing the program since it is often much more convenient. Allen-Bradley PLCs offer both options when it comes to programming your devices.

Picking a Module

There’s an Allen-Bradley PLC system out there for almost every application, environment, and budget. Modular systems like the ControlLogix series are a good way to ensure that you can dynamically add performance and capability to your system as new requirements arise.

For simpler applications, there are many small and micro control systems that offer minimal I/O. These can be a very cost-effective solution for automating small to medium tasks. Take care when selecting your system and make sure that you have made a thorough assessment of the requirements, to ensure you get the right PLC.

For more information or to purchase a PLC module, click here.

ControlLogix PLC Programming/Troubleshooting Guide

The objective of this guide is to give Allen Bradley PLC programmers a good start on the path to programming as well as to give the programmer some comprehensive troubleshooting concepts that will help if a program is not working as expected.

What you need to know:

There are a few platforms that Allen Bradley PLCs can be on and they are the following: RS Logix 5, RS Logix 500, Connected Components Workbench (CCW), and RS Logix 500 or Studio 5000. This tutorial will focus on RS Logix 5000 or Studio 5000. This is the latest platform that Allen Bradley PLC’s are on and supports ControlLogix, CompactLogix, and SoftLogix controllers.

Coding Environments

With Allen Bradley controllers, there are a few environments you can choose from: Structured Text, Function Block Diagram, and Ladder. You can have each routine as a different environment. For example, one routine could be a function block diagram and another could be ladder logic. There are additional instruction sets that are for function block only, for example, the enhanced PID instruction (PIDE) is only available inside function block diagrams.

The default environment is ladder logic, so this is what this tutorial is focused on. The assumption for this tutorial includes the following:

  • You have a program that is not working correctly or as it should.
  • You have the software, program file, and can get online with the controller. 
  • You know a bit about ladder logic and electrical engineering.
  • You know about basic data types: DINT, INT, SINT, REAL, and STRING
PLC Status Panel
PLC Status Panel


On AB Controllers there is a small key on the front face of the CPU. This key allows you to control the mode that the controller is in. There are three modes: Run, Rem (Remote), and Prog (Program). The physical key takes priority over what is set up in the software. If the key is in the program position, then the PLC cannot be put in run mode remotely using the Logix software. However, if the key is in the REM (or Remote) position then the PLC can be put into Program or Run remotely using the Logix software.

If you are having trouble trying to put the PLC in a different mode, the physical key may be overriding it. Unless there is a good reason not to, leave the key in Rem mode.

In the PLC Status Panel seen in the image below, the status of the key can be seen to the right of the window.

Key Status
Key Status

Controller Tags Window

To monitor, edit, delete or add tags to the controller using the Controller Tags window. To get to it, click “Controller Tags” inside of the Controller Organizer (I/O Tree).

Controller Tags Window
Controller Tags Window

Instruction Set Help

Allen Bradley offers a lot of great help every one of their built-in instruction sets. To get to it in the upper context menu, click “help”, then click “instruction help”, as seen in the example below.

Navigate to Instruction Help
Navigate to Instruction Help

Hardware Issues and the I/O OK Light

In Logix 500 there is a little indicator on both on the physical PLC and in the software program. It can be seen in the next image, below the “Energy Storage OK” indicator. This light indicates if there is a problem with the hardware connected to the controller; if you are having hardware issues that are global to a rack or a card – this would be the first thing to check. If the I/O light is blinking, you can scroll down in your I/O tree and the faulty module will have a little triangle with an exclamation point inside of it. If the light is solid then all of your I/O modules are recognized by the software and are not reporting any faults.

Cross Reference

In AB controllers, the cross-reference tool is your friend. You can highlight any tag in your controller, right click, and run a cross-reference on that tag. Another way to complete this is to highlight the tag and hit “control + e”.

Cross Reference
Cross Reference

The above image shows the exact menu selection when right-clicking a tag.

Cross Reference Window
Cross Reference Window

The cross-reference window as seen in the image above will show up when a cross-reference is run. All of the instances of that particular tag will be listed. In this case, a cross-reference on “On Switch” was run and there is only one instance of usage on this tag. If an instance is double-clicked, the software will take you to the place in the program that the instance occurs.

Continuous Tasks

Always avoid having continuous tasks. There is less predictability overscan time when a task is set up for continuous. A lot of times programmers will incorporate scan time-dependent logic into their routines, and if the scan time changes it will cause things to go haywire.

Program Structure

The structure of your program is very important. It is good practice to lay out the tasks and routines in how you would like them to be scanned. Your inputs tasks and/or routines should be at the top of the list, then the guts of the logic program, process control programs, or machine control programs, then your output routines. Here’s a good example of a good program structure.

Main Task (Periodic)

Input Program


(this routine will call the ones below it with a JSR instruction. Each program should have a main routine that calls all of the subroutines in the same order as they are listed)



Process Program



Output Program




Online Edits

In Allen Bradley controllers – the logic can be changed online. While online, it is a three-step process.

  1. Enable rung edits – Double-click the rung number that you want to change. After you do this the rung will have multiple “i” characters next to the rung number. Also, a new run will be inserted directly below the rung that you are editing and have multiple “r” characters next to the rung number. The one with the “r” characters is the original rung that you started with. The one with the “i” characters can be edited to correct the logic.
  2. Edit the logic
  3. Assemble the edits – There is a little icon in the top of the ladder editor that looks like this:

That is the “Finalize Edits” button. This will finalize all pending edits in the program. Once the edits are final the “i” and “r” rungs are replaced with the final rung and the new logic is running.

Scan Order

One of the biggest pitfalls of people switching to Allen Bradley controllers is to understand how the programs are run.

In general, the AB controllers scan the program how you would read a book: “left-to-right, top-to-bottom”. This is a good concept to keep in the back of your head when programming in this environment – THE ORDER YOU DO THINGS MATTERS. The program schedule matters, the order of routine calls matters as well.

Duplicate Destructive Bits and More on Scan Order

Destructive bits are instructions that write to tags. Having duplicate destructive bits for an OTE instruction causes unexpected and unwanted behavior. Consider the following program in the following image.

Duplicate Destructive Bit
Duplicate Destructive Bit

These rungs are taken from an online program, so the program is executing. You can see the “OnSwitch” is true, but why isn’t the OTE instruction for “Lamp” not on? Well, it is because of the rung below it. The Lamp tag is used in two separate locations. In the case of duplicate destructive bits, the last one wins. This is because even though rung 1 yields true, the rung right after it yields false, and will remain false until the scan comes back to rung 1.

Consider if the rungs were switched, like in the below image.

Duplicate Destructive Bit On
Duplicate Destructive Bit On

In this image, the OTE instructions for “Lamp” are on. This is because the last rung that uses the Lamp tag is true and remains true until the scan comes back to rung 1.

This is an important concept to keep in mind when programming because it applies to ANY instruction that writes values to tags. In this case, it is easy to see the problem when the two rungs are right next to each other, but when the rungs are in a different routine or even a different task it is not so obvious. If a cross-reference is done on this tag you can see that there is more than one destructive bit for this tag.

XRef Duplicate Destructive Bit
XRef Duplicate Destructive Bit

Seen in the image above, the tag has multiple OTE instructions, which is, again, not a good practice when writing programs.

Last thing on the scan order

Consider the following Rungs:

Lamp Delay
Lamp Delay

In this program, the Lamp will never turn on because the reset for the timer is before the Lamp output instruction.

A little about timers

The preset for timer instructions is ALWAYS in milliseconds. If the incoming value for a soft-coded preset is in seconds it will have to be converted to milliseconds. This is common when interfacing with an HMI or SCADA system.

We have covered a lot of things not to do, now let’s give you some good circuits/rungs to put in your program.

Start/Stop circuit

Good start/stop circuit
Good start/stop circuit

The image above shows how to construct a good start-stop circuit if your buttons are momentary. The Lamp tag is used in two places. One, for the output instruction (OTE) and one to latch in the circuit (XIC). Once the On-Switch is pressed the circuit will latch in. It will remain latched until the Off-Switch is pressed.

Start/Stop circuit with delay

Start/Stop with Delay
Start/Stop with Delay

The image above shows a start / stop circuit with a time delay. The lamp output will come on three seconds after the On-Switch is pressed. If it is desired to have the operator hold the button, then the branch with the LampTMR.TT XIC instruction can be removed.

State toggle off of a momentary bit

The Mysterious Toggle Circuit
The Mysterious Toggle Circuit

If you can figure out how this simple rung works – you have mastered the scan order in Allen Bradley controllers. The circuit shown in the above image will toggle the Toggle On bit when the Momentary bit is pressed. There is a duplicate destructive bit inside of this logic, but there are always exceptions to the rule not to use them. In this case, ONE_SHOT.1 is used twice but is critical in making this circuit work as expected. Going into why this is the case is beyond this tutorial but consider how the system is scanning and you can figure it out.

A little about ONS

The ONS instruction (or One-Shot Rising) will pass the signal once when the logic in front of it is true. This is incredibly useful when programming calculations that only need to be performed once for example.


“Stuff” happens, right? Controllers fault, sometimes it is after a change, other times it is when a pocket of logic gets enabled and it can appear at random.

With Allen Bradley controllers, when a fault happens all of the logic is stopped. Normally, the outputs go to a “safe state” value which is usually in the off position, 0V, or 4mA depending on the flavor of output.

Here’s what the software Status Panel looks like when a controller faults.

Controller Fault
Controller Fault

In the above picture, the Controller Fault status indicator is blinking. There is also a fault light on the physical controller that blinks to indicate it is faulted.

What to do?

It is important to remember to remain calm, and even though the first reaction is to “Clear the fault and get going again”, it is important to try and figure out why it happened to prevent the event in the future. In Allen Bradley controllers once you clear a major fault you can’t look back and see where it occurred. The process should be the following: Go To The Fault, Correct the Logic that caused the fault, clear the fault, go back to run mode.

First Thing – GO TO FAULT

Go To Faults Menu Selection
Go To Faults Menu Selection

The picture above shows how to get to the Go To Faults menu selection. Click on the controller Icon right next to the “Faulted” indicator and click on Go To Faults. This brings up the “Faults” tab in the controller properties window.

Major Faults Tab Inside of Controller Properties Window
Major Faults Tab Inside of Controller Properties Window

Within the window in the screen capture shown above, the Program, Routine, and Rung where the fault happened are listed. This tells where the fault happened. It also tells the fault type: in this case, the fault was “Code 20 – Array subscript too large, or CONTROL data type POS or LEN invalid”.

Second Thing – Correct Cause of Fault.

Fault Rung
Fault Rung

The above picture shows the rung that was causing a fault. Inspecting this rung, the programmer is using indirect addressing to index through an array called Shift Register. Looking at the Shift Register tag it is an array of DINTS with the length of 10 (0-9). Looking back to the fault rung the index tag value is a 10 which is outside the array. In this image, where the MOV (Move instruction) is, you should be able to see the “?” under the indirect indexed tag. That means that the controller doesn’t know what the value of the expression is; hence the fault.

To correct the error, let us add an LES instruction that will only pass if the index is less than the length of the array. We can add this online, but to assemble the edits we will have to clear the major fault, and since it is clear where it occurs that is not a concern.

Clear the Fault

Go To Faults Menu Selection
Go To Faults Menu Selection

In the above image, the Clear Faults menu selection is right above the Go To Faults menu selection. To clear the fault, click on it. After the fault clears, the controller remains in Program Mode. This is good because the error is not fully corrected yet.

Correct the Fault

Reset the Index value manually by typing in a zero into its value. Add the correction to the logic as seen in the screen capture below.

Corrected Fault Rung
Corrected Fault Rung

Put the Controller in Run Mode

The last step is to put the controller back to run mode. This can be done via the PLC Status Panel.

Why Isn’t This Working?

This is a question a lot of programmers ask themselves. A lot of times it happens in the installation of a new routine. Look at the following rung in the below diagram.

New Logic Routine
New Logic Routine

The rung logic is true but the OTE instruction for the Enabled bit is not coming on. A lot of times there is one simple answer: the routine is not being called. There needs to be a JSR (Jump to SubRoutine) to execute the new logic.

Inside of each Program configuration, you can specify the main routine that will automatically execute. Any routine other than the main in the same program is considered a subroutine and will have to get called from the main routine.

Program Properties
Program Properties

In the image shown above, the main routine for the “Machine Logic” program is “R000_MainRoutine”. When the program was created the Main routine is the first routine added in the program. This can be changed offline, not online.

Machine Logic Program Main Routine
Machine Logic Program Main Routine

The above image shows the logic rungs for the Machine Logic program Main Routine (R000_MainRoutine). There is only one subroutine being called which is “R100_Machine1”. For our new routine “R200_TempControl” to be executed a new JSR instruction will have to be added to the R000_MainRoutine ladder. You can add JSR instructions online. Once added, the main routine should look like the below screen capture.

New Routine JSR
New Routine JSR

Then, if we look back at the routine we want to execute in the image below.

New Working Routine
New Working Routine

Deleting Tags

Allen Bradley Controllers allow you to delete “some” tags online. They have to meet the following criteria though:

  1. The tag is not being used ANYWHERE in the program
  2. The tag is not being scanned from an outside source

It is the second one that gets most people. Outside sources could be an HMI through CIP or OPC, or maybe another PLC controller.

Produced and Consumed Tags

Allen Bradley Logix 5000 controllers give the user the ability to setup produced and consumed tags. Produced tags are tags inside a PLC that are available to other Logix 5000 controllers, and consumed tags are “proxied” tags from other Logix 5000 family controllers to the PLC. This offers a very seamless way to share data between controllers. One controller produces tags and any controller out there can be set up to consume that data. Setting this up inside controller(s) is beyond this tutorial but keep in mind that it is possible. Last note on this, some Allen Bradley controllers limit the number of “connections” to other devices through ethernet and Produced / Consumed tags do not take up a “connection”.

User Defined Tags (UDT)

Allen Bradley 5000 controllers allow the user to build their own data types. These are usually groups of standard datatypes but they can be cascading meaning the programmer can have a UDT inside another UDT. User Defined Tags are a very nice and useful feature because the programmer can set up template UTDs for devices and it offers consistent data structures for faster development both on the PLC side and HMI side.

Add-On Instructions

Add on instructions are pockets of logic abstracted into a general routine. Then, instances of these add-on instructions can be created. It is a little like a UDT but instead of having only a data structure it is a data structure AND logic. Creating these is beyond the scope of this tutorial.

Hopefully, this gave you some direction or some guidance for troubleshooting or programming an Allen Bradley 5000 family processor.


How to set up Communication between an Allen Bradley PLC and LabView, through Ethernet/IP


Industrial Ethernet protocols are basic tools for compatibility and network communication. They add characteristics for reliability with standard Ethernet/IP to communicate over single or interconnected networks (Internet). LabVIEW uses the Ethernet/IP driver to interact with objects in the CIP object module on a PLC. The list of controllers that support this protocol can be verified on the manufacturer’s website.

Step one: define the master device, aka the scanner, and the slave device, aka the adapter.

  • The Scanner Class, the “Master”, will initiate both implicit and explicit communication and commands.
  • The Adapter Class, the “Slave”, only sends data if the data is requested by a scanner (master). The adapter (slave) device does, however, support explicit and implicit messaging.
  • The Messaging class is used for on-demand data transfer applications or setup; this unit initiates data transfers by either device.

To ensure that the LabVIEW driver for Ethernet/IP can communicate with your device, make sure that the device can act as a scanner (master).

Step two: precisely define the type of the application being run:

  • Non-Real Time applications work with a standard TCP/IP, or UDP/IP for PLC to HMI, or PLC to SCADA.
  • Real-Time applications utilize COTS hardware for control data.
  • Hard Real-Time applications add specific hardware, such as distributed motion.

Step three: define the Ethernet/IP Terminology:

The first option, Explicit messages, use TCP/IP and are used to set parameters and initiate implicit communication

The other option, Implicit messages, use UPD/IP Multicast; these messages are used to communicate I/O data and are normally set up for cyclical updates.

Step four: go over Ethernet/IP Allen Bradley protocol considerations:

It is the principal bus for Rockwell Automation, managed by Open Device Vendors Association (ODVA) that allows the DeviceNET concepts to expand to Ethernet, using a transport layer (TCP and UDP), although it can potentially overload networks with UDP messages.

Step five: installing the LabVIEW Ethernet/IP Driver:

In order to establish communication with a Rockwell Automation Logix PLC (or any Allen Bradley PLC), the user has to begin by installing the drivers in an NI Measurement & Automation Explorer, specifically onto the real-time target. When using a real-time controller, use the “Add/Remote” software tab in the “Measurement & Automation Explorer” software.

Use the “Add/Remote” software tab in the “Measurement & Automation Explorer” software
Use the “Add/Remote” software tab in the “Measurement & Automation Explorer” software.

The Ethernet/IP driver interface provides VIs for communication to “Logix” PLC tags; the VIs can both write and read tags on Allen-Bradley CompactLogix and ControlLogix PLCs. This application will run on the LabVIEW program for Windows and the LabVIEW Real-Time OSs (Phar Lap and VxWorks).

Phar Lap and VxWorks
Phar Lap and VxWorks  
PLC Blockchain connection example.
PLC Blockchain connection example
PLC Blockchain connection example no. 2
PLC Blockchain connection example no. 2

This interface offers the simplest method to connect to Rockwell PLCs since LabView starts the communication and there is no need to change the PLC code. This driver has numerous advantages when working with a low number of tags, although it should generally not be used for higher counts. The driver uses TCP/IP and does not actually require IGMP snooping, which is usually used in order to prevent flooding of a network. One drawback of this driver is that it has an inefficient method for the packing of data into Ethernet, producing a slower communication and increased processing loads on the PLC. This driver also does not provide support of third-party EtherNet/IP or SLC devices.

Explicit Messaging

Both I/O data communication and several formats of explicit messaging are supported by this drive. A wide range of Ethernet/IP devices and Allen Bradley PLC devices are supported by this driver for extensive data sharing and communication. To write or read to a target, the VI’s use explicit messaging connections.

To write or read to a target, the VI’s use explicit messaging connections.
To write or read to a target, the VI’s use explicit messaging connections.

Tag Read/Write and SLC500 Read/Write. This option serves to directly access the data fields that are stored on the given PLC. To register files, the target must support Messaging class communications using either Multiple forms of PCCC communication or Logix tag names. Some of the targets that support message formats of this type include a variety of PLCs, such as Rockwell’s CompactLogix series, the ControlLogix series, the MicroLogix series, and the SLC 500 series.

The Get/Set Attribute: single VIs offer channels to interact directly on an Ethernet/IP device with individual instances of objects within the CIP object model. While some classes of objects are standardized, others are device-specific. In order to tell which class and attributes are necessary to operate the controller, the user should utilize the information that is provided in the device’s user manual.

I/O Data

Another option offered by the Ethernet/IP solution is the VI’s on the palette that give the LabVIEW system the ability to function as an adapter for a remote PLC, as well as to create an I/O assembly. This is a kind of communication named “Class 1”, or alternatively, “I/O Server Communication”, in which the device appears to be a remote I/O to the PLC, allowing it to be addressed in the ladder logic application as if it is a local I/O. The PLC is permitted to set up an implicit I/O data connection with LabVIEW through a Class 1 Protocol, which also allows the PLC to exchange assembly data at a specific rate, assemblies being memories that are used to manage data from the PLC. Through this protocol, the data can be exchanged in the background in series.

Implicit I/O data connection with LabVIEW
Implicit I/O data connection with LabVIEW

Several additional VIs can be added for Ethernet/IP scanner and message modes; these can be found listed below.


VI Add-ons
VI Add-ons
VI Add-ons no. 2
VI Add-ons no. 2
  • CIP Sync: this add-on is based on IEEE 1588 and provides a shared clock to devices.
  • CIP Motion: this add-on builds on the previous one, CIP Sync, in order to perform distributed control for motion; this device uses clock sharing as an alternative to QoS.
  • CIP Safety: this add-on builds on DeviceNet safety, intelligent devices with time out parameters.

Step six: Go Over the System Requirements

Before anything else, ensure that your Allen Bradley device will actually be able to communicate over Ethernet/IP. Many of the Allen Bradley devices come with RS485 ports, which is the same port found on most Ethernet cables, but it is used exclusively for Modbus or Series communications rather than Ethernet/IP.

The required Ethernet/IP driver is supported on a Windows device running LabVIEW, as well as LabVIEW Real-Time systems. Some of the supported systems include Compact Fieldpoint, NI Smart Cameras, Desktop PCs, Compact Vision System, NI Industrial Controllers, Embedded Vision System, CompactRIO, and PXI Controllers.

The installation of the driver component into the target should be handled through the “Add/Remote” Software tab in “Measurement & Automation Explorer.” Before beginning, ensure that the correct software is installed on your computer in order to manage the Allen Bradley Controllers. Some software options are RSLogix 500 or RS Linx, or Studio 5000, as well as Drives Executive, Connected Components Work bench, or Studio 5000 for drives.

Step seven: configure the IP address and subnet for your PC

We’re almost finished; before the final step, make sure to connect to the device either through an unmanaged switch or directly. Your PC should also have a static IP address.

Connect through un-managed switch or directly.
Connect through an un-managed switch or directly.

Step eight: configure the IP address and subnet for your PLC

The final step is to set up and configure the Allen Bradley PLC, either using the BootP software utility or manually. Manual setup is typically completed through USB ports, switches, or a logical HMI; manual setup is device specific, although instructions can usually be found in the user manual that comes with the device.

Configure IP address and subnet for the PLC.
Configure the IP address and subnet for the PLC.

Once the processor has been powered up and is connected to your computer, we can begin the process of adding the device’s address. Follow the BootP requests in order to do this; then make an Ethernet/IP driver in RSLinx on a local subnet. This processor will show up in RSLinx, and functions like putting the processor online, or ControlFLASH, will become available at the end of this step.

Once the PC has been configured for a static IP address and the device is configured, a connection should be possible.


For more information or to purchase a PLC, click here.

How to Program a PLC 5/40 in RSLogix and What Cables are Needed

This article will serve to answer the above prompt, which is how to program a PLC 5 family of logic controllers using RSLogix. This article will not explain how to program specific functions using different combinations of bits used with Allen Bradley (AB) programmable controllers; instead, this article will focus on how to communicate to an AB PLC, and what cables are required. We will also outline some of the important aspects that should be kept in mind when programming to the older programs like RSLogix5, versus the newer RSLogix5000.

To start programming an AB PLC, we must first set up the computer being used on the same subnetwork as the device. So if our PLC is, for example, on an IP address of, we can set up the computer’s Ethernet/LAC adapter to (as long as that IP address is  NOT taken elsewhere within the system). Once we have confirmed that the computer is ready to be programmed, we should always ping the device in the command prompt and establish a communication path with the PLC. Once communication is established, the next step is to set up the RSLinx drivers.

RSLinx is the proprietary software of AB for communication to their devices. It offers many different drivers but if using Ethernet/IP, which is by far the most popular communication protocol used in industry, we can use the Ethernet driver or the Ethernet/IP driver within RSLinx. The ethernet driver in RSLinx is used to manually define the IP of the device, so then you will look specifically for that device and no other. It takes a few additional steps, but it does help. since you are defining the exact IP to the device you wish to program. When it comes to huge plants that may be using nearly all of the available 255 IP address’ in the subnetwork 192.168.1, it helps to define the specific device, but the easier option is the Ethernet IP driver. This driver scans all available devices on the subnetwork you are on and will display all available devices. The image below shows some of the IP address I have manually set within RSLinx in the ethernet driver. To add a new address type in the IP address and apply the addition.


The hostname is where you put the IP of the device you wish to program to while the station describes which position it is on the list of Hostnames.
The hostname is where you put the IP of the device you wish to program to, while the station describes in which position it is on the list of Hostnames.

Once you have set up the computer and configured the RSLinx drivers then we can open our RSLogix 5 program and make the changes and download them to the PLC. You can confirm if you configured the drivers properly by opening RSWho in the communications tab in RSLinx and opening the driver tree and confirming that you don’t get a red X across your device which shows that you don’t have a defined communication path to the PLC. The next image below shows the RSWho window.

RSWho window to confirm communications with the PLC by opening the plus box and expanding the organization tree of the driver.
RSWho window to confirm communications with the PLC by opening the plus box and expanding the organization tree of the driver.

Now we have officially set up the computer and RSLInx to communicate with a PLC to be able to program through an ethernet cable. But let’s detail some of the main differences between the older PLC5’s that use RSLogix5 (which has since been obsoleted by AB) and ControlLogix or CompactLogix, which are the newer family members of the PLC5/40, and which use RSLogix5000. The biggest difference between the two is the actual act of programming to the PLC5; the older version of RSLogix uses bit addressing for programming, while the newer PLC use alias’ to program the ladder logic. “Bits” are binary or float values; for example, if we defined the float value F8:1 in RSLogix as a pump start command, then whenever I program a “bit” I must remember and input the address F8:1. As you can imagine it becomes tedious to go back and look at all the different bits as you code big programs with lots of bits; but RSLogix5000 allows you to provide an alias and program to that alias. So instead of remembering that F8:1 is my feed pump start command, I can name the bit “Feed_PU_start”. Then I input that alias and it will know which bit I want to use in my data files.

Another huge difference is the requirements and importance of an offline program. As we program, we tend to describe each bit, allowing that description to pop up above the bit as we program. This becomes important when trying to read the logic and understand the functionality; however, the older PLC programs require that you have an offline version of the code to upload to or go online with to keep those comments. If you try to go in blind and upload the program from the PLC. Instead of seeing all your descriptions you will only see the bit addressing, similar to F8:1 mentioned above. Then without the comments and descriptions, you have no idea what the program is doing when it is functioning. The newer version of AB PLC saves all descriptions and offline information into the CPU in the PLC rack. But should you need to program an old PLC that has not been upgraded non-obsoleted PLCs then you can follow the above steps to setup your computer to be able to program the PLC as needed.

How to Set Up the Host Computer for Programming

To first communicate to an AB PLC, we need to understand the communication protocols that are used within the industry. Without a doubt, the most popular method of communication is through Ethernet/IP protocols. This communication protocol requires every device to be assigned a unique IP address, which is the means of communicating with that device. For this example, we are going to use the IP for our AB PLC and for our programming laptop. To be able to communicate with this PLC, we need to be on the same subnetwork, which in this case is the non-routable base subnetwork of 192.168.1. Thus if we want to be able to communicate with the PLC without any other major communication protocol, we must put the programming computer onto the same subnetwork of devices and choose a unique IP address which we assigned above as To do this you must change your adapter settings. The most common adapter name that needs to be changed is the Local Area Connection (LAC), or Ethernet adapters. You will need to go into the adapter properties and choose TCP/IPv4. Within this property, we choose to assign our IP address manually, which we will set as for this case. Then we need to set the subnet mask to This subnet mask allows us to use the exact subnetwork 192.168.1 (described by the 255.255.255) that each of those number must be exactly the same but the 0 allows us to scan different devices within this subnetwork of devices on the 192.168.1 subnetwork.  This is shown in the image below for reference.

Within the network connection I opened my ethernet adapter properties, went into TCP/IPv4 and set my IP address manually.
Within the network connection, I opened my ethernet adapter properties, went into TCP/IPv4 and set my IP address manually.

Now that we have set up our computer to be able to communicate to the PLC on the subnetwork we have to be sure we have an established communication path. Most commonly you will go into an ethernet switch that is connected to the PLC through an ethernet card with a Cat5 (standard ethernet cable). Be sure that you have a good ethernet cable and plug it into your computer and the ethernet switch or port that has a path to the PLC. To confirm we have a good communication path to the PLC we can try pinging the device. This is a method for the computer to send information to the device and see if it responds and confirms that we have an established communication path to the PLC. This is done through by opening the command prompt in your computer. This can be done by opening the start menu and searching for command prompt or CMD. When this has been done we need to put in the command to ping the device. That command is “ping”. This will send four data packages and confirm if communication is established. The image below shows an example of pinging a device and what is confirmation that you have a good communication path and what confirms you don’t have a communication path and you need to be sure your cable is good and that your computer is set up as we did above.

The red portion shows an unconfirmed communication path while the blue is a confirmed path. The IP addresses are different than our example because I am on my home subnetwork and needed to show both examples.
The red portion shows an unconfirmed communication path while the blue is a confirmed path. The IP addresses are different than our example because I am on my home subnetwork and needed to show both examples.

Once we have an established communication path,  our computer is prepared to be able to program.


For more information or to purchase a PLC, please go to our homepage here.

An Introduction to PLC programming

A PLC or Programmable Logic Controller is an electronic or computer device used for industrial control systems; using types of software, the PLC runs a program that manages inputs and logically turns outputs on/off to obtain the desired control. This article will cover the general structure of a PLC program.

PLC programming
PLC programming

Instructions and programs

An instruction or job order is formed by two main parts: operation and function. The function is the complement of the operation and is divided into symbol and parameter. The operation determines the CPU’s job or the kind of instruction that it must execute, and the function determines the address. The address, in turn, indicates where the CPU should execute the instruction of elements such as counters, timers, I/O, and internal marks. Basic examples of instructions are:

LD: (4C) Loads the line

LDN: (42) Negation of the operation LD

AND: (41) AND logic

ANDN: (44) Negation of the operation AND

OR: (4F) OR logic

To write a program, other kinds of instructions called service instructions are required. These are used to elaborate and analyze the program, among other things.

Program Execution

When the PLC is set in RUN mode, the PLC takes a snapshot and the analog and digital inputs values are saved in a memory table, the CPU executes the program contained in the user memory from the address 000 to the last one, the resulting values from the logic instructions and operations go to the output memories and written in the output modules, then the PLC restarts the process and check for faults; this is called the scan cycle format. Most of PLCs follow the positive logic convention: True=Logic 1 = Input energized, False=Logic 0=Input not energized.

We can distinguish between the following programming structures according to the way the CPU executes or runs the program:

  • Linear execution, where the cycle is run line-by-line. The instructions contained in the memory are read sequentially until the end of the program and the resulting values are written in the output memories.
  • Execution with a conditional jump, where the program can alter the sequence based on a condition. If the condition is true, the program jumps to the line determined; then the program continues the normal sequence. This allows the possibility of reducing the execution time of the cycle.
  • Execution with subroutines, where there is more than one sequence with the same instructions. It is easier to write the subroutine once and load or call it anytime it is required.

Programming Languages

Each manufacturer determines the unique characteristics of their equipment and the programming language that they use to provide the programmer with an easy tool and environment to solve industrial logic problems. In general, programming languages are textual, graphical, or both. Textual languages use instruction lists and structured text while graphics languages and graphic methods use networks of contacts or blocks that represent a logical or arithmetic expression.

  • Ladder language or KOP.

Ladder language and contact diagrams use a network of relays or contacts, like an electrical circuit that represents a logical expression, which makes it easier to understand and work. The system is based on opening and closing the relays to give the system the ON/OFF control it requires for automation and manufacturing processes.

  • Boolean or AWL

It is possible to implement complex algorithms and operations in AWL since it is a machine level language an offers more flexibility and freedom of programming.  These expressions are based in Boolean or algebraic logic and instruction lists, for example:

LD: Loads an open contact or line

LD NOT: Loads a closed contact or line

AND (Y): Open series contact

OR (O): Open parallel contact

AND NOT: Close series contact

OR NOT: Close parallel contact

OUT: Output relay

MEM: Intern relay or memory

TMR: Timer

CNT: Counter

Program Elements Assignment

It is important to assign the proper names to the elements of the program in such a way that  helps us to maintain order and structure and does not incur mistakes or repetitions. We can elaborate a table with the description of each element. For example, inputs should be named as IN1, IN2, IN3, etc; outputs should be named OUT1, OUT2, OUT3, etc; timers should be named: TIM1, TIM2, TIM3, etc; counters should be named CNT1, CNT2, CNT3, etc; and memories should be named MEM1, MEM2, MEM3, etc.

Considerations before starting programming:

  • Programs are made from left to right and from up to down.
  • The number of contacts that we can assign from the beginning of the main line until the output is unlimited.
  • It is preferable to write a clear circuit with a higher number of contacts rather than a complicated program, even if it contains a lower number of contacts.
  • We can not connect an output directly to the main line, as this would put a closed contact between the two.
  • The number of open or closed contacts that we can use in a program is unlimited.
  • The number of outputs is fixed, but the contacts associated with those outputs are unlimited.
  • Although memories are not external outputs, they work in a similar way and are used as auxiliary relays.

Most PLCs are protected against power outage, so they do not lose their state; there are also other PLCs with more special functions like the change of time bases for timers.


For more information or to purchase a PLC unit, go to

Manufacturing Automation: Integrating the Future

From looms to robots, humanity is in constant pursuit of ways to enhance lives with machines.

Though the term “automation” was coined in the automotive manufacturing industry back in the 1940’s, it has become applicable to nearly every sector of the global business economy. Its definition is too-often misconstrued as the replacement of human workers with machines, though in actuality automation refers to the integration of machines into a self-governing system. As automation becomes more prevalent, human workers are challenged to assimilate their robot counterparts and expand their skillsets into realms beyond what has ever been required in their chosen professions. At the same time, businesses across the global manufacturing sector must thoughtfully adopt automation in a manner which creates maximum value for their organizations.

From Mechanization to Automation

Jacquard Loom
Jacquard Loom – Image credit: Northampton Silk Project

According to Mikell P. Groover, author of “Automation, Production Systems, and Computer-Integrated Manufacturing”, automation grew from mechanization, which is the replacement of human or animal power with mechanical power. While humans have always possessed a propensity for fashioning tools to enhance their work, mechanization is traceable to the days of the first Industrial Revolution, which began in the late 1700’s. Back then, the invention of the steam engine kicked off a series of discoveries including the use of feedback in the establishment of automated control systems, as well as the first programmable machine, the Jacquard loom.

Considering the predecessor to today’s digital computer, the Jacquard loom revolutionized textile manufacturing with its use of pre-made punch cards to control complex weaving patterns, automating a production process that was once almost entirely people-driven. In addition to the introduction of automated control, the Jacquard loom represented a turning point in the human-machine interaction, as the worker’s role elevated from hands-on operation to encompass more planning and oversight of the loom’s work.

The image to the left is a model of the Jacquard loom, on which you can see the punch cards hung in preparation for feeding into the top of the machine.

Progress in Automation Technology

During the 20th century, several technological developments drove the progress of automation technology across the spectrum of global industries:

  • The invention of the digital computer – Namely, the Electronic Numerical Integrator and Computer (ENIAC) in 1946, and the Universal Automated Computer in 1951.
  • Advances in data storage capability – Rapidly advancing from punch cards, modern-day storage consists of magnetic and optical forms of media whose capacities are dense yet rapidly readable.
  • Improvements in programming methods – Modern programming languages constantly evolve to allow for greater logic capabilities while becoming more accessible through simplicity and ease of use.
  • Development of enhanced feedback sensors – Essential to automatic feedback control systems, sensors make possible industrial tasks such as quality inspection and robot guidance.
  • Evolution of advanced mathematical theory of control systems – This theory includes negative feedback control, adaptive control, and artificial intelligence (AI).

As the above advances came to fruition, the global manufacturing industry underwent two additional industrial revolutions that, while less well-known as the first, were just as impactful. These are described by Bill Pollock, President and CEO of Optimation Technology Inc., as having occurred in the early and latter parts of the 20th century. The second industrial revolution was ushered in by the marriage of electricity with the assembly line, and the third took place as computers became common fixtures on factory floors.

Efficiency of Machine Technology
Efficiency of Machine Technology – Image credit: AIA

Industry 4.0

Industry 4.0 is the popular term for the fourth industrial revolution, a time of technological disruption the manufacturing industry is currently undergoing. It is marked by the growing use of robotics, adoption of 3D printing capabilities, virtual reality’s leap from gaming rooms to factory floors, and the introduction of the Industrial Internet of Things (IIoT). The IIoT, also known as the Industrial Internet, consists of interconnected devices that monitor, collect, exchange, analyze, and deliver data for the purpose of driving business decisions.

According to Pollock, Industry 4.0 is defined by:

  • Interoperability – connection of machines, devices, sensors, and humans through the IIoT
  • Information transparency – a collection of vast amounts of data from the manufacturing process
  • Technical assistance from AI – shifting the role of humans from operators to problem solvers
  • Decentralized decisions – autonomous systems capable of operating without human intervention

The growing use of automation is a binding thread throughout the fabric of Industry 4.0, as executives and workers in the manufacturing sector determine how to deploy and integrate automated systems in accordance with the above four principles.

The Future of Automation in Manufacturing

Findings in a report by McKinsey, a global research firm, reveal that “manufacturing is second, among industry sectors, only to accommodation and food services in terms of automation potential”. With this potential comes pressure to adopt automation as rapidly as possible, for the sake of remaining competitive in the era of Industry 4.0. Based on their research, McKinsey recommends company executives take into account three fundamental perspectives when deciding where and how much to automate:

1) what automation is currently making possible

2) likely possibilities as the technology evolves

3) factors besides technical feasibility

Adapting and enhancing the human workforce is key to realizing the full, long-term potential of manufacturing automation. Just as the Jacquard loom allowed a person to elevate their role above handling a shuttle and lifting threads into place, automation is poised to revolutionize the very definition of what it means to be employed in the manufacturing sector. McKinsey states, “Particularly in the highest-paid occupations, machines can augment human capabilities to a high degree and amplify the value of expertise by freeing employees to focus on work of higher value.” To support this optimistic assessment, companies must commit to managing near-constant change with a focus on fostering a culture of inclusiveness, and by providing training to help employees keep up with constantly changing technologies.

Though industrial revolutions are considered times of disruption, one need not view Industry 4.0 as a threat to the global workforce. A look back at our history reveals that technological enhancements, from steam engines to automated weaving machines to computer-controlled manufacturing systems, have not only enhanced the state of the global industry, but also the lives of humanity at large.