IEC 61131-3, already well established in Europe, is rapidly spreading in North America and Asia as the programming standard for industrial and process control. Why? These days, control and automation systems are increasingly complex. IEC 61131-3 allows designers to program complicated systems without spending needless time, money, and effort to develop and maintain their software. The programming language improves software life cycles — making requirements analysis, design, construction, testing, validation, installation, operation, and maintenance easier. In fact, this maintenance improvement may be the most helpful feature, as control-software maintenance (including upgrades) often requires more than 20 times the labor of initial programming.

Control programs can run distributed and independently rather than concentrated in large controllers. No longer are thousands of lines of control programs required to run into one controller for complex automation applications; this boosts reliability and simplifies programs.

Within control programs, IEC 61131-3 provides multilanguage support. So, control program developers can select the language best suited to a particular task to increase productivity. Too, the IEC 61131-3 standardized programming interface is completely independent of the hardware platform, so users can also reduce the cost of program maintenance and training across company-wide automation applications.

Again, IEC 61131-3 is hardware independent. It transports automation solutions to other platforms better than PLC applications — so users and system integrators gain reusability. Too, IEC 61131 increases the efficiency of implementing new automation solutions by using readily available control components developed on other projects and by outside developers.

Technology overview

IEC 61131-3 was established by the International Electrotechnical Commission (IEC) — a worldwide standards organization recognized in the controls industry by over 50 countries. As the international standard for programmable controller programming languages, it specifies the syntax, semantics, and displays for PLC Ladder Diagram, Sequential Function Charts, Function Block Diagram, Structured Text, and Instruction List programming languages.

What's with IEC 61131-3's dash-3 suffix? IEC 61131-3 is actually Part 3 of the larger, officially defined IEC 61131 code, which includes a general overview, and then sections on hardware, programming languages, user guidelines, and communication. For technical applications, it's most useful to understand the standard's common elements and programming language functionality. Let's review those now.

Common elements

Data typing is one element of the standard; its purpose is to prevent errors early in development. Data typing defines parameter types to be used, and stops errors like dividing dates by integers, for example. The different types of data it supports are Boolean, Integer, Real, Byte, Word, Date, Time of Day, and String. IEC 61131-3 also allows users to define their own variables for data typing. Called derived data types, these let engineers define analog input channels as data types and reuse them over and over again.

Another element, variables, are assigned to explicit hardware addresses, or explicit inputs and outputs. These can be assigned in custom configurations and programs. The system is independent and able to function with little to no messaging from an external network, so each variable has a scope. These limit their variables to the organization units in which they're declared — so their names can be reused in other parts without any conflict or errors. Variables can also have global scope. In this case, they're declared as such, and their parameters are assigned initial values at startup and restart.

Taking it from the top

At the highest level, the entire software required to solve a particular control problem can be formulated as one configuration: A configuration is specific to a particular control system type, including the arrangement of the hardware — including processing resources, memory addresses for I/O channels, and system capabilities.

Within one configuration, designers can define multiple resources. These resources can be thought of as processing facilities able to execute IEC programs. So within one resource, one or more tasks can be defined. Tasks control the execution of a set of programs and/or function blocks. These can either be executed periodically or upon occurrence of a specified trigger. For example, in an IEC 61131-enabled drive, when rpm falls below a predefined value, a trigger can be set to increase speed. Results are instant and come directly from the drive. There is no lag or handshaking by an external PLC, so there is almost no risk of miscommunication or losing a message. Feedback is nearly instantaneous, compared to a programmable controller with an I/O and program scan-time.

Programs are built from a number of different software elements written in any IEC-defined languages — Ladder diagrams, Sequential Function Charts, Function Block Diagrams, Structured Text, or Instruction List. It's typical for programs to consist of series of highlevel functions blocks written in one or more of these languages.

Program organization units

Within IEC 61131-3, the programs, function blocks, and functions are called program organization units. IEC 61131-3 includes defined standard functions instances, ADD, ABS, SQRT, SIN, and COS. Or, designers can create custom function blocks and reuse those. Function blocks (software objects with increased levels of detailed control) can contain data as well as algorithms. As software objects, these blocks have well-defined interfaces and hidden internals. This creates a clear line between the different program levels — a characteristic that reflects a best practice of object-oriented programming principles.

Function blocks can be written in any of the IEC languages — in most cases, even in C. Programs can also be written using the any of the above-mentioned basic building blocks. Here, sequential function charts control the sequential behavior of a control program and support synchronization and concurrency.

Programming languages

Within IEC 61131-3, the syntax and semantics are defined for five standard programming languages, leaving no room for dialects. This isn't a limitation, because once they're learned, the syntax and semantics can be used on a wide variety of systems based on the IEC 61131-3 standard. Designers are free to choose the programming language based on their knowledge, the problem at hand, external components, interfaces, or even personal preference. Also, all the languages are linked and provided a common suite to provide a universal communication tool. Because of this structure, built-on functions, and function blocks, users can adopt either a top-down or bottom-up strategy to develop their own programs.

What is CoDeSys?

CoDeSys, short for Controller Development System, is one of the most widely used IEC 61131-3 programming tools for controllers. Developed by Smart Software Solutions GmbH, or 3S, Kempten, Germany, CoDeSys supports all five programming languages of the standard to combine the power of advanced programming languages such as C or Pascal with the handling and operational functions of PLC programming systems.

Unlike other tools, CoDeSys produces native machine code for many common processors. Native machine code is inherently faster and more reliable than interpreted solutions. Other benefits:

Fast customization

Complete test adaptation (including online functionality) can be done on any standard processor hardware within two days, and CoDeSys has ready backends for all current processors. To minimize customization time and resulting expenses, its code generation and run-time and programming systems are coordinated.

Easy to use

Functions such as Autodeclare, Autoformat, and a context-sensitive input assistance simplify the use of CoDeSys. All functions are accessible by keyboard. The tool is efficient because it requires few resources.

High performance

Native code generators for all common processors optimize control-system usage. Intelligent algorithms such as incremental compile assemble large projects with thousands of global variables and hundreds of components quickly. Almost all data types specified in the IEC 61131-3 are accommodated; other features include offline simulation and online breakpoints, single stepping, power flow, sampling traces, and online changes.

For more information on using Freescale processors with embedded open IEC 61131 control software, visit www.rtaautomation.com or call John Rinaldi at (414) 453-5100.

Cutting down on traffic

Using a free, open source, designers can now program Banner SureCross wireless gateways to manipulate data like a PLC.

Real Time Automation recently created the solution for Banner Engineering Corp., Minneapolis, and their wireless product development partner, Sensonix Inc., Plymouth Minn. using CoDeSys 1131-3 open control software. Through a customizable browser-based HMI interface, users can access and manipulate data from multiple wireless sensors.

Placing PLC functionality on the gateway reduces network traffic and can eliminate the need for a PLC in some applications. This reduces the footprint and cost of automating applications. In addition, the browser-based functionality allows users the ability to access data from any internet connection.