How to choose the correct programming language

What kind of applications and operations best fit which of five IEC 61131-3 programming languages? Depending on what you’re doing, relay ladder logic could be wasting significant time and effort.

By Fred Habenschuss December 29, 2011

Choosing a control programming language most suitable for the task at hand reduces program complexity and troubleshooting/maintenance costs. It will also make the code more readable, improve the development process, and enhance controller performance.

The first step in solving discrete, process, batch, drive, safety, and motion control challenges is to ensure the language editors for relay ladder logic (RLL), function block diagram (FBD), sequential function chart (SFC), and structured text (ST) programming are native to your programming software and controller. Then, use the chart below to best match the task to the appropriate language.

When a section of your code represents the following, select:

Relay Ladder Logic (RLL) for:

  • Continuous or parallel execution of multiple operations (not sequenced)
  • Boolean or bit-based operations
  • Complex logical operations
  • Message and communication processing
  • Machine interlocking
  • Operations that service or maintenance personnel may have to interpret to troubleshoot the machine or process
  • Servo motion control

Function Block Diagram (FBD) for:

  • Continuous process and drive control
  • Loop control
  • Calculations in circuit flow

Sequential Function Chart (SFC) for:

  • High-level management of multiple operations
  • Repetitive sequences of operations
  • Batch process
  • Motion control sequencing (via sequential function chart with embedded structure text)
  • State machine operations

Structured Text (ST) for:

  • Complex mathematical operations structured text
  • Specialized array or table loop processing
  • ASCII string handling or protocol processing

For example, it’s possible to use relay ladder logic for complex data handling, such as sorting algorithms. This process would work but take weeks (and potentially hundreds of rungs of code) to program. This would be time-consuming to write and maintain, less readable, and require extra time in the controller to scan and execute. Using structured text for this task is more suitable, making programming a complex, bubble-sorting algorithm simple, straightforward, and more efficient, approximately 10 lines of code with less impact on controller performance.

This is just one example of choosing the right programming language for the right task. Mixing and matching programming languages in a project to meet an application need is an essential competency of your programming software. Some programming software will allow, within the same project, programming for a batch operation in SFC, pump station in FBD, conveyor system in RLL, and a complex mathematical algorithm in ST.

– Fred Habenschuss is commercial engineering manager, Rockwell Automation.

www.rockwellautomation.com 

See other articles related to the January 2012 cover story on automation programming. Edited by Mark T. Hoske, CFE Media, Control Engineering, www.controleng.com.

Also see the PAC and PLC Channel at https://www.controleng.com/PLCs