Programming PLCs: A Technical Summary with Siemens Examples

Programmable logic controllers (PLCs) are ruggedized microprocessor-based electronics essential to all modern automation, including:

  • The process-heavy industries of oil and gas, nuclear, steelmaking, and wastewater treatment
  • Industries with an emphasis on control of discrete tasks — including general factory automation, automated warehousing, packaging, food and beverage, and medical-device manufacture

In these installations, PLCs are traditionally found on DIN-rail mounted or control-cabinet rack systems with slots to accept PLC modules (having CPUs to run logic and dispatch commands) and complementary power supply modules, application-specific function modules, and digital as well as analog I/O modules.

Of course, PLCs aren’t the only option for automation control. Relay-based systems maintain their indispensability in a vast array of applications, and programmable automation controllers (PACs) or industrial PCs (IPCs), as well as panel PCs (HMIs with control electronics), are other alternatives for many machine designs and systems needing varying degrees of distributed control. PACs and IPCs running industrial-grade Microsoft Windows OSs especially offer top design flexibility.

Each of these control systems is configured and programmed with software of diverse sophistication to render all types of control design more advanced and user-friendly than ever. This in turn allows OEM machine builders and plant engineers to quickly institute system builds, upgrades, and migrations with maximal efficiency, productivity, and IIoT connectivity.

The tools to program controls — including PLCs

Programming PLCs: A Technical Summary with Siemens ExamplesFigure 1: PLCs offer all the strengths of purpose-built hardware — including reliability. In contrast, PACs offer top flexibility. Some suppliers allow engineers to program both control types in the same unified software environment. Such environments can also impart unrestricted access to digitalized automation, engineering, and operational monitoring tools. (Image source: Siemens)

Nearly all PLCs today are configured and programmed through PC-based software. Large vendors with broad programmable motion control, sensing, actuation, and machine-interface component offerings (in addition to general automation and PLC products) typically allow programming of all these components in their own proprietary unified programming environments — PC-based Windows-compatible software with design, configuration, programming, and even operating and management modules. That’s especially true where vendor lineups include pre-integrated offerings — such as smart motors or HMIs having PLC functionality, for example.

While potentially daunting to learn, unified programming environments (once mastered) dramatically speed machine design.

One benefit of such software environments is how they provide error-free, editable, and universally applicable databases of symbol, variable, or tag names. These are human-readable alphanumeric names assigned to the addresses of components (including PLCs) and improving upon the direct use of complicated register addresses — which was once standard practice. Complementing these sortable and searchable device tags are informative machine and workcell tags as well as those for common machine functions such as Auto, Manual, MotorOn, Fault, or Reset.

Consider Siemens STEP 7 Totally Integrated Automation (TIA Portal) software, which includes various use-specific packages and is accessible through the Siemens SIMATIC (Siemens Automatic) software-management environment. STEP 7 software is convenient for illustrating the most common approaches to PLC programming, as it’s the most widely used software in the world for industrial automation — with copious verification of functionality and reliability. By most estimates, Siemens PLCs are employed in nearly one-third of all PLC installations worldwide.

With this software, engineers can create process control, discrete automation, energy management, HMI visualization, or simulation and digital-twin programming related to the functions of PLCs and other industrial controllers. For PLCs, Siemens’ STEP 7 (TIA Portal) engineering software evolved from legacy SIMATIC STEP 7 software to support the programming of S7-1200, S7-1500, and S7-1500 controllers — as well as ET 200SP I/O CPUs and legacy S7-300 CPUs (an enduring industry staple) along with S7-400 and SIMATIC WinAC controllers. Professional-grade and specially licensed copies of STEP 7 include additional functions, logic editors, and integration of traditional engineering software.

Though beyond the scope of this article, it’s worth noting that industrial control alternatives to multi-function PLCs are configurable and programmable through complementary software. The vast ecosystem of Siemens controls provides copious examples.

  1. LOGO! logic modules satisfy small and modest automation applications to bridge the gap between relays and microprocessor-based industrial controllers. They’re programmed via Siemens LOGO! software with Soft Comfort engineering software, a LOGO! Access Tool, and a LOGO! Web Editor for simple configuration and design operation.
  2. Process control systems employ Siemens SIMATIC PCS 7 controller products programmable through SIMATIC PCS 7 system software.
  3. Rack (rail), panel, and box industrial PC (IPC) products for distributed controls and machines needing IIoT connectivity rely on Siemens SIMATIC IPC software modules, including an IPC Image and Partition Creator; IPC DiagMonitor; IPC Remote Manager; IPC FirmwareManager; and the SIMATIC Industrial OS.
  4. HMIs serving as panel PCs for on-machine controls employ SIMATIC WinCC Unified (TIA Portal) software as well as SIMATIC WinCC (TIA Portal), WinCC flexible, WinCC V7, WinCC OA, ProAgent process diagnostics software, notification software for mobile devices, and more.

Choosing between SIMATIC PLCs and other machine controls is simplified with still more software — in the form of an online cloud-based Selection Tool (or the offline variation) that asks engineers about a given design’s physical arrangement (whether necessitating a control cabinet or distributed control) and:

  • The number of anticipated I/Os including sensors, switches, and actuators.
  • The programming language to be used, whether ladder diagram (LD), structured control language (SCL), or Function Block Diagram (FBD); more advanced structured text (ST), graph-based sequential function chart (SFC), and continuous function chart (CFC); or more advanced languages.
  • The level of motion control required (where applicable) — from simple speed and position control to Electronic camming and advanced kinematic controls.
  • The hardware preference and whether a software PLC program running on an IPC might be most suitable.

PLC Program Projects

PLC programming written in PLC supplier software is often contained in projects. These are associated with focused application-specific operations such as:

  • Heating, mixing, filling, metering, and irrigating
  • Moving, steering, cycling, positioning, and braking
  • Gripping, cutting, punching, and slicing
  • Welding, gluing, marking, and dispensing
  • Sensing, tracking, sequencing, and indicating

The most advanced options support digital planning and integrated engineering as well as transparent operation that’s easily accessible through HMIs with user-specific screens one in operation. In other words, such PLC software can allow for the presentation of pertinent PLC information on different displays to serve the divergent informational needs of machine operators, technicians, plant managers, or even business managers.

Simulation tools within PLC supplier software environments also can speed time to market for a given product — and boost throughput of finished product. Completing the suite of software-based improvements are energy-management functions and diagnostics.

Verifying and loading PLCs with programs written in software

Programming PLCs: A Technical Summary with Siemens ExamplesFigure 2: Siemens SIMATIC PLC and automation systems were first introduced in the 1950s. Today, SIMATIC S7 products (including the SIMATIC S7-1500 PLC components shown here) have evolved to support various industrial automation applications. (Image source: Siemens)

Core to optimal PLC functionality is the quality of its programming. All code should satisfy software-development industry standards and best practices. Beyond that, verification processes (both manual and automated) can reveal everything from critical errors to code inefficiencies. Reconsider the programming of SIMATIC S7 products. Within the Siemens ecosystem, a TIA Portal Project Check application can automatically compare certain code against rules defined by a programming style guide for these specific PLCs. Then engineers can export comparison results to an XML or Excel file. User-defined rule sets (even complex types) can also be added via a Project Check software development kit (or SDK) in C# or Visual Basic (.NET). This SDK primarily proofs a program’s style.

Programming aspect Goal Quality Realization • Tool
Style Comprehensibility Empirical Code review • Style check
Technique Conformity Pragmatic Static code analysis • Lint
Technique fficiency Pragmatic Dynamic code analysis • Profiling
Test cases Functionality Syntactic Function test • Unit/integration test
Mathematical model Correctness • completeness Semantic Formal verification • Model check

Table 1: Verification of PLC programming can leverage manual and automated approaches — with the latter especially useful for verifying style and technique. (Chart source: Siemens)

After a project destined for a PLC is fully written and verified, it must be loaded onto that PLC. In many cases, a PC (often a laptop) is temporarily connected to the PLC via an Ethernet cable or a specialty PC USB to PLC COMM adapter — to load that programming onto PLC microelectronics. The PLC then connects to controlled components via I/O modules. After additional verification upon startup, the PLC executes its programs by commanding networked actuators (via various signal types) and making real-time adjustments in response to returned feedback from field devices.

Occasionally, a machine or automated workcell will require adjustment, troubleshooting, or repair — and (through some type of programming PC connection to the PLC) the overriding of PLC default responses to feedback with forcing. This “tricks” the PLC into operating as if certain feedback is at some value when it isn’t — a tactic employed when the stations downstream of a malfunctioning actuator must be cleared, for example. Other times, a machine or workcell might require in-field adjustment of an installed PLC’s parameters via modifying. Such adjustments must reference suitable triggers, variable values or tables, counters, and timers.

Conclusion

Working with the vast array of Siemens automation and industrial-controls offerings can provide design engineers with a deeper understanding of today’s control options — including PLCs and other hardware types. That’s true no matter the brand or hardware subtype ultimately chosen for an automated installation.