Despite its importance, there are no rigid, set-in-stone rules for PLC programming organization. The organizational method described below is one that is commonly used by large machine builders; however, there are other techniques you can choose to employ. The key objective in program organization is to make a machine easy to troubleshoot and modify.

Using Zones in PLC Programming Organization

Zones can be used as a logical division of groups of cells. All the mechanism-operating auto sequences can be placed within the cells. The primary reason for dividing a machine into zones is to allow the zones, or groups of cells, to act autonomously. In this way, zones can be thought of like separate machines. Zones will often each have their own safety circuits so if a guard door opens, for example, it only shuts down the group of cells in that zone. Subsequently, there may be programs within the Main Task called Zone_1, Zone_2, and so forth. Within the programs may be Input, Output and Fault routines, as well as routines that link to all of the cells assigned to the zone. Data acquisition and productivity information may also be assembled at the zone level. Generally, the inputs and outputs would only be those that affect all of the cells, such as safety or indication I/O. A zone may also have an HMI that only controls devices within the zone; HMI bit mapping could also then be contained in the Zone program and routines.

Below are examples of layout templates at the Zone level and cell level.

sample plc programming layout template

Pictured above is a sample layout template from the zone level.

sample plc sequences at cell level

The layout to the left illustrates sequences in the Cell level. (Disclaimer: the b_Inputs/c_Outputs/d_AutoSequence rungs are not in the best order. They should be listed as b_Inputs/c_AutoSequence(s)/d_Outputs instead) 

The Importance of PLC Programming Templates

Start with a basic programming template. If you have the opportunity to use various platforms, develop your own templates to outline programs for each. Start with the basics: standard mode control logic, structures for input and output rungs, sample fault routines, and some basic data collection. This standardization will make it easier for others to troubleshoot and modify your program.

As you advance in your programming expertise, develop more in-depth template or consider creating a tag generation program using macros in Excel that allows you to automate the generation of HMI tags, permissives, faults, data collection and subroutine structures, which is definitely a time-saver!

Tag Names and Descriptions

Naming conventions for tags vary depending on the industry or business’ preference. Process industries, for example, tend to prefer ISA definitions and Piping and Instrumentation Diagrams (P&ID) designators. These tags include a mix of four-digit numerical tags, like “8454” and standard definitions, such as “PIT, EU, PSHH”. One downfall to this numerical system is that these tags must often be clearly defined and documented on the machine or system itself for interpretation, otherwise troubleshooting and modifying the programs can be problematic for new technicians or programming consultants.

Tag names are long enough that clearer definitions are possible. Custom machine builders often use more descriptive naming conventions, including: Extend – Retract, Advance – Return, Raise – Lower, Advance – Home, Rotate CW – Rotate CCW, On – Off. Thus, a tag built upon a “Assembly-Device-Action” description may represent “Locator Cylinder Advanced Proximity Switch” as “LocCylAdvPX”.

Time is money, and the more obscure your tagging system, the longer it takes new programmers, technicians or outside consultants to get up to speed. As long as abbreviations are consistent and documented clearly, you should be in good shape.

plc tag names and dotfields

Pictured in the upper right corner in the screenshot above is a clip from a SLC500, showing the Symbol and Description for an N7 (signed integer) register. While the address can be typed into the program either as N7:40 or TOT_060_FT52, only the address of N7:40 is present in the PLC processor. The symbol is a sort of shortcut or mnemonic to make it easier to find and organize.

The clip on the left side of the image above shows a UDT called “CakeRecipe” which is used to create the elements Flavor, LbsFlour etc. in the tag ModRecipe.

Converting Register-Based Platforms to Tag-Based Platforms

Older programs, such as those written for SLCs and PLC5s are register-based platforms, while newer programs, like ControlLogix, are tag-based. In tag-based platforms, you will see a database of text addresses for each data value. If you are converting from an older, register-based platform to a newer tag-based system, the symbol, if a symbol is defined, will automatically be used as the tag name. If a symbol is not used, the tag name defaults to a non-descriptive tag, something like “N7_40”, using the example in the screenshot above.

There are a few limitations to note in converting system tag names. First, register-based SLC symbols are limited to 20 characters in length and do not contain dotfields (the part of the tag that follows the period – often used for Add On Instructions or User Data Types) outside of those built into the datatype (such as a timer preset, T4:58.PRE or TDL_101_GS01.PRE as a symbol), while ControlLogix tags are limited to 40 alphanumeric characters not including the dotfield.