Cookies are important for this site to function properly, to guarantee your safety, and to provide you with the best experience. By clicking OK, you accept all cookies. For more information, please access our Privacy Policy.
Table of Contents
Tutorials / 
Structured Text Example for Input & Output Tag Aliasing Assignments
Intermediate

Structured Text Example for Input & Output Tag Aliasing Assignments

PLC Programming
Allen Bradley
RSLogix 5000
Studio 5000
Structured Text

Introduction

One of the ways we utilize Structured Text to speed up machine development is through input and output assignment. In a typical system integration environment, one would have to create a rung dedicated for every input and output in order to pass the data to an internal tag of the PLC. The reason for this practice was discussed in a tutorial on tag aliasing we've released before. In short, by doing so, we can easily reassign and expand our tags as the program changes.

Input and Output Tag Assignment in Ladder Logic

As you design a new piece of equipment or system, it's important to keep documentation of every point of input and output. More often than not, this documentation would be kept in an Excel spreadsheet and used by electricians during the installation phase and by engineers during the commissioning phase. In other words, it's a list of all the inputs and outputs of the system identifying their location and what they're connected to in the field.

By using Structured Text over ladder logic in this specific case, programmers can create simple string manipulations in Excel and implement the entire tag architecture through copy pasting entire routines. Furthermore, by taking this approach, it becomes much easier to make changes to an existing system and to export the information of data into other structures or databases.

Creating Input and Output Documentation for Each Slot

In a control system, you'd typically expect to see a number of input and output points coming back to the main controller or PLC. In Allen Bradley based systems, as well as many others, this would translate to receiving points of inputs and outputs on the main chassis or a remote block through PointIO, FlexIO or other means. Regardless of where the point is being received, it has to be documented on electrical drawings as well as startup-checks for field personnel. SolisPLC integrators often provide these checklists to electricians and engineers to facilitate system installation and commissioning.

The list is simple; it lists the name of the card, its location, each point of IO and all the details associated with it. Here's a simple example of what this may look like. It can be further expanded into including the physical location of the component, part number and more.

Output assignment Excel example for a local 16 point card

The same list at the one above will be created for each card in the system. Note that investing time in such documentation will aid your engineering and maintenance teams now and in the future. We've received a lot of praise for providing this to our customers when it should be standard in the industry.

Excel / Google Sheet String Manipulation for Structured Text

We typically use Google Sheets for all our documentation. It allows us to easily collaborate and share information among our engineers as well as the customer.

Google Sheets provide simple string manipulation functions similar to Excel. To create our Structured Text strings, we will be using the CONCATENATE() function. In short, it allows the user to combine multiple strings into one.

Drawing on the knowledge we've acquired from our first tutorial on Structured Text, we can automatically create tag assignments as well as comments for every boolean of data as we see fit.

Example 1 - Output 0

Output Local Tag (PLC side)= LocOut[0].0

Output (card side) = Local:1:O.Data.0

Description = "Stack Light - Red"

Structured Text = Local:1:O.Data.0 [:=] LocOut[0].0; //Stack Light - Red

Using CONCATENATE, the formula to generate the above becomes:

=CONCATENATE(C3, " [:=] ",B3,"; //",E3) where C3 = Local:1:O.Data.0, B3 = LocOut[0].0, E3 = "Stack Light - Red"

By dragging the formula down, it's possible to reapply the exact same pattern to each cell and automatically generate an array of Structured Text blocks for each input and output card within the system.

Structured Text Implementation & Modifications

Once the structure is completed in Excel or Google Sheets, it becomes extremely easy to transfer it into the PLC program. Simply copy and past the last column we've created into a Structured Text routine and compile. All the appropriate tags would have been assigned and commented based on your list. Here's an example of the routine based on the previous spreadsheet:

Local:1:O.Data.0 [:=] LocOut[0].0; //Stack Light - Red

Local:1:O.Data.1 [:=] LocOut[0].1; //Stack Light - Yellow

Local:1:O.Data.2 [:=] LocOut[0].2; //Stack Light - Green

Local:1:O.Data.3 [:=] LocOut[0].3; //SV1010

Local:1:O.Data.4 [:=] LocOut[0].4; //MTR1003

Local:1:O.Data.5 [:=] LocOut[0].5; //SPARE

Local:1:O.Data.6 [:=] LocOut[0].6; //SPARE

Local:1:O.Data.7 [:=] LocOut[0].7; //HTR1001

Local:1:O.Data.8 [:=] LocOut[0].8; //HTR1002

Local:1:O.Data.9 [:=] LocOut[0].9; //HTR1003

Local:1:O.Data.10 [:=] LocOut[0].10; //SPARE

Local:1:O.Data.11 [:=] LocOut[0].11; //SPARE

Local:1:O.Data.12 [:=] LocOut[0].12; //SPARE

Local:1:O.Data.13 [:=] LocOut[0].13; //SPARE

Local:1:O.Data.14 [:=] LocOut[0].14; //SPARE

Local:1:O.Data.15 [:=] LocOut[0].15; //SPARE

In addition to ease the initial deployment of the system, the method described above would provide a simple way of modifying the system. Instead of going through electrical drawings an engineer may determine that there are spares on multiple output points directly from the spreadsheet, create appropriate tags in Excel and import them into the PLC programs.

On the maintenance side, we've seen customers request a part number of the field devices associated with each output. When the device would fail, technicians could easily refer back to the documentation on the spreadsheet as well as within the PLC in order to figure out what they needed to purchase for a replacement.

Conclusion

Documentation is key for control system development, commissioning and maintenance. By leveraging string concatenation in a spreadsheet environment (Excel or Google Sheets), one can easily create strings users can export into Structured Text programming environments. This process reduces the time it takes to create ladder logic rungs, facilitates system maintenance and troubleshooting.