Program development: How to simplify a complex system

Control systems engineers work on processes that can be incredibly complex. The interactions of process, operator, environment, and control systems can produce at time a dizzying and bewildering array of outcomes.


"If you can't explain it simply, you don't understand it well enough." - Albert Einstein

We, as control systems engineers, work on processes that can be incredibly complex.  The interactions of process, operator, environment, and control systems can produce at times a dizzying and bewildering array of outcomes.  We make every effort to anticipate and manage those outcomes, but as systems grow more complex, the ability of even the most thorough engineer can fall short.  Add to that the growing tool sets available to us, such as the IEC 61131-3 programming languages, utilities that permit the use of pre-programmed code blocks, and the ability to manipulate our control processors down to the operating system level, and the internal complexity of our controls only adds to the overall system complexity.  Modern control processors have given us a Swiss army knife with a thousand blades to help us, and a thousand blades we can cut ourselves with, too.  Though not specifically about controls, a recent piece by Quinn Norton, “Everything is Broken,” touched on this phenomenon.

It is incumbent upon controls professionals, in my view, to find the simplicity hidden in the complexity of the systems we design and program.  Updating Einstein’s maxim:  If you can’t program it simply, you don’t understand it will enough.  Failing to do so does a disservice to our clients, users and, ultimately, to our profession.

An automotive company had a paint booth whose color-changing logic was so complex and convoluted that no one could add, remove, or edit a color.  In this case, the complexity was deliberate, the programmer doing so in the expectation that he would be needed to make any color table changes, thus making himself indispensable to the facility.  The facility engineer spent days unraveling the code and rewriting it to something understandable.  The original programmer was  then sent away for good.

A biotech firm had a machine with a simple sequence.  However, the company insisted that it be programmed using a number of pre-programmed code blocks ill-suited to the task rather than simple ladder logic.  The programming effort required many times what would have been otherwise needed to remove the vast majority of the functionality of the blocks, and the result was a “black box” program that was unable to be monitored or maintained by site personnel.

So, how does one distill simplicity down from a complex system?  Here are a few rules I’ve developed to make programs easier to understand and maintain:

1. Know your audience.  This is the prime directive of programming.  Will your system be maintained by engineers, technicians, or electricians?  What is the level of familiarity with the platform being implemented?  What languages are plant personnel comfortable with?  Handing over something that is coded at a level far above the ability to maintain it is no different from delivering system documentation written in Klingon. 

2. Keep tag names descriptive but short.  Long tag names can be as cryptic as ones that are too short, and tend to limit the amount of code viewable when troubleshooting.  Save the prose for the element descriptor.

3. Break the problem into small pieces.  Even the most complex system can be subdivided into smaller problems that are easily comprehensible.  Take the time to plan your work by chopping a Godzilla-sized task into dozens of gecko-sized ones.

4. Use fall-through programming.  Logic for the beginning of the process should be close to the top of one’s application, programming for the tail end near the bottom. Conditions that are used at a particular point in the program should be defined above that point.

5. Avoid indexing.  Using arrays or tables with pointers is a good way to reduce code size, but it’s also a good way to make a program difficult to monitor.  Unless absolutely necessary, do not use arrays.

6. Keep the use of pre-programmed code blocks limited.  These code blocks can be great shortcuts for simple devices, like motor starters or valves, and can actually improve program clarity.  But if they become too large, their functionality can become uncertain and even dependent on configuration.  Blocks can cause large portions of a program to become a black box to a troubleshooter or editor.

7. Limit the use of unfamiliar languages.  If the plant is only versed in ladder logic, using large swaths of structured text can be vexing.  If such programming is called for, do all that can be done to keep it limited and document the call to the code well, explaining what it does, what the inputs to the code are and what can be expected for the output.

8. Document, document, document.  Aside from the usual element, rung and section comments, take the time, in the very first section of the program, to tell a future user about anything you may have done that differs from the machine default.  This may include I/O scan settings, fault condition setup, program execution interrupts, etc.  You found it important to modify these things and he may find it important to know about them.

We know our business well.  Let’s prove it by making what we do look easy.

This post was written by Bradley Ems. Bradley is a project manager at MAVERICK Technologies, a leading automation solutions provider offering industrial automation, strategic manufacturing, and enterprise integration services for the process industries. MAVERICK delivers expertise and consulting in a wide variety of areas including industrial automation controls, distributed control systems, manufacturing execution systems, operational strategy, business process optimization and more.

No comments
The Engineers' Choice Awards highlight some of the best new control, instrumentation and automation products as chosen by...
The System Integrator Giants program lists the top 100 system integrators among companies listed in CFE Media's Global System Integrator Database.
Each year, a panel of Control Engineering and Plant Engineering editors and industry expert judges select the System Integrator of the Year Award winners in three categories.
This eGuide illustrates solutions, applications and benefits of machine vision systems.
Learn how to increase device reliability in harsh environments and decrease unplanned system downtime.
This eGuide contains a series of articles and videos that considers theoretical and practical; immediate needs and a look into the future.
Controller programming; Safety networks; Enclosure design; Power quality; Safety integrity levels; Increasing process efficiency
Additive manufacturing benefits; HMI and sensor tips; System integrator advice; Innovations from the industry
Robotic safety, collaboration, standards; DCS migration tips; IT/OT convergence; 2017 Control Engineering Salary and Career Survey
Featured articles highlight technologies that enable the Industrial Internet of Things, IIoT-related products and strategies to get data more easily to the user.
This article collection contains several articles on how automation and controls are helping human-machine interface (HMI) hardware and software advance.
This digital report will explore several aspects of how IIoT will transform manufacturing in the coming years.

Find and connect with the most suitable service provider for your unique application. Start searching the Global System Integrator Database Now!

Infrastructure for natural gas expansion; Artificial lift methods; Disruptive technology and fugitive gas emissions
Mobility as the means to offshore innovation; Preventing another Deepwater Horizon; ROVs as subsea robots; SCADA and the radio spectrum
Future of oil and gas projects; Reservoir models; The importance of SCADA to oil and gas
Automation Engineer; Wood Group
System Integrator; Cross Integrated Systems Group
Jose S. Vasquez, Jr.
Fire & Life Safety Engineer; Technip USA Inc.
This course focuses on climate analysis, appropriateness of cooling system selection, and combining cooling systems.
This course will help identify and reveal electrical hazards and identify the solutions to implementing and maintaining a safe work environment.
This course explains how maintaining power and communication systems through emergency power-generation systems is critical.
click me